VectorDraw Developer Framework使用教程:如何裁切多面體
我們都知道,VectorDraw Developer Framework可以對(duì)3D視圖進(jìn)行隨意裁切。下面我將用 vdCurve object 裁剪一個(gè)多面體,并用這個(gè)對(duì)象在多面體上裁切圓形或矩形等形狀。
從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)
同時(shí)還要添加一個(gè)方法到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)
這個(gè)命令可以以這種形式進(jìn)行調(diào)用:doc.CommandAction.CmdCutPolyface(null, null, null, true);
空參數(shù)會(huì)迫使庫提示用戶選擇一個(gè)多面體、曲線和點(diǎn)。這個(gè)命令對(duì)于3D對(duì)象的創(chuàng)建非常有用。
下面綠色的曲線是vdArcs,紅色的矩形框是由cmdBox創(chuàng)建的:
在rendermode下經(jīng)過四次剪切后的效果:
下圖中綠色的部分是vdRect objects,紅色的部分是由cmdBox創(chuàng)建的多邊形盒子,同時(shí)在中間添加一個(gè)圓:
同樣,在rendermode下經(jīng)過五次剪切后的效果如下:
當(dāng)然還可以作出更復(fù)雜的效果,如紅色的椎體和綠色的折線結(jié)合: