文檔首頁>>VectorDraw Developer Framework使用教程>>VectorDraw Developer Framework使用教程:如何裁切多面體
VectorDraw Developer Framework使用教程:如何裁切多面體
我們都知道,VectorDraw Developer Framework可以對3D視圖進行隨意裁切。下面我將用 vdCurve object 裁剪一個多面體,并用這個對象在多面體上裁切圓形或矩形等形狀。
從VectorDraw v6.024開始,添加了以下方法到vdPolyface object:
summary>Cuts this polyface using the passed vdCurve object. param name="curve">A vdCurve object to be used in order to cut the polyface. You can use a circle , rect , ellipse , polyline and cut a polyface object. param name="sideToKeep">A gPoint in WCS that represents the side of the polyface to keep.This point is relative to the vdCurve object. param name="CreateCoverFaces">A boolean value representing if extra faces will be added in order to cover the cutted edges. param name="CreatedFacesEdgesVisibility">A boolean value representing the edges visibility of the created cover faces. returns>True if the command was succesfull. public bool Cut(vdCurve curve , gPoint sideToKeep , bool CreateCoverFaces ,bool CreatedFacesEdgesVisibility)
同時還要添加一個方法到vdDocument object的CommandLine:
summary>Changes the passed polyface so it is cut with the passed curve. A point is also asked to determine which part of the polyface will be kept. param name="polyface">The polyface object to cut OR null , "USER" so the user picks the polyface. param name="curve">A vdCurve object OR null,"USER" so the user picks the curve. param name="sideToKeep">A gPoint object or null,"USER" so the user picks a point on the screen. This point represents the side of the polyface that is going to be kept. param name="CoverFaces">A boolean value OR null,"USER" so the user is prompted for a Yes/No answer. This boolean value represents if cover faces are going to be created where the polyface is going to be cutted. returns>True if the command was succesfull. remarks>This command is very usefull in order to slice a polyface with a curve and create various 3D objects. You can also use closed curves like circle,rects etc.. to create holes to a polyface. public bool CmdCutPolyface(object polyface, object curve , object sideToKeep , object CoverFaces)
這個命令可以以這種形式進行調用:doc.CommandAction.CmdCutPolyface(null, null, null, true);
空參數會迫使庫提示用戶選擇一個多面體、曲線和點。這個命令對于3D對象的創(chuàng)建非常有用。
下面綠色的曲線是vdArcs,紅色的矩形框是由cmdBox創(chuàng)建的:
在rendermode下經過四次剪切后的效果:
下圖中綠色的部分是vdRect objects,紅色的部分是由cmdBox創(chuàng)建的多邊形盒子,同時在中間添加一個圓:
同樣,在rendermode下經過五次剪切后的效果如下:
當然還可以作出更復雜的效果,如紅色的椎體和綠色的折線結合: