📄 parameterization_polyhedron_adaptor_ex.h
字号:
if (prev_vertex == NULL && next_vertex == NULL) { // Loop over all incident halfedges Halfedge_around_vertex_circulator cir = vertex->vertex_begin(), cir_end = cir; CGAL_For_all(cir, cir_end) cir->is_parameterized(parameterized); } else // if seam vertex { assert(prev_vertex != NULL); assert(next_vertex != NULL); // first inner halfedge (for a clockwise rotation) Halfedge_around_vertex_circulator cir( get_halfedge((Vertex*)&*next_vertex, vertex) ); // past-the-end inner halfedge (for a clockwise rotation) Halfedge_around_vertex_circulator cir_end( get_halfedge((Vertex*)&*prev_vertex, vertex) ); // Loop over incident halfedges at the "right" // of the prev_vertex -> vertex -> next_vertex line CGAL_For_all(cir, cir_end) cir->is_parameterized(parameterized); } } // Get/set index of corners at the "right" // of the prev_vertex -> vertex -> next_vertex line. // Default value is undefined. // (stored in incident halfedges) int get_corners_index(Vertex_const_handle vertex, Vertex_const_handle prev_vertex, Vertex_const_handle next_vertex) const { // if inner vertex if (prev_vertex == NULL && next_vertex == NULL) { // get index from any incident halfedge return vertex->halfedge()->index(); } else // if seam vertex { assert(prev_vertex != NULL); assert(next_vertex != NULL); // get index from first inner halfedge (clockwise) Halfedge_around_vertex_const_circulator cir( get_halfedge(next_vertex, vertex) ); return cir->index(); } } void set_corners_index(Vertex_handle vertex, Vertex_const_handle prev_vertex, Vertex_const_handle next_vertex, int index) { // if inner vertex if (prev_vertex == NULL && next_vertex == NULL) { // Loop over all incident halfedges Halfedge_around_vertex_circulator cir = vertex->vertex_begin(), cir_end = cir; CGAL_For_all(cir, cir_end) cir->index(index); } else // if seam vertex { assert(prev_vertex != NULL); assert(next_vertex != NULL); // first inner halfedge (for a clockwise rotation) Halfedge_around_vertex_circulator cir( get_halfedge((Vertex*)&*next_vertex, vertex) ); // past-the-end inner halfedge (for a clockwise rotation) Halfedge_around_vertex_circulator cir_end( get_halfedge((Vertex*)&*prev_vertex, vertex) ); // Loop over incident halfedges at the "right" // of the prev_vertex -> vertex -> next_vertex line CGAL_For_all(cir, cir_end) cir->index(index); } } // Get/set all purpose tag of corners at the "right" // of the prev_vertex -> vertex -> next_vertex line. // Default value is undefined. // (stored in incident halfedges) int get_corners_tag(Vertex_const_handle vertex, Vertex_const_handle prev_vertex, Vertex_const_handle next_vertex) const { // if inner vertex if (prev_vertex == NULL && next_vertex == NULL) { // get tag from any incident halfedge return vertex->halfedge()->tag(); } else // if seam vertex { assert(prev_vertex != NULL); assert(next_vertex != NULL); // get tag from first inner halfedge (clockwise) Halfedge_around_vertex_const_circulator cir( get_halfedge(next_vertex, vertex) ); return cir->tag(); } } void set_corners_tag(Vertex_handle vertex, Vertex_const_handle prev_vertex, Vertex_const_handle next_vertex, int tag) { // if inner vertex if (prev_vertex == NULL && next_vertex == NULL) { // Loop over all incident halfedges Halfedge_around_vertex_circulator cir = vertex->vertex_begin(), cir_end = cir; CGAL_For_all(cir, cir_end) cir->tag(tag); } else // if seam vertex { assert(prev_vertex != NULL); assert(next_vertex != NULL); // first inner halfedge (for a clockwise rotation) Halfedge_around_vertex_circulator cir( get_halfedge((Vertex*)&*next_vertex, vertex) ); // past-the-end inner halfedge (for a clockwise rotation) Halfedge_around_vertex_circulator cir_end( get_halfedge((Vertex*)&*prev_vertex, vertex) ); // Loop over incident halfedges at the "right" // of the prev_vertex -> vertex -> next_vertex line CGAL_For_all(cir, cir_end) cir->tag(tag); } }// Private operationsprivate: // Extract mesh's longest border std::list<Vertex_handle> extract_longest_border() { std::list<Vertex_handle> longest_border; // returned list double max_len = 0; // length of longest_border // Tag all vertices as unprocessed const int tag_free = 0; const int tag_done = 1; for (Vertex_iterator it=mesh_vertices_begin(); it!=mesh_vertices_end(); it++) set_vertex_tag(it, tag_free); // find all closed borders and keep longest one int nb = 0; while (1) { // Find a border tagged as "free" and tag it as "processed" std::list<Vertex_handle> border = find_free_border(tag_free, tag_done); if(border.empty()) break; // compute total len of 'border' double len = 0.0; std::list<Vertex_handle>::const_iterator it; for(it = border.begin(); it != border.end(); it++) { // Get next iterator (looping) std::list<Vertex_handle>::const_iterator next = it; next++; if (next == border.end()) next = border.begin(); Vector_3 vect = get_vertex_position(*next) - get_vertex_position(*it); len += std::sqrt(vect*vect); } // Keep 'border' if longer if (len > max_len) { longest_border = border; max_len = len; } nb++; } return longest_border; } // Find a border tagged as "free" and tag it as "processed" // Return an empty list if not found std::list<Vertex_handle> find_free_border(int tag_free, int tag_done) { std::list<Vertex_handle> border; // returned list // get any border vertex with "free" tag Vertex_handle seed_vertex = NULL; for (Vertex_iterator pVertex = mesh_vertices_begin(); pVertex != mesh_vertices_end(); pVertex++) { if (is_vertex_on_border(pVertex) && get_vertex_tag(pVertex) == tag_free) { seed_vertex = pVertex; break; } } if (seed_vertex == NULL) return border; // return empty list // Get the border containing seed_vertex border = get_border(seed_vertex); // Tag border vertices as "processed" std::list<Vertex_handle>::iterator it; for(it = border.begin(); it != border.end(); it++) set_vertex_tag(*it, tag_done); return border; }// Fieldsprivate: // The adapted mesh (cannot be NULL) Polyhedron_ex& m_polyhedron; // Main border of a topological disc inside m_polyhedron (may be empty) std::list<Vertex_handle> m_main_border;// Private typesprivate: // Utility class to generate the Vertex_around_facet_circulator type struct Project_halfedge_vertex { typedef Halfedge argument_type; typedef Parameterization_polyhedron_adaptor_ex::Vertex Vertex; typedef Vertex result_type; typedef CGAL::Arity_tag<1> Arity; // Get the target vertex of a halfedge Vertex& operator()(Halfedge& h) const { return *(h.vertex()); } const Vertex& operator()(const Halfedge& h) const { return *(h.vertex()); } }; friend struct Project_halfedge_vertex; // SUN's CC 5.50 requires that // Utility class to generate the Border_vertex_iterator type struct Project_vertex_handle_vertex { typedef Vertex_handle argument_type; typedef Parameterization_polyhedron_adaptor_ex::Vertex Vertex; typedef Vertex result_type; typedef CGAL::Arity_tag<1> Arity; // Convert Vertex_handle to Vertex Vertex& operator()(Vertex_handle& vh) const { return *vh; } const Vertex& operator()(const Vertex_handle& vh) const { return *vh; } }; friend struct Project_vertex_handle_vertex; // SUN's CC 5.50 requires that // This class is used to generate the Vertex_around_vertex_circulator type struct Project_opposite_halfedge_vertex { typedef Halfedge argument_type; typedef Parameterization_polyhedron_adaptor_ex::Vertex Vertex; typedef Vertex result_type; typedef CGAL::Arity_tag<1> Arity; // Get the source vertex of a halfedge Vertex& operator()(Halfedge& h) const { return *(h.opposite()->vertex()); } const Vertex& operator()(const Halfedge& h) const { return *(h.opposite()->vertex()); } }; friend struct Project_opposite_halfedge_vertex; // SUN's CC 5.50 requires that}; // Parameterization_polyhedron_adaptor_ex#endif //PARAMETERIZATION_POLYHEDRON_ADAPTOREX_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -