Subject: CGAL users discussion list
List archive
[cgal-discuss] Precondition violation (it1.e_ == it2.e_) when creating a Triangulation_3
Chronological Thread
- From: Thiago Milanetto Schlittler <>
- To:
- Subject: [cgal-discuss] Precondition violation (it1.e_ == it2.e_) when creating a Triangulation_3
- Date: Wed, 30 Sep 2015 01:07:40 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
- Ironport-phdr: 9a23:Y6kaphGtP7BD9TSvyl01H51GYnF86YWxBRYc798ds5kLTJ75osiwAkXT6L1XgUPTWs2DsrQf27aQ7vCrAD1IyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/ni6bvq9aKMk1hv3mUX/BbFF2OtwLft80b08NJC50a7V/3mEZOYPlc3mhyJFiezF7W78a0+4N/oWwL46pyv50IbaKvdKsxSflUDS8tLnsuzMztrxjKCwWVtVUGVWBDrhpJCgfCpDT7Wp73vzfmsaJG0ymePNHqSb0uEWC+76ZiRxjtk3wvODsw8WWRgct12vEI6Cm9rgByltaHKLqeM+BzK/vQ
Hello!
I’m writing a routine to import/export a mesh from a file, and I’m having some problems with the 3D cases. Essentially, I’m building Triangulation_3 by “hand”, using the underlying tds() structure, and I’m getting the following error for certain meshes:
CGAL error: precondition violation!
_expression_ : it1.e_ == it2.e_
File : /opt/local/include/CGAL/iterator.h
Line : 585
The program starts by adding the finite cells and defining the neighbouring relations between them - this step seems to be correct, and I get the correct structure after doing this. Then, it iterates over the finite cells to find which ones still have facets with no neighbours and builds the corresponding infinite cells. All works well, up to a point where the program creates the infinite cells associated to a certain cell, and then gives the error above when it tries to access the next finite cell.
I'm using the create_cell() method to create either the finite or the infinite cells, and then I set up the vertices using set_vertices(). I don’t think that the problem is in the mesh file reading because the structure of the finite cells seems to be correct, and the error appears for different meshes. What could it be?
I’ve annexed some snippets of the code below. mVertexHandleIndexMap is an unordered map used to associate each vertex to an unique index (at least, for the finite faces). This index is also saved inside the cell’s info().ExtIndex. info() also contains a vector faceHasNeighbour[idxNeigh], used to mark whether a cell has a neighbour in the direction idxNeigh or not.
Thanks in advance!
Thiago Milanetto Schlittler
void Triangular_Mesh_3::AddInfiniteCells_3()
{
int idxIII = -1;
int idxJJJ = -1;
int idxKKK = -1;
int vertexIII = -1;
int vertexJJJ = -1;
int vertexKKK = -1;
Vertex_handle_3 infiniteVertex = mesh.infinite_vertex();
std::vector<Cell_handle_3> infiniteCells(mSize_vertices);
int FakeIndex = 0;
// Build the infinite cells
for(Finite_cells_iterator_3 itCells = mesh.finite_cells_begin(); itCells != mesh.finite_cells_end(); ++itCells)
{
if(mNbOfNeighs[itCells->info().ExtIndex]!=4)
{
// Then there are (infinite) neighbours missing
for(int idxNeigh = 0; idxNeigh < 4; ++idxNeigh)
{
if(itCells->info().faceHasNeighbour[idxNeigh]==0)
{
// The cell has an empty neighbor, create an infinite cell
idxIII = mesh.vertex_triple_index(idxNeigh,0);
idxJJJ = mesh.vertex_triple_index(idxNeigh,1);
idxKKK = mesh.vertex_triple_index(idxNeigh,2);
vertexIII = itCells->vertex(idxIII)->info().ExtIndex;
vertexJJJ = itCells->vertex(idxJJJ)->info().ExtIndex;
vertexKKK = itCells->vertex(idxKKK)->info().ExtIndex;
infiniteCells[FakeIndex] = Create_Infinite_Cell_3(vertexIII,vertexJJJ,vertexKKK);
// Set as neighbour for the finite cell
itCells->set_neighbor(idxNeigh,infiniteCells[FakeIndex]);
// And the reciprocal relation
for(int jjj = 0; jjj < 4; ++jjj)
{
if(mesh.is_infinite(infiniteCells[FakeIndex]->vertex(jjj)))
{
infiniteCells[FakeIndex]->set_neighbor(jjj,itCells);
}
}
++mNbOfNeighs[itCells->info().ExtIndex];
++FakeIndex;
}
}
}
}
}
Cell_handle_3 Triangular_Mesh_3::Create_Infinite_Cell_3(int i0, int i1, int i2)
{
// Create cell
Cell_handle_3 outputHandle = mesh.tds().create_cell();
outputHandle->set_neighbors();
outputHandle->info().faceHasNeighbour.resize(4,0);
outputHandle->set_vertices(mVertexHandleIndexMap[i2],
mVertexHandleIndexMap[i1],
mVertexHandleIndexMap[i0],
mesh.infinite_vertex());
// Set incident cells
mVertexHandleIndexMap[i0]->set_cell(outputHandle);
mVertexHandleIndexMap[i1]->set_cell(outputHandle);
mVertexHandleIndexMap[i2]->set_cell(outputHandle);
mesh.infinite_vertex()->set_cell(outputHandle);
// Set external index
outputHandle->info().ExtIndex = mSize_cells;
return outputHandle;
}
- [cgal-discuss] Precondition violation (it1.e_ == it2.e_) when creating a Triangulation_3, Thiago Milanetto Schlittler, 09/30/2015
- Re: [cgal-discuss] Precondition violation (it1.e_ == it2.e_) when creating a Triangulation_3, Anto, 09/30/2015
- Re: [cgal-discuss] Precondition violation (it1.e_ == it2.e_) when creating a Triangulation_3, Monique Teillaud, 09/30/2015
- Re: [cgal-discuss] Precondition violation (it1.e_ == it2.e_) when creating a Triangulation_3, Thiago Milanetto Schlittler, 09/30/2015
Archive powered by MHonArc 2.6.18.