mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-16 17:44:36 +00:00
- WARNING! huge commit
- completely changed the deallocation process of the default per mesh decorators - added new interface virtual function for the edit plugin informing MeshLab on the best way to render the meshes contained into the document when the edit plugin is activated
This commit is contained in:
parent
3c94507387
commit
63a793c66a
@ -557,6 +557,8 @@ public:
|
||||
//should return a sentence describing what the editing tool does
|
||||
static const QString Info();
|
||||
|
||||
virtual void suggestedRenderingData(MeshModel &/*m*/, MLRenderingData& /*dt*/) {}
|
||||
|
||||
// Called when the user press the first time the button
|
||||
virtual bool StartEdit(MeshModel &/*m*/, GLArea * /*parent*/,MLSceneGLSharedDataContext* /*cont*/){return true;}
|
||||
virtual bool StartEdit(MeshDocument &md, GLArea *parent,MLSceneGLSharedDataContext* cont)
|
||||
|
||||
@ -760,6 +760,7 @@ void MLPoliciesStandAloneFunctions::suggestedDefaultPerViewGLOptions( MLPerViewG
|
||||
tmp._perwire_fixed_color = vcg::Color4b(vcg::Color4b::DarkGray);
|
||||
tmp._persolid_fixed_color = vcg::Color4b(vcg::Color4b::LightGray);
|
||||
tmp._sel_enabled = true;
|
||||
tmp._peredge_extra_enabled = true;
|
||||
}
|
||||
|
||||
//void MLPoliciesStandAloneFunctions::bestPrimitiveModalityMaskAfterUpdate( MeshModel* meshmodel,int meshmodelmask,const MLRenderingData::PRIMITIVE_MODALITY_MASK& inputpm,MLRenderingData::PRIMITIVE_MODALITY_MASK& outputpm )
|
||||
|
||||
@ -469,7 +469,7 @@ void GLArea::paintEvent(QPaintEvent* /*event*/)
|
||||
iRenderer->Render(currentShader, *this->md(), dt, this);
|
||||
|
||||
|
||||
MLDefaultMeshDecorators defdec;
|
||||
MLDefaultMeshDecorators defdec(mw());
|
||||
|
||||
foreach(MeshModel * mp, this->md()->meshList)
|
||||
{
|
||||
@ -532,7 +532,7 @@ void GLArea::paintEvent(QPaintEvent* /*event*/)
|
||||
decorInterface->decorateMesh(*it,*mp,this->glas.currentGlobalParamSet,this,&painter,md()->Log);
|
||||
}
|
||||
|
||||
MLDefaultMeshDecorators defdec;
|
||||
MLDefaultMeshDecorators defdec(mw());
|
||||
datacont->getRenderInfoPerMeshView(mp->id(),context(),curr);
|
||||
defdec.decorateMesh(*mp,curr,&painter,md()->Log);
|
||||
}
|
||||
@ -613,8 +613,8 @@ void GLArea::paintEvent(QPaintEvent* /*event*/)
|
||||
if (takeSnapTile) pasteTile();
|
||||
|
||||
// Finally display HELP if requested
|
||||
if (isHelpVisible()) displayHelp();
|
||||
glFinish();
|
||||
if (isHelpVisible())
|
||||
displayHelp();
|
||||
|
||||
// Draw the log area background
|
||||
// on the bottom of the glArea
|
||||
@ -644,6 +644,8 @@ void GLArea::paintEvent(QPaintEvent* /*event*/)
|
||||
painter.endNativePainting();
|
||||
//glFinish();
|
||||
//doneCurrent();
|
||||
glFlush();
|
||||
glFinish();
|
||||
}
|
||||
|
||||
void GLArea::displayMatrix(QPainter *painter, QRect areaRect)
|
||||
@ -1008,7 +1010,7 @@ void GLArea::updateAllPerMeshDecorators()
|
||||
if (shared == NULL)
|
||||
return;
|
||||
|
||||
MLDefaultMeshDecorators defdec;
|
||||
MLDefaultMeshDecorators defdec(mw());
|
||||
for(MeshModel* mm = mdoc->nextMesh();mm != NULL;mm = mdoc->nextMesh(mm))
|
||||
{
|
||||
MLRenderingData dt;
|
||||
@ -1021,13 +1023,43 @@ void GLArea::updateAllPerMeshDecorators()
|
||||
|
||||
void GLArea::setCurrentEditAction(QAction *editAction)
|
||||
{
|
||||
if ((parentmultiview == NULL) || (parentmultiview->sharedDataContext() == NULL))
|
||||
return;
|
||||
|
||||
makeCurrent();
|
||||
assert(editAction);
|
||||
currentEditor = editAction;
|
||||
|
||||
iEdit = actionToMeshEditMap.value(currentEditor);
|
||||
assert(iEdit);
|
||||
if (iEdit == NULL)
|
||||
return;
|
||||
|
||||
lastModelEdited = this->md()->mm();
|
||||
|
||||
MLRenderingData dt;
|
||||
if (iEdit->isSingleMeshEdit())
|
||||
{
|
||||
if (md()->mm() != NULL)
|
||||
{
|
||||
parentmultiview->sharedDataContext()->getRenderInfoPerMeshView(md()->mm()->id(), context(), dt);
|
||||
iEdit->suggestedRenderingData(*(md()->mm()), dt);
|
||||
parentmultiview->sharedDataContext()->setRenderingDataPerMeshView(md()->mm()->id(), context(), dt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach(MeshModel* mm, md()->meshList)
|
||||
{
|
||||
if (mm != NULL)
|
||||
{
|
||||
parentmultiview->sharedDataContext()->getRenderInfoPerMeshView(mm->id(), context(), dt);
|
||||
iEdit->suggestedRenderingData(*(mm), dt);
|
||||
parentmultiview->sharedDataContext()->setRenderingDataPerMeshView(mm->id(), context(), dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mw() != NULL)
|
||||
mw()->updateLayerTable();
|
||||
if (!iEdit->StartEdit(*this->md(), this,parentmultiview->sharedDataContext()))
|
||||
{
|
||||
//iEdit->EndEdit(*(this->md()->mm()), this);
|
||||
@ -1036,7 +1068,7 @@ void GLArea::setCurrentEditAction(QAction *editAction)
|
||||
else
|
||||
{
|
||||
Logf(GLLogStream::SYSTEM,"Started Mode %s", qPrintable(currentEditor->text()));
|
||||
if(mm()!=NULL)
|
||||
if(mm()!=NULL)
|
||||
mm()->meshModified() = true;
|
||||
else assert(!iEdit->isSingleMeshEdit());
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
#include "snapshotsetting.h"
|
||||
#include "multiViewer_Container.h"
|
||||
#include "ml_selection_buffers.h"
|
||||
#include "ml_default_decorators.h"
|
||||
|
||||
#define SSHOT_BYTES_PER_PIXEL 4
|
||||
|
||||
@ -82,7 +83,7 @@ public:
|
||||
MeshModel* mm = md()->getMesh(meshid);
|
||||
if (mm != NULL)
|
||||
{
|
||||
CMeshO::PerMeshAttributeHandle< MLSelectionBuffers* > selbufhand = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<MLSelectionBuffers* >(mm->cm, "SelectionBuffers");
|
||||
CMeshO::PerMeshAttributeHandle< MLSelectionBuffers* > selbufhand = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<MLSelectionBuffers* >(mm->cm, MLDefaultMeshDecorators::selectionAttName());
|
||||
if ((selbufhand() != NULL) && (facesel))
|
||||
selbufhand()->updateBuffer(MLSelectionBuffers::ML_PERFACE_SEL);
|
||||
|
||||
@ -92,6 +93,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/*WARNING!!!!! HORRIBLE THING!!!!! Added just to avoid to include the multiViewer_container.cpp file in a MeshLab plugins project in case it needs to update all the GLArea and not just the one passed as parameter*/
|
||||
|
||||
void updateAllSiblingsGLAreas()
|
||||
{
|
||||
if (mvc() == NULL)
|
||||
return;
|
||||
foreach(GLArea* viewer, mvc()->viewerList)
|
||||
{
|
||||
if (viewer != NULL)
|
||||
viewer->update();
|
||||
}
|
||||
}
|
||||
|
||||
void requestForRenderingAttsUpdate( int meshid,MLRenderingData::ATT_NAMES attname )
|
||||
{
|
||||
if (parentmultiview != NULL)
|
||||
|
||||
@ -843,6 +843,7 @@ MeshTreeWidgetItem::MeshTreeWidgetItem(MeshModel* meshmodel,QTreeWidget* tree,ML
|
||||
tree->setItemWidget(this,3,_rendertoolbar);
|
||||
|
||||
setText(2, meshName);
|
||||
setToolTip(2, inf.absoluteFilePath());
|
||||
_meshid = meshmodel->id();
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,6 +122,7 @@ public slots:
|
||||
bool openProject(QString fileName=QString());
|
||||
bool appendProject(QString fileName=QString());
|
||||
void updateCustomSettings();
|
||||
void updateLayerDialog();
|
||||
|
||||
private slots:
|
||||
|
||||
@ -146,6 +147,8 @@ public:
|
||||
void updateRenderingDataAccordingToActions(int meshid,const QList<MLRenderingAction*>& acts);
|
||||
void updateRenderingDataAccordingToAction( int meshid,MLRenderingAction* act);
|
||||
|
||||
unsigned int viewsRequiringRenderingActions(int meshid,MLRenderingAction* act);
|
||||
|
||||
void updateSharedContextDataAfterFilterExecution(int postcondmask,int fclasses,bool& newmeshcreated);
|
||||
private slots:
|
||||
//////////// Slot Menu File //////////////////////
|
||||
@ -188,7 +191,6 @@ private slots:
|
||||
void updateStdDialog();
|
||||
void updateXMLStdDialog();
|
||||
void enableDocumentSensibleActionsContainer(const bool enable);
|
||||
void updateLayerDialog();
|
||||
//void updatePerViewApplicationStatus();
|
||||
void setSplit(QAction *qa);
|
||||
void setUnsplit();
|
||||
|
||||
@ -3384,7 +3384,7 @@ void MainWindow::updateRenderingDataAccordingToActions(int meshid,const QList<ML
|
||||
MeshModel* mm = meshDoc()->getMesh(meshid);
|
||||
if (mm != NULL)
|
||||
{
|
||||
MLDefaultMeshDecorators dec;
|
||||
MLDefaultMeshDecorators dec(this);
|
||||
dec.updateMeshDecorationData(*mm,olddt,dt);
|
||||
}
|
||||
GLA()->update();
|
||||
@ -3403,8 +3403,29 @@ void MainWindow::updateRenderingDataAccordingToAction( int meshid,MLRenderingAct
|
||||
MeshModel* mm = meshDoc()->getMesh(meshid);
|
||||
if (mm != NULL)
|
||||
{
|
||||
MLDefaultMeshDecorators dec;
|
||||
MLDefaultMeshDecorators dec(this);
|
||||
dec.updateMeshDecorationData(*mm,olddt,dt);
|
||||
}
|
||||
GLA()->update();
|
||||
}
|
||||
|
||||
unsigned int MainWindow::viewsRequiringRenderingActions(int meshid, MLRenderingAction* act)
|
||||
{
|
||||
unsigned int res = 0;
|
||||
MultiViewer_Container* cont = currentViewContainer();
|
||||
if (cont != NULL)
|
||||
{
|
||||
MLSceneGLSharedDataContext* share = cont->sharedDataContext();
|
||||
if (share != NULL)
|
||||
{
|
||||
foreach(GLArea* area,cont->viewerList)
|
||||
{
|
||||
MLRenderingData dt;
|
||||
share->getRenderInfoPerMeshView(meshid, area->context(), dt);
|
||||
if (act->isRenderingDataEnabled(dt))
|
||||
++res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -27,8 +27,15 @@
|
||||
#include <wrap/gui/coordinateframe.h>
|
||||
#include <wrap/qt/gl_label.h>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ml_selection_buffers.h"
|
||||
|
||||
MLDefaultMeshDecorators::MLDefaultMeshDecorators(MainWindow* mw)
|
||||
:_mw(mw)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool MLDefaultMeshDecorators::updateMeshDecorationData( MeshModel& mesh,const MLRenderingData& previousdata,const MLRenderingData& currentdata )
|
||||
{
|
||||
MLPerViewGLOptions oldopts;
|
||||
@ -38,25 +45,51 @@ bool MLDefaultMeshDecorators::updateMeshDecorationData( MeshModel& mesh,const ML
|
||||
if ((!oldvalid) || (!currentvalid))
|
||||
return false;
|
||||
|
||||
/*the boolean conditions should make the following code lines mutually exclusive.....hopefully*/
|
||||
initBoundaryDecoratorData(mesh,currentopts._peredge_edgeboundary_enabled && !oldopts._peredge_edgeboundary_enabled,
|
||||
currentopts._peredge_faceboundary_enabled && !oldopts._peredge_faceboundary_enabled);
|
||||
cleanBoundaryDecoratorData(mesh,!currentopts._peredge_edgeboundary_enabled && oldopts._peredge_edgeboundary_enabled,
|
||||
!currentopts._peredge_faceboundary_enabled && oldopts._peredge_faceboundary_enabled);
|
||||
/*bool extraswitchon = currentopts._peredge_extra_enabled && !oldopts._peredge_extra_enabled;
|
||||
bool extraswitchoff = !currentopts._peredge_extra_enabled && oldopts._peredge_extra_enabled;
|
||||
|
||||
//the boolean conditions should make the following code lines mutually exclusive.....hopefully
|
||||
initBoundaryDecoratorData(mesh,(extraswitchon || (currentopts._peredge_edgeboundary_enabled && !oldopts._peredge_edgeboundary_enabled)),
|
||||
(extraswitchon || (currentopts._peredge_faceboundary_enabled && !oldopts._peredge_faceboundary_enabled)));
|
||||
cleanBoundaryDecoratorData(mesh,(extraswitchoff || (!currentopts._peredge_edgeboundary_enabled && oldopts._peredge_edgeboundary_enabled)),
|
||||
(extraswitchoff || (!currentopts._peredge_faceboundary_enabled && oldopts._peredge_faceboundary_enabled)));
|
||||
|
||||
|
||||
if (currentopts._peredge_edgemanifold_enabled && !oldopts._peredge_edgemanifold_enabled)
|
||||
if (extraswitchon || (currentopts._peredge_edgemanifold_enabled && !oldopts._peredge_edgemanifold_enabled))
|
||||
initNonManifEdgeDecoratorData(mesh);
|
||||
else
|
||||
if (!currentopts._peredge_edgemanifold_enabled && oldopts._peredge_edgemanifold_enabled)
|
||||
if (extraswitchoff || (!currentopts._peredge_edgemanifold_enabled && oldopts._peredge_edgemanifold_enabled))
|
||||
cleanNonManifEdgeDecoratorData(mesh);
|
||||
|
||||
if (currentopts._peredge_text_boundary_enabled && !oldopts._peredge_text_boundary_enabled)
|
||||
if (extraswitchon || (currentopts._peredge_text_boundary_enabled && !oldopts._peredge_text_boundary_enabled))
|
||||
initBoundaryTextDecoratorData(mesh);
|
||||
else
|
||||
if (!currentopts._peredge_text_boundary_enabled && oldopts._peredge_text_boundary_enabled)
|
||||
cleanBoundaryTextDecoratorData(mesh);
|
||||
if (extraswitchoff || (!currentopts._peredge_text_boundary_enabled && oldopts._peredge_text_boundary_enabled))
|
||||
cleanBoundaryTextDecoratorData(mesh);*/
|
||||
|
||||
initBoundaryDecoratorData(mesh,currentopts._peredge_edgeboundary_enabled && !oldopts._peredge_edgeboundary_enabled,
|
||||
currentopts._peredge_faceboundary_enabled && !oldopts._peredge_faceboundary_enabled);
|
||||
cleanBoundaryDecoratorData(mesh,!currentopts._peredge_edgeboundary_enabled && oldopts._peredge_edgeboundary_enabled,
|
||||
!currentopts._peredge_faceboundary_enabled && oldopts._peredge_faceboundary_enabled);
|
||||
|
||||
|
||||
if (currentopts._peredge_edgemanifold_enabled && !oldopts._peredge_edgemanifold_enabled)
|
||||
initNonManifEdgeDecoratorData(mesh);
|
||||
else
|
||||
if (!currentopts._peredge_edgemanifold_enabled && oldopts._peredge_edgemanifold_enabled)
|
||||
cleanNonManifEdgeDecoratorData(mesh);
|
||||
|
||||
if (currentopts._peredge_vertmanifold_enabled && !oldopts._peredge_vertmanifold_enabled)
|
||||
initNonManifVertDecoratorData(mesh);
|
||||
else
|
||||
if (!currentopts._peredge_vertmanifold_enabled && oldopts._peredge_vertmanifold_enabled)
|
||||
cleanNonManifVertDecoratorData(mesh);
|
||||
|
||||
if (currentopts._peredge_text_boundary_enabled && !oldopts._peredge_text_boundary_enabled)
|
||||
initBoundaryTextDecoratorData(mesh);
|
||||
else
|
||||
if (!currentopts._peredge_text_boundary_enabled && oldopts._peredge_text_boundary_enabled)
|
||||
cleanBoundaryTextDecoratorData(mesh);
|
||||
|
||||
initSelectionDecoratorData(mesh, currentopts._vertex_sel && !oldopts._vertex_sel, currentopts._face_sel && !oldopts._face_sel);
|
||||
cleanSelectionDecoratorData(mesh,!currentopts._vertex_sel && oldopts._vertex_sel, !currentopts._face_sel && oldopts._face_sel);
|
||||
@ -71,15 +104,19 @@ bool MLDefaultMeshDecorators::initMeshDecorationData( MeshModel& m,const MLRende
|
||||
if (!valid)
|
||||
return false;
|
||||
|
||||
initBoundaryDecoratorData(m,opts._peredge_edgeboundary_enabled,opts._peredge_faceboundary_enabled);
|
||||
//if (opts._peredge_extra_enabled)
|
||||
//{
|
||||
initBoundaryDecoratorData(m, opts._peredge_edgeboundary_enabled, opts._peredge_faceboundary_enabled);
|
||||
|
||||
if (opts._peredge_edgemanifold_enabled)
|
||||
initNonManifEdgeDecoratorData(m);
|
||||
if (opts._peredge_edgemanifold_enabled)
|
||||
initNonManifEdgeDecoratorData(m);
|
||||
|
||||
if (opts._peredge_text_boundary_enabled)
|
||||
initBoundaryTextDecoratorData(m);
|
||||
|
||||
initSelectionDecoratorData(m,opts._vertex_sel,opts._face_sel);
|
||||
if (opts._peredge_text_boundary_enabled)
|
||||
initBoundaryTextDecoratorData(m);
|
||||
//}
|
||||
|
||||
initSelectionDecoratorData(m, opts._vertex_sel, opts._face_sel);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -98,7 +135,8 @@ void MLDefaultMeshDecorators::decorateMesh( MeshModel & m,const MLRenderingData&
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > bvH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<std::vector<PointPC> >(m.cm,boundaryVertAttName());
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > beH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<std::vector<PointPC> >(m.cm,boundaryEdgeAttName());
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > bfH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<std::vector<PointPC> >(m.cm,boundaryFaceAttName());
|
||||
drawLineVector(beH());
|
||||
if (opts._peredge_edgeboundary_enabled)
|
||||
drawLineVector(beH());
|
||||
if(opts._peredge_faceboundary_enabled)
|
||||
drawTriVector(bfH());
|
||||
drawDotVector(bvH(),5);
|
||||
@ -127,13 +165,13 @@ void MLDefaultMeshDecorators::decorateMesh( MeshModel & m,const MLRenderingData&
|
||||
if (opts._peredge_vertmanifold_enabled)
|
||||
{
|
||||
// Note the standard way for adding extra per-mesh data using the per-mesh attributes.
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > vvH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<std::vector<PointPC> >(m.cm,"NonManifVertVertVector");
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > tvH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<std::vector<PointPC> >(m.cm,"NonManifVertTriVector");
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > vvH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<std::vector<PointPC> >(m.cm,nonManifVertAttName());
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > tvH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<std::vector<PointPC> >(m.cm,nonManifVertFaceAttName());
|
||||
drawDotVector(vvH());
|
||||
drawTriVector(tvH());
|
||||
|
||||
QString inf;
|
||||
inf += "<b>" + QString::number(vvH().size()) + " </b> non manifold vertices<br><b>" + QString::number(tvH().size()) + "</b> faces over non manifold edges";
|
||||
inf += "<b>" + QString::number(vvH().size()) + " </b> non manifold vertices<br><b>" + QString::number(tvH().size() / 3) + "</b> faces over non manifold edges";
|
||||
log.RealTimeLog("Non Manifold Vertices",m.shortName(),inf);
|
||||
}
|
||||
|
||||
@ -199,7 +237,6 @@ void MLDefaultMeshDecorators::decorateMesh( MeshModel & m,const MLRenderingData&
|
||||
drawQuotedBox(m,painter,qf);
|
||||
}
|
||||
}
|
||||
|
||||
glFinish();
|
||||
}
|
||||
|
||||
@ -453,6 +490,9 @@ bool MLDefaultMeshDecorators::cleanMeshDecorationData( MeshModel& mesh,const MLR
|
||||
|
||||
if (opts._peredge_text_boundary_enabled)
|
||||
cleanBoundaryTextDecoratorData(mesh);
|
||||
|
||||
if (opts._vertex_sel || opts._face_sel)
|
||||
cleanSelectionDecoratorData(mesh, !opts._vertex_sel, !opts._face_sel);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -463,12 +503,18 @@ void MLDefaultMeshDecorators::initBoundaryDecoratorData( MeshModel& m,bool edgeb
|
||||
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > bvH;
|
||||
bvH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm,boundaryVertAttName());
|
||||
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > beH;
|
||||
if (edgeboundary)
|
||||
beH= vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm,boundaryEdgeAttName());
|
||||
if (edgeboundary)
|
||||
{
|
||||
beH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm, boundaryEdgeAttName());
|
||||
}
|
||||
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > bfH;
|
||||
if (faceboundary)
|
||||
bfH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm,boundaryFaceAttName());
|
||||
if (faceboundary)
|
||||
{
|
||||
bfH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm, boundaryFaceAttName());
|
||||
}
|
||||
|
||||
std::vector<PointPC> *BVp = &bvH();
|
||||
std::vector<PointPC> *BEp = NULL;
|
||||
@ -537,12 +583,45 @@ void MLDefaultMeshDecorators::initBoundaryDecoratorData( MeshModel& m,bool edgeb
|
||||
|
||||
void MLDefaultMeshDecorators::cleanBoundaryDecoratorData( MeshModel& m,bool edgeboundary,bool faceboundary)
|
||||
{
|
||||
if (edgeboundary && faceboundary)
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute(m.cm,boundaryVertAttName());
|
||||
if (edgeboundary)
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute(m.cm,boundaryEdgeAttName());
|
||||
if (_mw == NULL)
|
||||
return;
|
||||
|
||||
MLRenderingEdgeBoundaryAction eact(m.id(), NULL);
|
||||
unsigned int edgerequview = _mw->viewsRequiringRenderingActions(m.id(), &eact);
|
||||
if (edgeboundary)
|
||||
{
|
||||
if (edgerequview == 0)
|
||||
{
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > beH;
|
||||
beH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm, boundaryEdgeAttName());
|
||||
if (beH._handle != NULL)
|
||||
beH().clear();
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute<std::vector<PointPC>>(m.cm, beH);
|
||||
}
|
||||
}
|
||||
|
||||
MLRenderingFaceBoundaryAction fact(m.id(), NULL);
|
||||
unsigned int facerequview = _mw->viewsRequiringRenderingActions(m.id(), &fact);
|
||||
if (faceboundary)
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute(m.cm,boundaryFaceAttName());
|
||||
{
|
||||
if (facerequview == 0)
|
||||
{
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > beH;
|
||||
beH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm, boundaryFaceAttName());
|
||||
if (beH._handle != NULL)
|
||||
beH().clear();
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute<std::vector<PointPC>>(m.cm, beH);
|
||||
}
|
||||
}
|
||||
|
||||
if ((facerequview == 0) && (edgerequview == 0))
|
||||
{
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > beH;
|
||||
beH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm, boundaryVertAttName());
|
||||
if (beH._handle != NULL)
|
||||
beH().clear();
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute<std::vector<PointPC>>(m.cm, beH);
|
||||
}
|
||||
}
|
||||
|
||||
void MLDefaultMeshDecorators::initSelectionDecoratorData(MeshModel & mm, bool vertsel, bool facesel)
|
||||
@ -554,20 +633,28 @@ void MLDefaultMeshDecorators::initSelectionDecoratorData(MeshModel & mm, bool ve
|
||||
if (vertsel)
|
||||
selbufhand()->updateBuffer(MLSelectionBuffers::ML_PERVERT_SEL);
|
||||
if (facesel)
|
||||
selbufhand()->updateBuffer(MLSelectionBuffers::ML_PERFACE_SEL);
|
||||
selbufhand()->updateBuffer(MLSelectionBuffers::ML_PERFACE_SEL);
|
||||
}
|
||||
|
||||
void MLDefaultMeshDecorators::cleanSelectionDecoratorData(MeshModel& mm, bool vertsel, bool facesel)
|
||||
{
|
||||
CMeshO::PerMeshAttributeHandle< MLSelectionBuffers* > selbufhand = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<MLSelectionBuffers*>(mm.cm, selectionAttName());
|
||||
MLSelectionBuffers* tmp = selbufhand();
|
||||
if (vertsel && (tmp != NULL))
|
||||
tmp->deallocateBuffer(MLSelectionBuffers::ML_PERVERT_SEL);
|
||||
if (_mw == NULL)
|
||||
return;
|
||||
|
||||
if (facesel && (tmp != NULL))
|
||||
CMeshO::PerMeshAttributeHandle< MLSelectionBuffers* > selbufhand = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute<MLSelectionBuffers*>(mm.cm, selectionAttName());
|
||||
MLSelectionBuffers* tmp = selbufhand();
|
||||
|
||||
MLRenderingVertSelectionAction vact(mm.id(), NULL);
|
||||
unsigned int vertselreqview = _mw->viewsRequiringRenderingActions(mm.id(), &vact);
|
||||
if (vertsel && (tmp != NULL) && (vertselreqview == 0))
|
||||
tmp->deallocateBuffer(MLSelectionBuffers::ML_PERVERT_SEL);
|
||||
|
||||
MLRenderingFaceSelectionAction fact(mm.id(), NULL);
|
||||
unsigned int faceselreqview = _mw->viewsRequiringRenderingActions(mm.id(), &fact);
|
||||
if (facesel && (tmp != NULL) && (faceselreqview == 0))
|
||||
tmp->deallocateBuffer(MLSelectionBuffers::ML_PERFACE_SEL);
|
||||
|
||||
if (facesel && vertsel)
|
||||
if ((faceselreqview == 0) && (vertselreqview == 0))
|
||||
{
|
||||
delete tmp;
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute<MLSelectionBuffers*>(mm.cm, selbufhand);
|
||||
@ -619,8 +706,94 @@ void MLDefaultMeshDecorators::initNonManifEdgeDecoratorData(MeshModel& m)
|
||||
|
||||
void MLDefaultMeshDecorators::cleanNonManifEdgeDecoratorData( MeshModel& m )
|
||||
{
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute(m.cm,nonManifEdgeAttName());
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute(m.cm,nonManifEdgeFaceAttName());
|
||||
if (_mw == NULL)
|
||||
return;
|
||||
|
||||
MLRenderingEdgeManifoldAction eact(m.id(), NULL);
|
||||
unsigned int manifreqviews = _mw->viewsRequiringRenderingActions(m.id(), &eact);
|
||||
|
||||
if (manifreqviews == 0)
|
||||
{
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > beH;
|
||||
beH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm, nonManifEdgeAttName());
|
||||
if (beH._handle != NULL)
|
||||
beH().clear();
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute<std::vector<PointPC>>(m.cm, beH);
|
||||
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > bef;
|
||||
bef = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm, nonManifEdgeFaceAttName());
|
||||
if (bef._handle != NULL)
|
||||
bef().clear();
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute<std::vector<PointPC>>(m.cm, bef);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MLDefaultMeshDecorators::initNonManifVertDecoratorData(MeshModel& mm)
|
||||
{
|
||||
CMeshO::PerMeshAttributeHandle<std::vector<PointPC> > bvH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(mm.cm, nonManifVertAttName());
|
||||
CMeshO::PerMeshAttributeHandle<std::vector<PointPC> > fvH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(mm.cm, nonManifVertFaceAttName());
|
||||
std::vector<PointPC> *BVp = &bvH();
|
||||
std::vector<PointPC> *FVp = &fvH();
|
||||
BVp->clear();
|
||||
FVp->clear();
|
||||
mm.updateDataMask(MeshModel::MM_FACEFACETOPO);
|
||||
vcg::tri::SelectionStack<CMeshO> ss(mm.cm);
|
||||
ss.push();
|
||||
vcg::tri::UpdateSelection<CMeshO>::VertexClear(mm.cm);
|
||||
int res = vcg::tri::Clean<CMeshO>::CountNonManifoldVertexFF(mm.cm, true);
|
||||
vcg::Color4b bCol(255, 0, 255, 0);
|
||||
vcg::Color4b vCol(255, 0, 255, 64);
|
||||
vcg::tri::UpdateFlags<CMeshO>::VertexClearV(mm.cm);
|
||||
for (CMeshO::FaceIterator fi = mm.cm.face.begin(); fi != mm.cm.face.end(); ++fi)
|
||||
{
|
||||
if (!(*fi).IsD())
|
||||
{
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if ((*fi).V(i)->IsS())
|
||||
{
|
||||
if (!(*fi).V0(i)->IsV())
|
||||
{
|
||||
BVp->push_back(std::make_pair((*fi).V0(i)->P(), vcg::Color4b(vcg::Color4b::Magenta)));
|
||||
(*fi).V0(i)->SetV();
|
||||
}
|
||||
|
||||
Point3m P1 = ((*fi).V0(i)->P() + (*fi).V1(i)->P()) / 2.0f;
|
||||
Point3m P2 = ((*fi).V0(i)->P() + (*fi).V2(i)->P()) / 2.0f;
|
||||
FVp->push_back(std::make_pair((*fi).V0(i)->P(), vCol));
|
||||
FVp->push_back(std::make_pair(P1, bCol));
|
||||
FVp->push_back(std::make_pair(P2, bCol));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ss.pop();
|
||||
}
|
||||
|
||||
void MLDefaultMeshDecorators::cleanNonManifVertDecoratorData(MeshModel& m)
|
||||
{
|
||||
if (_mw == NULL)
|
||||
return;
|
||||
|
||||
MLRenderingVertManifoldAction eact(m.id(), NULL);
|
||||
unsigned int manifreqviews = _mw->viewsRequiringRenderingActions(m.id(), &eact);
|
||||
|
||||
if (manifreqviews == 0)
|
||||
{
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > beH;
|
||||
beH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm, nonManifVertAttName());
|
||||
if (beH._handle != NULL)
|
||||
beH().clear();
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute<std::vector<PointPC>>(m.cm, beH);
|
||||
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > bef;
|
||||
bef = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm, nonManifVertFaceAttName());
|
||||
if (bef._handle != NULL)
|
||||
bef().clear();
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute<std::vector<PointPC>>(m.cm, bef);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MLDefaultMeshDecorators::initBoundaryTextDecoratorData( MeshModel& m)
|
||||
@ -661,7 +834,17 @@ void MLDefaultMeshDecorators::initBoundaryTextDecoratorData( MeshModel& m)
|
||||
|
||||
void MLDefaultMeshDecorators::cleanBoundaryTextDecoratorData( MeshModel& m)
|
||||
{
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute(m.cm,boundaryTextVertAttName());
|
||||
MLRenderingTexBorderAction eact(m.id(), NULL);
|
||||
unsigned int manifreqviews = _mw->viewsRequiringRenderingActions(m.id(), &eact);
|
||||
|
||||
if (manifreqviews == 0)
|
||||
{
|
||||
CMeshO::PerMeshAttributeHandle< std::vector<PointPC> > beH;
|
||||
beH = vcg::tri::Allocator<CMeshO>::GetPerMeshAttribute< std::vector<PointPC> >(m.cm, boundaryTextVertAttName());
|
||||
if (beH._handle != NULL)
|
||||
beH().clear();
|
||||
vcg::tri::Allocator<CMeshO>::DeletePerMeshAttribute<std::vector<PointPC>>(m.cm, beH);
|
||||
}
|
||||
}
|
||||
|
||||
void MLDefaultMeshDecorators::drawLineVector(std::vector<PointPC> &EV)
|
||||
|
||||
@ -21,14 +21,20 @@
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ML_DEFAULT_DECORATORS_H
|
||||
#define ML_DEFAULT_DECORATORS_H
|
||||
|
||||
#include <common/ml_shared_data_context.h>
|
||||
#include <common/meshmodel.h>
|
||||
#include <common/GLLogStream.h>
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class MLDefaultMeshDecorators
|
||||
{
|
||||
public:
|
||||
MLDefaultMeshDecorators(MainWindow* mw);
|
||||
|
||||
typedef std::pair<Point3m,vcg::Color4b> PointPC; // this type is used to have a simple coord+color pair to rapidly draw non manifold faces
|
||||
|
||||
//the initMeshDecorationData is called when a mesh has been updated by a filter execution
|
||||
@ -38,7 +44,21 @@ public:
|
||||
|
||||
//The updateMeshDecorationData is called when a decoration button is clicked on/off
|
||||
bool updateMeshDecorationData(MeshModel& mesh,const MLRenderingData& previousdata,const MLRenderingData& currentdata);
|
||||
|
||||
|
||||
static const char* selectionAttName() { return "SelectionBuffers"; }
|
||||
|
||||
static const char* boundaryVertAttName() { return "BoundaryVertVector"; }
|
||||
static const char* boundaryEdgeAttName() { return "BoundaryEdgeVector"; }
|
||||
static const char* boundaryFaceAttName() { return "BoundaryFaceVector"; }
|
||||
|
||||
static const char* nonManifEdgeAttName() { return "NonManifEdgeVector"; }
|
||||
static const char* nonManifEdgeFaceAttName() { return "NonManifEdgeFaceVector"; }
|
||||
|
||||
static const char* nonManifVertAttName() { return "NonManifVertVector"; }
|
||||
static const char* nonManifVertFaceAttName() { return "NonManifVertFaceVector"; }
|
||||
|
||||
static const char* boundaryTextVertAttName() { return "BoundaryTexVector"; }
|
||||
|
||||
private:
|
||||
void initBoundaryDecoratorData(MeshModel& mm,bool edgeboundary,bool faceboundary);
|
||||
void cleanBoundaryDecoratorData(MeshModel& mm,bool edgeboundary,bool faceboundary);
|
||||
@ -49,22 +69,13 @@ private:
|
||||
void initNonManifEdgeDecoratorData(MeshModel& mm);
|
||||
void cleanNonManifEdgeDecoratorData(MeshModel& mm);
|
||||
|
||||
void initNonManifVertDecoratorData(MeshModel& mm);
|
||||
void cleanNonManifVertDecoratorData(MeshModel& mm);
|
||||
|
||||
void initBoundaryTextDecoratorData(MeshModel& mm);
|
||||
void cleanBoundaryTextDecoratorData(MeshModel& mm);
|
||||
|
||||
static const char* selectionAttName() { return "SelectionBuffers"; }
|
||||
|
||||
static const char* boundaryVertAttName() {return "BoundaryVertVector";}
|
||||
static const char* boundaryEdgeAttName() {return "BoundaryEdgeVector";}
|
||||
static const char* boundaryFaceAttName() {return "BoundaryFaceVector";}
|
||||
|
||||
static const char* nonManifEdgeAttName() {return "NonManifEdgeVector";}
|
||||
static const char* nonManifEdgeFaceAttName() {return "NonManifEdgeFaceVector";}
|
||||
|
||||
static const char* nonManifVertAttName() {return "NonManifVertVector";}
|
||||
static const char* nonManifVertFaceAttName() {return "NonManifVertFaceVector";}
|
||||
|
||||
static const char* boundaryTextVertAttName() {return "BoundaryTexVector";}
|
||||
|
||||
static void drawLineVector(std::vector<PointPC> &EV);
|
||||
static void drawTriVector(std::vector<PointPC> &TV);
|
||||
@ -74,4 +85,8 @@ private:
|
||||
static void chooseX(Box3m &box,double *mm,double *mp,GLint *vp,vcg::Point3d &x1,vcg::Point3d &x2);
|
||||
static void chooseY(Box3m &box,double *mm,double *mp,GLint *vp,vcg::Point3d &y1,vcg::Point3d &y2);
|
||||
static void chooseZ(Box3m &box,double *mm,double *mp,GLint *vp,vcg::Point3d &z1,vcg::Point3d &z2);
|
||||
};
|
||||
|
||||
MainWindow* _mw;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -23,13 +23,15 @@
|
||||
#ifndef __MULTIVIEWER_CONTAINER_H__
|
||||
#define __MULTIVIEWER_CONTAINER_H__
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGLWidget>
|
||||
#include <QVector>
|
||||
#include <QSplitter>
|
||||
#include <QSplitterHandle>
|
||||
|
||||
#include "../common/meshmodel.h"
|
||||
#include <GL/glew.h>
|
||||
#include "../common/ml_shared_data_context.h"
|
||||
|
||||
// Class list
|
||||
@ -82,7 +84,8 @@ public:
|
||||
int getNextViewerId();
|
||||
int viewerCounter();
|
||||
|
||||
void updateAllViewer();
|
||||
void updateAllViewer();
|
||||
|
||||
void resetAllTrackBall();
|
||||
void update(int id);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user