VDF常见问题整理(二十八):如何对多个顶点进行圆角处理?
VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。
VectorDraw Developer Framework试用版下载
点开本篇文章,是否对矢量图形工具感兴趣呢?来看看最新的矢量图形工具测评吧!点击此处>>即可直达哦!
问:
我正在创建带有某些顶点的折线,并希望使用FilletRadiousAtIndex方法对圆角进行切角,例如段0、1和2,但是我的代码无法正常工作。我怎样才能做到这一点 ?
答:
FilletRadiousAtIndex方法如果成功,则将向折线添加一个新顶点,并且(可能是封闭的)它也可能改变点的顺序。因此,像您发送的代码那样的代码将无法工作,因为首次调用FilletRadiousAtIndex会改变点的顺序,因为需要添加新的点,因此,您不能使用像这样的代码:
poly.FilletRadiusAtIndex(radious,0); poly.FilletRadiusAtIndex(radious,1); poly.FilletRadiusAtIndex(radious,2);
您需要遵循以下代码中的其他方法,请参见以下代码:
private void button5_Click(object sender, EventArgs e)
{
vdDocument doc = vdFramed1.BaseControl.ActiveDocument; doc.New();
doc.ZoomWindow(new gPoint(0, -10), new gPoint(240, 240));
Vertexes verts = new Vertexes();
verts.Add(40, 0, 0, 0); verts.Add(40, 200, 0, 0); verts.Add(20, 180, 0, 0); verts.Add(20, 230, 0, 0);
verts.Add(200, 230, 0, 0); verts.Add(200, 180, 0, 0); verts.Add(180, 200, 0, 0); verts.Add(180, 0, 0, 0);
vdPolyline poly = new vdPolyline(doc, verts);
doc.Model.Entities.AddItem(poly);
poly.Flag = VectorDraw.Professional.Constants.VdConstPlineFlag.PlFlagCLOSE;
poly.Update();
double R1 = 9.0d; double R2 = 6.0d; double R3 = 3.0d; // alter these as you like
gPoints pts_to_Fillet = new gPoints(); // to keep the “original” indexes that you need to fillet
pts_to_Fillet.Add(new gPoint(poly.VertexList[0] as gPoint));// pt 0 -> R1
pts_to_Fillet.Add(new gPoint(poly.VertexList[2] as gPoint));// pt 1 -> R2
pts_to_Fillet.Add(new gPoint(poly.VertexList[3] as gPoint));// pt 2 -> R3
pts_to_Fillet.Add(new gPoint(poly.VertexList[4] as gPoint));// pt 3 -> R3
pts_to_Fillet.Add(new gPoint(poly.VertexList[5] as gPoint));// pt 4 -> R2
pts_to_Fillet.Add(new gPoint(poly.VertexList[7] as gPoint));// pt 5 -> R1
for (int i = 0; i < pts_to_Fillet.Count; i++)
{
double radious = 9.0;
if (i == 0 || i == 5) radious = R1;
else if (i == 1 || i == 4) radious = R2;
else if (i == 2 || i == 3) radious = R3;
int index_pl = poly.VertexList.FindVertexPoint(pts_to_Fillet[i]); // get the new index of the previously stored
if (index_pl > -1)
{
poly.FilletRadiusAtIndex(radious, index_pl); // and fillet it
poly.Update();
}
else MessageBox.Show("point not found on polyline");
}
poly.Invalidate();
} 对于以上问答,如果您有任何的疑惑都可以在评论区留言,我们会及时回复。此系列的问答教程我们会持续更新,如果您感兴趣,可以多多关注本教程。
相关资料推荐:
点击此处还有VectorDraw Developer Framework的demo示例等着你来体验哦!
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系咨询相关问题。
关注慧聚IT微信公众号 ???,了解产品的最新动态及最新资讯。


QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线