diff --git a/MetaMeshPlugin.cc b/MetaMeshPlugin.cc index 93f9ffe658e84050a4183f54e54973ed75dfdbf6..daea02d09d5c57d61e90531b75e38cc66c51b385 100644 --- a/MetaMeshPlugin.cc +++ b/MetaMeshPlugin.cc @@ -8,6 +8,9 @@ #include <QDebug> +/*! + * \brief MetaMeshPlugin::initializePlugin + */ void MetaMeshPlugin::initializePlugin() { widget_ = new MetaMeshToolbox(); @@ -24,8 +27,8 @@ void MetaMeshPlugin::initializePlugin() connect(widget_->button_collapse_, SIGNAL(clicked()), this, SLOT(collapse())); connect(widget_->button_relocate_, SIGNAL(clicked()), this, SLOT(relocate())); connect(widget_->button_remesh_, SIGNAL(clicked()), this, SLOT(remesh())); - connect(widget_->button_insert_, SIGNAL(clicked()), this, SLOT(markmetaV())); - connect(widget_->button_delete_, SIGNAL(clicked()), this, SLOT(markmetaHE())); + connect(widget_->button_dummy1_, SIGNAL(clicked()), this, SLOT(DummySlotFunction1())); + connect(widget_->button_dummy2_, SIGNAL(clicked()), this, SLOT(DummySlotFunction2())); connect(widget_->button_next_, SIGNAL(clicked()), this, SLOT(nxt())); connect(widget_->button_opp_, SIGNAL(clicked()), this, SLOT(opp())); connect(widget_->button_prev_, SIGNAL(clicked()), this, SLOT(prv())); @@ -38,18 +41,20 @@ void MetaMeshPlugin::initializePlugin() printf("Created MetaMesh object\n"); } +/*! + * \brief MetaMeshPlugin::pluginsInitialized + */ void MetaMeshPlugin::pluginsInitialized() { printf("Plugins Initialized\n"); } +/*! + * \brief MetaMeshPlugin::slotObjectUpdated + * \param _identifier + */ void MetaMeshPlugin::slotObjectUpdated(int _identifier) { - /* - qDebug() << "updatedObject"; - qDebug() << "_identifier: " << _identifier << " base_mesh_id_: " << base_mesh_id_ - << " meta_mesh_id_: " << meta_mesh_id_; - */ if (_identifier == meta_mesh_id_ && !selection_mutex_ && widget_->checkbox_copy_markings_->checkState() == Qt::Checked) { selection_mutex_ = true; @@ -58,6 +63,10 @@ void MetaMeshPlugin::slotObjectUpdated(int _identifier) } } +/*! + * \brief MetaMeshPlugin::triangulate triangulates a meta mesh from marked vertices on the currently + * loaded mesh + */ void MetaMeshPlugin::triangulate() { qDebug() << "Triangulate Button pressed"; @@ -98,14 +107,24 @@ void MetaMeshPlugin::triangulate() emit updatedObject(meta_mesh_id_, UPDATE_ALL); } +/*! + * \brief MetaMeshPlugin::randomizetotal randomize an absolute number of vertices + */ void MetaMeshPlugin::randomizetotal() { randomize(Embedding::RandomType::TOTAL); } +/*! + * \brief MetaMeshPlugin::randomizeratio randomize a ratio of vertices + */ void MetaMeshPlugin::randomizeratio() { randomize(Embedding::RandomType::RATIO); } +/*! + * \brief MetaMeshPlugin::randomize randomize meta mesh vertices and triangulate + * \param type + */ void MetaMeshPlugin::randomize(Embedding::RandomType type) { using namespace PluginFunctions; for (auto* o : objects(TARGET_OBJECTS, DATA_TRIANGLE_MESH)) { @@ -129,7 +148,6 @@ void MetaMeshPlugin::randomize(Embedding::RandomType type) { } meta_mesh_->update_normals(); embedding_->GetBaseMesh()->update_normals(); - //meta_mesh_->clear(); emit updatedObject(o->id(), UPDATE_ALL); qDebug() << "Exited InitialTriangulation function"; } @@ -142,6 +160,9 @@ void MetaMeshPlugin::randomize(Embedding::RandomType type) { emit updatedObject(meta_mesh_id_, UPDATE_ALL); } +/*! + * \brief MetaMeshPlugin::test_meta_mesh run selected test + */ void MetaMeshPlugin::test_meta_mesh() { using namespace PluginFunctions; if (embedding_->GetMetaMesh() == nullptr) { @@ -192,6 +213,10 @@ void MetaMeshPlugin::test_meta_mesh() { postoperation(UPDATE_ALL, UPDATE_ALL); } +/*! + * \brief MetaMeshPlugin::retrace retrace the selected meta edges / halfedges. None selected means + * everything will be retraced. + */ void MetaMeshPlugin::retrace() { using namespace PluginFunctions; preoperation(); @@ -213,6 +238,9 @@ void MetaMeshPlugin::retrace() { postoperation(UPDATE_ALL, UPDATE_TOPOLOGY); } +/*! + * \brief MetaMeshPlugin::rotate rotate all selected meta edges and halfedges + */ void MetaMeshPlugin::rotate() { using namespace PluginFunctions; preoperation(); @@ -226,6 +254,9 @@ void MetaMeshPlugin::rotate() { postoperation(UPDATE_ALL, UPDATE_TOPOLOGY); } +/*! + * \brief MetaMeshPlugin::split split faces and edges at selected base vertices + */ void MetaMeshPlugin::split() { using namespace PluginFunctions; preoperation(); @@ -240,6 +271,9 @@ void MetaMeshPlugin::split() { postoperation(UPDATE_TOPOLOGY, UPDATE_TOPOLOGY); } +/*! + * \brief MetaMeshPlugin::collapse collapse all selected meta edges and halfedges + */ void MetaMeshPlugin::collapse() { using namespace PluginFunctions; preoperation(); @@ -253,6 +287,9 @@ void MetaMeshPlugin::collapse() { postoperation(UPDATE_TOPOLOGY, UPDATE_TOPOLOGY); } +/*! + * \brief MetaMeshPlugin::relocate relocate selected meta vertex to selected non-meta vertex + */ void MetaMeshPlugin::relocate() { using namespace PluginFunctions; preoperation(); @@ -282,6 +319,9 @@ void MetaMeshPlugin::relocate() { postoperation(UPDATE_TOPOLOGY, UPDATE_TOPOLOGY); } +/*! + * \brief MetaMeshPlugin::remesh calls IsotropicRemesher::Remesh with menu selected parameters + */ void MetaMeshPlugin::remesh() { using namespace PluginFunctions; preoperation(); @@ -316,6 +356,9 @@ void MetaMeshPlugin::remesh() { postoperation(UPDATE_TOPOLOGY, UPDATE_TOPOLOGY); } +/*! + * \brief MetaMeshPlugin::calculateoffset calculate an offset to separate base and meta mesh. + */ void MetaMeshPlugin::calculateoffset() { const double inf = std::numeric_limits<double>::infinity(); ACG::Vec3d minCorner = {+inf, +inf, +inf}; @@ -328,6 +371,9 @@ void MetaMeshPlugin::calculateoffset() { meta_mesh_visualization_offset_[0] = (maxCorner[0]-minCorner[0])*1.3; } +/*! + * \brief MetaMeshPlugin::addoffset move the meta mesh away from the base mesh + */ void MetaMeshPlugin::addoffset() { for (auto mvh : embedding_->GetMetaMesh()->vertices()) { embedding_->GetMetaMesh()->point(mvh) += meta_mesh_visualization_offset_/2.0; @@ -337,6 +383,9 @@ void MetaMeshPlugin::addoffset() { } } +/*! + * \brief MetaMeshPlugin::removeoffset move the meta mesh back to the base mesh + */ void MetaMeshPlugin::removeoffset() { for (auto mvh : embedding_->GetMetaMesh()->vertices()) { embedding_->GetMetaMesh()->point(mvh) -= meta_mesh_visualization_offset_/2.0; @@ -346,21 +395,15 @@ void MetaMeshPlugin::removeoffset() { } } +/*! + * \brief MetaMeshPlugin::copyselection copy selected elements from the meta mesh + * into the base mesh (select the corresponding elements) + */ void MetaMeshPlugin::copyselection() { if (!metameshsanitychecks(false)) return; using namespace PluginFunctions; removeoffset(); - /* - for (auto bvh : embedding_->GetBaseMesh()->vertices()) { - embedding_->GetBaseMesh()->status(bvh).set_selected(false); - } - for (auto mvh : embedding_->GetMetaMesh()->vertices()) { - embedding_->GetBaseMesh()->status( - embedding_->GetMetaMesh()->property(embedding_->mv_connection_, mvh)).set_selected( - embedding_->GetMetaMesh()->status(mvh).selected()); - } - */ for (auto bheh : embedding_->GetBaseMesh()->halfedges()) { embedding_->GetBaseMesh()->status(bheh).set_selected(false); } @@ -382,28 +425,14 @@ void MetaMeshPlugin::copyselection() { auto bheh = embedding_->GetMetaMesh()->property(embedding_->mhe_connection_, embedding_->GetMetaMesh()->halfedge_handle(meh, 0)); auto beh = embedding_->GetBaseMesh()->edge_handle(bheh); - //*/ embedding_->GetBaseMesh()->status(beh).set_selected( embedding_->GetMetaMesh()->status(meh).selected()); - /*/ - embedding_->GetBaseMesh()->status(bheh).set_selected( - embedding_->GetMetaMesh()->status(meh).selected()); - embedding_->GetBaseMesh()->status( - embedding_->GetBaseMesh()->opposite_halfedge_handle(bheh)).set_selected( - embedding_->GetMetaMesh()->status(meh).selected()); - /*/ - while (embedding_->GetBaseMesh()->status(/*bheh*/beh).selected() && + while (embedding_->GetBaseMesh()->status(beh).selected() && embedding_->GetBaseMesh()->property(embedding_->next_heh_, bheh) != OpenMesh::PolyConnectivity::InvalidHalfedgeHandle) { bheh = embedding_->GetBaseMesh()->property(embedding_->next_heh_, bheh); auto beh = embedding_->GetBaseMesh()->edge_handle(bheh); - //*/ embedding_->GetBaseMesh()->status(beh).set_selected(true); - /*/ - embedding_->GetBaseMesh()->status(bheh).set_selected(true); - embedding_->GetBaseMesh()->status(embedding_->GetBaseMesh()-> - opposite_halfedge_handle(bheh)).set_selected(true); - /*/ } } @@ -412,10 +441,13 @@ void MetaMeshPlugin::copyselection() { addoffset(); emit updatedObject(base_mesh_id_, UPDATE_SELECTION); UpdateMetaMesh(UPDATE_SELECTION); - //emit updateView(); } -void MetaMeshPlugin::markmetaV() { +/*! + * \brief MetaMeshPlugin::DummySlotFunction1 function for the first dummy button, + * used to test various things on the mesh + */ +void MetaMeshPlugin::DummySlotFunction1() { using namespace PluginFunctions; for (auto bheh : embedding_->GetBaseMesh()->halfedges()) { if (embedding_->GetMetaMesh()->is_valid_handle( @@ -424,89 +456,28 @@ void MetaMeshPlugin::markmetaV() { embedding_->GetBaseMesh()->status(bheh).set_selected(true); } } - /* - for (auto* o : objects(TARGET_OBJECTS, DATA_POLY_MESH)) { - auto testmesh = polyMesh(o->id()); - for (auto heh : testmesh->halfedges()) { - testmesh->status(heh).set_selected(true); - if (testmesh->is_boundary(heh)) { - qDebug() << "Found boundary " << heh.idx(); - testmesh->status(heh).set_selected(true); - } - } - emit updatedObject(o->id(), UPDATE_SELECTION); - } - for (auto* o : objects(TARGET_OBJECTS, DATA_TRIANGLE_MESH)) { - auto testmesh = triMesh(o->id()); - for (auto heh : testmesh->halfedges()) { - testmesh->status(heh).set_selected(true); - if (testmesh->is_boundary(heh)) { - qDebug() << "Found boundary " << heh.idx(); - testmesh->status(heh).set_selected(true); - } - } - emit updatedObject(o->id(), UPDATE_SELECTION); - } - return; - */ - /* - for (auto bheh : embedding_->GetBaseMesh()->halfedges()) { - if (embedding_->GetBaseMesh()->is_boundary(bheh)) { - embedding_->GetBaseMesh()->status(bheh).set_selected(true); - } - } - */ - /* - for (auto bheh : embedding_->GetBaseMesh()->halfedges()) { - double w = embedding_->GetBaseMesh()->property(embedding_->halfedge_weight_, bheh); - if (w > 1.0) { - embedding_->GetBaseMesh()->status(bheh).set_selected(true); - } - if (w > 2.0) { - embedding_->GetBaseMesh()->status(embedding_->GetBaseMesh()->edge_handle(bheh)) - .set_selected(true); - } - } - */ - //emit updatedObject(meta_mesh_id_, UPDATE_SELECTION); emit updatedObject(base_mesh_id_, UPDATE_SELECTION); } -void MetaMeshPlugin::markmetaHE() { +/*! + * \brief MetaMeshPlugin::DummySlotFunction2 function for the first dummy button, + * used to test various things on the mesh + */ +void MetaMeshPlugin::DummySlotFunction2() { using namespace PluginFunctions; for (auto mheh : meta_mesh_->halfedges()) { if (meta_mesh_->is_boundary(mheh)) { meta_mesh_->status(mheh).set_selected(true); } } - /* - for (auto mheh : embedding_->GetMetaMesh()->halfedges()) { - if (embedding_->GetMetaMesh()->is_valid_handle(mheh) - && !embedding_->GetMetaMesh()->status(mheh).deleted() - && embedding_->GetMetaMesh()->is_boundary(mheh)) { - embedding_->GetMetaMesh()->status(mheh).set_selected(true); - } - } - */ - /* - for (auto bvh : embedding_->GetBaseMesh()->vertices()) { - auto mvh = embedding_->GetBaseMesh()->property(embedding_->bv_connection_, bvh); - if (embedding_->GetMetaMesh()->is_valid_handle(mvh)) { - embedding_->GetBaseMesh()->status(bvh).set_selected(true); - } - } - emit updatedObject(base_mesh_id_, UPDATE_SELECTION); - for (auto bheh : embedding_->GetBaseMesh()->halfedges()) { - auto mheh = embedding_->GetBaseMesh()->property(embedding_->bhe_connection_, bheh); - if (embedding_->GetMetaMesh()->is_valid_handle(mheh)) { - embedding_->GetBaseMesh()->status(bheh).set_selected(true); - } - } - */ emit updatedObject(meta_mesh_id_, UPDATE_SELECTION); emit updatedObject(base_mesh_id_, UPDATE_SELECTION); } +/*! + * \brief MetaMeshPlugin::nxt move all selections on meta halfedges forward to their + * next_halfedge_handle + */ void MetaMeshPlugin::nxt() { if (!metameshsanitychecks()) return; @@ -544,6 +515,10 @@ void MetaMeshPlugin::nxt() { UpdateMetaMesh(UPDATE_SELECTION_HALFEDGES); } +/*! + * \brief MetaMeshPlugin::opp move all selections of meta halfedges to + * their opposite_halfedge_handle + */ void MetaMeshPlugin::opp() { if (!metameshsanitychecks()) return; @@ -581,6 +556,10 @@ void MetaMeshPlugin::opp() { UpdateMetaMesh(UPDATE_SELECTION_HALFEDGES); } +/*! + * \brief MetaMeshPlugin::prv move all halfedge selections on the meta mesh + * to their prev_halfedge_handle + */ void MetaMeshPlugin::prv() { if (!metameshsanitychecks()) return; @@ -618,6 +597,12 @@ void MetaMeshPlugin::prv() { UpdateMetaMesh(UPDATE_SELECTION_HALFEDGES); } +/*! + * \brief MetaMeshPlugin::metameshsanitychecks checks a few conditions that make + * visualizing the meta_mesh_ unsafe (crashes the GPUoptimizer or other problems) + * \param verbose + * \return false if the meta mesh should not be virualized + */ bool MetaMeshPlugin::metameshsanitychecks(bool verbose) { if (meta_mesh_ == nullptr) { if (verbose) @@ -638,24 +623,39 @@ bool MetaMeshPlugin::metameshsanitychecks(bool verbose) { return true; } +/*! + * \brief MetaMeshPlugin::MetaMeshUpdateNormals + */ void MetaMeshPlugin::MetaMeshUpdateNormals() { if (metameshsanitychecks(false)) { meta_mesh_->update_normals(); } } +/*! + * \brief MetaMeshPlugin::EmbeddingGarbageCollection + */ void MetaMeshPlugin::EmbeddingGarbageCollection() { if (metameshsanitychecks(false)) { embedding_->MetaGarbageCollection(); } } +/*! + * \brief MetaMeshPlugin::UpdateMetaMesh + * \param _type + */ void MetaMeshPlugin::UpdateMetaMesh(const UpdateType &_type) { if (metameshsanitychecks(false)) { emit updatedObject(meta_mesh_id_, _type); } } +/*! + * \brief MetaMeshPlugin::GetHalfedgeSelection + * \return a list of selected meta halfedges (when they or their corresponding base + * halfedges are selected) + */ std::queue<OpenMesh::HalfedgeHandle> MetaMeshPlugin::GetHalfedgeSelection() { std::queue<OpenMesh::HalfedgeHandle> output; if (widget_->checkbox_copy_markings_->checkState() == Qt::Checked) { @@ -703,6 +703,14 @@ std::queue<OpenMesh::HalfedgeHandle> MetaMeshPlugin::GetHalfedgeSelection() { return output; } +/*! + * \brief MetaMeshPlugin::screenshot updates view and takes(saves) a screenshot + * this function will be handed over to IsotropicRemesher + * \param name filename + * \param dir directory + * \param width dimension X + * \param height dimension Y + */ void MetaMeshPlugin::screenshot(const QString& name, const QString& dir, const int& width, const int& height) { //qDebug() << "screenshotfunction"; @@ -728,12 +736,23 @@ void MetaMeshPlugin::screenshot(const QString& name, const QString& dir, removeoffset(); } -// Functions to be called before an operation changing the mesh +/*! + * \brief MetaMeshPlugin::preoperation functions to be called before operations on the + * mesh are performed. Currently only removes the meta mesh offset, but this wrapper + * is here for consistency with postoperation() + */ void MetaMeshPlugin::preoperation() { removeoffset(); } -// Functions to be called after an operation changing the mesh +/*! + * \brief MetaMeshPlugin::postoperation functions to be called after operations on the + * mesh are performed such as garbage collection, updating normals, adding an offset + * to the meta mesh, colorizing it etc. + * \param typem meta mesh update type eg. UPDATE_SELECTION + * \param typeb base mesh update type eg. UPDATE_TOPOLOGY + * \param verbose + */ void MetaMeshPlugin::postoperation(const UpdateType &typem, const UpdateType &typeb, bool verbose) { if (embedding_->ErrStatus() diff --git a/MetaMeshPlugin.hh b/MetaMeshPlugin.hh index 440a564451979a7f76602914dc97d59efbbfd405..3d109145648b099423ce61be515d75719f63b826 100644 --- a/MetaMeshPlugin.hh +++ b/MetaMeshPlugin.hh @@ -57,8 +57,8 @@ public slots: void remesh(); void togglecopy(); void copyselection(); - void markmetaV(); - void markmetaHE(); + void DummySlotFunction1(); + void DummySlotFunction2(); void nxt(); void opp(); void prv(); diff --git a/MetaMeshToolbox.cc b/MetaMeshToolbox.cc index e5d78a830053bdb6bf8142409e865cbf372f4d0c..0331249a350f9f0aa01263eb729c559fa11c6bdc 100644 --- a/MetaMeshToolbox.cc +++ b/MetaMeshToolbox.cc @@ -43,8 +43,8 @@ MetaMeshToolbox::MetaMeshToolbox(QWidget* parent) : QWidget(parent) button_split_ = new QPushButton("Split"); button_collapse_ = new QPushButton("Collapse"); button_relocate_ = new QPushButton("Relocate"); - button_insert_ = new QPushButton("Insert"); - button_delete_ = new QPushButton("Delete"); + button_dummy1_ = new QPushButton("Insert"); + button_dummy2_ = new QPushButton("Delete"); button_next_ = new QPushButton("nxt"); button_opp_ = new QPushButton("opp"); button_prev_ = new QPushButton("prv"); @@ -89,8 +89,8 @@ MetaMeshToolbox::MetaMeshToolbox(QWidget* parent) : QWidget(parent) layout->addWidget(button_split_, 7, 3, 1, 3); layout->addWidget(button_collapse_, 8, 0, 1, 3); layout->addWidget(button_relocate_, 8, 3, 1, 3); - layout->addWidget(button_insert_, 9, 0, 1, 3); - layout->addWidget(button_delete_, 9, 3, 1, 3); + layout->addWidget(button_dummy1_, 9, 0, 1, 3); + layout->addWidget(button_dummy2_, 9, 3, 1, 3); layout->addWidget(button_next_, 10, 0, 1, 2); layout->addWidget(button_opp_, 10, 2, 1, 2); layout->addWidget(button_prev_, 10, 4, 1, 2); diff --git a/MetaMeshToolbox.hh b/MetaMeshToolbox.hh index 0dbde2ce99bb203b2b7042da4feea78e36e97e90..ebe4ff06a974e5dc93a0e535918bdf871ea4f554 100644 --- a/MetaMeshToolbox.hh +++ b/MetaMeshToolbox.hh @@ -35,8 +35,8 @@ public: QPushButton* button_collapse_; QPushButton* button_relocate_; QPushButton* button_remesh_; - QPushButton* button_insert_; - QPushButton* button_delete_; + QPushButton* button_dummy1_; + QPushButton* button_dummy2_; QPushButton* button_next_; QPushButton* button_opp_; QPushButton* button_prev_;