示例#1
0
    override public void parseData(object[] datas, object[] pivot)
    {
        this._line1        = new GeomLine(this._map);
        this._line2        = new GeomLine(this._map);
        this._line1.entity = this._line2.entity = this.entity;
        double angle  = Math2.angleToRadian(Convert.ToSingle(datas[0]));
        double angle2 = Math2.angleToRadian(Convert.ToSingle(datas[1]));

        this._radius = (int)(datas[2]);

        if (datas.Length > 3)
        {
            this.inRadius = (int)(datas[3]);
        }

        Vector2D        v       = Vector2D.createVector();
        List <Vector2D> vectors = new List <Vector2D>();

        vectors.Add(v);
        v       = Vector2D.createVector(this._radius, 0);
        v.angle = angle;
        vectors.Add(v);
        v       = Vector2D.createVector(this._radius, 0);
        v.angle = angle2;
        vectors.Add(v);

        datas = new object[] {
            new object[] { 0, 0 },        //[x, y]
            new object[] { this._radius, 0 }
        };

        this._line1.parseData(datas);
        this._line2.parseData(datas);
        this.init(vectors, Vector2D.createVector3(pivot));
    }
示例#2
0
    private static CollisionInfo circleToLine(GeomBase geom1, GeomBase geom2)
    {
        GeomCircle circle = (GeomCircle)geom1;
        GeomLine   line   = (GeomLine)geom2;

        Vector2D v1 = circle.center.clone().subtract(line.point1);
        Vector2D v2 = line.vector2D;

        double len = v2.length;

        v2.normalize();
        double u = v1.dotProd(v2);

        Vector2D v0 = Vector2D.createVector();

        if (u <= 0)
        {
            v0.copy(line.point1);
        }
        else if (u >= len)
        {
            v0.copy(line.point2);
        }
        else
        {
            v0.copy(v2.multiply(u).add(line.point1));
        }
        help.isHit = v0.dist(circle.center) <= circle.radius;
        v0.clear();
        v1.clear();
        v2.clear();
        return(help);
    }
示例#3
0
 public override void clear()
 {
     base.clear();
     Utils.clearObject(this._line1);
     Utils.clearObject(this._line2);
     this._line1 = null;
     this._line2 = null;
 }
        public override bool Execute()
        {
            var position  = Dependency[0].TransformedPoint3D;
            var direction = new gpDir(Dependency[1].TransformedPoint3D.GpPnt.XYZ);

            var line       = new GeomLine(new gpLin(position.GpPnt, direction));
            var helperLine = OccShapeCreatorCode.BuildDottedLine(line);

            Interactive = helperLine;
            return(true);
        }
        public static AISLine BuildDottedLine(GeomLine line)
        {
            var helperLine = new AISLine(line);
            var drawer     = helperLine.Attributes;

            drawer.LineAspect = new Prs3dLineAspect(QuantityNameOfColor.Quantity_NOC_GRAY70,
                                                    AspectTypeOfLine.Aspect_TOL_DOT, 0.5);

            helperLine.UnsetSelectionMode();
            return(helperLine);
        }
示例#6
0
    public override void setData(Dictionary <string, object> data)
    {
        base.setData(data);
        Dictionary <string, object> lineData = (Dictionary <string, object>)data["line1"];

        this._line1        = (GeomLine)this.entity.map.getNetObject((int)(lineData["netId"]));
        lineData           = (Dictionary <string, object>)data["line2"];
        this._line1.entity = this.entity;
        this._line2        = (GeomLine)this.entity.map.getNetObject((int)(lineData["netId"]));
        this._line2.entity = this.entity;
        this.inRadius      = (int)(data["inRadius"]);
    }
示例#7
0
        public override SolverPreviewObject InterestingShapeAroundPoint(gpPln planeOfTheView, Point3D currentPoint,
                                                                        Point3D initialPosition)
        {
            if (currentPoint.IsEqual(initialPosition))
            {
                return(null);
            }

            var qosLock = QosFactory.Instance.Get(QosNames.ParallelLineLock);

            qosLock.Begin();

            var vec = new gpVec(initialPosition.GpPnt, currentPoint.GpPnt);

            foreach (var solverGeometricObject in Geometry)
            {
                if (solverGeometricObject.ParallelAxis.Count == 0)
                {
                    continue;
                }
                foreach (var axis in solverGeometricObject.ParallelAxis)
                {
                    if (vec.IsNormal(axis.Vector, _precision))
                    {
                        var   planeNormal     = vec.Crossed(axis.Vector);
                        var   planeNormalAxis = new gpAx1(initialPosition.GpPnt, new gpDir(planeNormal));
                        gpVec v2 = axis.Vector.Normalized;
                        v2.Rotate(planeNormalAxis, Math.PI / 2.0);

                        var parallelLine    = new gceMakeLin(initialPosition.GpPnt, new gpDir(v2)).Value;
                        var geomLine        = new GeomLine(parallelLine);
                        var projectionPoint = new GeomAPIProjectPointOnCurve(currentPoint.GpPnt, geomLine);

                        if (projectionPoint.NbPoints <= 0)
                        {
                            return(null);
                        }
                        var secondPoint = new Point3D(projectionPoint.NearestPoint);
                        var solverPoint = new SolverEdgeTwoPointsResult(secondPoint, initialPosition, Color.Black)
                        {
                            Type = "Perpendicular Line"
                        };
                        return(solverPoint);
                    }
                }
            }
            qosLock.End();

            return(null);
        }
        private Point3D?GetOtherPoint(Point3D firstLinePoint, Point3D secondLinePoint,
                                      gpDir direction)
        {
            // Make a parallel line with this line starting from the initial point
            var parallelLine    = new gceMakeLin(firstLinePoint.GpPnt, direction).Value;
            var geomLine        = new GeomLine(parallelLine);
            var projectionPoint = new GeomAPIProjectPointOnCurve(secondLinePoint.GpPnt, geomLine);

            if (projectionPoint.NbPoints <= 0)
            {
                return(null);
            }
            return(new Point3D(projectionPoint.NearestPoint));
        }
        public static Point3D?ProjectPointOnLine(Point3D firstLinePoint, gpDir lineDirection, Point3D pointToProject)
        {
            // Make a parallel line with this line starting from the initial point
            var projectionLine  = new gceMakeLin(firstLinePoint.GpPnt, lineDirection).Value;
            var geomLine        = new GeomLine(projectionLine);
            var projectionPoint = new GeomAPIProjectPointOnCurve(pointToProject.GpPnt, geomLine);

            if (projectionPoint.NbPoints > 0)
            {
                return(new Point3D(projectionPoint.NearestPoint));
            }

            return(null);
        }
示例#10
0
        private List <NodeBuilder> PreviewRectangle(Document document, Node sketchNode)
        {
            //var axis1 = new gpAx2();
            //axis1.Axis = (sketchNode.Children[1].Get<Axis3DInterpreter>().Axis.GpAxis);
            //var location = axis1.Axis.Location.Transformed(sketchNode.Get<TransformationInterpreter>().CurrTransform);
            //var direction = axis1.Axis.Direction.Transformed(sketchNode.Get<TransformationInterpreter>().CurrTransform);
            //var axis = new gpAx2(location, direction);

            var   axisAll = NodeBuilderUtils.GetTransformedAxis(new NodeBuilder(sketchNode));
            var   axis    = new gpAx2(axisAll.Location, axisAll.Direction);
            var   vec     = new gpVec(Points[0].GpPnt, Points[1].GpPnt);
            gpVec v2      = vec.Normalized;

            v2.Rotate(axis.Axis, Math.PI / 2.0);

            var parallelLine    = new gceMakeLin(Points[1].GpPnt, new gpDir(v2)).Value;
            var geomLine        = new GeomLine(parallelLine);
            var projectionPoint = new GeomAPIProjectPointOnCurve(Points[2].GpPnt, geomLine);

            var thirdPoint = new Point3D(projectionPoint.NearestPoint);

            var firstPoint2D  = Points[0].ToPoint2D(axis);
            var secondPoint2D = Points[1].ToPoint2D(axis);
            var thirdPoint2D  = thirdPoint.ToPoint2D(axis);

            var parallelLine2    = new gceMakeLin(Points[2].GpPnt, new gpDir(vec)).Value;
            var geomLine2        = new GeomLine(parallelLine2);
            var projectionPoint2 = new GeomAPIProjectPointOnCurve(Points[0].GpPnt, geomLine2);

            var fourthPoint   = new Point3D(projectionPoint2.NearestPoint);
            var fourthPoint2D = fourthPoint.ToPoint2D(axis);

            var point3Ds = new List <Point3D>();

            point3Ds.Add(GeomUtils.Point2DTo3D(axis, firstPoint2D.X, firstPoint2D.Y));
            point3Ds.Add(GeomUtils.Point2DTo3D(axis, secondPoint2D.X, secondPoint2D.Y));
            point3Ds.Add(GeomUtils.Point2DTo3D(axis, thirdPoint2D.X, thirdPoint2D.Y));
            point3Ds.Add(GeomUtils.Point2DTo3D(axis, fourthPoint2D.X, fourthPoint2D.Y));
            var pointLinker = new SketchCreator(document).PointLinker;

            var lines = new List <NodeBuilder>
            {
                BuildLine(Document, pointLinker, point3Ds[0], point3Ds[1]),
                BuildLine(Document, pointLinker, point3Ds[1], point3Ds[2]),
                BuildLine(Document, pointLinker, point3Ds[2], point3Ds[3]),
                BuildLine(Document, pointLinker, point3Ds[3], point3Ds[0])
            };

            return(lines);
        }
示例#11
0
    private static CollisionInfo circleToSector(GeomBase geom1, GeomBase geom2)
    {
        GeomCircle circle = (GeomCircle)geom1;
        GeomSector sector = (GeomSector)geom2;
        GeomLine   line1  = sector.line1;
        GeomLine   line2  = sector.line2;

        //这个因为有需求所以就这么直接写一下了。
        bool result = !(0 != sector.inRadius && sector.center.dist(circle.center) <= sector.inRadius /* + circle.radius*/) && //不能在内圆
                      ((line1.checkPoint(circle.center) >= 0 && line2.checkPoint(circle.center) <= 0) ||                      //在夹角内
                       circleToLine(circle, line1).isHit || circleToLine(circle, line2).isHit);                               //或者与线相交

        help.isHit = result;
        return(help);
    }
示例#12
0
        public override bool Execute()
        {
            var point      = Dependency[0].TransformedPoint3D;
            var firstPoint = point;

            firstPoint.X += 10000;

            var line = new GeomLine(firstPoint.GpPnt,
                                    new gpDir(new gpVec(-20000, 0, 0)));
            var helperLine = new AISLine(line);
            var drawer     = helperLine.Attributes;

            drawer.LineAspect = (new Prs3dLineAspect(QuantityNameOfColor.Quantity_NOC_GRAY70,
                                                     AspectTypeOfLine.Aspect_TOL_DOT, 0.5));
            helperLine.Transparency = 0.8;

            Interactive = helperLine;
            return(true);
        }
        /// <summary>
        ///   Calculates the projection of the second line point on the direction so that the line created from
        ///   [first point, projection] is parallel with direction.
        /// </summary>
        /// <param name = "firstLinePoint"></param>
        /// <param name = "secondLinePoint"></param>
        /// <param name = "direction"></param>
        /// <param name = "color"></param>
        /// <returns></returns>
        public static SolverPreviewObject ProjectPointOnDirection(Point3D firstLinePoint, Point3D secondLinePoint,
                                                                  gpDir direction, Color color)
        {
            // Make a parallel line with this line starting from the initial point
            var parallelLine    = new gceMakeLin(firstLinePoint.GpPnt, direction).Value;
            var geomLine        = new GeomLine(parallelLine);
            var projectionPoint = new GeomAPIProjectPointOnCurve(secondLinePoint.GpPnt, geomLine);

            if (projectionPoint.NbPoints <= 0)
            {
                return(null);
            }
            var firstParallelPoint  = new Point3D(projectionPoint.NearestPoint);
            var secondParallelPoint = firstLinePoint;
            var solverPoint         = new SolverEdgeTwoPointsResult(firstParallelPoint, secondParallelPoint, color)
            {
                Type = "Parallel Line"
            };

            return(solverPoint);
        }
示例#14
0
        public static ComplexGeometry ExecuteStages(Point centerLocation)
        {
            var finalGeometry = new List <Geometry>();

            var pointsList = GeomPoint.CreatePoints();

            finalGeometry.Add(pointsList);
            var linesList = GeomLine.CreateLines(pointsList);

            finalGeometry.Add(linesList);
            var ellipse = GeomEllipse.CreateEllipse(linesList);

            finalGeometry.Add(ellipse);
            var circle = GeomCircle.CreateCircle(ellipse);

            finalGeometry.Add(circle);
            var boundingBox = GeomBoundingBox.CreateBoundingBox(ellipse);

            finalGeometry.Add(boundingBox);

            return(finalGeometry);
        }
示例#15
0
 public AISAxis(GeomLine aComponent)
     :
     base(AIS_Axis_Ctor7C3C08A3(aComponent.Instance))
 {
 }
示例#16
0
 public AISLine(GeomLine aLine)
     :
     base(AIS_Line_Ctor7C3C08A3(aLine.Instance))
 {
 }