I'm creating an application using qt creator which read .off files as CGAL::Linear_cell_complex_for_combinatorial_map and preview it I want to make operations on the read mesh such as removing edge and restore it .
it shows the following error :
terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: i != idx.end()
my code:
filename =std::string("/home/nourhan/QT projects/cube.off");
std::ifstream ifile(filename.c_str());
if (ifile)
{
CGAL::load_off(lcc, ifile);
}
lcc.display_characteristics(std::cout) << ", valid=" <<
lcc.is_valid() << std::endl;
LCC_3::Dart_handle d2=lcc.darts().begin();
LCC_3::Dart_handle d3= lcc.insert_cell_0_in_cell_1( d2);
lcc.insert_cell_0_in_cell_2( d2);
std::vector<LCC_3::Dart_handle> adarts;
adarts.push_back(d2);
adarts.push_back(d3);
adarts.push_back(lcc.beta<1>(d3));
if (lcc.is_insertable_cell_1_in_cell_2(d2, d3))
lcc.insert_cell_1_in_cell_2( d2, d3);
lcc.display_characteristics(std::cout) << ", valid=" <<
lcc.is_valid() << std::endl;
CGAL::write_off(lcc, "copy-head.off");
}
the output : Darts=24, #0-cells=8, #1-cells=12, #2-cells=6, #ccs=1, valid=1
Darts=36, #0-cells=10, #1-cells=18, #2-cells=10, #ccs=1, valid=Map not valid: dart 0x5d7df0 does not have a vertex.
0
the output .off file :
OFF
8 10 0
I don't know how it inserted edges successfully and the same time Map not valid and the output .off file isn't correct .
I appreciate any help .
The method you use, insert_cell_0_in_cell_1, is a method from combinatorial map.
This method modifies the topology of the object, inserting a new vertex, but the geometry is not updated, because a combinatorial map does not necessarily have a geometry.
There are 2 solutions:
Using one of these solutions will give you a valid linear cell complex, and thus you can export it as off file.
But, one important question is what are you trying to do ? It seems you insert some cells randomly, thus it is highly likely to obtain a very strange mesh.
Have a look once again at the examples Modification Operations of the linear cell complex package. When I insert cells, I do not take random darts but precise darts in order to do a precise operation.