Exemplo n.º 1
0
 /// <summary>
 /// Inicializa una nueva instancia de la clase <c>Punto</c>.
 /// </summary>
 public Punto()
     : base(DxfCodigoObjeto.Punto)
 {
     this.ubicacion = Vector3f.Nulo;
     //this.thickness = 0.0f;
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
     this.normal = Vector3f.UnitarioZ;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Inicializa una nueva instancia de la clase <c>linea</c>.
 /// </summary>
 public Linea()
     : base(DxfCodigoObjeto.Linea)
 {
     this.puntoInicio = Vector3f.Nulo;
     this.puntoFin = Vector3f.Nulo;
     //this.thickness = 0.0f;
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
     this.normal = Vector3f.UnitarioZ;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <c>Vertex</c> class.
 /// </summary>
 /// <param name="location">Vertex <see cref="netDxf.Vector2f">location</see>.</param>
 public Vertex(Vector2f location)
     : base(DxfCodigoObjeto.Vertex)
 {
     this.flags = VertexTypeFlags.PolylineVertex;
     this.location = new Vector3f(location.X, location.Y, 0.0f);
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
     this.bulge = 0.0f;
     this.beginThickness = 0.0f;
     this.endThickness = 0.0f;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Inicializa una nueva instancia de la clase <c>Circulo</c>.
 /// </summary>
 public Circulo()
     : base(DxfCodigoObjeto.Circulo)
 {
     this.centro = Vector3f.Nulo;
     this.radio = 1.0f;
     this.inicio = Vector3f.Nulo;
     //this.thickness = 0.0f;
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
     this.normal = Vector3f.UnitarioZ;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <c>Polyline</c> class.
 /// </summary>
 /// <param name="vertexes">Polyline <see cref="LightWeightPolylineVertex">vertex</see> list in object coordinates.</param>
 public LightWeightPolyline(List<LightWeightPolylineVertex> vertexes)
     : base(DxfCodigoObjeto.LightWeightPolyline)
 {
     this.vertexes = vertexes;
     this.isClosed = false;
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
     this.normal = Vector3f.UnitarioZ;
     this.elevation = 0.0f;
     this.thickness = 0.0f;
     this.flags = PolylineTypeFlags.OpenPolyline;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Inicializa una nueva instancia de la clase <c>Arco</c>
 /// </summary>
 public Arco()
     : base(DxfCodigoObjeto.Arco)
 {
     this.centro = Vector3f.Nulo;
     this.radio = 0.0f;
     this.anguloInicio = 0.0f;
     this.anguloFin = 0.0f;
     //this.thickness = 0.0f;
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
     this.normal = Vector3f.UnitarioZ;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Inicializa una nueva instancia de la clase <c>Elipse</c>.
 /// </summary>
 public Elipse()
     : base(DxfCodigoObjeto.Elipse)
 {
     this.centro = Vector3f.Nulo;
     this.ejeMayor = 1.0f;
     this.ejeMenor = 0.5f;
     this.anguloInicio = 0.0f;
     this.anguloFin = 360.0f;
     this.rotacion = 0.0f;
     //this.curvePoints = 30;
     //this.thickness = 0.0f;
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
     this.normal = Vector3f.UnitarioZ;
 }
Exemplo n.º 8
0
 public void InvertirPuntos()
 {
     Vector3f ptoTemp = this.puntoInicio;
     this.puntoInicio = this.puntoFin;
     this.puntoFin = ptoTemp;
     this.invertido = true;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <c>Polyline</c> class.
 /// </summary>
 public Polilinea()
     : base(DxfCodigoObjeto.Polilinea)
 {
     this.vertexes = new List<PolylineVertex>();
     this.isClosed = false;
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
     this.normal = Vector3f.UnitarioZ;
     this.elevation = 0.0f;
     this.flags = PolylineTypeFlags.OpenPolyline;
     //this.endSequence = new EndSequence();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <c>Polyline</c> class.
 /// </summary>
 /// <param name="vertexes">Polyline vertex list in object coordinates.</param>
 /// <param name="isClosed">Sets if the polyline is closed</param>
 public Polilinea(List<PolylineVertex> vertexes, bool isClosed)
     : base(DxfCodigoObjeto.Polilinea)
 {
     this.vertexes = vertexes;
     this.isClosed = isClosed;
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
     this.normal = Vector3f.UnitarioZ;
     this.elevation = 0.0f;
     //this.thickness = 0.0f;
     this.flags = isClosed ? PolylineTypeFlags.ClosedPolylineOrClosedPolygonMeshInM : PolylineTypeFlags.OpenPolyline;
     //this.endSequence = new EndSequence();
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <c>Polyline3dVertex</c> class.
 /// </summary>
 /// <param name="location">Polyline <see cref="Vector3f">vertex</see> coordinates.</param>
 public Polyline3dVertex(Vector3f location)
     : base(DxfCodigoObjeto.Vertex)
 {
     this.flags = VertexTypeFlags.Polyline3dVertex;
     this.location = location;
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Obtains the dot product of two vectors.
 /// </summary>
 /// <param name="u">Vector3f.</param>
 /// <param name="v">Vector3f.</param>
 /// <returns>The dot product.</returns>
 public static float DotProduct(Vector3f u, Vector3f v)
 {
     return (u.X * v.X) + (u.Y * v.Y) + (u.Z * v.Z);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Obtains the distance between two points.
 /// </summary>
 /// <param name="u">Vector3f.</param>
 /// <param name="v">Vector3f.</param>
 /// <returns>Distancie.</returns>
 public static float Distance(Vector3f u, Vector3f v)
 {
     return (float)(Math.Sqrt((u.X - v.X) * (u.X - v.X) + (u.Y - v.Y) * (u.Y - v.Y) + (u.Z - v.Z) * (u.Z - v.Z)));
 }
Exemplo n.º 14
0
        public void InvertirPuntos()
        {
            //invierto los puntos
            Vector3f ptoTemp = this.puntoInicio;
            this.puntoInicio = this.puntoFin;
            this.puntoFin = ptoTemp;

            //e invierto el sentido del arco
            if (this.sentido == 'A') this.sentido = 'H';
            else this.sentido = 'A';

            this.invertido = true;
        }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <c>PolylineVertex</c> class.
 /// </summary>
 public PolyfaceMeshVertex()
     : base(DxfCodigoObjeto.Vertex)
 {
     this.flags = VertexTypeFlags.PolyfaceMeshVertex | VertexTypeFlags.Polygon3dMesh;
     this.location = Vector3f.Nulo;
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
 }
Exemplo n.º 16
0
 public bool Equals(Vector3f obj)
 {
     return obj.x == this.x && obj.y == this.y && obj.z == this.z;
 }
Exemplo n.º 17
0
        /// </summary>
        /// Check if the components of two vectors are approximate equals.
        /// <param name="obj">Vector3f.</param>
        /// <param name="threshold">Maximun tolerance.</param>
        /// <returns>True if the three components are almost equal or false in anyother case.</returns>
        public bool Equals(Vector3f obj, float threshold)
        {
            if (Math.Abs(obj.X - this.x) > threshold)
            {
                return false;
            }
            if (Math.Abs(obj.Y - this.y) > threshold)
            {
                return false;
            }
            if (Math.Abs(obj.Z - this.z) > threshold)
            {
                return false;
            }

            return true;
        }
Exemplo n.º 18
0
 /// <summary>
 /// Obtains the square distance between two points.
 /// </summary>
 /// <param name="u">Vector3f.</param>
 /// <param name="v">Vector3f.</param>
 /// <returns>Square distance.</returns>
 public static float SquareDistance(Vector3f u, Vector3f v)
 {
     return (u.X - v.X) * (u.X - v.X) + (u.Y - v.Y) * (u.Y - v.Y) + (u.Z - v.Z) * (u.Z - v.Z);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Rounds the components of a vector.
 /// </summary>
 /// <param name="u">Vector3f.</param>
 /// <param name="numDigits">Number of significative defcimal digits.</param>
 /// <returns>Vector3F.</returns>
 public static Vector3f Round(Vector3f u, int numDigits)
 {
     return new Vector3f((float)(Math.Round(u.X, numDigits)),
                         (float)(Math.Round(u.Y, numDigits)),
                         (float)(Math.Round(u.Z, numDigits)));
 }
Exemplo n.º 20
0
 /// <summary>
 /// Obtains the midpoint.
 /// </summary>
 /// <param name="u">Vector3f.</param>
 /// <param name="v">Vector3f.</param>
 /// <returns>Vector3f.</returns>
 public static Vector3f MidPoint(Vector3f u, Vector3f v)
 {
     return new Vector3f((v.X + u.X) * 0.5F, (v.Y + u.Y) * 0.5F, (v.Z + u.Z) * 0.5F);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Checks if two vectors are perpendicular.
 /// </summary>
 /// <param name="u">Vector3f.</param>
 /// <param name="v">Vector3f.</param>
 /// <param name="threshold">Tolerance used.</param>
 /// <returns>True if are penpendicular or false in anyother case.</returns>
 public static bool ArePerpendicular(Vector3f u, Vector3f v, float threshold)
 {
     return MathHelper.IsZero(DotProduct(u, v), threshold);
 }
Exemplo n.º 22
0
 /// <summary>
 /// Checks if two vectors are parallel.
 /// </summary>
 /// <param name="u">Vector3f.</param>
 /// <param name="v">Vector3f.</param>
 /// <param name="threshold">Tolerance used.</param>
 /// <returns>True if are parallel or false in anyother case.</returns>
 public static bool AreParallel(Vector3f u, Vector3f v, float threshold)
 {
     float a = u.Y * v.Z - u.Z * v.Y;
     float b = u.Z * v.X - u.X * v.Z;
     float c = u.X * v.Y - u.Y * v.X;
     if (!MathHelper.IsZero(a, threshold))
     {
         return false;
     }
     if (!MathHelper.IsZero(b, threshold))
     {
         return false;
     }
     if (!MathHelper.IsZero(c, threshold))
     {
         return false;
     }
     return true;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the PolylineVertex class.
 /// </summary>
 /// <param name="x">X coordinate.</param>
 /// <param name="y">Y coordinate.</param>
 /// <param name="z">Z coordinate.</param>
 public PolyfaceMeshVertex(float x, float y, float z)
     : base(DxfCodigoObjeto.Vertex)
 {
     this.flags = VertexTypeFlags.PolyfaceMeshVertex | VertexTypeFlags.Polygon3dMesh;
     this.location = new Vector3f(x, y, z);
     //this.layer = Layer.Default;
     //this.color = AciColor.ByLayer;
     //this.lineType = LineType.ByLayer;
 }
Exemplo n.º 24
0
 /// <summary>
 /// Obtains the cross product of two vectors.
 /// </summary>
 /// <param name="u">Vector3f.</param>
 /// <param name="v">Vector3f.</param>
 /// <returns>Vector3f.</returns>
 public static Vector3f CrossProduct(Vector3f u, Vector3f v)
 {
     float a = u.Y * v.Z - u.Z * v.Y;
     float b = u.Z * v.X - u.X * v.Z;
     float c = u.X * v.Y - u.Y * v.X;
     return new Vector3f(a, b, c);
 }
Exemplo n.º 25
0
        private Vertex ReadVertex(ref ParCodigoValor cod)
        {
            string handle = string.Empty;
            //Layer layer = Layer.Default;
            //AciColor color = AciColor.ByLayer;
            //LineType lineType = LineType.ByLayer;
            Vector3f location = new Vector3f();
            //Dictionary<ApplicationRegistry, XData> xData = new Dictionary<ApplicationRegistry, XData>();
            float endThickness = 0.0f;
            float beginThickness = 0.0f;
            float bulge = 0.0f;
            List<int> vertexIndexes = new List<int>();
            VertexTypeFlags flags = VertexTypeFlags.PolylineVertex;

            cod = this.ReadCodePair();

            while (cod.Cod != 0)
            {
                switch (cod.Cod)
                {
                    case 5:
                        handle = cod.Val;
                        cod = this.ReadCodePair();
                        break;
                    //case 8:
                    //    layer = this.GetLayer(cod.Val);
                    //    code = this.ReadCodePair();
                    //    break;
                    //case 62:
                    //    color = new AciColor(short.Parse(cod.Val));
                    //    code = this.ReadCodePair();
                    //    break;
                    //case 6:
                    //    lineType = this.GetLineType(code.Value);
                    //    code = this.ReadCodePair();
                    //    break;
                    case 10:
                        location.X = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 20:
                        location.Y = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 30:
                        location.Z = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 40:
                        beginThickness = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 41:
                        endThickness = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 42:
                        bulge = float.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 70:
                        flags = (VertexTypeFlags)int.Parse(cod.Val);
                        cod = this.ReadCodePair();
                        break;
                    case 71:
                        vertexIndexes.Add(int.Parse(cod.Val));
                        cod = this.ReadCodePair();
                        break;
                    case 72:
                        vertexIndexes.Add(int.Parse(cod.Val));
                        cod = this.ReadCodePair();
                        break;
                    case 73:
                        vertexIndexes.Add(int.Parse(cod.Val));
                        cod = this.ReadCodePair();
                        break;
                    case 74:
                        vertexIndexes.Add(int.Parse(cod.Val));
                        cod = this.ReadCodePair();
                        break;
                    //case 1001:
                    //    XData xDataItem = this.ReadXDataRecord(code.Value, ref code);
                    //    xData.Add(xDataItem.ApplicationRegistry, xDataItem);
                    //    break;
                    default:
                        if (cod.Cod >= 1000 && cod.Cod <= 1071)
                            throw new DxfInvalidCodeValueEntityException(cod.Cod, cod.Val, this.archivo,
                                                                         "The extended data of an entity must start with the application registry code " + this.fileLine);

                        cod = this.ReadCodePair();
                        break;
                }
            }

            return new Vertex
            {
                Flags = flags,
                Location = location,
                BeginThickness = beginThickness,
                Bulge = bulge,
                //Color = color,
                EndThickness = endThickness,
                //Layer = layer,
                //LineType = lineType,
                VertexIndexes = vertexIndexes.ToArray(),
                //XData = xData,
                Handle = handle
            };
        }
Exemplo n.º 26
0
 /// <summary>
 /// Obtains the angle between two vectors.
 /// </summary>
 /// <param name="u">Vector3f.</param>
 /// <param name="v">Vector3f.</param>
 /// <returns>Angle in radians.</returns>
 public static float AngleBetween(Vector3f u, Vector3f v)
 {
     float cos = DotProduct(u, v) / (u.Modulus() * v.Modulus());
     if (MathHelper.IsOne(cos))
     {
         return 0;
     }
     if (MathHelper.IsOne(-cos))
     {
         return (float)Math.PI;
     }
     return (float)Math.Acos(cos);
 }