Example #1
0
        //--------------------------------------------------------------------------------------------------

        void _ExportEdges(List <TopoDS_Edge> edges, TopoDS_Face face)
        {
            // Order edges
            var order = new ShapeAnalysis_WireOrder(true, 0.0001);

            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.TopAbs_FORWARD)
                {
                    order.Add(first.Coord, last.Coord);
                }
                else
                {
                    order.Add(last.Coord, first.Coord);
                }
            }
            order.Perform(true);

            if (order.IsDone())
            {
                order.SetChains(0.0001);
                for (int chain = 1; chain <= order.NbChains(); chain++)
                {
                    int startIndex = 0, endIndex = 0;
                    order.Chain(chain, ref startIndex, ref endIndex);

                    // Process ordered edges
                    for (int i = startIndex; i <= endIndex; i++)
                    {
                        int orderIndex    = order.Ordered(i);
                        int originalIndex = Math.Abs(orderIndex) - 1; // order index is 1-based
                        _ExportEdge(edges[originalIndex], orderIndex < 0, face);
                    }

                    // Add path to group
                    ClosePath();
                    if (!CombineToPath)
                    {
                        FinalizePath();
                    }
                }
            }
            else
            {
                // Cannot sort, just pump out all edges
                foreach (var edge in edges)
                {
                    _ExportEdge(edge, false, face);
                }

                // Add path to group
                if ((CurrentPath != null) && CurrentPath.Segments.Any())
                {
                    CurrentGroup.Children.Add(CurrentPath);
                }
            }
        }
Example #2
0
        //--------------------------------------------------------------------------------------------------

        public static bool RenderEdges(IDrawingRenderer renderer, List <TopoDS_Edge> edges, TopoDS_Face face)
        {
            var res = true;

            // Order edges
            var order = new ShapeAnalysis_WireOrder(true, 0.0001);

            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.TopAbs_FORWARD)
                {
                    order.Add(first.Coord, last.Coord);
                }
                else
                {
                    order.Add(last.Coord, first.Coord);
                }
            }
            order.Perform(true);

            if (order.IsDone())
            {
                order.SetChains(0.0001);
                for (int chain = 1; chain <= order.NbChains(); chain++)
                {
                    int startIndex = 0, endIndex = 0;
                    order.Chain(chain, ref startIndex, ref endIndex);
                    if (startIndex > endIndex)
                    {
                        continue;
                    }

                    // Process ordered edges
                    renderer.BeginPathSegment();
                    for (int index = startIndex; index <= endIndex; index++)
                    {
                        int orderIndex    = order.Ordered(index);
                        int originalIndex = Math.Abs(orderIndex) - 1; // order index is 1-based
                        res &= RenderEdge(renderer, edges[originalIndex], orderIndex < 0, face);
                    }
                    renderer.EndPathSegment();
                }
            }
            else
            {
                // Cannot sort, just pump out all edges
                foreach (var edge in edges)
                {
                    res &= RenderEdge(renderer, edge, false, face);
                }
            }

            return(res);
        }
Example #3
0
 public bool FixReorder(ShapeAnalysis_WireOrder wi)
 {
     throw new NotImplementedException();
 }