首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如果(网格或Brep)的面是平面,如何得到它的法向量

如果(网格或Brep)的面是平面,如何得到它的法向量
EN

Stack Overflow用户
提问于 2019-05-14 14:43:27
回答 1查看 274关注 0票数 0

我想要点击一个实体的面,并出现其正常的vector.It将帮助我设置一个旋转轴。

我遵循示例中的model1_SelectionChanged :EyeshotDemo,我可以知道我click.But哪个face,我不知道下一步我能做什么。

EN

回答 1

Stack Overflow用户

发布于 2019-05-14 20:25:08

您应该使用viewportLayout.FindClosestTriangle进行面部定位。

这将为您提供一个构成面的三角形(通常是最接近鼠标的三角形)。

然后从那里创建一个平面,指定该三角形的3个顶点,该顶点的法线方向将与三角形法线相匹配。

下面是一个完整的工作代码:

代码语言:javascript
复制
// create a basic cube solid
var cube = Solid.CreateBox(10, 10, 10);

// add to the viewport (vp is the ViewportLayout control)
vp.Entities.Add(cube);

// in the vp (ViewportLayout control) mouse click
private void vp_MouseClick(object sender, MouseEventArgs e)
{
    // get the index of the entity under the cursor
    var index = vp.GetEntityUnderMouseCursor(e.Location);

    // get that item from the entity list as a IFace (since it's a solid)
    var item = vp.Entities[index] as IFace;

    // find the closest triangles
    var triangles = vp.FindClosestTriangle(item, e.Location);

    // get the meshes of that IFace
    var meshes = item.GetPolygonMeshes();

    // in meshes you have all vertex and triangles you need to create a plane
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56124408

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档