Esempio n. 1
0
        /// <summary>
        /// Constructs a Object3d object based on a solid file.
        /// </summary>
        /// <param name="solid">solid used to construct the Object3d object</param>
        public Object3D(Solid solid)
        {
            Vertex v1, v2, v3, vertex;

            Vector3d[] verticesPoints = solid.GetVertices();
            int[]      indices        = solid.GetIndices();
            var        verticesTemp   = new List <Vertex>();

            //create vertices
            Vertices = new List <Vertex>();
            for (int i = 0; i < verticesPoints.Length; i++)
            {
                vertex = AddVertex(verticesPoints[i], Status.UNKNOWN);
                verticesTemp.Add(vertex);
            }

            //create faces
            Faces = new List <Face>();
            for (int i = 0; i < indices.Length; i = i + 3)
            {
                v1 = verticesTemp[indices[i]];
                v2 = verticesTemp[indices[i + 1]];
                v3 = verticesTemp[indices[i + 2]];
                AddFace(v1, v2, v3);
            }

            //create bound
            _Bound = new Bound(verticesPoints);
        }
Esempio n. 2
0
        /// <summary>
        /// Constructs a Object3d object based on a solid file.
        /// </summary>
        /// <param name="solid">solid used to construct the Object3d object</param>
        public Object3D(Solid solid)
        {
            var verticesPoints = CollectionPool <Vector3Double> .ListCell.Create();

            solid.GetVertices(verticesPoints);

            var indices = CollectionPool <int> .ListCell.Create();

            solid.GetTriangles(indices);

            using (var vsCache = CollectionPool <Vertex> .ListCell.Create())
            {
                //create vertices
                m_vertices = CollectionPool <Vertex> .ListCell.Create();

                for (int i = 0; i < verticesPoints.Count; i++)
                {
                    var vertex = AddVertex(verticesPoints[i], Status.UNKNOWN);
                    vsCache.Add(vertex);
                }

                //create faces
                m_faces = CollectionPool <Face> .ListCell.Create();

                for (int i = 0; i < indices.Count; i += 3)
                {
                    var v1 = vsCache[indices[i]];
                    var v2 = vsCache[indices[i + 1]];
                    var v3 = vsCache[indices[i + 2]];
                    AddFace(v1, v2, v3);
                }
            }

            //create bound
            m_bound = new Bound(verticesPoints);
            indices.Dispose();
            verticesPoints.Dispose();
        }