mirror of https://github.com/CGAL/cgal
Wip refactoring the demo.
This commit is contained in:
parent
bc1faf125e
commit
2e79d76bbe
|
|
@ -22,6 +22,9 @@
|
|||
#include <QApplication>
|
||||
#include <CGAL/Qt/resources.h>
|
||||
|
||||
// Global random
|
||||
CGAL::Random myrandom;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::cout<<"Size of dart: "<<sizeof(LCC::Dart)<<std::endl;
|
||||
|
|
|
|||
|
|
@ -28,62 +28,26 @@ void subdivide_lcc_3 (LCC & m);
|
|||
|
||||
#define DELAY_STATUSMSG 1500
|
||||
|
||||
bool isVisibleAndFilled(char property)
|
||||
{ return (property & LCC_DEMO_FILLED) && (property & LCC_DEMO_VISIBLE); }
|
||||
|
||||
bool isVisible(char property)
|
||||
{ return (property & LCC_DEMO_VISIBLE); }
|
||||
|
||||
bool isFilled(char property)
|
||||
{ return (property & LCC_DEMO_FILLED); }
|
||||
|
||||
char setVisible(char property)
|
||||
{ return property | LCC_DEMO_VISIBLE; }
|
||||
|
||||
char setHidden(char property)
|
||||
{
|
||||
if ( !isVisible(property) ) return property;
|
||||
return property ^ LCC_DEMO_VISIBLE;
|
||||
}
|
||||
|
||||
char setFilled(char property)
|
||||
{ return property | LCC_DEMO_FILLED; }
|
||||
|
||||
char setWireframe(char property)
|
||||
{
|
||||
if ( !isFilled(property) ) return property;
|
||||
return property ^ LCC_DEMO_FILLED;
|
||||
}
|
||||
|
||||
char setVisibleAndFilled(char property)
|
||||
{ return property | LCC_DEMO_FILLED | LCC_DEMO_VISIBLE; }
|
||||
|
||||
char negateVisible(char property)
|
||||
{ return property ^ LCC_DEMO_VISIBLE; }
|
||||
|
||||
char negateFilled(char property)
|
||||
{ return property ^ LCC_DEMO_FILLED; }
|
||||
|
||||
|
||||
MainWindow::MainWindow (QWidget * parent):CGAL::Qt::DemosMainWindow (parent),
|
||||
nbcube (0),
|
||||
dialogmesh(this),
|
||||
nbcube (0),
|
||||
dialogmesh (this),
|
||||
dialogmenger(this),
|
||||
mengerDart(NULL),
|
||||
volumeUid(1)
|
||||
mengerDart (NULL)
|
||||
{
|
||||
setupUi (this);
|
||||
|
||||
scene.lcc = new LCC;
|
||||
|
||||
volumeListDock = new QDockWidget(QString(tr("Volume List")),this);
|
||||
volumeListDock->setAllowedAreas(Qt::RightDockWidgetArea |
|
||||
Qt::LeftDockWidgetArea);
|
||||
volumeList = new QTableWidget(0,3,volumeListDock);
|
||||
volumeList = new QTableWidget(0,4,volumeListDock);
|
||||
volumeList->verticalHeader()->hide();
|
||||
volumeList->setColumnHidden(4,true);
|
||||
QObject::connect(this->volumeList, SIGNAL(cellChanged(int,int)),
|
||||
this, SLOT(onCellChanged(int,int)));
|
||||
|
||||
QStringList labels(QString(tr("Volume")));
|
||||
QStringList labels(QString(tr("Volume color")));
|
||||
labels.append(QString(tr("Filled")));
|
||||
labels.append(QString(tr("Hidden")));
|
||||
volumeList->setHorizontalHeaderLabels(labels);
|
||||
|
|
@ -99,17 +63,9 @@ MainWindow::MainWindow (QWidget * parent):CGAL::Qt::DemosMainWindow (parent),
|
|||
QObject::connect(&dialogmesh, SIGNAL(accepted()),
|
||||
this, SLOT(onCreateMeshOk()));
|
||||
|
||||
QObject::connect(dialogmenger.mengerLevel, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(onMengerChange(int)));
|
||||
QObject::connect(&dialogmenger, SIGNAL(accepted()),
|
||||
this, SLOT(onMengerOk()));
|
||||
QObject::connect(&dialogmenger, SIGNAL(rejected()),
|
||||
this, SLOT(onMengerCancel()));
|
||||
|
||||
this->viewer->setScene (&scene);
|
||||
this->viewer->setVectorPointers(&volumeDartIndex,&volumeProperties);
|
||||
|
||||
connectActions ();
|
||||
connect_actions ();
|
||||
this->addAboutDemo (":/cgal/help/about_Linear_cell_complex_3.html");
|
||||
this->addAboutCGAL ();
|
||||
|
||||
|
|
@ -124,7 +80,7 @@ MainWindow::MainWindow (QWidget * parent):CGAL::Qt::DemosMainWindow (parent),
|
|||
|
||||
}
|
||||
|
||||
void MainWindow::connectActions ()
|
||||
void MainWindow::connect_actions ()
|
||||
{
|
||||
QObject::connect (this->actionQuit, SIGNAL (triggered ()),
|
||||
qApp, SLOT (quit ()));
|
||||
|
|
@ -135,6 +91,13 @@ void MainWindow::connectActions ()
|
|||
QObject::connect(this->volumeList->horizontalHeader(),
|
||||
SIGNAL(sectionClicked(int)),
|
||||
this, SLOT(onHeaderClicked(int)));
|
||||
|
||||
QObject::connect(dialogmenger.mengerLevel, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(onMengerChange(int)));
|
||||
QObject::connect(&dialogmenger, SIGNAL(accepted()),
|
||||
this, SLOT(onMengerOk()));
|
||||
QObject::connect(&dialogmenger, SIGNAL(rejected()),
|
||||
this, SLOT(onMengerCancel()));
|
||||
}
|
||||
|
||||
void MainWindow::onSceneChanged ()
|
||||
|
|
@ -170,7 +133,7 @@ void MainWindow::onSceneChanged ()
|
|||
statusMessage->setText (os.str().c_str ());
|
||||
}
|
||||
|
||||
void MainWindow::updateOperationEntry(bool show)
|
||||
void MainWindow::update_operations_entries(bool show)
|
||||
{
|
||||
actionImportOFF->setEnabled(show);
|
||||
actionAddOFF->setEnabled(show);
|
||||
|
|
@ -232,7 +195,7 @@ void MainWindow::load_off (const QString & fileName, bool clear)
|
|||
std::ifstream ifs (qPrintable (fileName));
|
||||
|
||||
CGAL::import_from_polyhedron_3_flux < LCC > (*scene.lcc, ifs);
|
||||
initAllNewVolumes();
|
||||
init_all_new_volumes();
|
||||
|
||||
this->addToRecentFiles (fileName);
|
||||
QApplication::restoreOverrideCursor ();
|
||||
|
|
@ -246,22 +209,23 @@ void MainWindow::load_off (const QString & fileName, bool clear)
|
|||
emit (sceneChanged ());
|
||||
}
|
||||
|
||||
void MainWindow::onNewVolume(Dart_handle adart)
|
||||
void MainWindow::on_new_volume(Dart_handle adart)
|
||||
{
|
||||
scene.lcc->set_attribute<3>(adart,scene.lcc->create_attribute<3>
|
||||
(CGAL::Color(random.get_int(0,256),
|
||||
random.get_int(0,256),
|
||||
random.get_int(0,256))));
|
||||
assert( adart->attribute<3>()==NULL);
|
||||
scene.lcc->set_attribute<3>(adart,scene.lcc->create_attribute<3>());
|
||||
adart->attribute<3>()->info().color()=(CGAL::Color(myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256)));
|
||||
update_volume_list_add(adart);
|
||||
}
|
||||
|
||||
void MainWindow::initAllNewVolumes()
|
||||
void MainWindow::init_all_new_volumes()
|
||||
{
|
||||
for (LCC::One_dart_per_cell_range<3>::iterator
|
||||
it(scene.lcc->one_dart_per_cell<3>().begin());
|
||||
it.cont(); ++it)
|
||||
if ( it->attribute<3>()==NULL )
|
||||
{ onNewVolume(it); }
|
||||
{ on_new_volume(it); }
|
||||
}
|
||||
|
||||
void MainWindow::load_3DTDS (const QString & fileName, bool clear)
|
||||
|
|
@ -279,7 +243,7 @@ void MainWindow::load_3DTDS (const QString & fileName, bool clear)
|
|||
T.insert (begin, end);
|
||||
|
||||
CGAL::import_from_triangulation_3 < LCC, Triangulation >(*scene.lcc, T);
|
||||
initAllNewVolumes();
|
||||
init_all_new_volumes();
|
||||
|
||||
QApplication::restoreOverrideCursor ();
|
||||
emit (sceneChanged ());
|
||||
|
|
@ -310,7 +274,7 @@ Dart_handle MainWindow::on_actionCreate_cube_triggered ()
|
|||
|
||||
Dart_handle d = make_iso_cuboid(basepoint, 1);
|
||||
|
||||
onNewVolume(d);
|
||||
on_new_volume(d);
|
||||
|
||||
++nbcube;
|
||||
|
||||
|
|
@ -327,9 +291,9 @@ void MainWindow::on_actionCreate3Cubes_triggered ()
|
|||
Dart_handle d2 = make_iso_cuboid (Point_3 (nbcube + 1, nbcube, nbcube),1);
|
||||
Dart_handle d3 = make_iso_cuboid (Point_3 (nbcube, nbcube + 1, nbcube), 1);
|
||||
|
||||
onNewVolume(d1);
|
||||
onNewVolume(d2);
|
||||
onNewVolume(d3);
|
||||
on_new_volume(d1);
|
||||
on_new_volume(d2);
|
||||
on_new_volume(d3);
|
||||
|
||||
scene.lcc->sew<3> (d1->beta(1)->beta(1)->beta(2), d2->beta(2));
|
||||
scene.lcc->sew<3> (d1->beta(2)->beta(1)->beta(1)->beta(2), d3);
|
||||
|
|
@ -358,8 +322,8 @@ void MainWindow::on_actionCreate2Volumes_triggered ()
|
|||
CGAL::remove_cell<LCC,2>(*scene.lcc, d3);
|
||||
CGAL::remove_cell<LCC,2>(*scene.lcc, d2->beta (2));
|
||||
|
||||
onNewVolume(d1);
|
||||
onNewVolume(d4);
|
||||
on_new_volume(d1);
|
||||
on_new_volume(d4);
|
||||
|
||||
++nbcube;
|
||||
statusBar ()->showMessage (QString ("2 volumes were created"),
|
||||
|
|
@ -381,7 +345,7 @@ void MainWindow::onCreateMeshOk()
|
|||
{
|
||||
Dart_handle d = make_iso_cuboid
|
||||
(Point_3 (x+nbcube, y+nbcube, z+nbcube), 1);
|
||||
onNewVolume(d);
|
||||
on_new_volume(d);
|
||||
}
|
||||
++nbcube;
|
||||
|
||||
|
|
@ -401,11 +365,8 @@ void MainWindow::on_actionSubdivide_triggered ()
|
|||
void MainWindow::on_actionClear_triggered(bool msg)
|
||||
{
|
||||
scene.lcc->clear ();
|
||||
volumeUid = 1;
|
||||
nbcube=0;
|
||||
|
||||
volumeDartIndex.clear();
|
||||
volumeProperties.clear();
|
||||
volumeList->clearContents();
|
||||
volumeList->setRowCount(0);
|
||||
|
||||
|
|
@ -495,7 +456,7 @@ void MainWindow::on_actionCompute_Voronoi_3D_triggered ()
|
|||
scene.lcc->free_mark(mark_toremove);
|
||||
}
|
||||
|
||||
initAllNewVolumes();
|
||||
init_all_new_volumes();
|
||||
emit (sceneChanged ());
|
||||
statusBar ()->showMessage (QString ("Voronoi 3D of points in ") + fileName,
|
||||
DELAY_STATUSMSG);
|
||||
|
|
@ -518,7 +479,7 @@ void MainWindow::on_actionDual_3_triggered ()
|
|||
delete scene.lcc;
|
||||
scene.lcc = duallcc;
|
||||
this->viewer->setScene(&scene);
|
||||
initAllNewVolumes();
|
||||
init_all_new_volumes();
|
||||
|
||||
statusBar ()->showMessage (QString ("Dual_3 computed"), DELAY_STATUSMSG);
|
||||
emit (sceneChanged ());
|
||||
|
|
@ -528,8 +489,8 @@ void MainWindow::on_actionClose_volume_triggered()
|
|||
{
|
||||
if ( scene.lcc->close(3) > 0 )
|
||||
{
|
||||
initAllNewVolumes();
|
||||
statusBar ()->showMessage (QString ("Volume are closed"), DELAY_STATUSMSG);
|
||||
init_all_new_volumes();
|
||||
statusBar ()->showMessage (QString ("All volume(s) closed"), DELAY_STATUSMSG);
|
||||
emit (sceneChanged ());
|
||||
}
|
||||
else
|
||||
|
|
@ -541,14 +502,21 @@ void MainWindow::on_actionSew3_same_facets_triggered()
|
|||
{
|
||||
// timer.reset();
|
||||
// timer.start();
|
||||
if ( scene.lcc->sew3_same_facets() > 0 )
|
||||
int mymark = scene.lcc->get_new_mark();
|
||||
mark_all_filled_and_visible_volumes(mymark);
|
||||
|
||||
if ( scene.lcc->sew3_same_facets(mymark) > 0 )
|
||||
{
|
||||
statusBar()->showMessage
|
||||
(QString ("Same facets are 3-sewn"), DELAY_STATUSMSG);
|
||||
(QString ("Same facets of visible and filled volume(s) are 3-sewn"),
|
||||
DELAY_STATUSMSG);
|
||||
emit (sceneChanged ());
|
||||
}
|
||||
else
|
||||
statusBar()->showMessage (QString ("No facets 3-sewn"), DELAY_STATUSMSG);
|
||||
|
||||
scene.lcc->free_mark(mymark);
|
||||
|
||||
// timer.stop();
|
||||
// std::cout<<"sew3_same_facets in "<<timer.time()<<" seconds."<<std::endl;
|
||||
}
|
||||
|
|
@ -560,14 +528,16 @@ void MainWindow::on_actionUnsew3_all_triggered()
|
|||
for (LCC::Dart_range::iterator it=scene.lcc->darts().begin();
|
||||
it!=scene.lcc->darts().end(); ++it)
|
||||
{
|
||||
if ( !it->is_free(3) )
|
||||
if ( !it->is_free(3) &&
|
||||
it->attribute<3>()->info().is_filled_and_visible() )
|
||||
{ scene.lcc->unsew<3>(it); ++nb; }
|
||||
}
|
||||
|
||||
if ( nb > 0 )
|
||||
{
|
||||
statusBar()->showMessage
|
||||
(QString ("All darts are 3-unsewn"), DELAY_STATUSMSG);
|
||||
(QString ("Darts between visible and filled volume(s) are 3-unsewn"),
|
||||
DELAY_STATUSMSG);
|
||||
emit (sceneChanged ());
|
||||
}
|
||||
else
|
||||
|
|
@ -577,65 +547,33 @@ void MainWindow::on_actionUnsew3_all_triggered()
|
|||
void MainWindow::on_actionRemove_filled_volumes_triggered()
|
||||
{
|
||||
unsigned int count = 0;
|
||||
if(volumeDartIndex.size() > 0)
|
||||
for (LCC::Attribute_range<3>::type::iterator
|
||||
it=scene.lcc->attributes<3>().begin(),
|
||||
itend=scene.lcc->attributes<3>().end(); it!=itend; )
|
||||
{
|
||||
for(unsigned int i = 0; i < volumeDartIndex.size();)
|
||||
LCC::Attribute_handle<3>::type cur = it++;
|
||||
if( cur->info().is_filled_and_visible() )
|
||||
{
|
||||
if( isVisibleAndFilled(volumeProperties[i]) )
|
||||
{
|
||||
CGAL::remove_cell<LCC,3>(*scene.lcc,volumeDartIndex[i].second);
|
||||
update_volume_list_remove(i);
|
||||
++count;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
update_volume_list_remove(cur->dart());
|
||||
CGAL::remove_cell<LCC,3>(*scene.lcc,cur->dart());
|
||||
++count;
|
||||
}
|
||||
emit(sceneChanged());
|
||||
}
|
||||
emit(sceneChanged());
|
||||
|
||||
statusBar()->showMessage
|
||||
(QString::number(count)+QString(" visible volume(s) removed"),
|
||||
(QString::number(count)+QString("Visible and filled volume(s) removed"),
|
||||
DELAY_STATUSMSG);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRemove_selected_volume_triggered()
|
||||
{
|
||||
bool nothingSelected = true;
|
||||
int row = 0;
|
||||
for(; row < volumeList->rowCount(); row++)
|
||||
{
|
||||
if(volumeList->item(row,0)->isSelected())
|
||||
{
|
||||
nothingSelected = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(nothingSelected)
|
||||
statusBar()->showMessage (QString("Nothing Selected"), DELAY_STATUSMSG);
|
||||
else
|
||||
{
|
||||
if(::isVisible(volumeProperties[row]))
|
||||
{
|
||||
CGAL::remove_cell<LCC,3>(*scene.lcc,volumeDartIndex[row].second);
|
||||
update_volume_list_remove(row);
|
||||
emit(sceneChanged());
|
||||
}
|
||||
else
|
||||
{
|
||||
statusBar()->showMessage (QString("Volume is hidden"), DELAY_STATUSMSG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionTriangulate_all_facets_triggered()
|
||||
{
|
||||
std::vector<LCC::Dart_handle> v;
|
||||
for (LCC::One_dart_per_cell_range<2>::iterator
|
||||
it(scene.lcc->one_dart_per_cell<2>().begin()); it.cont(); ++it)
|
||||
{
|
||||
v.push_back(it);
|
||||
if ( it->attribute<3>()->info().is_filled_and_visible() )
|
||||
v.push_back(it);
|
||||
}
|
||||
for (std::vector<LCC::Dart_handle>::iterator itv(v.begin());
|
||||
itv!=v.end(); ++itv)
|
||||
|
|
@ -643,7 +581,8 @@ void MainWindow::on_actionTriangulate_all_facets_triggered()
|
|||
|
||||
emit (sceneChanged ());
|
||||
statusBar()->showMessage
|
||||
(QString ("All facets were triangulated"), DELAY_STATUSMSG);
|
||||
(QString ("Facets of visible and filled volume(s) triangulated"),
|
||||
DELAY_STATUSMSG);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionMerge_all_volumes_triggered()
|
||||
|
|
@ -652,7 +591,8 @@ void MainWindow::on_actionMerge_all_volumes_triggered()
|
|||
for (LCC::Dart_range::iterator it(scene.lcc->darts().begin()),
|
||||
itend=scene.lcc->darts().end(); it!=itend; )
|
||||
{
|
||||
if ( !it->is_free(3) )
|
||||
if ( !it->is_free(3) &&
|
||||
it->attribute<3>()->info().is_filled_and_visible() )
|
||||
{
|
||||
CGAL::remove_cell<LCC,2>(*scene.lcc,it);
|
||||
itend=scene.lcc->darts().end();
|
||||
|
|
@ -663,8 +603,6 @@ void MainWindow::on_actionMerge_all_volumes_triggered()
|
|||
++it;
|
||||
}
|
||||
|
||||
volumeDartIndex.clear();
|
||||
volumeProperties.clear();
|
||||
volumeList->clearContents();
|
||||
volumeList->setRowCount(0);
|
||||
|
||||
|
|
@ -675,7 +613,7 @@ void MainWindow::on_actionMerge_all_volumes_triggered()
|
|||
|
||||
emit (sceneChanged ());
|
||||
statusBar()->showMessage
|
||||
(QString ("All volumes were merged"), DELAY_STATUSMSG);
|
||||
(QString ("All volume(s) merged"), DELAY_STATUSMSG);
|
||||
}
|
||||
|
||||
void MainWindow::connectVolumeListHandlers()
|
||||
|
|
@ -686,6 +624,7 @@ void MainWindow::connectVolumeListHandlers()
|
|||
this, SLOT(onItemSelectionChanged()));
|
||||
}
|
||||
|
||||
/*
|
||||
void MainWindow::check_volume_list()
|
||||
{
|
||||
// Check that the volumeList is ok
|
||||
|
|
@ -698,38 +637,27 @@ void MainWindow::check_volume_list()
|
|||
assert( (scene.lcc)->is_whole_map_marked(markVols) );
|
||||
(scene.lcc)->free_mark(markVols);
|
||||
}
|
||||
*/
|
||||
|
||||
bool MainWindow::is_volume_in_list(Dart_handle dh)
|
||||
{
|
||||
for(int row=0; row < volumeList->rowCount(); ++row)
|
||||
{
|
||||
for(LCC::Dart_of_cell_range<3>::iterator
|
||||
it=(scene.lcc)->darts_of_cell<3>(volumeDartIndex[row].second).begin(),
|
||||
itend=(scene.lcc)->darts_of_cell<3>(volumeDartIndex[row].second).end();
|
||||
it!=itend; ++it)
|
||||
{
|
||||
if(it==dh)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return ( volumeAttributePositions.find(dh->attribute<3>())!=
|
||||
volumeAttributePositions.end() );
|
||||
}
|
||||
|
||||
void MainWindow::update_volume_list_add(Dart_handle it)
|
||||
{
|
||||
assert( !is_volume_in_list(it) );
|
||||
|
||||
volumeDartIndex.push_back(std::pair<unsigned int, Dart_handle>(volumeUid,it));
|
||||
volumeProperties.push_back(setVisibleAndFilled(0));
|
||||
volumeList->disconnect(this);
|
||||
|
||||
// volumeAttributePositions[it->attribute<3>()]=volumeList->rowCount();
|
||||
|
||||
int newRow = volumeList->rowCount();
|
||||
volumeList->setRowCount(newRow+1);
|
||||
|
||||
volumeList->disconnect(this);
|
||||
|
||||
QTableWidgetItem* volumeLabel =
|
||||
new QTableWidgetItem(QString::number(volumeUid));
|
||||
QTableWidgetItem* volumeLabel = new QTableWidgetItem
|
||||
(QString(it->attribute<3>()->info().color_name().c_str()));
|
||||
volumeLabel->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
volumeLabel->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||
volumeList->setItem(newRow,0,volumeLabel);
|
||||
|
|
@ -744,7 +672,11 @@ void MainWindow::update_volume_list_add(Dart_handle it)
|
|||
hiddenCB->setCheckState(Qt::Unchecked);
|
||||
volumeList->setItem(newRow,2,hiddenCB);
|
||||
|
||||
volumeUid++;
|
||||
QTableWidgetItem* attribHandle = new QTableWidgetItem;
|
||||
attribHandle->setData
|
||||
(Qt::UserRole, reinterpret_cast<quintptr>(&*(it->attribute<3>())));
|
||||
|
||||
volumeList->setItem(newRow,3,attribHandle);
|
||||
|
||||
connectVolumeListHandlers();
|
||||
|
||||
|
|
@ -753,46 +685,86 @@ void MainWindow::update_volume_list_add(Dart_handle it)
|
|||
void MainWindow::update_volume_list_remove(int i)
|
||||
{
|
||||
assert(i<volumeList->rowCount());
|
||||
|
||||
volumeDartIndex.erase(volumeDartIndex.begin()+i);
|
||||
volumeProperties.erase(volumeProperties.begin()+i);
|
||||
volumeList->removeRow(i);
|
||||
|
||||
this->viewer->setSelectedVolumeIndex(-1);
|
||||
/* this->viewer->setSelectedVolumeIndex(-1);
|
||||
|
||||
if(volumeList->rowCount() > i)
|
||||
volumeList->item(i,0)->setSelected(false);
|
||||
|
||||
if ( volumeList->rowCount()>0 )
|
||||
volumeUid = volumeDartIndex[volumeList->rowCount()-1].first+1;
|
||||
else
|
||||
volumeUid = 1;
|
||||
volumeList->item(i,0)->setSelected(false);*/
|
||||
}
|
||||
|
||||
void MainWindow::update_volume_list_remove(Dart_handle dh)
|
||||
{
|
||||
for(int row=0; row < volumeList->rowCount(); ++row)
|
||||
{
|
||||
for(LCC::Dart_of_cell_range<3>::iterator
|
||||
it=(scene.lcc)->darts_of_cell<3>(volumeDartIndex[row].second).begin(),
|
||||
itend=(scene.lcc)->darts_of_cell<3>(volumeDartIndex[row].second).end();
|
||||
it!=itend; ++it)
|
||||
LCC::Attribute_type<3>::type* ptr=
|
||||
reinterpret_cast<LCC::Attribute_type<3>::type*>
|
||||
( volumeList->item(row,3)->data(Qt::UserRole).value<quintptr>() );
|
||||
|
||||
if(ptr==&*dh->attribute<3>())
|
||||
{
|
||||
if(it==dh)
|
||||
{
|
||||
update_volume_list_remove(row);
|
||||
return;
|
||||
}
|
||||
update_volume_list_remove(row);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::update_volume_list()
|
||||
{
|
||||
volumeList->disconnect(this);
|
||||
|
||||
for(int row=0; row < volumeList->rowCount(); ++row)
|
||||
{
|
||||
LCC::Attribute_type<3>::type* ptr=
|
||||
reinterpret_cast<LCC::Attribute_type<3>::type*>
|
||||
( volumeList->item(row,3)->data(Qt::UserRole).value<quintptr>() );
|
||||
|
||||
if ( ptr->info().is_filled() )
|
||||
volumeList->item(row,1)->setCheckState(Qt::Checked);
|
||||
else
|
||||
volumeList->item(row,1)->setCheckState(Qt::Unchecked);
|
||||
|
||||
if ( !ptr->info().is_visible() )
|
||||
volumeList->item(row,2)->setCheckState(Qt::Checked);
|
||||
else
|
||||
volumeList->item(row,2)->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
|
||||
connectVolumeListHandlers();
|
||||
}
|
||||
|
||||
void MainWindow::mark_all_filled_and_visible_volumes(int amark)
|
||||
{
|
||||
for (LCC::Attribute_range<3>::type::iterator
|
||||
it=scene.lcc->attributes<3>().begin(),
|
||||
itend=scene.lcc->attributes<3>().end(); it!=itend; ++it)
|
||||
{
|
||||
if ( it->info().is_filled_and_visible() &&
|
||||
!scene.lcc->is_marked(it->dart(), amark) )
|
||||
CGAL::mark_cell<LCC,3>(*scene.lcc, it->dart(), amark);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onCellChanged(int row, int col)
|
||||
{
|
||||
LCC::Attribute_type<3>::type* ptr=
|
||||
reinterpret_cast<LCC::Attribute_type<3>::type*>
|
||||
( volumeList->item(row,3)->data(Qt::UserRole).value<quintptr>() );
|
||||
|
||||
volumeProperties[row] =
|
||||
(volumeList->item(row,2)->checkState() == Qt::Unchecked ? ::setVisible(0) : 0) |
|
||||
(volumeList->item(row,1)->checkState() == Qt::Checked ? ::setFilled(0) : 0 );
|
||||
if ( col==1 )
|
||||
{
|
||||
ptr->info().negate_filled();
|
||||
}
|
||||
else if ( col==2 )
|
||||
{
|
||||
ptr->info().negate_visible();
|
||||
if ( !ptr->info().is_visible() )
|
||||
volumeList->item(row,1)->setFlags
|
||||
(volumeList->item(row,1)->flags()^Qt::ItemIsEnabled);
|
||||
else
|
||||
volumeList->item(row,1)->setFlags
|
||||
(volumeList->item(row,1)->flags()|Qt::ItemIsEnabled);
|
||||
}
|
||||
|
||||
// Change selection when toggling any checkbox?
|
||||
// volumeList->item(row,0)->setSelected(true);
|
||||
|
|
@ -807,15 +779,15 @@ void MainWindow::onItemSelectionChanged()
|
|||
// QItemSelectionModel* selectionModel = volumeList->selectionModel();
|
||||
// QModelIndexList selectedRow = selectionModel->selectedIndexes();
|
||||
|
||||
int row = 0;
|
||||
/* int row = 0;
|
||||
for(; row < volumeList->rowCount(); row++)
|
||||
{
|
||||
if(volumeList->item(row,0)->isSelected())
|
||||
break;
|
||||
}
|
||||
|
||||
this->viewer->setSelectedVolumeIndex(row);
|
||||
emit(sceneChanged());
|
||||
//this->viewer->setSelectedVolumeIndex(row);
|
||||
emit(sceneChanged()); */
|
||||
// statusBar()->showMessage (QString::number(row)+QString(" is selected"), DELAY_STATUSMSG);
|
||||
}
|
||||
|
||||
|
|
@ -825,28 +797,29 @@ void MainWindow::onHeaderClicked(int col)
|
|||
{
|
||||
volumeList->disconnect(this);
|
||||
|
||||
for(unsigned int i = 0; i < volumeProperties.size(); i++)
|
||||
for(int i = 0; i < volumeList->rowCount(); ++i)
|
||||
{
|
||||
LCC::Attribute_type<3>::type* ptr=
|
||||
reinterpret_cast<LCC::Attribute_type<3>::type*>
|
||||
( volumeList->item(i,3)->data(Qt::UserRole).value<quintptr>() );
|
||||
|
||||
switch(qApp->keyboardModifiers())
|
||||
{
|
||||
case(Qt::ShiftModifier):
|
||||
volumeProperties[i] =
|
||||
(col == 1 ? ::setWireframe(volumeProperties[i]) :
|
||||
::setVisible(volumeProperties[i]));
|
||||
volumeList->item(i,col)->setCheckState( Qt::Unchecked);
|
||||
if (col==1) ptr->info().set_filled(false);
|
||||
else if (col==2) ptr->info().set_visible(true);
|
||||
volumeList->item(i,col)->setCheckState(Qt::Unchecked);
|
||||
break;
|
||||
case(Qt::ControlModifier):
|
||||
volumeProperties[i] =
|
||||
( col == 1 ? ::negateFilled(volumeProperties[i]) :
|
||||
::negateVisible(volumeProperties[i]));
|
||||
if (col==1) ptr->info().negate_filled();
|
||||
else if (col==2) ptr->info().negate_visible();
|
||||
volumeList->item(i,col)->
|
||||
setCheckState(volumeList->item(i,col)->checkState() ?
|
||||
Qt::Unchecked: Qt::Checked);
|
||||
break;
|
||||
default:
|
||||
volumeProperties[i] =
|
||||
(col == 1 ? ::setFilled(volumeProperties[i]) :
|
||||
::setHidden(volumeProperties[i]));
|
||||
if (col==1) ptr->info().set_filled(true);
|
||||
else if (col==2) ptr->info().set_visible(false);
|
||||
volumeList->item(i,col)->setCheckState(Qt::Checked);
|
||||
break;
|
||||
}
|
||||
|
|
@ -857,7 +830,7 @@ void MainWindow::onHeaderClicked(int col)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::extendVolumesSatisfying(char amask, char negatemask)
|
||||
void MainWindow::on_actionExtend_filled_volumes_triggered()
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
|
|
@ -865,62 +838,90 @@ void MainWindow::extendVolumesSatisfying(char amask, char negatemask)
|
|||
|
||||
int mark_volume = scene.lcc->get_new_mark();
|
||||
|
||||
for(unsigned int i = 0; i < volumeProperties.size(); i++)
|
||||
for (LCC::Attribute_range<3>::type::iterator
|
||||
it=scene.lcc->attributes<3>().begin(),
|
||||
itend=scene.lcc->attributes<3>().end(); it!=itend; ++it)
|
||||
{
|
||||
if ( ((volumeProperties[i] & amask) == amask) &&
|
||||
((volumeProperties[i] & negatemask) ==0 ) )
|
||||
if ( it->info().is_filled() &&
|
||||
!scene.lcc->is_marked(it->dart(), mark_volume) )
|
||||
{
|
||||
for (LCC::Dart_of_cell_range<3>::iterator
|
||||
it=scene.lcc->darts_of_cell<3>(volumeDartIndex[i].second).begin(),
|
||||
itend=scene.lcc->darts_of_cell<3>(volumeDartIndex[i].second).end();
|
||||
it!=itend; ++it )
|
||||
for (LCC::Dart_of_cell_basic_range<3>::iterator it2=
|
||||
scene.lcc->darts_of_cell_basic<3>(it->dart(), mark_volume).begin();
|
||||
it2.cont(); ++it2 )
|
||||
{
|
||||
scene.lcc->mark(it, mark_volume);
|
||||
if ( !it->is_free(3) &&
|
||||
!scene.lcc->is_marked( it->beta(3), mark_volume) )
|
||||
scene.lcc->mark(it2, mark_volume);
|
||||
if ( !it2->is_free(3) &&
|
||||
!scene.lcc->is_marked( it2->beta(3), mark_volume) )
|
||||
{
|
||||
CGAL::mark_cell<LCC,3>(*scene.lcc, it->beta(3), mark_volume);
|
||||
CGAL::mark_cell<LCC,3>(*scene.lcc, it2->beta(3), mark_volume);
|
||||
it2->beta(3)->attribute<3>()->info().set_filled(true);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < volumeProperties.size(); i++)
|
||||
CGAL_assertion( scene.lcc->is_whole_map_unmarked(mark_volume) );
|
||||
scene.lcc->free_mark(mark_volume);
|
||||
|
||||
connectVolumeListHandlers();
|
||||
if ( changed )
|
||||
{
|
||||
if ( scene.lcc->is_marked(volumeDartIndex[i].second, mark_volume) )
|
||||
update_volume_list();
|
||||
emit(sceneChanged());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExtend_hidden_volumes_triggered()
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
volumeList->disconnect(this);
|
||||
|
||||
int mark_volume = scene.lcc->get_new_mark();
|
||||
|
||||
for (LCC::Attribute_range<3>::type::iterator
|
||||
it=scene.lcc->attributes<3>().begin(),
|
||||
itend=scene.lcc->attributes<3>().end(); it!=itend; ++it)
|
||||
{
|
||||
if ( !it->info().is_visible() &&
|
||||
!scene.lcc->is_marked(it->dart(), mark_volume) )
|
||||
{
|
||||
volumeProperties[i] |= amask;
|
||||
volumeProperties[i] ^= (volumeProperties[i] & negatemask);
|
||||
CGAL::unmark_cell<LCC,3>(*scene.lcc, volumeDartIndex[i].second,
|
||||
mark_volume);
|
||||
|
||||
volumeList->item(i,1)->setCheckState
|
||||
( (::isFilled(volumeProperties[i])? Qt::Checked : Qt::Unchecked) );
|
||||
volumeList->item(i,2)->setCheckState
|
||||
( (::isVisible(volumeProperties[i])? Qt::Unchecked: Qt::Checked) );
|
||||
for (LCC::Dart_of_cell_basic_range<3>::iterator it2=
|
||||
scene.lcc->darts_of_cell_basic<3>(it->dart(), mark_volume).begin();
|
||||
it2.cont(); ++it2 )
|
||||
{
|
||||
scene.lcc->mark(it2, mark_volume);
|
||||
if ( !it2->is_free(3) &&
|
||||
!scene.lcc->is_marked( it2->beta(3), mark_volume) )
|
||||
{
|
||||
CGAL::mark_cell<LCC,3>(*scene.lcc, it2->beta(3), mark_volume);
|
||||
it2->beta(3)->attribute<3>()->info().set_visible(false);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CGAL_assertion( scene.lcc->is_whole_map_unmarked(mark_volume) );
|
||||
scene.lcc->free_mark(mark_volume);
|
||||
|
||||
connectVolumeListHandlers();
|
||||
if ( changed ) emit(sceneChanged());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExtend_filled_volumes_triggered()
|
||||
{ extendVolumesSatisfying( LCC_DEMO_VISIBLE | LCC_DEMO_FILLED, 0 ); }
|
||||
void MainWindow::on_actionExtend_hidden_volumes_triggered()
|
||||
{ extendVolumesSatisfying( 0, LCC_DEMO_VISIBLE ); }
|
||||
connectVolumeListHandlers();
|
||||
if ( changed )
|
||||
{
|
||||
update_volume_list();
|
||||
emit(sceneChanged());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionCreate_Menger_Sponge_triggered ()
|
||||
{
|
||||
dialogmenger.mengerLevel->setValue(0);
|
||||
mengerLevel=0;
|
||||
mengerFirstVol= (int)volumeProperties.size();
|
||||
/* mengerFirstVol= (int)volumeProperties.size();
|
||||
mengerDart=on_actionCreate_cube_triggered();
|
||||
updateOperationEntry(false);
|
||||
*/
|
||||
update_operations_entries(false);
|
||||
dialogmenger.show();
|
||||
}
|
||||
|
||||
|
|
@ -954,13 +955,13 @@ void MainWindow::onMengerCancel()
|
|||
|
||||
toremove.clear();
|
||||
connectVolumeListHandlers();
|
||||
updateOperationEntry(true);
|
||||
update_operations_entries(true);
|
||||
emit(sceneChanged());
|
||||
}
|
||||
|
||||
void MainWindow::onMengerOk()
|
||||
{
|
||||
updateOperationEntry(true);
|
||||
update_operations_entries(true);
|
||||
}
|
||||
|
||||
void MainWindow::onMengerChange(int newLevel)
|
||||
|
|
@ -972,7 +973,8 @@ void MainWindow::onMengerChange(int newLevel)
|
|||
void MainWindow::onMengerInc()
|
||||
{
|
||||
this->mengerLevel++;
|
||||
|
||||
/*
|
||||
TODO
|
||||
std::vector<Dart_handle> edges;
|
||||
std::vector<Dart_handle> faces;
|
||||
std::vector<Dart_handle> volumes;
|
||||
|
|
@ -1045,7 +1047,7 @@ void MainWindow::onMengerInc()
|
|||
{
|
||||
split_vol_in_twentyseven(volumes[i]);
|
||||
}
|
||||
|
||||
*/
|
||||
assert( (scene.lcc)->is_valid() );
|
||||
|
||||
emit(sceneChanged());
|
||||
|
|
@ -1120,15 +1122,15 @@ void MainWindow::split_vol_in_three(Dart_handle dh, bool removecenter)
|
|||
Dart_handle f2=
|
||||
insert_cell_2_in_cell_3(*(scene.lcc),edges2.begin(),edges2.end());
|
||||
|
||||
f1->attribute<3>()->info()=
|
||||
(CGAL::Color(random.get_int(0,256),
|
||||
random.get_int(0,256),
|
||||
random.get_int(0,256)));
|
||||
/* f1->attribute<3>()->info()=
|
||||
(CGAL::Color(myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256)));
|
||||
f2->attribute<3>()->info()=
|
||||
(CGAL::Color(random.get_int(0,256),
|
||||
random.get_int(0,256),
|
||||
random.get_int(0,256)));
|
||||
|
||||
(CGAL::Color(myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256)));
|
||||
*/
|
||||
if ( removecenter )
|
||||
CGAL::remove_cell<LCC,3>(*scene.lcc,f1);
|
||||
else
|
||||
|
|
@ -1164,13 +1166,14 @@ void MainWindow::split_vol_in_nine(Dart_handle dh, bool removecenter)
|
|||
Dart_handle f2=
|
||||
insert_cell_2_in_cell_3(*(scene.lcc),edges2.begin(),edges2.end());
|
||||
|
||||
f1->attribute<3>()->info()=(CGAL::Color(random.get_int(0,256),
|
||||
random.get_int(0,256),
|
||||
random.get_int(0,256)));
|
||||
f2->attribute<3>()->info()=(CGAL::Color(random.get_int(0,256),
|
||||
random.get_int(0,256),
|
||||
random.get_int(0,256)));
|
||||
|
||||
/*
|
||||
f1->attribute<3>()->info()=(CGAL::Color(myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256)));
|
||||
f2->attribute<3>()->info()=(CGAL::Color(myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256)));
|
||||
*/
|
||||
split_face_in_three(f1);
|
||||
split_face_in_three(f2);
|
||||
|
||||
|
|
@ -1215,13 +1218,14 @@ void MainWindow::split_vol_in_twentyseven(Dart_handle dh)
|
|||
Dart_handle f2=
|
||||
insert_cell_2_in_cell_3(*(scene.lcc),edges2.begin(),edges2.end());
|
||||
|
||||
f1->attribute<3>()->info()=(CGAL::Color(random.get_int(0,256),
|
||||
random.get_int(0,256),
|
||||
random.get_int(0,256)));
|
||||
f2->attribute<3>()->info()=(CGAL::Color(random.get_int(0,256),
|
||||
random.get_int(0,256),
|
||||
random.get_int(0,256)));
|
||||
|
||||
/*
|
||||
f1->attribute<3>()->info()=(CGAL::Color(myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256)));
|
||||
f2->attribute<3>()->info()=(CGAL::Color(myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256)));
|
||||
*/
|
||||
update_volume_list_add(f1->beta(2));
|
||||
update_volume_list_add(f2->beta(2));
|
||||
|
||||
|
|
@ -1233,7 +1237,7 @@ void MainWindow::split_vol_in_twentyseven(Dart_handle dh)
|
|||
split_vol_in_nine(f2->beta(2),false);
|
||||
}
|
||||
|
||||
void MainWindow::processFullSlice(Dart_handle init,
|
||||
void MainWindow::process_full_slice(Dart_handle init,
|
||||
std::vector<Dart_handle>& faces,
|
||||
int markVols)
|
||||
{
|
||||
|
|
@ -1265,7 +1269,7 @@ void MainWindow::processFullSlice(Dart_handle init,
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::processInterSlice(Dart_handle init,
|
||||
void MainWindow::process_inter_slice(Dart_handle init,
|
||||
std::vector<Dart_handle>& faces,
|
||||
int markVols)
|
||||
{
|
||||
|
|
@ -1317,6 +1321,8 @@ void MainWindow::onMengerDec()
|
|||
{
|
||||
this->mengerLevel--;
|
||||
|
||||
// TODO
|
||||
/*
|
||||
int markVols = (scene.lcc)->get_new_mark();
|
||||
int markVertices = (scene.lcc)->get_new_mark();
|
||||
|
||||
|
|
@ -1333,11 +1339,11 @@ void MainWindow::onMengerDec()
|
|||
{
|
||||
Dart_handle init=volumeDartIndex[i].second;
|
||||
CGAL::mark_cell<LCC,3>(*(scene.lcc), init, markVols);
|
||||
processFullSlice(init,faces,markVols);
|
||||
process_full_slice(init,faces,markVols);
|
||||
init=init->beta(2)->beta(1)->beta(1)->beta(2);
|
||||
processInterSlice(init,faces,markVols);
|
||||
process_inter_slice(init,faces,markVols);
|
||||
init=init->beta(3)->beta(2)->beta(1)->beta(1)->beta(2)->beta(3);
|
||||
processFullSlice(init,faces,markVols);
|
||||
process_full_slice(init,faces,markVols);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1425,7 +1431,7 @@ void MainWindow::onMengerDec()
|
|||
|
||||
(scene.lcc)->free_mark(markVols);
|
||||
(scene.lcc)->free_mark(markVertices);
|
||||
|
||||
*/
|
||||
statusBar ()->showMessage (QString ("Menger Dec"),DELAY_STATUSMSG);
|
||||
emit(sceneChanged());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include "ui_CreateMenger.h"
|
||||
|
||||
#include <CGAL/Qt/DemosMainWindow.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QSlider>
|
||||
|
|
@ -46,9 +45,7 @@ class DialogMesh : public QDialog, public Ui::createMesh
|
|||
|
||||
public:
|
||||
DialogMesh(QWidget* parent)
|
||||
{
|
||||
setupUi (this);
|
||||
}
|
||||
{ setupUi (this); }
|
||||
|
||||
int getX() { return xvalue->value(); }
|
||||
int getY() { return yvalue->value(); }
|
||||
|
|
@ -57,14 +54,11 @@ public:
|
|||
|
||||
class DialogMenger : public QDialog, public Ui::createMenger
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
DialogMenger(QWidget *parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
public:
|
||||
DialogMenger(QWidget *parent)
|
||||
{ setupUi(this); }
|
||||
};
|
||||
|
||||
class MainWindow : public CGAL::Qt::DemosMainWindow, private Ui::MainWindow
|
||||
|
|
@ -97,7 +91,6 @@ public slots:
|
|||
void on_actionSew3_same_facets_triggered();
|
||||
void on_actionUnsew3_all_triggered();
|
||||
void on_actionMerge_all_volumes_triggered();
|
||||
void on_actionRemove_selected_volume_triggered();
|
||||
void on_actionRemove_filled_volumes_triggered();
|
||||
|
||||
// View menu
|
||||
|
|
@ -107,7 +100,6 @@ public slots:
|
|||
// Other slots
|
||||
void load_off(const QString& fileName, bool clear=true);
|
||||
void load_3DTDS(const QString& fileName, bool clear=true);
|
||||
void extendVolumesSatisfying(char amask, char negatemask);
|
||||
|
||||
void onSceneChanged();
|
||||
|
||||
|
|
@ -128,14 +120,15 @@ signals:
|
|||
void sceneChanged();
|
||||
|
||||
protected:
|
||||
void onNewVolume(Dart_handle adart);
|
||||
void onDeleteVolume(Dart_handle adart);
|
||||
void initAllNewVolumes();
|
||||
|
||||
void on_new_volume(Dart_handle adart);
|
||||
void on_delete_volume(Dart_handle adart);
|
||||
void init_all_new_volumes();
|
||||
void mark_all_filled_and_visible_volumes(int amark);
|
||||
|
||||
Dart_handle make_iso_cuboid(const Point_3 basepoint, LCC::FT lg);
|
||||
|
||||
void connectActions();
|
||||
void updateOperationEntry(bool show);
|
||||
void connect_actions();
|
||||
void update_operations_entries(bool show);
|
||||
|
||||
void check_volume_list();
|
||||
bool is_volume_in_list(Dart_handle it);
|
||||
|
|
@ -150,12 +143,12 @@ protected:
|
|||
void split_vol_in_three (Dart_handle dh, bool removecenter);
|
||||
void split_vol_in_nine (Dart_handle dh, bool removecenter);
|
||||
void split_vol_in_twentyseven(Dart_handle dh);
|
||||
void processFullSlice(Dart_handle init,
|
||||
std::vector<Dart_handle>& faces,
|
||||
int markVols);
|
||||
void processInterSlice(Dart_handle init,
|
||||
std::vector<Dart_handle>& faces,
|
||||
int markVols);
|
||||
void process_full_slice(Dart_handle init,
|
||||
std::vector<Dart_handle>& faces,
|
||||
int markVols);
|
||||
void process_inter_slice(Dart_handle init,
|
||||
std::vector<Dart_handle>& faces,
|
||||
int markVols);
|
||||
|
||||
Scene scene;
|
||||
Timer timer;
|
||||
|
|
@ -164,18 +157,16 @@ protected:
|
|||
QLabel* statusMessage;
|
||||
DialogMesh dialogmesh;
|
||||
DialogMenger dialogmenger;
|
||||
CGAL::Random random;
|
||||
|
||||
int mengerLevel;
|
||||
int mengerFirstVol;
|
||||
Dart_handle mengerDart;
|
||||
|
||||
std::vector<Dart_handle> mengerVolumes;
|
||||
|
||||
QDockWidget* volumeListDock;
|
||||
QTableWidget* volumeList;
|
||||
|
||||
unsigned int volumeUid;
|
||||
std::vector< std::pair<unsigned int,Dart_handle> > volumeDartIndex;
|
||||
std::vector< char > volumeProperties;
|
||||
std::map<LCC::Attribute_handle<3>::type, int> volumeAttributePositions;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -55,15 +55,14 @@
|
|||
<string>&Operations</string>
|
||||
</property>
|
||||
<addaction name="actionSubdivide"/>
|
||||
<addaction name="actionDual_3"/>
|
||||
<addaction name="actionClose_volume"/>
|
||||
<addaction name="actionTriangulate_all_facets"/>
|
||||
<addaction name="actionSew3_same_facets"/>
|
||||
<addaction name="actionUnsew3_all"/>
|
||||
<addaction name="actionMerge_all_volumes"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionRemove_selected_volume"/>
|
||||
<addaction name="actionRemove_filled_volumes"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionClose_volume"/>
|
||||
<addaction name="actionSew3_same_facets"/>
|
||||
<addaction name="actionDual_3"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuCreations">
|
||||
<property name="title">
|
||||
|
|
@ -142,7 +141,7 @@
|
|||
</action>
|
||||
<action name="actionClose_volume">
|
||||
<property name="text">
|
||||
<string>&Close volumes</string>
|
||||
<string>&Close all volumes</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreate_cube">
|
||||
|
|
@ -152,7 +151,7 @@
|
|||
</action>
|
||||
<action name="actionSew3_same_facets">
|
||||
<property name="text">
|
||||
<string>S&ew3 same facets</string>
|
||||
<string>S&ew3 all same facets</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreate_mesh">
|
||||
|
|
@ -167,17 +166,17 @@
|
|||
</action>
|
||||
<action name="actionRemove_filled_volumes">
|
||||
<property name="text">
|
||||
<string>&Remove filled volumes</string>
|
||||
<string>&Remove volumes</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionTriangulate_all_facets">
|
||||
<property name="text">
|
||||
<string>&Triangulate all facets</string>
|
||||
<string>&Triangulate facets</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUnsew3_all">
|
||||
<property name="text">
|
||||
<string>&Unsew3 all</string>
|
||||
<string>&Unsew3</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemove_selected_volume">
|
||||
|
|
@ -215,7 +214,7 @@
|
|||
</action>
|
||||
<action name="actionMerge_all_volumes">
|
||||
<property name="text">
|
||||
<string>&Merge all volumes</string>
|
||||
<string>&Merge volumes</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
|
|
|||
|
|
@ -31,18 +31,20 @@ CGAL::Bbox_3 Viewer::bbox()
|
|||
if ( scene->lcc->is_empty() )
|
||||
{
|
||||
bb = LCC::Point(CGAL::ORIGIN).bbox();
|
||||
bb = bb + LCC::Point(1,1,1).bbox(); // To avoid a warning from Qglviewer
|
||||
}
|
||||
else
|
||||
{
|
||||
for(unsigned int i = 0; i < pVolumeDartIndex->size(); i++)
|
||||
for (LCC::Attribute_range<3>::type::iterator
|
||||
it=scene->lcc->attributes<3>().begin(),
|
||||
itend=scene->lcc->attributes<3>().end(); it!=itend; ++it )
|
||||
{
|
||||
if( ::isVisible((*pVolumeProperties)[i]))
|
||||
if ( it->info().is_visible() )
|
||||
{
|
||||
for( LCC::Dart_of_cell_range<3>::iterator
|
||||
it=scene->lcc->darts_of_cell<3>((*pVolumeDartIndex)[i].second).begin(),
|
||||
itend=scene->lcc->darts_of_cell<3>((*pVolumeDartIndex)[i].second).end();
|
||||
it.cont(); ++it)
|
||||
bb = bb + LCC::point(it).bbox();
|
||||
it2=scene->lcc->darts_of_cell<3>(it->dart()).begin();
|
||||
it2.cont(); ++it2)
|
||||
bb = bb + LCC::point(it2).bbox();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -73,14 +75,14 @@ void Viewer::drawFacet(Dart_const_handle ADart)
|
|||
assert( ADart->attribute<3>()!=NULL );
|
||||
|
||||
// double r = (double)ADart->attribute<3>()->info().r()/255.0;
|
||||
double r = (double)ADart->attribute<3>()->info().r()/255.0;
|
||||
double g = (double)ADart->attribute<3>()->info().g()/255.0;
|
||||
double b = (double)ADart->attribute<3>()->info().b()/255.0;
|
||||
double r = (double)ADart->attribute<3>()->info().color().r()/255.0;
|
||||
double g = (double)ADart->attribute<3>()->info().color().g()/255.0;
|
||||
double b = (double)ADart->attribute<3>()->info().color().b()/255.0;
|
||||
if ( !ADart->is_free(3) )
|
||||
{
|
||||
r += (double)ADart->beta(3)->attribute<3>()->info().r()/255.0;
|
||||
g += (double)ADart->beta(3)->attribute<3>()->info().g()/255.0;
|
||||
b += (double)ADart->beta(3)->attribute<3>()->info().b()/255.0;
|
||||
r += (double)ADart->beta(3)->attribute<3>()->info().color().r()/255.0;
|
||||
g += (double)ADart->beta(3)->attribute<3>()->info().color().g()/255.0;
|
||||
b += (double)ADart->beta(3)->attribute<3>()->info().color().b()/255.0;
|
||||
r /= 2; g /= 2; b /= 2;
|
||||
}
|
||||
|
||||
|
|
@ -142,8 +144,7 @@ void Viewer::draw_one_vol(Dart_const_handle adart, bool filled)
|
|||
it.cont(); ++it)
|
||||
{
|
||||
drawFacet(it);
|
||||
if(edges) drawEdges(it);
|
||||
|
||||
if (edges) drawEdges(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -171,21 +172,23 @@ void Viewer::draw()
|
|||
|
||||
if ( m.is_empty() ) return;
|
||||
|
||||
for(unsigned int i = 0; i < pVolumeDartIndex->size(); i++)
|
||||
for (LCC::Attribute_range<3>::type::iterator
|
||||
it=m.attributes<3>().begin(),
|
||||
itend=m.attributes<3>().end(); it!=itend; ++it )
|
||||
{
|
||||
if( ::isVisible((*pVolumeProperties)[i]))
|
||||
if ( it->info().is_visible() )
|
||||
{
|
||||
if(selectedVolumeIndex == (int)i) glLineWidth(5.0f);
|
||||
draw_one_vol((*pVolumeDartIndex)[i].second,
|
||||
::isFilled((*pVolumeProperties)[i]));
|
||||
if(selectedVolumeIndex == (int)i) glLineWidth(1.4f);
|
||||
// TODO allow to select one volume ?
|
||||
// if(selectedVolumeIndex == (int)i) glLineWidth(5.0f);
|
||||
draw_one_vol(it->dart(), it->info().is_filled());
|
||||
// if(selectedVolumeIndex == (int)i) glLineWidth(1.4f);
|
||||
|
||||
if(vertices)
|
||||
{
|
||||
for( LCC::One_dart_per_incident_cell_range<0,3>::iterator
|
||||
it(m, (*pVolumeDartIndex)[i].second); it.cont(); ++it)
|
||||
it2(m, it->dart()); it2.cont(); ++it2)
|
||||
{
|
||||
LCC::Point p = m.point(it);
|
||||
LCC::Point p = m.point(it2);
|
||||
glBegin(GL_POINTS);
|
||||
glColor3f(.6f,.2f,.8f);
|
||||
glVertex3f( p.x(),p.y(),p.z());
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include "typedefs.h"
|
||||
#include <QGLViewer/qglviewer.h>
|
||||
#include <QKeyEvent>
|
||||
#include <QTableWidget>
|
||||
|
||||
class Viewer : public QGLViewer
|
||||
{
|
||||
|
|
@ -42,14 +41,11 @@ class Viewer : public QGLViewer
|
|||
typedef LCC::Dart_handle Dart_handle;
|
||||
typedef LCC::Dart_const_handle Dart_const_handle;
|
||||
|
||||
std::vector<std::pair<unsigned int,Dart_handle> >* pVolumeDartIndex;
|
||||
std::vector<char>* pVolumeProperties;
|
||||
|
||||
|
||||
public:
|
||||
Viewer(QWidget* parent)
|
||||
: QGLViewer(parent), wireframe(false), flatShading(true),
|
||||
edges(true), vertices(true), modeFilledFacet(0), selectedVolumeIndex(-1)
|
||||
edges(true), vertices(true), modeFilledFacet(0)
|
||||
{}
|
||||
|
||||
void setScene(Scene* scene_)
|
||||
|
|
@ -57,18 +53,6 @@ public:
|
|||
scene = scene_;
|
||||
}
|
||||
|
||||
void setVectorPointers(std::vector<std::pair<unsigned int,Dart_handle> >* v1,
|
||||
std::vector<char>* v2)
|
||||
{
|
||||
pVolumeDartIndex = v1;
|
||||
pVolumeProperties = v2;
|
||||
}
|
||||
|
||||
void setSelectedVolumeIndex(unsigned int index)
|
||||
{
|
||||
selectedVolumeIndex = index;
|
||||
}
|
||||
|
||||
public:
|
||||
void draw();
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <CGAL/IO/Color.h>
|
||||
#include <CGAL/Timer.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
|
@ -35,17 +36,80 @@
|
|||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
// Global random
|
||||
extern CGAL::Random myrandom;
|
||||
|
||||
template<class Cell>
|
||||
struct Average_functor : public std::binary_function<Cell,Cell,void>
|
||||
struct Merge_vol_functor : public std::binary_function<Cell,Cell,void>
|
||||
{
|
||||
void operator()(Cell& acell1,Cell& acell2)
|
||||
{
|
||||
acell1.attribute()=
|
||||
CGAL::Color((acell1.attribute().r()+acell2.attribute().r())/2,
|
||||
(acell1.attribute().g()+acell2.attribute().g())/2,
|
||||
(acell1.attribute().b()+acell2.attribute().b())/2);
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<class Cell>
|
||||
struct Split_vol_functor : public std::binary_function<Cell,Cell,void>
|
||||
{
|
||||
void operator()(Cell& acell1,Cell& acell2)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// Use to define properties on volumes.
|
||||
#define LCC_DEMO_VISIBLE 1 // if not visible => hidden
|
||||
#define LCC_DEMO_FILLED 2 // if not filled, wireframe
|
||||
|
||||
class Volume_info
|
||||
{
|
||||
public:
|
||||
Volume_info() : m_color(CGAL::Color(myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256),
|
||||
myrandom.get_int(0,256))),
|
||||
m_status( LCC_DEMO_VISIBLE | LCC_DEMO_FILLED )
|
||||
{}
|
||||
|
||||
CGAL::Color& color()
|
||||
{ return m_color; }
|
||||
const CGAL::Color& color() const
|
||||
{ return m_color; }
|
||||
|
||||
std::string color_name() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "#" << std::hex << m_color.red()<< m_color.green()<<m_color.blue();
|
||||
return std::string(ss.str());
|
||||
}
|
||||
|
||||
bool is_visible() const
|
||||
{ return (m_status & LCC_DEMO_VISIBLE); }
|
||||
bool is_filled() const
|
||||
{ return (m_status & LCC_DEMO_FILLED); }
|
||||
bool is_filled_and_visible() const
|
||||
{ return is_filled() && is_visible(); }
|
||||
|
||||
void set_visible(bool val=true)
|
||||
{
|
||||
if ( is_visible()==val ) return;
|
||||
if ( val ) m_status = m_status | LCC_DEMO_VISIBLE;
|
||||
else m_status = m_status ^ LCC_DEMO_VISIBLE;
|
||||
}
|
||||
void set_filled(bool val=true)
|
||||
{
|
||||
if ( is_filled()==val ) return;
|
||||
if ( val ) m_status = m_status | LCC_DEMO_FILLED;
|
||||
else m_status = m_status ^ LCC_DEMO_FILLED;
|
||||
}
|
||||
|
||||
void negate_visible()
|
||||
{ set_visible(!is_visible()); }
|
||||
void negate_filled()
|
||||
{ set_filled(!is_filled()); }
|
||||
|
||||
private:
|
||||
CGAL::Color m_color;
|
||||
char m_status;
|
||||
};
|
||||
|
||||
class Myitems
|
||||
{
|
||||
public:
|
||||
|
|
@ -55,7 +119,7 @@ public:
|
|||
typedef CGAL::Dart<3, Refs > Dart;
|
||||
|
||||
typedef CGAL::Cell_attribute_with_point< Refs > Vertex_attrib;
|
||||
typedef CGAL::Cell_attribute< Refs, CGAL::Color > Volume_attrib;
|
||||
typedef CGAL::Cell_attribute< Refs, Volume_info > Volume_attrib;
|
||||
|
||||
typedef CGAL::cpp0x::tuple<Vertex_attrib,void,void,
|
||||
Volume_attrib> Attributes;
|
||||
|
|
@ -78,19 +142,4 @@ struct Scene {
|
|||
LCC* lcc;
|
||||
};
|
||||
|
||||
// Use to define properties on volumes.
|
||||
#define LCC_DEMO_VISIBLE 1 // if not visible => hidden
|
||||
#define LCC_DEMO_FILLED 2 // if not filled, wireframe
|
||||
|
||||
bool isVisibleAndFilled(char property);
|
||||
bool isVisible(char property);
|
||||
bool isFilled(char property);
|
||||
char setVisible(char property);
|
||||
char setHidden(char property);
|
||||
char setFilled(char property);
|
||||
char setWireframe(char property);
|
||||
char setVisibleAndFilled(char property);
|
||||
char negateVisible(char property);
|
||||
char negateFilled(char property);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -230,8 +230,9 @@ namespace CGAL {
|
|||
return samegeometry;
|
||||
}
|
||||
|
||||
/// Sew3 the facets having same geometry.
|
||||
unsigned int sew3_same_facets()
|
||||
/// Sew3 the marked facets having same geometry
|
||||
/// (a facet is considered marked if one of its dart is marked).
|
||||
unsigned int sew3_same_facets(int AMark)
|
||||
{
|
||||
unsigned int res = 0;
|
||||
|
||||
|
|
@ -244,7 +245,7 @@ namespace CGAL {
|
|||
for (typename Dart_range::iterator it(this->darts().begin()),
|
||||
itend(this->darts().end()); it!=itend; ++it )
|
||||
{
|
||||
if ( !this->is_marked(it, mymark) )
|
||||
if ( !this->is_marked(it, mymark) && this->is_marked(it, AMark) )
|
||||
{
|
||||
Point min_point=point(it);
|
||||
Dart_handle min_dart = it;
|
||||
|
|
|
|||
Loading…
Reference in New Issue