std::list<CgalPoint> erGeometryExtractConvexPolygon(InputSegmentIterator debut,InputSegmentIterator fin) { CDT cdt ; std::list<CgalPoint> result; int inc(0); for( InputSegmentIterator icg = debut; icg != fin; icg++) { //std::cout << inc++ << std::endl; cdt.insert_constraint(icg->source(),icg->target()); }; CDT::Vertex_handle v_inf = cdt.infinite_vertex(); CDT::Face_circulator fc = cdt.incident_faces(v_inf); CDT::Face_circulator fi=fc; CGAL_For_all(fc,fi) { //std::cout << inc++ << " tour dans cv hull" << std::endl; int id_inf=fc->index(v_inf); CDT::Vertex_handle vp = fc->vertex(fc->cw(id_inf)); result.push_back(vp->point()); };
void Scene_nef_polyhedron_item::compute_normals_and_vertices(void) { int count = 0; positions_facets.resize(0); positions_points.resize(0); color_lines.resize(0); color_facets.resize(0); color_points.resize(0); normals.resize(0); positions_lines.resize(0); //The Facets { for(Nef_polyhedron::Halffacet_const_iterator f = nef_poly->halffacets_begin (), end = nef_poly->halffacets_end(); f != end; ++f) { if(f->is_twin()) continue; count++; Nef_polyhedron::Vector_3 v = f->plane().orthogonal_vector(); P_traits cdt_traits(v); CDT cdt(cdt_traits); for(Nef_polyhedron::Halffacet_cycle_const_iterator fc = f->facet_cycles_begin(), end = f->facet_cycles_end(); fc != end; ++fc) { if ( fc.is_shalfedge() ) { Nef_polyhedron::SHalfedge_const_handle h = fc; Nef_polyhedron::SHalfedge_around_facet_const_circulator hc(h), he(hc); CDT::Vertex_handle previous, first; do { Nef_polyhedron::SVertex_const_handle v = hc->source(); const Nef_polyhedron::Point_3& point = v->source()->point(); CDT::Vertex_handle vh = cdt.insert(point); if(first == 0) { first = vh; } vh->info() = hc->source(); if(previous != 0 && previous != vh) { cdt.insert_constraint(previous, vh); } previous = vh; } while( ++hc != he ); cdt.insert_constraint(previous, first); // sets mark is_external for(CDT::All_faces_iterator fit = cdt.all_faces_begin(), end = cdt.all_faces_end(); fit != end; ++fit) { fit->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 //and the normals to the appropriate vectors for(CDT::Finite_faces_iterator ffit = cdt.finite_faces_begin(), end = cdt.finite_faces_end(); ffit != end; ++ffit) { if(ffit->info().is_external){ continue;} for(int i = 0; i<3; i++) { positions_facets.push_back(CGAL::to_double(ffit->vertex(i)->point().x())); positions_facets.push_back(CGAL::to_double(ffit->vertex(i)->point().y())); positions_facets.push_back(CGAL::to_double(ffit->vertex(i)->point().z())); } Nef_polyhedron::Vector_3 v = f->plane().orthogonal_vector(); GLdouble normal[3]; normal[0] = CGAL::to_double(v.x()); normal[1] = CGAL::to_double(v.y()); normal[2] = CGAL::to_double(v.z()); GLdouble norm = normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]; norm = CGAL::sqrt(norm); normal[0] /= norm; normal[1] /= norm; normal[2] /= norm; normals.push_back(normal[0]); normals.push_back(normal[1]); normals.push_back(normal[2]); normals.push_back(normal[0]); normals.push_back(normal[1]); normals.push_back(normal[2]); normals.push_back(normal[0]); normals.push_back(normal[1]); normals.push_back(normal[2]); if(is_selected) { color_facets.push_back(this->color().lighter(120).redF()); color_facets.push_back(this->color().lighter(120).greenF()); color_facets.push_back(this->color().lighter(120).blueF()); color_facets.push_back(this->color().lighter(120).redF()); color_facets.push_back(this->color().lighter(120).greenF()); color_facets.push_back(this->color().lighter(120).blueF()); color_facets.push_back(this->color().lighter(120).redF()); color_facets.push_back(this->color().lighter(120).greenF()); color_facets.push_back(this->color().lighter(120).blueF()); } else { color_facets.push_back(this->color().redF()); color_facets.push_back(this->color().greenF()); color_facets.push_back(this->color().blueF()); color_facets.push_back(this->color().redF()); color_facets.push_back(this->color().greenF()); color_facets.push_back(this->color().blueF()); color_facets.push_back(this->color().redF()); color_facets.push_back(this->color().greenF()); color_facets.push_back(this->color().blueF()); } } } } } } // end facets //The Lines { for(Nef_polyhedron::Halfedge_const_iterator e = nef_poly->halfedges_begin(), end = nef_poly->halfedges_end(); e != end; ++e) { if (e->is_twin()) continue; const Nef_polyhedron::Vertex_const_handle& s = e->source(); const Nef_polyhedron::Vertex_const_handle& t = e->twin()->source(); const Nef_polyhedron::Point_3& a = s->point(); const Nef_polyhedron::Point_3& b = t->point(); positions_lines.push_back(CGAL::to_double(a.x())); positions_lines.push_back(CGAL::to_double(a.y())); positions_lines.push_back(CGAL::to_double(a.z())); positions_lines.push_back(CGAL::to_double(b.x())); positions_lines.push_back(CGAL::to_double(b.y())); positions_lines.push_back(CGAL::to_double(b.z())); if(is_selected) { color_lines.push_back(this->color().lighter(50).redF()); color_lines.push_back(this->color().lighter(50).greenF()); color_lines.push_back(this->color().lighter(50).blueF()); color_lines.push_back(this->color().lighter(50).redF()); color_lines.push_back(this->color().lighter(50).greenF()); color_lines.push_back(this->color().lighter(50).blueF()); } else { color_lines.push_back(0.0); color_lines.push_back(0.0); color_lines.push_back(0.0); color_lines.push_back(0.0); color_lines.push_back(0.0); color_lines.push_back(0.0); } } } //The points { for(Nef_polyhedron::Vertex_const_iterator v = nef_poly->vertices_begin(), end = nef_poly->vertices_end(); v != end; ++v) { const Nef_polyhedron::Point_3& p = v->point(); positions_points.push_back(CGAL::to_double(p.x())); positions_points.push_back(CGAL::to_double(p.y())); positions_points.push_back(CGAL::to_double(p.z())); color_points.push_back(this->color().lighter(50).redF()); color_points.push_back(this->color().lighter(50).greenF()); color_points.push_back(this->color().lighter(50).blueF()); color_points.push_back(this->color().lighter(50).redF()); color_points.push_back(this->color().lighter(50).greenF()); color_points.push_back(this->color().lighter(50).blueF()); } } //end points }
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()); } } }
void Scene_polyhedron_item::triangulate_facet(Facet_iterator fit) const { //Computes the normal of the facet 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 fit2 = cdt.all_faces_begin(), end = cdt.all_faces_end(); fit2 != end; ++fit2) { fit2->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 //and the normals to the appropriate vectors for(CDT::Finite_faces_iterator ffit = cdt.finite_faces_begin(), end = cdt.finite_faces_end(); ffit != end; ++ffit) { if(ffit->info().is_external) continue; double vertices[3][3]; vertices[0][0] = ffit->vertex(0)->point().x(); vertices[0][1] = ffit->vertex(0)->point().y(); vertices[0][2] = ffit->vertex(0)->point().z(); vertices[1][0] = ffit->vertex(1)->point().x(); vertices[1][1] = ffit->vertex(1)->point().y(); vertices[1][2] = ffit->vertex(1)->point().z(); vertices[2][0] = ffit->vertex(2)->point().x(); vertices[2][1] = ffit->vertex(2)->point().y(); vertices[2][2] = ffit->vertex(2)->point().z(); positions_facets.push_back( vertices[0][0]); positions_facets.push_back( vertices[0][1]); positions_facets.push_back( vertices[0][2]); positions_facets.push_back(1.0); positions_facets.push_back( vertices[1][0]); positions_facets.push_back( vertices[1][1]); positions_facets.push_back( vertices[1][2]); positions_facets.push_back(1.0); positions_facets.push_back( vertices[2][0]); positions_facets.push_back( vertices[2][1]); positions_facets.push_back( vertices[2][2]); positions_facets.push_back(1.0); typedef Kernel::Vector_3 Vector; Vector n = CGAL::Polygon_mesh_processing::compute_face_normal(fit, *poly); normals_flat.push_back(n.x()); normals_flat.push_back(n.y()); normals_flat.push_back(n.z()); normals_flat.push_back(n.x()); normals_flat.push_back(n.y()); normals_flat.push_back(n.z()); normals_flat.push_back(n.x()); normals_flat.push_back(n.y()); normals_flat.push_back(n.z()); normals_gouraud.push_back(n.x()); normals_gouraud.push_back(n.y()); normals_gouraud.push_back(n.z()); normals_gouraud.push_back(n.x()); normals_gouraud.push_back(n.y()); normals_gouraud.push_back(n.z()); normals_gouraud.push_back(n.x()); normals_gouraud.push_back(n.y()); normals_gouraud.push_back(n.z()); } }
void Viewer::compute_face(Dart_handle dh, LCC::size_type markface) { LCC &lcc = *scene->lcc; CGAL::mark_cell<LCC, 2>(lcc, dh, markface); double r = (double)lcc.info<3>(dh).color().r()/255.0; double g = (double)lcc.info<3>(dh).color().g()/255.0; double b = (double)lcc.info<3>(dh).color().b()/255.0; if ( !lcc.is_free(dh, 3) ) { r += (double)lcc.info<3>(lcc.beta(dh,3)).color().r()/255.0; g += (double)lcc.info<3>(lcc.beta(dh,3)).color().g()/255.0; b += (double)lcc.info<3>(lcc.beta(dh,3)).color().b()/255.0; r /= 2; g /= 2; b /= 2; } //compute flat normals LCC::Vector normal = CGAL::compute_normal_of_cell_2(lcc,dh); normal = normal/(CGAL::sqrt(normal*normal)); if (lcc.beta<1,1,1>(dh)!=dh) { P_traits cdt_traits(normal); CDT cdt(cdt_traits); // Iterates on the vector of facet handles CDT::Vertex_handle previous = NULL, first = NULL; for (LCC::Dart_of_orbit_range<1>::const_iterator he_circ = lcc.darts_of_orbit<1>(dh).begin(), he_circ_end = lcc.darts_of_orbit<1>(dh).end(); he_circ!=he_circ_end; ++he_circ) { CDT::Vertex_handle vh = cdt.insert(lcc.point(he_circ)); if(first == NULL) { first = vh; } vh->info().v = CGAL::compute_normal_of_cell_0<LCC>(lcc, he_circ); if(previous!=NULL && previous != vh) { cdt.insert_constraint(previous, vh); } previous = vh; } if (previous!=NULL) cdt.insert_constraint(previous, first); // sets mark is_external for(CDT::All_faces_iterator fit = cdt.all_faces_begin(), fitend = cdt.all_faces_end(); fit!=fitend; ++fit) { fit->info().is_external = true; fit->info().is_process = false; } //check if the facet is external or internal std::queue<CDT::Face_handle> face_queue; CDT::Face_handle face_internal = NULL; 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_process) { fh->info().is_process = true; for(int i = 0; i <3; ++i) { if(!cdt.is_constrained(std::make_pair(fh, i))) { face_queue.push(fh->neighbor(i)); } else if (face_internal==NULL) { face_internal = fh->neighbor(i); } } } } if ( face_internal!=NULL ) face_queue.push(face_internal); while(! face_queue.empty() ) { CDT::Face_handle fh = face_queue.front(); face_queue.pop(); if(!fh->info().is_process) { fh->info().is_process = true; fh->info().is_external = false; 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 //and the normals to the appropriate vectors for(CDT::Finite_faces_iterator ffit = cdt.finite_faces_begin(), ffitend = cdt.finite_faces_end(); ffit != ffitend; ++ffit) { if(!ffit->info().is_external) { flat_normals.push_back(normal.x()); flat_normals.push_back(normal.y()); flat_normals.push_back(normal.z()); flat_normals.push_back(normal.x()); flat_normals.push_back(normal.y()); flat_normals.push_back(normal.z()); flat_normals.push_back(normal.x()); flat_normals.push_back(normal.y()); flat_normals.push_back(normal.z()); smooth_normals.push_back(ffit->vertex(0)->info().v.x()); smooth_normals.push_back(ffit->vertex(0)->info().v.y()); smooth_normals.push_back(ffit->vertex(0)->info().v.z()); smooth_normals.push_back(ffit->vertex(1)->info().v.x()); smooth_normals.push_back(ffit->vertex(1)->info().v.y()); smooth_normals.push_back(ffit->vertex(1)->info().v.z()); smooth_normals.push_back(ffit->vertex(2)->info().v.x()); smooth_normals.push_back(ffit->vertex(2)->info().v.y()); smooth_normals.push_back(ffit->vertex(2)->info().v.z()); pos_facets.push_back(ffit->vertex(0)->point().x()); pos_facets.push_back(ffit->vertex(0)->point().y()); pos_facets.push_back(ffit->vertex(0)->point().z()); pos_facets.push_back(ffit->vertex(1)->point().x()); pos_facets.push_back(ffit->vertex(1)->point().y()); pos_facets.push_back(ffit->vertex(1)->point().z()); pos_facets.push_back(ffit->vertex(2)->point().x()); pos_facets.push_back(ffit->vertex(2)->point().y()); pos_facets.push_back(ffit->vertex(2)->point().z()); colors.push_back(r);colors.push_back(g);colors.push_back(b); colors.push_back(r);colors.push_back(g);colors.push_back(b); colors.push_back(r);colors.push_back(g);colors.push_back(b); } } } else { colors.push_back(r);colors.push_back(g);colors.push_back(b); colors.push_back(r);colors.push_back(g);colors.push_back(b); colors.push_back(r);colors.push_back(g);colors.push_back(b); flat_normals.push_back(normal.x()); flat_normals.push_back(normal.y()); flat_normals.push_back(normal.z()); flat_normals.push_back(normal.x()); flat_normals.push_back(normal.y()); flat_normals.push_back(normal.z()); flat_normals.push_back(normal.x()); flat_normals.push_back(normal.y()); flat_normals.push_back(normal.z()); for (LCC::Dart_of_orbit_range<1>::const_iterator orbitIter = lcc.darts_of_orbit<1>(dh).begin(); orbitIter.cont(); ++orbitIter) { //compute Smooth normals LCC::Vector normal = CGAL::compute_normal_of_cell_0(lcc,orbitIter); normal = normal/(CGAL::sqrt(normal*normal)); smooth_normals.push_back(normal.x()); smooth_normals.push_back(normal.y()); smooth_normals.push_back(normal.z()); const LCC::Point& p = lcc.point(orbitIter); pos_facets.push_back(p.x()); pos_facets.push_back(p.y()); pos_facets.push_back(p.z()); } } }
void constrained_delaunay_triangulation(LCC_3 &lcc, Dart_handle d1) { CGAL::set_ascii_mode(std::cout); std::cout<<"Vertices: "; for (LCC_3::Vertex_attribute_const_range::iterator v=lcc.vertex_attributes().begin(), vend=lcc.vertex_attributes().end(); v!=vend; ++v) std::cout << lcc.point_of_vertex_attribute(v) << "; "; std::cout<<std::endl; LCC_3::Vector normal = CGAL::compute_normal_of_cell_2(lcc,d1); P_traits cdt_traits(normal); CDT cdt(cdt_traits); //inserting the constraints edge by edge LCC_3::Dart_of_orbit_range<1>::iterator it(lcc.darts_of_orbit<1>(d1).begin()); CDT::Vertex_handle previous=LCC_3::null_handle, first=LCC_3::null_handle, vh=LCC_3::null_handle; for (LCC_3::Dart_of_orbit_range<1>::iterator itend(lcc.darts_of_orbit<1>(d1).end()); it!=itend; ++it) { vh = cdt.insert(lcc.point(it)); vh->info()=it; if( first==NULL ){ first=vh; } if( previous!=NULL){ CGAL_assertion( previous !=vh ); cdt.insert_constraint(previous,vh); } previous=vh; } cdt.insert_constraint(previous,first); CGAL_assertion(cdt.is_valid()); // sets mark is_external for( CDT::All_faces_iterator fit = cdt.all_faces_begin(), fitend = cdt.all_faces_end(); fit != fitend; ++fit) { fit->info().is_external = false; fit->info().exist_edge[0]=false; fit->info().exist_edge[1]=false; fit->info().exist_edge[2]=false; } 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) { 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)); } } } } for( CDT::Finite_edges_iterator eit = cdt.finite_edges_begin(), eitend = cdt.finite_edges_end(); eit != eitend; ++eit) { CDT::Face_handle fh = eit->first; int index = eit->second; CDT::Face_handle opposite_fh = fh->neighbor(index); if(cdt.is_constrained(std::make_pair(fh, index))) { fh->info().exist_edge[index]=true; opposite_fh->info().exist_edge[cdt.mirror_index(fh,index)]=true; if ( !fh->info().is_external && number_of_existing_edge(fh)==2 ) face_queue.push(fh); if ( !opposite_fh->info().is_external && number_of_existing_edge(opposite_fh)==2 ) face_queue.push(opposite_fh); } } while( !face_queue.empty() ) { CDT::Face_handle fh = face_queue.front(); face_queue.pop(); CGAL_assertion( number_of_existing_edge(fh)>=2 ); // i.e. ==2 or ==3 CGAL_assertion( !fh->info().is_external ); if (number_of_existing_edge(fh)==2) { int index = get_free_edge(fh); CDT::Face_handle opposite_fh = fh->neighbor(index); CGAL_assertion( !fh->info().exist_edge[index] ); CGAL_assertion( !opposite_fh->info(). exist_edge[cdt.mirror_index(fh,index)] ); const CDT::Vertex_handle va = fh->vertex(cdt. cw(index)); const CDT::Vertex_handle vb = fh->vertex(cdt.ccw(index)); Dart_handle ndart= CGAL::insert_cell_1_in_cell_2(lcc,va->info(),vb->info()); va->info()=lcc.beta<2>(ndart); fh->info().exist_edge[index]=true; opposite_fh->info().exist_edge[cdt.mirror_index(fh,index)]=true; if ( !opposite_fh->info().is_external && number_of_existing_edge(opposite_fh)==2 ) face_queue.push(opposite_fh); } } }
/* * BuildCutLinesInDEM * * This routine builds horizontal and vertical lines in a DEM via constraints. * Useful for cutting over on a rectangularly mapped texture. * * The DEM points that are used are removed from the mesh to keep them from getting hit multiple times. * */ void BuildCutLinesInDEM( DEMGeo& ioDem, CDT& outMesh, int segments) // Number of cuts per dim, 1 means no action taken! { CDT::Face_handle local; int x_interval = (ioDem.mWidth-1) / segments; int y_interval = (ioDem.mHeight-1) / segments; vector<CDT::Vertex_handle> junctions; junctions.resize((segments+1)*(segments+1)); // First, there will be some crossing points - add every one of them to the triangulation. int x, y, dx, dy; for (y = 0; y < ioDem.mHeight; y += y_interval) for (x = 0; x < ioDem.mWidth; x += x_interval) { float h = ioDem(x,y); if (h != NO_DATA) { // gMeshPoints.push_back(Point_2(ioDem.x_to_lon(x),ioDem.y_to_lat(y))); #if !NO_TRIANGULATE CDT::Vertex_handle vv = outMesh.insert(CDT::Point(ioDem.x_to_lon(x),ioDem.y_to_lat(y)), local); vv->info().height = h; local = vv->face(); #endif junctions[(x / x_interval) + (y / y_interval) * (segments+1)] = vv; } else AssertPrintf("Needed DEM point AWOL - %d,%d.\n",x,y); } // Next, add the vertical segments. Run through each vertical stripe except the edges, // for every horizontal one except the top. This is each vertical band we must add. for (y = y_interval; y < ioDem.mHeight; y += y_interval) for (x = x_interval; x < (ioDem.mWidth-x_interval); x += x_interval) { CDT::Vertex_handle v1, v2; v1 = junctions[(x / x_interval) + ((y-y_interval) / y_interval) * (segments+1)]; for (dy = y - y_interval + 1; dy < y; ++dy) { float h = ioDem(x,dy); if (h != NO_DATA) { // gMeshPoints.push_back(Point_2(ioDem.x_to_lon(x),ioDem.y_to_lat(dy))); #if !NO_TRIANGULATE v2 = outMesh.insert(CDT::Point(ioDem.x_to_lon(x),ioDem.y_to_lat(dy)), local); v2->info().height = h; local = v2->face(); outMesh.insert_constraint(v1, v2); v2 = v1; #endif } } v2 = junctions[(x / x_interval) + (y / y_interval) * (segments+1)]; outMesh.insert_constraint(v1, v2); } // Same thing but horizontal-like. for (y = y_interval; y < (ioDem.mHeight-y_interval); y += y_interval) for (x = x_interval; x < ioDem.mWidth; x += x_interval) { CDT::Vertex_handle v1, v2; v1 = junctions[((x-x_interval) / x_interval) + (y / y_interval) * (segments+1)]; for (dx = x - x_interval + 1; dx < x; ++dx) { float h = ioDem(dx,y); if (h != NO_DATA) { // gMeshPoints.push_back(Point_2(ioDem.x_to_lon(dx),ioDem.y_to_lat(y))); #if !NO_TRIANGULATE v2 = outMesh.insert(CDT::Point(ioDem.x_to_lon(dx),ioDem.y_to_lat(y)), local); v2->info().height = h; local = v2->face(); outMesh.insert_constraint(v1, v2); v2 = v1; #endif } } v2 = junctions[(x / x_interval) + (y / y_interval) * (segments+1)]; outMesh.insert_constraint(v1, v2); } }