protected int append_vertex_internal() { int vid = vertices_refcount.allocate(); vertex_edges.insert(new List <int>(), vid); updateTimeStamp(true); return(vid); }
public int AppendVertex(Vector2d v) { int vid = vertices_refcount.allocate(); int i = 2 * vid; vertices.insert(v[1], i + 1); vertices.insert(v[0], i); vertex_edges.insert(new List <int>(), vid); updateTimeStamp(true); return(vid); }
public int AppendTriangle(Index3i tv, int gid = -1) { if (IsVertex(tv[0]) == false || IsVertex(tv[1]) == false || IsVertex(tv[2]) == false) { Util.gDevAssert(false); return(InvalidID); } if (tv[0] == tv[1] || tv[0] == tv[2] || tv[1] == tv[2]) { Util.gDevAssert(false); return(InvalidID); } // look up edges. if any already have two triangles, this would // create non-manifold geometry and so we do not allow it int e0 = find_edge(tv[0], tv[1]); int e1 = find_edge(tv[1], tv[2]); int e2 = find_edge(tv[2], tv[0]); if ((e0 != InvalidID && edge_is_boundary(e0) == false) || (e1 != InvalidID && edge_is_boundary(e1) == false) || (e2 != InvalidID && edge_is_boundary(e2) == false)) { return(NonManifoldID); } // now safe to insert triangle int tid = triangles_refcount.allocate(); int i = 3 * tid; triangles.insert(tv[2], i + 2); triangles.insert(tv[1], i + 1); triangles.insert(tv[0], i); if (triangle_groups != null) { triangle_groups.insert(gid, tid); } // increment ref counts and update/create edges vertices_refcount.increment(tv[0]); vertices_refcount.increment(tv[1]); vertices_refcount.increment(tv[2]); add_tri_edge(tid, tv[0], tv[1], 0, e0); add_tri_edge(tid, tv[1], tv[2], 1, e1); add_tri_edge(tid, tv[2], tv[0], 2, e2); updateTimeStamp(); return(tid); }
protected int add_edge(int a, int b, int gid) { if (b < a) { int t = b; b = a; a = t; } int eid = edges_refcount.allocate(); int i = 3 * eid; edges.insert(a, i); edges.insert(b, i + 1); edges.insert(gid, i + 2); vertex_edges[a].Add(eid); vertex_edges[b].Add(eid); return(eid); }
public int AppendVertex(Vector2d v, Vector3f c) { int vid = vertices_refcount.allocate(); int i = 2 * vid; vertices.insert(v[1], i + 1); vertices.insert(v[0], i); if (colors != null) { i = 3 * vid; colors.insert(c.z, i + 2); colors.insert(c.y, i + 1); colors.insert(c.x, i); } vertex_edges.insert(new List <int>(), vid); updateTimeStamp(true); return(vid); }
public int AppendVertex(NewVertexInfo info) { int vid = vertices_refcount.allocate(); int i = 3 * vid; vertices.insert(info.v[2], i + 2); vertices.insert(info.v[1], i + 1); vertices.insert(info.v[0], i); if (normals != null) { Vector3f n = (info.bHaveN) ? info.n : Vector3f.AxisY; normals.insert(n[2], i + 2); normals.insert(n[1], i + 1); normals.insert(n[0], i); } if (colors != null) { Vector3f c = (info.bHaveC) ? info.c : Vector3f.One; colors.insert(c[2], i + 2); colors.insert(c[1], i + 1); colors.insert(c[0], i); } if (uv != null) { Vector2f u = (info.bHaveUV) ? info.uv : Vector2f.Zero; int j = 2 * vid; uv.insert(u[1], j + 1); uv.insert(u[0], j); } vertex_edges.insert(new List <int>(), vid); updateTimeStamp(); return(vid); }