-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Please use the following template to help us solving your issue.
Issue Details
I am using split function to intersect two surface meshes and I want to get the newly created points/edges during split so that I can remesh these points. From this link I think I could use visitor to get what I want. the surface meshes, named slope and slide respectively, are shown as follows:
However, I could not get any infomation, before_subface_creations, after_subface_created after_subface_creations all the 3 call back functions do not get called.
/
I hope if anyone could help me solve this. Thank you!
Source Code
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/selection.h>
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/clip.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <iostream>
#include <string>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Exact_predicates_exact_constructions_kernel EK;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef Mesh::Property_map<vertex_descriptor, EK::Point_3> Exact_point_map;
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
namespace PMP = CGAL::Polygon_mesh_processing;
namespace params = CGAL::parameters;
class Insert_iterator
{
typedef std::unordered_map<face_descriptor, face_descriptor> Container;
Container& container;
public:
Insert_iterator(Container& c)
: container(c) {}
Insert_iterator&
operator=(const std::pair<face_descriptor, face_descriptor>& p)
{
container[p.second] = p.first;
return *this;
}
Insert_iterator&
operator*() { return *this; }
Insert_iterator
operator++(int) { return *this; }
};
struct Visitor : public CGAL::Polygon_mesh_processing::Corefinement::Default_visitor<Mesh>
{
typedef std::unordered_map<face_descriptor, face_descriptor> Container;
Container& container;
face_descriptor qfd;
Visitor(Container& container)
: container(container)
{}
void before_subface_creations(face_descriptor fd)
{
std::cout << "split : " << fd << " into:" << std::endl;
Container::iterator it = container.find(fd);
qfd = it->second;
container.erase(it);
}
void after_subface_created(face_descriptor fd)
{
std::cout << " " << fd;
container[fd] = qfd;
}
void after_subface_creations()
{
std::cout << std::endl;
}
};
int main(int argc, char* argv[])
{
const std::string filename1 = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/slope.off");
const std::string filename2 = (argc > 2) ? argv[2] : CGAL::data_file_path("meshes/slide.off");
Mesh mesh1, mesh2;
if (!PMP::IO::read_polygon_mesh(filename1, mesh1) || !PMP::IO::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
if (PMP::does_self_intersect(mesh1) || PMP::does_self_intersect(mesh2))
{
std::cerr << "self intersect input." << std::endl;
return 1;
}
std::unordered_map<face_descriptor, face_descriptor> t2q;
Visitor v(t2q);
PMP::split(mesh1, mesh2, params::do_not_modify(true), params::visitor(v).do_not_modify(true));
return 0;
}Environment
- Operating system (Windows/Mac/Linux, 32/64 bits): Windows 11
- Compiler: MSVC
- Release or debug mode:
- Specific flags used (if any):
- CGAL version: 5.6.1
- Boost version:
- Other libraries versions if used (Eigen, TBB, etc.):
Reactions are currently unavailable

