Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confused about PMP::surface_Delaunay_remeshing() documentation. #8662

Open
yDF8EPJN8 opened this issue Dec 17, 2024 · 0 comments
Open

Confused about PMP::surface_Delaunay_remeshing() documentation. #8662

yDF8EPJN8 opened this issue Dec 17, 2024 · 0 comments

Comments

@yDF8EPJN8
Copy link

yDF8EPJN8 commented Dec 17, 2024

Issue Details

In surface_Delaunay_remeshing() documentation.

There is Extra in the description of face_patch_map named parameters:

Extra: The map is updated during the remeshing process while new faces are created.

But it doesn't happen, neither in the TriangleMeshOut nor in the TriangleMesh.

Source Code

This is slightly modified code from example Polygon_mesh_processing/delaunay_remeshing_example.cpp.

This example uses a model from the CGAL data.

https://github.com/CGAL/cgal/blob/master/Data/data/meshes/anchor_dense.off

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>
#include <CGAL/Polygon_mesh_processing/surface_Delaunay_remeshing.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Mesh_constant_domain_field_3.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel   K;
typedef CGAL::Surface_mesh<K::Point_3>                        Mesh;

typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef CGAL::Mesh_constant_domain_field_3<K, int> Sizing_field;

namespace PMP = CGAL::Polygon_mesh_processing;

int main(int argc, char* argv[])
{
  std::string filename = (argc > 1) ? std::string(argv[1])
    : CGAL::data_file_path("meshes/anchor_dense.off");

  Mesh mesh;
  if (!PMP::IO::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh))
  {
    std::cerr << "Invalid input." << std::endl;
    return 1;
  }

  double target_edge_length = (argc > 2) ? std::stod(std::string(argv[2])) : 0.02;
  Sizing_field size(target_edge_length);

  double fdist = (argc > 3) ? std::stod(std::string(argv[3])) : 0.01;

  std::cout << "Detect features..." << std::endl;

  using EIFMap = boost::property_map<Mesh, CGAL::edge_is_feature_t>::type;
  EIFMap eif = get(CGAL::edge_is_feature, mesh);
  PMP::detect_sharp_edges(mesh, 45, eif);

  std::cout << "Find connected components..." << std::endl;

  Mesh::Property_map<face_descriptor, std::size_t> fccmap =
    mesh.add_property_map<face_descriptor, std::size_t>("f:CC").first;
  std::size_t num = PMP::connected_components(mesh,
    fccmap,
    CGAL::parameters::edge_is_constrained_map(eif));

  std::cout << "Start remeshing of " << filename
    << " (" << num_faces(mesh) << " faces)..." << std::endl;
  // mesh is passed as a const reference, it does not change.
  Mesh outmesh = PMP::surface_Delaunay_remeshing(mesh,
    CGAL::parameters::protect_constraints(true)
    .mesh_edge_size(size)
    .mesh_facet_distance(fdist)
    .edge_is_constrained_map(eif)
    .face_patch_map(fccmap)
    );

  std::cout << "Remeshing done." << std::endl;

  std::optional<Mesh::Property_map<face_descriptor, std::size_t>> out_fccmap_wrap
  = outmesh.property_map<face_descriptor, std::size_t>("f:CC");

  if (!out_fccmap_wrap.has_value())
    std::cout << "outmesh does not have f:CC map\n";

  return EXIT_SUCCESS;
}

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits): Windows 64 bits
  • Compiler: visual c++
  • Release or debug mode:
  • Specific flags used (if any):
  • CGAL version: 6.0.1
  • Boost version: 1.86
  • Other libraries versions if used (Eigen, TBB, etc.):

Suggestions

I'm working with geometry from CAD. For each model I have:

  1. face_patch_map for triangles.
  2. edge_polyline_map with boost::graph_traits<PolygonMesh>::edge_descriptor as key type and int as value type. It has a default value of -1. And non-negative value for edges that belong to geometrically important chains of edges. In other words, each polyline (chain of edges) has its own index.
  3. vertex_is_constrained_map which points to geometrically important points. Most often these are endpoints of polylines.

It would be great if one could specify such property maps via Named Parameters and they would be saved correctly in the out mesh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants