我们都知道,VectorDraw Developer Framework可以对3D视图进行随意裁切。下面我将用 vdCurve object 裁剪一个多面体,并用这个对象在多面体上裁切圆形或矩形等形状。
从VectorDraw v6.024开始,添加了以下方法到vdPolyface object:
1
2
3
4
5
6
7
|
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:
1
2
3
4
5
6
7
8
|
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对象的创建非常有用。
下面绿色的曲线是vdArcs,红色的矩形框是由cmdBox创建的:
在rendermode下经过四次剪切后的效果:
下图中绿色的部分是vdRect objects,红色的部分是由cmdBox创建的多边形盒子,同时在中间添加一个圆:
同样,在rendermode下经过五次剪切后的效果如下:
当然还可以作出更复杂的效果,如红色的椎体和绿色的折线结合: