C# VTK OCCT 将OCCT 交线转换为 vtk 交线

因为vtkIntersectionPolyDataFilter 交线算法有问题所以改为 OCCT BRepAlgoAPI_Section交线算法。

OCCT 生成一个正方体和球体

BRepPrimAPI_MakeBox brepBox = new BRepPrimAPI_MakeBox(new Pnt(0,0,0),10,10,10);
vtkPolyData boxData = OcctConvert.TopoDsShapeToPolyData(brepBox.Shape());

BRepPrimAPI_MakeSphere brepSphere = new BRepPrimAPI_MakeSphere(new Pnt(5,5,5),6);
vtkPolyData sphereData = OcctConvert.TopoDsShapeToPolyData(brepSphere.Shape());

执行OCCT 交线算法 

BRepAlgoAPI_Section brepSection = new BRepAlgoAPI_Section(brepBox.Shape(), brepSphere.Shape());
brepSection.ComputePCurveOn1(true); 
brepSection.Approximation(true);
brepSection.Build();

OCCT  交线 转换为 vtk

因为OCCT  的 Edge 可能是无序的所以先排序,其次几何上明显是相连的Edge  Chains存储时却不是相连,Chains 可以 看做是vtk 的连通域,所以要对Edge 进行连通域的分类。

        public static vtkPolyData ChainEdgeList(TopoDS_Shape shape)
        {
            var order = new ShapeAnalysis_WireOrder();
            List<TopoDS_Edge> edges = ShapeEdges(shape);

            foreach (var edge in edges)
            {
                var first = BRep_Tool.Pnt(TopExp.FirstVertex(edge));
                var last = BRep_Tool.Pnt(TopExp.LastVertex(edge));
                if (edge.Orientation() == TopAbs_Orientation.FORWARD)
                    order.Add(first.Coord, last.Coord);
                else
     
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值