Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Precondition violation (it1.e_ == it2.e_) when creating a Triangulation_3

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Precondition violation (it1.e_ == it2.e_) when creating a Triangulation_3


Chronological Thread 
  • From: Anto <>
  • To: "" <>
  • Subject: Re: [cgal-discuss] Precondition violation (it1.e_ == it2.e_) when creating a Triangulation_3
  • Date: Tue, 29 Sep 2015 23:47:30 +0000 (UTC)
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:OLrdxxMcEiUuPiTIH0wl6mtUPXoX/o7sNwtQ0KIMzox0KPX9rarrMEGX3/hxlliBBdydsKIYzbeG+Pu6EUU7or+/81k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i760zceF13FOBZvIaytQ8iJ35jxirD5oMebSj4LrQT+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf9d32JiKAHbtR/94sCt4MwrqHwI6Lpyv/JHBO/xcK08CLBZFz87KHsd5cvxtBCFQxHFri8XXWwS1xZJGAPY9wrSX5HrsyK8uPArixOXJcnncbdhcDK+6O8/QRn0zjwbOiEw6n3/m8Vwi6UdqxWk8U9R2YnRNaiTKP02KqrbYZUBWWdeV9xNfz1IAoS7KYAICrxSbq5js4Dhqg5W/lOFDg62Cba3xw==

there are opens source examples of the file export codes for example, openscad blockscad openjscad are the ones i know of, i.e. export.cpp with examples for stl, x3d obj and similar. x3d is in openjscad and blockscad, but cgal doesnt support color so it's not colored.


From: Thiago Milanetto Schlittler <>
To:
Sent: Wednesday, September 30, 2015 1:07 AM
Subject: [cgal-discuss] Precondition violation (it1.e_ == it2.e_) when creating a Triangulation_3

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().ExtIndexinfo() 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;
}





Archive powered by MHonArc 2.6.18.

Top of Page