mirror of https://github.com/CGAL/cgal
Merge pull request #1885 from maxGimeno/Tet_soup_in_c3t3-GF
Add a .mesh reader
This commit is contained in:
commit
6ea415022b
|
|
@ -115,6 +115,7 @@ void build_finite_cells(Tr& tr,
|
|||
{
|
||||
CGAL_precondition(static_cast<std::size_t>(tet[j]) < tr.number_of_vertices() &&
|
||||
tet[j] >= 0);
|
||||
vertex_handle_vector[tet[j] + 1]->set_dimension(3);
|
||||
vs[j] = vertex_handle_vector[tet[j] + 1];
|
||||
CGAL_postcondition(vs[j] != Vertex_handle());
|
||||
}
|
||||
|
|
@ -294,6 +295,10 @@ bool build_triangulation(Tr& tr,
|
|||
tr.tds().clear(); // not tr.clear() since it calls tr.init() which we don't want
|
||||
|
||||
build_vertices<Tr>(tr, points, vertex_handle_vector);
|
||||
BOOST_FOREACH(Vertex_handle vh, vertex_handle_vector)
|
||||
{
|
||||
vh->set_dimension(-1);
|
||||
}
|
||||
if(!finite_cells.empty())
|
||||
{
|
||||
build_finite_cells<Tr>(tr, finite_cells, vertex_handle_vector, incident_cells_map, border_facets);
|
||||
|
|
@ -305,11 +310,6 @@ bool build_triangulation(Tr& tr,
|
|||
std::cout << tr.number_of_cells() << " cells" << std::endl;
|
||||
}
|
||||
std::cout << tr.number_of_vertices() << " vertices" << std::endl;
|
||||
|
||||
BOOST_FOREACH(Vertex_handle vh, vertex_handle_vector)
|
||||
{
|
||||
vh->set_dimension(3);
|
||||
}
|
||||
if(c3t3_loader_failed)
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load(QFileInfo fileinfo) {
|
|||
if(try_load_other_binary_format(in, item->c3t3())) {
|
||||
item->c3t3_changed();
|
||||
item->changed();
|
||||
item->resetCutPlane();
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
@ -89,6 +90,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load(QFileInfo fileinfo) {
|
|||
if(try_load_a_cdt_3(in, item->c3t3())) {
|
||||
item->c3t3_changed();
|
||||
item->changed();
|
||||
item->resetCutPlane();
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
|
@ -143,6 +145,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load(QFileInfo fileinfo) {
|
|||
}
|
||||
}
|
||||
item->c3t3_changed();
|
||||
item->resetCutPlane();
|
||||
return item;
|
||||
}
|
||||
else if(item->c3t3().triangulation().number_of_finite_cells() == 0)
|
||||
|
|
|
|||
|
|
@ -492,18 +492,6 @@ struct Set_show_tetrahedra {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
double complex_diag(const Scene_item* item) {
|
||||
const Scene_item::Bbox& bbox = item->bbox();
|
||||
const double& xdelta = bbox.xmax()-bbox.xmin();
|
||||
const double& ydelta = bbox.ymax()-bbox.ymin();
|
||||
const double& zdelta = bbox.zmax()-bbox.zmin();
|
||||
const double diag = std::sqrt(xdelta*xdelta +
|
||||
ydelta*ydelta +
|
||||
zdelta*zdelta);
|
||||
return diag * 0.7;
|
||||
}
|
||||
|
||||
Scene_c3t3_item::Scene_c3t3_item()
|
||||
: Scene_group_item("unnamed", Scene_c3t3_item_priv::NumberOfBuffers, Scene_c3t3_item_priv::NumberOfVaos)
|
||||
, d(new Scene_c3t3_item_priv(this))
|
||||
|
|
@ -1519,6 +1507,7 @@ void Scene_c3t3_item_priv::computeElements()
|
|||
|
||||
//The grid
|
||||
{
|
||||
|
||||
float x = (2 * (float)complex_diag()) / 10.0;
|
||||
float y = (2 * (float)complex_diag()) / 10.0;
|
||||
for (int u = 0; u < 11; u++)
|
||||
|
|
@ -1644,25 +1633,28 @@ void Scene_c3t3_item::show_grid(bool b)
|
|||
}
|
||||
void Scene_c3t3_item::show_spheres(bool b)
|
||||
{
|
||||
d->spheres_are_shown = b;
|
||||
contextMenu()->findChild<QAction*>("actionShowSpheres")->setChecked(b);
|
||||
if(b && !d->spheres)
|
||||
if(is_valid())
|
||||
{
|
||||
d->spheres = new Scene_spheres_item(this, true);
|
||||
d->spheres->setName("Protecting spheres");
|
||||
d->spheres->setRenderingMode(Gouraud);
|
||||
connect(d->spheres, SIGNAL(destroyed()), this, SLOT(reset_spheres()));
|
||||
scene->addItem(d->spheres);
|
||||
scene->changeGroup(d->spheres, this);
|
||||
lockChild(d->spheres);
|
||||
d->computeSpheres();
|
||||
d->spheres_are_shown = b;
|
||||
contextMenu()->findChild<QAction*>("actionShowSpheres")->setChecked(b);
|
||||
if(b && !d->spheres)
|
||||
{
|
||||
d->spheres = new Scene_spheres_item(this, true);
|
||||
d->spheres->setName("Protecting spheres");
|
||||
d->spheres->setRenderingMode(Gouraud);
|
||||
connect(d->spheres, SIGNAL(destroyed()), this, SLOT(reset_spheres()));
|
||||
scene->addItem(d->spheres);
|
||||
scene->changeGroup(d->spheres, this);
|
||||
lockChild(d->spheres);
|
||||
d->computeSpheres();
|
||||
}
|
||||
else if (!b && d->spheres!=NULL)
|
||||
{
|
||||
unlockChild(d->spheres);
|
||||
scene->erase(scene->item_id(d->spheres));
|
||||
}
|
||||
Q_EMIT redraw();
|
||||
}
|
||||
else if (!b && d->spheres!=NULL)
|
||||
{
|
||||
unlockChild(d->spheres);
|
||||
scene->erase(scene->item_id(d->spheres));
|
||||
}
|
||||
Q_EMIT redraw();
|
||||
|
||||
}
|
||||
void Scene_c3t3_item::show_intersection(bool b)
|
||||
|
|
@ -1694,10 +1686,12 @@ void Scene_c3t3_item::show_intersection(bool b)
|
|||
}
|
||||
void Scene_c3t3_item::show_cnc(bool b)
|
||||
{
|
||||
d->cnc_are_shown = b;
|
||||
contextMenu()->findChild<QAction*>("actionShowCNC")->setChecked(b);
|
||||
Q_EMIT redraw();
|
||||
|
||||
if(is_valid())
|
||||
{
|
||||
d->cnc_are_shown = b;
|
||||
contextMenu()->findChild<QAction*>("actionShowCNC")->setChecked(b);
|
||||
Q_EMIT redraw();
|
||||
}
|
||||
}
|
||||
|
||||
void Scene_c3t3_item::reset_intersection_item()
|
||||
|
|
@ -1992,4 +1986,8 @@ void Scene_c3t3_item::invalidateOpenGLBuffers()
|
|||
compute_bbox();
|
||||
d->invalidate_stats();
|
||||
}
|
||||
void Scene_c3t3_item::resetCutPlane()
|
||||
{
|
||||
d->reset_cut_plane();
|
||||
}
|
||||
#include "Scene_c3t3_item.moc"
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ public:
|
|||
|
||||
void c3t3_changed();
|
||||
|
||||
void resetCutPlane();
|
||||
|
||||
void set_valid(bool);
|
||||
|
||||
const C3t3& c3t3() const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue