From c4600248ee14250edbe499515792b5da0bbbfd3f Mon Sep 17 00:00:00 2001 From: Fabio Ganovelli ganovelli Date: Wed, 30 Jan 2013 17:23:22 +0000 Subject: [PATCH] Update use og vcg::tri::Allocate< >::Get*Attribute to revision 4811 of vcglib (below): ----------------------------------------------------------------------- vcg::tri::Allocate::Get*Attribute(m,name); has CHANGED! Before it was returning a valid handle to the attribute IF it existed, otherwise the handle was invalid. Now it always returns a valid handle to the attribute, by creating the attribute name if it did not exist or returning the handle to it if it was already there. ALl the code using Get*Attribute has been changed accordingly. --- .../decorate_base/decorate_base.cpp | 58 ++++--------------- .../edit_align/align/AlignPair.cpp | 6 +- .../edit_align/align/AlignPair.h | 6 +- .../edit_pickpoints/pickpointsDialog.cpp | 8 +-- .../edit_point/connectedComponent.h | 6 +- src/meshlabplugins/edit_point/knnGraph.h | 2 +- .../filter_aging/filter_aging.cpp | 11 ++-- src/meshlabplugins/filter_ao/filter_ao.cpp | 14 ++--- .../feature_alignment.h | 8 +-- .../filter_func/filter_func.cpp | 57 ++++++++---------- .../filter_isoparametrization.cpp | 10 ++-- .../local_parametrization.h | 2 +- .../filter_unsharp/filter_unsharp.cpp | 2 +- .../edit_ocme/edit_ocme.cpp | 6 +- .../edit_ocme/src/ocme/ocme_commit.h | 10 ++-- .../edit_ocme/src/ocme/ocme_extract.h | 31 ++-------- .../filter_vsa/region_growing.h | 4 -- 17 files changed, 80 insertions(+), 161 deletions(-) diff --git a/src/meshlabplugins/decorate_base/decorate_base.cpp b/src/meshlabplugins/decorate_base/decorate_base.cpp index fe0504fbe..6f46cd858 100644 --- a/src/meshlabplugins/decorate_base/decorate_base.cpp +++ b/src/meshlabplugins/decorate_base/decorate_base.cpp @@ -305,40 +305,32 @@ void ExtraMeshDecoratePlugin::decorateMesh(QAction *a, MeshModel &m, RichParamet { CMeshO::PerMeshAttributeHandle qH; qH = vcg::tri::Allocator::GetPerMeshAttribute(m.cm,"QualityHist"); - - if(vcg::tri::Allocator::IsValidHandle (m.cm, qH)) { - CHist &ch=qH(); - this->DrawColorHistogram(ch,gla, painter,rm,qf); - } + CHist &ch=qH(); + this->DrawColorHistogram(ch,gla, painter,rm,qf); } break; case DP_SHOW_NON_MANIF_VERT : { // Note the standard way for adding extra per-mesh data using the per-mesh attributes. CMeshO::PerMeshAttributeHandle< vector > vvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,"NonManifVertVertVector"); CMeshO::PerMeshAttributeHandle< vector > tvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,"NonManifVertTriVector"); - if(vcg::tri::Allocator::IsValidHandle (m.cm, vvH)) - { - DrawDotVector(vvH()); - DrawTriVector(tvH()); + DrawDotVector(vvH()); + DrawTriVector(tvH()); - this->RealTimeLog("Non Manifold Vertices",m.shortName(), + this->RealTimeLog("Non Manifold Vertices",m.shortName(), "%i non manifold vertices
" "%i faces over non manifold vertices",vvH().size(),tvH().size()/3); - } - }break; + } + break; case DP_SHOW_NON_MANIF_EDGE : { // Note the standard way for adding extra per-mesh data using the per-mesh attributes. CMeshO::PerMeshAttributeHandle< vector > bvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,"NonManifEdgeVector"); CMeshO::PerMeshAttributeHandle< vector > fvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,"NonManifFaceVector"); - if(vcg::tri::Allocator::IsValidHandle (m.cm, bvH)) - { - DrawLineVector(bvH()); - DrawTriVector(fvH()); - this->RealTimeLog("Non Manifold Edges",m.shortName(), - " %i non manifold edges
" - " %i faces over non manifold edges",bvH().size()/2,fvH().size()/3); - } + DrawLineVector(bvH()); + DrawTriVector(fvH()); + this->RealTimeLog("Non Manifold Edges",m.shortName(), + " %i non manifold edges
" + " %i faces over non manifold edges",bvH().size()/2,fvH().size()/3); } break; case DP_SHOW_BOUNDARY : { @@ -346,19 +338,14 @@ void ExtraMeshDecoratePlugin::decorateMesh(QAction *a, MeshModel &m, RichParamet // Note the standard way for adding extra per-mesh data using the per-mesh attributes. CMeshO::PerMeshAttributeHandle< vector > bvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,"BoundaryVertVector"); CMeshO::PerMeshAttributeHandle< vector > bfH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,"BoundaryFaceVector"); - if(vcg::tri::Allocator::IsValidHandle (m.cm, bvH)) - { DrawLineVector(bvH()); if(showBorderFlag) DrawTriVector(bfH()); this->RealTimeLog("Boundary",m.shortName(),"%i boundary edges",bvH().size()/2); - } } break; case DP_SHOW_BOUNDARY_TEX : { // Note the standard way for adding extra per-mesh data using the per-mesh attributes. CMeshO::PerMeshAttributeHandle< vector > btvH = vcg::tri::Allocator::GetPerMeshAttribute >(m.cm,"BoundaryTexVector"); - if(vcg::tri::Allocator::IsValidHandle (m.cm, btvH)) - { vector *BTVp = &btvH(); if (BTVp->size() != 0) { @@ -378,7 +365,6 @@ void ExtraMeshDecoratePlugin::decorateMesh(QAction *a, MeshModel &m, RichParamet glDisableClientState (GL_VERTEX_ARRAY); glPopAttrib(); } - } } break; } // end switch; glPopMatrix(); @@ -818,8 +804,6 @@ bool ExtraMeshDecoratePlugin::startDecorate(QAction * action, MeshModel &m, Rich case DP_SHOW_NON_FAUX_EDGE : { CMeshO::PerMeshAttributeHandle< vector > bvH = vcg::tri::Allocator::GetPerMeshAttribute< vector >(m.cm,"ExtraordinaryVertexVector"); - if(!vcg::tri::Allocator::IsValidHandle(m.cm,bvH)) - bvH=vcg::tri::Allocator::AddPerMeshAttribute< vector >(m.cm,std::string("ExtraordinaryVertexVector")); vector *BVp = &bvH(); BVp->clear(); @@ -885,10 +869,6 @@ bool ExtraMeshDecoratePlugin::startDecorate(QAction * action, MeshModel &m, Rich { CMeshO::PerMeshAttributeHandle< vector > bvH = vcg::tri::Allocator::GetPerMeshAttribute< vector >(m.cm,"BoundaryVertVector"); CMeshO::PerMeshAttributeHandle< vector > bfH = vcg::tri::Allocator::GetPerMeshAttribute< vector >(m.cm,"BoundaryFaceVector"); - if(!vcg::tri::Allocator::IsValidHandle(m.cm,bvH)){ - bvH=vcg::tri::Allocator::AddPerMeshAttribute< vector >(m.cm,std::string("BoundaryVertVector")); - bfH=vcg::tri::Allocator::AddPerMeshAttribute< vector >(m.cm,std::string("BoundaryFaceVector")); - } vector *BVp = &bvH(); vector *BFp = &bfH(); BVp->clear(); @@ -919,8 +899,6 @@ bool ExtraMeshDecoratePlugin::startDecorate(QAction * action, MeshModel &m, Rich { m.updateDataMask(MeshModel::MM_FACEFACETOPO); CMeshO::PerMeshAttributeHandle< vector > btvH = vcg::tri::Allocator::GetPerMeshAttribute< vector >(m.cm,"BoundaryTexVector"); - if(!vcg::tri::Allocator::IsValidHandle(m.cm,btvH)) - btvH=vcg::tri::Allocator::AddPerMeshAttribute< vector >(m.cm,std::string("BoundaryTexVector")); vector *BTVp = &btvH(); BTVp->clear(); vector > SaveTopoVec; @@ -955,11 +933,6 @@ bool ExtraMeshDecoratePlugin::startDecorate(QAction * action, MeshModel &m, Rich { CMeshO::PerMeshAttributeHandle< vector > bvH = vcg::tri::Allocator::GetPerMeshAttribute< vector >(m.cm,"NonManifVertVertVector"); CMeshO::PerMeshAttributeHandle< vector > fvH = vcg::tri::Allocator::GetPerMeshAttribute< vector >(m.cm,"NonManifVertTriVector"); - if(!vcg::tri::Allocator::IsValidHandle(m.cm,bvH)) - { - bvH=vcg::tri::Allocator::AddPerMeshAttribute< vector >(m.cm,std::string("NonManifVertVertVector")); - fvH=vcg::tri::Allocator::AddPerMeshAttribute< vector >(m.cm,std::string("NonManifVertTriVector")); - } vector *BVp = &bvH(); vector *FVp = &fvH(); BVp->clear(); @@ -998,11 +971,6 @@ bool ExtraMeshDecoratePlugin::startDecorate(QAction * action, MeshModel &m, Rich { CMeshO::PerMeshAttributeHandle< vector > bvH = vcg::tri::Allocator::GetPerMeshAttribute< vector >(m.cm,"NonManifEdgeVector"); CMeshO::PerMeshAttributeHandle< vector > fvH = vcg::tri::Allocator::GetPerMeshAttribute< vector >(m.cm,"NonManifFaceVector"); - if(!vcg::tri::Allocator::IsValidHandle(m.cm,bvH)) - { - bvH=vcg::tri::Allocator::AddPerMeshAttribute< vector >(m.cm,std::string("NonManifEdgeVector")); - fvH=vcg::tri::Allocator::AddPerMeshAttribute< vector >(m.cm,std::string("NonManifFaceVector")); - } vector *BVp = &bvH(); vector *FVp = &fvH(); BVp->clear(); @@ -1046,8 +1014,6 @@ bool ExtraMeshDecoratePlugin::startDecorate(QAction * action, MeshModel &m, Rich if( perVertFlag && !(tri::HasPerVertexQuality(m.cm) && tri::HasPerVertexColor(m.cm)) ) return false; if(!perVertFlag && !(tri::HasPerFaceQuality(m.cm) && tri::HasPerFaceColor(m.cm)) ) return false; CMeshO::PerMeshAttributeHandle qH = vcg::tri::Allocator::GetPerMeshAttribute(m.cm,"QualityHist"); - if(!vcg::tri::Allocator::IsValidHandle(m.cm,qH)) - qH=vcg::tri::Allocator::AddPerMeshAttribute (m.cm,std::string("QualityHist")); CHist *H = &qH(); std::pair minmax; diff --git a/src/meshlabplugins/edit_align/align/AlignPair.cpp b/src/meshlabplugins/edit_align/align/AlignPair.cpp index 976daddae..82db55687 100644 --- a/src/meshlabplugins/edit_align/align/AlignPair.cpp +++ b/src/meshlabplugins/edit_align/align/AlignPair.cpp @@ -26,7 +26,7 @@ #include #include -#include +//#include #include #include #include @@ -55,7 +55,7 @@ bool AlignPair::A2Mesh::InitVert(const Matrix44d &Tr,bool hasborderflag) { Matrix44d Idn; Idn.SetIdentity(); if(Tr!=Idn) tri::UpdatePosition::Matrix(*this,Tr); - tri::UpdateNormal::NormalizeVertex(*this); + tri::UpdateNormal::NormalizePerVertex(*this); tri::UpdateBounding::Box(*this); return true; } @@ -76,8 +76,6 @@ bool AlignPair::A2Mesh::Init(const Matrix44d &Tr,bool hasborderflag) //int t5=clock(); tri::UpdateBounding::Box(*this); //int t6=clock(); - tri::UpdateEdges::Set(*this); - //int t7=clock(); /* printf("LoadPly %6i\n",t1-t0); printf("RemoveUnrefVert %6i\n",t2-t1); diff --git a/src/meshlabplugins/edit_align/align/AlignPair.h b/src/meshlabplugins/edit_align/align/AlignPair.h index e678dcfab..51f3d2f15 100644 --- a/src/meshlabplugins/edit_align/align/AlignPair.h +++ b/src/meshlabplugins/edit_align/align/AlignPair.h @@ -280,7 +280,7 @@ void ConvertMesh(const MESH &M1, A2Mesh &M2) M2.face.resize(M1.fn); for(vi=M1.vert.begin(),v2i=M2.vert.begin();vi!=M1.vert.end();++vi) if(!(*vi).IsD()){ - (*v2i).Flags()=(*vi).Flags(); + (*v2i).Flags()=(*vi).cFlags(); (*v2i).P().Import((*vi).P()); (*v2i).N().Import((*vi).cN()); (*v2i).N().Normalize(); @@ -293,7 +293,7 @@ void ConvertMesh(const MESH &M1, A2Mesh &M2) typename A2Mesh::FaceIterator f2i; for(fi=M1.face.begin(),f2i=M2.face.begin();fi!=M1.face.end();++fi)if(!(*fi).IsD()){ - (*f2i).Flags()=(*fi).Flags(); + (*f2i).Flags()=(*fi).cFlags(); (*f2i).V(0)=&M2.vert[ (vmap[(*fi).V(0)-&M1.vert[0] ]) ]; (*f2i).V(1)=&M2.vert[ (vmap[(*fi).V(1)-&M1.vert[0] ]) ]; (*f2i).V(2)=&M2.vert[ (vmap[(*fi).V(2)-&M1.vert[0] ]) ]; @@ -318,7 +318,7 @@ void ConvertVertex(const std::vector &vert1, std::vector &vert vert2.clear(); typename std::vector::const_iterator vi; A2Vertex tv; - tv.UberFlags()=0; + tv.Flags()=0; Box3 bb; if(Clip){ bb.Import(*Clip); diff --git a/src/meshlabplugins/edit_pickpoints/pickpointsDialog.cpp b/src/meshlabplugins/edit_pickpoints/pickpointsDialog.cpp index cc3a093d9..aaf6feb04 100644 --- a/src/meshlabplugins/edit_pickpoints/pickpointsDialog.cpp +++ b/src/meshlabplugins/edit_pickpoints/pickpointsDialog.cpp @@ -541,7 +541,7 @@ void PickPointsDialog::setCurrentMeshModel(MeshModel *newMeshModel, GLArea *gla) if(vcg::tri::HasPerMeshAttribute(newMeshModel->cm, PickedPoints::Key)) { CMeshO::PerMeshAttributeHandle ppHandle = - vcg::tri::Allocator::GetPerMeshAttribute(newMeshModel->cm, PickedPoints::Key); + vcg::tri::Allocator::GetPerMeshAttribute(newMeshModel->cm, PickedPoints::Key); PickedPoints *pickedPoints = ppHandle(); @@ -786,11 +786,7 @@ void PickPointsDialog::savePointsToMetaData() { //save the points to the metadata if(NULL != meshModel){ - CMeshO::PerMeshAttributeHandle ppHandle = - (vcg::tri::HasPerMeshAttribute(meshModel->cm, PickedPoints::Key) ? - vcg::tri::Allocator::GetPerMeshAttribute (meshModel->cm, PickedPoints::Key) : - vcg::tri::Allocator::AddPerMeshAttribute (meshModel->cm, PickedPoints::Key) ); - + CMeshO::PerMeshAttributeHandle ppHandle =vcg::tri::Allocator::GetPerMeshAttribute (meshModel->cm, PickedPoints::Key); ppHandle() = getPickedPoints(); //qDebug() << "saved points"; diff --git a/src/meshlabplugins/edit_point/connectedComponent.h b/src/meshlabplugins/edit_point/connectedComponent.h index b978e219e..1ff3ad514 100644 --- a/src/meshlabplugins/edit_point/connectedComponent.h +++ b/src/meshlabplugins/edit_point/connectedComponent.h @@ -115,11 +115,7 @@ static void Dijkstra(_MyMeshType& m, VertexType& v, int numOfNeighbours, float m notReachableVect.clear(); - typename _MyMeshType::template PerVertexAttributeHandle distFromCenter; - if (!hasDistParam) { - distFromCenter = tri::Allocator<_MyMeshType>::template AddPerVertexAttribute(m, std::string("DistParam")); - } - else distFromCenter = tri::Allocator<_MyMeshType>::template GetPerVertexAttribute(m, std::string("DistParam")); + typename _MyMeshType::template PerVertexAttributeHandle distFromCenter = vcg::tri::Allocator<_MyMeshType>::template GetPerVertexAttribute(m, std::string("DistParam")); if (!hasKNNGraph) { KNNGraph<_MyMeshType>::MakeKNNTree(m, numOfNeighbours); diff --git a/src/meshlabplugins/edit_point/knnGraph.h b/src/meshlabplugins/edit_point/knnGraph.h index 7ac48e6b7..bb0c3f4d8 100644 --- a/src/meshlabplugins/edit_point/knnGraph.h +++ b/src/meshlabplugins/edit_point/knnGraph.h @@ -2,7 +2,7 @@ #define KNNGRAPH_H #include -#include +#include #include #include diff --git a/src/meshlabplugins/filter_aging/filter_aging.cpp b/src/meshlabplugins/filter_aging/filter_aging.cpp index 3d1dd683d..96ceb1b68 100644 --- a/src/meshlabplugins/filter_aging/filter_aging.cpp +++ b/src/meshlabplugins/filter_aging/filter_aging.cpp @@ -202,14 +202,11 @@ bool GeometryAgingPlugin::applyFilter(QAction *filter, MeshDocument &md, RichPar // if requested, add erosion attribute to vertexes and initialize it if(storeDispl) { - CMeshO::PerVertexAttributeHandle vah = - (tri::HasPerVertexAttribute(m.cm, "Erosion") ? - tri::Allocator::GetPerVertexAttribute(m.cm, "Erosion") : - tri::Allocator::AddPerVertexAttribute(m.cm, std::string("Erosion"))); + CMeshO::PerVertexAttributeHandle vah = tri::Allocator::GetPerVertexAttribute(m.cm, "Erosion"); for(CMeshO::VertexIterator vi=m.cm.vert.begin(); vi!=m.cm.vert.end(); vi++) vah[vi] = Point3f(0.0, 0.0, 0.0); } - CMeshO::PerVertexAttributeHandle vah = vcg::tri::Allocator::GetPerVertexAttribute(m.cm, "Erosion"); + CMeshO::PerVertexAttributeHandle vah = vcg::tri::Allocator::GetPerVertexAttribute(m.cm, "Erosion"); // vertexes along selection border will not be displaced if(selected) tri::UpdateSelection::VertexFromFaceStrict(m.cm); @@ -368,7 +365,7 @@ void GeometryAgingPlugin::smoothPeaks(CMeshO &m, bool selected, bool updateErosi GridStaticPtr gM; gM.Set(m.face.begin(), m.face.end()); CMeshO::PerVertexAttributeHandle vah = - vcg::tri::Allocator::GetPerVertexAttribute(m, "Erosion"); + vcg::tri::Allocator::GetPerVertexAttribute(m, "Erosion"); for(CMeshO::FaceIterator fi=m.face.begin(); fi!=m.face.end(); fi++) { if((*fi).IsD()) continue; @@ -402,7 +399,7 @@ void GeometryAgingPlugin::computeMeanCurvature(CMeshO &m) if(delvert) Log( "Pre-Curvature Cleaning: Removed %d unreferenced vertices", delvert); tri::Allocator::CompactVertexVector(m); tri::UpdateCurvature::MeanAndGaussian(m); - tri::UpdateQuality::VertexFromMeanCurvature(m); + tri::UpdateQuality::VertexFromMeanCurvatureHG(m); } diff --git a/src/meshlabplugins/filter_ao/filter_ao.cpp b/src/meshlabplugins/filter_ao/filter_ao.cpp index 6b216818b..29a7d0e3f 100644 --- a/src/meshlabplugins/filter_ao/filter_ao.cpp +++ b/src/meshlabplugins/filter_ao/filter_ao.cpp @@ -194,14 +194,12 @@ bool AmbientOcclusionPlugin::processGL(MeshModel &m, vector &posVect) vcg::tri::Allocator::CompactFaceVector(m.cm); vcg::tri::UpdateNormal::PerVertexNormalizedPerFaceNormalized(m.cm); - CMeshO::PerVertexAttributeHandle BN = tri::Allocator::GetPerVertexAttribute(m.cm, "BentNormal"); - if(!tri::Allocator::IsValidHandle(m.cm,BN)) - { - BN = tri::Allocator::AddPerVertexAttribute (m.cm,"BentNormal"); - std::vector AllVertexAttribName; - tri::Allocator::GetAllPerVertexAttribute< Point3f >(m.cm,AllVertexAttribName); - qDebug("Now mesh has %i attrib",AllVertexAttribName.size()); - } + CMeshO::PerVertexAttributeHandle BN = tri::Allocator::GetPerVertexAttribute(m.cm, "BentNormal"); + + std::vector AllVertexAttribName; + tri::Allocator::GetAllPerVertexAttribute< Point3f >(m.cm,AllVertexAttribName); + qDebug("Now mesh has %i attrib",AllVertexAttribName.size()); + glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); diff --git a/src/meshlabplugins/filter_feature_alignment/feature_alignment.h b/src/meshlabplugins/filter_feature_alignment/feature_alignment.h index d9336c98a..b31107e63 100644 --- a/src/meshlabplugins/filter_feature_alignment/feature_alignment.h +++ b/src/meshlabplugins/filter_feature_alignment/feature_alignment.h @@ -590,7 +590,7 @@ template class FeatureAlignment else return PVAttributeHandle(NULL,0); } //now we can get a handle to the attribute and return it - return tri::Allocator::template GetPerVertexAttribute (m,std::string(FeatureType::getName())); + return tri::Allocator::template FindPerVertexAttribute (m,std::string(FeatureType::getName())); } /** \brief Extracts \c numRequested features from mesh \c m using the specified \c samplingStrategy. @@ -825,7 +825,7 @@ template class FeatureAlignment pph = tri::Allocator::template AddPerMeshAttribute(m,PickedPoints::Key); pph() = new PickedPoints(); } - else pph = tri::Allocator::template GetPerMeshAttribute(m, PickedPoints::Key); + else pph = tri::Allocator::template FindPerMeshAttribute(m, PickedPoints::Key); for(unsigned int i=0; i class FeatureAlignment PMAttributeHandle pph; //we get a handle to the attribute if it exists if(!tri::HasPerMeshAttribute(m, PickedPoints::Key)) return; - pph = tri::Allocator::template GetPerMeshAttribute(m, PickedPoints::Key); + pph = tri::Allocator::template FindPerMeshAttribute(m, PickedPoints::Key); //delete previous picked points (pph()->getPickedPointVector())->clear(); @@ -869,7 +869,7 @@ template class FeatureAlignment pph = tri::Allocator::template AddPerMeshAttribute(m,PickedPoints::Key); pph() = new PickedPoints(); } - else pph = tri::Allocator::template GetPerMeshAttribute(m, PickedPoints::Key); + else pph = tri::Allocator::template FindPerMeshAttribute(m, PickedPoints::Key); (pph()->getPickedPointVector())->clear(); //clear old contents diff --git a/src/meshlabplugins/filter_func/filter_func.cpp b/src/meshlabplugins/filter_func/filter_func.cpp index 639f5e732..ef1baa757 100644 --- a/src/meshlabplugins/filter_func/filter_func.cpp +++ b/src/meshlabplugins/filter_func/filter_func.cpp @@ -756,7 +756,7 @@ bool FilterFunctionPlugin::applyFilter(QAction *filter, MeshDocument &md, RichPa CMeshO::PerVertexAttributeHandle h; if(tri::HasPerVertexAttribute(m.cm,name)) { - h = tri::Allocator::GetPerVertexAttribute(m.cm, name); + h = tri::Allocator::FindPerVertexAttribute(m.cm, name); if(!tri::Allocator::IsValidHandle(m.cm,h)) { errorMessage = "attribute already exists with a different type"; @@ -814,7 +814,7 @@ bool FilterFunctionPlugin::applyFilter(QAction *filter, MeshDocument &md, RichPa CMeshO::PerFaceAttributeHandle h; if(tri::HasPerFaceAttribute(m.cm,name)) { - h = tri::Allocator::GetPerFaceAttribute(m.cm, name); + h = tri::Allocator::FindPerFaceAttribute(m.cm, name); if(!tri::Allocator::IsValidHandle(m.cm,h)) { errorMessage = "attribute already exists with a different type"; @@ -1170,40 +1170,36 @@ void FilterFunctionPlugin::setPerVertexVariables(Parser &p, CMeshO &m) for(int i = 0; i < (int) AllVertexAttribName.size(); i++) { CMeshO::PerVertexAttributeHandle hh = tri::Allocator::GetPerVertexAttribute(m, AllVertexAttribName[i]); - if(tri::Allocator::IsValidHandle(m,hh)) - { - v_handlers.push_back(hh); - v_attrNames.push_back(AllVertexAttribName[i]); - v_attrValue.push_back(0); - p.DefineVar(v_attrNames.back(), &v_attrValue.back()); - qDebug("Adding custom per vertex float variable %s",v_attrNames.back().c_str()); - } + v_handlers.push_back(hh); + v_attrNames.push_back(AllVertexAttribName[i]); + v_attrValue.push_back(0); + p.DefineVar(v_attrNames.back(), &v_attrValue.back()); + qDebug("Adding custom per vertex float variable %s",v_attrNames.back().c_str()); } AllVertexAttribName.clear(); tri::Allocator::GetAllPerVertexAttribute< Point3f >(m,AllVertexAttribName); for(int i = 0; i < (int) AllVertexAttribName.size(); i++) { CMeshO::PerVertexAttributeHandle hh3 = tri::Allocator::GetPerVertexAttribute(m, AllVertexAttribName[i]); - if(tri::Allocator::IsValidHandle(m,hh3)) - { - v3_handlers.push_back(hh3); - v3_attrValue.push_back(0); - v3_attrNames.push_back(AllVertexAttribName[i]+"_x"); - p.DefineVar(v3_attrNames.back(), &v3_attrValue.back()); + v3_handlers.push_back(hh3); - v3_attrValue.push_back(0); - v3_attrNames.push_back(AllVertexAttribName[i]+"_y"); - p.DefineVar(v3_attrNames.back(), &v3_attrValue.back()); + v3_attrValue.push_back(0); + v3_attrNames.push_back(AllVertexAttribName[i]+"_x"); + p.DefineVar(v3_attrNames.back(), &v3_attrValue.back()); - v3_attrValue.push_back(0); - v3_attrNames.push_back(AllVertexAttribName[i]+"_z"); - p.DefineVar(v3_attrNames.back(), &v3_attrValue.back()); - qDebug("Adding custom per vertex Point3f variable %s",v3_attrNames.back().c_str()); - } - } + v3_attrValue.push_back(0); + v3_attrNames.push_back(AllVertexAttribName[i]+"_y"); + p.DefineVar(v3_attrNames.back(), &v3_attrValue.back()); + + v3_attrValue.push_back(0); + v3_attrNames.push_back(AllVertexAttribName[i]+"_z"); + p.DefineVar(v3_attrNames.back(), &v3_attrValue.back()); + qDebug("Adding custom per vertex Point3f variable %s",v3_attrNames.back().c_str()); + } } + // Function explicitely define parser variables to perform Per-Face filter action void FilterFunctionPlugin::setPerFaceVariables(Parser &p, CMeshO &m) { @@ -1281,13 +1277,10 @@ void FilterFunctionPlugin::setPerFaceVariables(Parser &p, CMeshO &m) for(int i = 0; i < (int) AllFaceAttribName.size(); i++) { CMeshO::PerFaceAttributeHandle hh = tri::Allocator::GetPerFaceAttribute(m, AllFaceAttribName[i]); - if(tri::Allocator::IsValidHandle(m,hh)) - { - f_handlers.push_back(hh); - f_attrNames.push_back(AllFaceAttribName[i]); - f_attrValue.push_back(0); - p.DefineVar(f_attrNames.back(), &f_attrValue.back()); - } + f_handlers.push_back(hh); + f_attrNames.push_back(AllFaceAttribName[i]); + f_attrValue.push_back(0); + p.DefineVar(f_attrNames.back(), &f_attrValue.back()); } } diff --git a/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.cpp b/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.cpp index dbfc6014c..36aeae81c 100644 --- a/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.cpp +++ b/src/meshlabplugins/filter_isoparametrization/filter_isoparametrization.cpp @@ -357,7 +357,7 @@ bool FilterIsoParametrization::applyFilter(QAction *filter, MeshDocument& md, Ri case ISOP_REMESHING : { CMeshO::PerMeshAttributeHandle isoPHandle = - tri::Allocator::GetPerMeshAttribute(*mesh,"isoparametrization"); + tri::Allocator::FindPerMeshAttribute(*mesh,"isoparametrization"); bool b=tri::Allocator::IsValidHandle(*mesh,isoPHandle); if (!b) @@ -399,7 +399,7 @@ bool FilterIsoParametrization::applyFilter(QAction *filter, MeshDocument& md, Ri case ISOP_DIAMPARAM : { CMeshO::PerMeshAttributeHandle isoPHandle = - tri::Allocator::GetPerMeshAttribute(*mesh,"isoparametrization"); + tri::Allocator::FindPerMeshAttribute(*mesh,"isoparametrization"); bool b=tri::Allocator::IsValidHandle(*mesh,isoPHandle); if (!b) { @@ -432,7 +432,7 @@ bool FilterIsoParametrization::applyFilter(QAction *filter, MeshDocument& md, Ri return false; } CMeshO::PerMeshAttributeHandle isoPHandle = - tri::Allocator::GetPerMeshAttribute(*mesh,"isoparametrization"); + tri::Allocator::FindPerMeshAttribute(*mesh,"isoparametrization"); bool b=tri::Allocator::IsValidHandle(*mesh,isoPHandle); if (!b) @@ -456,7 +456,7 @@ bool FilterIsoParametrization::applyFilter(QAction *filter, MeshDocument& md, Ri { m->updateDataMask(MeshModel::MM_VERTQUALITY); CMeshO::PerMeshAttributeHandle isoPHandle = - tri::Allocator::GetPerMeshAttribute(*mesh,"isoparametrization"); + tri::Allocator::FindPerMeshAttribute(*mesh,"isoparametrization"); bool b=tri::Allocator::IsValidHandle(*mesh,isoPHandle); if (!b) @@ -481,7 +481,7 @@ bool FilterIsoParametrization::applyFilter(QAction *filter, MeshDocument& md, Ri CMeshO *srcMesh=&mmsrc->cm; CMeshO::PerMeshAttributeHandle isoPHandle = - tri::Allocator::GetPerMeshAttribute(*mesh,"isoparametrization"); + tri::Allocator::FindPerMeshAttribute(*mesh,"isoparametrization"); bool b=tri::Allocator::IsValidHandle(*srcMesh,isoPHandle); if (!b) diff --git a/src/meshlabplugins/filter_isoparametrization/local_parametrization.h b/src/meshlabplugins/filter_isoparametrization/local_parametrization.h index 5a13cf8d9..e9a396c20 100644 --- a/src/meshlabplugins/filter_isoparametrization/local_parametrization.h +++ b/src/meshlabplugins/filter_isoparametrization/local_parametrization.h @@ -454,7 +454,7 @@ typename MeshType::ScalarType EstimateAreaByParam typedef typename MeshType::VertexType VertexType; typedef typename MeshType::ScalarType ScalarType; - //MeshType::PerVertexAttributeHandle handle = vcg::tri::Allocator::GetPerVertexAttribute(mesh,"AuxiliaryVertData"); + //MeshType::PerVertexAttributeHandle handle = vcg::tri::Allocator::GetPerVertexAttribute(mesh,"AuxiliaryVertData"); ScalarType estimated[2]={0,0}; int num[2]={0,0}; diff --git a/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp b/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp index 93351a097..e226e5b9c 100644 --- a/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp +++ b/src/meshlabplugins/filter_unsharp/filter_unsharp.cpp @@ -445,7 +445,7 @@ bool FilterUnsharp::applyFilter(QAction *filter, MeshDocument &md, RichParameter errorMessage = "Failed to retrieve the stored vertex position. First Store than recover."; return false; } - CMeshO::PerVertexAttributeHandle h = tri::Allocator::GetPerVertexAttribute (m.cm,AttribName); + CMeshO::PerVertexAttributeHandle h = tri::Allocator::GetPerVertexAttribute (m.cm,AttribName); CMeshO::VertexIterator vi; for(vi= m.cm.vert.begin();vi!= m.cm.vert.end();++vi) diff --git a/src/plugins_experimental/edit_ocme/edit_ocme.cpp b/src/plugins_experimental/edit_ocme/edit_ocme.cpp index e5828ae37..b7e3aece7 100755 --- a/src/plugins_experimental/edit_ocme/edit_ocme.cpp +++ b/src/plugins_experimental/edit_ocme/edit_ocme.cpp @@ -548,10 +548,10 @@ void OcmeEditPlugin::drop(){ void OcmeEditPlugin::markEditable(){ CMeshO:: PerVertexAttributeHandle lockedV = - vcg::tri::Allocator:: GetPerVertexAttribute (mm->cm,"ocme_locked"); + vcg::tri::Allocator:: GetPerVertexAttribute (mm->cm,"ocme_locked"); CMeshO:: PerFaceAttributeHandle lockedF = - vcg::tri::Allocator:: GetPerFaceAttribute (mm->cm,"ocme_locked"); + vcg::tri::Allocator:: GetPerFaceAttribute (mm->cm,"ocme_locked"); for(CMeshO::VertexIterator vi = mm->cm.vert.begin(); vi != mm->cm.vert.end(); ++vi ) if(!(*vi).IsD()) @@ -640,7 +640,7 @@ void OcmeEditPlugin::edit(){ vcg::tri::UpdateNormals::PerVertexPerFace ( mm->cm ); CMeshO:: PerFaceAttributeHandle gposf = - vcg::tri::Allocator:: GetPerFaceAttribute (mm->cm,"ocme_gindex"); + vcg::tri::Allocator:: GetPerFaceAttribute (mm->cm,"ocme_gindex"); if(!mm->cm.face.IsColorEnabled()) mm->cm.face.EnableColor(); diff --git a/src/plugins_experimental/edit_ocme/src/ocme/ocme_commit.h b/src/plugins_experimental/edit_ocme/src/ocme/ocme_commit.h index 87ac3a24c..12e2addd6 100755 --- a/src/plugins_experimental/edit_ocme/src/ocme/ocme_commit.h +++ b/src/plugins_experimental/edit_ocme/src/ocme/ocme_commit.h @@ -97,24 +97,24 @@ void OCME::Commit(MeshType & m, AttributeMapper attr_map){ assert(vcg::tri::Allocator::IsValidHandle(m,gPosV)); typename MeshType::template PerFaceAttributeHandle gPosF = - vcg::tri::Allocator::template GetPerFaceAttribute (m,"ocme_gindex"); + vcg::tri::Allocator::template GetPerFaceAttribute (m,"ocme_gindex"); assert(vcg::tri::Allocator::IsValidHandle(m,gPosF)); typename MeshType::template PerMeshAttributeHandle srE = - vcg::tri::Allocator::template GetPerMeshAttribute (m,"ocme_range"); + vcg::tri::Allocator::template GetPerMeshAttribute (m,"ocme_range"); assert(vcg::tri::Allocator::IsValidHandle(m,srE)); typename MeshType::template PerVertexAttributeHandle lockedV = - vcg::tri::Allocator::template GetPerVertexAttribute (m,"ocme_locked"); + vcg::tri::Allocator::template GetPerVertexAttribute (m,"ocme_locked"); assert(vcg::tri::Allocator::IsValidHandle(m,lockedV)); typename MeshType::template PerFaceAttributeHandle lockedF = - vcg::tri::Allocator::template GetPerFaceAttribute (m,"ocme_locked"); + vcg::tri::Allocator::template GetPerFaceAttribute (m,"ocme_locked"); assert(vcg::tri::Allocator::IsValidHandle(m,lockedF)); typename MeshType::template PerMeshAttributeHandle > sel_cells_attr = - vcg::tri::Allocator::template GetPerMeshAttribute > (m,"sel_cells"); + vcg::tri::Allocator::template GetPerMeshAttribute > (m,"sel_cells"); assert(vcg::tri::Allocator::IsValidHandle(m,sel_cells_attr)); diff --git a/src/plugins_experimental/edit_ocme/src/ocme/ocme_extract.h b/src/plugins_experimental/edit_ocme/src/ocme/ocme_extract.h index d9ec624f3..00063180c 100755 --- a/src/plugins_experimental/edit_ocme/src/ocme/ocme_extract.h +++ b/src/plugins_experimental/edit_ocme/src/ocme/ocme_extract.h @@ -174,49 +174,28 @@ m.face.EnableColor(); typename MeshType::template PerVertexAttributeHandle gPosV = vcg::tri::Allocator::template GetPerVertexAttribute (m,"ocme_gindex"); - if(!vcg::tri::Allocator::IsValidHandle(m,gPosV)) - gPosV = vcg::tri::Allocator::template AddPerVertexAttribute (m,"ocme_gindex"); - // create an attibute that will store the address in ocme for the vertex typename MeshType::template PerVertexAttributeHandle biV = vcg::tri::Allocator::template GetPerVertexAttribute (m,"bi"); - if(!vcg::tri::Allocator::IsValidHandle(m,biV)) - biV = vcg::tri::Allocator::template AddPerVertexAttribute (m,"bi"); // create an attibute that will store if the vertex is locked or not typename MeshType::template PerVertexAttributeHandle lockedV = - vcg::tri::Allocator::template GetPerVertexAttribute (m,"ocme_locked"); - - if(!vcg::tri::Allocator::IsValidHandle(m,lockedV)) - lockedV = vcg::tri::Allocator::template AddPerVertexAttribute (m,"ocme_locked"); + vcg::tri::Allocator::template GetPerVertexAttribute (m,"ocme_locked"); // create an attibute that will store the address in ocme for the face typename MeshType::template PerFaceAttributeHandle gPosF = - vcg::tri::Allocator::template GetPerFaceAttribute (m,"ocme_gindex"); - - if(!vcg::tri::Allocator::IsValidHandle(m,gPosF) ) - gPosF = vcg::tri::Allocator::template AddPerFaceAttribute (m,"ocme_gindex"); + vcg::tri::Allocator::template GetPerFaceAttribute (m,"ocme_gindex"); // create an attibute that will store if the face is locked or not typename MeshType::template PerFaceAttributeHandle lockedF = - vcg::tri::Allocator::template GetPerFaceAttribute (m,"ocme_locked"); - - if(!vcg::tri::Allocator::IsValidHandle(m,lockedF) ) - lockedF = vcg::tri::Allocator::template AddPerFaceAttribute (m,"ocme_locked"); + vcg::tri::Allocator::template GetPerFaceAttribute (m,"ocme_locked"); // create an attibute that will store the ScaleRange of the mesh typename MeshType::template PerMeshAttributeHandle range = - vcg::tri::Allocator::template GetPerMeshAttribute (m,"ocme_range"); - - if(!vcg::tri::Allocator::IsValidHandle(m,range)) - range = vcg::tri::Allocator::template AddPerMeshAttribute (m,"ocme_range"); - + vcg::tri::Allocator::template GetPerMeshAttribute (m,"ocme_range"); typename MeshType::template PerMeshAttributeHandle > sel_cells_attr = - vcg::tri::Allocator::template GetPerMeshAttribute< std::vector > (m,"sel_cells"); - if(!vcg::tri::Allocator::IsValidHandle(m,sel_cells_attr)) - sel_cells_attr = vcg::tri::Allocator::template AddPerMeshAttribute > (m,"sel_cells"); - + vcg::tri::Allocator::template GetPerMeshAttribute< std::vector > (m,"sel_cells"); ScaleRange sr; diff --git a/src/plugins_experimental/filter_vsa/region_growing.h b/src/plugins_experimental/filter_vsa/region_growing.h index 48a6c9ca5..a265d34ef 100755 --- a/src/plugins_experimental/filter_vsa/region_growing.h +++ b/src/plugins_experimental/filter_vsa/region_growing.h @@ -173,12 +173,8 @@ public: // tte an attibute that will store the address in ocme for the vertex attr_r = vcg::tri::Allocator::template GetPerFaceAttribute (*m,"r"); - if(!vcg::tri::Allocator::IsValidHandle(*m,attr_r)) - attr_r = vcg::tri::Allocator::template AddPerFaceAttribute (*m,"r"); attr_r_old = vcg::tri::Allocator::template GetPerFaceAttribute (*m,"r_old"); - if(!vcg::tri::Allocator::IsValidHandle(*m,attr_r_old)) - attr_r_old = vcg::tri::Allocator::template AddPerFaceAttribute (*m,"r_old"); regions.clear();