Exemplo 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)
        {
            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();
        }