From 70b2a513738ec5b08dc2d4ed6e5ed93d9478ba5a Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Thu, 26 Apr 2012 10:56:39 +0200 Subject: [PATCH] orbit as template -> viewer OK --- Apps/Examples/viewer.cpp | 10 +- Apps/Examples/viewer.h | 5 +- include/Algo/Export/export.h | 16 +-- include/Algo/Export/export.hpp | 66 +++++----- include/Algo/Geometry/area.h | 20 +-- include/Algo/Geometry/area.hpp | 20 +-- include/Algo/Geometry/basic.h | 8 +- include/Algo/Geometry/boundingbox.h | 2 +- include/Algo/Geometry/centroid.h | 18 +-- include/Algo/Geometry/centroid.hpp | 6 +- include/Algo/Geometry/normal.h | 18 +-- include/Algo/Geometry/normal.hpp | 18 +-- include/Algo/Import/import2tables.h | 2 +- include/Algo/Import/import2tablesSurface.hpp | 62 ++++----- include/Algo/Import/import2tablesVolume.hpp | 6 +- include/Algo/Import/importMesh.hpp | 28 ++--- include/Algo/Import/importMoka.hpp | 14 +-- include/Algo/Import/importNodeEle.hpp | 16 +-- include/Algo/Import/importObjEle.hpp | 16 +-- include/Algo/Import/importTet.hpp | 16 +-- include/Algo/Import/importTs.hpp | 20 ++- include/Algo/Modelisation/polyhedron.h | 25 ++-- include/Algo/Modelisation/polyhedron.hpp | 28 ++--- include/Algo/Render/GL2/mapRender.h | 13 +- include/Algo/Render/GL2/mapRender.hpp | 42 +++---- include/Algo/Render/GL2/topoRender.h | 7 +- include/Algo/Render/GL2/topoRender.hpp | 12 +- include/Topology/generic/attribmap.hpp | 43 +++++++ include/Topology/generic/genericmap.hpp | 123 ++++++++++++++++++ src/Topology/generic/attribmap.cpp | 43 ------- src/Topology/generic/genericmap.cpp | 126 ------------------- 31 files changed, 410 insertions(+), 439 deletions(-) diff --git a/Apps/Examples/viewer.cpp b/Apps/Examples/viewer.cpp index a5fd588b1..8ac97feb2 100644 --- a/Apps/Examples/viewer.cpp +++ b/Apps/Examples/viewer.cpp @@ -201,7 +201,7 @@ void Viewer::importMesh(std::string& filename) if (extension == std::string(".map")) { myMap.loadMapBin(filename); - position = myMap.getAttribute(VERTEX, "position") ; + position = myMap.getAttribute("position") ; } else { @@ -211,7 +211,7 @@ void Viewer::importMesh(std::string& filename) CGoGNerr << "could not import " << filename << CGoGNendl ; return; } - position = myMap.getAttribute(VERTEX, attrNames[0]) ; + position = myMap.getAttribute(attrNames[0]) ; } m_render->initPrimitives(myMap, allDarts, Algo::Render::GL2::POINTS) ; @@ -224,9 +224,9 @@ void Viewer::importMesh(std::string& filename) normalBaseSize = bb.diagSize() / 100.0f ; // vertexBaseSize = normalBaseSize / 5.0f ; - normal = myMap.getAttribute(VERTEX, "normal") ; + normal = myMap.getAttribute("normal") ; if(!normal.isValid()) - normal = myMap.addAttribute(VERTEX, "normal") ; + normal = myMap.addAttribute("normal") ; Algo::Geometry::computeNormalVertices(myMap, position, normal) ; @@ -246,7 +246,7 @@ void Viewer::exportMesh(std::string& filename) Algo::Export::exportOFF(myMap, position, filename.c_str(), allDarts) ; else if (extension.compare(0, 4, std::string(".ply")) == 0) { - std::vector attributes ; + std::vector*> attributes ; attributes.push_back(&position) ; Algo::Export::exportPLYnew(myMap, attributes, filename.c_str(), true, allDarts) ; } diff --git a/Apps/Examples/viewer.h b/Apps/Examples/viewer.h index bc38941e7..89f296aa3 100644 --- a/Apps/Examples/viewer.h +++ b/Apps/Examples/viewer.h @@ -59,6 +59,7 @@ struct PFP: public PFP_STANDARD }; typedef PFP::MAP MAP ; +typedef PFP::VEC3 VEC3 ; class Viewer : public Utils::QT::SimpleQT { @@ -92,8 +93,8 @@ public: bool m_drawNormals ; bool m_drawTopo ; - PFP::TVEC3 position ; - PFP::TVEC3 normal ; + AttributeHandler position ; + AttributeHandler normal ; Algo::Render::GL2::MapRender* m_render ; Algo::Render::GL2::TopoRender* m_topoRender ; diff --git a/include/Algo/Export/export.h b/include/Algo/Export/export.h index b69fe3eab..9187b2e0e 100644 --- a/include/Algo/Export/export.h +++ b/include/Algo/Export/export.h @@ -46,7 +46,7 @@ namespace Export * @return true */ template -bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const bool binary, const FunctorSelect& good = allDarts) ; +bool exportPLY(typename PFP::MAP& map, const AttributeHandler& position, const char* filename, const bool binary, const FunctorSelect& good = allDarts) ; /** * export the map into a PLY file @@ -57,7 +57,7 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons * @return true */ template -bool exportPLYnew(typename PFP::MAP& map, const std::vector& attributeHandlers, const char* filename, const bool binary, const FunctorSelect& good = allDarts) ; +bool exportPLYnew(typename PFP::MAP& map, const std::vector* >& attributeHandlers, const char* filename, const bool binary, const FunctorSelect& good = allDarts) ; /** * export the map into a OFF file @@ -66,7 +66,7 @@ bool exportPLYnew(typename PFP::MAP& map, const std::vector -bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ; +bool exportOFF(typename PFP::MAP& map, const AttributeHandler& position, const char* filename, const FunctorSelect& good = allDarts) ; /** * export the map into a Trian file @@ -75,7 +75,7 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons * @return true */ template -bool exportTrian(typename PFP::MAP& map, const typename PFP::TVEC3& position, char* filename, const FunctorSelect& good = allDarts) ; +bool exportTrian(typename PFP::MAP& map, const AttributeHandler& position, char* filename, const FunctorSelect& good = allDarts) ; /** * export the map into a PLYPTMgeneric file (K. Vanhoey generic format). @@ -90,7 +90,7 @@ bool exportTrian(typename PFP::MAP& map, const typename PFP::TVEC3& position, ch * @return true */ //template -//bool exportPlySLFgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ; +//bool exportPlySLFgeneric(typename PFP::MAP& map, const AttributeHandler& position, const char* filename, const FunctorSelect& good = allDarts) ; /** * export the map into a PLYPTMgeneric file (K. Vanhoey generic format). @@ -105,7 +105,7 @@ bool exportTrian(typename PFP::MAP& map, const typename PFP::TVEC3& position, ch * @return true */ //template -//bool exportPlySLFgenericBin(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ; +//bool exportPlySLFgenericBin(typename PFP::MAP& map, const AttributeHandler& position, const char* filename, const FunctorSelect& good = allDarts) ; /** * export the map into a PLYSLF file (K. Vanhoey generic format). @@ -120,7 +120,7 @@ bool exportTrian(typename PFP::MAP& map, const typename PFP::TVEC3& position, ch * @return true */ template -bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ; +bool exportPlyPTMgeneric(typename PFP::MAP& map, const AttributeHandler& position, const char* filename, const FunctorSelect& good = allDarts) ; /** * export the map into a PLYPTMgeneric file (K. Vanhoey generic format) @@ -132,7 +132,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi * @return true */ template -bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const typename PFP::TVEC3 frame[3], const typename PFP::TVEC3 colorPTM[6], const FunctorSelect& good = allDarts) ; +bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const AttributeHandler& position, const AttributeHandler frame[3], const AttributeHandler colorPTM[6], const FunctorSelect& good = allDarts) ; } // namespace Export diff --git a/include/Algo/Export/export.hpp b/include/Algo/Export/export.hpp index 856add9fc..6cd15ae2b 100644 --- a/include/Algo/Export/export.hpp +++ b/include/Algo/Export/export.hpp @@ -38,7 +38,7 @@ namespace Export { template -bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, bool binary, const FunctorSelect& good) +bool exportPLY(typename PFP::MAP& map, const AttributeHandler& position, const char* filename, bool binary, const FunctorSelect& good) { typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; @@ -67,7 +67,7 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons vertices.reserve(nbDarts/6) ; // Go over all faces - CellMarker markV(map, VERTEX) ; + CellMarker markV(map) ; TraversorF t(map, good) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) { @@ -78,7 +78,7 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next()) { ++degree ; - unsigned int vNum = map.getEmbedding(it) ; + unsigned int vNum = map.template getEmbedding(it) ; if(!markV.isMarked(it)) { markV.mark(it) ; @@ -165,7 +165,7 @@ bool exportPLY(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons } template -bool exportPLYnew(typename PFP::MAP& map, const std::vector& attributeHandlers, const char* filename, bool binary, const FunctorSelect& good) +bool exportPLYnew(typename PFP::MAP& map, const std::vector*>& attributeHandlers, const char* filename, bool binary, const FunctorSelect& good) { typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; @@ -194,7 +194,7 @@ bool exportPLYnew(typename PFP::MAP& map, const std::vector markV(map) ; TraversorF t(map, good) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) { @@ -205,7 +205,7 @@ bool exportPLYnew(typename PFP::MAP& map, const std::vector(it) ; + unsigned int vNum = map.template getEmbedding(it) ; if(!markV.isMarked(it)) { markV.mark(it) ; @@ -241,7 +241,7 @@ bool exportPLYnew(typename PFP::MAP& map, const std::vector::const_iterator attrHandler = attributeHandlers.begin() ; attrHandler != attributeHandlers.end() ; ++attrHandler) + for (typename std::vector* >::const_iterator attrHandler = attributeHandlers.begin() ; attrHandler != attributeHandlers.end() ; ++attrHandler) { if ((*attrHandler)->isValid() && ((*attrHandler)->getOrbit() == VERTEX) ) { @@ -281,7 +281,7 @@ bool exportPLYnew(typename PFP::MAP& map, const std::vector::const_iterator attrHandler = attributeHandlers.begin() ; attrHandler != attributeHandlers.end() ; ++attrHandler) + for (typename std::vector* >::const_iterator attrHandler = attributeHandlers.begin() ; attrHandler != attributeHandlers.end() ; ++attrHandler) if ((*attrHandler)->isValid() && (*attrHandler)->getOrbit() == VERTEX) out << (*(*attrHandler))[vertices[i]] << std::endl ; @@ -298,7 +298,7 @@ bool exportPLYnew(typename PFP::MAP& map, const std::vector::const_iterator attrHandler = attributeHandlers.begin() ; attrHandler != attributeHandlers.end() ; ++attrHandler) + for (typename std::vector*>::const_iterator attrHandler = attributeHandlers.begin() ; attrHandler != attributeHandlers.end() ; ++attrHandler) if ((*attrHandler)->isValid() && (*attrHandler)->getOrbit() == VERTEX) { const typename PFP::VEC3& v = (*(*attrHandler))[vertices[i]] ; @@ -320,7 +320,7 @@ bool exportPLYnew(typename PFP::MAP& map, const std::vector -bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good) +bool exportOFF(typename PFP::MAP& map, const AttributeHandler& position, const char* filename, const FunctorSelect& good) { typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; @@ -342,7 +342,7 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons std::vector vertices ; vertices.reserve(nbDarts/6) ; - CellMarker markV(map, VERTEX) ; + CellMarker markV(map) ; TraversorF t(map, good) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) { @@ -353,7 +353,7 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next()) { ++degree ; - unsigned int vNum = map.getEmbedding(it) ; + unsigned int vNum = map.template getEmbedding(it) ; if(!markV.isMarked(it)) { markV.mark(it) ; @@ -387,13 +387,11 @@ bool exportOFF(typename PFP::MAP& map, const typename PFP::TVEC3& position, cons } template -bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good) +bool exportPlyPTMgeneric(typename PFP::MAP& map, const AttributeHandler& position, const char* filename, const FunctorSelect& good) { typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; - typedef typename PFP::TVEC3 TVEC3; typedef typename PFP::REAL REAL; - typedef typename PFP::TREAL TREAL; std::ofstream out(filename, std::ios::out) ; if (!out.good()) @@ -402,8 +400,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi return false ; } - AutoAttributeHandler tableVertLab(map, VERTEX); - + AutoAttributeHandler tableVertLab(map); unsigned int nbDarts = map.getNbDarts() ; @@ -413,7 +410,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi vertices.reserve(nbDarts/5); // TODO non optimal reservation faces.reserve(nbDarts/3); - CellMarker markV(map, VERTEX); + CellMarker markV(map); TraversorF t(map, good) ; unsigned int lab = 0; unsigned int nbf = 0; @@ -427,7 +424,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi { markV.mark(it); tableVertLab[it] = lab++; - vertices.push_back(map.getEmbedding(it)); + vertices.push_back(map.template getEmbedding(it)); } face.push_back(tableVertLab[it]); } @@ -439,13 +436,13 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi ++nbf; } - TVEC3 frame[3] ; - TVEC3 colorPTM[15] ; + AttributeHandler frame[3] ; + AttributeHandler colorPTM[15] ; frame[0] = map.template getAttribute(VERTEX, "frame_T") ; frame[1] = map.template getAttribute(VERTEX, "frame_B") ; frame[2] = map.template getAttribute(VERTEX, "frame_N") ; - for (unsigned i = 0 ; i < 15 ; ++i) + for (unsigned int i = 0 ; i < 15 ; ++i) { std::stringstream name ; name << "colorPTM_a" << i ; @@ -476,9 +473,9 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi for(unsigned int coefI = 0 ; coefI < nbCoefs ; ++coefI) out << "property float C2_a" << coefI << std::endl ; - TREAL errL2 = map.template getAttribute(VERTEX,"errL2") ; - TREAL errLmax = map.template getAttribute(VERTEX,"errLmax") ; - TREAL stdDev = map.template getAttribute(VERTEX,"stdDev") ; + AttributeHandler errL2 = map.template getAttribute(VERTEX, "errL2") ; + AttributeHandler errLmax = map.template getAttribute(VERTEX, "errLmax") ; + AttributeHandler stdDev = map.template getAttribute(VERTEX, "stdDev") ; if (errL2.isValid()) out << "property float errL2" << std::endl ; if (errLmax.isValid()) @@ -529,13 +526,11 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi } /* template -bool exportPlySLFgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good) +bool exportPlySLFgeneric(typename PFP::MAP& map, const AttributeHandler& position, const char* filename, const FunctorSelect& good) { typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; - typedef typename PFP::TVEC3 TVEC3; typedef typename PFP::REAL REAL; - typedef typename PFP::TREAL TREAL; std::ofstream out(filename, std::ios::out) ; if (!out.good()) @@ -546,7 +541,6 @@ bool exportPlySLFgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi AutoAttributeHandler tableVertLab(map, VERTEX); - unsigned int nbDarts = map.getNbDarts() ; std::vector vertices; @@ -581,7 +575,7 @@ bool exportPlySLFgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi ++nbf; } - TVEC3 frame[3] ; + AttributeHandler frame[3] ; std::vector coefs ; frame[0] = map.template getAttribute(VERTEX, "frame_T") ; @@ -663,13 +657,11 @@ bool exportPlySLFgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& posi } template -bool exportPlySLFgenericBin(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good) +bool exportPlySLFgenericBin(typename PFP::MAP& map, const AttributeHandler& position, const char* filename, const FunctorSelect& good) { typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; - typedef typename PFP::TVEC3 TVEC3; typedef typename PFP::REAL REAL; - typedef typename PFP::TREAL TREAL; std::ofstream out(filename, std::ios::out) ; if (!out.good()) @@ -806,7 +798,7 @@ bool exportPlySLFgenericBin(typename PFP::MAP& map, const typename PFP::TVEC3& p */ template -bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const typename PFP::TVEC3 frame[3], const typename PFP::TVEC3 colorPTM[6], const FunctorSelect& good) +bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const AttributeHandler& position, const AttributeHandler frame[3], const AttributeHandler colorPTM[6], const FunctorSelect& good) { typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; @@ -818,7 +810,7 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P return false ; } - AutoAttributeHandler tableVertLab(map, VERTEX); + AutoAttributeHandler tableVertLab(map); unsigned int nbDarts = map.getNbDarts() ; @@ -828,7 +820,7 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P vertices.reserve(nbDarts/5); // TODO non optimal reservation faces.reserve(nbDarts/3); - CellMarker markV(map, VERTEX); + CellMarker markV(map); TraversorF t(map, good) ; unsigned int lab = 0; unsigned int nbf = 0; @@ -842,7 +834,7 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P { markV.mark(it); tableVertLab[it] = lab++; - vertices.push_back(map.getEmbedding(it)); + vertices.push_back(map.template getEmbedding(it)); } face.push_back(tableVertLab[it]); } diff --git a/include/Algo/Geometry/area.h b/include/Algo/Geometry/area.h index db9714031..9ae36b788 100644 --- a/include/Algo/Geometry/area.h +++ b/include/Algo/Geometry/area.h @@ -35,34 +35,34 @@ namespace Geometry { template -typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; +typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const AttributeHandler& position) ; template -typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; +typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const AttributeHandler& position) ; template -typename PFP::REAL totalArea(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; +typename PFP::REAL totalArea(typename PFP::MAP& map, const AttributeHandler& position, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; template -typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; +typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const AttributeHandler& position) ; template -typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; +typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Dart d, const AttributeHandler& position) ; template -typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; +typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const AttributeHandler& position) ; template -void computeAreaFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& face_area, const FunctorSelect& select = allDarts) ; +void computeAreaFaces(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& face_area, const FunctorSelect& select = allDarts) ; template -void computeOneRingAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select = allDarts) ; +void computeOneRingAreaVertices(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& vertex_area, const FunctorSelect& select = allDarts) ; template -void computeBarycentricAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select = allDarts) ; +void computeBarycentricAreaVertices(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& vertex_area, const FunctorSelect& select = allDarts) ; template -void computeVoronoiAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select = allDarts) ; +void computeVoronoiAreaVertices(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& vertex_area, const FunctorSelect& select = allDarts) ; } // namespace Geometry diff --git a/include/Algo/Geometry/area.hpp b/include/Algo/Geometry/area.hpp index 5fd35dbf3..e07db166b 100644 --- a/include/Algo/Geometry/area.hpp +++ b/include/Algo/Geometry/area.hpp @@ -37,7 +37,7 @@ namespace Geometry { template -typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typename PFP::VEC3 p1 = position[d] ; typename PFP::VEC3 p2 = position[map.phi1(d)] ; @@ -47,7 +47,7 @@ typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const typename P } template -typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typedef typename PFP::VEC3 VEC3 ; @@ -69,7 +69,7 @@ typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const typename } template -typename PFP::REAL totalArea(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& select, unsigned int thread) +typename PFP::REAL totalArea(typename PFP::MAP& map, const AttributeHandler& position, const FunctorSelect& select, unsigned int thread) { typename PFP::REAL area(0) ; TraversorF t(map, select) ; @@ -79,7 +79,7 @@ typename PFP::REAL totalArea(typename PFP::MAP& map, const typename PFP::TVEC3& } template -typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typename PFP::REAL area(0) ; Traversor2VF t(map, d) ; @@ -89,7 +89,7 @@ typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const typen } template -typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typename PFP::REAL area(0) ; Traversor2VF t(map, d) ; @@ -99,7 +99,7 @@ typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Dart d, const t } template -typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typename PFP::REAL area(0) ; Traversor2VF t(map, d) ; @@ -127,7 +127,7 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Dart d, const typen } template -void computeAreaFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& face_area, const FunctorSelect& select) +void computeAreaFaces(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& face_area, const FunctorSelect& select) { TraversorF t(map, select) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) @@ -135,7 +135,7 @@ void computeAreaFaces(typename PFP::MAP& map, const typename PFP::TVEC3& positio } template -void computeOneRingAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select) +void computeOneRingAreaVertices(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& vertex_area, const FunctorSelect& select) { TraversorV t(map, select) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) @@ -143,7 +143,7 @@ void computeOneRingAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC } template -void computeBarycentricAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select) +void computeBarycentricAreaVertices(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& vertex_area, const FunctorSelect& select) { TraversorV t(map, select) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) @@ -151,7 +151,7 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const typename PFP:: } template -void computeVoronoiAreaVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& vertex_area, const FunctorSelect& select) +void computeVoronoiAreaVertices(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& vertex_area, const FunctorSelect& select) { TraversorV t(map, select) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) diff --git a/include/Algo/Geometry/basic.h b/include/Algo/Geometry/basic.h index 22e598646..2292d7600 100644 --- a/include/Algo/Geometry/basic.h +++ b/include/Algo/Geometry/basic.h @@ -40,7 +40,7 @@ namespace Geometry * vectorOutOfDart return a dart from the position of vertex attribute of d to the position of vertex attribute of phi1(d) */ template -inline typename PFP::VEC3 vectorOutOfDart(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +inline typename PFP::VEC3 vectorOutOfDart(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typename PFP::VEC3 vec = position[map.phi1(d)] ; vec -= position[d] ; @@ -48,14 +48,14 @@ inline typename PFP::VEC3 vectorOutOfDart(typename PFP::MAP& map, Dart d, const } template -inline typename PFP::REAL edgeLength(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +inline typename PFP::REAL edgeLength(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typename PFP::VEC3 v = vectorOutOfDart(map, d, position) ; return v.norm() ; } template -inline float angle(typename PFP::MAP& map, Dart d1, Dart d2, const typename PFP::TVEC3& position) +inline float angle(typename PFP::MAP& map, Dart d1, Dart d2, const AttributeHandler& position) { typename PFP::VEC3 v1 = vectorOutOfDart(map, d1, position) ; typename PFP::VEC3 v2 = vectorOutOfDart(map, d2, position) ; @@ -63,7 +63,7 @@ inline float angle(typename PFP::MAP& map, Dart d1, Dart d2, const typename PFP: } template -bool isTriangleObtuse(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +bool isTriangleObtuse(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { return Geom::isTriangleObtuse(position[d], position[map.phi1(d)], position[map.phi_1(d)]) ; } diff --git a/include/Algo/Geometry/boundingbox.h b/include/Algo/Geometry/boundingbox.h index 8a5622b5d..235ca119c 100644 --- a/include/Algo/Geometry/boundingbox.h +++ b/include/Algo/Geometry/boundingbox.h @@ -39,7 +39,7 @@ namespace Geometry { template -Geom::BoundingBox computeBoundingBox(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& select = allDarts) +Geom::BoundingBox computeBoundingBox(typename PFP::MAP& map, const AttributeHandler& position, const FunctorSelect& select = allDarts) { Geom::BoundingBox bb ; TraversorV t(map, select) ; diff --git a/include/Algo/Geometry/centroid.h b/include/Algo/Geometry/centroid.h index 501e7b2db..61485dca0 100644 --- a/include/Algo/Geometry/centroid.h +++ b/include/Algo/Geometry/centroid.h @@ -59,9 +59,9 @@ EMB volumeCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs); * @param position the vector of attribute */ template -typename PFP::VEC3 volumeCentroid(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::VEC3 volumeCentroid(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { - return volumeCentroidGen(map, d, position); + return volumeCentroidGen, typename PFP::VEC3>(map, d, position); } /** @@ -85,9 +85,9 @@ EMB faceCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& attributs); * @param position the vector of attribute */ template -typename PFP::VEC3 faceCentroid(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::VEC3 faceCentroid(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { - return faceCentroidGen(map, d, position); + return faceCentroidGen, typename PFP::VEC3>(map, d, position); } /** @@ -110,19 +110,19 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at * @param position the vector of attribute */ template -typename PFP::VEC3 vertexNeighborhoodCentroid(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::VEC3 vertexNeighborhoodCentroid(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { - return vertexNeighborhoodCentroidGen(map, d, position); + return vertexNeighborhoodCentroidGen, typename PFP::VEC3>(map, d, position); } template -void computeCentroidVolumes(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vol_centroid, const FunctorSelect& select = allDarts) ; +void computeCentroidVolumes(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& vol_centroid, const FunctorSelect& select = allDarts) ; template -void computeCentroidFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_centroid, const FunctorSelect& select = allDarts) ; +void computeCentroidFaces(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& face_centroid, const FunctorSelect& select = allDarts) ; template -void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vertex_centroid, const FunctorSelect& select = allDarts) ; +void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& vertex_centroid, const FunctorSelect& select = allDarts) ; } // namespace Geometry diff --git a/include/Algo/Geometry/centroid.hpp b/include/Algo/Geometry/centroid.hpp index c5b01186f..455680845 100644 --- a/include/Algo/Geometry/centroid.hpp +++ b/include/Algo/Geometry/centroid.hpp @@ -86,7 +86,7 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at } template -void computeCentroidVolumes(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vol_centroid, const FunctorSelect& select) +void computeCentroidVolumes(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& vol_centroid, const FunctorSelect& select) { TraversorW t(map, select) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) @@ -94,7 +94,7 @@ void computeCentroidVolumes(typename PFP::MAP& map, const typename PFP::TVEC3& p } template -void computeCentroidFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_centroid, const FunctorSelect& select) +void computeCentroidFaces(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& face_centroid, const FunctorSelect& select) { TraversorF t(map, select) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) @@ -102,7 +102,7 @@ void computeCentroidFaces(typename PFP::MAP& map, const typename PFP::TVEC3& pos } template -void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& vertex_centroid, const FunctorSelect& select) +void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& vertex_centroid, const FunctorSelect& select) { TraversorV t(map, select) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) diff --git a/include/Algo/Geometry/normal.h b/include/Algo/Geometry/normal.h index e17258ed1..6002dd5be 100644 --- a/include/Algo/Geometry/normal.h +++ b/include/Algo/Geometry/normal.h @@ -37,22 +37,22 @@ namespace Geometry { template -typename PFP::VEC3 triangleNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; +typename PFP::VEC3 triangleNormal(typename PFP::MAP& map, Dart d, const AttributeHandler& position) ; template -typename PFP::VEC3 newellNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position); +typename PFP::VEC3 newellNormal(typename PFP::MAP& map, Dart d, const AttributeHandler& position); template -typename PFP::VEC3 faceNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; +typename PFP::VEC3 faceNormal(typename PFP::MAP& map, Dart d, const AttributeHandler& position) ; template -typename PFP::VEC3 vertexNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; +typename PFP::VEC3 vertexNormal(typename PFP::MAP& map, Dart d, const AttributeHandler& position) ; template -typename PFP::VEC3 vertexBorderNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ; +typename PFP::VEC3 vertexBorderNormal(typename PFP::MAP& map, Dart d, const AttributeHandler& position) ; template -void computeNormalFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_normal, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; +void computeNormalFaces(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& face_normal, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; /** * compute normals of vertices @@ -63,13 +63,13 @@ void computeNormalFaces(typename PFP::MAP& map, const typename PFP::TVEC3& posit * @ param th the thread number */ template -void computeNormalVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& normal, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; +void computeNormalVertices(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& normal, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; template -typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ; +typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Dart d, AttributeHandler& position) ; template -void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& angles, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; +void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& angles, const FunctorSelect& select = allDarts, unsigned int thread = 0) ; } // namespace Geometry diff --git a/include/Algo/Geometry/normal.hpp b/include/Algo/Geometry/normal.hpp index b7ccaab78..0f2526be6 100644 --- a/include/Algo/Geometry/normal.hpp +++ b/include/Algo/Geometry/normal.hpp @@ -40,7 +40,7 @@ namespace Geometry { template -typename PFP::VEC3 triangleNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::VEC3 triangleNormal(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typename PFP::VEC3 N = Geom::triangleNormal(position[d], position[map.phi1(d)], position[map.phi_1(d)]) ; N.normalize() ; @@ -48,7 +48,7 @@ typename PFP::VEC3 triangleNormal(typename PFP::MAP& map, Dart d, const typename } template -typename PFP::VEC3 newellNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::VEC3 newellNormal(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typename PFP::VEC3 N(0); @@ -67,7 +67,7 @@ typename PFP::VEC3 newellNormal(typename PFP::MAP& map, Dart d, const typename P } template -typename PFP::VEC3 faceNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::VEC3 faceNormal(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { if(map.faceDegree(d) == 3) return triangleNormal(map, d, position) ; @@ -90,7 +90,7 @@ typename PFP::VEC3 faceNormal(typename PFP::MAP& map, Dart d, const typename PFP } template -typename PFP::VEC3 vertexNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::VEC3 vertexNormal(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typedef typename PFP::VEC3 VEC3 ; @@ -114,7 +114,7 @@ typename PFP::VEC3 vertexNormal(typename PFP::MAP& map, Dart d, const typename P } template -typename PFP::VEC3 vertexBorderNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::VEC3 vertexBorderNormal(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { assert(map.dimension() == 3); @@ -148,7 +148,7 @@ typename PFP::VEC3 vertexBorderNormal(typename PFP::MAP& map, Dart d, const type } template -void computeNormalFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_normal, const FunctorSelect& select, unsigned int thread) +void computeNormalFaces(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& face_normal, const FunctorSelect& select, unsigned int thread) { TraversorF trav(map, select, thread); for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) @@ -156,7 +156,7 @@ void computeNormalFaces(typename PFP::MAP& map, const typename PFP::TVEC3& posit } template -void computeNormalVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& normal, const FunctorSelect& select, unsigned int thread) +void computeNormalVertices(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& normal, const FunctorSelect& select, unsigned int thread) { TraversorV trav(map, select, thread); for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) @@ -164,7 +164,7 @@ void computeNormalVertices(typename PFP::MAP& map, const typename PFP::TVEC3& po } template -typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) +typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Dart d, const AttributeHandler& position) { typedef typename PFP::VEC3 VEC3 ; @@ -195,7 +195,7 @@ typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Dart } template -void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& angles, const FunctorSelect& select, unsigned int thread) +void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const AttributeHandler& position, AttributeHandler& angles, const FunctorSelect& select, unsigned int thread) { TraversorE trav(map, select, thread); for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) diff --git a/include/Algo/Import/import2tables.h b/include/Algo/Import/import2tables.h index 7c6ec5530..95453da56 100644 --- a/include/Algo/Import/import2tables.h +++ b/include/Algo/Import/import2tables.h @@ -86,7 +86,7 @@ protected: static ImportSurfacique::ImportType getFileType(const std::string& filename); #ifdef WITH_ASSIMP - void extractMeshRec(AttributeContainer& container, AttributeHandler& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo); + void extractMeshRec(AttributeContainer& container, AttributeHandler& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo); #endif public: diff --git a/include/Algo/Import/import2tablesSurface.hpp b/include/Algo/Import/import2tablesSurface.hpp index 8abe8dd94..e56877a1e 100644 --- a/include/Algo/Import/import2tablesSurface.hpp +++ b/include/Algo/Import/import2tablesSurface.hpp @@ -144,14 +144,14 @@ bool MeshTablesSurface::importMesh(const std::string& filename, std::vector template bool MeshTablesSurface::importTrian(const std::string& filename, std::vector& attrNames) { - AttributeHandler positions = m_map.template getAttribute(VERTEX, "position") ; + AttributeHandler positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute(VERTEX, "position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; - AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = m_map.template getAttributeContainer() ; // open file std::ifstream fp(filename.c_str(), std::ios::in); @@ -211,14 +211,14 @@ bool MeshTablesSurface::importTrian(const std::string& filename, std::vecto template bool MeshTablesSurface::importTrianBinGz(const std::string& filename, std::vector& attrNames) { - AttributeHandler positions = m_map.template getAttribute(VERTEX, "position") ; + AttributeHandler positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute(VERTEX, "position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; - AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = m_map.template getAttributeContainer() ; // open file igzstream fs(filename.c_str(), std::ios::in|std::ios::binary); @@ -281,14 +281,14 @@ bool MeshTablesSurface::importTrianBinGz(const std::string& filename, std:: template bool MeshTablesSurface::importOff(const std::string& filename, std::vector& attrNames) { - AttributeHandler positions = m_map.template getAttribute(VERTEX, "position") ; + AttributeHandler positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute(VERTEX, "position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; - AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = m_map.template getAttributeContainer() ; // open file std::ifstream fp(filename.c_str(), std::ios::in); @@ -380,16 +380,16 @@ bool MeshTablesSurface::importOff(const std::string& filename, std::vector< template bool MeshTablesSurface::importMeshBin(const std::string& filename, std::vector& attrNames) { - AttributeHandler positions = m_map.template getAttribute(VERTEX, "position") ; + AttributeHandler positions = m_map.template getAttribute("position") ; if (!positions.isValid()) { - positions = m_map.template addAttribute(VERTEX, "position") ; + positions = m_map.template addAttribute("position") ; } attrNames.push_back(positions.name()) ; - AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = m_map.template getAttributeContainer() ; // open file std::ifstream fp(filename.c_str(), std::ios::in | std::ios::binary); @@ -451,14 +451,14 @@ bool MeshTablesSurface::importMeshBin(const std::string& filename, std::vec template bool MeshTablesSurface::importObj(const std::string& filename, std::vector& attrNames) { - AttributeHandler positions = m_map.template getAttribute(VERTEX, "position") ; + AttributeHandler positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute(VERTEX, "position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; - AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = m_map.template getAttributeContainer() ; // open file std::ifstream fp(filename.c_str(), std::ios::binary); @@ -575,14 +575,14 @@ bool MeshTablesSurface::importObj(const std::string& filename, std::vector< template bool MeshTablesSurface::importPly(const std::string& filename, std::vector& attrNames) { - AttributeHandler positions = m_map.template getAttribute(VERTEX, "position") ; + AttributeHandler positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute(VERTEX, "position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; - AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = m_map.template getAttributeContainer() ; PlyImportData pid; @@ -592,11 +592,11 @@ bool MeshTablesSurface::importPly(const std::string& filename, std::vector< return false; } - AttributeHandler colors = m_map.template getAttribute(VERTEX, "color") ; + AttributeHandler colors = m_map.template getAttribute("color") ; if (pid.hasColors()) { if(!colors.isValid()) - colors = m_map.template addAttribute(VERTEX, "color") ; + colors = m_map.template addAttribute("color") ; attrNames.push_back(colors.name()) ; } @@ -1152,7 +1152,7 @@ bool MeshTablesSurface::importAHEM(const std::string& filename, std::vector // Allocate vertices - AttributeContainer& vxContainer = m_map.getAttributeContainer(VERTEX); + AttributeContainer& vxContainer = m_map.template getAttributeContainer(); std::vector verticesId; verticesId.resize(hdr.meshHdr.vxCount); @@ -1192,10 +1192,10 @@ bool MeshTablesSurface::importAHEM(const std::string& filename, std::vector // Read positions - AttributeHandler position = m_map.template getAttribute(VERTEX, "position") ; + AttributeHandler position = m_map.template getAttribute("position") ; if (!position.isValid()) - position = m_map.template addAttribute(VERTEX, "position") ; + position = m_map.template addAttribute("position") ; attrNames.push_back(position.name()) ; @@ -1237,7 +1237,7 @@ bool MeshTablesSurface::importAHEM(const std::string& filename, std::vector #ifdef WITH_ASSIMP template -void MeshTablesSurface::extractMeshRec(AttributeContainer& container, AttributeHandler& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo) +void MeshTablesSurface::extractMeshRec(AttributeContainer& container, AttributeHandler& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo) { struct aiMatrix4x4 prev; @@ -1293,8 +1293,8 @@ void MeshTablesSurface::extractMeshRec(AttributeContainer& container, Attri template bool MeshTablesSurface::importASSIMP(const std::string& filename, std::vector& attrNames) { - AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ; - AttributeHandler positions = m_map.template addAttribute(VERTEX, "position") ; + AttributeContainer& container = m_map.template getAttributeContainer() ; + AttributeHandler positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; m_nbVertices = 0; @@ -1335,9 +1335,9 @@ bool MeshTablesSurface::mergeCloseVertices() // init grid with null ptrs for (unsigned int i=0; i positions = m_map.template getAttribute(VERTEX, "position"); + AttributeHandler positions = m_map.template getAttribute("position"); // compute BB Geom::BoundingBox bb(positions[ positions.begin() ]) ; @@ -1354,8 +1354,8 @@ bool MeshTablesSurface::mergeCloseVertices() bb.addPoint( bb.max() + one); bbsize = (bb.max() - bb.min()); - AutoAttributeHandler gridIndex(m_map,VERTEX, "gridIndex"); - AutoAttributeHandler newIndices(m_map,VERTEX, "newIndices"); + AutoAttributeHandler gridIndex(m_map, "gridIndex"); + AutoAttributeHandler newIndices(m_map, "newIndices"); // Store each vertex in the grid and store voxel index in vertex attribute for (unsigned int i = positions.begin(); i != positions.end(); positions.next(i)) @@ -1442,7 +1442,7 @@ bool MeshTablesSurface::mergeCloseVertices() } // delete embeddings - AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = m_map.template getAttributeContainer() ; for (unsigned int i = positions.begin(); i != positions.end(); positions.next(i)) { diff --git a/include/Algo/Import/import2tablesVolume.hpp b/include/Algo/Import/import2tablesVolume.hpp index ce9be86df..7f269a67c 100644 --- a/include/Algo/Import/import2tablesVolume.hpp +++ b/include/Algo/Import/import2tablesVolume.hpp @@ -70,14 +70,14 @@ bool MeshTablesVolume::importMesh(const std::string& filename, std::vector< template bool MeshTablesVolume::importTet(const std::string& filename, std::vector& attrNames, float scaleFactor) { - AttributeHandler positions = m_map.template getAttribute(VERTEX, "position") ; + AttributeHandler positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute(VERTEX, "position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; - AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = m_map.template getAttributeContainer() ; //open file std::ifstream fp(filename.c_str(), std::ios::in); diff --git a/include/Algo/Import/importMesh.hpp b/include/Algo/Import/importMesh.hpp index 5bd247efe..589a4c1d8 100644 --- a/include/Algo/Import/importMesh.hpp +++ b/include/Algo/Import/importMesh.hpp @@ -39,7 +39,7 @@ namespace Import template bool importMesh(typename PFP::MAP& map, MeshTablesSurface& mts) { - AutoAttributeHandler< NoMathIONameAttribute< std::vector > > vecDartsPerVertex(map, VERTEX, "incidents"); + AutoAttributeHandler< NoMathIONameAttribute< std::vector >, VERTEX > vecDartsPerVertex(map, "incidents"); unsigned nbf = mts.getNbFaces(); int index = 0; @@ -78,9 +78,9 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface& mts) { unsigned int em = edgesBuffer[j]; // get embedding - FunctorSetEmb fsetemb(map, VERTEX, em); + FunctorSetEmb fsetemb(map, em); // foreach_dart_of_orbit_in_parent(&map, VERTEX, d, fsetemb) ; - map.foreach_dart_of_orbit( PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb); + map.template foreach_dart_of_orbit(d, fsetemb); m.mark(d) ; // mark on the fly to unmark on second loop vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction @@ -98,11 +98,11 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface& mts) // darts incident to end vertex of edge std::vector& vec = vecDartsPerVertex[map.phi1(d)]; - unsigned int embd = map.getEmbedding(d); + unsigned int embd = map.template getEmbedding(d); Dart good_dart = NIL; for (typename std::vector::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it) { - if (map.getEmbedding(map.phi1(*it)) == embd) + if (map.template getEmbedding(map.phi1(*it)) == embd) good_dart = *it; } @@ -124,7 +124,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface& mts) unsigned int nbH = map.closeMap(); CGoGNout << "Map closed (" << nbBoundaryEdges << " boundary edges / " << nbH << " holes)" << CGoGNendl; // ensure bijection between topo and embedding - map.bijectiveOrbitEmbedding(VERTEX); + map.template bijectiveOrbitEmbedding(); } return true ; @@ -133,7 +133,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface& mts) template bool importMeshSToV(typename PFP::MAP& map, MeshTablesSurface& mts, float dist) { - AutoAttributeHandler< NoMathIONameAttribute< std::vector > > vecDartsPerVertex(map, VERTEX, "incidents"); + AutoAttributeHandler< NoMathIONameAttribute< std::vector >, VERTEX > vecDartsPerVertex(map, "incidents"); unsigned nbf = mts.getNbFaces(); int index = 0; // buffer for tempo faces (used to remove degenerated edges) @@ -142,7 +142,7 @@ bool importMeshSToV(typename PFP::MAP& map, MeshTablesSurface& mts, float d DartMarkerNoUnmark m(map) ; - AttributeHandler position = map.template getAttribute(VERTEX, "position"); + AttributeHandler position = map.template getAttribute("position"); std::vector backEdgesBuffer(mts.getNbVertices(), EMBNULL); // for each face of table -> create a prism @@ -178,22 +178,22 @@ bool importMeshSToV(typename PFP::MAP& map, MeshTablesSurface& mts, float d if(backEdgesBuffer[em] == EMBNULL) { - unsigned int emn = map.newCell(VERTEX); + unsigned int emn = map.template newCell(); map.copyCell(emn, em); backEdgesBuffer[em] = emn; position[emn] += typename PFP::VEC3(0,0,dist); } - FunctorSetEmb fsetemb(map, VERTEX, em); + FunctorSetEmb fsetemb(map, em); //foreach_dart_of_orbit_in_parent(&map, VERTEX, d, fsetemb) ; - map.foreach_dart_of_orbit(PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb); + map.foreach_dart_of_orbit(d, fsetemb); //Embed the other base face Dart d2 = map.phi1(map.phi1(map.phi2(d))); unsigned int em2 = backEdgesBuffer[em]; - FunctorSetEmb fsetemb2(map, VERTEX, em2); + FunctorSetEmb fsetemb2(map, em2); //foreach_dart_of_orbit_in_parent(&map, VERTEX, d2, fsetemb2) ; - map.foreach_dart_of_orbit(PFP::MAP::ORBIT_IN_PARENT(VERTEX), d2, fsetemb2); + map.foreach_dart_of_orbit(d2, fsetemb2); m.mark(d) ; // mark on the fly to unmark on second loop vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction @@ -241,7 +241,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume& mtv) { typedef typename PFP::VEC3 VEC3 ; - AutoAttributeHandler< NoMathIONameAttribute< std::vector > > vecDartsPerVertex(map, VERTEX, "incidents"); + AutoAttributeHandler< NoMathIONameAttribute< std::vector >, VERTEX > vecDartsPerVertex(map, "incidents"); return false; } diff --git a/include/Algo/Import/importMoka.hpp b/include/Algo/Import/importMoka.hpp index bad7e6836..f57bc647b 100644 --- a/include/Algo/Import/importMoka.hpp +++ b/include/Algo/Import/importMoka.hpp @@ -49,13 +49,13 @@ bool importMoka(typename PFP::MAP& gmap, const std::string& filename, std::vecto return false; } - AttributeHandler position = gmap.template getAttribute(VERTEX, "position"); + AttributeHandler position = gmap.template getAttribute("position"); if (!position.isValid()) - position = gmap.template addAttribute(VERTEX, "position"); + position = gmap.template addAttribute("position"); attrNames.push_back(position.name()); - AttributeContainer& vertexContainer = gmap.getAttributeContainer(VERTEX) ; + AttributeContainer& vertexContainer = gmap.template getAttributeContainer() ; std::string ligne; std::getline (fp, ligne); @@ -70,10 +70,10 @@ bool importMoka(typename PFP::MAP& gmap, const std::string& filename, std::vecto // ignore 2nd line std::getline (fp, ligne); - AttributeHandler att_beta0 = gmap.template getAttribute(DART, "beta0"); - AttributeHandler att_beta1 = gmap.template getAttribute(DART, "beta1"); - AttributeHandler att_beta2 = gmap.template getAttribute(DART, "beta2"); - AttributeHandler att_beta3 = gmap.template getAttribute(DART, "beta3"); + AttributeHandler att_beta0 = gmap.template getAttribute("beta0"); + AttributeHandler att_beta1 = gmap.template getAttribute("beta1"); + AttributeHandler att_beta2 = gmap.template getAttribute("beta2"); + AttributeHandler att_beta3 = gmap.template getAttribute("beta3"); std::map map_dart_emb; diff --git a/include/Algo/Import/importNodeEle.hpp b/include/Algo/Import/importNodeEle.hpp index d826caf41..1d4ebedc7 100644 --- a/include/Algo/Import/importNodeEle.hpp +++ b/include/Algo/Import/importNodeEle.hpp @@ -39,13 +39,13 @@ bool importNodeWithELERegions(typename PFP::MAP& map, const std::string& filenam { typedef typename PFP::VEC3 VEC3; - AttributeHandler position = map.template addAttribute(VERTEX, "position") ; + AttributeHandler position = map.template addAttribute("position") ; attrNames.push_back(position.name()) ; - AttributeContainer& container = map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = map.template getAttributeContainer() ; unsigned int m_nbVertices = 0, m_nbFaces = 0, m_nbEdges = 0, m_nbVolumes = 0; - AutoAttributeHandler< NoMathIONameAttribute< std::vector > > vecDartsPerVertex(map, VERTEX, "incidents"); + AutoAttributeHandler< NoMathIONameAttribute< std::vector >, VERTEX > vecDartsPerVertex(map, "incidents"); //open file std::ifstream fnode(filenameNode.c_str(), std::ios::in); @@ -163,8 +163,8 @@ bool importNodeWithELERegions(typename PFP::MAP& map, const std::string& filenam // Embed three vertices for(unsigned int j = 0 ; j < 3 ; ++j) { - FunctorSetEmb fsetemb(map, VERTEX, verticesID[pt[2-j]]); - map.foreach_dart_of_orbit(PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb); + FunctorSetEmb fsetemb(map, verticesID[pt[2-j]]); + map.foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction Dart dd = d; @@ -182,8 +182,8 @@ bool importNodeWithELERegions(typename PFP::MAP& map, const std::string& filenam //Embed the last vertex d = map.phi_1(map.phi2(d)); - FunctorSetEmb fsetemb(map, VERTEX, verticesID[pt[3]]); - map.foreach_dart_of_orbit( PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb); + FunctorSetEmb fsetemb(map, verticesID[pt[3]]); + map.foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction Dart dd = d; @@ -225,7 +225,7 @@ bool importNodeWithELERegions(typename PFP::MAP& map, const std::string& filenam } else { - m.unmarkOrbit(PFP::MAP::ORBIT_IN_PARENT(FACE), d); + m.unmarkOrbit(d); ++nbBoundaryFaces; } } diff --git a/include/Algo/Import/importObjEle.hpp b/include/Algo/Import/importObjEle.hpp index 772682b04..6ae9c43e0 100644 --- a/include/Algo/Import/importObjEle.hpp +++ b/include/Algo/Import/importObjEle.hpp @@ -39,14 +39,14 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename { typedef typename PFP::VEC3 VEC3; - AttributeHandler position = map.template addAttribute(VERTEX, "position") ; + AttributeHandler position = map.template addAttribute("position") ; attrNames.push_back(position.name()) ; - AttributeContainer& container = map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = map.template getAttributeContainer() ; unsigned int m_nbVertices = 0, m_nbFaces = 0, m_nbEdges = 0, m_nbVolumes = 0; - AutoAttributeHandler< NoMathIONameAttribute< std::vector > > vecDartsPerVertex(map, VERTEX, "incidents"); + AutoAttributeHandler< NoMathIONameAttribute< std::vector >, VERTEX > vecDartsPerVertex(map, "incidents"); // open files std::ifstream foff(filenameOFF.c_str(), std::ios::in); @@ -158,8 +158,8 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename // Embed three vertices for(unsigned int j = 0 ; j < 3 ; ++j) { - FunctorSetEmb fsetemb(map, VERTEX, verticesID[pt[2-j]]); - map.foreach_dart_of_orbit( PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb); + FunctorSetEmb fsetemb(map, verticesID[pt[2-j]]); + map.foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction Dart dd = d; @@ -177,8 +177,8 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename //Embed the last vertex d = map.phi_1(map.phi2(d)); - FunctorSetEmb fsetemb(map, VERTEX, verticesID[pt[3]]); - map.foreach_dart_of_orbit( PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb); + FunctorSetEmb fsetemb(map, verticesID[pt[3]]); + map.foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction Dart dd = d; @@ -220,7 +220,7 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename } else { - m.unmarkOrbit(PFP::MAP::ORBIT_IN_PARENT(FACE), d); + m.unmarkOrbit(d); ++nbBoundaryFaces; } } diff --git a/include/Algo/Import/importTet.hpp b/include/Algo/Import/importTet.hpp index f038aa35b..09489eb7d 100644 --- a/include/Algo/Import/importTet.hpp +++ b/include/Algo/Import/importTet.hpp @@ -39,13 +39,13 @@ bool importTet(typename PFP::MAP& map, const std::string& filename, std::vector< { typedef typename PFP::VEC3 VEC3; - AttributeHandler position = map.template addAttribute(VERTEX, "position") ; + AttributeHandler position = map.template addAttribute("position") ; attrNames.push_back(position.name()) ; - AttributeContainer& container = map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = map.template getAttributeContainer() ; unsigned int m_nbVertices = 0, m_nbVolumes = 0; - AutoAttributeHandler< NoMathIONameAttribute< std::vector > > vecDartsPerVertex(map, VERTEX, "incidents"); + AutoAttributeHandler< NoMathIONameAttribute< std::vector >, VERTEX > vecDartsPerVertex(map, "incidents"); //open file std::ifstream fp(filename.c_str(), std::ios::in); @@ -128,8 +128,8 @@ bool importTet(typename PFP::MAP& map, const std::string& filename, std::vector< // Embed three "base" vertices for(unsigned int j = 0 ; j < 3 ; ++j) { - FunctorSetEmb fsetemb(map, VERTEX, verticesID[pt[2-j]]); - map.foreach_dart_of_orbit( PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb); + FunctorSetEmb fsetemb(map, verticesID[pt[2-j]]); + map.foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction @@ -147,8 +147,8 @@ bool importTet(typename PFP::MAP& map, const std::string& filename, std::vector< //Embed the last "top" vertex d = map.phi_1(map.phi2(d)); - FunctorSetEmb fsetemb(map, VERTEX, verticesID[pt[3]]); - map.foreach_dart_of_orbit( PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb); + FunctorSetEmb fsetemb(map, verticesID[pt[3]]); + map.foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction @@ -189,7 +189,7 @@ bool importTet(typename PFP::MAP& map, const std::string& filename, std::vector< } else { - m.unmarkOrbit(PFP::MAP::ORBIT_IN_PARENT(FACE), d); + m.unmarkOrbit(d); ++nbBoundaryFaces; } } diff --git a/include/Algo/Import/importTs.hpp b/include/Algo/Import/importTs.hpp index 305de8145..254895cb7 100644 --- a/include/Algo/Import/importTs.hpp +++ b/include/Algo/Import/importTs.hpp @@ -43,16 +43,16 @@ bool importTs(typename PFP::MAP& map, const std::string& filename, std::vector position = map.template addAttribute(VERTEX, "position") ; + AttributeHandler position = map.template addAttribute("position") ; attrNames.push_back(position.name()) ; - AttributeHandler scalaire = map.template addAttribute(VERTEX, "scalar"); + AttributeHandler scalaire = map.template addAttribute("scalar"); attrNames.push_back(scalaire.name()) ; - AttributeContainer& container = map.getAttributeContainer(VERTEX) ; + AttributeContainer& container = map.template getAttributeContainer() ; unsigned int m_nbVertices = 0, m_nbVolumes = 0; - AutoAttributeHandler< NoMathIONameAttribute< std::vector > > vecDartsPerVertex(map, VERTEX, "incidents"); + AutoAttributeHandler< NoMathIONameAttribute< std::vector >, VERTEX > vecDartsPerVertex(map, "incidents"); // open file std::ifstream fp(filename.c_str(), std::ios::in); @@ -75,7 +75,6 @@ bool importTs(typename PFP::MAP& map, const std::string& filename, std::vector fsetemb(map, VERTEX, verticesID[pt[2-j]]); - map.foreach_dart_of_orbit( PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb); - + FunctorSetEmb fsetemb(map, verticesID[pt[2-j]]); + map.foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction Dart dd = d; @@ -155,8 +153,8 @@ bool importTs(typename PFP::MAP& map, const std::string& filename, std::vector fsetemb(map, VERTEX, verticesID[pt[3]]); - map.foreach_dart_of_orbit( PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb); + FunctorSetEmb fsetemb(map, verticesID[pt[3]]); + map.foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction Dart dd = d; @@ -196,7 +194,7 @@ bool importTs(typename PFP::MAP& map, const std::string& filename, std::vector(d); ++nbBoundaryFaces; } } diff --git a/include/Algo/Modelisation/polyhedron.h b/include/Algo/Modelisation/polyhedron.h index 8a988cd8d..6e8a95303 100644 --- a/include/Algo/Modelisation/polyhedron.h +++ b/include/Algo/Modelisation/polyhedron.h @@ -61,9 +61,8 @@ enum { NONE, GRID, CUBE, CYLINDER, CONE, SPHERE, TORE, COMPOSED }; // Dart triangleFan_topo(typename PFP::MAP& the_map, int n); - /** - * Unsex the Umbrella aroud a vertex, close the hole and then + * Unsew the Umbrella aroud a vertex, close the hole and then * create a symetric to construct a polyedron * @param d a dart from the vertex */ @@ -73,8 +72,6 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 positi - - /** * create a n-sided pyramid */ @@ -93,9 +90,6 @@ Dart createPrism(typename PFP::MAP& map, unsigned int nbSides); template Dart createDiamond(typename PFP::MAP& map, unsigned int nbSides); - - - /** * create a tetrahedron */ @@ -145,6 +139,7 @@ template class Polyhedron { typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; public: enum {NONE,GRID, CUBE, CYLINDER, CONE, SPHERE, TORE, COMPOSED}; @@ -184,9 +179,9 @@ protected: bool m_bottom_closed; - typename PFP::TVEC3& m_positions; + AttributeHandler& m_positions; - typename PFP::VEC3 m_center; + VEC3 m_center; /** * return the dart of next vertex when traversing the boundary of a quad or trifan grid @@ -207,7 +202,7 @@ public: * @param map the map in which we want to work * @param idPositions id of attribute position */ - Polyhedron(MAP& map, typename PFP::TVEC3& position): + Polyhedron(MAP& map, AttributeHandler& position): m_map(map), m_kind(NONE), m_nx(-1), m_ny(-1), m_nz(-1), @@ -228,17 +223,17 @@ public: /* * get the reference dart */ - Dart getDart() { return m_dart;} + Dart getDart() { return m_dart; } /* * get the center of Polyhedron */ - const typename PFP::VEC3& getCenter() { return m_center;} + const typename PFP::VEC3& getCenter() { return m_center; } /** * get the table of darts (one per vertex) */ - std::vector& getVertexDarts() { return m_tableVertDarts;} + std::vector& getVertexDarts() { return m_tableVertDarts; } /** * Create a 2D grid @@ -350,7 +345,7 @@ public: * @param maxHeight height to reach * @param turns number of turn */ - void embedHelicoid( float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1); + void embedHelicoid(float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1); /** * transform the Polyhedron with transformation matrice @@ -362,7 +357,7 @@ public: * mark all darts of the Polyhedron * @param m the CellMarker(VERTEX) to use */ - void mark(CellMarker& m); + void mark(CellMarker& m); /** * mark all embedded vertices of the Polyhedron diff --git a/include/Algo/Modelisation/polyhedron.hpp b/include/Algo/Modelisation/polyhedron.hpp index 7eb5f2574..5bfa7a4cb 100644 --- a/include/Algo/Modelisation/polyhedron.hpp +++ b/include/Algo/Modelisation/polyhedron.hpp @@ -284,14 +284,14 @@ Polyhedron::Polyhedron(const Polyhedron& p1, const Polyhedron& p2 m_top_closed(false), m_bottom_closed(false), m_positions(p1.m_positions) { - if (&(p1.map) != &(p2.map)) + if (&(p1.m_map) != &(p2.m_map)) { CGoGNerr << "Warning, can not merge to Polyhedrons of different maps"<< CGoGNendl; } m_tableVertDarts.reserve(p1.m_tableVertDarts.size() + p2.m_tableVertDarts.size()); // can be too much but ... - typename PFP::VEC3 center(0); + VEC3 center(0); for(typename std::vector::const_iterator di = p1.m_tableVertDarts.begin(); di != p1.m_tableVertDarts.end(); ++di) { @@ -302,13 +302,13 @@ Polyhedron::Polyhedron(const Polyhedron& p1, const Polyhedron& p2 // O(n2) pas terrible !! for(typename std::vector::const_iterator di = p2.m_tableVertDarts.begin(); di != p2.m_tableVertDarts.end(); ++di) { - unsigned int em = m_map.getEmbedding(*di, VERTEX); + unsigned int em = m_map.template getEmbedding(*di); typename std::vector::const_iterator dj=p1.m_tableVertDarts.begin(); bool found = false; while ((dj !=p1.m_tableVertDarts.end()) && (!found)) { - unsigned int xm = m_map.getEmbedding(*dj, VERTEX); + unsigned int xm = m_map.template getEmbedding(*dj); if (xm == em) found = true; else @@ -343,7 +343,7 @@ Dart Polyhedron::grid_topo(unsigned int x, unsigned int y) { for (unsigned int j = 1; j <= x; ++j) { - Dart d = m_map.newFace(4,false); + Dart d = m_map.newFace(4, false); m_tableVertDarts.push_back(d); if (j == x) m_tableVertDarts.push_back(m_map.phi1(d)); @@ -368,7 +368,7 @@ Dart Polyhedron::grid_topo(unsigned int x, unsigned int y) Dart d = m_tableVertDarts[pos]; Dart e = m_tableVertDarts[pos-(x+1)]; e = m_map.phi1(m_map.phi1(e)); - m_map.sewFaces(d,e,false); + m_map.sewFaces(d, e, false); } if (j > 0) // sew with preceeding column { @@ -377,7 +377,7 @@ Dart Polyhedron::grid_topo(unsigned int x, unsigned int y) d = m_map.phi_1(d); Dart e = m_tableVertDarts[pos-1]; e = m_map.phi1(e); - m_map.sewFaces(d,e,false); + m_map.sewFaces(d, e, false); } } } @@ -1076,7 +1076,7 @@ void Polyhedron::transform(const Geom::Matrix44f& matrice) } template -void Polyhedron::mark(CellMarker& m) +void Polyhedron::mark(CellMarker& m) { for(typename std::vector::iterator di = m_tableVertDarts.begin(); di != m_tableVertDarts.end(); ++di) { @@ -1084,16 +1084,6 @@ void Polyhedron::mark(CellMarker& m) } } -//template -//void Polyhedron::markEmbVertices(Mark m) -//{ -// AttributeHandler markers(VERTEX << 24, m_map); -// for(typename std::vector::iterator di = m_tableVertDarts.begin(); di != m_tableVertDarts.end(); ++di) -// { -// markers[*di].setMark(m); -// } -//} - template void Polyhedron::embedTwistedStrip(float radius_min, float radius_max, float turns) { @@ -1114,7 +1104,7 @@ void Polyhedron::embedTwistedStrip(float radius_min, float radius_max, flo VEC3 pos(r*cos(alpha*float(i)), r*sin(alpha*float(i)), rw*sin(beta*float(i))); unsigned int em = m_positions.insert(pos); Dart d = m_tableVertDarts[i*(m_nx+1)+j]; - m_map.embedOrbit(d, em); + m_map.template embedOrbit(d, em); } } } diff --git a/include/Algo/Render/GL2/mapRender.h b/include/Algo/Render/GL2/mapRender.h index d6cad7666..f86e8e631 100644 --- a/include/Algo/Render/GL2/mapRender.h +++ b/include/Algo/Render/GL2/mapRender.h @@ -80,7 +80,6 @@ enum bufferIndex class MapRender { - protected: /** * vbo buffers @@ -165,16 +164,16 @@ protected: void addTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices) ; template - inline void addEarTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices, const typename PFP::TVEC3* position); + inline void addEarTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices, const AttributeHandler* position); template float computeEarAngle(const typename PFP::VEC3& P1, const typename PFP::VEC3& P2, const typename PFP::VEC3& P3, const typename PFP::VEC3& normalPoly); template - bool computeEarIntersection(const typename PFP::TVEC3& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly); + bool computeEarIntersection(const AttributeHandler& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly); template - void recompute2Ears(const typename PFP::TVEC3& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly, VPMS& ears, bool convex); + void recompute2Ears(const AttributeHandler& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly, VPMS& ears, bool convex); template bool inTriangle(const VEC3& P, const VEC3& normal, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc); @@ -185,9 +184,9 @@ public: * @param tableIndices the table where indices are stored */ template - void initTriangles(typename PFP::MAP& map, const FunctorSelect& good, std::vector& tableIndices, const typename PFP::TVEC3* position, unsigned int thread = 0) ; + void initTriangles(typename PFP::MAP& map, const FunctorSelect& good, std::vector& tableIndices, const AttributeHandler* position, unsigned int thread = 0) ; template - void initTrianglesOptimized(typename PFP::MAP& map, const FunctorSelect& good, std::vector& tableIndices, const typename PFP::TVEC3* position, unsigned int thread = 0) ; + void initTrianglesOptimized(typename PFP::MAP& map, const FunctorSelect& good, std::vector& tableIndices, const AttributeHandler* position, unsigned int thread = 0) ; /** * creation of indices table of lines (optimized order) @@ -220,7 +219,7 @@ public: void initPrimitives(typename PFP::MAP& map, const FunctorSelect& good, int prim, bool optimized = true, unsigned int thread = 0) ; template - void initPrimitives(typename PFP::MAP& map, const FunctorSelect& good, int prim, const typename PFP::TVEC3* position, bool optimized = true, unsigned int thread = 0) ; + void initPrimitives(typename PFP::MAP& map, const FunctorSelect& good, int prim, const AttributeHandler* position, bool optimized = true, unsigned int thread = 0) ; /** * initialization of the VBO indices primitives diff --git a/include/Algo/Render/GL2/mapRender.hpp b/include/Algo/Render/GL2/mapRender.hpp index dd84d2dff..98bda0ed1 100644 --- a/include/Algo/Render/GL2/mapRender.hpp +++ b/include/Algo/Render/GL2/mapRender.hpp @@ -71,7 +71,7 @@ bool MapRender::inTriangle(const VEC3& P, const VEC3& normal, const VEC3& Ta, c } template -void MapRender::recompute2Ears(const typename PFP::TVEC3& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly, VPMS& ears, bool convex) +void MapRender::recompute2Ears(const AttributeHandler& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly, VPMS& ears, bool convex) { VertexPoly* vprev = vp->prev; VertexPoly* vp2 = vp->next; @@ -151,7 +151,7 @@ float MapRender::computeEarAngle(const typename PFP::VEC3& P1, const typename PF } template -bool MapRender::computeEarIntersection(const typename PFP::TVEC3& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly) +bool MapRender::computeEarIntersection(const AttributeHandler& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly) { VertexPoly* endV = vp->prev; @@ -175,12 +175,12 @@ bool MapRender::computeEarIntersection(const typename PFP::TVEC3& position, Vert } template -inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices, const typename PFP::TVEC3* pos) +inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices, const AttributeHandler* pos) { bool(*fn_pt1)(VertexPoly*,VertexPoly*) = &(MapRender::cmpVP); VPMS ears(fn_pt1); - const typename PFP::TVEC3& position = *pos ; + const AttributeHandler& position = *pos ; // compute normal to polygon typename PFP::VEC3 normalPoly = Algo::Geometry::newellNormal(map, d, position); @@ -195,12 +195,12 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector(a)]; - typename PFP::VEC3 P2 = position[map.getEmbedding(b)]; - typename PFP::VEC3 P3 = position[map.getEmbedding(c)]; + typename PFP::VEC3 P1 = position[map.template getEmbedding(a)]; + typename PFP::VEC3 P2 = position[map.template getEmbedding(b)]; + typename PFP::VEC3 P3 = position[map.template getEmbedding(c)]; float val = computeEarAngle(P1, P2, P3, normalPoly); - VertexPoly* vp = new VertexPoly(map.getEmbedding(b), val, (P3-P1).norm2(), vpp); + VertexPoly* vp = new VertexPoly(map.template getEmbedding(b), val, (P3-P1).norm2(), vpp); if (vp->value < 5.0f) nbe++; @@ -288,16 +288,16 @@ inline void MapRender::addTri(typename PFP::MAP& map, Dart d, std::vector(d)); - tableIndices.push_back(map.getEmbedding(b)); - tableIndices.push_back(map.getEmbedding(c)); + tableIndices.push_back(map.template getEmbedding(d)); + tableIndices.push_back(map.template getEmbedding(b)); + tableIndices.push_back(map.template getEmbedding(c)); b = c; c = map.phi1(b); } while (c != d); } template -void MapRender::initTriangles(typename PFP::MAP& map, const FunctorSelect& good, std::vector& tableIndices, const typename PFP::TVEC3* position, unsigned int thread) +void MapRender::initTriangles(typename PFP::MAP& map, const FunctorSelect& good, std::vector& tableIndices, const AttributeHandler* position, unsigned int thread) { tableIndices.reserve(4 * map.getNbDarts() / 3); @@ -321,7 +321,7 @@ void MapRender::initTriangles(typename PFP::MAP& map, const FunctorSelect& good, } template -void MapRender::initTrianglesOptimized(typename PFP::MAP& map, const FunctorSelect& good, std::vector& tableIndices, const typename PFP::TVEC3* position, unsigned int thread) +void MapRender::initTrianglesOptimized(typename PFP::MAP& map, const FunctorSelect& good, std::vector& tableIndices, const AttributeHandler* position, unsigned int thread) { #define LIST_SIZE 20 DartMarker m(map, thread); @@ -404,8 +404,8 @@ void MapRender::initLines(typename PFP::MAP& map, const FunctorSelect& good, std TraversorE trav(map, good, thread); for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) { - tableIndices.push_back(map.getEmbedding(d)); - tableIndices.push_back(map.getEmbedding(map.phi1(d))); + tableIndices.push_back(map.template getEmbedding(d)); + tableIndices.push_back(map.template getEmbedding(map.phi1(d))); } } @@ -419,8 +419,8 @@ void MapRender::initBoundaries(typename PFP::MAP& map, const FunctorSelect& good { if (map.isBoundaryEdge(d)) { - tableIndices.push_back(map.getEmbedding(d)); - tableIndices.push_back(map.getEmbedding(map.phi1(d))); + tableIndices.push_back(map.template getEmbedding(d)); + tableIndices.push_back(map.template getEmbedding(map.phi1(d))); } } } @@ -451,9 +451,9 @@ void MapRender::initLinesOptimized(typename PFP::MAP& map, const FunctorSelect& if (!m.isMarked(ee)) { if(good(ee)) - tableIndices.push_back(map.getEmbedding(ee)); + tableIndices.push_back(map.template getEmbedding(ee)); if(good(f)) - tableIndices.push_back(map.getEmbedding(map.phi1(ee))); + tableIndices.push_back(map.template getEmbedding(map.phi1(ee))); m.markOrbit(f); bound.push_back(f); @@ -481,7 +481,7 @@ void MapRender::initPoints(typename PFP::MAP& map, const FunctorSelect& good, st TraversorV trav(map, good, thread); for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) - tableIndices.push_back(map.getEmbedding(d)); + tableIndices.push_back(map.template getEmbedding(d)); } template @@ -491,7 +491,7 @@ void MapRender::initPrimitives(typename PFP::MAP& map, const FunctorSelect& good } template -void MapRender::initPrimitives(typename PFP::MAP& map, const FunctorSelect& good, int prim, const typename PFP::TVEC3* position, bool optimized, unsigned int thread) +void MapRender::initPrimitives(typename PFP::MAP& map, const FunctorSelect& good, int prim, const AttributeHandler* position, bool optimized, unsigned int thread) { std::vector tableIndices; diff --git a/include/Algo/Render/GL2/topoRender.h b/include/Algo/Render/GL2/topoRender.h index 791a58fb1..fbe25320e 100644 --- a/include/Algo/Render/GL2/topoRender.h +++ b/include/Algo/Render/GL2/topoRender.h @@ -235,14 +235,13 @@ public: Dart picking(typename PFP::MAP& map, int x, int y, const FunctorSelect& good=allDarts); template - void updateData(typename PFP::MAP& map, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good = allDarts); + void updateData(typename PFP::MAP& map, const AttributeHandler& positions, float ke, float kf, const FunctorSelect& good = allDarts); template - void updateDataMap(typename PFP::MAP& map, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good = allDarts); + void updateDataMap(typename PFP::MAP& map, const AttributeHandler& positions, float ke, float kf, const FunctorSelect& good = allDarts); template - void updateDataGMap(typename PFP::MAP& map, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good = allDarts); - + void updateDataGMap(typename PFP::MAP& map, const AttributeHandler& positions, float ke, float kf, const FunctorSelect& good = allDarts); /** * render to svg struct diff --git a/include/Algo/Render/GL2/topoRender.hpp b/include/Algo/Render/GL2/topoRender.hpp index 076f69385..76d40bde6 100644 --- a/include/Algo/Render/GL2/topoRender.hpp +++ b/include/Algo/Render/GL2/topoRender.hpp @@ -32,16 +32,18 @@ namespace CGoGN { + namespace Algo { + namespace Render { + namespace GL2 { - template -void TopoRender::updateData(typename PFP::MAP& map, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good) +void TopoRender::updateData(typename PFP::MAP& map, const AttributeHandler& positions, float ke, float kf, const FunctorSelect& good) { Map2* ptrMap2 = dynamic_cast(&map); if (ptrMap2 != NULL) @@ -56,8 +58,7 @@ void TopoRender::updateData(typename PFP::MAP& map, const typename PFP::TVEC3& p } template -//void TopoRenderMapD::updateData(typename PFP::MAP& map, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good) -void TopoRender::updateDataMap(typename PFP::MAP& mapx, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good) +void TopoRender::updateDataMap(typename PFP::MAP& mapx, const AttributeHandler& positions, float ke, float kf, const FunctorSelect& good) { Map2& map = reinterpret_cast(mapx); @@ -200,8 +201,7 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const typename PFP::TVEC } template -//void TopoRenderGMap::updateData(typename PFP::MAP& map, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good) -void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const typename PFP::TVEC3& positions, float ke, float kf, const FunctorSelect& good) +void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const AttributeHandler& positions, float ke, float kf, const FunctorSelect& good) { GMap2& map = dynamic_cast(mapx); diff --git a/include/Topology/generic/attribmap.hpp b/include/Topology/generic/attribmap.hpp index 2d6c96630..96b357810 100644 --- a/include/Topology/generic/attribmap.hpp +++ b/include/Topology/generic/attribmap.hpp @@ -88,5 +88,48 @@ inline unsigned int AttribMap::getNbCells(unsigned int orbit) return this->m_attribs[orbit].size() ; } +/**************************************** + * UTILITIES * + ****************************************/ + +template +unsigned int AttribMap::computeIndexCells(AttributeHandler& idx) +{ + AttributeContainer& cont = m_attribs[ORBIT] ; + unsigned int cpt = 0 ; + for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i)) + idx[i] = cpt++ ; + return cpt ; +} + +template +void AttribMap::bijectiveOrbitEmbedding() +{ + assert(isOrbitEmbedded(ORBIT) || !"Invalid parameter: orbit not embedded") ; + + AttributeHandler counter = addAttribute("tmpCounter") ; + counter.setAllValues(int(0)) ; + + DartMarker mark(*this) ; + for(Dart d = begin(); d != end(); next(d)) + { + if(!mark.isMarked(d)) + { + mark.markOrbit(d) ; + unsigned int emb = getEmbedding(d) ; + if (emb != EMBNULL) + { + if (counter[d] > 0) + { + unsigned int newEmb = embedNewCell(d) ; + copyCell(newEmb, emb) ; + } + counter[d]++ ; + } + } + } + + removeAttribute(counter) ; +} } // namespace CGoGN diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index 469a40e82..b04a3f24d 100644 --- a/include/Topology/generic/genericmap.hpp +++ b/include/Topology/generic/genericmap.hpp @@ -22,6 +22,9 @@ * * *******************************************************************************/ +#include "Topology/generic/dartmarker.h" +#include "Topology/generic/traversorCell.h" + namespace CGoGN { @@ -268,6 +271,31 @@ inline unsigned int GenericMap::getEmbedding(Dart d) return (*m_embeddings[ORBIT])[d_index] ; } +template +void GenericMap::setDartEmbedding(Dart d, unsigned int emb) +{ + assert(isOrbitEmbedded(ORBIT) || !"Invalid parameter: orbit not embedded"); + + unsigned int old = getEmbedding(d); + + if (old == emb) // if same emb + return; // nothing to do + + if (old != EMBNULL) // if different + { + if(m_attribs[ORBIT].unrefLine(old)) // then unref the old emb + { + for (unsigned int t = 0; t < m_nbThreads; ++t) // clear the markers if it was the + (*m_markTables[ORBIT][t])[old].clear(); // last unref of the line + } + } + + if (emb != EMBNULL) + m_attribs[ORBIT].refLine(emb); // ref the new emb + + (*m_embeddings[ORBIT])[dartIndex(d)] = emb ; // finally affect the embedding to the dart +} + template inline void GenericMap::copyDartEmbedding(Dart dest, Dart src) { @@ -350,6 +378,38 @@ inline AttributeMultiVector* GenericMap::getEmbeddingAttributeVect return m_embeddings[ORBIT] ; } +template +bool GenericMap::registerAttribute(const std::string &nameType) +{ + RegisteredBaseAttribute* ra = new RegisteredAttribute; + if (ra == NULL) + { + CGoGNerr << "Erreur enregistrement attribut" << CGoGNendl; + return false; + } + + ra->setTypeName(nameType); + + m_attributes_registry_map->insert(std::pair(nameType,ra)); + return true; +} + +template +void GenericMap::initOrbitEmbedding(bool realloc) +{ + assert(isOrbitEmbedded(ORBIT) || !"Invalid parameter: orbit not embedded") ; + DartMarker mark(*this) ; + for(Dart d = begin(); d != end(); next(d)) + { + if(!mark.isMarked(d)) + { + mark.markOrbit(d) ; + if(realloc || getEmbedding(d) == EMBNULL) + embedNewCell(d) ; + } + } +} + /**************************************** * DARTS TRAVERSALS * ****************************************/ @@ -388,6 +448,69 @@ inline void GenericMap::next(Dart& d) const m_attribs[DART].next(d.index) ; } +template +bool GenericMap::foreach_dart_of_orbit(Dart d, FunctorType& f, unsigned int thread) +{ + switch(ORBIT) + { +// case DART: return f(d); +// case VERTEX: return foreach_dart_of_vertex(d, f, thread); +// case EDGE: return foreach_dart_of_edge(d, f, thread); +// case ORIENTED_FACE: return foreach_dart_of_oriented_face(d, f, thread); +// case FACE: return foreach_dart_of_face(d, f, thread); +// case VOLUME: return foreach_dart_of_volume(d, f, thread); + + case DART: return f(d); + case VERTEX: return foreach_dart_of_vertex(d, f, thread); + case EDGE: return foreach_dart_of_edge(d, f, thread); + case FACE: return foreach_dart_of_face(d, f, thread); + case VOLUME: return foreach_dart_of_volume(d, f, thread); + case VERTEX1: return foreach_dart_of_vertex1(d, f, thread); + case EDGE1: return foreach_dart_of_edge1(d, f, thread); + case VERTEX2: return foreach_dart_of_vertex2(d, f, thread); + case EDGE2: return foreach_dart_of_edge2(d, f, thread); + case FACE2: return foreach_dart_of_face2(d, f, thread); + default: assert(!"Cells of this dimension are not handled");break; + } + return false; +} + +template +bool GenericMap::foreach_orbit(FunctorType& fonct, const FunctorSelect& good, unsigned int thread) +{ + TraversorCell trav(*this, good, true, thread); + bool found = false; + + for (Dart d = trav.begin(); !found && d != trav.end(); d = trav.next()) + { + if ((fonct)(d)) + found = true; + } + return found; +} + +template +unsigned int GenericMap::getNbOrbits(const FunctorSelect& good) +{ + FunctorCount fcount; + foreach_orbit(fcount, good); + return fcount.getNb(); +} + +template +void GenericMap::boundaryMarkOrbit(Dart d) +{ + FunctorMark fm(*this, m_boundaryMarker, m_markTables[DART][0]) ; + foreach_dart_of_orbit(d, fm, 0) ; +} + +template +void GenericMap::boundaryUnmarkOrbit(Dart d) +{ + FunctorUnmark fm(*this, m_boundaryMarker, m_markTables[DART][0]) ; + foreach_dart_of_orbit(d, fm, 0) ; +} + /**************************************** * TOPOLOGICAL ATTRIBUTES MANAGEMENT * ****************************************/ diff --git a/src/Topology/generic/attribmap.cpp b/src/Topology/generic/attribmap.cpp index 2cad73a8d..5c47c224a 100644 --- a/src/Topology/generic/attribmap.cpp +++ b/src/Topology/generic/attribmap.cpp @@ -23,7 +23,6 @@ *******************************************************************************/ #include "Topology/generic/attribmap.h" -#include "Topology/generic/autoAttributeHandler.h" #include "Topology/generic/dartmarker.h" namespace CGoGN @@ -58,47 +57,5 @@ void AttribMap::clear(bool removeAttrib) init() ; } -/**************************************** - * UTILITIES * - ****************************************/ - -template -unsigned int AttribMap::computeIndexCells(AttributeHandler& idx) -{ - AttributeContainer& cont = m_attribs[ORBIT] ; - unsigned int cpt = 0 ; - for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i)) - idx[i] = cpt++ ; - return cpt ; -} - -template -void AttribMap::bijectiveOrbitEmbedding() -{ - assert(isOrbitEmbedded(ORBIT) || !"Invalid parameter: orbit not embedded") ; - - AutoAttributeHandler counter(*this) ; - counter.setAllValues(int(0)) ; - - DartMarker mark(*this) ; - for(Dart d = begin(); d != end(); next(d)) - { - if(!mark.isMarked(d)) - { - mark.markOrbit(d) ; - unsigned int emb = getEmbedding(d) ; - if (emb != EMBNULL) - { - if (counter[d] > 0) - { - unsigned int newEmb = embedNewCell(d) ; - copyCell(newEmb, emb) ; - } - counter[d]++ ; - } - } - } -} - } // namespace CGoGN diff --git a/src/Topology/generic/genericmap.cpp b/src/Topology/generic/genericmap.cpp index 440595916..4e15a40eb 100644 --- a/src/Topology/generic/genericmap.cpp +++ b/src/Topology/generic/genericmap.cpp @@ -24,7 +24,6 @@ #include "Topology/generic/genericmap.h" #include "Topology/generic/attributeHandler.h" -#include "Topology/generic/dartmarker.h" #include "Topology/generic/traversorCell.h" #include "Geometry/vector_gen.h" @@ -241,35 +240,6 @@ void GenericMap::removeLevel() } } -/**************************************** - * EMBEDDING MANAGEMENT * - ****************************************/ - -template -void GenericMap::setDartEmbedding(Dart d, unsigned int emb) -{ - assert(isOrbitEmbedded(ORBIT) || !"Invalid parameter: orbit not embedded"); - - unsigned int old = getEmbedding(d); - - if (old == emb) // if same emb - return; // nothing to do - - if (old != EMBNULL) // if different - { - if(m_attribs[ORBIT].unrefLine(old)) // then unref the old emb - { - for (unsigned int t = 0; t < m_nbThreads; ++t) // clear the markers if it was the - (*m_markTables[ORBIT][t])[old].clear(); // last unref of the line - } - } - - if (emb != EMBNULL) - m_attribs[ORBIT].refLine(emb); // ref the new emb - - (*m_embeddings[ORBIT])[dartIndex(d)] = emb ; // finally affect the embedding to the dart -} - /**************************************** * ATTRIBUTES MANAGEMENT * ****************************************/ @@ -305,38 +275,6 @@ void GenericMap::setDartEmbedding(Dart d, unsigned int emb) // } //} -template -bool GenericMap::registerAttribute(const std::string &nameType) -{ - RegisteredBaseAttribute* ra = new RegisteredAttribute; - if (ra == NULL) - { - CGoGNerr << "Erreur enregistrement attribut" << CGoGNendl; - return false; - } - - ra->setTypeName(nameType); - - m_attributes_registry_map->insert(std::pair(nameType,ra)); - return true; -} - -template -void GenericMap::initOrbitEmbedding(bool realloc) -{ - assert(isOrbitEmbedded(ORBIT) || !"Invalid parameter: orbit not embedded") ; - DartMarker mark(*this) ; - for(Dart d = begin(); d != end(); next(d)) - { - if(!mark.isMarked(d)) - { - mark.markOrbit(d) ; - if(realloc || getEmbedding(d) == EMBNULL) - embedNewCell(d) ; - } - } -} - void GenericMap::viewAttributesTables() { std::cout << "======================="<< std::endl ; @@ -847,70 +785,6 @@ bool GenericMap::foreach_dart(FunctorType& f, const FunctorSelect& good) return false; } -template -bool GenericMap::foreach_dart_of_orbit(Dart d, FunctorType& f, unsigned int thread) -{ - switch(ORBIT) - { -// case DART: return f(d); -// case VERTEX: return foreach_dart_of_vertex(d, f, thread); -// case EDGE: return foreach_dart_of_edge(d, f, thread); -// case ORIENTED_FACE: return foreach_dart_of_oriented_face(d, f, thread); -// case FACE: return foreach_dart_of_face(d, f, thread); -// case VOLUME: return foreach_dart_of_volume(d, f, thread); - - case DART: return f(d); - case VERTEX: return foreach_dart_of_vertex(d, f, thread); - case EDGE: return foreach_dart_of_edge(d, f, thread); - case FACE: return foreach_dart_of_face(d, f, thread); - case VOLUME: return foreach_dart_of_volume(d, f, thread); - case VERTEX1: return foreach_dart_of_vertex1(d, f, thread); - case EDGE1: return foreach_dart_of_edge1(d, f, thread); - case VERTEX2: return foreach_dart_of_vertex2(d, f, thread); - case EDGE2: return foreach_dart_of_edge2(d, f, thread); - case FACE2: return foreach_dart_of_face2(d, f, thread); - default: assert(!"Cells of this dimension are not handled");break; - - } - return false; -} - -template -bool GenericMap::foreach_orbit(FunctorType& fonct, const FunctorSelect& good, unsigned int thread) -{ - TraversorCell trav(*this, good, true, thread); - bool found = false; - - for (Dart d = trav.begin(); !found && d != trav.end(); d = trav.next()) - { - if ((fonct)(d)) - found = true; - } - return found; -} - -template -unsigned int GenericMap::getNbOrbits(const FunctorSelect& good) -{ - FunctorCount fcount; - foreach_orbit(fcount, good); - return fcount.getNb(); -} - -template -void GenericMap::boundaryMarkOrbit(Dart d) -{ - FunctorMark fm(*this, m_boundaryMarker, m_markTables[DART][0]) ; - foreach_dart_of_orbit(d, fm, 0) ; -} - -template -void GenericMap::boundaryUnmarkOrbit(Dart d) -{ - FunctorUnmark fm(*this, m_boundaryMarker, m_markTables[DART][0]) ; - foreach_dart_of_orbit(d, fm, 0) ; -} - void GenericMap::boundaryUnmarkAll() { AttributeContainer& cont = getAttributeContainer() ; -- GitLab