Closed KeepFaithMe closed 4 years ago
In the simplification function documentation, you will see that there is the named parameter edge_is_constrained_map
that can be used to pass some constrained edges to the algorithm. You also need to use the Constrained_placement
to wrap you current placement.
Here is an example where sharp edges of a Polyhedron are constrained. You can adapt it to make it work with OpenMesh.
I have another question! I can read the .obj data,and I want convert the .obj data to Polyhedron_3,at the same time do the operation of simplification. I use the function 'make_triangle()' to construct Polyhedron_3,but when I do the simplification,there is a bug ,I do'nt konw what's wrong with the code?And I check out the output data, the vertices chabged.For example,in the .obj file,the number of vertices is 351,but in the new .off file is 1662.I konw the vertices is repeat,but I do'nt konw why? the Code :
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> surface_mesh;
typedef boost::graph_traits<surface_mesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<surface_mesh>::vertex_descriptor vertex_descriptor;
for (int i = 0; i < aMesh->mIndices.size(); i += 3)
{
Point_3 p1 = Point_3(aMesh->mVertices[aMesh->mIndices[i]].x, aMesh->mVertices[aMesh->mIndices[i]].y, aMesh->mVertices[aMesh->mIndices[i]].z);
Point_3 p2 = Point_3(aMesh->mVertices[aMesh->mIndices[i + 1]].x, aMesh->mVertices[aMesh->mIndices[i + 1]].y, aMesh->mVertices[aMesh->mIndices[i + 1]].z);
Point_3 p3 = Point_3(aMesh->mVertices[aMesh->mIndices[i + 2]].x, aMesh->mVertices[aMesh->mIndices[i + 2]].y, aMesh->mVertices[aMesh->mIndices[i + 2]].z);
SMesh.make_triangle(p1, p2, p3);
}
the aMesh save the vertices ,indeics,etc,not the surface_mesh.
Use the function
template <class Point_3>
bool
read_OBJ( std::istream& input,
std::vector<Point_3> &points,
std::vector<std::vector<std::size_t> > &faces)
in CGAL/IO/OBJ_reader.h
together with the function polygon_soup_to_polygon_mesh()
.
Please use the following template to help us solving your issue.
Issue Details
I want to constrain some edges of the surface_mesh.I see the document https://doc.cgal.org/latest/Surface_mesh_simplification/index.html . and Surface_mesh_simplification/edge_collapse_OpenMesh.cpp .The data struct is OpenMesh.The type of surface_mesh is: typedef OpenMesh::PolyMesh_ArrayKernelT<> surface_mesh;but I want use the 'typedef CGAL::Simple_cartesian K; typedef CGAL::Surface_meshsurfacemesh ;',but the function 'add_property()' do not contain in this surface_mesh.
So if I want use the '_typedef CGAL::Simple_cartesian K; typedef CGAL::Surface_meshsurfacemesh',what should i do?
Source Code
If your issue arises by using CGAL in your own source code, please provide a minimalist example that we can compile easily to reproduce the bug. If your issue arises from using a CGAL program (demo, example, etc.), please let us know which one. Helping you solving an issue is much easier and efficient if we can reproduce it.
Environment