Exemplo n.º 1
0
 /// <summary>
 /// Construct Edge of line type by points and normal (localY).
 /// </summary>
 public Edge(FdPoint3d startPoint, FdPoint3d endPoint, FdVector3d localY)
 {
     this.Type = "line";
     this.Points.Add(startPoint);
     this.Points.Add(endPoint);
     this.Normal = localY;
 }
Exemplo n.º 2
0
 public bool Equals(FdPoint3d p)
 {
     if ((object)p == null)
     {
         return(false);
     }
     return((X == p.X) && (Y == p.Y) && (Z == p.Z));
 }
Exemplo n.º 3
0
 public bool Equals(FdPoint3d p, double tolerance)
 {
     if ((object)p == null)
     {
         return(false);
     }
     return((Math.Abs(X - p.X) < tolerance) && (Math.Abs(Y - p.Y) < tolerance) && (Math.Abs(Z - p.Z) < tolerance));
 }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// Create FdCoordinateSystem from Dynamo coordinate system of a Arc or Circle.
        /// Dynamo Arcs and Circles follow left-hand rule.
        /// This method realignes the coordinate system.
        /// </summary>
        internal static FdCoordinateSystem FromDynamoCoordinateSystemArcOrCircle(Autodesk.DesignScript.Geometry.CoordinateSystem obj)
        {
            FdPoint3d  origin = FdPoint3d.FromDynamo(obj.Origin);
            FdVector3d localX = FdVector3d.FromDynamo(obj.YAxis);
            FdVector3d localY = FdVector3d.FromDynamo(obj.XAxis);
            FdVector3d localZ = localX.Cross(localY).Normalize();

            return(new FdCoordinateSystem(origin, localX, localY, localZ));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create FdCoordinateSystem from Dynamo coordinate system of a Surface.
        /// No realignment neccessary.
        /// </summary>
        internal static FdCoordinateSystem FromDynamoCoordinateSystemSurface(Autodesk.DesignScript.Geometry.CoordinateSystem obj)
        {
            FdPoint3d  origin = FdPoint3d.FromDynamo(obj.Origin);
            FdVector3d localX = FdVector3d.FromDynamo(obj.XAxis);
            FdVector3d localY = FdVector3d.FromDynamo(obj.YAxis);
            FdVector3d localZ = FdVector3d.FromDynamo(obj.ZAxis);

            return(new FdCoordinateSystem(origin, localX, localY, localZ));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create Edge (Line) from Dynamo NurbsCurve.
        /// </summary>
        public static Geometry.Edge FromDynamoLinearNurbsCurve(Autodesk.DesignScript.Geometry.NurbsCurve obj)
        {
            FdPoint3d startPoint = FdPoint3d.FromDynamo(obj.StartPoint);
            FdPoint3d endPoint   = FdPoint3d.FromDynamo(obj.EndPoint);

            // lcs
            FdCoordinateSystem cs = FdCoordinateSystem.FromDynamoCurve(obj);

            // return
            return(new Geometry.Edge(startPoint, endPoint, cs));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Create Edge (Circle) from Dynamo Circle.
        /// </summary>
        public static Geometry.Edge FromDynamoCircle(Autodesk.DesignScript.Geometry.Circle obj)
        {
            double    radius      = obj.Radius;
            FdPoint3d centerPoint = FdPoint3d.FromDynamo(obj.CenterPoint);

            // lcs
            FdCoordinateSystem cs = FdCoordinateSystem.FromDynamoCurve(obj);

            // return
            return(new Geometry.Edge(radius, centerPoint, cs));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Create Edge (Arc2) from Dynamo Arc.
        /// Used for bar definition.
        /// </summary>
        public static Geometry.Edge FromDynamoArc2(Autodesk.DesignScript.Geometry.Arc obj)
        {
            FdPoint3d p0 = FdPoint3d.FromDynamo(obj.StartPoint);
            FdPoint3d p1 = FdPoint3d.FromDynamo(obj.PointAtParameter(0.5));
            FdPoint3d p2 = FdPoint3d.FromDynamo(obj.EndPoint);

            // lcs
            FdCoordinateSystem cs = FdCoordinateSystem.FromDynamoCurve(obj);

            // return
            return(new Geometry.Edge(p0, p1, p2, cs));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Create Edge (Arc1) from Dynamo Arc.
        /// </summary>
        public static Geometry.Edge FromDynamoArc1(Autodesk.DesignScript.Geometry.Arc obj)
        {
            double     radius      = obj.Radius;
            double     startAngle  = 0;
            double     endAngle    = startAngle + Degree.ToRadians(obj.SweepAngle);
            FdPoint3d  centerPoint = FdPoint3d.FromDynamo(obj.CenterPoint);
            FdVector3d xAxis       = new FdVector3d(centerPoint, FdPoint3d.FromDynamo(obj.StartPoint)).Normalize();

            // lcs
            FdCoordinateSystem cs = FdCoordinateSystem.FromDynamoCurve(obj);

            // return
            return(new Geometry.Edge(radius, startAngle, endAngle, centerPoint, xAxis, cs));
        }
Exemplo n.º 10
0
        public override bool Equals(System.Object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            FdPoint3d p = obj as FdPoint3d;

            if ((System.Object)p == null)
            {
                return(false);
            }
            return((X == p.X) && (Y == p.Y) && (Z == p.Z));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Construct FdCoordinateSystem from origin point and local x, y, z axes.
        /// </summary>
        public FdCoordinateSystem(FdPoint3d origin, FdVector3d localX, FdVector3d localY, FdVector3d localZ)
        {
            this.Origin  = origin;
            this._localX = localX;
            this._localY = localY;
            this._localZ = localZ;

            if (!this.IsComplete())
            {
                throw new System.ArgumentException("The defined coordinate system is not complete!");
            }

            if (!this.IsOrthogonal())
            {
                throw new System.ArgumentException($"The defined coordinate system is not orthogonal within the tolerance {Tolerance.DotProduct}");
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Create region by points and coordinate system.
        /// </summary>
        /// <param name="points">List of sorted points defining the outer perimeter of the region.</param>
        /// <param name="coordinateSystem">Coordinate system of the region</param>
        public Region(List <FdPoint3d> points, FdCoordinateSystem coordinateSystem)
        {
            // edge normal
            FdVector3d edgeLocalY = coordinateSystem.LocalZ;

            List <Edge> edges = new List <Edge>();

            for (int idx = 0; idx < points.Count; idx++)
            {
                // startPoint
                FdPoint3d p0 = p0 = points[idx];

                // endPoint
                FdPoint3d p1;
                if (idx != points.Count - 1)
                {
                    p1 = points[idx + 1];
                }

                else
                {
                    p1 = points[0];
                }

                // create edge
                edges.Add(new Edge(p0, p1, edgeLocalY));
            }

            // create contours
            Contour contour = new Contour(edges);

            // set properties
            this.Contours = new List <Contour> {
                contour
            };
            this.CoordinateSystem = coordinateSystem;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Create FdPoint3d from Dynamo point.
        /// </summary>
        public static FdPoint3d FromDynamo(Autodesk.DesignScript.Geometry.Point point)
        {
            FdPoint3d newPoint = new FdPoint3d(point.X, point.Y, point.Z);

            return(newPoint);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Construct FdVector3d by start and end points.
 /// </summary>
 /// <param name="p0">Start point</param>
 /// <param name="p1">End point</param>
 public FdVector3d(FdPoint3d p0, FdPoint3d p1)
 {
     this.X = p1.X - p0.X;
     this.Y = p1.Y - p0.Y;
     this.Z = p1.Z - p0.Z;
 }
Exemplo n.º 15
0
 internal static Rhino.Geometry.Point3d ToRhino(this FemDesign.Geometry.FdPoint3d point)
 {
     return(new Rhino.Geometry.Point3d(point.X, point.Y, point.Z));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Construct LineSegment from start and endpoint.
 /// </summary>
 /// <param name="verticies"></param>
 public LineSegment(FdPoint3d start, FdPoint3d end)
 {
     this.StartPoint = start;
     this.BasePoint  = new FdPoint3d((start.X + end.X) / 2.0, (start.Y + end.Y) / 2.0, (start.Z + end.Z) / 2.0);
     this.EndPoint   = end;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Global coordinate system
 /// </summary>
 public static FdCoordinateSystem Global()
 {
     return(new FdCoordinateSystem(FdPoint3d.Origin(), FdVector3d.UnitX(), FdVector3d.UnitY()));
 }