public void subdivide_face(CLSFace f) { CLSEdgeVector f_edges = g.face_edges(f); Debug.Assert(f_edges.size() == 4); CLSVertex center = g.add_vertex(); foreach (CLSEdge e in f_edges) { CLSVertex src = g.source(e); CLSVertex trg = g.target(e); // new vertex at mid-point of each edge Point mid = 0.5 * (g[src].position + g[trg].position); g[center].position += 0.25 * g[src].position; // average of four corners CLSVertex v = g.add_vertex(); g[v].position = mid; g.insert_vertex_in_edge(v, e); // this also removes the old edges... } // now loop through edges again: f_edges = g.face_edges(f); Debug.Assert(f_edges.size() == 8); foreach (CLSEdge e in f_edges) { Console.Write(e); Console.Write("\n"); } }
public boost::python.list getEdges() { boost::python.list edge_list = new boost::python.list(); foreach (CLSEdge edge in g.edges()) { // loop through each edge boost::python.list point_list = new boost::python.list(); // the endpoints of each edge CLSVertex v1 = g.source(edge); CLSVertex v2 = g.target(edge); point_list.append(g[v1].position); point_list.append(g[v2].position); edge_list.append(point_list); } return(new boost::python.list(edge_list)); }
public void init() { // initialize cl-surf // // b e1 a // e2 e4 // c e3 d CLSVertex a = g.add_vertex(); // VertexProps( Point(far,far,0) ), g); g[a].position = new Point(far, far, 0); CLSVertex b = g.add_vertex(); // VertexProps( Point(-far,far,0) ), g); g[b].position = new Point(-far, far, 0); CLSVertex c = g.add_vertex(); // VertexProps( Point(-far,-far,0) ), g); g[c].position = new Point(-far, -far, 0); CLSVertex d = g.add_vertex(); // VertexProps( Point(far,-far,0) ), g); g[c].position = new Point(far, -far, 0); CLSFace f_outer = g.add_face(); CLSFace f_inner = g.add_face(); CLSEdge e1 = g.add_edge(a, b); CLSEdge e1t = g.add_edge(b, a); CLSEdge e2 = g.add_edge(b, c); CLSEdge e2t = g.add_edge(c, b); CLSEdge e3 = g.add_edge(c, d); CLSEdge e3t = g.add_edge(d, c); CLSEdge e4 = g.add_edge(d, a); CLSEdge e4t = g.add_edge(a, d); g[f_inner].edge = e1; g[f_outer].edge = e1t; //C++ TO C# CONVERTER TODO TASK: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created: //ORIGINAL LINE: out_face = f_outer; out_face.CopyFrom(f_outer); // twin edges g.twin_edges(e1, e1t); g.twin_edges(e2, e2t); g.twin_edges(e3, e3t); g.twin_edges(e4, e4t); // inner face: g[e1].face = f_inner; g[e2].face = f_inner; g[e3].face = f_inner; g[e4].face = f_inner; // outer face: g[e1t].face = f_outer; g[e2t].face = f_outer; g[e3t].face = f_outer; g[e4t].face = f_outer; // next-pointers: g[e1].next = e2; g[e2].next = e3; g[e3].next = e4; g[e4].next = e1; // outer next-pointers: g[e1t].next = e4t; g[e4t].next = e3t; g[e3t].next = e2t; g[e2t].next = e1t; subdivide(); }