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

Add edge_polyline_map as NP to split_long_edges() #8661

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

Add edge_polyline_map as NP to split_long_edges() #8661

yDF8EPJN8 opened this issue Dec 17, 2024 · 0 comments

Comments

@yDF8EPJN8
Copy link

Issue Details

My issue is similar to Add face_patch_map as NP to split_long_edges().

I'm asking to add another property to the Named Parameters for the split_long_edges() function, which is similar to face_patch_map, but for the edges that the function will split.

I'm working with geometry from CAD. For each model I have face_patch_map for triangles and edge_polyline_map with boost::graph_traits<PolygonMesh>::edge_descriptor as key type and int as value type.

I want the edges resulting from the splitting of edges belonging to a polyline to retain that property (i.e. the index of the polyline).

At the moment I'm solving this problem by assigning patch indices to the triangles around the polylines, but I think it would be as simple as the face_patch_map_solution.

Source Code

#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/Surface_mesh.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel   Kernel;
typedef Kernel::Point_3                                       Point;
typedef Kernel::Vector_3                                      Vector;
typedef CGAL::Surface_mesh<Point>                             Mesh;
typedef Mesh::Vertex_index                                    vertex_descriptor;
typedef Mesh::Edge_index                                      edge_descriptor;
typedef Mesh::Face_index                                      face_descriptor;

int main() {
  Mesh m;
  // triangle
  vertex_descriptor v1 = m.add_vertex(Point(0, 0, 0));
  vertex_descriptor v2 = m.add_vertex(Point(1, 0, 0));
  vertex_descriptor v3 = m.add_vertex(Point(0, 1, 0));
  face_descriptor f = m.add_face(v1, v2, v3);

  // edge polyline map
  auto e2p = m.add_property_map<edge_descriptor, int>("e:polyline", -1).first;
  // mark the edges on the line between p and q
  Point p(1, 0, 0);
  Point q(0, 1, 0);
  for (auto e : m.edges()) {
    Point p1 = m.point(m.vertex(e, 0));
    Point p2 = m.point(m.vertex(e, 1));
    if (CGAL::collinear(p, q, p1) && CGAL::collinear(p, q, p2))
      e2p[e] = 1;
  }
  std::cout << "edge polyline map before splitting\n";
  for (auto e : m.edges()) {
    Point p1 = m.point(m.vertex(e, 0));
    Point p2 = m.point(m.vertex(e, 1));
    std::cout << e.idx() << '\t' << e2p[e] << "\t(" << p1 << ")\t(" << p2 << ")\n";
  }

  CGAL::Polygon_mesh_processing::split_long_edges(m.edges(), 1.0, m);

  std::cout << "edge polyline map after splitting\n";
  for (auto e : m.edges()) {
    Point p1 = m.point(m.vertex(e, 0));
    Point p2 = m.point(m.vertex(e, 1));
    std::cout << e.idx() << '\t' << e2p[e] << "\t(" << p1 << ")\t(" << p2 << ")\n";
  }

  return 0;
}

The current output:

edge polyline map before splitting
0       -1      (1 0 0) (0 0 0)
1       1       (0 1 0) (1 0 0)
2       -1      (0 0 0) (0 1 0)
edge polyline map after splitting
0       -1      (1 0 0) (0 0 0)
1       1       (0 1 0) (0.5 0.5 0)
2       -1      (0 0 0) (0 1 0)
3       -1      (1 0 0) (0.5 0.5 0)
4       -1      (0 0 0) (0.5 0.5 0)

I expect it like

edge polyline map before splitting
0       -1      (1 0 0) (0 0 0)
1       1       (0 1 0) (1 0 0)
2       -1      (0 0 0) (0 1 0)
edge polyline map after splitting
0       -1      (1 0 0) (0 0 0)
1       1       (0 1 0) (0.5 0.5 0)
2       -1      (0 0 0) (0 1 0)
3       1       (1 0 0) (0.5 0.5 0)
4       -1      (0 0 0) (0.5 0.5 0)

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.):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant