void Scene_polyhedron_item:: init() { typedef Polyhedron::Facet_iterator Facet_iterator; // Fill indices map and get max subdomain value int max = 0; for(Facet_iterator fit = poly->facets_begin(), end = poly->facets_end() ; fit != end; ++fit) { max = (std::max)(max, fit->patch_id()); } colors_.clear(); compute_color_map(this->color(), max + 1, std::back_inserter(colors_)); }
void Scene_polyhedron_item:: init() { typedef Polyhedron::Facet_iterator Facet_iterator; if ( !plugin_has_set_color_vector_m ) { // Fill indices map and get max subdomain value int max = 0; for(Facet_iterator fit = poly->facets_begin(), end = poly->facets_end() ; fit != end; ++fit) { max = (std::max)(max, fit->patch_id()); } colors_.clear(); compute_color_map(this->color(), max + 1, std::back_inserter(colors_)); } volume=-std::numeric_limits<double>::infinity(); area=-std::numeric_limits<double>::infinity(); if (poly->is_pure_triangle()) { // compute the volume if the polyhedron is closed if (poly->is_closed()) { volume=0; Polyhedron::Vertex::Point p(0,0,0); Q_FOREACH(Polyhedron::Face_handle fh, faces(*poly)) { volume+=CGAL::volume( p, fh->halfedge()->vertex()->point(), fh->halfedge()->next()->vertex()->point(), fh->halfedge()->prev()->vertex()->point() ); } }
void Scene_polyhedron_item::triangulate_facet_color(Facet_iterator fit) const { Traits::Vector_3 normal = CGAL::Polygon_mesh_processing::compute_face_normal(fit, *poly); //check if normal contains NaN values if (normal.x() != normal.x() || normal.y() != normal.y() || normal.z() != normal.z()) { qDebug()<<"Warning : normal is not valid. Facet not displayed"; return; } P_traits cdt_traits(normal); CDT cdt(cdt_traits); Facet::Halfedge_around_facet_circulator he_circ = fit->facet_begin(), he_circ_end(he_circ); // Iterates on the vector of facet handles CDT::Vertex_handle previous, first; do { CDT::Vertex_handle vh = cdt.insert(he_circ->vertex()->point()); if(first == 0) { first = vh; } vh->info() = he_circ; if(previous != 0 && previous != vh) { cdt.insert_constraint(previous, vh); } previous = vh; } while( ++he_circ != he_circ_end ); cdt.insert_constraint(previous, first); // sets mark is_external for(CDT::All_faces_iterator afit = cdt.all_faces_begin(), end = cdt.all_faces_end(); afit != end; ++afit) { afit->info().is_external = false; } //check if the facet is external or internal std::queue<CDT::Face_handle> face_queue; face_queue.push(cdt.infinite_vertex()->face()); while(! face_queue.empty() ) { CDT::Face_handle fh = face_queue.front(); face_queue.pop(); if(fh->info().is_external) continue; fh->info().is_external = true; for(int i = 0; i <3; ++i) { if(!cdt.is_constrained(std::make_pair(fh, i))) { face_queue.push(fh->neighbor(i)); } } } //iterates on the internal faces to add the vertices to the positions vector for(CDT::Finite_faces_iterator ffit = cdt.finite_faces_begin(), end = cdt.finite_faces_end(); ffit != end; ++ffit) { if(ffit->info().is_external) continue; //Add Colors for(int i = 0; i<3; ++i) { const int this_patch_id = fit->patch_id(); color_facets.push_back(colors_[this_patch_id].redF()); color_facets.push_back(colors_[this_patch_id].greenF()); color_facets.push_back(colors_[this_patch_id].blueF()); color_facets.push_back(colors_[this_patch_id].redF()); color_facets.push_back(colors_[this_patch_id].greenF()); color_facets.push_back(colors_[this_patch_id].blueF()); } } }