コード例 #1
0
        public static IfcProductDefinitionShape CreateExtruded(IfcRepresentationContext representationContext,
            IfcProfileDef ifcProfileDef, IfcAxis2Placement3D placement3D, IfcDirection direction, double depth)
        {
            var extruded = new IfcExtrudedAreaSolid
                               {
                                   SweptArea = ifcProfileDef,
                                   Position =  placement3D,
                                   ExtrudedDirection = direction ,
                                   Depth = depth,
                               };

            var shaperep = new IfcShapeRepresentation
                               {
                                   ContextOfItems = representationContext,
                                   RepresentationIdentifier = "Body",
                                   RepresentationType = "SweptSolid",
                                   Items = new List<IfcRepresentationItem>(),
                               };
            shaperep.Items.Add(extruded);

            var ifcShape = new IfcProductDefinitionShape
                               {
                                   // Name=
                                   // Description =
                                   Representations = new List<IfcRepresentation>(),
                               };
            ifcShape.Representations.Add(shaperep);

            return ifcShape;
        }
コード例 #2
0
        public static Matrix4 Axis2Placement3DToMatrix(IfcAxis2Placement3D axis2Placement3)
        {
            if (axis2Placement3.Axis == null)
            {
                axis2Placement3.Axis = new IfcDirection(0, 0, 1);
            }

            if (axis2Placement3.RefDirection == null)
            {
                axis2Placement3.RefDirection = new IfcDirection(1, 0, 0);
            }

            // Y direction is Z x ref direction
            // Caution
            // X direction is YxZ, not ZxY, which is reverse direction

            IfcDirection yDirection = IfcDirection.GetCrossProduct(axis2Placement3.Axis, axis2Placement3.RefDirection);
            IfcDirection xDirection = IfcDirection.GetCrossProduct(yDirection, axis2Placement3.Axis);
            IfcDirection zDirection = axis2Placement3.Axis;


            return(new Matrix4(
                       xDirection.DirectionRatios[0], yDirection.DirectionRatios[0], zDirection.DirectionRatios[0],
                       axis2Placement3.Location.Coordinates[0],
                       xDirection.DirectionRatios[1], yDirection.DirectionRatios[1], zDirection.DirectionRatios[1],
                       axis2Placement3.Location.Coordinates[1],
                       xDirection.DirectionRatios[2], yDirection.DirectionRatios[2], zDirection.DirectionRatios[2],
                       axis2Placement3.Location.Coordinates[2],
                       0, 0, 0, 1
                       ));
        }
コード例 #3
0
ファイル: IfcDirection.cs プロジェクト: mind-peace/ifctoolkit
        //public override string ToString()
        //{
        //    return string.Format("({0:0.000}, {1:0.000}, {2:0.000})", DirectionRatios[0], DirectionRatios[1], DirectionRatios[2]);
        //}



        public static void AngleToDirection2D(double radian, out IfcDirection xAxisDirection, out IfcDirection yAxisDirection)
        {
            // rotation matrix = | cos -sin |
            //                   | sin  cos |

            xAxisDirection = new IfcDirection(Math.Cos(radian), -Math.Sin(radian));
            yAxisDirection = new IfcDirection(-Math.Sin(radian), Math.Cos(radian));
        }
コード例 #4
0
 public IfcAxis2Placement3D(IfcCartesianPoint location, IfcDirection axis, IfcDirection refAxis)
 {
     if (location == null) throw new ArgumentNullException("location");
     if (refAxis == null) throw new ArgumentNullException("refAxis");
     if (axis == null) throw new ArgumentNullException("axis");
     this.Location = location;
     this.Axis = axis;
     this.RefDirection = refAxis;
 }
コード例 #5
0
ファイル: IfcDirection.cs プロジェクト: mind-peace/ifctoolkit
        //public double Normalize()
        //{
        //    return this.Normalize(1.0);
        //}

        /// <summary>
        /// Normalizes the vector using the given length.
        /// </summary>
        /// <param name="newLength">The length to be used.</param>
        /// <returns>The normalized vector's length.</returns>
        //public double Normalize(double newLength)
        //{
        //    var length = Math.Sqrt(DirectionRatios[0] * DirectionRatios[0] + DirectionRatios[1] * DirectionRatios[1] + DirectionRatios[2] * DirectionRatios[2]);
        //    var minLength = MathService.Epsilon;

        //    if (length > minLength)
        //    {
        //        DirectionRatios[0] = DirectionRatios[0] / length * newLength;
        //        DirectionRatios[1] = DirectionRatios[1] / length * newLength;
        //        DirectionRatios[2] = DirectionRatios[2] / length * newLength;

        //        length = newLength;
        //    }
        //    return length;
        //}

        /// <summary>
        /// Gets the angle (in radians) between the current vector and the given vector.
        /// </summary>
        /// <param name="dir">The vector to be used.</param>
        /// <returns>The angle between the vectors in radians.</returns>
        public double GetAngleBetween(IfcDirection dir)
        {
            var from = this;
            var that = dir;

            if (Math.Abs(from.Dot(that) - 1.0) <= MathService.Epsilon)
            {
                return(0.0);
            }
            return(Math.Abs(@from.Dot(that) + 1.0) <= MathService.Epsilon ? Math.PI : Math.Acos(@from.Dot(that)));
        }
コード例 #6
0
ファイル: IfcDirection.cs プロジェクト: mind-peace/ifctoolkit
        public static IfcDirection GetCrossProduct(IfcDirection directionX, IfcDirection directionY)
        {
            double X, Y, Z;

            X = directionX.DirectionRatios[1] * directionY.DirectionRatios[2]
                - directionX.DirectionRatios[2] * directionY.DirectionRatios[1];
            Y = directionX.DirectionRatios[2] * directionY.DirectionRatios[0]
                - directionX.DirectionRatios[0] * directionY.DirectionRatios[2];
            Z = directionX.DirectionRatios[0] * directionY.DirectionRatios[1]
                - directionX.DirectionRatios[1] * directionY.DirectionRatios[0];
            var ret = new IfcDirection(X, Y, Z);

            // ret.MakeUnitVector();
            return(ret);
        }
コード例 #7
0
ファイル: BbDirection2D.cs プロジェクト: JackTing/ifctoolkit
        BbDirection2D(double[] x)
        {
            if (x.Length == 2) {

                x = MathService.Normalize (x);

                List<REAL> list = new List<REAL>();
                list.Add(x[0]);
                list.Add(x[1]);

                IfcDirection = new IfcDirection{
                    DirectionRatios = list,
                };
            } else {
                throw new ArgumentException ();
            }
        }
コード例 #8
0
 public IfcAxis2Placement3D(IfcCartesianPoint location, IfcDirection axis, IfcDirection refAxis)
 {
     if (location == null)
     {
         throw new ArgumentNullException("location");
     }
     if (refAxis == null)
     {
         throw new ArgumentNullException("refAxis");
     }
     if (axis == null)
     {
         throw new ArgumentNullException("axis");
     }
     this.Location     = location;
     this.Axis         = axis;
     this.RefDirection = refAxis;
 }
コード例 #9
0
ファイル: IfcDirection.cs プロジェクト: mind-peace/ifctoolkit
 /// <summary>
 /// Instantiates a new IfcDirection with given IfcDirection, and normalizes
 /// </summary>
 /// <param name="dir">The dir to be used.</param>
 public IfcDirection(IfcDirection dir)
 {
     if (dir.DirectionRatios.Count == 3)
     {
         DirectionRatios = new List <REAL>
         {
             dir.DirectionRatios[0],
             dir.DirectionRatios[1],
             dir.DirectionRatios[2]
         };
     }
     else
     {
         DirectionRatios = new List <REAL>
         {
             dir.DirectionRatios[0],
             dir.DirectionRatios[1]
         };
     }
     MakeUnitVector();
 }
コード例 #10
0
ファイル: IfcDirection.cs プロジェクト: JackTing/ifctoolkit
 /// <summary>
 /// Instantiates a new IfcDirection with given IfcDirection, and normalizes
 /// </summary>
 /// <param name="dir">The dir to be used.</param>
 public IfcDirection(IfcDirection dir)
 {
     if (dir.DirectionRatios.Count == 3)
     {
         DirectionRatios = new List<REAL>
             {
                 dir.DirectionRatios[0],
                 dir.DirectionRatios[1],
                 dir.DirectionRatios[2]
             };
     }
     else
     {
         DirectionRatios = new List<REAL>
             {
                 dir.DirectionRatios[0],
                 dir.DirectionRatios[1]
             };
     }
     MakeUnitVector();
 }
コード例 #11
0
ファイル: BbDirection3D.cs プロジェクト: JackTing/ifctoolkit
        BbDirection3D(double[] x)
        {
            if (x.Length == 3)
            {

                x = MathService.Normalize(x);

                X = x[0];
                Y = x[1];
                Z = x[2];

                IfcDirection = new IfcDirection
                {
                    DirectionRatios = new List<REAL> { X, Y, Z },
                };
            }
            else
            {
                throw new ArgumentException();
            }
        }
コード例 #12
0
        public BbDirectionGeometry(
             BbDirection3D bbDirection
            )
        {
            _ifcDirection = bbDirection.IfcDirection;

            _ifcShapeRepresentation = new IfcShapeRepresentation
                {
                    ContextOfItems = BbHeaderSetting.Setting3D.GeometricRepresentationContext,
                    RepresentationIdentifier = "Body",
                    RepresentationType = "GeometricCurveSet",
                    Items = new List<IfcRepresentationItem>(),
                };
            _ifcShapeRepresentation.Items.Add(_ifcDirection);

            _ifcProductDefinitionShape = new IfcProductDefinitionShape
                {
                    // Name=
                    // Description =
                    Representations = new List<IfcRepresentation>(),
                };
            _ifcProductDefinitionShape.Representations.Add(_ifcShapeRepresentation);
        }
コード例 #13
0
ファイル: IfcDirection.cs プロジェクト: JackTing/ifctoolkit
 /// <summary>
 /// Returns a new normalized equivalent of the current vector.
 /// </summary>
 /// <returns>The normalized equivalent of the current vector.</returns>
 //public IfcDirection GetNormal()
 //{
 //    var normal = new IfcDirection(this);
 //    normal.Normalize();
 //    return normal;
 //}
 /// <summary>
 /// Returns a dot product of the current vector and the given vector.
 /// </summary>
 /// <param name="dir">The vector to be used.</param>
 /// <returns>The dot product of the vectors.</returns>
 public double Dot(IfcDirection dir)
 {
     return DirectionRatios[0] * dir.DirectionRatios[0]
            + DirectionRatios[1] * dir.DirectionRatios[1]
            + DirectionRatios[2] * dir.DirectionRatios[2];
 }
コード例 #14
0
ファイル: IfcDirection.cs プロジェクト: JackTing/ifctoolkit
 /// <summary>
 /// Returns a new cross product vector of the current vector and the given vector.
 /// </summary>
 /// <param name="dir">The vector to be used.</param>
 /// <returns>The new cross product vector.</returns>
 public IfcDirection Cross(IfcDirection dir)
 {
     return new IfcDirection(DirectionRatios[1] * dir.DirectionRatios[2] - DirectionRatios[2] * dir.DirectionRatios[1],
                             DirectionRatios[2] * dir.DirectionRatios[0] - DirectionRatios[0] * dir.DirectionRatios[2],
                             DirectionRatios[0] * dir.DirectionRatios[1] - DirectionRatios[1] * dir.DirectionRatios[0]);
 }
コード例 #15
0
ファイル: IfcDirection.cs プロジェクト: JackTing/ifctoolkit
 public static IfcDirection GetCrossProduct(IfcDirection directionX, IfcDirection directionY)
 {
     double X, Y, Z;
     X = directionX.DirectionRatios[1] * directionY.DirectionRatios[2]
         - directionX.DirectionRatios[2] * directionY.DirectionRatios[1];
     Y = directionX.DirectionRatios[2] * directionY.DirectionRatios[0]
         - directionX.DirectionRatios[0] * directionY.DirectionRatios[2];
     Z = directionX.DirectionRatios[0] * directionY.DirectionRatios[1]
         - directionX.DirectionRatios[1] * directionY.DirectionRatios[0];
     var ret = new IfcDirection(X, Y, Z);
     // ret.MakeUnitVector();
     return ret;
 }
コード例 #16
0
ファイル: IfcDirection.cs プロジェクト: JackTing/ifctoolkit
 /// <summary>
 /// Returns a dot product of the given two vectors.
 /// </summary>
 /// <param name="dir1">The first vector to be used.</param>
 /// <param name="dir2">The second vector to be used.</param>
 /// <returns>The dot product of the vectors.</returns>
 public static double Dot(IfcDirection dir1, IfcDirection dir2)
 {
     return dir1.Dot(dir2);
 }
コード例 #17
0
ファイル: IfcDirection.cs プロジェクト: JackTing/ifctoolkit
 /// <summary>
 /// Returns a new cross product vector of the given two vectors.
 /// </summary>
 /// <param name="dir1">The first vector to be used.</param>
 /// <param name="dir2">The second vector to be used.</param>
 /// <returns>The new cross product vector.</returns>
 public static IfcDirection Cross(IfcDirection dir1, IfcDirection dir2)
 {
     return dir1.Cross(dir2);
 }
コード例 #18
0
ファイル: IfcDirection.cs プロジェクト: JackTing/ifctoolkit
        //public override string ToString()
        //{
        //    return string.Format("({0:0.000}, {1:0.000}, {2:0.000})", DirectionRatios[0], DirectionRatios[1], DirectionRatios[2]);
        //}
        public static void AngleToDirection2D(double radian, out IfcDirection xAxisDirection, out IfcDirection yAxisDirection)
        {
            // rotation matrix = | cos -sin |
            //                   | sin  cos |

            xAxisDirection = new IfcDirection(Math.Cos(radian), -Math.Sin(radian));
            yAxisDirection = new IfcDirection(-Math.Sin(radian), Math.Cos(radian));
        }
コード例 #19
0
ファイル: IfcDirection.cs プロジェクト: mind-peace/ifctoolkit
        /// <summary>
        /// Returns a new normalized equivalent of the current vector.
        /// </summary>
        /// <returns>The normalized equivalent of the current vector.</returns>
        //public IfcDirection GetNormal()
        //{
        //    var normal = new IfcDirection(this);
        //    normal.Normalize();

        //    return normal;
        //}

        /// <summary>
        /// Returns a dot product of the current vector and the given vector.
        /// </summary>
        /// <param name="dir">The vector to be used.</param>
        /// <returns>The dot product of the vectors.</returns>
        public double Dot(IfcDirection dir)
        {
            return(DirectionRatios[0] * dir.DirectionRatios[0]
                   + DirectionRatios[1] * dir.DirectionRatios[1]
                   + DirectionRatios[2] * dir.DirectionRatios[2]);
        }
コード例 #20
0
ファイル: IfcDirection.cs プロジェクト: mind-peace/ifctoolkit
 /// <summary>
 /// Returns a dot product of the given two vectors.
 /// </summary>
 /// <param name="dir1">The first vector to be used.</param>
 /// <param name="dir2">The second vector to be used.</param>
 /// <returns>The dot product of the vectors.</returns>
 public static double Dot(IfcDirection dir1, IfcDirection dir2)
 {
     return(dir1.Dot(dir2));
 }
コード例 #21
0
        public static IfcProductDefinitionShape CreateExtruded(IfcRepresentationContext representationContext,
                                                               IfcProfileDef ifcProfileDef, IfcAxis2Placement3D placement3D, IfcDirection direction, double depth)
        {
            var extruded = new IfcExtrudedAreaSolid
            {
                SweptArea         = ifcProfileDef,
                Position          = placement3D,
                ExtrudedDirection = direction,
                Depth             = depth,
            };

            var shaperep = new IfcShapeRepresentation
            {
                ContextOfItems           = representationContext,
                RepresentationIdentifier = "Body",
                RepresentationType       = "SweptSolid",
                Items = new List <IfcRepresentationItem>(),
            };

            shaperep.Items.Add(extruded);

            var ifcShape = new IfcProductDefinitionShape
            {
                // Name=
                // Description =
                Representations = new List <IfcRepresentation>(),
            };

            ifcShape.Representations.Add(shaperep);

            return(ifcShape);
        }
コード例 #22
0
ファイル: IfcDirection.cs プロジェクト: mind-peace/ifctoolkit
 /// <summary>
 /// Returns a new cross product vector of the current vector and the given vector.
 /// </summary>
 /// <param name="dir">The vector to be used.</param>
 /// <returns>The new cross product vector.</returns>
 public IfcDirection Cross(IfcDirection dir)
 {
     return(new IfcDirection(DirectionRatios[1] * dir.DirectionRatios[2] - DirectionRatios[2] * dir.DirectionRatios[1],
                             DirectionRatios[2] * dir.DirectionRatios[0] - DirectionRatios[0] * dir.DirectionRatios[2],
                             DirectionRatios[0] * dir.DirectionRatios[1] - DirectionRatios[1] * dir.DirectionRatios[0]));
 }
コード例 #23
0
ファイル: IfcDirection.cs プロジェクト: JackTing/ifctoolkit
        //public double Normalize()
        //{
        //    return this.Normalize(1.0);
        //}
        /// <summary>
        /// Normalizes the vector using the given length.
        /// </summary>
        /// <param name="newLength">The length to be used.</param>
        /// <returns>The normalized vector's length.</returns>
        //public double Normalize(double newLength)
        //{
        //    var length = Math.Sqrt(DirectionRatios[0] * DirectionRatios[0] + DirectionRatios[1] * DirectionRatios[1] + DirectionRatios[2] * DirectionRatios[2]);
        //    var minLength = MathService.Epsilon;
        //    if (length > minLength)
        //    {
        //        DirectionRatios[0] = DirectionRatios[0] / length * newLength;
        //        DirectionRatios[1] = DirectionRatios[1] / length * newLength;
        //        DirectionRatios[2] = DirectionRatios[2] / length * newLength;
        //        length = newLength;
        //    }
        //    return length;
        //}
        /// <summary>
        /// Gets the angle (in radians) between the current vector and the given vector.
        /// </summary>
        /// <param name="dir">The vector to be used.</param>
        /// <returns>The angle between the vectors in radians.</returns>
        public double GetAngleBetween(IfcDirection dir)
        {
            var from = this;
            var that = dir;

            if (Math.Abs(from.Dot(that) - 1.0) <= MathService.Epsilon)
                return 0.0;
            return Math.Abs(@from.Dot(that) + 1.0) <= MathService.Epsilon ? Math.PI : Math.Acos(@from.Dot(that));
        }
コード例 #24
0
ファイル: IfcDirection.cs プロジェクト: mind-peace/ifctoolkit
 /// <summary>
 /// Returns a new cross product vector of the given two vectors.
 /// </summary>
 /// <param name="dir1">The first vector to be used.</param>
 /// <param name="dir2">The second vector to be used.</param>
 /// <returns>The new cross product vector.</returns>
 public static IfcDirection Cross(IfcDirection dir1, IfcDirection dir2)
 {
     return(dir1.Cross(dir2));
 }
コード例 #25
0
ファイル: IfcDirection.cs プロジェクト: JackTing/ifctoolkit
 protected bool Equals(IfcDirection other)
 {
     return Equals(DirectionRatios, other.DirectionRatios);
 }
コード例 #26
0
ファイル: IfcDirection.cs プロジェクト: mind-peace/ifctoolkit
 protected bool Equals(IfcDirection other)
 {
     return(Equals(DirectionRatios, other.DirectionRatios));
 }