c++ - no member named set_sizing_info was found in Triangulation_vertex_base_2 -
i trying use cgal triangulate 2d plane mesh network. following instructions this link. works fine until last step can use lloyd optimization optimize mesh. when compiling code, error /usr/local/include/cgal/mesh_2/mesh_sizing_field.h:100:12: no member named 'set_sizing_info' in 'cgal::triangulation_vertex_base_2<cgal::epick, cgal::triangulation_ds_vertex_base_2<cgal::triangulation_data_structure_2<cgal::triangulation_vertex_base_2<cgal::epick, cgal::triangulation_ds_vertex_base_2<void> >, cgal::delaunay_mesh_face_base_2<cgal::epick, cgal::constrained_delaunay_triangulation_face_base_2<cgal::epick, cgal::constrained_triangulation_face_base_2<cgal::epick, cgal::triangulation_face_base_2<cgal::epick, cgal::triangulation_ds_face_base_2<void> > > > > > > >'
popped up. traced triangulation_ds_face_base_2 , didn't find function named set_sizing_info.
my code:
// // main.cpp // 2ddrawingtemplate // // created xiangyu on 03/11/2016. // copyright © 2016 jxkj. rights reserved. // // std. includes #define cgal_mesh_2_optimizer_verbose //#define cgal_mesh_2_optimizers_debug //#define cgal_mesh_2_sizing_field_use_barycentric_coordinates #include <string> #include <iostream> #include <fstream> #include <vector> #include <iterator> //glfw #define glew_static #include <gl/glew.h> //glfw #include <glfw/glfw3.h> //gl includes #include "shader.h" #include "camera.h" //glm mathematics #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/type_ptr.hpp> //cgal libs #include <cgal/exact_predicates_inexact_constructions_kernel.h> #include <cgal/delaunay_triangulation_2.h> #include <cgal/constrained_delaunay_triangulation_2.h> #include <cgal/triangulation_conformer_2.h> #include <cgal/delaunay_mesher_2.h> #include <cgal/delaunay_mesh_face_base_2.h> #include <cgal/delaunay_mesh_size_criteria_2.h> #include <cgal/lloyd_optimize_mesh_2.h> #include <cgal/random.h> #include <cgal/point_generators_2.h> #include <cgal/timer.h> //typedefs typedef cgal::exact_predicates_inexact_constructions_kernel k; typedef k::point_2 point_2; typedef k::iso_rectangle_2 iso_rectangle_2; typedef k::segment_2 segment_2; typedef k::ray_2 ray_2; typedef k::line_2 line_2; typedef cgal::delaunay_triangulation_2<k> delaunay_triangulation_2; typedef cgal::triangulation_vertex_base_2<k> vb; typedef cgal::delaunay_mesh_face_base_2<k> fb; typedef cgal::triangulation_data_structure_2<vb, fb> tds; typedef cgal::constrained_delaunay_triangulation_2<k, tds> cdt; typedef cgal::delaunay_mesh_size_criteria_2<cdt> criteria; typedef cgal::delaunay_mesher_2<cdt, criteria> mesher; typedef cdt::point point; typedef cdt::vertex_handle vertex_handle; //properties gluint screenwidth = 800, screenheight = 600; //callback function prototypes void key_callback(glfwwindow* window, int key, int scancode, int action, int mode); void scroll_callback(glfwwindow* window, double xoffset, double yoffset); void mouse_callback(glfwwindow* window, double xpos, double ypos); void do_movement(); //other function prototypes void generatedata(glfloat** vertices); delaunay_triangulation_2 delaunaytriangulation(std::vector<point_2> pts); cdt conforminggabrieldt(std::vector<point> pts); //camera camera camera(glm::vec3(0.0f, 0.0f, 3.0f)); bool keys[1024]; glfloat lastx = 400, lasty = 300; bool firstmouse = true; //parameters glfloat deltatime = 0.0f; glfloat lastframe = 0.0f; gluint facecount = 0; gluint vertscount = 0; //namespaces int main(int argc, const char * argv[]) { glfwinit(); glfwwindowhint(glfw_context_version_major, 3); glfwwindowhint(glfw_context_version_minor, 3); glfwwindowhint(glfw_opengl_profile, glfw_opengl_core_profile); glfwwindowhint(glfw_resizable, gl_false); glfwwindowhint(glfw_opengl_forward_compat, gl_true); glfwwindowhint(glfw_samples, 4); //create periodic delaunay glfwwindow* window = glfwcreatewindow(screenwidth, screenheight, "triangulation2", nullptr, nullptr); glfwmakecontextcurrent(window); //callback functions glfwsetkeycallback(window, key_callback); glfwsetcursorposcallback(window, mouse_callback); glfwsetscrollcallback(window, scroll_callback); //options glfwsetinputmode(window, glfw_cursor, glfw_cursor_disabled); glfwsetcursorpos(window, screenwidth/2, screenheight/2); //init glew setup opengl function pointers glewexperimental = gl_true; glewinit(); //define viewport dimensions glviewport(0, 0, screenwidth, screenheight); //setup opengl options //glenable(gl_depth_test); //setup , compile shaders shader ourshader("vertexshader.vert", "fragmentshader.frag"); //create vertices // glfloat vertices[] = { // 0.0f, 0.5f, 0.0f, // -0.5f, 0.0f, 0.0f, // 0.5f, 0.0f, 0.0f // }; glfloat* vertices; generatedata(&vertices); // (int = 0; < 3 * vertscount; i+=3) // std::cout << vertices[i] << " " << vertices[i+1] << " " << vertices[i + 2] << std::endl; //setup vbo , vao gluint vbo[2], vao[2]; glgenvertexarrays(1, &vao[0]); glgenbuffers(1, &vbo[0]); glbindvertexarray(vao[0]); glbindbuffer(gl_array_buffer, vbo[0]); glbufferdata(gl_array_buffer, 3*vertscount*sizeof(glfloat), vertices, gl_static_draw); //position attribute glvertexattribpointer(0, 3, gl_float, gl_false, 3 * sizeof(glfloat), (glvoid*)0); glenablevertexattribarray(0); glbindvertexarray(0); //load , create texture //game loop while(!glfwwindowshouldclose(window)) { glfloat currentframe = glfwgettime(); deltatime = currentframe - lastframe; lastframe = currentframe; glfwpollevents(); do_movement(); glclearcolor(0.2f, 0.3f, 0.3f, 1.0f); glclear(gl_color_buffer_bit | gl_depth_buffer_bit); //glclear(gl_color_buffer_bit); //enable shader ourshader.use(); //create camera transformation glm::mat4 view; view = camera.getviewmatrix(); glm::mat4 projection; projection = glm::perspective(camera.zoom, (float)screenwidth/(float)screenheight, 0.1f, 1000.0f); //get uniform locations glint modelloc = glgetuniformlocation(ourshader.program, "model"); glint viewloc = glgetuniformlocation(ourshader.program, "view"); glint projloc = glgetuniformlocation(ourshader.program, "projection"); //pass matrices shader gluniformmatrix4fv(viewloc, 1, gl_false, glm::value_ptr(view)); gluniformmatrix4fv(projloc, 1, gl_false, glm::value_ptr(projection)); glbindvertexarray(vao[0]); glm::mat4 model; //model = glm::translate(model, glm::vec3(0.0f, 0.0f, 0.0f)); //glfloat angle = 0.0f; //model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f)); gluniformmatrix4fv(modelloc, 1, gl_false, glm::value_ptr(model)); //draw cgcdt glpolygonmode(gl_front_and_back, gl_line); gldrawarrays(gl_triangles, 0, vertscount); glbindvertexarray(0); // glbindvertexarray(vao[1]); // gluniformmatrix4fv(modelloc, 1, gl_false, glm::value_ptr(model)); // //draw ccdt // glpolygonmode(gl_front_and_back, gl_line); // gldrawarrays(gl_triangles, 0, vertscount); // glbindvertexarray(0); glfwswapbuffers(window); } gldeletevertexarrays(1, &vao[0]); gldeletebuffers(1, &vbo[0]); glfwterminate(); return 0; } // moves/alters camera positions based on user input void do_movement() { // camera controls if(keys[glfw_key_w]) camera.processkeyboard(forward, deltatime); if(keys[glfw_key_s]) camera.processkeyboard(backward, deltatime); if(keys[glfw_key_a]) camera.processkeyboard(left, deltatime); if(keys[glfw_key_d]) camera.processkeyboard(right, deltatime); } // called whenever key pressed/released via glfw void key_callback(glfwwindow* window, int key, int scancode, int action, int mode) { //cout << key << endl; if(key == glfw_key_escape && action == glfw_press) glfwsetwindowshouldclose(window, gl_true); if (key >= 0 && key < 1024) { if(action == glfw_press) keys[key] = true; else if(action == glfw_release) keys[key] = false; } } void mouse_callback(glfwwindow* window, double xpos, double ypos) { if(firstmouse) { lastx = xpos; lasty = ypos; firstmouse = false; } glfloat xoffset = xpos - lastx; glfloat yoffset = lasty - ypos; // reversed since y-coordinates go bottom left lastx = xpos; lasty = ypos; camera.processmousemovement(xoffset, yoffset); } void scroll_callback(glfwwindow* window, double xoffset, double yoffset) { camera.processmousescroll(yoffset); } void generatedata(glfloat** vertices) { typedef cgal::creator_uniform_2<double, point_2> creator; cgal::random random(7); cgal::random_points_in_square_2<point_2, creator> in_square(.5, random); int n = 100; std::vector<point_2> pts; std::vector<point> cgdt_pts; (int = 0 ; < n ; i++) { point_2 p = *in_square; in_square++; pts.push_back(point_2(p.x() + .5, p.y() + .5)); cgdt_pts.push_back(point(p.x() + .5, p.y() + .5)); //std::cout << pts[i].x() << " " << pts[i].y() << std::endl; } //delaunay_triangulation_2 dt2 = delaunaytriangulation(pts); //delaunay_triangulation_2::finite_faces_iterator it; cdt dt2 = conforminggabrieldt(cgdt_pts); cdt::finite_faces_iterator it; facecount = dt2.number_of_faces(); vertscount = 3 * facecount; *vertices = new glfloat[9 * facecount]; std::cout << "number of faces: " << facecount << std::endl; int index = 0; (it = dt2.finite_faces_begin(); != dt2.finite_faces_end(); it++) { (*vertices)[index ] = dt2.triangle(it).vertex(0).x(); (*vertices)[index + 1] = dt2.triangle(it).vertex(0).y(); (*vertices)[index + 2] = 0.0f; index += 3; (*vertices)[index ] = dt2.triangle(it).vertex(1).x(); (*vertices)[index + 1] = dt2.triangle(it).vertex(1).y(); (*vertices)[index + 2] = 0.0f; index += 3; (*vertices)[index ] = dt2.triangle(it).vertex(2).x(); (*vertices)[index + 1] = dt2.triangle(it).vertex(2).y(); (*vertices)[index + 2] = 0.0f; index += 3; } std::ofstream outfile("output.out"); if (!outfile.is_open()) return; (int = 0; < 3 * vertscount; i+=3) { outfile << (*vertices)[i] << " " <<(*vertices)[i + 1] << " " << (*vertices)[i + 2]<< std::endl; } } delaunay_triangulation_2 delaunaytriangulation(std::vector<point_2> pts) { delaunay_triangulation_2 dt2; dt2.insert(pts.begin(), pts.end()); return dt2; } cdt conforminggabrieldt(std::vector<point> pts) { cdt cdt; vertex_handle va = cdt.insert(point(-4,0)); vertex_handle vb = cdt.insert(point(0,-1)); vertex_handle vc = cdt.insert(point(4,0)); vertex_handle vd = cdt.insert(point(0,1)); vertex_handle ve = cdt.insert(point(2, 0.6)); vertex_handle vf = cdt.insert(point(3, 3)); cdt.insert_constraint(ve, vd); cdt.insert_constraint(ve, vc); //cdt.insert_constraint(vb, vb); cdt.insert_constraint(vf, va); cdt.insert_constraint(vf, vd); cdt.insert_constraint(vf, vc); cdt.insert_constraint(va, vb); cdt.insert_constraint(vb, vc); cdt.insert_constraint(vc, vd); cdt.insert_constraint(vd, va); // (int = 0; < pts.size(); ++) // { // //insert points // cdt.insert(pts[i]); // } // // cdt.insert_constraint(pts[1], pts[2]); // cdt.insert_constraint(pts[2], pts[3]); // cdt.insert_constraint(pts[3], pts[4]); // cdt.insert_constraint(pts[4], pts[1]); std::cout << "number of vertices: " << cdt.number_of_vertices() << std::endl; std::cout << "meshing triangulation..." << std::endl; //cgal::refine_delaunay_mesh_2(cdt, criteria(0.125, 0.5)); mesher mesher(cdt); mesher.refine_mesh(); std::cout << "number of vertices: " << cdt.number_of_vertices() << std::endl; //cgal::make_conforming_delaunay_2(cdt); //cgal::make_conforming_gabriel_2(cdt); std::cout << "meshing new criterias..." << std::endl; // 0.125 default shape bound. corresponds abound 20.6 degree. // 0.5 upper bound on length of longuest edge. // see reference manual delaunay_mesh_size_traits_2<k>. mesher.set_criteria(criteria(0.125, 0.2)); mesher.refine_mesh(); std::cout << "number of vertices: " << cdt.number_of_vertices() << std::endl; // std::cout << "run lloyd optimization..."; // cgal::lloyd_optimize_mesh_2(cdt, // cgal::parameters::max_iteration_number = 10); // std::cout << " done." << std::endl; return cdt; }
according documentation, have use vertex , face type respectibely model of delaunaymeshfacebase_2 , delaunaymeshvertexbase_2. see this example
Comments
Post a Comment