Ejemplo n.º 1
0
        protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw wd)
        {
            // Update the dummy vertex to be our 3D point
            // projected onto our plane
            if (_isArcSeg)
            {
                Point3d  lastVertex = _pline.GetPoint3dAt(_pline.NumberOfVertices - 2);
                Vector3d refDir;
                if (_pline.NumberOfVertices < 3)
                {
                    refDir = new Vector3d(1.0, 1.0, 0.0);
                }
                else
                {
                    // Check bulge to see if last segment was an arc or a line
                    if (_pline.GetBulgeAt(_pline.NumberOfVertices - 3) != 0)
                    {
                        CircularArc3d arcSegment = _pline.GetArcSegmentAt(_pline.NumberOfVertices - 3);
                        Line3d        tangent    = arcSegment.GetTangent(lastVertex);
                        // Reference direction is the invert of the arc tangent
                        // at last vertex
                        refDir = tangent.Direction.MultiplyBy(-1.0);
                    }
                    else
                    {
                        Point3d pt = _pline.GetPoint3dAt(_pline.NumberOfVertices - 3);
                        refDir = new Vector3d(lastVertex.X - pt.X, lastVertex.Y - pt.Y, lastVertex.Z - pt.Z);
                    }
                }
                double angle = Class1.JigUtils.ComputeAngle(lastVertex, _tempPoint, refDir, _ucs);
                // Bulge is defined as tan of one fourth of included angle
                // Need to double the angle since it represents the included
                // angle of the arc
                // So formula is: bulge = Tan(angle * 2 * 0.25)
                double bulge = Math.Tan(angle * 0.5);
                _pline.SetBulgeAt(_pline.NumberOfVertices - 2, bulge);
            }
            else
            {
                // Line mode. Need to remove last bulge if there was one
                if (_pline.NumberOfVertices > 1)
                {
                    _pline.SetBulgeAt(_pline.NumberOfVertices - 2, 0);
                }
            }
            _pline.SetPointAt(_pline.NumberOfVertices - 1, _tempPoint.Convert2d(_plane));

            if (_pline.NumberOfVertices == 3)
            {
                _pline.Closed = true;
                ObjectIdCollection ids = new ObjectIdCollection();
                ids.Add(_pline.ObjectId);
                // Add the hatch loops and complete the hatch
                _hat.Associative = true;
                _hat.AppendLoop(HatchLoopTypes.Default, ids);
            }
            if (!wd.RegenAbort)
            {
                wd.Geometry.Draw(_pline);
                if (_pline.NumberOfVertices > 2)
                {
                    _hat.EvaluateHatch(true);
                    if (!wd.RegenAbort)
                    {
                        wd.Geometry.Draw(_hat);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        protected override bool Update()
        {
            // Update the dummy vertex to be our 3D point
            // projected onto our plane

            Polyline pl = Entity as Polyline;

            if (_isArcSeg)
            {
                Point3d lastVertex =
                    pl.GetPoint3dAt(pl.NumberOfVertices - 2);

                Vector3d refDir;

                if (pl.NumberOfVertices < 3)
                {
                    refDir = new Vector3d(1.0, 1.0, 0.0);
                }
                else
                {
                    // Check bulge to see if last segment was an arc or a line

                    if (pl.GetBulgeAt(pl.NumberOfVertices - 3) != 0)
                    {
                        CircularArc3d arcSegment =
                            pl.GetArcSegmentAt(pl.NumberOfVertices - 3);

                        Line3d tangent = arcSegment.GetTangent(lastVertex);

                        // Reference direction is the invert of the arc tangent
                        // at last vertex

                        refDir = tangent.Direction.MultiplyBy(-1.0);
                    }
                    else
                    {
                        Point3d pt =
                            pl.GetPoint3dAt(pl.NumberOfVertices - 3);

                        refDir =
                            new Vector3d(
                                lastVertex.X - pt.X,
                                lastVertex.Y - pt.Y,
                                lastVertex.Z - pt.Z
                                );
                    }
                }

                double angle =
                    JigUtils.ComputeAngle(
                        lastVertex, _tempPoint, refDir, _ucs
                        );

                // Bulge is defined as tan of one fourth of included angle
                // Need to double the angle since it represents the included
                // angle of the arc
                // So formula is: bulge = Tan(angle * 2 * 0.25)

                double bulge = Math.tan(angle * 0.5);

                pl.SetBulgeAt(pl.NumberOfVertices - 2, bulge);
            }
            else
            {
                // Line mode. Need to remove last bulge if there was one

                if (pl.NumberOfVertices > 1)
                {
                    pl.SetBulgeAt(pl.NumberOfVertices - 2, 0);
                }
            }

            pl.SetPointAt(
                pl.NumberOfVertices - 1, _tempPoint.Convert2d(_plane)
                );

            return(true);
        }