Exemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------

        public static void RenderArrow(IDrawingRenderer renderer, Ax2d location, double scale = 1.0)
        {
            var arrowSize = GetArrowSize();

            var p1        = location.Location;
            var backpoint = p1.Translated(location.Direction.Reversed().ToVec(arrowSize.Length * scale));
            var rightVec  = new Vec2d(location.Direction.Y, -location.Direction.X).Scaled(arrowSize.Width * 0.5 * scale);
            var p2        = backpoint.Translated(rightVec);
            var p3        = backpoint.Translated(rightVec.Reversed());

            renderer.SetStyle(null, new FillStyle(Common.Color.Black), null);
            renderer.BeginPath();
            renderer.BeginPathSegment();
            renderer.Line(p1, p2);
            renderer.Line(p2, p3);
            renderer.Line(p3, p1);
            renderer.EndPathSegment();
            renderer.EndPath();
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        public static bool RenderFaces(IDrawingRenderer renderer, TopoDS_Shape brepShape)
        {
            var res = true;

            renderer.BeginPath();

            var faces = brepShape.Faces();

            if (faces.Count == 0)
            {
                // Drawings may only contain lines, not faces
                res = RenderEdges(renderer, brepShape.Edges(), null);
            }
            else
            {
                foreach (var face in faces)
                {
                    var outerWire = BRepTools.OuterWire(face);
                    if (outerWire == null)
                    {
                        continue;
                    }

                    res &= RenderEdges(renderer, outerWire.Edges(), face);

                    var wires = face.Wires();
                    foreach (var wire in wires)
                    {
                        if (wire.IsEqual(outerWire))
                        {
                            continue;
                        }
                        res &= RenderEdges(renderer, wire.Edges(), face);
                    }
                }
            }

            renderer.EndPath();

            return(res);
        }