Open mazerLIU opened 2 years ago
Hard to tell exactly what is the problem you are having without any detail but my guess is that you are try to have more than two faces along an edge (non-manifold surface).
I try to convert my mesh to polyhdron.But some mesh convert to polyhdron with wrong. How to solve the bug?
You need to share more information, like some code or the file itself. This example might also be interesting.
template <class HDS>
class WorkMesh_to_polyhedron : public CGAL::Modifier_base<HDS> {
public:
WorkMesh_to_polyhedron(const Work_Mesh &mesh) : m_mesh(mesh) {}
void operator()(HDS& hds) {
// get mesh data
const std::vector<Work_Triangle>& mFirstTris = m_mesh.GetFaces();
const std::vector<Point3D>& mFirstVers = m_mesh.GetVertices();
// Postcondition: `hds' is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HDS> B(hds, true);
B.begin_surface(mFirstVers.size(), mFirstTris.size() / 3);
// vertices
typedef typename HDS::Vertex::Point Vertex;
typedef typename Vertex Point;
for (unsigned i = 0; i < mFirstVers.size(); i++) {
HDS::Vertex_handle vh = B.add_vertex(Point(mFirstVers[i].x(), mFirstVers[i].y(), mFirstVers[i].z()));
//vh->id = i;
}
// get all triangles
std::vector<Vertex_Index> tempFs;
for (unsigned i = 0; i < mFirstTris.size(); i++) {
int p0 = mFirstTris[i].GetVerIndex(0);
int p1 = mFirstTris[i].GetVerIndex(1);
int p2 = mFirstTris[i].GetVerIndex(2);
tempFs.push_back(Vertex_Index(p0));
tempFs.push_back(Vertex_Index(p1));
tempFs.push_back(Vertex_Index(p2));
}
// triangles
for (unsigned j = 0; j < tempFs.size() / 3; ++j) {
HDS::Face_handle fh = B.begin_facet();
B.add_vertex_to_facet(tempFs[3 * j]);
B.add_vertex_to_facet(tempFs[3 * j + 1]);
B.add_vertex_to_facet(tempFs[3 * j + 2]);
B.end_facet();
//fh->id = j;
}
B.end_surface();
}
private:
Work_Mesh m_mesh;
};
What is you input? Did you try to use the aforementioned example?
Also, we have no idea what your WorkMesh
type is. Is it 2-manifold (with border) ?
The message indicates that there is a vertex v
not on a border, and now comes yet another triangle that is incident to v
.
@mazerLIU it would be great to get a confirmation from you that the mesh is non manifold. We then can close the issue.
Issue Details
Error is "input error: at vertex 31746 a closed surface already exists and facet 108501 is nonetheless adjacent"
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