Beispiel #1
0
        public void Copy(DMesh3 copy, bool bNormals = true, bool bColors = true, bool bUVs = true)
        {
            vertices = new DVector <double>(copy.vertices);

            normals = (bNormals && copy.normals != null) ? new DVector <float>(copy.normals) : null;
            colors  = (bColors && copy.colors != null) ? new DVector <float>(copy.colors) : null;
            uv      = (bUVs && copy.uv != null) ? new DVector <float>(copy.uv) : null;

            vertices_refcount = new RefCountVector(copy.vertices_refcount);
            vertex_edges      = new DVector <List <int> >(copy.vertex_edges);
            int N = vertex_edges.Length;

            for (int i = 0; i < N; ++i)
            {
                if (vertices_refcount.isValid(i))
                {
                    vertex_edges[i] = new List <int>(copy.vertex_edges[i]);
                }
                else
                {
                    vertex_edges[i] = null;
                }
            }

            triangles          = new DVector <int>(copy.triangles);
            triangle_edges     = new DVector <int>(copy.triangle_edges);
            triangles_refcount = new RefCountVector(copy.triangles_refcount);
            if (copy.triangle_groups != null)
            {
                triangle_groups = new DVector <int>(copy.triangle_groups);
            }

            edges          = new DVector <int>(copy.edges);
            edges_refcount = new RefCountVector(copy.edges_refcount);
        }
Beispiel #2
0
        public DMesh3(bool bWantNormals = true, bool bWantColors = false, bool bWantUVs = false, bool bWantTriGroups = false)
        {
            vertices = new DVector <double>();
            if (bWantNormals)
            {
                normals = new DVector <float>();
            }
            if (bWantColors)
            {
                colors = new DVector <float>();
            }
            if (bWantUVs)
            {
                uv = new DVector <float>();
            }
            vertex_edges      = new DVector <List <int> >();
            vertices_refcount = new RefCountVector();

            triangles          = new DVector <int>();
            triangle_edges     = new DVector <int>();
            triangles_refcount = new RefCountVector();
            if (bWantTriGroups)
            {
                triangle_groups = new DVector <int>();
            }

            edges          = new DVector <int>();
            edges_refcount = new RefCountVector();
        }
Beispiel #3
0
        public DGraph()
        {
            vertex_edges      = new DVector <List <int> >();
            vertices_refcount = new RefCountVector();

            edges          = new DVector <int>();
            edges_refcount = new RefCountVector();
            max_group_id   = 0;
        }
Beispiel #4
0
        public void CompactCopy(DMesh3 copy, bool bNormals = true, bool bColors = true, bool bUVs = true)
        {
            if (copy.IsCompact)
            {
                Copy(copy, bNormals, bColors, bUVs);
                return;
            }

            vertices           = new DVector <double>();
            vertex_edges       = new DVector <List <int> >();
            vertices_refcount  = new RefCountVector();
            triangles          = new DVector <int>();
            triangle_edges     = new DVector <int>();
            triangles_refcount = new RefCountVector();
            edges          = new DVector <int>();
            edges_refcount = new RefCountVector();

            normals = (bNormals && copy.normals != null) ? new DVector <float>() : null;
            colors  = (bColors && copy.colors != null) ? new DVector <float>() : null;
            uv      = (bUVs && copy.uv != null) ? new DVector <float>() : null;

            // [TODO] if we knew some of these were dense we could copy directly...

            NewVertexInfo vinfo = new NewVertexInfo();

            int[] mapV = new int[copy.MaxVertexID];
            foreach (int vid in copy.vertices_refcount)
            {
                copy.GetVertex(vid, ref vinfo, bNormals, bColors, bUVs);
                mapV[vid] = AppendVertex(vinfo);
            }

            // [TODO] would be much faster to explicitly copy triangle & edge data structures!!

            foreach (int tid in copy.triangles_refcount)
            {
                Index3i t = copy.GetTriangle(tid);
                t.a = mapV[t.a]; t.b = mapV[t.b]; t.c = mapV[t.c];
                int g = (copy.HasTriangleGroups) ? copy.GetTriangleGroup(tid) : InvalidID;
                AppendTriangle(t, g);
            }
        }
 public RefCountVector(RefCountVector copy)
 {
     ref_counts   = new DVector <short>(copy.ref_counts);
     free_indices = new DVector <int>(copy.free_indices);
     used_count   = copy.used_count;
 }