int main(int argc, char** argv) { std::string surfaceMesh; if (argc < 2) { cgogn_log_info("cmap2_import") << "USAGE: " << argv[0] << " [filename]"; surfaceMesh = std::string(DEFAULT_MESH_PATH) + std::string("off/aneurysm_3D.off"); cgogn_log_info("cmap2_import") << "Using default mesh : " << surfaceMesh; } else surfaceMesh = std::string(argv[1]); Map2 map; for (uint32 k = 0; k < 2; ++k) { cgogn::io::import_surface<Vec3>(map, surfaceMesh); uint32 nb_darts = 0; map.foreach_dart([&nb_darts] (cgogn::Dart) { nb_darts++; }); cgogn_log_info("cmap2_import") << "nb darts -> " << nb_darts; uint32 nb_darts_2 = 0; std::vector<uint32> nb_darts_per_thread(cgogn::NB_THREADS - 1); for (uint32& n : nb_darts_per_thread) n = 0; map.parallel_foreach_dart([&nb_darts_per_thread] (cgogn::Dart, uint32 thread_index) { nb_darts_per_thread[thread_index]++; }); for (uint32 n : nb_darts_per_thread) nb_darts_2 += n; cgogn_log_info("cmap2_import")<< "nb darts // -> " << nb_darts_2; VertexAttribute<Vec3> vertex_position = map.get_attribute<Vec3, Map2::Vertex::ORBIT>("position"); VertexAttribute<Vec3> vertex_normal = map.add_attribute<Vec3, Map2::Vertex::ORBIT>("normal"); FaceAttribute<Vec3> face_normal = map.add_attribute<Vec3, Map2::Face::ORBIT>("normal"); cgogn_log_info("cmap2_import") << "Map integrity : " << std::boolalpha << map.check_map_integrity(); uint32 nb_vertices = 0; cgogn::CellCache<Map2> cache(map); cache.build<Map2::Vertex>(); map.foreach_cell([&nb_vertices] (Map2::Vertex) { nb_vertices++; }, cache); cgogn_log_info("cmap2_import") << "nb vertices -> " << nb_vertices; uint32 nb_boundary_faces = 0; cgogn::BoundaryCache<Map2> bcache(map); map.foreach_cell([&nb_boundary_faces] (Map2::Boundary) { nb_boundary_faces++; }, bcache); cgogn_log_info("cmap2_import") << "nb boundary faces -> " << nb_boundary_faces; uint32 nb_faces = 0; map.foreach_cell([&nb_faces] (Map2::Face) { nb_faces++;}); cgogn_log_info("cmap2_import") << "nb faces -> " << nb_faces; uint32 nb_faces_2 = 0; std::vector<uint32> nb_faces_per_thread(cgogn::NB_THREADS - 1); for (uint32& n : nb_faces_per_thread) n = 0; map.parallel_foreach_cell([&nb_faces_per_thread] (Map2::Face, uint32 thread_index) { nb_faces_per_thread[thread_index]++; }); for (uint32 n : nb_faces_per_thread) nb_faces_2 += n; cgogn_log_info("cmap2_import") << "nb faces // -> " << nb_faces_2; std::chrono::time_point<std::chrono::system_clock> start, end; start = std::chrono::system_clock::now(); for (uint32 i = 0; i < 10; ++i) cgogn::geometry::compute_normal<Vec3>(map, vertex_position, face_normal); for (uint32 i = 0; i < 10; ++i) cgogn::geometry::compute_normal<Vec3>(map, vertex_position, vertex_normal); end = std::chrono::system_clock::now(); std::chrono::duration<float64> elapsed_seconds = end - start; cgogn_log_info("cmap2_import") << "elapsed time: " << elapsed_seconds.count() << "s"; } return 0; }
int main(int , char** ) { int32 x = 100; int32 y = 100; const cgogn::Orbit vertorb = Map2::Vertex::ORBIT; { Map2 map; VertexAttribute<Vec3> vertex_grid = map.add_attribute<Vec3, Map2::Vertex::ORBIT>("grid"); VertexAttribute<Vec3> vertex_twisted_strip = map.add_attribute<Vec3, Map2::Vertex::ORBIT>("twisted_strip"); VertexAttribute<Vec3> vertex_helicoid = map.add_attribute<Vec3, Map2::Vertex::ORBIT>("helicoid"); // map.add_attribute<int32, Map2::CDart::ORBIT>("darts"); map.add_attribute<int32, Map2::Edge::ORBIT>("edges"); map.add_attribute<int32, Map2::Face::ORBIT>("faces"); map.add_attribute<int32, Map2::Volume::ORBIT>("volumes"); cgogn::modeling::TriangularGrid<Map2> g(map, x, y); std::cout << "is good ? " << std::boolalpha << map.check_map_integrity() << std::endl; g.embed_into_grid(vertex_grid, 10.0f, 10.0f, 0.0f); g.embed_into_twisted_strip<Vec3>(vertex_twisted_strip, 10.0f, 5.0f, 3.1f); g.embed_into_helicoid<Vec3>(vertex_helicoid, 10.0f, 5.0f, 15.0f, 3.0f, 1); cgogn::io::export_surface(map, cgogn::io::ExportOptions("grid.off", {vertorb, "grid"}, {}, false, false)); cgogn::io::export_surface(map, cgogn::io::ExportOptions("twisted_strip.off", {vertorb, "twisted_strip"}, {}, false, false)); cgogn::io::export_surface(map, cgogn::io::ExportOptions("helicoid.off", {vertorb, "helicoid"}, {}, false, false)); } { Map2 map; VertexAttribute<Vec3> vertex_cylinder = map.add_attribute<Vec3, Map2::Vertex::ORBIT>("cylinder"); VertexAttribute<Vec3> vertex_sphere = map.add_attribute<Vec3, Map2::Vertex::ORBIT>("sphere"); VertexAttribute<Vec3> vertex_cone = map.add_attribute<Vec3, Map2::Vertex::ORBIT>("cone"); // map.add_attribute<int32, Map2::CDart::ORBIT>("darts"); map.add_attribute<int32, Map2::Edge::ORBIT>("edges"); map.add_attribute<int32, Map2::Face::ORBIT>("faces"); map.add_attribute<int32, Map2::Volume::ORBIT>("volumes"); cgogn::modeling::TriangularCylinder<Map2> g(map, x, y); std::cout << "is good ? " << std::boolalpha << map.check_embedding_integrity() << std::endl; g.close_top(); g.close_bottom(); g.triangule_top(); g.triangule_bottom(); g.embed_into_cylinder(vertex_cylinder, 10.0f, 8.0f, 5.0f); g.embed_into_sphere<Vec3>(vertex_sphere, 10.0f); g.embed_into_cone<Vec3>(vertex_cone, 10.0f, 5.0f); cgogn::io::export_surface(map, cgogn::io::ExportOptions("cylinder.off", {vertorb, "cylinder"}, {}, false, false)); cgogn::io::export_surface(map, cgogn::io::ExportOptions("sphere.off", {vertorb, "sphere"}, {}, false, false)); cgogn::io::export_surface(map, cgogn::io::ExportOptions("cone.off", {vertorb, "cone"}, {}, false, false)); } { Map2 map; VertexAttribute<Vec3> vertex_tore = map.add_attribute<Vec3, Map2::Vertex::ORBIT>("tore"); // map.add_attribute<int32, Map2::CDart::ORBIT>("darts"); map.add_attribute<int32, Map2::Edge::ORBIT>("edges"); map.add_attribute<int32, Map2::Face::ORBIT>("faces"); map.add_attribute<int32, Map2::Volume::ORBIT>("volumes"); cgogn::modeling::TriangularTore<Map2> g(map, x, y); std::cout << "is good ? " << std::boolalpha << map.check_embedding_integrity() << std::endl; g.embed_into_tore(vertex_tore, 10.0f, 4.0f); cgogn::io::export_surface(map, cgogn::io::ExportOptions("tore.off", {vertorb, "tore"}, {}, false, false)); } /* { Map2 map; cgogn::modeling::TriangularCube<Map2> g(map, x, y, x); VertexAttribute<Vec3> vertex_tore = map.add_attribute<Vec3, Map2::Vertex::ORBIT>("cube"); g.embed_into_cube(vertex_tore, 10.0f, 4.0f, 5.0f); std::vector<std::pair<cgogn::Orbit,std::string>> att_vec; att_vec.push_back(std::make_pair(cgogn::Orbit(Map2::Vertex::ORBIT), std::string("cube"))); cgogn::io::export_surface(map, cgogn::io::ExportOptions("cube.off", att_vec, false)); } */ return 0; }