From 437409f697371c7b5de09691731eb161c71c85ac Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Tue, 18 Feb 2014 17:55:24 +0100 Subject: [PATCH] first successfully compiled program !! --- Apps/Examples/clipping.cpp | 10 +- Apps/Examples/clipping.h | 10 +- Apps/Examples/concave_rendering.cpp | 3 +- Apps/Examples/extrusionView.cpp | 3 +- Apps/Examples/mcmesh.h | 3 +- Apps/Examples/simpleGMap2.h | 3 +- Apps/Examples/simpleGMap3.cpp | 4 +- Apps/Examples/simpleGMap3.h | 7 +- Apps/Examples/texturesExample.cpp | 18 +-- Apps/Examples/texturesExample.h | 2 + include/Algo/Geometry/boundingbox.h | 2 +- include/Algo/Geometry/laplacian.h | 40 +++--- include/Algo/Geometry/laplacian.hpp | 70 +++++---- include/Algo/Import/import.hpp | 52 ++++--- include/Algo/Import/import2tables.h | 16 ++- include/Algo/Import/import2tablesSurface.hpp | 119 +++++++-------- include/Algo/Import/import2tablesVolume.hpp | 15 +- include/Algo/Import/importMSH.hpp | 17 +-- include/Algo/Import/importNAS.hpp | 47 +++--- include/Algo/Import/importObjTex.h | 70 +++++---- include/Algo/Import/importObjTex.hpp | 131 ++++------------- include/Algo/Import/importVBGZ.hpp | 21 ++- include/Algo/Import/importVTU.hpp | 32 ++--- include/Algo/MC/marchingcube.h | 16 +-- include/Algo/MC/marchingcube.hpp | 125 ++++++++-------- include/Algo/Modelisation/extrusion.h | 45 ++++-- include/Algo/Modelisation/extrusion.hpp | 132 +++++++++++------ include/Algo/Modelisation/polyhedron.h | 6 +- include/Algo/Modelisation/polyhedron.hpp | 100 ++++++------- include/Algo/Modelisation/subdivision.h | 14 +- include/Algo/Modelisation/subdivision.hpp | 95 +++++++----- include/Algo/Modelisation/subdivision3.h | 16 +-- include/Algo/Modelisation/subdivision3.hpp | 136 ++++++++++-------- include/Algo/Modelisation/triangulation.h | 9 +- include/Algo/Modelisation/triangulation.hpp | 42 +++--- include/Algo/Render/GL1/topo_render.h | 9 +- include/Algo/Render/GL1/topo_render.hpp | 67 +++++---- include/Algo/Render/GL2/mapRender.h | 14 +- include/Algo/Render/GL2/mapRender.hpp | 76 +++++----- include/Algo/Render/GL2/topo3PrimalRender.h | 20 +-- include/Algo/Render/GL2/topo3PrimalRender.hpp | 42 +++--- include/Algo/Render/GL2/topo3Render.h | 24 ++-- include/Algo/Render/GL2/topo3Render.hpp | 120 +++++++--------- include/Algo/Render/GL2/topoPrimalRender.h | 20 +-- include/Algo/Render/GL2/topoPrimalRender.hpp | 16 +-- include/Algo/Render/GL2/topoRender.h | 22 +-- include/Algo/Render/GL2/topoRender.hpp | 53 +++---- include/Algo/Render/SVG/mapSVGRender.h | 8 +- include/Algo/Render/SVG/mapSVGRender.hpp | 8 +- include/Algo/Tiling/Surface/hexagonal.h | 16 +-- include/Algo/Tiling/Surface/hexagonal.hpp | 2 +- include/Algo/Tiling/Surface/square.h | 32 +++-- include/Algo/Tiling/Surface/square.hpp | 16 +-- include/Algo/Tiling/Surface/triangular.h | 15 +- include/Algo/Tiling/Surface/triangular.hpp | 2 +- include/Algo/Tiling/Volume/cubic.h | 17 +-- include/Algo/Tiling/Volume/cubic.hpp | 8 +- include/Algo/Tiling/tiling.h | 19 ++- include/Algo/Tiling/tiling.hpp | 21 ++- .../Topology/generic/autoAttributeHandler.h | 10 +- include/Topology/generic/dartmarker.h | 4 +- include/Topology/generic/genericmap.h | 12 +- include/Topology/generic/genericmap.hpp | 3 - include/Topology/generic/mapMono.h | 2 +- include/Topology/generic/mapMono.hpp | 5 +- include/Topology/generic/mapMulti.h | 2 +- include/Topology/generic/mapMulti.hpp | 31 +++- include/Topology/gmap/gmap3.hpp | 4 +- include/Topology/map/map2.hpp | 2 +- include/Topology/map/map3.hpp | 4 +- src/Topology/generic/genericmap.cpp | 47 +----- 71 files changed, 1077 insertions(+), 1127 deletions(-) diff --git a/Apps/Examples/clipping.cpp b/Apps/Examples/clipping.cpp index cf5237dc..777b3e21 100644 --- a/Apps/Examples/clipping.cpp +++ b/Apps/Examples/clipping.cpp @@ -138,21 +138,21 @@ void Clipping::slot_drawFaces(bool b) void Clipping::slot_explodTopoPhi1(double c) { m_coeffTopoExplod[0] = (float)c; - m_render_topo->updateData(myMap, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]); + m_render_topo->updateData(myMap, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]); updateGL(); } void Clipping::slot_explodTopoPhi2(double c) { m_coeffTopoExplod[1] = (float)c; - m_render_topo->updateData(myMap, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]); + m_render_topo->updateData(myMap, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]); updateGL(); } void Clipping::slot_explodTopoPhi3(double c) { m_coeffTopoExplod[2] = (float)c; - m_render_topo->updateData(myMap, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]); + m_render_topo->updateData(myMap, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]); updateGL(); } @@ -814,7 +814,7 @@ void Clipping::importMesh(std::string& filename) updateVBOprimitives(Algo::Render::GL2::TRIANGLES | Algo::Render::GL2::LINES | Algo::Render::GL2::POINTS) ; - m_render_topo->updateData(myMap, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]); + m_render_topo->updateData(myMap, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]); m_bb = Algo::Geometry::computeBoundingBox(myMap, position) ; gPosObj = m_bb.center() ; @@ -843,7 +843,7 @@ void Clipping::cb_initGL() // create the render m_render = new Algo::Render::GL2::MapRender(); - m_render_topo = new Algo::Render::GL2::Topo3Render(); + m_render_topo = new Algo::Render::GL2::Topo3Render(); // create VBO for position m_positionVBO = new Utils::VBO(); diff --git a/Apps/Examples/clipping.h b/Apps/Examples/clipping.h index b622ec22..0df93423 100644 --- a/Apps/Examples/clipping.h +++ b/Apps/Examples/clipping.h @@ -70,18 +70,18 @@ struct PFP: public PFP_STANDARD typedef EmbeddedMap3 MAP; }; +typedef PFP::MAP MAP; +typedef PFP::MAP::IMPL MAP_IMPL; +typedef PFP::VEC3 VEC3; class Clipping: public Utils::QT::SimpleQT { Q_OBJECT public: - typedef PFP::MAP MAP; - typedef PFP::VEC3 VEC3; - //Manip Carte MAP myMap ; - VertexAttribute position; + VertexAttribute position; Dart dglobal; //Render @@ -91,7 +91,7 @@ public: bool m_drawTopo; Algo::Render::GL2::MapRender* m_render; - Algo::Render::GL2::Topo3Render* m_render_topo; + Algo::Render::GL2::Topo3Render* m_render_topo; Geom::BoundingBox m_bb; diff --git a/Apps/Examples/concave_rendering.cpp b/Apps/Examples/concave_rendering.cpp index 5f2e9722..ab2ae80e 100644 --- a/Apps/Examples/concave_rendering.cpp +++ b/Apps/Examples/concave_rendering.cpp @@ -128,12 +128,13 @@ struct PFP: public PFP_STANDARD }; typedef PFP::MAP MAP ; +typedef PFP::MAP::IMPL MAP_IMPL ; typedef PFP::VEC3 VEC3 ; // declaration of the map MAP myMap; // and attribute of position -VertexAttribute position; +VertexAttribute position; unsigned int nb_ears; diff --git a/Apps/Examples/extrusionView.cpp b/Apps/Examples/extrusionView.cpp index f15e4458..950dad06 100644 --- a/Apps/Examples/extrusionView.cpp +++ b/Apps/Examples/extrusionView.cpp @@ -53,6 +53,7 @@ struct PFP: public PFP_STANDARD }; typedef PFP::MAP MAP ; +typedef PFP::MAP::IMPL MAP_IMPL ; typedef PFP::VEC3 VEC3 ; MAP myMap; @@ -103,7 +104,7 @@ int main(int argc, char **argv) QApplication app(argc, argv); MyQT sqt; - VertexAttribute position = myMap.addAttribute("position") ; + VertexAttribute position = myMap.addAttribute("position") ; // define the face extruded (here a cross) std::vector objV; diff --git a/Apps/Examples/mcmesh.h b/Apps/Examples/mcmesh.h index c69cdd2d..61eab5c0 100644 --- a/Apps/Examples/mcmesh.h +++ b/Apps/Examples/mcmesh.h @@ -55,6 +55,7 @@ struct PFP: public PFP_STANDARD }; typedef PFP::MAP MAP ; +typedef PFP::MAP::IMPL MAP_IMPL ; typedef PFP::VEC3 VEC3 ; typedef unsigned char DATATYPE; @@ -76,7 +77,7 @@ public: bool m_drawEdges ; bool m_drawFaces ; - VertexAttribute position ; + VertexAttribute position ; Algo::Render::GL2::MapRender* m_render ; diff --git a/Apps/Examples/simpleGMap2.h b/Apps/Examples/simpleGMap2.h index 8269f8ba..3d8fcae5 100644 --- a/Apps/Examples/simpleGMap2.h +++ b/Apps/Examples/simpleGMap2.h @@ -42,6 +42,7 @@ struct PFP: public PFP_STANDARD }; typedef PFP::MAP MAP ; +typedef PFP::MAP::IMPL MAP_IMPL ; typedef PFP::VEC3 VEC3 ; class SimpleGMap2 : public Utils::QT::SimpleQT @@ -51,7 +52,7 @@ class SimpleGMap2 : public Utils::QT::SimpleQT public: MAP myMap ; - VertexAttribute position ; + VertexAttribute position ; SimpleGMap2() ; diff --git a/Apps/Examples/simpleGMap3.cpp b/Apps/Examples/simpleGMap3.cpp index b8ddee4b..af47ae63 100644 --- a/Apps/Examples/simpleGMap3.cpp +++ b/Apps/Examples/simpleGMap3.cpp @@ -132,10 +132,10 @@ void SimpleGMap3::cb_initGL() float gWidthObj = std::max(std::max(tailleX, tailleY), tailleZ) ; setParamObject(gWidthObj, gPosObj.data()); - m_render_topo = new Algo::Render::GL2::Topo3Render(); + m_render_topo = new Algo::Render::GL2::Topo3Render(); m_render_topo->setDartWidth(2.0f); m_render_topo->setInitialDartsColor(1.0f,1.0f,1.0f); - m_render_topo->updateData(myMap, position, 0.9f,0.9f,0.8f); + m_render_topo->updateData(myMap, position, 0.9f,0.9f,0.8f); } void SimpleGMap3::cb_redraw() diff --git a/Apps/Examples/simpleGMap3.h b/Apps/Examples/simpleGMap3.h index 2bd2b306..53e96ee5 100644 --- a/Apps/Examples/simpleGMap3.h +++ b/Apps/Examples/simpleGMap3.h @@ -43,6 +43,7 @@ struct PFP: public PFP_STANDARD }; typedef PFP::MAP MAP ; +typedef PFP::MAP::IMPL MAP_IMPL ; typedef PFP::VEC3 VEC3 ; class SimpleGMap3 : public Utils::QT::SimpleQT @@ -52,10 +53,10 @@ class SimpleGMap3 : public Utils::QT::SimpleQT public: MAP myMap ; - VertexAttribute position ; - VolumeAttribute volume ; + VertexAttribute position ; + VolumeAttribute volume ; - Algo::Render::GL2::Topo3Render* m_render_topo; + Algo::Render::GL2::Topo3Render* m_render_topo; SimpleGMap3() ; diff --git a/Apps/Examples/texturesExample.cpp b/Apps/Examples/texturesExample.cpp index 092fe209..8bc6cf18 100644 --- a/Apps/Examples/texturesExample.cpp +++ b/Apps/Examples/texturesExample.cpp @@ -85,12 +85,11 @@ void TexView::cb_initGL() m_shader2->setSpecular(Geom::Vec4f(0.5)); registerShader(m_shader2); - glEnable(GL_TEXTURE_2D); if (!m_obj.hasNormals()) { - VertexAttribute normal = myMap.getAttribute("normal") ; + VertexAttribute normal = myMap.getAttribute("normal") ; if(!normal.isValid()) normal = myMap.addAttribute("normal") ; @@ -99,7 +98,6 @@ void TexView::cb_initGL() } m_nbIndices = m_obj.createSimpleVBO_PTN(m_positionVBO,m_texcoordVBO,m_normalVBO); - } void TexView::cb_redraw() @@ -120,8 +118,6 @@ void TexView::cb_redraw() glDrawArrays(GL_TRIANGLES, 0, m_nbIndices); m_shader->disableVertexAttribs(); } - - } void TexView::cb_keyPress(int code) @@ -152,7 +148,6 @@ void TexView::cb_keyPress(int code) m_shader2->setShininess(1.0f); m_shader2->setSpecular(Geom::Vec4f(0)); break; - } updateGL(); } @@ -179,10 +174,8 @@ void TexView::init(const std::string& fnm, const std::string& fnt) // send BB info to interface for centering on GL screen setParamObject(lWidthObj, lPosObj.data()); - } - void TexView::computeImage() { std::vector colorTable; @@ -213,8 +206,8 @@ void TexView::computeTore() { #define NB 96 - VertexAttribute position = myMap.addAttribute("position"); - VertexAttribute texcoord = myMap.addAttribute("texcoord"); + VertexAttribute position = myMap.addAttribute("position"); + VertexAttribute texcoord = myMap.addAttribute("texcoord"); //Algo::Surface::Modelisation::Polyhedron prim(myMap, position); Algo::Surface::Tilings::Square::Tore prim(myMap, NB, NB); prim.embedIntoTore(position, 40.0f,20.0f); @@ -245,9 +238,6 @@ void TexView::computeTore() m_obj.setTexCoordAttribute(texcoord); } - - - int main(int argc, char**argv) { // interface: @@ -267,10 +257,8 @@ int main(int argc, char**argv) tv.init("","x"); } - tv.show(); - // et on attend la fin. return app.exec(); } diff --git a/Apps/Examples/texturesExample.h b/Apps/Examples/texturesExample.h index db45eff5..9e305209 100644 --- a/Apps/Examples/texturesExample.h +++ b/Apps/Examples/texturesExample.h @@ -50,7 +50,9 @@ struct PFP: public PFP_STANDARD }; typedef PFP::MAP MAP ; +typedef PFP::MAP::IMPL MAP_IMPL ; typedef PFP::VEC3 VEC3 ; + /** * A class for a little interface and rendering */ diff --git a/include/Algo/Geometry/boundingbox.h b/include/Algo/Geometry/boundingbox.h index 076c1a9b..2fa3cee7 100644 --- a/include/Algo/Geometry/boundingbox.h +++ b/include/Algo/Geometry/boundingbox.h @@ -41,7 +41,7 @@ namespace Geometry { template -Geom::BoundingBox computeBoundingBox(typename PFP::MAP& map, const VertexAttribute& position) +Geom::BoundingBox computeBoundingBox(typename PFP::MAP& map, const VertexAttribute& position) { Geom::BoundingBox bb ; TraversorV t(map) ; diff --git a/include/Algo/Geometry/laplacian.h b/include/Algo/Geometry/laplacian.h index 65b5510f..a3f5a685 100644 --- a/include/Algo/Geometry/laplacian.h +++ b/include/Algo/Geometry/laplacian.h @@ -43,41 +43,41 @@ template ATTR_TYPE computeLaplacianTopoVertex( typename PFP::MAP& map, Dart d, - const VertexAttribute& attr) ; + const VertexAttribute& attr) ; template ATTR_TYPE computeLaplacianCotanVertex( typename PFP::MAP& map, Dart d, - const EdgeAttribute& edgeWeight, - const VertexAttribute& vertexArea, - const VertexAttribute& attr) ; + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea, + const VertexAttribute& attr) ; template void computeLaplacianTopoVertices( typename PFP::MAP& map, - const VertexAttribute& attr, - VertexAttribute& laplacian) ; + const VertexAttribute& attr, + VertexAttribute& laplacian) ; template void computeLaplacianCotanVertices( typename PFP::MAP& map, - const EdgeAttribute& edgeWeight, - const VertexAttribute& vertexArea, - const VertexAttribute& attr, - VertexAttribute& laplacian) ; + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea, + const VertexAttribute& attr, + VertexAttribute& laplacian) ; template typename PFP::REAL computeCotanWeightEdge( typename PFP::MAP& map, Dart d, - const VertexAttribute& position) ; + const VertexAttribute& position) ; template void computeCotanWeightEdges( typename PFP::MAP& map, - const VertexAttribute& position, - EdgeAttribute& edgeWeight) ; + const VertexAttribute& position, + EdgeAttribute& edgeWeight) ; } // namespace Geometry @@ -90,19 +90,21 @@ namespace Geometry { template -ATTR_TYPE computeLaplacianTopoVertex( typename PFP::MAP& map, Dart d, const VertexAttribute& attr) ; +ATTR_TYPE computeLaplacianTopoVertex( + typename PFP::MAP& map, + Dart d, + const VertexAttribute& attr) ; template -void computeLaplacianTopoVertices(typename PFP::MAP& map, const VertexAttribute& attr, - VertexAttribute& laplacian) ; - - +void computeLaplacianTopoVertices( + typename PFP::MAP& map, + const VertexAttribute& attr, + VertexAttribute& laplacian) ; } // namespace Geometry } // namespace Volume - } // namespace Algo } // namespace CGoGN diff --git a/include/Algo/Geometry/laplacian.hpp b/include/Algo/Geometry/laplacian.hpp index 8e80b0be..b0517ee1 100644 --- a/include/Algo/Geometry/laplacian.hpp +++ b/include/Algo/Geometry/laplacian.hpp @@ -42,7 +42,7 @@ template ATTR_TYPE computeLaplacianTopoVertex( typename PFP::MAP& map, Dart d, - const VertexAttribute& attr) + const VertexAttribute& attr) { ATTR_TYPE l(0) ; ATTR_TYPE value = attr[d] ; @@ -63,19 +63,21 @@ template ATTR_TYPE computeLaplacianCotanVertex( typename PFP::MAP& map, Dart d, - const EdgeAttribute& edgeWeight, - const VertexAttribute& vertexArea, - const VertexAttribute& attr) + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea, + const VertexAttribute& attr) { + typedef typename PFP::REAL REAL; + ATTR_TYPE l(0) ; - typename PFP::REAL vArea = vertexArea[d] ; + REAL vArea = vertexArea[d] ; ATTR_TYPE value = attr[d] ; - typename PFP::REAL wSum = 0 ; + REAL wSum = 0 ; Traversor2VE t(map, d) ; for(Dart it = t.begin(); it != t.end(); it = t.next()) { - typename PFP::REAL w = edgeWeight[it] / vArea ; + REAL w = edgeWeight[it] / vArea ; l += (attr[map.phi1(it)] - value) * w ; wSum += w ; } @@ -87,8 +89,8 @@ ATTR_TYPE computeLaplacianCotanVertex( template void computeLaplacianTopoVertices( typename PFP::MAP& map, - const VertexAttribute& attr, - VertexAttribute& laplacian) + const VertexAttribute& attr, + VertexAttribute& laplacian) { TraversorV t(map) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) @@ -98,10 +100,10 @@ void computeLaplacianTopoVertices( template void computeLaplacianCotanVertices( typename PFP::MAP& map, - const EdgeAttribute& edgeWeight, - const VertexAttribute& vertexArea, - const VertexAttribute& attr, - VertexAttribute& laplacian) + const EdgeAttribute& edgeWeight, + const VertexAttribute& vertexArea, + const VertexAttribute& attr, + VertexAttribute& laplacian) { TraversorV t(map) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) @@ -112,26 +114,29 @@ template typename PFP::REAL computeCotanWeightEdge( typename PFP::MAP& map, Dart d, - const VertexAttribute& position) + const VertexAttribute& position) { + typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; + if(map.isBoundaryEdge(d)) { - const typename PFP::VEC3& p1 = position[d] ; - const typename PFP::VEC3& p2 = position[map.phi1(d)] ; - const typename PFP::VEC3& p3 = position[map.phi_1(d)] ; + const VEC3& p1 = position[d] ; + const VEC3& p2 = position[map.phi1(d)] ; + const VEC3& p3 = position[map.phi_1(d)] ; - typename PFP::REAL cot_alpha = 1 / tan(Geom::angle(p1 - p3, p2 - p3)) ; + REAL cot_alpha = 1 / tan(Geom::angle(p1 - p3, p2 - p3)) ; return 0.5 * cot_alpha ; } else { - const typename PFP::VEC3& p1 = position[d] ; - const typename PFP::VEC3& p2 = position[map.phi1(d)] ; - const typename PFP::VEC3& p3 = position[map.phi_1(d)] ; - const typename PFP::VEC3& p4 = position[map.phi_1(map.phi2(d))] ; + const VEC3& p1 = position[d] ; + const VEC3& p2 = position[map.phi1(d)] ; + const VEC3& p3 = position[map.phi_1(d)] ; + const VEC3& p4 = position[map.phi_1(map.phi2(d))] ; - typename PFP::REAL cot_alpha = 1 / tan(Geom::angle(p1 - p3, p2 - p3)) ; - typename PFP::REAL cot_beta = 1 / tan(Geom::angle(p2 - p4, p1 - p4)) ; + REAL cot_alpha = 1 / tan(Geom::angle(p1 - p3, p2 - p3)) ; + REAL cot_beta = 1 / tan(Geom::angle(p2 - p4, p1 - p4)) ; return 0.5 * ( cot_alpha + cot_beta ) ; } } @@ -139,8 +144,8 @@ typename PFP::REAL computeCotanWeightEdge( template void computeCotanWeightEdges( typename PFP::MAP& map, - const VertexAttribute& position, - EdgeAttribute& edgeWeight) + const VertexAttribute& position, + EdgeAttribute& edgeWeight) { TraversorE t(map) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) @@ -159,7 +164,10 @@ namespace Geometry { template -ATTR_TYPE computeLaplacianTopoVertex(typename PFP::MAP& map, Dart d, const VertexAttribute& attr) +ATTR_TYPE computeLaplacianTopoVertex( + typename PFP::MAP& map, + Dart d, + const VertexAttribute& attr) { ATTR_TYPE l(0) ; ATTR_TYPE value = attr[d] ; @@ -177,20 +185,20 @@ ATTR_TYPE computeLaplacianTopoVertex(typename PFP::MAP& map, Dart d, const Verte } template -void computeLaplacianTopoVertices(typename PFP::MAP& map, const VertexAttribute& attr, - VertexAttribute& laplacian) +void computeLaplacianTopoVertices( + typename PFP::MAP& map, + const VertexAttribute& attr, + VertexAttribute& laplacian) { TraversorV t(map) ; for(Dart d = t.begin(); d != t.end(); d = t.next()) laplacian[d] = computeLaplacianTopoVertex(map, d, attr) ; } - } // namespace Geometry } // namespace Volume - } // namespace Algo } // namespace CGoGN diff --git a/include/Algo/Import/import.hpp b/include/Algo/Import/import.hpp index ad615576..6c896677 100644 --- a/include/Algo/Import/import.hpp +++ b/include/Algo/Import/import.hpp @@ -42,7 +42,10 @@ namespace Import template bool importMesh(typename PFP::MAP& map, MeshTablesSurface& mts) { - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecDartsPerVertex(map, "incidents"); + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecDartsPerVertex(map, "incidents"); unsigned nbf = mts.getNbFaces(); int index = 0; @@ -50,9 +53,9 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface& mts) std::vector edgesBuffer; edgesBuffer.reserve(16); - DartMarkerNoUnmark m(map) ; + DartMarkerNoUnmark m(map) ; - FunctorInitEmb fsetemb(map); + FunctorInitEmb fsetemb(map); // for each face of table for(unsigned int i = 0; i < nbf; ++i) @@ -183,7 +186,10 @@ bool importVoxellisation(typename PFP::MAP& map, Algo::Surface::Modelisation::Vo template bool importMeshSAsV(typename PFP::MAP& map, MeshTablesSurface& mts) { - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecDartsPerVertex(map, "incidents"); + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecDartsPerVertex(map, "incidents"); unsigned nbf = mts.getNbFaces(); int index = 0; @@ -191,7 +197,7 @@ bool importMeshSAsV(typename PFP::MAP& map, MeshTablesSurface& mts) std::vector edgesBuffer; edgesBuffer.reserve(16); - DartMarkerNoUnmark m(map) ; + DartMarkerNoUnmark m(map) ; // for each face of table for(unsigned int i = 0; i < nbf; ++i) @@ -222,7 +228,7 @@ bool importMeshSAsV(typename PFP::MAP& map, MeshTablesSurface& mts) { unsigned int em = edgesBuffer[j]; // get embedding - FunctorSetEmb fsetemb(map, em); + FunctorSetEmb fsetemb(map, em); map.template foreach_dart_of_orbit(d, fsetemb); m.mark(d) ; // mark on the fly to unmark on second loop @@ -298,16 +304,20 @@ namespace Import template bool importMeshSToV(typename PFP::MAP& map, Surface::Import::MeshTablesSurface& mts, float dist) { - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecDartsPerVertex(map, "incidents"); + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + typedef typename PFP::VEC3 VEC3; + + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecDartsPerVertex(map, "incidents"); unsigned nbf = mts.getNbFaces(); int index = 0; // buffer for tempo faces (used to remove degenerated edges) std::vector edgesBuffer; edgesBuffer.reserve(16); - DartMarkerNoUnmark m(map) ; + DartMarkerNoUnmark m(map) ; - VertexAttribute position = map.template getAttribute("position"); + VertexAttribute position = map.template getAttribute("position"); std::vector backEdgesBuffer(mts.getNbVertices(), EMBNULL); // for each face of table -> create a prism @@ -334,7 +344,7 @@ bool importMeshSToV(typename PFP::MAP& map, Surface::Import::MeshTablesSurface

2) { - Dart d = Surface::Modelisation::createPrism(map, nbe,false); + Dart d = Surface::Modelisation::createPrism(map, nbe, false); //Embed the base faces for (unsigned int j = 0; j < nbe; ++j) @@ -404,18 +414,22 @@ bool importMeshSToV(typename PFP::MAP& map, Surface::Import::MeshTablesSurface

bool importMeshSurfToVol(typename PFP::MAP& map, Surface::Import::MeshTablesSurface& mts, float scale, unsigned int nbStage) { - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecDartsPerVertex(map); + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + typedef typename PFP::VEC3 VEC3; + + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecDartsPerVertex(map); unsigned nbf = mts.getNbFaces(); int index = 0; // buffer for tempo faces (used to remove degenerated edges) std::vector edgesBuffer; edgesBuffer.reserve(16); - DartMarkerNoUnmark m(map) ; + DartMarkerNoUnmark m(map) ; unsigned int nbVertices = mts.getNbVertices(); - VertexAttribute position = map.template getAttribute("position"); + VertexAttribute position = map.template getAttribute("position"); std::vector backEdgesBuffer(nbVertices*nbStage, EMBNULL); // for each face of table -> create a prism @@ -533,7 +547,11 @@ bool importMeshSurfToVol(typename PFP::MAP& map, Surface::Import::MeshTablesSurf template bool importMesh(typename PFP::MAP& map, MeshTablesVolume& mtv) { - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecDartsPerVertex(map, "incidents"); + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + typedef typename PFP::VEC3 VEC3; + + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecDartsPerVertex(map, "incidents"); unsigned int nbv = mtv.getNbVolumes(); int index = 0; @@ -541,8 +559,8 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume& mtv) std::vector edgesBuffer; edgesBuffer.reserve(16); - DartMarkerNoUnmark m(map) ; - FunctorInitEmb fsetemb(map); + DartMarkerNoUnmark m(map) ; + FunctorInitEmb fsetemb(map); //for each volume of table for(unsigned int i = 0 ; i < nbv ; ++i) @@ -714,7 +732,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume& mtv) } else { - m.unmarkOrbit(d); + m.template unmarkOrbit(d); ++nbBoundaryFaces; } } diff --git a/include/Algo/Import/import2tables.h b/include/Algo/Import/import2tables.h index 1094d27e..5bdbbe2e 100644 --- a/include/Algo/Import/import2tables.h +++ b/include/Algo/Import/import2tables.h @@ -60,11 +60,14 @@ template class MeshTablesSurface { public: + typedef typename PFP::MAP MAP ; + typedef typename PFP::MAP::IMPL MAP_IMPL ; typedef typename PFP::VEC3 VEC3 ; typedef typename VEC3::DATA_TYPE DATA_TYPE ; + typedef typename PFP::REAL REAL ; private: - typename PFP::MAP& m_map; + MAP& m_map; unsigned int m_nbVertices; @@ -83,7 +86,7 @@ private: std::vector m_emb; #ifdef WITH_ASSIMP - void extractMeshRec(AttributeContainer& container, VertexAttribute& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo); + void extractMeshRec(AttributeContainer& container, VertexAttribute& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo); #endif bool importTrian(const std::string& filename, std::vector& attrNames); @@ -131,7 +134,7 @@ public: bool importPlySLFgenericBin(const std::string& filename, std::vector& attrNames); - MeshTablesSurface(typename PFP::MAP& map): + MeshTablesSurface(MAP& map): m_map(map) { } }; @@ -143,6 +146,7 @@ public: namespace Volume { + namespace Import { @@ -150,12 +154,14 @@ template class MeshTablesVolume { public: + typedef typename PFP::MAP MAP ; + typedef typename PFP::MAP::IMPL MAP_IMPL ; typedef typename PFP::VEC3 VEC3 ; typedef typename VEC3::DATA_TYPE DATA_TYPE ; typedef typename PFP::REAL REAL; private: - typename PFP::MAP& m_map; + MAP& m_map; unsigned int m_nbVertices; @@ -216,7 +222,7 @@ public: bool importMesh(const std::string& filename, std::vector& attrNames); - MeshTablesVolume(typename PFP::MAP& map): + MeshTablesVolume(MAP& map): m_map(map) { } }; diff --git a/include/Algo/Import/import2tablesSurface.hpp b/include/Algo/Import/import2tablesSurface.hpp index 9b9992d0..7f02db28 100644 --- a/include/Algo/Import/import2tablesSurface.hpp +++ b/include/Algo/Import/import2tablesSurface.hpp @@ -114,10 +114,10 @@ bool MeshTablesSurface::importMesh(const std::string& filename, std::vector template bool MeshTablesSurface::importTrian(const std::string& filename, std::vector& attrNames) { - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; @@ -181,10 +181,10 @@ bool MeshTablesSurface::importTrian(const std::string& filename, std::vecto template bool MeshTablesSurface::importTrianBinGz(const std::string& filename, std::vector& attrNames) { - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; @@ -251,10 +251,10 @@ bool MeshTablesSurface::importTrianBinGz(const std::string& filename, std:: template bool MeshTablesSurface::importOff(const std::string& filename, std::vector& attrNames) { - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; @@ -350,10 +350,10 @@ bool MeshTablesSurface::importOff(const std::string& filename, std::vector< template bool MeshTablesSurface::importVoxellisation(Algo::Surface::Modelisation::Voxellisation& voxellisation, std::vector& attrNames) { - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; @@ -394,11 +394,11 @@ bool MeshTablesSurface::importVoxellisation(Algo::Surface::Modelisation::Vo template bool MeshTablesSurface::importMeshBin(const std::string& filename, std::vector& attrNames) { - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; if (!positions.isValid()) { - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; } attrNames.push_back(positions.name()) ; @@ -465,10 +465,10 @@ bool MeshTablesSurface::importMeshBin(const std::string& filename, std::vec template bool MeshTablesSurface::importObj(const std::string& filename, std::vector& attrNames) { - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; @@ -589,10 +589,10 @@ bool MeshTablesSurface::importObj(const std::string& filename, std::vector< template bool MeshTablesSurface::importPly(const std::string& filename, std::vector& attrNames) { - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; @@ -606,11 +606,11 @@ bool MeshTablesSurface::importPly(const std::string& filename, std::vector< return false; } - VertexAttribute colors = m_map.template getAttribute("color") ; + VertexAttribute colors = m_map.template getAttribute("color") ; if (pid.hasColors()) { if(!colors.isValid()) - colors = m_map.template addAttribute("color") ; + colors = m_map.template addAttribute("color") ; attrNames.push_back(colors.name()) ; } @@ -769,52 +769,52 @@ bool MeshTablesSurface::importPlySLFgeneric(const std::string& filename, st } while (tag != std::string("end_header")) ; // Define containers - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; ; if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; - VertexAttribute *frame = new VertexAttribute[3] ; - frame[0] = m_map.template addAttribute("frameT") ; // Tangent - frame[0] = m_map.template addAttribute("frameB") ; // Binormal - frame[0] = m_map.template addAttribute("frameN") ; // Normal + VertexAttribute *frame = new VertexAttribute[3] ; + frame[0] = m_map.template addAttribute("frameT") ; // Tangent + frame[0] = m_map.template addAttribute("frameB") ; // Binormal + frame[0] = m_map.template addAttribute("frameN") ; // Normal attrNames.push_back(frame[0].name()) ; attrNames.push_back(frame[1].name()) ; attrNames.push_back(frame[2].name()) ; - VertexAttribute *PBcoefs = NULL, *SHcoefs = NULL ; + VertexAttribute *PBcoefs = NULL, *SHcoefs = NULL ; if (PTM) { - PBcoefs = new VertexAttribute[nbCoefs] ; + PBcoefs = new VertexAttribute[nbCoefs] ; for (unsigned int i = 0 ; i < nbCoefs ; ++i) { std::stringstream name ; name << "PBcoefs" << i ; - PBcoefs[i] = m_map.template addAttribute(name.str()) ; + PBcoefs[i] = m_map.template addAttribute(name.str()) ; attrNames.push_back(PBcoefs[i].name()) ; } } if (SH) { - SHcoefs = new VertexAttribute[nbCoefs] ; + SHcoefs = new VertexAttribute[nbCoefs] ; for (unsigned int i = 0 ; i < nbCoefs ; ++i) { std::stringstream name ; name << "SHcoefs" << i ; - SHcoefs[i] = m_map.template addAttribute(name.str()) ; + SHcoefs[i] = m_map.template addAttribute(name.str()) ; attrNames.push_back(SHcoefs[i].name()) ; } } - VertexAttribute *remainders = new VertexAttribute[nbRemainders] ; + VertexAttribute *remainders = new VertexAttribute[nbRemainders] ; for (unsigned int i = 0 ; i < nbRemainders ; ++i) { std::stringstream name ; name << "remainderNo" << i ; - remainders[i] = m_map.template addAttribute(name.str()) ; - attrNames.push_back(remainders[i].name()) ; + remainders[i] = m_map.template addAttribute(name.str()) ; + attrNames.push_back(remainders[i].name()) ; } // Read vertices @@ -1019,59 +1019,59 @@ bool MeshTablesSurface::importPlySLFgenericBin(const std::string& filename, delete[] endline ; // Define containers - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; - VertexAttribute *frame = new VertexAttribute[3] ; + VertexAttribute *frame = new VertexAttribute[3] ; if (tangent) { - frame[0] = m_map.template addAttribute("frameT") ; // Tangent + frame[0] = m_map.template addAttribute("frameT") ; // Tangent attrNames.push_back(frame[0].name()) ; } if (binormal) { - frame[1] = m_map.template addAttribute("frameB") ; // Bitangent + frame[1] = m_map.template addAttribute("frameB") ; // Bitangent attrNames.push_back(frame[0].name()) ; } if (normal) { - frame[2] = m_map.template addAttribute("frameN") ; // Normal + frame[2] = m_map.template addAttribute("frameN") ; // Normal attrNames.push_back(frame[0].name()) ; } - VertexAttribute *PBcoefs = NULL, *SHcoefs = NULL ; + VertexAttribute *PBcoefs = NULL, *SHcoefs = NULL ; if (PTM) { - PBcoefs = new VertexAttribute[nbCoefs] ; + PBcoefs = new VertexAttribute[nbCoefs] ; for (unsigned int i = 0 ; i < nbCoefs ; ++i) { std::stringstream name ; name << "PBcoefs" << i ; - PBcoefs[i] = m_map.template addAttribute(name.str()) ; + PBcoefs[i] = m_map.template addAttribute(name.str()) ; attrNames.push_back(PBcoefs[i].name()) ; } } if (SH) { - SHcoefs = new VertexAttribute[nbCoefs] ; + SHcoefs = new VertexAttribute[nbCoefs] ; for (unsigned int i = 0 ; i < nbCoefs ; ++i) { std::stringstream name ; name << "SHcoefs" << i ; - SHcoefs[i] = m_map.template addAttribute(name.str()) ; + SHcoefs[i] = m_map.template addAttribute(name.str()) ; attrNames.push_back(SHcoefs[i].name()) ; } } - VertexAttribute *remainders = new VertexAttribute[nbRemainders] ; + VertexAttribute *remainders = new VertexAttribute[nbRemainders] ; for (unsigned int i = 0 ; i < nbRemainders ; ++i) { std::stringstream name ; name << "remainderNo" << i ; - remainders[i] = m_map.template addAttribute(name.str()) ; + remainders[i] = m_map.template addAttribute(name.str()) ; attrNames.push_back(remainders[i].name()) ; } @@ -1377,10 +1377,10 @@ bool MeshTablesSurface::importAHEM(const std::string& filename, std::vector // Read positions - VertexAttribute position = m_map.template getAttribute("position") ; + VertexAttribute position = m_map.template getAttribute("position") ; if (!position.isValid()) - position = m_map.template addAttribute("position") ; + position = m_map.template addAttribute("position") ; attrNames.push_back(position.name()) ; @@ -1422,7 +1422,7 @@ bool MeshTablesSurface::importAHEM(const std::string& filename, std::vector #ifdef WITH_ASSIMP template -void MeshTablesSurface::extractMeshRec(AttributeContainer& container, VertexAttribute& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo) +void MeshTablesSurface::extractMeshRec(AttributeContainer& container, VertexAttribute& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo) { struct aiMatrix4x4 prev; @@ -1479,7 +1479,7 @@ template bool MeshTablesSurface::importASSIMP(const std::string& filename, std::vector& attrNames) { AttributeContainer& container = m_map.template getAttributeContainer() ; - VertexAttribute positions = m_map.template addAttribute("position") ; + VertexAttribute positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; m_nbVertices = 0; @@ -1522,7 +1522,7 @@ bool MeshTablesSurface::mergeCloseVertices() for (unsigned int i=0; i positions = m_map.template getAttribute("position"); + VertexAttribute positions = m_map.template getAttribute("position"); // compute BB Geom::BoundingBox bb(positions[ positions.begin() ]) ; @@ -1539,8 +1539,8 @@ bool MeshTablesSurface::mergeCloseVertices() bb.addPoint( bb.max() + one); bbsize = (bb.max() - bb.min()); - VertexAutoAttribute gridIndex(m_map, "gridIndex"); - VertexAutoAttribute newIndices(m_map, "newIndices"); + VertexAutoAttribute gridIndex(m_map, "gridIndex"); + VertexAutoAttribute 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)) @@ -1652,10 +1652,10 @@ bool MeshTablesSurface::mergeCloseVertices() template bool MeshTablesSurface::importSTLAscii(const std::string& filename, std::vector& attrNames) { - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; @@ -1740,10 +1740,10 @@ bool MeshTablesSurface::importSTLAscii(const std::string& filename, std::ve template bool MeshTablesSurface::importSTLBin(const std::string& filename, std::vector& attrNames) { - VertexAttribute positions = m_map.template getAttribute("position") ; + VertexAttribute positions = m_map.template getAttribute("position") ; if (!positions.isValid()) - positions = m_map.template addAttribute("position") ; + positions = m_map.template addAttribute("position") ; attrNames.push_back(positions.name()) ; @@ -1811,18 +1811,9 @@ bool MeshTablesSurface::importSTLBin(const std::string& filename, std::vect return true; } - - - - - - - - - } // namespace Import -} +} // namespace Surface } // namespace Algo diff --git a/include/Algo/Import/import2tablesVolume.hpp b/include/Algo/Import/import2tablesVolume.hpp index f6e66d56..9cf5e5b1 100644 --- a/include/Algo/Import/import2tablesVolume.hpp +++ b/include/Algo/Import/import2tablesVolume.hpp @@ -100,7 +100,7 @@ bool MeshTablesVolume::importMesh(const std::string& filename, std::vector< template bool MeshTablesVolume::importTet(const std::string& filename, std::vector& attrNames) { - VertexAttribute position = m_map.template getAttribute("position") ; + VertexAttribute position = m_map.template getAttribute("position") ; if (!position.isValid()) position = m_map.template addAttribute("position") ; @@ -204,7 +204,7 @@ bool MeshTablesVolume::importTet(const std::string& filename, std::vector bool MeshTablesVolume::importOFFWithELERegions(const std::string& filenameOFF, const std::string& filenameELE, std::vector& attrNames) { - VertexAttribute position = m_map.template getAttribute("position") ; + VertexAttribute position = m_map.template getAttribute("position") ; if (!position.isValid()) position = m_map.template addAttribute("position") ; @@ -345,7 +345,7 @@ bool MeshTablesVolume::importOFFWithELERegions(const std::string& filenameO template bool MeshTablesVolume::importNodeWithELERegions(const std::string& filenameNode, const std::string& filenameELE, std::vector& attrNames) { - VertexAttribute position = m_map.template getAttribute("position") ; + VertexAttribute position = m_map.template getAttribute("position") ; if (!position.isValid()) position = m_map.template addAttribute("position") ; @@ -480,7 +480,7 @@ bool MeshTablesVolume::importNodeWithELERegions(const std::string& filename template bool MeshTablesVolume::importTetmesh(const std::string& filename, std::vector& attrNames) { - VertexAttribute position = m_map.template getAttribute("position") ; + VertexAttribute position = m_map.template getAttribute("position") ; if (!position.isValid()) position = m_map.template addAttribute("position") ; @@ -592,7 +592,7 @@ template bool MeshTablesVolume::importTs(const std::string& filename, std::vector& attrNames) { // - VertexAttribute position = m_map.template getAttribute("position") ; + VertexAttribute position = m_map.template getAttribute("position") ; if (!position.isValid()) position = m_map.template addAttribute("position") ; @@ -600,7 +600,7 @@ bool MeshTablesVolume::importTs(const std::string& filename, std::vector scalar = m_map.template getAttribute("scalar"); + VertexAttribute scalar = m_map.template getAttribute("scalar"); if (!scalar.isValid()) scalar = m_map.template addAttribute("scalar") ; @@ -705,7 +705,7 @@ template bool MeshTablesVolume::importMSH(const std::string& filename, std::vector& attrNames) { // - VertexAttribute position = m_map.template getAttribute("position") ; + VertexAttribute position = m_map.template getAttribute("position") ; if (!position.isValid()) position = m_map.template addAttribute("position") ; @@ -837,7 +837,6 @@ bool MeshTablesVolume::importMSH(const std::string& filename, std::vector bool importMSH(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, float scaleFactor) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; - VertexAttribute position = map.template addAttribute("position") ; + VertexAttribute position = map.template addAttribute("position") ; attrNames.push_back(position.name()) ; AttributeContainer& container = map.template getAttributeContainer() ; unsigned int m_nbVertices = 0, m_nbVolumes = 0; - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecDartsPerVertex(map, "incidents"); + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecDartsPerVertex(map, "incidents"); //open file std::ifstream fp(filename.c_str(), std::ios::in); @@ -69,12 +71,10 @@ bool importMSH(typename PFP::MAP& map, const std::string& filename, std::vector< std::stringstream oss(ligne); oss >> nbv; - //reading vertices // std::vector verticesID; std::map verticesMapID; - // verticesID.reserve(nbv); for(unsigned int i = 0; i < nbv;++i) { @@ -105,7 +105,6 @@ bool importMSH(typename PFP::MAP& map, const std::string& filename, std::vector< m_nbVertices = nbv; - // ELM std::getline (fp, ligne); @@ -268,10 +267,9 @@ bool importMSH(typename PFP::MAP& map, const std::string& filename, std::vector< CGoGNout << "nb points = " << m_nbVertices ; - m_nbVolumes = 0; - DartMarkerNoUnmark m(map) ; + DartMarkerNoUnmark m(map) ; if (tet.size() > 0) { @@ -369,7 +367,6 @@ bool importMSH(typename PFP::MAP& map, const std::string& filename, std::vector< vecDartsPerVertex[verticesMapID[pt[1]]].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd)); vecDartsPerVertex[verticesMapID[pt[1]]].push_back(dd); m.mark(dd); - d = map.phi1(d); fsetemb.changeEmb(verticesMapID[pt[2]]); map.template foreach_dart_of_orbit(d, fsetemb); @@ -378,7 +375,6 @@ bool importMSH(typename PFP::MAP& map, const std::string& filename, std::vector< vecDartsPerVertex[verticesMapID[pt[2]]].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd)); vecDartsPerVertex[verticesMapID[pt[2]]].push_back(dd); m.mark(dd); - d = map.phi1(d); fsetemb.changeEmb(verticesMapID[pt[3]]); map.template foreach_dart_of_orbit(d, fsetemb); @@ -423,7 +419,6 @@ bool importMSH(typename PFP::MAP& map, const std::string& filename, std::vector< //end of hexa } CGoGNout << " / nb hexa = " << hexa.size()/2 << CGoGNendl; - } //Association des phi3 @@ -470,7 +465,7 @@ bool importMSH(typename PFP::MAP& map, const std::string& filename, std::vector< } // namespace Import -} +} // namespace Volume } // namespace Algo diff --git a/include/Algo/Import/importNAS.hpp b/include/Algo/Import/importNAS.hpp index dc16d057..d5bf56c3 100644 --- a/include/Algo/Import/importNAS.hpp +++ b/include/Algo/Import/importNAS.hpp @@ -64,19 +64,19 @@ inline float floatFromNas(std::string& s_v) return x; } - template bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, float scaleFactor) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; - VertexAttribute position = map.template addAttribute("position") ; + VertexAttribute position = map.template addAttribute("position") ; attrNames.push_back(position.name()) ; AttributeContainer& container = map.template getAttributeContainer() ; - - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecDartsPerVertex(map, "incidents"); + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecDartsPerVertex(map, "incidents"); //open file std::ifstream fp(filename.c_str(), std::ios::in); @@ -151,14 +151,14 @@ bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector< s_v = ligne.substr(16,8); unsigned int ind8 = atoi(s_v.c_str()); - typename PFP::VEC3 P = position[verticesMapID[ind5]]; - typename PFP::VEC3 A = position[verticesMapID[ind1]]; - typename PFP::VEC3 B = position[verticesMapID[ind2]]; - typename PFP::VEC3 C = position[verticesMapID[ind3]]; + VEC3 P = position[verticesMapID[ind5]]; + VEC3 A = position[verticesMapID[ind1]]; + VEC3 B = position[verticesMapID[ind2]]; + VEC3 C = position[verticesMapID[ind3]]; Geom::Vec4ui v; - if (Geom::testOrientation3D(P,A,B,C) == Geom::OVER) + if (Geom::testOrientation3D(P,A,B,C) == Geom::OVER) { v[0] = ind4; v[1] = ind3; @@ -196,14 +196,14 @@ bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector< s_v = ligne.substr(48,8); unsigned int ind4 = atoi(s_v.c_str()); - typename PFP::VEC3 P = position[verticesMapID[ind1]]; - typename PFP::VEC3 A = position[verticesMapID[ind2]]; - typename PFP::VEC3 B = position[verticesMapID[ind3]]; - typename PFP::VEC3 C = position[verticesMapID[ind4]]; + VEC3 P = position[verticesMapID[ind1]]; + VEC3 A = position[verticesMapID[ind2]]; + VEC3 B = position[verticesMapID[ind3]]; + VEC3 C = position[verticesMapID[ind4]]; Geom::Vec4ui v; - if (Geom::testOrientation3D(P,A,B,C) == Geom::OVER) + if (Geom::testOrientation3D(P,A,B,C) == Geom::OVER) { v[0] = ind4; v[1] = ind3; @@ -223,14 +223,11 @@ bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector< tag = ligne.substr(0,4); } while (!fp.eof()); - - CGoGNout << "nb points = " << m_nbVertices ; - unsigned int m_nbVolumes = 0; - DartMarkerNoUnmark m(map) ; + DartMarkerNoUnmark m(map) ; if (tet.size() > 0) { @@ -250,11 +247,10 @@ bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector< Dart d = Surface::Modelisation::createTetrahedron(map,false); - // Embed three "base" vertices for(unsigned int j = 0 ; j < 3 ; ++j) { - FunctorSetEmb fsetemb(map, verticesMapID[pt[2-j]]); + FunctorSetEmb fsetemb(map, verticesMapID[pt[2-j]]); map.template foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction @@ -272,7 +268,7 @@ bool importNAS(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, verticesMapID[pt[3]]); + FunctorSetEmb fsetemb(map, verticesMapID[pt[3]]); map.template foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction @@ -287,12 +283,10 @@ bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector< //end of tetra } CGoGNout << " / nb tetra = " << tet.size() << CGoGNendl; - } if (hexa.size() > 0) { - m_nbVolumes += hexa.size()/2; //Read and embed all tetrahedrons @@ -312,7 +306,7 @@ bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector< Dart d = Surface::Modelisation::createHexahedron(map,false); - FunctorSetEmb fsetemb(map, verticesMapID[pt[0]]); + FunctorSetEmb fsetemb(map, verticesMapID[pt[0]]); map.template foreach_dart_of_orbit(d, fsetemb); Dart dd = d; @@ -328,7 +322,6 @@ bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector< vecDartsPerVertex[verticesMapID[pt[1]]].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd)); vecDartsPerVertex[verticesMapID[pt[1]]].push_back(dd); m.mark(dd); - d = map.phi1(d); fsetemb.changeEmb(verticesMapID[pt[2]]); map.template foreach_dart_of_orbit(d, fsetemb); @@ -337,7 +330,6 @@ bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector< vecDartsPerVertex[verticesMapID[pt[2]]].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd)); vecDartsPerVertex[verticesMapID[pt[2]]].push_back(dd); m.mark(dd); - d = map.phi1(d); fsetemb.changeEmb(verticesMapID[pt[3]]); map.template foreach_dart_of_orbit(d, fsetemb); @@ -382,7 +374,6 @@ bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector< //end of hexa } CGoGNout << " / nb hexa = " << hexa.size()/2 << CGoGNendl; - } //Association des phi3 @@ -429,7 +420,7 @@ bool importNAS(typename PFP::MAP& map, const std::string& filename, std::vector< } // namespace Import -} +} // namespace Volume } // namespace Algo diff --git a/include/Algo/Import/importObjTex.h b/include/Algo/Import/importObjTex.h index 0d54977d..0313ac21 100644 --- a/include/Algo/Import/importObjTex.h +++ b/include/Algo/Import/importObjTex.h @@ -32,14 +32,16 @@ namespace CGoGN { + namespace Algo { + namespace Surface { + namespace Import { - class MaterialOBJ { public: @@ -80,16 +82,16 @@ public: // } }; - - template class OBJModel { - typedef typename PFP::VEC3 VEC3; + typedef typename PFP::VEC3 VEC3; + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef Geom::Vec2f VEC2; protected: - typename PFP::MAP& m_map; + MAP& m_map; // infof of sub-groups (group/material) std::vector m_beginIndices; @@ -129,30 +131,28 @@ protected: unsigned int m_tagG ; unsigned int m_tagF ; - void computeBB(const std::vector& pos); public: /// marker for special vertices (with several normals & tex coords) - CellMarker m_specialVertices; + CellMarker m_specialVertices; /// marker for darts with phi2 reconstruction face - DartMarker m_dirtyEdges; + DartMarker m_dirtyEdges; /// Face Attribute for group ID storage - FaceAttribute m_groups; - FaceAttribute m_attMat; + FaceAttribute m_groups; + FaceAttribute m_attMat; /// Vertex Attribute Handlers - VertexAttribute m_positions; - VertexAttribute m_normals; - VertexAttribute m_texCoords; + VertexAttribute m_positions; + VertexAttribute m_normals; + VertexAttribute m_texCoords; /// Vertex of face Attribute Handlers - AttributeHandler m_normalsF; - AttributeHandler m_texCoordsF; - + AttributeHandler m_normalsF; + AttributeHandler m_texCoordsF; /** * @brief Constructeur @@ -172,26 +172,25 @@ public: * @brief set position attribute * @param position attribute */ - void setPositionAttribute(VertexAttribute position); + void setPositionAttribute(VertexAttribute position); /** * @brief set position attribute * @param position attribute */ - void setNormalAttribute(VertexAttribute normal); + void setNormalAttribute(VertexAttribute normal); /** * @brief set texture coordinate attribute * @param texcoord attribute */ - void setTexCoordAttribute(VertexAttributetexcoord); - + void setTexCoordAttribute(VertexAttributetexcoord); - bool hasTexCoords() const { return m_tagVT!=0; } + bool hasTexCoords() const { return m_tagVT != 0; } - bool hasNormals() const { return m_tagVN!=0; } + bool hasNormals() const { return m_tagVN != 0; } - bool hasGroups() const { return m_tagG!=0; } + bool hasGroups() const { return m_tagG != 0; } /** * @brief import @@ -201,15 +200,13 @@ public: */ bool import(const std::string& filename, std::vector& attrNames); - - // Faire un handler ? /** * @brief getNormal * @param d * @return */ - typename PFP::VEC3 getNormal(Dart d); + VEC3 getNormal(Dart d); /** * @brief getTexCoord @@ -223,8 +220,7 @@ public: * @param d * @return */ - typename PFP::VEC3 getPosition(Dart d); - + VEC3 getPosition(Dart d); /** * @brief Generate one browser per group @@ -258,7 +254,6 @@ public: */ const std::vector& getMaterials() const { return m_materials;} - /** * @brief nb group of indices created by createGroupMatVBO_XXX * @return @@ -325,7 +320,7 @@ public: // unsigned int objGroup(unsigned int i) const { return m_objGroups[i]; } - const Geom::BoundingBox& getGroupBB(unsigned int i) const { return m_groupBBs[i];} + const Geom::BoundingBox& getGroupBB(unsigned int i) const { return m_groupBBs[i]; } Geom::BoundingBox& getGroupBB(unsigned int i) { return m_groupBBs[i];} @@ -355,7 +350,6 @@ public: */ unsigned int createSimpleVBO_PN(Utils::VBO* positionVBO, Utils::VBO* normalVBO); - /** * @brief create simple VBO for separated triangles * @param positionVBO @@ -365,7 +359,6 @@ public: */ unsigned int createSimpleVBO_PTN(Utils::VBO* positionVBO, Utils::VBO* texcoordVBO, Utils::VBO* normalVBO); - /** * @brief create VBOs with group by material * @param positionVBO @@ -374,6 +367,7 @@ public: * @return */ bool createGroupMatVBO_P(Utils::VBO* positionVBO); + /** * @brief create VBOs with group by material * @param positionVBO @@ -413,12 +407,14 @@ public: unsigned int storeFacesOfGroup(unsigned int groupId, std::vector& dartFaces); }; +} // namespace Import + +} // namepsace Surface + +} // namespace Algo -} -} -} // end namespaces -} +} // namespace CGoGN -#include "importObjTex.hpp" +#include "Algo/Import/importObjTex.hpp" #endif // IMPORTOBJTEX_H diff --git a/include/Algo/Import/importObjTex.hpp b/include/Algo/Import/importObjTex.hpp index 3e575e7c..72f5ee6c 100644 --- a/include/Algo/Import/importObjTex.hpp +++ b/include/Algo/Import/importObjTex.hpp @@ -28,17 +28,18 @@ #include #include - namespace CGoGN { + namespace Algo { + namespace Surface { + namespace Import { - template OBJModel::OBJModel(typename PFP::MAP& map): m_map(map), m_maxTextureSize(2048), @@ -47,7 +48,6 @@ OBJModel::OBJModel(typename PFP::MAP& map): { } - template OBJModel::~OBJModel() { @@ -55,24 +55,18 @@ OBJModel::~OBJModel() delete *it; } - - - template inline void OBJModel::setMaxTextureSize(unsigned int mts) { m_maxTextureSize = mts; } - template inline typename PFP::VEC3 OBJModel::getPosition(Dart d) { return m_positions[d]; } - - template inline typename PFP::VEC3 OBJModel::getNormal(Dart d) { @@ -81,7 +75,6 @@ inline typename PFP::VEC3 OBJModel::getNormal(Dart d) return m_normals[d]; } - template inline Geom::Vec2f OBJModel::getTexCoord(Dart d) { @@ -90,31 +83,24 @@ inline Geom::Vec2f OBJModel::getTexCoord(Dart d) return m_texCoords[d]; } - template -void OBJModel::setPositionAttribute(VertexAttribute position) +void OBJModel::setPositionAttribute(VertexAttribute position) { m_positions = position; } template -void OBJModel::setNormalAttribute(VertexAttribute normal) +void OBJModel::setNormalAttribute(VertexAttribute normal) { m_normals = normal; } template -void OBJModel::setTexCoordAttribute(VertexAttributetexcoord) +void OBJModel::setTexCoordAttribute(VertexAttributetexcoord) { m_texCoords = texcoord; } - - - - - - template void OBJModel::readMaterials(const std::string& filename) { @@ -270,7 +256,6 @@ void OBJModel::readMaterials(const std::string& filename) } - template unsigned int OBJModel::getMaterialIndex(const std::string& name) const { @@ -280,7 +265,6 @@ unsigned int OBJModel::getMaterialIndex(const std::string& name) const return 0xffffffff; } - //template //bool OBJModel::generateBrowsers(std::vector& browsers) //{ @@ -306,10 +290,6 @@ unsigned int OBJModel::getMaterialIndex(const std::string& name) const // } // return true; //} - - - - template short OBJModel::readObjLine(std::stringstream& oss, std::vector& indices) @@ -359,7 +339,6 @@ short OBJModel::readObjLine(std::stringstream& oss, std::vector unsigned int OBJModel::createSimpleVBO_P(Utils::VBO* positionVBO) { @@ -392,7 +371,6 @@ unsigned int OBJModel::createSimpleVBO_P(Utils::VBO* positionVBO) return 3*nbtris; } - template unsigned int OBJModel::createSimpleVBO_PT(Utils::VBO* positionVBO, Utils::VBO* texcoordVBO) { @@ -447,10 +425,6 @@ unsigned int OBJModel::createSimpleVBO_PT(Utils::VBO* positionVBO, Utils::V return 3*nbtris; } - - - - template unsigned int OBJModel::createSimpleVBO_PN(Utils::VBO* positionVBO, Utils::VBO* normalVBO ) { @@ -518,8 +492,6 @@ unsigned int OBJModel::createSimpleVBO_PN(Utils::VBO* positionVBO, Utils::V return 3*nbtris; } - - template unsigned int OBJModel::createSimpleVBO_PTN(Utils::VBO* positionVBO, Utils::VBO* texcoordVBO, Utils::VBO* normalVBO ) { @@ -534,7 +506,6 @@ unsigned int OBJModel::createSimpleVBO_PTN(Utils::VBO* positionVBO, Utils:: return 0; } - TraversorF traf(m_map); std::vector posBuff; std::vector TCBuff; @@ -630,11 +601,6 @@ unsigned int OBJModel::createSimpleVBO_PTN(Utils::VBO* positionVBO, Utils:: return 3*nbtris; } - - - - - template bool OBJModel::createGroupMatVBO_P( Utils::VBO* positionVBO) { @@ -652,7 +618,6 @@ bool OBJModel::createGroupMatVBO_P( Utils::VBO* positionVBO) return false; } - std::vector< std::vector > group_faces; //(m_materialNames.size()); group_faces.reserve(16384); m_groupIdx.reserve(16384); @@ -670,13 +635,11 @@ bool OBJModel::createGroupMatVBO_P( Utils::VBO* positionVBO) m_groupFirstSub.push_back(0); - if (m_tagG != 0) m_groupIdx.push_back(c_grp); else m_groupIdx.push_back(0); - while (d!= traf.end()) { if ((m_groups[d] != c_grp) || (m_attMat[d] != c_mat)) @@ -707,7 +670,6 @@ bool OBJModel::createGroupMatVBO_P( Utils::VBO* positionVBO) m_groupNbSub.push_back(c_sg+1-m_groupFirstSub.back()); // nb sub-group of last group - // merging same material sub-groups of same group for (unsigned int g=0; g::createGroupMatVBO_P( Utils::VBO* positionVBO) } m_groupNbSub[outGr+1] = m_sgMat.size() - m_groupNbSub[outGr]; - // now create VBOs std::vector posBuff; @@ -825,9 +786,6 @@ bool OBJModel::createGroupMatVBO_P( Utils::VBO* positionVBO) return true; } - - - //template //bool OBJModel::createGroupMatVBO_P(Utils::VBO* positionVBO) //{ @@ -892,9 +850,6 @@ bool OBJModel::createGroupMatVBO_P( Utils::VBO* positionVBO) // return true; //} - - - template bool OBJModel::createGroupMatVBO_PT( Utils::VBO* positionVBO, Utils::VBO* texcoordVBO) @@ -913,7 +868,6 @@ bool OBJModel::createGroupMatVBO_PT( Utils::VBO* positionVBO, return false; } - std::vector< std::vector > group_faces; //(m_materialNames.size()); group_faces.reserve(16384); m_groupIdx.reserve(16384); @@ -931,13 +885,11 @@ bool OBJModel::createGroupMatVBO_PT( Utils::VBO* positionVBO, m_groupFirstSub.push_back(0); - if (m_tagG != 0) m_groupIdx.push_back(c_grp); else m_groupIdx.push_back(0); - while (d!= traf.end()) { if ((m_groups[d] != c_grp) || (m_attMat[d] != c_mat)) @@ -968,7 +920,6 @@ bool OBJModel::createGroupMatVBO_PT( Utils::VBO* positionVBO, m_groupNbSub.push_back(c_sg+1-m_groupFirstSub.back()); // nb sub-group of last group - // merging same material sub-groups of same group for (unsigned int g=0; g::createGroupMatVBO_PT( Utils::VBO* positionVBO, } m_groupNbSub[outGr+1] = m_sgMat.size() - m_groupNbSub[outGr]; - // now create VBOs std::vector posBuff; @@ -1033,7 +983,6 @@ bool OBJModel::createGroupMatVBO_PT( Utils::VBO* positionVBO, posBuff.reserve(16384); TCBuff.reserve(16384); - unsigned int firstIndex = 0; unsigned int sz = group_faces.size(); @@ -1112,10 +1061,6 @@ bool OBJModel::createGroupMatVBO_PT( Utils::VBO* positionVBO, return true; } - - - - template bool OBJModel::createGroupMatVBO_PN( Utils::VBO* positionVBO, Utils::VBO* normalVBO) @@ -1129,7 +1074,6 @@ bool OBJModel::createGroupMatVBO_PN( Utils::VBO* positionVBO, return false; } - std::vector< std::vector > group_faces; //(m_materialNames.size()); group_faces.reserve(16384); m_groupIdx.reserve(16384); @@ -1147,13 +1091,11 @@ bool OBJModel::createGroupMatVBO_PN( Utils::VBO* positionVBO, m_groupFirstSub.push_back(0); - if (m_tagG != 0) m_groupIdx.push_back(c_grp); else m_groupIdx.push_back(0); - while (d!= traf.end()) { if ((m_groups[d] != c_grp) || (m_attMat[d] != c_mat)) @@ -1184,7 +1126,6 @@ bool OBJModel::createGroupMatVBO_PN( Utils::VBO* positionVBO, m_groupNbSub.push_back(c_sg+1-m_groupFirstSub.back()); // nb sub-group of last group - // merging same material sub-groups of same group for (unsigned int g=0; g::createGroupMatVBO_PN( Utils::VBO* positionVBO, } m_groupNbSub[outGr+1] = m_sgMat.size() - m_groupNbSub[outGr]; - // now create VBOs std::vector posBuff; @@ -1328,14 +1268,11 @@ bool OBJModel::createGroupMatVBO_PN( Utils::VBO* positionVBO, return true; } - - - - template -bool OBJModel::createGroupMatVBO_PTN( Utils::VBO* positionVBO, - Utils::VBO* texcoordVBO, - Utils::VBO* normalVBO) +bool OBJModel::createGroupMatVBO_PTN( + Utils::VBO* positionVBO, + Utils::VBO* texcoordVBO, + Utils::VBO* normalVBO) { m_beginIndices.clear(); m_nbIndices.clear(); @@ -1351,7 +1288,6 @@ bool OBJModel::createGroupMatVBO_PTN( Utils::VBO* positionVBO, return false; } - std::vector< std::vector > group_faces; //(m_materialNames.size()); group_faces.reserve(16384); m_groupIdx.reserve(16384); @@ -1369,13 +1305,11 @@ bool OBJModel::createGroupMatVBO_PTN( Utils::VBO* positionVBO, m_groupFirstSub.push_back(0); - if (m_tagG != 0) m_groupIdx.push_back(c_grp); else m_groupIdx.push_back(0); - while (d!= traf.end()) { if ((m_groups[d] != c_grp) || (m_attMat[d] != c_mat)) @@ -1406,7 +1340,6 @@ bool OBJModel::createGroupMatVBO_PTN( Utils::VBO* positionVBO, m_groupNbSub.push_back(c_sg+1-m_groupFirstSub.back()); // nb sub-group of last group - // merging same material sub-groups of same group for (unsigned int g=0; g::createGroupMatVBO_PTN( Utils::VBO* positionVBO, } m_groupNbSub[outGr+1] = m_sgMat.size() - m_groupNbSub[outGr]; - // now create VBOs std::vector posBuff; @@ -1473,7 +1405,6 @@ bool OBJModel::createGroupMatVBO_PTN( Utils::VBO* positionVBO, TCBuff.reserve(16384); normalBuff.reserve(16384); - unsigned int firstIndex = 0; unsigned int sz = group_faces.size(); @@ -1571,9 +1502,6 @@ bool OBJModel::createGroupMatVBO_PTN( Utils::VBO* positionVBO, return true; } - - - template void OBJModel::computeBB(const std::vector& pos) { @@ -1594,15 +1522,13 @@ void OBJModel::computeBB(const std::vector& pos) bb.addPoint(pos[j]); } } - } - - - template bool OBJModel::import( const std::string& filename, std::vector& attrNames) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; typedef Geom::Vec2f VEC2; @@ -1643,17 +1569,13 @@ bool OBJModel::import( const std::string& filename, std::vector("position") ; if (!m_positions.isValid()) m_positions = m_map.template addAttribute("position") ; attrNames.push_back(m_positions.name()) ; - - m_texCoords = m_map.template getAttribute("texCoord") ; if (!m_texCoords.isValid()) m_texCoords = m_map.template addAttribute("texCoord") ; @@ -1677,7 +1599,6 @@ bool OBJModel::import( const std::string& filename, std::vector("normalF") ; } - // if (m_tagG != 0) always use group even if not in the file { @@ -1712,21 +1633,19 @@ bool OBJModel::import( const std::string& filename, std::vector texCoordsID; texCoordsID.reserve(m_tagV); - std::vector localIndices; localIndices.reserve(64*3); FunctorInitEmb fsetemb(m_map); - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecDartsPerVertex(m_map, "incidents"); - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecNormIndPerVertex(m_map, "incidentsN"); - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecTCIndPerVertex(m_map, "incidentsTC"); + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecDartsPerVertex(m_map, "incidents"); + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecNormIndPerVertex(m_map, "incidentsN"); + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecTCIndPerVertex(m_map, "incidentsTC"); int currentGroup = -1; unsigned int currentMat = 0; unsigned int nextMat = 0; - - DartMarkerNoUnmark mk(m_map) ; + DartMarkerNoUnmark mk(m_map) ; unsigned int i = 0; fp >> tag; std::getline(fp, ligne); @@ -1858,7 +1777,7 @@ bool OBJModel::import( const std::string& filename, std::vector(d); + mk.template unmarkOrbit(d); } else { @@ -1872,7 +1791,7 @@ bool OBJModel::import( const std::string& filename, std::vector tra(m_map); + TraversorV tra(m_map); for (Dart d = tra.begin(); d != tra.end(); d = tra.next()) { std::vector& vec = vecDartsPerVertex[d]; @@ -1921,11 +1840,9 @@ bool OBJModel::import( const std::string& filename, std::vector @@ -1945,8 +1862,10 @@ unsigned int OBJModel::storeFacesOfGroup(unsigned int groupId, std::vector< return dartFaces.size()-nb; } +} // namespace Import -} -} -} // end namespaces -} +} // namespace Surface + +} // namespace Algo + +} // namespace CGoGN diff --git a/include/Algo/Import/importVBGZ.hpp b/include/Algo/Import/importVBGZ.hpp index 54aa2008..4153437e 100644 --- a/include/Algo/Import/importVBGZ.hpp +++ b/include/Algo/Import/importVBGZ.hpp @@ -41,14 +41,16 @@ namespace Import template bool importVBGZ(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, float scaleFactor) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; - VertexAttribute position = map.template addAttribute("position") ; + VertexAttribute position = map.template addAttribute("position") ; attrNames.push_back(position.name()) ; AttributeContainer& container = map.template getAttributeContainer() ; - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecDartsPerVertex(map, "incidents"); + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecDartsPerVertex(map, "incidents"); //open file igzstream fs(filename.c_str(), std::ios::in|std::ios::binary); @@ -58,7 +60,6 @@ bool importVBGZ(typename PFP::MAP& map, const std::string& filename, std::vector return false; } - unsigned int numbers[3]; // read nb of points @@ -94,8 +95,7 @@ bool importVBGZ(typename PFP::MAP& map, const std::string& filename, std::vector } CGoGNout << "nb vertices = " << numbers[0]; - - DartMarkerNoUnmark m(map) ; + DartMarkerNoUnmark m(map) ; if (numbers[1] > 0) { @@ -114,7 +114,7 @@ bool importVBGZ(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, verticesID[pt[j]]); + FunctorSetEmb fsetemb(map, verticesID[pt[j]]); map.template foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction @@ -133,7 +133,7 @@ bool importVBGZ(typename PFP::MAP& map, const std::string& filename, std::vector d = map.template phi<211>(d); //d = map.phi_1(map.phi2(d)); - FunctorSetEmb fsetemb(map, verticesID[pt[3]]); + FunctorSetEmb fsetemb(map, verticesID[pt[3]]); map.template foreach_dart_of_orbit(d, fsetemb); //store darts per vertex to optimize reconstruction @@ -153,7 +153,6 @@ bool importVBGZ(typename PFP::MAP& map, const std::string& filename, std::vector if (numbers[2] > 0) { - //Read and embed all tetrahedrons for(unsigned int i = 0; i < numbers[2] ; ++i) { @@ -170,7 +169,7 @@ bool importVBGZ(typename PFP::MAP& map, const std::string& filename, std::vector Dart d = Surface::Modelisation::createHexahedron(map,false); - FunctorSetEmb fsetemb(map, verticesID[pt[0]]); + FunctorSetEmb fsetemb(map, verticesID[pt[0]]); map.template foreach_dart_of_orbit(d, fsetemb); Dart dd = d; @@ -186,7 +185,6 @@ bool importVBGZ(typename PFP::MAP& map, const std::string& filename, std::vector vecDartsPerVertex[verticesID[pt[1]]].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd)); vecDartsPerVertex[verticesID[pt[1]]].push_back(dd); m.mark(dd); - d = map.phi1(d); fsetemb.changeEmb(verticesID[pt[2]]); map.template foreach_dart_of_orbit(d, fsetemb); @@ -195,7 +193,6 @@ bool importVBGZ(typename PFP::MAP& map, const std::string& filename, std::vector vecDartsPerVertex[verticesID[pt[2]]].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd)); vecDartsPerVertex[verticesID[pt[2]]].push_back(dd); m.mark(dd); - d = map.phi1(d); fsetemb.changeEmb(verticesID[pt[3]]); map.template foreach_dart_of_orbit(d, fsetemb); @@ -287,7 +284,7 @@ bool importVBGZ(typename PFP::MAP& map, const std::string& filename, std::vector } // namespace Import -} +} // namespace Volume } // namespace Algo diff --git a/include/Algo/Import/importVTU.hpp b/include/Algo/Import/importVTU.hpp index 5d2062bb..58257f99 100644 --- a/include/Algo/Import/importVTU.hpp +++ b/include/Algo/Import/importVTU.hpp @@ -46,19 +46,20 @@ namespace Import template bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector& attrNames, float scaleFactor) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; - VertexAttribute position = map.template addAttribute("position") ; + VertexAttribute position = map.template addAttribute("position") ; attrNames.push_back(position.name()) ; AttributeContainer& container = map.template getAttributeContainer() ; - VertexAutoAttribute< NoTypeNameAttribute< std::vector > > vecDartsPerVertex(map, "incidents"); + VertexAutoAttribute< NoTypeNameAttribute< std::vector >, MAP_IMPL> vecDartsPerVertex(map, "incidents"); xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0); xmlNodePtr vtu_node = xmlDocGetRootElement(doc); - // std::cout << " NAME "<name << std::endl; xmlChar *prop = xmlGetProp(vtu_node, BAD_CAST "type"); @@ -103,14 +104,12 @@ bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector< verticesID.push_back(id); } - xmlNode* cell_node = piece_node->children; while (strcmp((char*)(cell_node->name),(char*)"Cells")!=0) cell_node = cell_node->next; std::cout <<"CELL NODE = "<< cell_node->name << std::endl; - std::vector typeVols; typeVols.reserve(nbVolumes); std::vector offsets; @@ -118,7 +117,6 @@ bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector< std::vector indices; indices.reserve(nbVolumes*4); - for (xmlNode* x_node = cell_node->children; x_node!=NULL; x_node = x_node->next) { while ((x_node!=NULL) && (strcmp((char*)(x_node->name),(char*)"DataArray")!=0)) @@ -176,14 +174,14 @@ bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector< xmlFreeDoc(doc); - DartMarkerNoUnmark m(map) ; + DartMarkerNoUnmark m(map) ; unsigned int currentOffset = 0; - for (unsigned int i=0; i< nbVolumes; ++i) + for (unsigned int i = 0; i < nbVolumes; ++i) { if (typeVols[i]==12) { - Dart d = Surface::Modelisation::createHexahedron(map,false); + Dart d = Surface::Modelisation::createHexahedron(map, false); unsigned int pt[8]; pt[0] = indices[currentOffset]; @@ -196,7 +194,7 @@ bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector< typename PFP::VEC3 B = position[verticesID[indices[currentOffset+1]]]; typename PFP::VEC3 C = position[verticesID[indices[currentOffset+2]]]; - if (Geom::testOrientation3D(P,A,B,C) == Geom::OVER) + if (Geom::testOrientation3D(P,A,B,C) == Geom::OVER) { pt[0] = indices[currentOffset+3]; @@ -220,8 +218,7 @@ bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector< pt[7] = indices[currentOffset+7]; } - - FunctorSetEmb fsetemb(map, verticesID[pt[0]]); + FunctorSetEmb fsetemb(map, verticesID[pt[0]]); map.template foreach_dart_of_orbit(d, fsetemb); Dart dd = d; @@ -237,7 +234,6 @@ bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector< vecDartsPerVertex[verticesID[pt[1]]].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd)); vecDartsPerVertex[verticesID[pt[1]]].push_back(dd); m.mark(dd); - d = map.phi1(d); fsetemb.changeEmb(verticesID[pt[2]]); map.template foreach_dart_of_orbit(d, fsetemb); @@ -246,7 +242,6 @@ bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector< vecDartsPerVertex[verticesID[pt[2]]].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd)); vecDartsPerVertex[verticesID[pt[2]]].push_back(dd); m.mark(dd); - d = map.phi1(d); fsetemb.changeEmb(verticesID[pt[3]]); map.template foreach_dart_of_orbit(d, fsetemb); @@ -303,7 +298,7 @@ bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector< typename PFP::VEC3 B = position[verticesID[pt[2]]]; typename PFP::VEC3 C = position[verticesID[pt[3]]]; - if (Geom::testOrientation3D(P,A,B,C) == Geom::OVER) + if (Geom::testOrientation3D(P,A,B,C) == Geom::OVER) { unsigned int ui=pt[1]; pt[1] = pt[2]; @@ -313,7 +308,7 @@ bool importVTU(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, verticesID[pt[2-j]]); + FunctorSetEmb fsetemb(map, verticesID[pt[2-j]]); map.template foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction @@ -331,7 +326,7 @@ bool importVTU(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, verticesID[pt[3]]); + FunctorSetEmb fsetemb(map, verticesID[pt[3]]); map.template foreach_dart_of_orbit(d, fsetemb); //store darts per vertices to optimize reconstruction @@ -347,7 +342,6 @@ bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector< currentOffset = offsets[i]; } - //Association des phi3 unsigned int nbBoundaryFaces = 0 ; for (Dart d = map.begin(); d != map.end(); map.next(d)) @@ -391,7 +385,7 @@ bool importVTU(typename PFP::MAP& map, const std::string& filename, std::vector< } // namespace Import -} +} // namespace Volume } // namespace Algo diff --git a/include/Algo/MC/marchingcube.h b/include/Algo/MC/marchingcube.h index bec7a589..d7a2da93 100644 --- a/include/Algo/MC/marchingcube.h +++ b/include/Algo/MC/marchingcube.h @@ -49,12 +49,13 @@ namespace MC * @param DataType the type of voxel image * @param Windowing the windowing class which allow to distinguish inside from outside */ -template< typename DataType, template < typename D2 > class Windowing, typename PFP > +template class Windowing, typename PFP> class MarchingCube { protected: typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::MAP L_MAP ; + typedef typename PFP::MAP::IMPL L_MAP_IMPL ; typedef Dart L_DART ; #ifdef MC_WIDTH_EDGE_Z_EMBEDED @@ -84,7 +85,7 @@ protected: */ L_MAP* m_map; - VertexAttribute& m_positions; + VertexAttribute& m_positions; /** * Origin of image @@ -227,7 +228,7 @@ public: * @param wind the windowing class (for inside/outside distinguish) * @param boundRemoved true is bound is going to be removed */ - MarchingCube(Image* img, L_MAP* map, VertexAttribute& position, Windowing wind, bool boundRemoved); + MarchingCube(Image* img, L_MAP* map, VertexAttribute& position, Windowing wind, bool boundRemoved); /** * destructor @@ -265,24 +266,23 @@ public: */ Geom::Vec3f boundMax() const { return m_Image->boundMax(); } - void removeFacesOfBoundary(VertexAttribute& boundVertices, unsigned int frameWidth); + void removeFacesOfBoundary(VertexAttribute& boundVertices, unsigned int frameWidth); void recalPoints(const Geom::Vec3f& origin); - #ifdef MC_WIDTH_EDGE_Z_EMBEDED - void setZSliceAttrib(EdgeAttribute* zsatt, unsigned int zbound, unsigned int nbZone); + void setZSliceAttrib(EdgeAttribute* zsatt, unsigned int zbound, unsigned int nbZone); #endif - }; } // namespace MC -} +} // namespace Surface } // namespace Algo } // namespace CGoGN #include "Algo/MC/marchingcube.hpp" + #endif diff --git a/include/Algo/MC/marchingcube.hpp b/include/Algo/MC/marchingcube.hpp index a57a5148..b76a3a3b 100644 --- a/include/Algo/MC/marchingcube.hpp +++ b/include/Algo/MC/marchingcube.hpp @@ -46,43 +46,40 @@ MarchingCube::MarchingCube(const char* _cName) m_Buffer = NULL; m_map = NULL; - m_fOrigin = typename PFP::VEC3(0.0,0.0,0.0); - m_fScal = typename PFP::VEC3(1.0,1.0,1.0); + m_fOrigin = VEC3(0.0,0.0,0.0); + m_fScal = VEC3(1.0,1.0,1.0); #ifdef MC_WIDTH_EDGE_Z_EMBEDED m_currentZSlice = 0; m_zslice = NULL; #endif - } - template< typename DataType, template < typename D2 > class Windowing, typename PFP > MarchingCube::MarchingCube(Image* img, Windowing wind, bool boundRemoved): m_Image(img), m_windowFunc(wind), m_Buffer(NULL), m_map(NULL), - m_fOrigin(typename PFP::VEC3(0.0,0.0,0.0)), - m_fScal(typename PFP::VEC3(1.0,1.0,1.0)), + m_fOrigin(VEC3(0.0,0.0,0.0)), + m_fScal(VEC3(1.0,1.0,1.0)), m_brem(boundRemoved) { #ifdef MC_WIDTH_EDGE_Z_EMBEDED m_currentZSlice = 0; m_zslice = NULL; #endif - } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -MarchingCube::MarchingCube(Image* img, L_MAP* map, VertexAttribute& position, Windowing wind, bool boundRemoved): +MarchingCube::MarchingCube(Image* img, L_MAP* map, VertexAttribute& position, Windowing wind, bool boundRemoved): m_Image(img), m_windowFunc(wind), m_Buffer(NULL), m_map(map), m_positions(position), - m_fOrigin(typename PFP::VEC3(0.0,0.0,0.0)), - m_fScal(typename PFP::VEC3(1.0,1.0,1.0)), + m_fOrigin(VEC3(0.0,0.0,0.0)), + m_fScal(VEC3(1.0,1.0,1.0)), m_brem(boundRemoved) { #ifdef MC_WIDTH_EDGE_Z_EMBEDED @@ -154,7 +151,7 @@ void MarchingCube::simpleMeshing() // compute value to transform points directly to final system coordinate - m_fOrigin = typename PFP::VEC3((float)(m_Image->getOrigin()[0]),(float)(m_Image->getOrigin()[1]),(float)(m_Image->getOrigin()[2])); + m_fOrigin = VEC3((float)(m_Image->getOrigin()[0]),(float)(m_Image->getOrigin()[1]),(float)(m_Image->getOrigin()[2])); m_fScal[0] = m_Image->getVoxSizeX(); m_fScal[1] = m_Image->getVoxSizeY(); @@ -287,9 +284,9 @@ unsigned char MarchingCube::computeIndex(const DataTyp } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -typename PFP::VEC3 MarchingCube::recalPoint(const typename PFP::VEC3& _P, const typename PFP::VEC3& _dec ) const +typename PFP::VEC3 MarchingCube::recalPoint(const VEC3& _P, const VEC3& _dec ) const { - typename PFP::VEC3 point = _P + _dec ; + VEC3 point = _P + _dec ; // point[0] = point[0] * m_fScal[0]; // point[1] = point[1] * m_fScal[1]; // point[2] = point[2] * m_fScal[2]; @@ -299,181 +296,181 @@ typename PFP::VEC3 MarchingCube::recalPoint(const type } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge0(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge0(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 1) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX,_lY,_lZ), m_Image->getVoxel(_lX+1,_lY,_lZ) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(interp, 0., 0.)); +// VEC3 newPoint = recalPoint(vPos,VEC3(interp, 0., 0.)); // lVertTable[0] = L_EMB::create(newPoint); lVertTable[0] = m_map->template newCell(); - m_positions[lVertTable[0]] = recalPoint(vPos,typename PFP::VEC3(interp, 0., 0.)); + m_positions[lVertTable[0]] = recalPoint(vPos,VEC3(interp, 0., 0.)); m_Buffer->setPointEdge0(_lX, _lY,lVertTable[0]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge1(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge1(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 2) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX,_lY,_lZ), m_Image->getVoxel(_lX,_lY+1,_lZ) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(1.,interp, 0.)); +// VEC3 newPoint = recalPoint(vPos,VEC3(1.,interp, 0.)); // lVertTable[1] = L_EMB::create(newPoint); lVertTable[1] = m_map->template newCell(); - m_positions[lVertTable[1]] = recalPoint(vPos,typename PFP::VEC3(1.,interp, 0.)); + m_positions[lVertTable[1]] = recalPoint(vPos,VEC3(1.,interp, 0.)); m_Buffer->setPointEdge1(_lX, _lY,lVertTable[1]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge2(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge2(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 4) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX-1,_lY,_lZ), m_Image->getVoxel(_lX,_lY,_lZ) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(interp, 1., 0.)); +// VEC3 newPoint = recalPoint(vPos,VEC3(interp, 1., 0.)); // lVertTable[2] = L_EMB::create(newPoint); lVertTable[2] = m_map->template newCell(); - m_positions[lVertTable[2]] = recalPoint(vPos,typename PFP::VEC3(interp, 1., 0.)); + m_positions[lVertTable[2]] = recalPoint(vPos,VEC3(interp, 1., 0.)); m_Buffer->setPointEdge2(_lX, _lY,lVertTable[2]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge3(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge3(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 8) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX,_lY-1,_lZ), m_Image->getVoxel(_lX,_lY,_lZ) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(0., interp, 0.)); +// VEC3 newPoint = recalPoint(vPos,VEC3(0., interp, 0.)); // lVertTable[3] = L_EMB::create(newPoint); lVertTable[3] = m_map->template newCell(); - m_positions[lVertTable[3]] = recalPoint(vPos,typename PFP::VEC3(0., interp, 0.)); + m_positions[lVertTable[3]] = recalPoint(vPos,VEC3(0., interp, 0.)); m_Buffer->setPointEdge3(_lX, _lY,lVertTable[3]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge4(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge4(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 16) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX,_lY,_lZ), m_Image->getVoxel(_lX+1,_lY,_lZ) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(interp, 0., 1.)); +// VEC3 newPoint = recalPoint(vPos,VEC3(interp, 0., 1.)); // lVertTable[4] = L_EMB::create(newPoint); lVertTable[4] = m_map->template newCell(); - m_positions[lVertTable[4]] = recalPoint(vPos,typename PFP::VEC3(interp, 0., 1.)); + m_positions[lVertTable[4]] = recalPoint(vPos,VEC3(interp, 0., 1.)); m_Buffer->setPointEdge4(_lX, _lY,lVertTable[4]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge5(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge5(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 32) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX,_lY,_lZ), m_Image->getVoxel(_lX,_lY+1,_lZ) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(1., interp, 1.)); +// VEC3 newPoint = recalPoint(vPos,VEC3(1., interp, 1.)); // lVertTable[5] = L_EMB::create(newPoint); lVertTable[5] = m_map->template newCell(); - m_positions[lVertTable[5]] = recalPoint(vPos,typename PFP::VEC3(1., interp, 1.)); + m_positions[lVertTable[5]] = recalPoint(vPos,VEC3(1., interp, 1.)); m_Buffer->setPointEdge5(_lX, _lY,lVertTable[5]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge6(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge6(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 64) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX-1,_lY,_lZ), m_Image->getVoxel(_lX,_lY,_lZ) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(interp, 1., 1.)); +// VEC3 newPoint = recalPoint(vPos,VEC3(interp, 1., 1.)); // lVertTable[6] = L_EMB::create(newPoint); lVertTable[6] = m_map->template newCell(); - m_positions[lVertTable[6]] = recalPoint(vPos,typename PFP::VEC3(interp, 1., 1.)); + m_positions[lVertTable[6]] = recalPoint(vPos,VEC3(interp, 1., 1.)); m_Buffer->setPointEdge6(_lX, _lY,lVertTable[6]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge7(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge7(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 128) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX,_lY-1,_lZ), m_Image->getVoxel(_lX,_lY,_lZ) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(0., interp, 1.)); +// VEC3 newPoint = recalPoint(vPos,VEC3(0., interp, 1.)); // lVertTable[7] = L_EMB::create(newPoint); lVertTable[7] = m_map->template newCell(); - m_positions[lVertTable[7]] = recalPoint(vPos,typename PFP::VEC3(0., interp, 1.)); + m_positions[lVertTable[7]] = recalPoint(vPos,VEC3(0., interp, 1.)); m_Buffer->setPointEdge7(_lX, _lY,lVertTable[7]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge8(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge8(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 256) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX,_lY,_lZ), m_Image->getVoxel(_lX,_lY,_lZ+1) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(0., 0., interp)); +// VEC3 newPoint = recalPoint(vPos,VEC3(0., 0., interp)); // lVertTable[8] = L_EMB::create(newPoint); lVertTable[8] = m_map->template newCell(); - m_positions[lVertTable[8]] = recalPoint(vPos,typename PFP::VEC3(0., 0., interp)); + m_positions[lVertTable[8]] = recalPoint(vPos,VEC3(0., 0., interp)); m_Buffer->setPointEdge8(_lX, _lY,lVertTable[8]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge9(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge9(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 512) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX,_lY,_lZ), m_Image->getVoxel(_lX,_lY,_lZ+1) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(1., 0., interp)); +// VEC3 newPoint = recalPoint(vPos,VEC3(1., 0., interp)); // lVertTable[9] = L_EMB::create(newPoint); lVertTable[9] = m_map->template newCell(); - m_positions[lVertTable[9]] = recalPoint(vPos,typename PFP::VEC3(1., 0., interp)); + m_positions[lVertTable[9]] = recalPoint(vPos,VEC3(1., 0., interp)); m_Buffer->setPointEdge9(_lX, _lY,lVertTable[9]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge10(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge10(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 1024) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX,_lY,_lZ), m_Image->getVoxel(_lX,_lY,_lZ+1) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(1., 1., interp)); +// VEC3 newPoint = recalPoint(vPos,VEC3(1., 1., interp)); // lVertTable[10] = L_EMB::create(newPoint); lVertTable[10] = m_map->template newCell(); - m_positions[lVertTable[10]] = recalPoint(vPos,typename PFP::VEC3(1., 1., interp)); + m_positions[lVertTable[10]] = recalPoint(vPos,VEC3(1., 1., interp)); m_Buffer->setPointEdge10(_lX, _lY,lVertTable[10]); } } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createPointEdge11(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const typename PFP::VEC3& vPos) +void MarchingCube::createPointEdge11(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int * const lVertTable, const VEC3& vPos) { if (accelMCTable::m_EdgeTable[_ucCubeIndex] & 2048) { float interp = m_windowFunc.interpole( m_Image->getVoxel(_lX,_lY,_lZ), m_Image->getVoxel(_lX,_lY,_lZ+1) ); -// typename PFP::VEC3 newPoint = recalPoint(vPos,typename PFP::VEC3(0., 1., interp)); +// VEC3 newPoint = recalPoint(vPos,VEC3(0., 1., interp)); // lVertTable[11] = L_EMB::create(newPoint); lVertTable[11] = m_map->template newCell(); - m_positions[lVertTable[11]] = recalPoint(vPos,typename PFP::VEC3(0., 1., interp)); + m_positions[lVertTable[11]] = recalPoint(vPos,VEC3(0., 1., interp)); m_Buffer->setPointEdge11(_lX, _lY,lVertTable[11]); } } @@ -487,9 +484,9 @@ void MarchingCube::createFaces_1(DataType *vox, const unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos(float(_lX) , float(_lY) , float(_lZ) ); -// typename PFP::VEC3 vPos(float(_lX) + 0.5f, float(_lY) + 0.5f, (float)_lZ + 0.5f); - typename PFP::VEC3 vPos(_lX, _lY, _lZ); +// VEC3 vPos(float(_lX) , float(_lY) , float(_lZ) ); +// VEC3 vPos(float(_lX) + 0.5f, float(_lY) + 0.5f, (float)_lZ + 0.5f); + VEC3 vPos(_lX, _lY, _lZ); // create the new vertices @@ -546,7 +543,7 @@ void MarchingCube::createFaces_2(DataType *vox, const return; unsigned int lVertTable[12]; - typename PFP::VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX; @@ -597,7 +594,7 @@ void MarchingCube::createFaces_3(DataType *vox, const return; unsigned int lVertTable[12]; - typename PFP::VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX; @@ -649,7 +646,7 @@ void MarchingCube::createFaces_4(DataType *vox, const return; unsigned int lVertTable[12]; - typename PFP::VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX; @@ -704,7 +701,7 @@ void MarchingCube::createFaces_5(DataType *vox, const return; unsigned int lVertTable[12]; - typename PFP::VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX; @@ -757,7 +754,7 @@ void MarchingCube::createFaces_6(DataType *vox, const return; unsigned int lVertTable[12]; - typename PFP::VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX+1; @@ -815,7 +812,7 @@ void MarchingCube::createFaces_7(DataType *vox, const return; unsigned int lVertTable[12]; - typename PFP::VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX+1; @@ -873,7 +870,7 @@ void MarchingCube::createFaces_8(DataType *vox, const return; unsigned int lVertTable[12]; - typename PFP::VEC3 vPos(_lX, _lY, _lZ); + VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX+1; @@ -1155,7 +1152,7 @@ void MarchingCube::createLocalFaces(const unsigned cha } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::removeFacesOfBoundary(VertexAttribute& boundVertices, unsigned int frameWidth) +void MarchingCube::removeFacesOfBoundary(VertexAttribute& boundVertices, unsigned int frameWidth) { float xmin = frameWidth; float xmax = m_Image->getWidthX() - frameWidth -1; @@ -1180,7 +1177,7 @@ void MarchingCube::removeFacesOfBoundary(VertexAttribu } // traverse face and check if all vertices are bound - DartMarker mf(*m_map); + DartMarker mf(*m_map); for (Dart d = m_map->begin(); d != m_map->end();) // next done inside loop because of deleteFace { if (!mf.isMarked(d) && !m_map->isBoundaryMarked2(d)) @@ -1225,10 +1222,9 @@ void MarchingCube::removeFacesOfBoundary(VertexAttribu template< typename DataType, template < typename D2 > class Windowing, typename PFP > void MarchingCube::recalPoints(const Geom::Vec3f& origin) { - for(unsigned int i=m_positions.begin(); i != m_positions.end(); m_positions.next(i)) { - typename PFP::VEC3& P = m_positions[i]; + VEC3& P = m_positions[i]; P -= m_fOrigin; P[0] = (P[0]+0.5f) * m_fScal[0]; P[1] = (P[1]+0.5f) * m_fScal[1]; @@ -1249,10 +1245,9 @@ void MarchingCube::setZSliceAttrib(EdgeAttribute -Dart extrusion_scale(typename PFP::MAP& the_map, VertexAttribute& positions, +Dart extrusion_scale( + typename PFP::MAP& the_map, + VertexAttribute& positions, const std::vector& profile, const typename PFP::VEC3& centerProfile, const typename PFP::VEC3& normalProfile, @@ -83,7 +85,9 @@ Dart extrusion_scale(typename PFP::MAP& the_map, VertexAttribute //Polyhedron* extrusion_scale_prim(typename PFP::MAP& the_map, VertexAttribute& positions, -Algo::Surface::Tilings::Tiling* extrusion_scale_prim(typename PFP::MAP& the_map, VertexAttribute& positions, +Algo::Surface::Tilings::Tiling* extrusion_scale_prim( + typename PFP::MAP& the_map, + VertexAttribute& positions, const std::vector& profile, const typename PFP::VEC3& centerProfile, const typename PFP::VEC3& normalProfile, @@ -108,7 +112,9 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim(typename PFP::MAP& the */ template //Polyhedron* extrusion_prim(typename PFP::MAP& the_map, VertexAttribute& positions, -Algo::Surface::Tilings::Tiling* extrusion_prim(typename PFP::MAP& the_map, VertexAttribute& positions, +Algo::Surface::Tilings::Tiling* extrusion_prim( + typename PFP::MAP& the_map, + VertexAttribute& positions, const std::vector& profile, const typename PFP::VEC3& centerProfile, const typename PFP::VEC3& normalProfile, @@ -129,7 +135,9 @@ Algo::Surface::Tilings::Tiling* extrusion_prim(typename PFP::MAP& the_map, * size of vector must be the same as path */ template -Dart extrusion(typename PFP::MAP& the_map, VertexAttribute& positions, +Dart extrusion( + typename PFP::MAP& the_map, + VertexAttribute& positions, const std::vector& profile, const typename PFP::VEC3& centerProfile, const typename PFP::VEC3& normal, @@ -149,7 +157,9 @@ Dart extrusion(typename PFP::MAP& the_map, VertexAttribute& */ template //Polyhedron* revolution_prim(typename PFP::MAP& the_map, VertexAttribute& positions, -Algo::Surface::Tilings::Tiling* revolution_prim(typename PFP::MAP& the_map, VertexAttribute& positions, +Algo::Surface::Tilings::Tiling* revolution_prim( + typename PFP::MAP& the_map, + VertexAttribute& positions, const std::vector& profile, const typename PFP::VEC3& center, const typename PFP::VEC3& axis, @@ -167,7 +177,9 @@ Algo::Surface::Tilings::Tiling* revolution_prim(typename PFP::MAP& the_map, * @param nbSide number of steps around the revolution */ template -Dart revolution(typename PFP::MAP& the_map, VertexAttribute& positions, +Dart revolution( + typename PFP::MAP& the_map, + VertexAttribute& positions, const std::vector& profile, const typename PFP::VEC3& center, const typename PFP::VEC3& axis, @@ -181,8 +193,11 @@ Dart revolution(typename PFP::MAP& the_map, VertexAttribute& * @param N the vector use to extrude face center (point) of axis revolution */ template -Dart extrudeFace(typename PFP::MAP& the_map, VertexAttribute& positions, - Dart d, const typename PFP::VEC3& N); +Dart extrudeFace( + typename PFP::MAP& the_map, + VertexAttribute& positions, + Dart d, + const typename PFP::VEC3& N); /** * Face extrusion @@ -191,12 +206,18 @@ Dart extrudeFace(typename PFP::MAP& the_map, VertexAttribute * @param dist the height to extrude face */ template -Dart extrudeFace(typename PFP::MAP& the_map, VertexAttribute& positions, - Dart d, float dist); +Dart extrudeFace( + typename PFP::MAP& the_map, + VertexAttribute& positions, + Dart d, + float dist); template -Dart extrudeRegion(typename PFP::MAP& the_map, VertexAttribute& position, - Dart d, const CellMarker& cm); +Dart extrudeRegion( + typename PFP::MAP& the_map, + VertexAttribute& position, + Dart d, + const CellMarker& cm); } // namespace Modelisation diff --git a/include/Algo/Modelisation/extrusion.hpp b/include/Algo/Modelisation/extrusion.hpp index e9cfff92..fbe4a1fa 100644 --- a/include/Algo/Modelisation/extrusion.hpp +++ b/include/Algo/Modelisation/extrusion.hpp @@ -38,9 +38,14 @@ namespace Modelisation { template -//Polyhedron* revolution_prim(typename PFP::MAP& the_map, VertexAttribute& position, const std::vector& profile, const typename PFP::VEC3& center, -Algo::Surface::Tilings::Tiling* revolution_prim(typename PFP::MAP& the_map, VertexAttribute& position, const std::vector& profile, const typename PFP::VEC3& center, - const typename PFP::VEC3& axis, bool profile_closed, int nbSides) +Algo::Surface::Tilings::Tiling* revolution_prim( + typename PFP::MAP& the_map, + VertexAttribute& position, + const std::vector& profile, + const typename PFP::VEC3& center, + const typename PFP::VEC3& axis, + bool profile_closed, + int nbSides) { typedef typename PFP::VEC3 VEC3 ; @@ -68,10 +73,15 @@ Algo::Surface::Tilings::Tiling* revolution_prim(typename PFP::MAP& the_map, } template -Dart revolution(typename PFP::MAP& the_map, VertexAttribute& position, const std::vector& profile, const typename PFP::VEC3& center, - const typename PFP::VEC3& axis, bool profile_closed, int nbSides) +Dart revolution( + typename PFP::MAP& the_map, + VertexAttribute& position, + const std::vector& profile, + const typename PFP::VEC3& center, + const typename PFP::VEC3& axis, + bool profile_closed, + int nbSides) { - //Polyhedron *prim = revolution_prim(the_map, position, profile, center, axis, profile_closed, nbSides); Algo::Surface::Tilings::Tiling *prim = revolution_prim(the_map, position, profile, center, axis, profile_closed, nbSides); Dart d = prim->getDart(); delete prim; @@ -80,10 +90,17 @@ Dart revolution(typename PFP::MAP& the_map, VertexAttribute& template -Dart extrusion_scale(typename PFP::MAP& the_map, VertexAttribute& position, const std::vector& profile, const typename PFP::VEC3& centerProfile, const typename PFP::VEC3& normalProfile, bool profile_closed, - const std::vector& path, bool path_closed, const std::vector& scalePath) +Dart extrusion_scale( + typename PFP::MAP& the_map, + VertexAttribute& position, + const std::vector& profile, + const typename PFP::VEC3& centerProfile, + const typename PFP::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed, + const std::vector& scalePath) { - //Polyhedron *prim = extrusion_scale_prim(the_map, position, profile, centerProfile, normalProfile, profile_closed, path, path_closed,scalePath); Algo::Surface::Tilings::Tiling *prim = extrusion_scale_prim(the_map, position, profile, centerProfile, normalProfile, profile_closed, path, path_closed,scalePath); Dart d = prim->getDart(); delete prim; @@ -91,11 +108,17 @@ Dart extrusion_scale(typename PFP::MAP& the_map, VertexAttribute -Dart extrusion(typename PFP::MAP& the_map, VertexAttribute& position, const std::vector& profile, const typename PFP::VEC3& centerProfile, const typename PFP::VEC3& normalProfile, bool profile_closed, - const std::vector& path, bool path_closed) +Dart extrusion( + typename PFP::MAP& the_map, + VertexAttribute& position, + const std::vector& profile, + const typename PFP::VEC3& centerProfile, + const typename PFP::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed) { std::vector scalePath; - //Polyhedron *prim = extrusion_scale_prim(the_map, position, profile, centerProfile, normalProfile, profile_closed, path, path_closed,scalePath); Algo::Surface::Tilings::Tiling *prim = extrusion_scale_prim(the_map, position, profile, centerProfile, normalProfile, profile_closed, path, path_closed,scalePath); Dart d = prim->getDart(); delete prim; @@ -103,20 +126,33 @@ Dart extrusion(typename PFP::MAP& the_map, VertexAttribute& } template -//Polyhedron* extrusion_prim(typename PFP::MAP& the_map, VertexAttribute& position, const std::vector& profile, const typename PFP::VEC3& centerProfile, const typename PFP::VEC3& normalProfile, bool profile_closed, -Algo::Surface::Tilings::Tiling* extrusion_prim(typename PFP::MAP& the_map, VertexAttribute& position, const std::vector& profile, const typename PFP::VEC3& centerProfile, const typename PFP::VEC3& normalProfile, bool profile_closed, - const std::vector& path, bool path_closed) +Algo::Surface::Tilings::Tiling* extrusion_prim( + typename PFP::MAP& the_map, + VertexAttribute& position, + const std::vector& profile, + const typename PFP::VEC3& centerProfile, + const typename PFP::VEC3& normalProfile, + bool profile_closed, + const std::vector& path, + bool path_closed) { std::vector scalePath; return extrusion_scale_prim(the_map, position, profile, centerProfile, normalProfile, profile_closed, path, path_closed,scalePath); } template -//Polyhedron* extrusion_scale_prim(typename PFP::MAP& the_map, VertexAttribute& position, const std::vector& profile, const typename PFP::VEC3& centerProfile, const typename PFP::VEC3& normal, bool profile_closed, const std::vector& path, bool path_closed, const std::vector& scalePath) -Algo::Surface::Tilings::Tiling* extrusion_scale_prim(typename PFP::MAP& the_map, VertexAttribute& position, const std::vector& profile, const typename PFP::VEC3& centerProfile, const typename PFP::VEC3& normal, bool profile_closed, const std::vector& path, bool path_closed, const std::vector& scalePath) +Algo::Surface::Tilings::Tiling* extrusion_scale_prim( + typename PFP::MAP& the_map, + VertexAttribute& position, + const std::vector& profile, + const typename PFP::VEC3& centerProfile, + const typename PFP::VEC3& normal, + bool profile_closed, + const std::vector& path, + bool path_closed, + const std::vector& scalePath) { // topological creation - //Polyhedron *prim = new Polyhedron(the_map, position); Algo::Surface::Tilings::Tiling* prim; //Dart grid; @@ -124,18 +160,15 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim(typename PFP::MAP& the if (profile_closed) { if (path_closed) - //grid = prim->tore_topo(profile.size() ,path.size()); prim = new Algo::Surface::Tilings::Square::Tore(the_map, profile.size(), path.size()); else - //grid = prim->cylinder_topo(profile.size() ,path.size()-1, false, false); - prim = new Algo::Surface::Tilings::Square::Cylinder(the_map, profile.size(), path.size()-1,false, false); + prim = new Algo::Surface::Tilings::Square::Cylinder(the_map, profile.size(), path.size()-1, false, false); } else { if (path_closed) { - //grid = prim->grid_topo(profile.size()-1 ,path.size()); - prim = new Algo::Surface::Tilings::Square::Grid(the_map, profile.size()-1 ,path.size(), true); + prim = new Algo::Surface::Tilings::Square::Grid(the_map, profile.size()-1, path.size(), true); // sewing boundaries correponding to path boundaries std::vector& darts = prim->getVertexDarts(); int index = profile.size()*path.size(); @@ -149,8 +182,7 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim(typename PFP::MAP& the } else - //grid = prim->grid_topo(profile.size()-1 ,path.size()-1); - prim = new Algo::Surface::Tilings::Square::Grid(the_map, profile.size()-1 ,path.size()-1, true); + prim = new Algo::Surface::Tilings::Square::Grid(the_map, profile.size()-1, path.size()-1, true); } glPushMatrix(); @@ -239,7 +271,7 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim(typename PFP::MAP& the Geom::translate(path[i][0],path[i][1],path[i][2],transf); } - CGoGNout << "PATH: "<< i<< CGoGNendl; + CGoGNout << "PATH: "<< i<< CGoGNendl; // apply transfo on object to embed Polyhedron. for(typename std::vector::iterator ip = localObj.begin(); ip != localObj.end(); ++ip) { @@ -288,12 +320,14 @@ Algo::Surface::Tilings::Tiling* extrusion_scale_prim(typename PFP::MAP& the } template -Dart extrudeFace(typename PFP::MAP& the_map, VertexAttribute& positions, Dart d, const typename PFP::VEC3& N) +Dart extrudeFace( + typename PFP::MAP& the_map, + VertexAttribute& positions, + Dart d, + const typename PFP::VEC3& N) { - typedef typename PFP::MAP MAP; - // triangule - Dart c = Surface::Modelisation::trianguleFace(the_map,d); + Dart c = Surface::Modelisation::trianguleFace(the_map, d); Dart cc = c; // cut edges @@ -329,20 +363,24 @@ Dart extrudeFace(typename PFP::MAP& the_map, VertexAttribute } template -Dart extrudeFace(typename PFP::MAP& the_map, VertexAttribute& position, Dart d, float dist) +Dart extrudeFace( + typename PFP::MAP& the_map, + VertexAttribute& position, + Dart d, + float dist) { - typedef typename PFP::MAP MAP; - //compute normal typename PFP::VEC3 normal = Surface::Geometry::faceNormal(the_map, d, position); normal *= dist; - return extrudeFace(the_map, position, d, normal); } template -Dart extrudeRegion(typename PFP::MAP& the_map, VertexAttribute& position, - Dart d, const CellMarker& cm) +Dart extrudeRegion( + typename PFP::MAP& the_map, + VertexAttribute& position, + Dart d, + const CellMarker& cm) { typedef typename PFP::MAP MAP; @@ -350,7 +388,7 @@ Dart extrudeRegion(typename PFP::MAP& the_map, VertexAttribute borderDarts; std::vector pile; pile.push_back(d); - CellMarker* em = new CellMarker(the_map); + CellMarker em(the_map); while(!pile.empty()) { @@ -363,9 +401,9 @@ Dart extrudeRegion(typename PFP::MAP& the_map, VertexAttributeisMarked(the_map.phi2(it))) + else if (!em.isMarked(the_map.phi2(it))) pile.push_back(the_map.phi2(it)); - em->mark(it); + em.mark(it); } } @@ -425,7 +463,7 @@ Dart extrudeRegion(typename PFP::MAP& the_map, VertexAttribute* fm = new CellMarker(the_map); + CellMarker* fm(the_map); int faceNb = 0; while(!pile.empty()) { @@ -433,13 +471,13 @@ Dart extrudeRegion(typename PFP::MAP& the_map, VertexAttributeisMarked(the_map.phi2(it)))) + if((cm.isMarked(the_map.phi2(it))) && (!fm.isMarked(the_map.phi2(it)))) pile.push_back(the_map.phi2(it)); - if(!fm->isMarked(it)) + if(!fm.isMarked(it)) { normal = normal + Surface::Geometry::faceNormal(the_map, it, position); faceNb++; - fm->mark(it); + fm.mark(it); } } } @@ -467,7 +505,7 @@ Dart extrudeRegion(typename PFP::MAP& the_map, VertexAttribute* vm = new CellMarker(the_map); + CellMarker* vm(the_map); while(!pile.empty()) { @@ -475,12 +513,12 @@ Dart extrudeRegion(typename PFP::MAP& the_map, VertexAttributeisMarked(it)) + if(!vm.isMarked(it)) { position[it] = position[it]+normal; - vm->mark(it); + vm.mark(it); } - if (cm.isMarked(it) && (!vm->isMarked(the_map.phi2(it)))) + if (cm.isMarked(it) && (!vm.isMarked(the_map.phi2(it)))) pile.push_back(the_map.phi2(it)); } } diff --git a/include/Algo/Modelisation/polyhedron.h b/include/Algo/Modelisation/polyhedron.h index 7614b383..315c2bb2 100644 --- a/include/Algo/Modelisation/polyhedron.h +++ b/include/Algo/Modelisation/polyhedron.h @@ -75,7 +75,7 @@ namespace Modelisation * @param d a dart from the vertex */ template -void explodPolyhedron(typename PFP::MAP& map, Dart d, VertexAttribute& position); +void explodPolyhedron(typename PFP::MAP& map, Dart d, VertexAttribute& position); @@ -138,11 +138,11 @@ bool isPrism(typename PFP::MAP& map, Dart d, unsigned int thread = 0); template -Dart embedPrism(typename PFP::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float bottom_radius, float top_radius, float height); +Dart embedPrism(typename PFP::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float bottom_radius, float top_radius, float height); template -Dart embedPyramid(typename PFP::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float radius, float height); +Dart embedPyramid(typename PFP::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float radius, float height); } // namespace Modelisation diff --git a/include/Algo/Modelisation/polyhedron.hpp b/include/Algo/Modelisation/polyhedron.hpp index 272ef508..6a052665 100644 --- a/include/Algo/Modelisation/polyhedron.hpp +++ b/include/Algo/Modelisation/polyhedron.hpp @@ -235,7 +235,7 @@ Dart createOctahedron(typename PFP::MAP& map, bool withBoundary) } template -Dart embedPrism(typename PFP::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float bottom_radius, float top_radius, float height) +Dart embedPrism(typename PFP::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float bottom_radius, float top_radius, float height) { typedef typename PFP::VEC3 VEC3 ; @@ -306,11 +306,8 @@ Dart embedPrism(typename PFP::MAP& map, VertexAttribute& pos return dres; } - -//VertexAttribute - template -Dart embedPyramid(typename PFP::MAP& map, AttributeHandler& position, unsigned int n, bool withBoundary, float radius, float height) +Dart embedPyramid(typename PFP::MAP& map, VertexAttribute& position, unsigned int n, bool withBoundary, float radius, float height) { typedef typename PFP::VEC3 VEC3 ; @@ -368,9 +365,6 @@ Dart embedPyramid(typename PFP::MAP& map, AttributeHandler bool isPyra(typename PFP::MAP& map, Dart d, unsigned int thread) { @@ -422,12 +416,8 @@ bool isPrism(typename PFP::MAP& map, Dart d, unsigned int thread) } - - - - template -void explodPolyhedron(typename PFP::MAP& map, Dart d, VertexAttribute& position) +void explodPolyhedron(typename PFP::MAP& map, Dart d, VertexAttribute& position) { map.unsewVertexUmbrella(d); unsigned int newFaceDegree = map.closeHole(map.phi1(d)); @@ -506,54 +496,52 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, VertexAttribute void quads2TrianglesCC(typename PFP::MAP& the_map, Dart primd) { -DartMarker m(the_map); - -// list of faces to process and processed(before pos iterator) -std::list ld; -ld.push_back(primd); -// current position in list -typename std::list::iterator pos = ld.begin(); -do -{ - Dart d = *pos; - - // cut the face of first dart of list - Dart d1 = the_map.phi1(d); - Dart e = the_map.phi1(d1); - Dart e1 = the_map.phi1(e); - Dart f = the_map.phi1(e1); - if (f==d) // quad - { - the_map.splitFace(d,e); - // mark the face - m.markOrbit(d); - m.markOrbit(e); - } - else m.markOrbit(d); - - // and store neighbours faces in the list - d = the_map.phi2(d); - e = the_map.phi2(e); - d1 = the_map.phi1(the_map.phi2(d1)); - e1 = the_map.phi1(the_map.phi2(e1)); - - if (!m.isMarked(d)) - ld.push_back(d); - if (!m.isMarked(e)) - ld.push_back(e); - if (!m.isMarked(d1)) - ld.push_back(d1); - if ((f==d) && (!m.isMarked(e1))) - ld.push_back(e1); - pos++; -}while (pos!=ld.end()); // stop when no more face to process + DartMarker m(the_map); + + // list of faces to process and processed(before pos iterator) + std::list ld; + ld.push_back(primd); + // current position in list + typename std::list::iterator pos = ld.begin(); + do + { + Dart d = *pos; + + // cut the face of first dart of list + Dart d1 = the_map.phi1(d); + Dart e = the_map.phi1(d1); + Dart e1 = the_map.phi1(e); + Dart f = the_map.phi1(e1); + if (f == d) // quad + { + the_map.splitFace(d,e); + // mark the face + m.template markOrbit(d); + m.template markOrbit(e); + } + else m.template markOrbit(d); + + // and store neighbours faces in the list + d = the_map.phi2(d); + e = the_map.phi2(e); + d1 = the_map.phi1(the_map.phi2(d1)); + e1 = the_map.phi1(the_map.phi2(e1)); + + if (!m.isMarked(d)) + ld.push_back(d); + if (!m.isMarked(e)) + ld.push_back(e); + if (!m.isMarked(d1)) + ld.push_back(d1); + if ((f == d) && (!m.isMarked(e1))) + ld.push_back(e1); + pos++; + } while (pos!=ld.end()); // stop when no more face to process } - } // namespace Modelisation } // namespace Surface diff --git a/include/Algo/Modelisation/subdivision.h b/include/Algo/Modelisation/subdivision.h index e9366877..7860de48 100644 --- a/include/Algo/Modelisation/subdivision.h +++ b/include/Algo/Modelisation/subdivision.h @@ -65,7 +65,8 @@ void trianguleFaces(typename PFP::MAP& map, EMBV& attributs) ; template void trianguleFaces( typename PFP::MAP& map, - VertexAttribute& position, const FaceAttribute& positionF) ; + VertexAttribute& position, + const FaceAttribute& positionF) ; /** * Quadrangule a face with central vertex @@ -84,7 +85,7 @@ template void quadranguleFaces(typename PFP::MAP& map, EMBV& attributs) ; template -void quadranguleFaces(typename PFP::MAP& map, VertexAttribute& position) ; +void quadranguleFaces(typename PFP::MAP& map, VertexAttribute& position) ; /** * Catmull-Clark subdivision scheme @@ -127,7 +128,6 @@ void DooSabin(typename PFP::MAP& map, EMBV& position); //void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position) ; - ///** // * Sqrt(3) subdivision scheme // */ @@ -135,15 +135,13 @@ void DooSabin(typename PFP::MAP& map, EMBV& position); //void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position) ; template -void computeDual(typename PFP::MAP& map, VertexAttribute& position); +void computeDual(typename PFP::MAP& map, VertexAttribute& position); template -void computeBoundaryConstraintDual(typename PFP::MAP& map, VertexAttribute& position); +void computeBoundaryConstraintDual(typename PFP::MAP& map, VertexAttribute& position); template -void computeBoundaryConstraintKeepingOldVerticesDual(typename PFP::MAP& map, VertexAttribute& position); - - +void computeBoundaryConstraintKeepingOldVerticesDual(typename PFP::MAP& map, VertexAttribute& position); } // namespace Modelisation diff --git a/include/Algo/Modelisation/subdivision.hpp b/include/Algo/Modelisation/subdivision.hpp index 763ceb94..eae51ae4 100644 --- a/include/Algo/Modelisation/subdivision.hpp +++ b/include/Algo/Modelisation/subdivision.hpp @@ -72,7 +72,7 @@ void trianguleFaces(typename PFP::MAP& map, EMBV& attributs) TraversorF t(map) ; for (Dart d = t.begin(); d != t.end(); d = t.next()) { - EMB center = Geometry::faceCentroid(map, d, attributs); // compute center + EMB center = Geometry::faceCentroid(map, d, attributs); // compute center Dart cd = trianguleFace(map, d); // triangule the face attributs[cd] = center; // affect the data to the central vertex Dart fit = cd ; @@ -93,8 +93,8 @@ void trianguleFaces(typename PFP::MAP& map, EMBV& attributs) template void trianguleFaces( typename PFP::MAP& map, - VertexAttribute& position, - const FaceAttribute& positionF + VertexAttribute& position, + const FaceAttribute& positionF ) { TraversorF t(map) ; @@ -132,10 +132,11 @@ Dart quadranguleFace(typename PFP::MAP& map, Dart d) template void quadranguleFaces(typename PFP::MAP& map, EMBV& attributs) { + typedef typename PFP::MAP MAP; typedef typename EMBV::DATA_TYPE EMB; - DartMarker me(map) ; - DartMarker mf(map) ; + DartMarker me(map) ; + DartMarker mf(map) ; // first pass: cut the edges for (Dart d = map.begin(); d != map.end(); map.next(d)) @@ -162,7 +163,7 @@ void quadranguleFaces(typename PFP::MAP& map, EMBV& attributs) { if ( !map.isBoundaryMarked2(d) && !mf.isMarked(d)) { - EMB center = Geometry::faceCentroid(map, d, attributs); // compute center + EMB center = Geometry::faceCentroid(map, d, attributs); // compute center Dart cf = quadranguleFace(map, d); // quadrangule the face attributs[cf] = center; // affect the data to the central vertex Dart e = cf; @@ -184,14 +185,15 @@ void quadranguleFaces(typename PFP::MAP& map, EMBV& attributs) template void CatmullClarkSubdivision(typename PFP::MAP& map, EMBV& attributs) { + typedef typename PFP::MAP MAP; typedef typename EMBV::DATA_TYPE EMB; std::vector l_middles; std::vector l_verts; - CellMarkerNoUnmark m0(map); - DartMarkerNoUnmark mf(map); - DartMarkerNoUnmark me(map); + CellMarkerNoUnmark m0(map); + DartMarkerNoUnmark mf(map); + DartMarkerNoUnmark me(map); // first pass: cut edges for (Dart d = map.begin(); d != map.end(); map.next(d)) @@ -342,14 +344,15 @@ inline double betaF(unsigned int n) template void LoopSubdivision(typename PFP::MAP& map, EMBV& attributs) { + typedef typename PFP::MAP MAP; typedef typename EMBV::DATA_TYPE EMB; std::vector l_middles; std::vector l_verts; - CellMarkerNoUnmark m0(map); - DartMarkerNoUnmark mv(map); - DartMarkerNoUnmark me(map); + CellMarkerNoUnmark m0(map); + DartMarkerNoUnmark mv(map); + DartMarkerNoUnmark me(map); // first pass cut edges for (Dart d = map.begin(); d != map.end(); map.next(d)) @@ -472,10 +475,11 @@ void LoopSubdivision(typename PFP::MAP& map, EMBV& attributs) template void TwoNPlusOneSubdivision(typename PFP::MAP& map, EMBV& attributs, float size) { + typedef typename PFP::MAP MAP; typedef typename EMBV::DATA_TYPE EMB; - CellMarker m0(map); - CellMarker m1(map); + CellMarker m0(map); + CellMarker m1(map); std::vector dOrig; @@ -511,7 +515,7 @@ void TwoNPlusOneSubdivision(typename PFP::MAP& map, EMBV& attributs, float size) CGoGNout << "nb orig : " << dOrig.size() << CGoGNendl; - DartMarkerNoUnmark mCorner(map); + DartMarkerNoUnmark mCorner(map); // //second pass create corner face for (std::vector::iterator it = dOrig.begin(); it != dOrig.end(); ++it) { @@ -546,9 +550,10 @@ void TwoNPlusOneSubdivision(typename PFP::MAP& map, EMBV& attributs, float size) template void DooSabin(typename PFP::MAP& map, EMBV& position) { + typedef typename PFP::MAP MAP; typedef typename EMBV::DATA_TYPE EMB; - DartMarker dm(map); + DartMarker dm(map); // storage of boundary of hole (missing vertex faces) std::vector fp; fp.reserve(16384); @@ -559,7 +564,7 @@ void DooSabin(typename PFP::MAP& map, EMBV& position) // create the edge faces - for(Dart d=map.begin(); d != map.end(); map.next(d)) + for(Dart d = map.begin(); d != map.end(); map.next(d)) { if (!dm.isMarked(d)) { @@ -587,7 +592,7 @@ void DooSabin(typename PFP::MAP& map, EMBV& position) } dm.markOrbit(e); e = map.phi1(e); - }while (e!=d); + } while (e!=d); } } // fill (create) the new vertex faces @@ -625,10 +630,10 @@ void DooSabin(typename PFP::MAP& map, EMBV& position) }while (e != * di); int N = buffer.size(); - for (int i=0; i -void computeDual(typename PFP::MAP& map, VertexAttribute& position) +void computeDual(typename PFP::MAP& map, VertexAttribute& position) { + typedef typename PFP::MAP MAP ; + typedef typename PFP::MAP::IMPL MAP_IMPL ; + typedef typename PFP::VEC3 VEC3 ; + // Face Attribute -> after dual new Vertex Attribute - FaceAttribute positionF = map.template getAttribute("position") ; + FaceAttribute positionF = map.template getAttribute("position") ; if(!positionF.isValid()) - positionF = map.template addAttribute("position") ; + positionF = map.template addAttribute("position") ; // Compute Centroid for the faces Algo::Surface::Geometry::computeCentroidFaces(map, position, positionF) ; @@ -736,16 +745,21 @@ void computeDual(typename PFP::MAP& map, VertexAttribute& po template -void computeBoundaryConstraintDual(typename PFP::MAP& map, VertexAttribute& position) +void computeBoundaryConstraintDual(typename PFP::MAP& map, VertexAttribute& position) { + typedef typename PFP::MAP MAP ; + typedef typename PFP::MAP::IMPL MAP_IMPL ; + typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; + // Face Attribute -> after dual new Vertex Attribute - FaceAttribute positionF = map.template getAttribute("position") ; + FaceAttribute positionF = map.template getAttribute("position") ; if(!positionF.isValid()) - positionF = map.template addAttribute("position") ; + positionF = map.template addAttribute("position") ; //Triangule boundary faces & compute for each new face the centroid std::vector boundsDart; - DartMarkerStore mf(map); + DartMarkerStore mf(map); for(Dart dit = map.begin() ; dit != map.end() ; map.next(dit)) { if(!mf.isMarked(dit) && map.isBoundaryMarked2(dit)) @@ -757,7 +771,7 @@ void computeBoundaryConstraintDual(typename PFP::MAP& map, VertexAttribute(dit); Dart x = map.phi2(map.phi_1(db)) ; @@ -767,12 +781,12 @@ void computeBoundaryConstraintDual(typename PFP::MAP& map, VertexAttribute(prev); dd = next ; } - positionF[dprev] = (position[dprev] + position[map.phi1(dprev)]) * typename PFP::REAL(0.5); + positionF[dprev] = (position[dprev] + position[map.phi1(dprev)]) * REAL(0.5); mf.markOrbit(dprev); } } @@ -802,16 +816,21 @@ void computeBoundaryConstraintDual(typename PFP::MAP& map, VertexAttribute -void computeBoundaryConstraintKeepingOldVerticesDual(typename PFP::MAP& map, VertexAttribute& position) +void computeBoundaryConstraintKeepingOldVerticesDual(typename PFP::MAP& map, VertexAttribute& position) { + typedef typename PFP::MAP MAP ; + typedef typename PFP::MAP::IMPL MAP_IMPL ; + typedef typename PFP::VEC3 VEC3 ; + typedef typename PFP::REAL REAL ; + // Face Attribute -> after dual new Vertex Attribute - FaceAttribute positionF = map.template getAttribute("position") ; + FaceAttribute positionF = map.template getAttribute("position") ; if(!positionF.isValid()) - positionF = map.template addAttribute("position") ; + positionF = map.template addAttribute("position") ; //Triangule boundary faces & compute for each new face the centroid std::vector boundsDart; - DartMarkerStore mf(map); + DartMarkerStore mf(map); for(Dart dit = map.begin() ; dit != map.end() ; map.next(dit)) { if(!mf.isMarked(dit) && map.isBoundaryMarked2(dit)) @@ -823,7 +842,7 @@ void computeBoundaryConstraintKeepingOldVerticesDual(typename PFP::MAP& map, Ver map.splitFace(db, d1) ; map.cutEdge(map.phi_1(db)) ; - positionF[dit] = (position[dit] + position[map.phi2(dit)]) * typename PFP::REAL(0.5); + positionF[dit] = (position[dit] + position[map.phi2(dit)]) * REAL(0.5); mf.markOrbit(dit); Dart x = map.phi2(map.phi_1(db)) ; @@ -833,12 +852,12 @@ void computeBoundaryConstraintKeepingOldVerticesDual(typename PFP::MAP& map, Ver Dart next = map.phi1(dd) ; Dart prev = map.phi_1(dd); map.splitFace(dd, map.phi1(x)) ; - positionF[prev] = (position[prev] + position[map.phi1(prev)]) * typename PFP::REAL(0.5); + positionF[prev] = (position[prev] + position[map.phi1(prev)]) * REAL(0.5); mf.markOrbit(prev); dd = next ; } - positionF[dprev] = (position[dprev] + position[map.phi1(dprev)]) * typename PFP::REAL(0.5); + positionF[dprev] = (position[dprev] + position[map.phi1(dprev)]) * REAL(0.5); mf.markOrbit(dprev); } } @@ -860,7 +879,7 @@ void computeBoundaryConstraintKeepingOldVerticesDual(typename PFP::MAP& map, Ver map.computeDual(); //Saving old position VertexAttribute to a FaceAttribute - FaceAttribute temp; + FaceAttribute temp; temp = position; position = positionF ; positionF = temp; diff --git a/include/Algo/Modelisation/subdivision3.h b/include/Algo/Modelisation/subdivision3.h index ef19d172..e84d0af4 100644 --- a/include/Algo/Modelisation/subdivision3.h +++ b/include/Algo/Modelisation/subdivision3.h @@ -45,7 +45,6 @@ namespace Modelisation template bool isHexahedron(typename PFP::MAP& the_map, Dart d, unsigned int thread=0); - /** * Cut a 3D ear from a mesh : the ear is sewn by phi3 to the rest of the volume * @param d dart of the point of the ear @@ -61,7 +60,7 @@ Dart cut3Ear(typename PFP::MAP& map, Dart d); * * TODO (optimization) change to build path while splitting faces */ template -Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute& position, Dart d, Geom::Plane3D pl); +Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute& position, Dart d, Geom::Plane3D pl); /** * Cut a volume considering a set of marked edges and vertices @@ -73,7 +72,7 @@ Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute -Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute& position, Dart d, CellMarker& edgesToCut, CellMarker& verticesToSplit); +Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute& position, Dart d, CellMarker& edgesToCut, CellMarker& verticesToSplit); /** * Cut a set of volumes considering a set of marked edges and vertices @@ -85,7 +84,7 @@ Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute -std::vector sliceConvexVolumes(typename PFP::MAP& map, VertexAttribute& position,CellMarker& volumesToCut, CellMarker& edgesToCut, CellMarker& verticesToSplit); +std::vector sliceConvexVolumes(typename PFP::MAP& map, VertexAttribute& position,CellMarker& volumesToCut, CellMarker& edgesToCut, CellMarker& verticesToSplit); /** * catmull clark volumic : do not move the original vertices @@ -102,14 +101,13 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs); //} template -void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& position); +void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& position); template -void relaxation(typename PFP::MAP& map, VertexAttribute& position); +void relaxation(typename PFP::MAP& map, VertexAttribute& position); template -void computeDual(typename PFP::MAP& map, VertexAttribute& position); - +void computeDual(typename PFP::MAP& map, VertexAttribute& position); } // namespace Modelisation @@ -122,5 +120,3 @@ void computeDual(typename PFP::MAP& map, VertexAttribute& po #include "Algo/Modelisation/subdivision3.hpp" #endif - - diff --git a/include/Algo/Modelisation/subdivision3.hpp b/include/Algo/Modelisation/subdivision3.hpp index eb79d3f4..a6f67103 100644 --- a/include/Algo/Modelisation/subdivision3.hpp +++ b/include/Algo/Modelisation/subdivision3.hpp @@ -111,20 +111,24 @@ Dart cut3Ear(typename PFP::MAP& map, Dart d) } template -Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute& position, Dart d, Geom::Plane3D pl) +Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute& position, Dart d, Geom::Plane3D pl) { + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; + Dart dRes=NIL; unsigned int nbInter = 0; unsigned int nbVertices = 0; - CellMarkerStore vs(map); //marker for new vertices from edge cut - CellMarkerStore cf(map); + CellMarkerStore vs(map); //marker for new vertices from edge cut + CellMarkerStore cf(map); Dart dPath; - MarkerForTraversor mte(map); - MarkerForTraversor mtf(map); + MarkerForTraversor mte(map); + MarkerForTraversor mtf(map); //search edges and vertices crossing the plane - Traversor3WE te(map,d); + Traversor3WE te(map,d); for(Dart dd = te.begin() ;dd != te.end() ; dd = te.next()) { if(!mte.isMarked(dd)) @@ -137,15 +141,15 @@ Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute(map,dd,position)); - Geom::Intersection inter = Geom::intersectionLinePlane >(position[dd],vec,pl,interP); + VEC3 interP; + VEC3 vec(Surface::Geometry::vectorOutOfDart(map,dd,position)); + Geom::Intersection inter = Geom::intersectionLinePlane >(position[dd],vec,pl,interP); if(inter==Geom::FACE_INTERSECTION) { Dart dOp = map.phi1(dd); - typename PFP::VEC3 v2(interP-position[dd]); - typename PFP::VEC3 v3(interP-position[dOp]); + VEC3 v2(interP-position[dd]); + VEC3 v3(interP-position[dOp]); if(vec.norm2()>v2.norm2() && vec.norm2()>v3.norm2()) { nbInter++; @@ -172,7 +176,7 @@ Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute1) { - Traversor3WF tf(map,d); + Traversor3WF tf(map,d); for(Dart dd = tf.begin() ; dd != tf.end() ; dd = tf.next()) { //for faces with a new vertex @@ -235,23 +239,25 @@ Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute -Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute& position, Dart d, CellMarker& edgesToCut, CellMarker& verticesToSplit) +Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute& position, Dart d, CellMarker& edgesToCut, CellMarker& verticesToSplit) { + typedef typename PFP::MAP MAP; typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; Dart dRes; unsigned int nbInter = 0; unsigned int nbVertices = 0; - CellMarkerStore vs(map); //marker for new vertices from edge cut - CellMarkerStore cf(map); + CellMarkerStore vs(map); //marker for new vertices from edge cut + CellMarkerStore cf(map); Dart dPath; - MarkerForTraversor mte(map); - MarkerForTraversor mtf(map); + MarkerForTraversor mte(map); + MarkerForTraversor mtf(map); //search edges and vertices crossing the plane - Traversor3WE te(map,d); - for(Dart dd = te.begin() ;dd != te.end() ; dd = te.next()) + Traversor3WE te(map,d); + for(Dart dd = te.begin(); dd != te.end(); dd = te.next()) { if(!mte.isMarked(dd) && edgesToCut.isMarked(dd)) { @@ -276,7 +282,7 @@ Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute1); - Traversor3WF tf(map,d); + Traversor3WF tf(map,d); for(Dart dd = tf.begin() ; dd != tf.end() ; dd = tf.next()) { //for faces with a new vertex @@ -334,16 +340,19 @@ Dart sliceConvexVolume(typename PFP::MAP& map, VertexAttribute -std::vector sliceConvexVolumes(typename PFP::MAP& map, VertexAttribute& position,CellMarker& volumesToCut, CellMarker& edgesToCut, CellMarker& verticesToSplit) +std::vector sliceConvexVolumes(typename PFP::MAP& map, VertexAttribute& position, CellMarker& volumesToCut, CellMarker& edgesToCut, CellMarker& verticesToSplit) { + typedef typename PFP::MAP MAP; + typedef typename PFP::VEC3 VEC3; + typedef typename PFP::REAL REAL; + std::vector vRes; - typedef typename PFP::VEC3 VEC3; - CellMarker localVerticesToSplit(map); //marker for new vertices from edge cut + CellMarker localVerticesToSplit(map); //marker for new vertices from edge cut //Step 1: Cut the edges and mark the resulting vertices as vertices to be face-split - TraversorE te(map); - CellMarkerStore cf(map); + TraversorE te(map); + CellMarkerStore cf(map); for(Dart d = te.begin(); d != te.end(); d=te.next()) //cut all edges { @@ -352,7 +361,7 @@ std::vector sliceConvexVolumes(typename PFP::MAP& map, VertexAttribute t3ef(map,d); + Traversor3EF t3ef(map,d); for(Dart dd = t3ef.begin() ; dd != t3ef.end() ; dd = t3ef.next()) cf.mark(dd); //mark face to split @@ -365,7 +374,7 @@ std::vector sliceConvexVolumes(typename PFP::MAP& map, VertexAttribute tf(map); + TraversorF tf(map); for(Dart d = tf.begin(); d != tf.end(); d=tf.next()) { if(cf.isMarked(d)) @@ -400,12 +409,12 @@ std::vector sliceConvexVolumes(typename PFP::MAP& map, VertexAttribute tw(map); + TraversorW tw(map); for(Dart d = tw.begin(); d != tw.end(); d=tw.next()) //Parcours des volumes { if(volumesToCut.isMarked(d)) { - Traversor3WV t3wv(map,d); + Traversor3WV t3wv(map,d); Dart dPath; bool found=false; @@ -426,8 +435,7 @@ std::vector sliceConvexVolumes(typename PFP::MAP& map, VertexAttribute vPath; vPath.reserve(32); vPath.push_back(dPath); - CellMarker cmf(map); - + CellMarker cmf(map); //define the path to split for the whole volume bool pathFound=false; @@ -460,19 +468,21 @@ std::vector sliceConvexVolumes(typename PFP::MAP& map, VertexAttribute void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename EMBV::DATA_TYPE EMB; //std::vector l_centers; std::vector l_vertices; //pre-computation : compute the centroid of all volume - VolumeAutoAttribute attBary(map); + VolumeAutoAttribute attBary(map); Volume::Geometry::computeCentroidVolumes(map, const_cast(attributs), attBary); //subdivision //1. cut edges - DartMarkerNoUnmark mv(map); - TraversorE travE(map); + DartMarkerNoUnmark mv(map); + TraversorE travE(map); for (Dart d = travE.begin(); d != travE.end(); d = travE.next()) { //memorize each vertices per volumes @@ -495,7 +505,7 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs) } //2. split faces - quadrangule faces - TraversorF travF(map) ; + TraversorF travF(map) ; for (Dart d = travF.begin(); d != travF.end(); d = travF.next()) { EMB center = Surface::Geometry::faceCentroid(map,d,attributs); @@ -561,7 +571,7 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs) assert(vd2.size() == v.size()); - map.PFP::MAP::ParentMap::splitSurface(v, true, false); + map.MAP::ParentMap::splitSurface(v, true, false); // follow the edge path a second time to embed the vertex, edge and volume orbits for(unsigned int i = 0; i < v.size(); ++i) @@ -598,7 +608,7 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs) Dart dd = map.phi2(map.phi1(*it)); Dart next = map.phi1(map.phi1(dd)) ; - map.PFP::MAP::ParentMap::splitFace(dd, next); + map.MAP::ParentMap::splitFace(dd, next); if (map.template isOrbitEmbedded()) { @@ -607,7 +617,7 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs) } Dart ne = map.phi2(map.phi_1(dd)); - map.PFP::MAP::ParentMap::cutEdge(ne); + map.MAP::ParentMap::cutEdge(ne); // dd = map.phi1(map.phi1(next)) ; // while(dd != ne) @@ -681,26 +691,30 @@ inline double sqrt3_K(unsigned int n) } template -void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& position) +void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& position) { - DartMarkerStore m(map); + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + typedef typename PFP::VEC3 VEC3; - DartMarkerStore newBoundaryV(map); + DartMarkerStore m(map); + + DartMarkerStore newBoundaryV(map); // // 1-4 flip of all tetrahedra // - TraversorW tW(map); + TraversorW tW(map); for(Dart dit = tW.begin() ; dit != tW.end() ; dit = tW.next()) { - Traversor3WF tWF(map, dit); + Traversor3WF tWF(map, dit); for(Dart ditWF = tWF.begin() ; ditWF != tWF.end() ; ditWF = tWF.next()) { if(!map.isBoundaryFace(ditWF) && !m.isMarked(ditWF)) m.markOrbit(ditWF); } - typename PFP::VEC3 volCenter(0.0); + VEC3 volCenter(0.0); volCenter += position[dit]; volCenter += position[map.phi1(dit)]; volCenter += position[map.phi_1(dit)]; @@ -714,7 +728,7 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& posit // // 2-3 swap of all old interior faces // - TraversorF tF(map); + TraversorF tF(map); for(Dart dit = tF.begin() ; dit != tF.end() ; dit = tF.next()) { if(m.isMarked(dit)) @@ -727,19 +741,19 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& posit // // 1-3 flip of all boundary tetrahedra // - TraversorW tWb(map); + TraversorW tWb(map); for(Dart dit = tWb.begin() ; dit != tWb.end() ; dit = tWb.next()) { if(map.isBoundaryVolume(dit)) { - Traversor3WE tWE(map, dit); + Traversor3WE tWE(map, dit); for(Dart ditWE = tWE.begin() ; ditWE != tWE.end() ; ditWE = tWE.next()) { if(map.isBoundaryEdge(ditWE) && !m.isMarked(ditWE)) m.markOrbit(ditWE); } - typename PFP::VEC3 faceCenter(0.0); + VEC3 faceCenter(0.0); faceCenter += position[dit]; faceCenter += position[map.phi1(dit)]; faceCenter += position[map.phi_1(dit)]; @@ -888,9 +902,13 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute& posit // solving Ax = b template -void relaxation(typename PFP::MAP& map, VertexAttribute& position) +void relaxation(typename PFP::MAP& map, VertexAttribute& position) { - VertexAttribute indexV = map.template getAttribute("indexV"); + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + typedef typename PFP::VEC3 VEC3; + + VertexAttribute indexV = map.template getAttribute("indexV"); if(!indexV.isValid()) indexV = map.template addAttribute("indexV"); @@ -912,7 +930,7 @@ void relaxation(typename PFP::MAP& map, VertexAttribute& pos { std::cout << "coord " << coord << std::flush; //setup variables - TraversorV tv(map); + TraversorV tv(map); for(Dart dit = tv.begin() ; dit != tv.end() ; dit = tv.next()) { nlSetVariable(indexV[dit], (position[dit])[coord]); @@ -927,7 +945,7 @@ void relaxation(typename PFP::MAP& map, VertexAttribute& pos nlEnable(NL_NORMALIZE_ROWS) ; - TraversorV tv2(map); + TraversorV tv2(map); for(Dart dit = tv2.begin() ; dit != tv2.end() ; dit = tv2.next()) { if(!map.isBoundaryVertex(dit)) @@ -938,7 +956,7 @@ void relaxation(typename PFP::MAP& map, VertexAttribute& pos nlBegin(NL_ROW) ; float sum = 0; - Traversor3VVaE tvvae(map, dit); + Traversor3VVaE tvvae(map, dit); for(Dart ditvvae = tvvae.begin() ; ditvvae != tvvae.end() ; ditvvae = tvvae.next()) { nlCoefficient(indexV[ditvvae], weight); @@ -975,12 +993,16 @@ void relaxation(typename PFP::MAP& map, VertexAttribute& pos } template -void computeDual(typename PFP::MAP& map, VertexAttribute& position) +void computeDual(typename PFP::MAP& map, VertexAttribute& position) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + typedef typename PFP::VEC3 VEC3; + // VolumeAttribute -> after dual new VertexAttribute - VolumeAttribute positionV = map.template getAttribute("position") ; + VolumeAttribute positionV = map.template getAttribute("position") ; if(!positionV.isValid()) - positionV = map.template addAttribute("position") ; + positionV = map.template addAttribute("position") ; // Compute Centroid for the volumes Algo::Volume::Geometry::computeCentroidVolumes(map, position, positionV) ; @@ -990,7 +1012,6 @@ void computeDual(typename PFP::MAP& map, VertexAttribute& po position = positionV ; } - } // namespace Modelisation } // namespace volume @@ -998,4 +1019,3 @@ void computeDual(typename PFP::MAP& map, VertexAttribute& po } // namespace Algo } // namespace CGoGN - diff --git a/include/Algo/Modelisation/triangulation.h b/include/Algo/Modelisation/triangulation.h index 80e3f6f2..fe0d79e4 100644 --- a/include/Algo/Modelisation/triangulation.h +++ b/include/Algo/Modelisation/triangulation.h @@ -50,6 +50,7 @@ template class EarTriangulation { typedef typename PFP::MAP MAP ; + typedef typename PFP::MAP::IMPL MAP_IMPL ; typedef typename PFP::VEC3 VEC3 ; protected: @@ -57,7 +58,7 @@ protected: class VertexPoly; // multiset typedef for simple writing - typedef std::multiset< VertexPoly,VertexPoly> VPMS; + typedef std::multiset VPMS; typedef typename VPMS::iterator VMPSITER; typedef NoTypeNameAttribute EarAttr ; @@ -85,9 +86,9 @@ protected: protected: typename PFP::MAP& m_map; - VertexAutoAttribute m_dartEars; + VertexAutoAttribute m_dartEars; - VertexAttribute m_position; + VertexAttribute m_position; VPMS m_ears; @@ -112,7 +113,7 @@ public: } // namespace Modelisation -} +} // namespace Surface } // namespace Algo diff --git a/include/Algo/Modelisation/triangulation.hpp b/include/Algo/Modelisation/triangulation.hpp index 92ba47e4..9c4fccc2 100644 --- a/include/Algo/Modelisation/triangulation.hpp +++ b/include/Algo/Modelisation/triangulation.hpp @@ -37,8 +37,8 @@ namespace Modelisation template bool EarTriangulation::inTriangle(const typename PFP::VEC3& P, const typename PFP::VEC3& normal, const typename PFP::VEC3& Ta, const typename PFP::VEC3& Tb, const typename PFP::VEC3& Tc) { - typedef typename PFP::VEC3 VECT ; - typedef typename VECT::DATA_TYPE T ; + typedef typename PFP::VEC3 VEC3 ; + typedef typename VEC3::DATA_TYPE T ; if (Geom::tripleProduct(P-Ta, (Tb-Ta), normal) >= T(0)) return false; @@ -55,19 +55,21 @@ bool EarTriangulation::inTriangle(const typename PFP::VEC3& P, const typena template void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& normalPoly, bool convex) { + typedef typename PFP::VEC3 VEC3 ; + Dart d2 = m_map.phi_1(d); Dart d_p = m_map.phi_1(d2); Dart d_n = m_map.phi1(d); - const typename PFP::VEC3& Ta = m_position[d2]; - const typename PFP::VEC3& Tb = m_position[d]; - const typename PFP::VEC3& Tc = m_position[d_p]; - const typename PFP::VEC3& Td = m_position[d_n]; + const VEC3& Ta = m_position[d2]; + const VEC3& Tb = m_position[d]; + const VEC3& Tc = m_position[d_p]; + const VEC3& Td = m_position[d_n]; // compute angle - typename PFP::VEC3 v1= Tb - Ta; - typename PFP::VEC3 v2= Tc - Ta; - typename PFP::VEC3 v3= Td - Tb; + VEC3 v1= Tb - Ta; + VEC3 v2= Tc - Ta; + VEC3 v3= Td - Tb; v1.normalize(); v2.normalize(); @@ -80,8 +82,8 @@ void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& no if (!convex) // if convex no need to test if vertex is an ear (yes) { - typename PFP::VEC3 nv1 = v1^v2; - typename PFP::VEC3 nv2 = v1^v3; + VEC3 nv1 = v1^v2; + VEC3 nv2 = v1^v3; if (nv1*normalPoly < 0.0) dotpr1 = 10.0f - dotpr1;// not an ears (concave) @@ -92,7 +94,7 @@ void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& no for (typename VPMS::reverse_iterator it = m_ears.rbegin(); (!finished)&&(it != m_ears.rend())&&(it->angle > 5.0f); ++it) { Dart dx = it->dart; - const typename PFP::VEC3& P = m_position[dx]; + const VEC3& P = m_position[dx]; if ((dotpr1 < 5.0f) && (d != d_p)) if (inTriangle(P, normalPoly,Tb,Tc,Ta)) @@ -116,22 +118,24 @@ void EarTriangulation::recompute2Ears( Dart d, const typename PFP::VEC3& no template float EarTriangulation::computeEarInit(Dart d, const typename PFP::VEC3& normalPoly, float& val) { + typedef typename PFP::VEC3 VEC3 ; + Dart e = m_map.phi1(d); Dart f = m_map.phi1(e); - const typename PFP::VEC3& Ta = m_position[e]; - const typename PFP::VEC3& Tb = m_position[f]; - const typename PFP::VEC3& Tc = m_position[d]; + const VEC3& Ta = m_position[e]; + const VEC3& Tb = m_position[f]; + const VEC3& Tc = m_position[d]; - typename PFP::VEC3 v1 = Tc-Ta; - typename PFP::VEC3 v2 = Tb-Ta; + VEC3 v1 = Tc-Ta; + VEC3 v2 = Tb-Ta; v1.normalize(); v2.normalize(); // val = 1.0f - (v1*v2); val = acos(v1*v2) / (M_PI/2.0f); - typename PFP::VEC3 vn = v1^v2; + VEC3 vn = v1^v2; if (vn*normalPoly > 0.0f) val = 10.0f - val; // not an ears (concave, store at the end for optimized use for intersections) @@ -245,7 +249,7 @@ void EarTriangulation::triangule(unsigned int thread) } // namespace Modelisation -} +} // namespace Surface } // namespace Algo diff --git a/include/Algo/Render/GL1/topo_render.h b/include/Algo/Render/GL1/topo_render.h index 19972c56..a34a30ab 100644 --- a/include/Algo/Render/GL1/topo_render.h +++ b/include/Algo/Render/GL1/topo_render.h @@ -62,7 +62,7 @@ namespace GL1 * @param kf exploding coefficient for face (1.0 normal draw) */ template -void renderTopoMD2(typename PFP::MAP& the_map, const VertexAttribute& positions, bool drawPhi1, bool drawPhi2, float ke, float kf); +void renderTopoMD2(typename PFP::MAP& the_map, const VertexAttribute& positions, bool drawPhi1, bool drawPhi2, float ke, float kf); /** @@ -77,7 +77,7 @@ void renderTopoMD2(typename PFP::MAP& the_map, const VertexAttribute -void renderTopoMD3(typename PFP::MAP& map, const VertexAttribute& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv); +void renderTopoMD3(typename PFP::MAP& map, const VertexAttribute& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv); /** * Render darts of g-map @@ -89,7 +89,7 @@ void renderTopoMD3(typename PFP::MAP& map, const VertexAttribute -void renderTopoGMD2(typename PFP::MAP& map, const VertexAttribute& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, float ke, float kf); +void renderTopoGMD2(typename PFP::MAP& map, const VertexAttribute& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, float ke, float kf); /** * Render darts of g-map @@ -103,8 +103,7 @@ void renderTopoGMD2(typename PFP::MAP& map, const VertexAttribute -void renderTopoGMD3(typename PFP::MAP& map, const VertexAttribute& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, bool drawBeta3, float kd, float ke, float kf, float kv); - +void renderTopoGMD3(typename PFP::MAP& map, const VertexAttribute& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, bool drawBeta3, float kd, float ke, float kf, float kv); } // namespace GL1 diff --git a/include/Algo/Render/GL1/topo_render.hpp b/include/Algo/Render/GL1/topo_render.hpp index 41185b07..755c7ba4 100644 --- a/include/Algo/Render/GL1/topo_render.hpp +++ b/include/Algo/Render/GL1/topo_render.hpp @@ -40,21 +40,23 @@ namespace GL1 { template -void renderTopoMD2(typename PFP::MAP& map, const VertexAttribute& positions, bool drawPhi1, bool drawPhi2, float ke, float kf) +void renderTopoMD2(typename PFP::MAP& map, const VertexAttribute& positions, bool drawPhi1, bool drawPhi2, float ke, float kf) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; typedef typename PFP::REAL REAL; - DartAutoAttribute fv1(map); - DartAutoAttribute fv11(map); - DartAutoAttribute fv2(map); - DartAutoAttribute vert(map); + DartAutoAttribute fv1(map); + DartAutoAttribute fv11(map); + DartAutoAttribute fv2(map); + DartAutoAttribute vert(map); glLineWidth(2.0f); glColor3f(0.9f,0.9f,0.9f); glBegin(GL_LINES); - DartMarker mf(map); + DartMarker mf(map); for(Dart d = map.begin(); d!= map.end(); map.next(d)) { if (!mf.isMarked(d)) @@ -74,7 +76,7 @@ void renderTopoMD2(typename PFP::MAP& map, const VertexAttribute -void renderTopoMD3(typename PFP::MAP& map, VertexAttribute& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv) +void renderTopoMD3(typename PFP::MAP& map, VertexAttribute& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; typedef typename PFP::REAL REAL; - DartAutoAttribute fv1(map); - DartAutoAttribute fv11(map); - DartAutoAttribute fv2(map); - DartAutoAttribute fv2x(map); - DartAutoAttribute vert(map); + DartAutoAttribute fv1(map); + DartAutoAttribute fv11(map); + DartAutoAttribute fv2(map); + DartAutoAttribute fv2x(map); + DartAutoAttribute vert(map); int m_nbDarts = 0; @@ -161,10 +165,10 @@ void renderTopoMD3(typename PFP::MAP& map, VertexAttribute& std::vector vecDartFaces; vecDartFaces.reserve(map.getNbDarts()/4); - DartMarker mark(map); // marker for darts + DartMarker mark(map); // marker for darts for (Dart d = map.begin(); d != map.end(); map.next(d)) { - CellMarkerStore markVert(map); //marker for vertices + CellMarkerStore markVert(map); //marker for vertices VEC3 center(0, 0, 0); unsigned int nbv = 0; unsigned int nbf = 0; @@ -307,20 +311,22 @@ void renderTopoMD3(typename PFP::MAP& map, VertexAttribute& } template -void renderTopoGMD2(typename PFP::MAP& map, const VertexAttribute& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, float kd, float ke, float kf) +void renderTopoGMD2(typename PFP::MAP& map, const VertexAttribute& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, float kd, float ke, float kf) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; typedef typename PFP::REAL REAL; - DartAutoAttribute posBeta1(map); - DartAutoAttribute posBeta2(map); - DartAutoAttribute vert(map); + DartAutoAttribute posBeta1(map); + DartAutoAttribute posBeta2(map); + DartAutoAttribute vert(map); glLineWidth(2.0f); glColor3f(0.9f,0.9f,0.9f); glBegin(GL_LINES); - DartMarker mf(map); + DartMarker mf(map); //draw all darts and potentially all beta0 for(Dart d = map.begin(); d!= map.end(); map.next(d)) { @@ -379,7 +385,7 @@ void renderTopoGMD2(typename PFP::MAP& map, const VertexAttribute(d); + mf.template markOrbit(d); } } @@ -416,14 +422,16 @@ void renderTopoGMD2(typename PFP::MAP& map, const VertexAttribute -void renderTopoGMD3(typename PFP::MAP& map, const VertexAttribute& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, bool drawBeta3, float kd, float ke, float kf, float kv) +void renderTopoGMD3(typename PFP::MAP& map, const VertexAttribute& positions, bool drawBeta0, bool drawBeta1, bool drawBeta2, bool drawBeta3, float kd, float ke, float kf, float kv) { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; typedef typename PFP::REAL REAL; - DartAutoAttribute posBeta1(map); - DartAutoAttribute posBeta2(map); //beta 3 link is represented at the same location as beta2 - DartAutoAttribute vert(map); + DartAutoAttribute posBeta1(map); + DartAutoAttribute posBeta2(map); //beta 3 link is represented at the same location as beta2 + DartAutoAttribute vert(map); // table of face (one dart of each) std::vector vecDartFaces; @@ -437,8 +445,8 @@ void renderTopoGMD3(typename PFP::MAP& map, const VertexAttribute vecVolCenters; vecVolCenters.reserve(vecDartFaces.size()/4); // = nb of volumes for a tetra mesh - DartMarker mark(map); // marker for darts - CellMarker mVol(map); + DartMarker mark(map); // marker for darts + CellMarker mVol(map); // DartMarker mVol(map); //compute barycenter and get a dart by face @@ -449,7 +457,7 @@ void renderTopoGMD3(typename PFP::MAP& map, const VertexAttribute markVert(map); //marker for vertices + CellMarkerStore markVert(map); //marker for vertices VEC3 center(0); unsigned int nbVertices = 0; unsigned int nbf = 0; @@ -616,4 +624,3 @@ void renderTopoGMD3(typename PFP::MAP& map, const VertexAttribute& tableIndices) ; template - inline void addEarTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices, const VertexAttribute* position); + inline void addEarTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices, const VertexAttribute* 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 VertexAttribute& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly); + bool computeEarIntersection(const VertexAttribute& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly); template - void recompute2Ears(const VertexAttribute& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly, VPMS& ears, bool convex); + void recompute2Ears(const VertexAttribute& 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); @@ -174,9 +174,9 @@ public: * @param tableIndices the table where indices are stored */ template - void initTriangles(typename PFP::MAP& map, std::vector& tableIndices, const VertexAttribute* position, unsigned int thread = 0) ; + void initTriangles(typename PFP::MAP& map, std::vector& tableIndices, const VertexAttribute* position, unsigned int thread = 0) ; template - void initTrianglesOptimized(typename PFP::MAP& map, std::vector& tableIndices, const VertexAttribute* position, unsigned int thread = 0) ; + void initTrianglesOptimized(typename PFP::MAP& map, std::vector& tableIndices, const VertexAttribute* position, unsigned int thread = 0) ; /** * creation of indices table of lines (optimized order) @@ -209,13 +209,13 @@ public: void initPrimitives(typename PFP::MAP& map, int prim, bool optimized = true, unsigned int thread = 0) ; template - void initPrimitives(typename PFP::MAP& map, int prim, const VertexAttribute* position, bool optimized = true, unsigned int thread = 0) ; + void initPrimitives(typename PFP::MAP& map, int prim, const VertexAttribute* position, bool optimized = true, unsigned int thread = 0) ; /** * add primitives to the VBO of indices */ template - void addPrimitives(typename PFP::MAP& map, int prim, const VertexAttribute* position, bool optimized = true, unsigned int thread = 0); + void addPrimitives(typename PFP::MAP& map, int prim, const VertexAttribute* 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 c6e1b84f..736edc16 100644 --- a/include/Algo/Render/GL2/mapRender.hpp +++ b/include/Algo/Render/GL2/mapRender.hpp @@ -71,20 +71,22 @@ bool MapRender::inTriangle(const VEC3& P, const VEC3& normal, const VEC3& Ta, c } template -void MapRender::recompute2Ears(const VertexAttribute& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly, VPMS& ears, bool convex) +void MapRender::recompute2Ears(const VertexAttribute& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly, VPMS& ears, bool convex) { + typedef typename PFP::VEC3 VEC3; + VertexPoly* vprev = vp->prev; VertexPoly* vp2 = vp->next; VertexPoly* vnext = vp2->next; - const typename PFP::VEC3& Ta = position[vp->id]; - const typename PFP::VEC3& Tb = position[vp2->id]; - const typename PFP::VEC3& Tc = position[vprev->id]; - const typename PFP::VEC3& Td = position[vnext->id]; + const VEC3& Ta = position[vp->id]; + const VEC3& Tb = position[vp2->id]; + const VEC3& Tc = position[vprev->id]; + const VEC3& Td = position[vnext->id]; // compute angle - typename PFP::VEC3 v1= Tb - Ta; - typename PFP::VEC3 v2= Tc - Ta; - typename PFP::VEC3 v3= Td - Tb; + VEC3 v1= Tb - Ta; + VEC3 v2= Tc - Ta; + VEC3 v3= Td - Tb; v1.normalize(); v2.normalize(); @@ -98,8 +100,8 @@ void MapRender::recompute2Ears(const VertexAttributevalue > 5.0f); ++it) { int id = (*it)->id; - const typename PFP::VEC3& P = position[id]; + const VEC3& P = position[id]; if ((dotpr1 < 5.0f) && (id !=vprev->id)) - if (inTriangle(P, normalPoly,Tb,Tc,Ta)) + if (inTriangle(P, normalPoly,Tb,Tc,Ta)) dotpr1 = 5.0f;// not an ears ! if ((dotpr2 < 5.0f) && (id !=vnext->id) ) - if (inTriangle(P, normalPoly,Td,Ta,Tb)) + if (inTriangle(P, normalPoly,Td,Ta,Tb)) dotpr2 = 5.0f;// not an ears ! finished = ((dotpr1 >= 5.0f)&&(dotpr2 >= 5.0f)); @@ -135,15 +137,17 @@ void MapRender::recompute2Ears(const VertexAttribute float MapRender::computeEarAngle(const typename PFP::VEC3& P1, const typename PFP::VEC3& P2, const typename PFP::VEC3& P3, const typename PFP::VEC3& normalPoly) { - typename PFP::VEC3 v1 = P1-P2; - typename PFP::VEC3 v2 = P3-P2; + typedef typename PFP::VEC3 VEC3; + + VEC3 v1 = P1-P2; + VEC3 v2 = P3-P2; v1.normalize(); v2.normalize(); // float dotpr = 1.0f - (v1*v2); float dotpr = acos(v1*v2) / (M_PI/2.0f); - typename PFP::VEC3 vn = v1^v2; + VEC3 vn = v1^v2; if (vn*normalPoly > 0.0f) dotpr = 10.0f - dotpr; // not an ears (concave, store at the end for optimized use for intersections) @@ -151,19 +155,20 @@ float MapRender::computeEarAngle(const typename PFP::VEC3& P1, const typename PF } template -bool MapRender::computeEarIntersection(const VertexAttribute& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly) +bool MapRender::computeEarIntersection(const VertexAttribute& position, VertexPoly* vp, const typename PFP::VEC3& normalPoly) { + typedef typename PFP::VEC3 VEC3; VertexPoly* endV = vp->prev; VertexPoly* curr = vp->next; - const typename PFP::VEC3& Ta = position[vp->id]; - const typename PFP::VEC3& Tb = position[curr->id]; - const typename PFP::VEC3& Tc = position[endV->id]; + const VEC3& Ta = position[vp->id]; + const VEC3& Tb = position[curr->id]; + const VEC3& Tc = position[endV->id]; curr = curr->next; while (curr != endV) { - if (inTriangle(position[curr->id], normalPoly,Tb,Tc,Ta)) + if (inTriangle(position[curr->id], normalPoly,Tb,Tc,Ta)) { vp->value = 5.0f;// not an ears ! return false; @@ -175,15 +180,17 @@ bool MapRender::computeEarIntersection(const VertexAttribute -inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices, const VertexAttribute* pos) +inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector& tableIndices, const VertexAttribute* pos) { + typedef typename PFP::VEC3 VEC3; + bool(*fn_pt1)(VertexPoly*,VertexPoly*) = &(MapRender::cmpVP); VPMS ears(fn_pt1); - const VertexAttribute& position = *pos ; + const VertexAttribute& position = *pos ; // compute normal to polygon - typename PFP::VEC3 normalPoly = Algo::Surface::Geometry::newellNormal(map, d, position); + VEC3 normalPoly = Algo::Surface::Geometry::newellNormal(map, d, position); // first pass create polygon in chained list with angle computation VertexPoly* vpp = NULL; @@ -195,9 +202,9 @@ inline void MapRender::addEarTri(typename PFP::MAP& map, Dart d, std::vector(a)]; - typename PFP::VEC3 P2 = position[map.template getEmbedding(b)]; - typename PFP::VEC3 P3 = position[map.template getEmbedding(c)]; + VEC3 P1 = position[map.template getEmbedding(a)]; + VEC3 P2 = position[map.template getEmbedding(b)]; + VEC3 P3 = position[map.template getEmbedding(c)]; float val = computeEarAngle(P1, P2, P3, normalPoly); VertexPoly* vp = new VertexPoly(map.template getEmbedding(b), val, (P3-P1).norm2(), vpp); @@ -297,7 +304,7 @@ inline void MapRender::addTri(typename PFP::MAP& map, Dart d, std::vector -void MapRender::initTriangles(typename PFP::MAP& map, std::vector& tableIndices, const VertexAttribute* position, unsigned int thread) +void MapRender::initTriangles(typename PFP::MAP& map, std::vector& tableIndices, const VertexAttribute* position, unsigned int thread) { tableIndices.reserve(4 * map.getNbDarts() / 3); @@ -321,7 +328,7 @@ void MapRender::initTriangles(typename PFP::MAP& map, std::vector& table } template -void MapRender::initTrianglesOptimized(typename PFP::MAP& map, std::vector& tableIndices, const VertexAttribute* position, unsigned int thread) +void MapRender::initTrianglesOptimized(typename PFP::MAP& map, std::vector& tableIndices, const VertexAttribute* position, unsigned int thread) { #define LIST_SIZE 20 DartMarker m(map, thread); @@ -348,7 +355,7 @@ void MapRender::initTrianglesOptimized(typename PFP::MAP& map, std::vector(map, dd, tableIndices, position); } } - m.markOrbit(dd); + m.template markOrbit(dd); bound.push_back(dd); int nb = 1; do @@ -374,7 +381,7 @@ void MapRender::initTrianglesOptimized(typename PFP::MAP& map, std::vector(map, f, tableIndices, position); } } - m.markOrbit(f); + m.template markOrbit(f); bound.push_back(map.phi1(f)); ++nb; if (nb > LIST_SIZE) @@ -452,7 +459,7 @@ void MapRender::initLinesOptimized(typename PFP::MAP& map, std::vector& { tableIndices.push_back(map.template getEmbedding(ee)); tableIndices.push_back(map.template getEmbedding(map.phi1(ee))); - m.markOrbit(f); + m.template markOrbit(f); bound.push_back(f); ++nb; @@ -489,7 +496,7 @@ void MapRender::initPrimitives(typename PFP::MAP& map, int prim, bool optimized, } template -void MapRender::initPrimitives(typename PFP::MAP& map, int prim, const VertexAttribute* position, bool optimized, unsigned int thread) +void MapRender::initPrimitives(typename PFP::MAP& map, int prim, const VertexAttribute* position, bool optimized, unsigned int thread) { std::vector tableIndices; @@ -529,9 +536,8 @@ void MapRender::initPrimitives(typename PFP::MAP& map, int prim, const VertexAtt glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER, m_nbIndices[prim] * sizeof(GLuint), &(tableIndices[0]), GL_STREAM_DRAW); } - template -void MapRender::addPrimitives(typename PFP::MAP& map, int prim, const VertexAttribute* position, bool optimized, unsigned int thread) +void MapRender::addPrimitives(typename PFP::MAP& map, int prim, const VertexAttribute* position, bool optimized, unsigned int thread) { std::vector tableIndices; diff --git a/include/Algo/Render/GL2/topo3PrimalRender.h b/include/Algo/Render/GL2/topo3PrimalRender.h index 95e2e065..0489ee7e 100644 --- a/include/Algo/Render/GL2/topo3PrimalRender.h +++ b/include/Algo/Render/GL2/topo3PrimalRender.h @@ -55,6 +55,10 @@ namespace GL2 template class Topo3PrimalRender { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + typedef typename PFP::VEC3 VEC3; + protected: /** * vbo buffers @@ -109,7 +113,7 @@ protected: /** * attribute index to get easy correspondence dart/color */ - DartAttribute m_attIndex; + DartAttribute m_attIndex; Geom::Vec3f* m_bufferDartPosition; @@ -215,7 +219,7 @@ public: /** * store darts in color for picking */ - void setDartsIdColor(typename PFP::MAP& map); + void setDartsIdColor(MAP& map); /** * pick dart with color set bey setDartsIdColor @@ -226,7 +230,7 @@ public: * @param y position of mouse (pass H-y, classic pb of origin) * @return the dart or NIL */ - Dart picking(typename PFP::MAP& map, int x, int y); + Dart picking(MAP& map, int x, int y); /** * compute dart from color (for picking) @@ -249,21 +253,21 @@ public: // template // void updateData(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf); - void updateData(typename PFP::MAP& mapx, const VertexAttribute& positions, float ke, float kf); + void updateData(MAP& mapx, const VertexAttribute& positions, float ke, float kf); /** * update color buffer with color attribute handler * @param map the map * @param colors attribute of dart's colors */ - void updateColors(typename PFP::MAP& map, const VertexAttribute& colors); + void updateColors(MAP& map, const VertexAttribute& colors); /** * Get back middle position of drawn darts * @param map the map * @param posExpl the output positions */ - void computeDartMiddlePositions(typename PFP::MAP& map, DartAttribute& posExpl); + void computeDartMiddlePositions(MAP& map, DartAttribute& posExpl); /** * render to svg struct @@ -275,9 +279,9 @@ public: */ void svgout2D(const std::string& filename, const glm::mat4& model, const glm::mat4& proj); - Dart coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle); + Dart coneSelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle); - Dart raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); + Dart raySelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); protected: // /** diff --git a/include/Algo/Render/GL2/topo3PrimalRender.hpp b/include/Algo/Render/GL2/topo3PrimalRender.hpp index cff42bdd..13bb0b0d 100644 --- a/include/Algo/Render/GL2/topo3PrimalRender.hpp +++ b/include/Algo/Render/GL2/topo3PrimalRender.hpp @@ -416,7 +416,7 @@ void Topo3PrimalRender::updateColors(typename PFP::MAP& map, const VertexAt } template -Dart Topo3PrimalRender::picking(typename PFP::MAP& map, int x, int y) +Dart Topo3PrimalRender::picking(MAP& map, int x, int y) { pushColors(); setDartsIdColor(map); @@ -432,12 +432,8 @@ Dart Topo3PrimalRender::picking(typename PFP::MAP& map, int x, int y) //} template -void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribute& positions, float ke, float kf) +void Topo3PrimalRender::updateData(MAP& mapx, const VertexAttribute& positions, float ke, float kf) { - typedef typename PFP::VEC3 VEC3; - typedef typename PFP::REAL REAL; - typedef Geom::Vec3f VEC3F; - if (m_attIndex.map() != &mapx) m_attIndex = mapx.template getAttribute("dart_index"); if (!m_attIndex.isValid()) @@ -452,23 +448,23 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAtt m_nbDarts = mapx.getNbDarts(); // beta2/3 - DartAutoAttribute fv2(mapx); + DartAutoAttribute fv2(mapx); m_vbo2->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3F), 0, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(Geom::Vec3f), 0, GL_STREAM_DRAW); GLvoid* ColorDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - VEC3F* colorDartBuf = reinterpret_cast(ColorDartsBuffer); + Geom::Vec3f* colorDartBuf = reinterpret_cast(ColorDartsBuffer); if (m_bufferDartPosition!=NULL) delete m_bufferDartPosition; - m_bufferDartPosition = new VEC3F[2*m_nbDarts]; - VEC3F* positionDartBuf = reinterpret_cast(m_bufferDartPosition); + m_bufferDartPosition = new Geom::Vec3f[2*m_nbDarts]; + Geom::Vec3f* positionDartBuf = reinterpret_cast(m_bufferDartPosition); - unsigned int posDBI=0; + unsigned int posDBI = 0; - int nbf=0; + int nbf = 0; //traverse each face of each volume - TraversorF traFace(mapx); + TraversorF traFace(mapx); for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next()) { std::vector vecPos; @@ -556,7 +552,7 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAtt VEC3F* positionF2 = reinterpret_cast(PositionBuffer2); - m_nbRel2=0; + m_nbRel2 = 0; for (Dart d = mapx.begin(); d != mapx.end(); mapx.next(d)) { @@ -576,16 +572,14 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAtt } template -void Topo3PrimalRender::computeDartMiddlePositions(typename PFP::MAP& map, DartAttribute& posExpl) +void Topo3PrimalRender::computeDartMiddlePositions(MAP& map, DartAttribute& posExpl) { - typedef Geom::Vec3f VEC3F; - m_vbo0->bind(); - VEC3F* positionsPtr = reinterpret_cast(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY)); + Geom::Vec3f* positionsPtr = reinterpret_cast(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY)); for (Dart d = map.begin(); d != map.end(); map.next(d)) { - const VEC3F& v =(positionsPtr[m_attIndex[d]] + positionsPtr[m_attIndex[d]+1])*0.5f; + const Geom::Vec3f& v =(positionsPtr[m_attIndex[d]] + positionsPtr[m_attIndex[d]+1])*0.5f; posExpl[d] = PFP::toVec3f(v); } @@ -594,7 +588,7 @@ void Topo3PrimalRender::computeDartMiddlePositions(typename PFP::MAP& map, } template -Dart Topo3PrimalRender::coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle) +Dart Topo3PrimalRender::coneSelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle) { float AB2 = rayAB*rayAB; Dart dFinal; @@ -624,7 +618,7 @@ Dart Topo3PrimalRender::coneSelection(typename PFP::MAP& map, const Geom::V } template -Dart Topo3PrimalRender::raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float dmax) +Dart Topo3PrimalRender::raySelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float dmax) { float AB2 = rayAB*rayAB; Dart dFinal; @@ -637,11 +631,11 @@ Dart Topo3PrimalRender::raySelection(typename PFP::MAP& map, const Geom::Ve const Geom::Vec3f& P = m_bufferDartPosition[m_attIndex[d]]; const Geom::Vec3f& Q =m_bufferDartPosition[m_attIndex[d]+1]; float ld2 = Geom::squaredDistanceLine2Seg(rayA, rayAB, AB2, P, Q); - if (ld2 class Topo3Render { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + typedef typename PFP::VEC3 VEC3; + protected: /** * vbo buffers @@ -118,7 +122,7 @@ protected: /** * attribute index to get easy correspondence dart/color */ - DartAttribute m_attIndex; + DartAttribute m_attIndex; Geom::Vec3f* m_bufferDartPosition; @@ -233,7 +237,7 @@ public: /** * store darts in color for picking */ - void setDartsIdColor(typename PFP::MAP& map); + void setDartsIdColor(MAP& map); /** * pick dart with color set bey setDartsIdColor @@ -244,7 +248,7 @@ public: * @param y position of mouse (pass H-y, classic pb of origin) * @return the dart or NIL */ - Dart picking(typename PFP::MAP& map, int x, int y); + Dart picking(MAP& map, int x, int y); /** * compute dart from color (for picking) @@ -264,7 +268,7 @@ public: * @param kf exploding coef for face * @param kv exploding coef for face */ - void updateData(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, float kv); + void updateData(MAP& map, const VertexAttribute& positions, float ke, float kf, float kv); // template // void updateData(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, float kv); @@ -277,14 +281,14 @@ public: // template // void updateColorsGen(typename PFP::MAP& map, const EMBV& colors); - void updateColors(typename PFP::MAP& map, const VertexAttribute& colors); + void updateColors(MAP& map, const VertexAttribute& colors); /** * Get back middle position of drawn darts * @param map the map * @param posExpl the output positions */ - void computeDartMiddlePositions(typename PFP::MAP& map, DartAttribute& posExpl); + void computeDartMiddlePositions(MAP& map, DartAttribute& posExpl); /** * render to svg struct @@ -296,9 +300,9 @@ public: */ void svgout2D(const std::string& filename, const glm::mat4& model, const glm::mat4& proj); - Dart coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle); + Dart coneSelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle); - Dart raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); + Dart raySelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); protected: /** @@ -309,7 +313,7 @@ protected: * @param kf exploding coef for face * @param kv exploding coef for face */ - void updateDataMap3(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, float kv); + void updateDataMap3(MAP& map, const VertexAttribute& positions, float ke, float kf, float kv); /** * update all drawing buffers to render a gmap @@ -319,7 +323,7 @@ protected: * @param kf exploding coef for face * @param kv exploding coef for face */ - void updateDataGMap3(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, float kv); + void updateDataGMap3(MAP& map, const VertexAttribute& positions, float ke, float kf, float kv); }; }//end namespace GL2 diff --git a/include/Algo/Render/GL2/topo3Render.hpp b/include/Algo/Render/GL2/topo3Render.hpp index a8171551..3a1a318f 100644 --- a/include/Algo/Render/GL2/topo3Render.hpp +++ b/include/Algo/Render/GL2/topo3Render.hpp @@ -394,7 +394,6 @@ void Topo3Render::svgout2D(const std::string& filename, const glm::mat4& mo template void Topo3Render::toSVG(Utils::SVG::SVGOut& svg) { - // PHI3 / beta3 Utils::SVG::SvgGroup* svg1 = new Utils::SVG::SvgGroup("phi3", svg.m_model, svg.m_proj); const Geom::Vec3f* ptr = reinterpret_cast(m_vbo3->lockPtr()); @@ -491,14 +490,15 @@ void Topo3Render::toSVG(Utils::SVG::SVGOut& svg) //} template -void Topo3Render::updateData(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, float kv) +void Topo3Render::updateData(MAP& map, const VertexAttribute& positions, float ke, float kf, float kv) { - if (map.mapTypeName()[0] == "M") // "Map2" + std::string typeName = map.mapTypeName(); + if (typeName[0] == "M") // "Map3" { updateDataMap3(map, positions, ke, kf, kv); return; } - if (map.mapTypeName()[0] == "G") // "GMap2" + if (typeName[0] == "G") // "GMap3" { updateDataGMap3(map, positions, ke, kf, kv); return; @@ -506,13 +506,8 @@ void Topo3Render::updateData(typename PFP::MAP& map, const VertexAttribute< } template -void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const VertexAttribute& positions, float ke, float kf, float kv) +void Topo3Render::updateDataMap3(MAP& mapx, const VertexAttribute& positions, float ke, float kf, float kv) { - typedef typename PFP::MAP MAP; - typedef typename PFP::VEC3 VEC3; - typedef typename PFP::REAL REAL; - typedef Geom::Vec3f VEC3F; - m_attIndex = mapx.template getAttribute("dart_index3"); if (!m_attIndex.isValid()) @@ -527,32 +522,32 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const VertexAttri // compute center of each volumes CellMarker cmv(mapx); - VolumeAutoAttribute centerVolumes(mapx, "centerVolumes"); + VolumeAutoAttribute centerVolumes(mapx, "centerVolumes"); Algo::Volume::Geometry::Parallel::computeCentroidELWVolumes(mapx, positions, centerVolumes,3); // debut phi1 - DartAutoAttribute fv1(mapx); + DartAutoAttribute fv1(mapx); // fin phi1 - DartAutoAttribute fv11(mapx); + DartAutoAttribute fv11(mapx); // phi2 - DartAutoAttribute fv2(mapx); - DartAutoAttribute fv2x(mapx); + DartAutoAttribute fv2(mapx); + DartAutoAttribute fv2x(mapx); m_vbo4->bind(); glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); GLvoid* ColorDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - VEC3F* colorDartBuf = reinterpret_cast(ColorDartsBuffer); + Geom::Vec3f* colorDartBuf = reinterpret_cast(ColorDartsBuffer); m_vbo0->bind(); glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - VEC3F* positionDartBuf = reinterpret_cast(PositionDartsBuffer); + Geom::Vec3f* positionDartBuf = reinterpret_cast(PositionDartsBuffer); std::vector vecDartFaces; vecDartFaces.reserve(m_nbDarts/3); - unsigned int posDBI=0; + unsigned int posDBI = 0; // traverse each face of each volume TraversorCell traFace(mapx); @@ -614,17 +609,17 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const VertexAttri m_vbo4->bind(); glUnmapBuffer(GL_ARRAY_BUFFER); - VEC3F* positioniF1 = new VEC3F[ 2*m_nbDarts]; - VEC3F* positioniF2 = new VEC3F[ 2*m_nbDarts]; - VEC3F* positioniF3 = new VEC3F[ 2*m_nbDarts]; + Geom::Vec3f* positioniF1 = new Geom::Vec3f[ 2*m_nbDarts]; + Geom::Vec3f* positioniF2 = new Geom::Vec3f[ 2*m_nbDarts]; + Geom::Vec3f* positioniF3 = new Geom::Vec3f[ 2*m_nbDarts]; - VEC3F* positionF1 = positioniF1; - VEC3F* positionF2 = positioniF2; - VEC3F* positionF3 = positioniF3; + Geom::Vec3f* positionF1 = positioniF1; + Geom::Vec3f* positionF2 = positioniF2; + Geom::Vec3f* positionF3 = positioniF3; - m_nbRel1=0; - m_nbRel2=0; - m_nbRel3=0; + m_nbRel1 = 0; + m_nbRel2 = 0; + m_nbRel3 = 0; for(std::vector::iterator face = vecDartFaces.begin(); face != vecDartFaces.end(); ++face) { @@ -659,13 +654,13 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const VertexAttri } m_vbo3->bind(); - glBufferData(GL_ARRAY_BUFFER, 4*m_nbRel3*sizeof(VEC3F), positioniF3, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, 4*m_nbRel3*sizeof(Geom::Vec3f), positioniF3, GL_STREAM_DRAW); m_vbo2->bind(); - glBufferData(GL_ARRAY_BUFFER, 4*m_nbRel2*sizeof(VEC3F), positioniF2, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, 4*m_nbRel2*sizeof(Geom::Vec3f), positioniF2, GL_STREAM_DRAW); m_vbo1->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbRel1*sizeof(VEC3F), positioniF1, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, 2*m_nbRel1*sizeof(Geom::Vec3f), positioniF1, GL_STREAM_DRAW); delete[] positioniF1; delete[] positioniF2; @@ -708,13 +703,11 @@ void Topo3Render::setDartsIdColor(typename PFP::MAP& map) } template -void Topo3Render::updateColors(typename PFP::MAP& map, const VertexAttribute& colors) +void Topo3Render::updateColors(MAP& map, const VertexAttribute& colors) { - typedef typename PFP::VEC3 VEC3; - m_vbo4->bind(); - VEC3* colorBuffer = reinterpret_cast(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE)); - unsigned int nb=0; + VEC3* colorBuffer = reinterpret_cast(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE)); + unsigned int nb = 0; for (Dart d = map.begin(); d != map.end(); map.next(d)) { @@ -736,7 +729,7 @@ void Topo3Render::updateColors(typename PFP::MAP& map, const VertexAttribut } template -Dart Topo3Render::picking(typename PFP::MAP& map, int x, int y) +Dart Topo3Render::picking(MAP& map, int x, int y) { pushColors(); setDartsIdColor(map); @@ -746,13 +739,8 @@ Dart Topo3Render::picking(typename PFP::MAP& map, int x, int y) } template -void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttribute& positions, float ke, float kf, float kv) +void Topo3Render::updateDataGMap3(MAP& mapx, const VertexAttribute& positions, float ke, float kf, float kv) { - typedef typename PFP::MAP MAP; - typedef typename PFP::VEC3 VEC3; - typedef typename PFP::REAL REAL; - typedef Geom::Vec3f VEC3F; - // GMap3& map = dynamic_cast(mapx); // TODO reflechir comment virer ce warning quand on compile avec PFP::MAP=Map3 if (m_attIndex.map() != &mapx) @@ -768,24 +756,24 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttr } // compute center of each volumes - VolumeAutoAttribute centerVolumes(mapx, "centerVolumes"); + VolumeAutoAttribute centerVolumes(mapx, "centerVolumes"); Algo::Volume::Geometry::Parallel::computeCentroidELWVolumes(mapx, positions, centerVolumes); // beta1 - DartAutoAttribute fv1(mapx); + DartAutoAttribute fv1(mapx); // beta2/3 - DartAutoAttribute fv2(mapx); - DartAutoAttribute fv2x(mapx); + DartAutoAttribute fv2(mapx); + DartAutoAttribute fv2x(mapx); m_vbo4->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3F), 0, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(Geom::Vec3f), 0, GL_STREAM_DRAW); GLvoid* ColorDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - VEC3F* colorDartBuf = reinterpret_cast(ColorDartsBuffer); + Geom::Vec3f* colorDartBuf = reinterpret_cast(ColorDartsBuffer); if (m_bufferDartPosition!=NULL) delete m_bufferDartPosition; - m_bufferDartPosition = new VEC3F[2*m_nbDarts]; - VEC3F* positionDartBuf = reinterpret_cast(m_bufferDartPosition); + m_bufferDartPosition = new Geom::Vec3f[2*m_nbDarts]; + Geom::Vec3f* positionDartBuf = reinterpret_cast(m_bufferDartPosition); // m_vbo0->bind(); // glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); @@ -794,7 +782,7 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttr std::vector vecDartFaces; vecDartFaces.reserve(m_nbDarts/6); - unsigned int posDBI=0; + unsigned int posDBI = 0; //traverse each face of each volume TraversorCell traFace(mapx); @@ -810,7 +798,7 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttr VEC3 vc = centerVolumes[d]; - VEC3 centerFace = Algo::Surface::Geometry::faceCentroidELW(mapx,d,positions)*kv +vc*okv; + VEC3 centerFace = Algo::Surface::Geometry::faceCentroidELW(mapx, d, positions)*kv +vc*okv; //shrink the face float okf = 1.0f - kf; @@ -864,7 +852,7 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttr } m_vbo0->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3F), m_bufferDartPosition, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(Geom::Vec3f), m_bufferDartPosition, GL_STREAM_DRAW); // m_vbo0->bind(); // glUnmapBuffer(GL_ARRAY_BUFFER); @@ -873,22 +861,22 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttr // beta3 m_vbo1->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3F), 0, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(Geom::Vec3f), 0, GL_STREAM_DRAW); GLvoid* PositionBuffer1 = glMapBufferARB(GL_ARRAY_BUFFER, GL_READ_WRITE); // beta3 m_vbo2->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3F), 0, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(Geom::Vec3f), 0, GL_STREAM_DRAW); GLvoid* PositionBuffer2 = glMapBufferARB(GL_ARRAY_BUFFER, GL_READ_WRITE); // beta3 m_vbo3->bind(); - glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3F), 0, GL_STREAM_DRAW); + glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(Geom::Vec3f), 0, GL_STREAM_DRAW); GLvoid* PositionBuffer3 = glMapBufferARB(GL_ARRAY_BUFFER, GL_READ_WRITE); - VEC3F* positionF1 = reinterpret_cast(PositionBuffer1); - VEC3F* positionF2 = reinterpret_cast(PositionBuffer2); - VEC3F* positionF3 = reinterpret_cast(PositionBuffer3); + Geom::Vec3f* positionF1 = reinterpret_cast(PositionBuffer1); + Geom::Vec3f* positionF2 = reinterpret_cast(PositionBuffer2); + Geom::Vec3f* positionF3 = reinterpret_cast(PositionBuffer3); m_nbRel2 = 0; m_nbRel3 = 0; @@ -956,17 +944,14 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttr } template -void Topo3Render::computeDartMiddlePositions(typename PFP::MAP& map, DartAttribute& posExpl) +void Topo3Render::computeDartMiddlePositions(MAP& map, DartAttribute& posExpl) { - typedef Geom::Vec3f VEC3F; - typedef typename PFP::VEC3 VEC3; - m_vbo0->bind(); - VEC3F* positionsPtr = reinterpret_cast(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY)); + Geom::Vec3f* positionsPtr = reinterpret_cast(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY)); for (Dart d = map.begin(); d != map.end(); map.next(d)) { - const VEC3F& v = (positionsPtr[m_attIndex[d]] + positionsPtr[m_attIndex[d]+1])*0.5f; + const Geom::Vec3f& v = (positionsPtr[m_attIndex[d]] + positionsPtr[m_attIndex[d]+1])*0.5f; posExpl[d] = PFP::toVec3f(v); } @@ -1196,9 +1181,8 @@ void Topo3Render::computeDartMiddlePositions(typename PFP::MAP& map, DartAt // glUnmapBuffer(GL_ARRAY_BUFFER); //} - template -Dart Topo3Render::coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle) +Dart Topo3Render::coneSelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle) { float AB2 = rayAB*rayAB; Dart dFinal; @@ -1228,7 +1212,7 @@ Dart Topo3Render::coneSelection(typename PFP::MAP& map, const Geom::Vec3f& } template -Dart Topo3Render::raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float dmax) +Dart Topo3Render::raySelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float dmax) { float AB2 = rayAB*rayAB; Dart dFinal; diff --git a/include/Algo/Render/GL2/topoPrimalRender.h b/include/Algo/Render/GL2/topoPrimalRender.h index 05cbe5db..8be592c1 100644 --- a/include/Algo/Render/GL2/topoPrimalRender.h +++ b/include/Algo/Render/GL2/topoPrimalRender.h @@ -55,6 +55,10 @@ namespace GL2 template class TopoPrimalRender { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + typedef typename PFP::VEC3 VEC3; + protected: /** * vbo buffers @@ -109,7 +113,7 @@ protected: /** * attribute index to get easy correspondence dart/color */ - DartAttribute m_attIndex; + DartAttribute m_attIndex; Geom::Vec3f* m_bufferDartPosition; @@ -213,7 +217,7 @@ public: /** * store darts in color for picking */ - void setDartsIdColor(typename PFP::MAP& map); + void setDartsIdColor(MAP& map); /** * pick dart with color set bey setDartsIdColor @@ -224,7 +228,7 @@ public: * @param y position of mouse (pass H-y, classic pb of origin) * @return the dart or NIL */ - Dart picking(typename PFP::MAP& map, int x, int y); + Dart picking(MAP& map, int x, int y); /** * compute dart from color (for picking) @@ -242,14 +246,14 @@ public: * @param positions attribute of position vertices * @param ke exploding coef for edge */ - void updateData(typename PFP::MAP& map, const VertexAttribute& positions, float ke); + void updateData(MAP& map, const VertexAttribute& positions, float ke); /** * update color buffer with color attribute handler * @param map the map * @param colors attribute of dart's colors */ - void updateColors(typename PFP::MAP& map, const VertexAttribute& colors); + void updateColors(MAP& map, const VertexAttribute& colors); /** * Get back middle position of drawn darts @@ -257,7 +261,7 @@ public: * @param posExpl the output positions */ template - void computeDartMiddlePositions(typename PFP::MAP& map, DartAttribute& posExpl); + void computeDartMiddlePositions(MAP& map, DartAttribute& posExpl); /** * render to svg struct @@ -269,9 +273,9 @@ public: */ void svgout2D(const std::string& filename, const glm::mat4& model, const glm::mat4& proj); - Dart coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle); + Dart coneSelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle); - Dart raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); + Dart raySelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); }; } // end namespace GL2 diff --git a/include/Algo/Render/GL2/topoPrimalRender.hpp b/include/Algo/Render/GL2/topoPrimalRender.hpp index 796872fe..fe6dde87 100644 --- a/include/Algo/Render/GL2/topoPrimalRender.hpp +++ b/include/Algo/Render/GL2/topoPrimalRender.hpp @@ -386,7 +386,7 @@ void TopoPrimalRender::setDartsIdColor(typename PFP::MAP& map) } template -void TopoPrimalRender::updateColors(typename PFP::MAP& map, const VertexAttribute& colors) +void TopoPrimalRender::updateColors(MAP& map, const VertexAttribute& colors) { m_vbo2->bind(); Geom::Vec3f* colorBuffer = reinterpret_cast(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE)); @@ -409,7 +409,7 @@ void TopoPrimalRender::updateColors(typename PFP::MAP& map, const VertexAtt } template -Dart TopoPrimalRender::picking(typename PFP::MAP& map, int x, int y) +Dart TopoPrimalRender::picking(MAP& map, int x, int y) { pushColors(); setDartsIdColor(map); @@ -419,10 +419,8 @@ Dart TopoPrimalRender::picking(typename PFP::MAP& map, int x, int y) } template -void TopoPrimalRender::updateData(typename PFP::MAP& map, const VertexAttribute& positions, float ke) +void TopoPrimalRender::updateData(MAP& map, const VertexAttribute& positions, float ke) { - typedef typename PFP::VEC3 VEC3; - if (m_attIndex.map() != &map) m_attIndex = map.template getAttribute("dart_index"); if (!m_attIndex.isValid()) @@ -435,7 +433,7 @@ void TopoPrimalRender::updateData(typename PFP::MAP& map, const VertexAttri // } m_nbDarts = map.getNbDarts(); - DartAutoAttribute fv1(map); + DartAutoAttribute fv1(map); m_vbo2->bind(); glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); @@ -536,7 +534,7 @@ void TopoPrimalRender::updateData(typename PFP::MAP& map, const VertexAttri } template -void TopoPrimalRender::computeDartMiddlePositions(typename PFP::MAP& map, DartAttribute& posExpl) +void TopoPrimalRender::computeDartMiddlePositions(MAP& map, DartAttribute& posExpl) { m_vbo0->bind(); VEC3* positionsPtr = reinterpret_cast(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY)); @@ -549,7 +547,7 @@ void TopoPrimalRender::computeDartMiddlePositions(typename PFP::MAP& map, D } template -Dart TopoPrimalRender::coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle) +Dart TopoPrimalRender::coneSelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle) { float AB2 = rayAB*rayAB; Dart dFinal; @@ -579,7 +577,7 @@ Dart TopoPrimalRender::coneSelection(typename PFP::MAP& map, const Geom::Ve } template -Dart TopoPrimalRender::raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float dmax) +Dart TopoPrimalRender::raySelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float dmax) { float AB2 = rayAB*rayAB; Dart dFinal; diff --git a/include/Algo/Render/GL2/topoRender.h b/include/Algo/Render/GL2/topoRender.h index 4fa7944e..7babf486 100644 --- a/include/Algo/Render/GL2/topoRender.h +++ b/include/Algo/Render/GL2/topoRender.h @@ -54,6 +54,10 @@ namespace GL2 template class TopoRender { + typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; + typedef typename PFP::VEC3 VEC3; + protected: /** * vbo buffers @@ -114,7 +118,7 @@ protected: /** * attribut d'index dans le VBO */ - DartAttribute m_attIndex; + DartAttribute m_attIndex; Geom::Vec3f* m_bufferDartPosition; @@ -139,7 +143,7 @@ protected: /** * affect a color to each dart */ - void setDartsIdColor(typename PFP::MAP& map, bool withBoundary); + void setDartsIdColor(MAP& map, bool withBoundary); /** * save colors before picking @@ -241,22 +245,22 @@ public: * @param y position of mouse (pass H-y, classic pb of origin) * @return the dart or NIL */ - Dart picking(typename PFP::MAP& map, int x, int y, bool withBoundary=false); + Dart picking(MAP& map, int x, int y, bool withBoundary=false); - Dart coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle); + Dart coneSelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle); - Dart raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); + Dart raySelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); - void updateData(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, bool withBoundary = false); + void updateData(MAP& map, const VertexAttribute& positions, float ke, float kf, bool withBoundary = false); - void updateDataMap(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, bool withBoundary = false); + void updateDataMap(MAP& map, const VertexAttribute& positions, float ke, float kf, bool withBoundary = false); - void updateDataGMap(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, bool withBoundary = false); + void updateDataGMap(MAP& map, const VertexAttribute& positions, float ke, float kf, bool withBoundary = false); /** * Special update function used to draw boundary of map3 */ - void updateDataBoundary(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, float ns); + void updateDataBoundary(MAP& map, const VertexAttribute& positions, float ke, float kf, float ns); /** * render to svg struct diff --git a/include/Algo/Render/GL2/topoRender.hpp b/include/Algo/Render/GL2/topoRender.hpp index b8007736..891e347f 100644 --- a/include/Algo/Render/GL2/topoRender.hpp +++ b/include/Algo/Render/GL2/topoRender.hpp @@ -432,11 +432,11 @@ void TopoRender::setBoundaryShift(float bs) } template -void TopoRender::updateDataBoundary(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf,float ns) +void TopoRender::updateDataBoundary(MAP& map, const VertexAttribute& positions, float ke, float kf,float ns) { m_normalShift = ns; - SelectorDartBoundary sdb(map); - DartContainerBrowserSelector browser(map, sdb); + SelectorDartBoundary sdb(map); + DartContainerBrowserSelector browser(map, sdb); browser.enable(); updateData(map, positions, ke, kf, true); browser.disable(); @@ -444,7 +444,7 @@ void TopoRender::updateDataBoundary(typename PFP::MAP& map, const VertexAtt } template -void TopoRender::updateData(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, bool withBoundary) +void TopoRender::updateData(MAP& map, const VertexAttribute& positions, float ke, float kf, bool withBoundary) { if (map.mapTypeName()[0] == "M") // "Map2" { @@ -459,16 +459,10 @@ void TopoRender::updateData(typename PFP::MAP& map, const VertexAttribute -void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribute& positions, float ke, float kf, bool withBoundary) +void TopoRender::updateDataMap(MAP& mapx, const VertexAttribute& positions, float ke, float kf, bool withBoundary) { //Map2& map = reinterpret_cast(mapx); - typedef typename PFP::MAP MAP; - typedef typename PFP::VEC3 VEC3; - typedef typename PFP::REAL REAL; - - typedef Geom::Vec3f VEC3F; - std::vector vecDarts; vecDarts.reserve(mapx.getNbDarts()); // no problem dart is int: no problem of memory @@ -485,16 +479,16 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribu m_nbDarts = vecDarts.size(); // debut phi1 - DartAutoAttribute fv1(mapx); + DartAutoAttribute fv1(mapx); // fin phi1 - DartAutoAttribute fv11(mapx); + DartAutoAttribute fv11(mapx); // phi2 - DartAutoAttribute fv2(mapx); + DartAutoAttribute fv2(mapx); m_vbo3->bind(); glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3F), 0, GL_STREAM_DRAW); GLvoid* ColorDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - VEC3F* colorDartBuf = reinterpret_cast(ColorDartsBuffer); + Geom::Vec3f* colorDartBuf = reinterpret_cast(ColorDartsBuffer); // m_vbo0->bind(); // glBufferData(GL_ARRAY_BUFFER, 2*m_nbDarts*sizeof(VEC3), 0, GL_STREAM_DRAW); @@ -504,7 +498,7 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribu if (m_bufferDartPosition!=NULL) delete m_bufferDartPosition; m_bufferDartPosition = new Geom::Vec3f[2*m_nbDarts]; - VEC3F* positionDartBuf = reinterpret_cast(m_bufferDartPosition); + Geom::Vec3f* positionDartBuf = reinterpret_cast(m_bufferDartPosition); std::vector vecPos; vecPos.reserve(16); @@ -567,7 +561,6 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribu } else if (withBoundary) { - Dart dd = d; do { @@ -658,16 +651,10 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const VertexAttribu } template -void TopoRender::updateDataGMap(typename PFP::MAP& map, const VertexAttribute& positions, float ke, float kf, bool withBoundary) +void TopoRender::updateDataGMap(MAP& map, const VertexAttribute& positions, float ke, float kf, bool withBoundary) { // GMap2& map = dynamic_cast(mapx); - typedef typename PFP::MAP MAP; - typedef typename PFP::VEC3 VEC3; - typedef typename PFP::REAL REAL; - - typedef Geom::Vec3f VEC3F; - std::vector vecDarts; vecDarts.reserve(map.getNbDarts()); // no problem dart is int: no problem of memory @@ -686,21 +673,21 @@ void TopoRender::updateDataGMap(typename PFP::MAP& map, const VertexAttribu m_nbDarts = vecDarts.size(); // debut phi1 - DartAutoAttribute fv1(map); + DartAutoAttribute fv1(map); // fin phi1 - DartAutoAttribute fv11(map); + DartAutoAttribute fv11(map); // phi2 - DartAutoAttribute fv2(map); + DartAutoAttribute fv2(map); m_vbo3->bind(); glBufferData(GL_ARRAY_BUFFER, 4*m_nbDarts*sizeof(VEC3F), 0, GL_STREAM_DRAW); GLvoid* ColorDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - VEC3F* colorDartBuf = reinterpret_cast(ColorDartsBuffer); + Geom::Vec3f* colorDartBuf = reinterpret_cast(ColorDartsBuffer); m_vbo0->bind(); glBufferData(GL_ARRAY_BUFFER, 4*m_nbDarts*sizeof(VEC3F), 0, GL_STREAM_DRAW); GLvoid* PositionDartsBuffer = glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); - VEC3F* positionDartBuf = reinterpret_cast(PositionDartsBuffer); + Geom::Vec3f* positionDartBuf = reinterpret_cast(PositionDartsBuffer); std::vector vecPos; vecPos.reserve(16); @@ -819,7 +806,7 @@ void TopoRender::updateDataGMap(typename PFP::MAP& map, const VertexAttribu } template -void TopoRender::setDartsIdColor(typename PFP::MAP& map, bool withBoundary) +void TopoRender::setDartsIdColor(MAP& map, bool withBoundary) { m_vbo3->bind(); float* colorBuffer = reinterpret_cast(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE)); @@ -862,7 +849,7 @@ void TopoRender::setDartsIdColor(typename PFP::MAP& map, bool withBoundary) } template -Dart TopoRender::picking(typename PFP::MAP& map,int x, int y, bool withBoundary) +Dart TopoRender::picking(MAP& map,int x, int y, bool withBoundary) { pushColors(); setDartsIdColor(map,withBoundary); @@ -873,7 +860,7 @@ Dart TopoRender::picking(typename PFP::MAP& map,int x, int y, bool withBoun } template -Dart TopoRender::coneSelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle) +Dart TopoRender::coneSelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float angle) { float AB2 = rayAB*rayAB; Dart dFinal; @@ -903,7 +890,7 @@ Dart TopoRender::coneSelection(typename PFP::MAP& map, const Geom::Vec3f& r } template -Dart TopoRender::raySelection(typename PFP::MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float dmax) +Dart TopoRender::raySelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float dmax) { float AB2 = rayAB*rayAB; Dart dFinal; diff --git a/include/Algo/Render/SVG/mapSVGRender.h b/include/Algo/Render/SVG/mapSVGRender.h index 0d7c781a..f87a74cb 100644 --- a/include/Algo/Render/SVG/mapSVGRender.h +++ b/include/Algo/Render/SVG/mapSVGRender.h @@ -49,28 +49,28 @@ namespace SVG * @warning no depth ordering */ template -void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, unsigned int thread=0); +void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, unsigned int thread = 0); /** * render colored vertices in a SVGOut * @warning no depth ordering */ template -void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, const VertexAttribute& color, unsigned int thread=0); +void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, const VertexAttribute& color, unsigned int thread = 0); /** * render edges in a SVGOut * @warning no depth ordering */ template -void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, unsigned int thread=0); +void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, unsigned int thread = 0); /** * render colored edges in a SVGOut * @warning no depth ordering */ template -void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, const VertexAttribute& color, unsigned int thread=0); +void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, const VertexAttribute& color, unsigned int thread = 0); } // namespace SVG diff --git a/include/Algo/Render/SVG/mapSVGRender.hpp b/include/Algo/Render/SVG/mapSVGRender.hpp index 8692837a..7be9f747 100644 --- a/include/Algo/Render/SVG/mapSVGRender.hpp +++ b/include/Algo/Render/SVG/mapSVGRender.hpp @@ -35,7 +35,7 @@ namespace SVG { template -void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, unsigned int /*thread*/) +void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, unsigned int /*thread*/) { Utils::SVG::SvgGroup* svg1 = new Utils::SVG::SvgGroup("vertices", svg.m_model, svg.m_proj); TraversorV trac(map); @@ -47,7 +47,7 @@ void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const Verte } template -void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, const VertexAttribute& color, unsigned int thread) +void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, const VertexAttribute& color, unsigned int thread) { Utils::SVG::SvgGroup* svg1 = new Utils::SVG::SvgGroup("vertices", svg.m_model, svg.m_proj); TraversorV trac(map); @@ -59,7 +59,7 @@ void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const Verte } template -void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, unsigned int /*thread*/) +void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, unsigned int /*thread*/) { Utils::SVG::SvgGroup* svg1 = new Utils::SVG::SvgGroup("edges", svg.m_model, svg.m_proj); TraversorE trac(map); @@ -71,7 +71,7 @@ void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAt } template -void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, const VertexAttribute& color, unsigned int thread) +void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute& position, const VertexAttribute& color, unsigned int thread) { Utils::SVG::SvgGroup* svg1 = new Utils::SVG::SvgGroup("edges", svg.m_model, svg.m_proj); TraversorE trac(map); diff --git a/include/Algo/Tiling/Surface/hexagonal.h b/include/Algo/Tiling/Surface/hexagonal.h index 5d0bd9f2..f617deae 100644 --- a/include/Algo/Tiling/Surface/hexagonal.h +++ b/include/Algo/Tiling/Surface/hexagonal.h @@ -48,19 +48,20 @@ template class Grid : public Tiling { typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; public: Grid(MAP& map, unsigned int x, unsigned int y, bool close): - Tiling(map,x,y,-1) + Tiling(map, x, y, -1) { - grid(x,y,close); + grid(x, y, close); } Grid(MAP& map, unsigned int x, unsigned int y): - Tiling(map,x,y,-1) + Tiling(map, x, y, -1) { - grid(x,y,true); + grid(x, y, true); } /*! @name Embedding Operators @@ -74,7 +75,7 @@ public: * @param x size in Y * @param y position in Z (centered on 0 by default) */ - void embedIntoGrid(VertexAttribute& position, float x, float y, float z = 0.0f); + void embedIntoGrid(VertexAttribute& position, float x, float y, float z = 0.0f); //! Embed a topological grid into a twister open ribbon with turns=PI it is a Moebius strip, needs only to be closed (if model allow it) /*! @param position Attribute used to store vertices positions @@ -82,7 +83,7 @@ public: * @param radius_max * @param turns number of turn multiplied by 2*PI */ - void embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns); + void embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns); //! Embed a topological grid into a helicoid /*! @param position Attribute used to store vertices positions @@ -91,7 +92,7 @@ public: * @param maxHeight height to reach * @param turns number of turn */ - void embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1); + void embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1); //@} protected: @@ -110,7 +111,6 @@ protected: }; - } // namespace Hexagonal } // namespace Tilings diff --git a/include/Algo/Tiling/Surface/hexagonal.hpp b/include/Algo/Tiling/Surface/hexagonal.hpp index 00698f96..58b63f76 100644 --- a/include/Algo/Tiling/Surface/hexagonal.hpp +++ b/include/Algo/Tiling/Surface/hexagonal.hpp @@ -98,7 +98,7 @@ void Grid::grid(unsigned int x, unsigned int y, bool close) } template -void Grid::embedIntoGrid(VertexAttribute& position, float x, float y, float z) +void Grid::embedIntoGrid(VertexAttribute& position, float x, float y, float z) { float dx = x / float(this->m_nx); float dy = y / float(this->m_ny); diff --git a/include/Algo/Tiling/Surface/square.h b/include/Algo/Tiling/Surface/square.h index ee0c33c9..72cbfadc 100644 --- a/include/Algo/Tiling/Surface/square.h +++ b/include/Algo/Tiling/Surface/square.h @@ -49,19 +49,20 @@ template class Grid : public Tiling { typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; public: Grid(MAP& map, unsigned int x, unsigned int y, bool close): - Tiling(map,x,y,-1) + Tiling(map, x, y, -1) { - grid(x,y,close); + grid(x, y, close); } Grid(MAP& map, unsigned int x, unsigned int y): - Tiling(map,x,y,-1) + Tiling(map, x, y, -1) { - grid(x,y,true); + grid(x, y, true); } /*! @name Embedding Operators @@ -75,7 +76,7 @@ public: * @param x size in Y * @param y position in Z (centered on 0 by default) */ - void embedIntoGrid(VertexAttribute& position, float x, float y, float z = 0.0f); + void embedIntoGrid(VertexAttribute& position, float x, float y, float z = 0.0f); //! Embed a topological grid into a twister open ribbon with turns=PI it is a Moebius strip, needs only to be closed (if model allow it) /*! @param position Attribute used to store vertices positions @@ -83,7 +84,7 @@ public: * @param radius_max * @param turns number of turn multiplied by 2*PI */ - void embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns); + void embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns); //! Embed a topological grid into a helicoid /*! @param position Attribute used to store vertices positions @@ -92,7 +93,7 @@ public: * @param maxHeight height to reach * @param turns number of turn */ - void embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1); + void embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1); //@} protected: @@ -117,6 +118,7 @@ template class Cylinder : public Tiling { typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; private: @@ -156,21 +158,21 @@ public: * @param top_radius * @param height */ - void embedIntoCylinder(VertexAttribute& position, float bottom_radius, float top_radius, float height); + void embedIntoCylinder(VertexAttribute& position, float bottom_radius, float top_radius, float height); //! Embed a topological sphere /*! @param position Attribute used to store vertices positions * @param radius * @param height */ - void embedIntoSphere(VertexAttribute& position, float radius); + void embedIntoSphere(VertexAttribute& position, float radius); //! Embed a topological cone /*! @param position Attribute used to store vertices positions * @param radius * @param height */ - void embedIntoCone(VertexAttribute& position, float radius, float height); + void embedIntoCone(VertexAttribute& position, float radius, float height); //@} /*! @name Topological Operators @@ -208,13 +210,14 @@ template class Cube : public Cylinder { typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; public: Cube(MAP& map, unsigned int x, unsigned int y, unsigned int z): - Cylinder(map,2*(x+y),z, false, false) + Cylinder(map, 2*(x+y), z, false, false) { - cube(x,y,z); + cube(x, y, z); } /*! @name Embedding Operators @@ -228,7 +231,7 @@ public: * @param y * @param z */ - void embedIntoCube(VertexAttribute& position, float x, float y, float z); + void embedIntoCube(VertexAttribute& position, float x, float y, float z); //@} protected: @@ -253,6 +256,7 @@ template class Tore : public Cylinder { typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; public: @@ -272,7 +276,7 @@ public: * @param big_radius * @param small_radius */ - void embedIntoTore(VertexAttribute& position, float big_radius, float small_radius); + void embedIntoTore(VertexAttribute& position, float big_radius, float small_radius); //@} /*! @name Topological Operators diff --git a/include/Algo/Tiling/Surface/square.hpp b/include/Algo/Tiling/Surface/square.hpp index 35e1572f..18cf3539 100644 --- a/include/Algo/Tiling/Surface/square.hpp +++ b/include/Algo/Tiling/Surface/square.hpp @@ -102,7 +102,7 @@ void Grid::grid(unsigned int x, unsigned int y, bool close) } template -void Grid::embedIntoGrid(VertexAttribute& position, float x, float y, float z) +void Grid::embedIntoGrid(VertexAttribute& position, float x, float y, float z) { float dx = x / float(this->m_nx); float dy = y / float(this->m_ny); @@ -117,7 +117,7 @@ void Grid::embedIntoGrid(VertexAttribute& position, float x, float y, } template -void Grid::embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns) +void Grid::embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns) { float alpha = float(2.0*M_PI/this->m_ny); float beta = turns/float(this->m_ny); @@ -138,7 +138,7 @@ void Grid::embedIntoTwistedStrip(VertexAttribute& position, float rad } template -void Grid::embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient) +void Grid::embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient) { float alpha = float(2.0*M_PI/this->m_nx)*nbTurn; float hS = maxHeight/this->m_nx; @@ -292,7 +292,7 @@ void Cylinder::triangleBottom() } template -void Cylinder::embedIntoCylinder(VertexAttribute& position, float bottom_radius, float top_radius, float height) +void Cylinder::embedIntoCylinder(VertexAttribute& position, float bottom_radius, float top_radius, float height) { float alpha = float(2.0*M_PI/this->m_nx); float dz = height/float(this->m_nz); @@ -326,7 +326,7 @@ void Cylinder::embedIntoCylinder(VertexAttribute& position, float bot } template -void Cylinder::embedIntoSphere(VertexAttribute& position, float radius) +void Cylinder::embedIntoSphere(VertexAttribute& position, float radius) { float alpha = float(2.0*M_PI/this->m_nx); float beta = float(M_PI/(this->m_nz+2)); @@ -361,7 +361,7 @@ void Cylinder::embedIntoSphere(VertexAttribute& position, float radiu } template -void Cylinder::embedIntoCone(VertexAttribute& position, float radius, float height) +void Cylinder::embedIntoCone(VertexAttribute& position, float radius, float height) { if(m_top_closed && m_top_triangulated) { @@ -491,7 +491,7 @@ void Cube::cube(unsigned int x, unsigned int y, unsigned int z) } template -void Cube::embedIntoCube(VertexAttribute& position, float sx, float sy, float sz) +void Cube::embedIntoCube(VertexAttribute& position, float sx, float sy, float sz) { float dz = sz/float(this->m_nz); float dy = sy/float(this->m_ny); @@ -571,7 +571,7 @@ void Tore::tore(unsigned int n, unsigned int m) } template -void Tore::embedIntoTore(VertexAttribute& position, float big_radius, float small_radius) +void Tore::embedIntoTore(VertexAttribute& position, float big_radius, float small_radius) { float alpha = float(2.0*M_PI/this->m_nx); float beta = float(2.0*M_PI/this->m_ny); diff --git a/include/Algo/Tiling/Surface/triangular.h b/include/Algo/Tiling/Surface/triangular.h index 0f77d3d3..6eaeea39 100644 --- a/include/Algo/Tiling/Surface/triangular.h +++ b/include/Algo/Tiling/Surface/triangular.h @@ -49,19 +49,20 @@ template class Grid : public Tiling { typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; public: Grid(MAP& map, unsigned int x, unsigned int y, bool close): - Tiling(map,x,y,-1) + Tiling(map, x, y, -1) { - grid(x,y,close); + grid(x, y, close); } Grid(MAP& map, unsigned int x, unsigned int y): - Tiling(map,x,y,-1) + Tiling(map, x, y, -1) { - grid(x,y,true); + grid(x, y, true); } /*! @name Embedding Operators @@ -75,7 +76,7 @@ public: * @param x size in Y * @param y position in Z (centered on 0 by default) */ - void embedIntoGrid(VertexAttribute& position, float x, float y, float z = 0.0f); + void embedIntoGrid(VertexAttribute& position, float x, float y, float z = 0.0f); //! Embed a topological grid into a twister open ribbon with turns=PI it is a Moebius strip, needs only to be closed (if model allow it) /*! @param position Attribute used to store vertices positions @@ -83,7 +84,7 @@ public: * @param radius_max * @param turns number of turn multiplied by 2*PI */ - void embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns); + void embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns); //! Embed a topological grid into a helicoid /*! @param position Attribute used to store vertices positions @@ -92,7 +93,7 @@ public: * @param maxHeight height to reach * @param turns number of turn */ - void embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1); + void embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1); //@} protected: diff --git a/include/Algo/Tiling/Surface/triangular.hpp b/include/Algo/Tiling/Surface/triangular.hpp index d12f2077..54110c2b 100644 --- a/include/Algo/Tiling/Surface/triangular.hpp +++ b/include/Algo/Tiling/Surface/triangular.hpp @@ -97,7 +97,7 @@ void Grid::grid(unsigned int x, unsigned int y, bool close) } template -void Grid::embedIntoGrid(VertexAttribute& position, float x, float y, float z) +void Grid::embedIntoGrid(VertexAttribute& position, float x, float y, float z) { float dx = x / float(this->m_nx); float dy = y / float(this->m_ny); diff --git a/include/Algo/Tiling/Volume/cubic.h b/include/Algo/Tiling/Volume/cubic.h index 3dbd7ba5..6413b061 100644 --- a/include/Algo/Tiling/Volume/cubic.h +++ b/include/Algo/Tiling/Volume/cubic.h @@ -49,16 +49,16 @@ template class Grid : public Algo::Surface::Tilings::Tiling { typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; public: Grid(MAP& map, unsigned int x, unsigned int y, unsigned int z): - Algo::Surface::Tilings::Tiling(map,x,y,z) + Algo::Surface::Tilings::Tiling(map, x, y, z) { - grid3D(x,y,z); + grid3D(x, y, z); } - /*! @name Embedding Operators * Tiling creation *************************************************************************/ @@ -70,7 +70,7 @@ public: * @param x size in Y * @param y position in Z (centered on 0 by default) */ - void embedIntoGrid(VertexAttribute& position, float x, float y, float z); + void embedIntoGrid(VertexAttribute& position, float x, float y, float z); //! Embed a topological grid into a twister open ribbon with turns=PI it is a Moebius strip, needs only to be closed (if model allow it) /*! @param position Attribute used to store vertices positions @@ -78,7 +78,7 @@ public: * @param radius_max * @param turns number of turn multiplied by 2*PI */ - void embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns); + void embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns); //! Embed a topological grid into a helicoid /*! @param position Attribute used to store vertices positions @@ -87,7 +87,7 @@ public: * @param maxHeight height to reach * @param turns number of turn */ - void embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1); + void embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1); //@} protected: @@ -114,13 +114,8 @@ protected: */ Dart grid1D(unsigned int x); //@} - }; - - - - } // namespace Cubic } // namespace Tilings diff --git a/include/Algo/Tiling/Volume/cubic.hpp b/include/Algo/Tiling/Volume/cubic.hpp index e2a4c50d..acb5c44f 100644 --- a/include/Algo/Tiling/Volume/cubic.hpp +++ b/include/Algo/Tiling/Volume/cubic.hpp @@ -158,7 +158,7 @@ Dart Grid::grid1D(unsigned int x) } template -void Grid::embedIntoGrid(VertexAttribute& position, float x, float y, float z) +void Grid::embedIntoGrid(VertexAttribute& position, float x, float y, float z) { float dx = x/float(this->m_nx); float dy = y/float(this->m_ny); @@ -183,7 +183,7 @@ void Grid::embedIntoGrid(VertexAttribute& position, float x, float y, } template -void Grid::embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns) +void Grid::embedIntoTwistedStrip(VertexAttribute& position, float radius_min, float radius_max, float turns) { float alpha = float(2.0*M_PI/this->m_ny); float beta = turns/float(this->m_ny); @@ -204,7 +204,7 @@ void Grid::embedIntoTwistedStrip(VertexAttribute& position, float rad } template -void Grid::embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient) +void Grid::embedIntoHelicoid(VertexAttribute& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient) { float alpha = float(2.0*M_PI/this->m_nx)*nbTurn; float hS = maxHeight/this->m_nx; @@ -234,8 +234,6 @@ void Grid::embedIntoHelicoid(VertexAttribute& position, float radius_ } } - - } // namespace Cubic } // namespace Tilings diff --git a/include/Algo/Tiling/tiling.h b/include/Algo/Tiling/tiling.h index 3ed688d1..4404ac8e 100644 --- a/include/Algo/Tiling/tiling.h +++ b/include/Algo/Tiling/tiling.h @@ -46,6 +46,7 @@ template class Tiling { typedef typename PFP::MAP MAP; + typedef typename PFP::MAP::IMPL MAP_IMPL; typedef typename PFP::VEC3 VEC3; protected: @@ -73,12 +74,12 @@ public: Tiling(MAP& map, unsigned int x, unsigned int y, unsigned int z): m_map(map), m_nx(x), m_ny(y), m_nz(z) - { } + {} Tiling(MAP& map) : m_map(map), m_nx(-1), m_ny(-1), m_nz(-1) - { } + {} Tiling(const Tiling& t1, const Tiling t2); @@ -87,20 +88,19 @@ public: */ std::vector& getVertexDarts() { return m_tableVertDarts; } - void computeCenter(VertexAttribute& position); + void computeCenter(VertexAttribute& position); //void Polyhedron::transform(float* matrice) - void transform(VertexAttribute& position, const Geom::Matrix44f& matrice); + void transform(VertexAttribute& position, const Geom::Matrix44f& matrice); - void mark(CellMarker& m); + void mark(CellMarker& m); /* - * get the reference dart - */ + * get the reference dart + */ Dart getDart() { return m_dart; } - bool exportPositions(const VertexAttribute& position, const char* filename); - + bool exportPositions(const VertexAttribute& position, const char* filename); // /** // * mark all embedded vertices of the Polyhedron @@ -113,7 +113,6 @@ public: // * @param d a dart of the vertex to test // */ // bool containVertex(Dart d); - }; } // namespace Tilings diff --git a/include/Algo/Tiling/tiling.hpp b/include/Algo/Tiling/tiling.hpp index 008da921..c3a22495 100644 --- a/include/Algo/Tiling/tiling.hpp +++ b/include/Algo/Tiling/tiling.hpp @@ -14,12 +14,12 @@ namespace Tilings template Tiling::Tiling(const Tiling& t1, const Tiling t2): m_map(t1.m_map), - m_nx(-1), m_ny(-1), m_nz(-1) + m_nx(-1), + m_ny(-1), + m_nz(-1) { - if (&(t1.m_map) != &(t2.m_map)) - { - CGoGNerr << "Warning, can not merge to Polyhedrons of different maps"<< CGoGNendl; - } + if (&(t1.m_map) != &(t2.m_map)) + CGoGNerr << "Warning, can not merge to Polyhedrons of different maps" << CGoGNendl; m_tableVertDarts.reserve(t1.m_tableVertDarts.size() + t2.m_tableVertDarts.size()); // can be too much but ... @@ -57,7 +57,7 @@ Tiling::Tiling(const Tiling& t1, const Tiling t2): } template -void Tiling::computeCenter(VertexAttribute& position) +void Tiling::computeCenter(VertexAttribute& position) { typename PFP::VEC3 center(0); @@ -72,7 +72,7 @@ void Tiling::computeCenter(VertexAttribute& position) template //void Tiling::transform(float* matrice) -void Tiling::transform(VertexAttribute& position, const Geom::Matrix44f& matrice) +void Tiling::transform(VertexAttribute& position, const Geom::Matrix44f& matrice) { // Geom::Vec4f v1(matrice[0],matrice[4],matrice[8], matrice[12]); // Geom::Vec4f v2(matrice[1],matrice[5],matrice[9], matrice[13]); @@ -98,16 +98,14 @@ void Tiling::transform(VertexAttribute& position, const Geom::Matrix4 } template -void Tiling::mark(CellMarker& m) +void Tiling::mark(CellMarker& m) { for(typename std::vector::iterator di = m_tableVertDarts.begin(); di != m_tableVertDarts.end(); ++di) - { m.mark(*di); - } } template -bool Tiling::exportPositions(const VertexAttribute& position, const char* filename) +bool Tiling::exportPositions(const VertexAttribute& position, const char* filename) { // open file std::ofstream out ; @@ -129,7 +127,6 @@ bool Tiling::exportPositions(const VertexAttribute& pos } - } // namespace Tilings } // namespace Surface diff --git a/include/Topology/generic/autoAttributeHandler.h b/include/Topology/generic/autoAttributeHandler.h index 314aff2d..9f335268 100644 --- a/include/Topology/generic/autoAttributeHandler.h +++ b/include/Topology/generic/autoAttributeHandler.h @@ -33,7 +33,7 @@ namespace CGoGN /** * shortcut class for Dart AutoAttribute (Handler) */ -template +template class DartAutoAttribute : public DartAttribute { public: @@ -58,7 +58,7 @@ public: /** * shortcut class for Vertex AutoAttribute (Handler) */ -template +template class VertexAutoAttribute : public VertexAttribute { public: @@ -83,7 +83,7 @@ public: /** * shortcut class for Edge AutoAttribute (Handler) */ -template +template class EdgeAutoAttribute : public EdgeAttribute { public: @@ -108,7 +108,7 @@ public: /** * shortcut class for Face AutoAttribute (Handler) */ -template +template class FaceAutoAttribute : public FaceAttribute { public: @@ -133,7 +133,7 @@ public: /** * shortcut class for Volume AutoAttribute (Handler) */ -template +template class VolumeAutoAttribute : public VolumeAttribute { public: diff --git a/include/Topology/generic/dartmarker.h b/include/Topology/generic/dartmarker.h index 1b2f96ed..73848f7e 100644 --- a/include/Topology/generic/dartmarker.h +++ b/include/Topology/generic/dartmarker.h @@ -180,7 +180,7 @@ public: { assert(m_map.template getMarkerSet(m_thread).testMark(m_mark)); FunctorUnmark fm(m_map, m_mark, m_markVector) ; - m_map.foreach_dart_of_orbit(d, fm, m_thread) ; + m_map.template foreach_dart_of_orbit(d, fm, m_thread) ; } /** @@ -335,7 +335,7 @@ protected: public: inline void unmarkAll() { - assert(this->m_map.getMarkerSet(this->m_thread).testMark(this->m_mark)); + assert(this->m_map.template getMarkerSet(this->m_thread).testMark(this->m_mark)); AttributeContainer& cont = this->m_map.template getAttributeContainer() ; for (unsigned int i = cont.realBegin(); i != cont.realEnd(); cont.realNext(i)) this->m_markVector->operator[](i).unsetMark(this->m_mark) ; diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h index 84e56bb8..8fbfeac6 100644 --- a/include/Topology/generic/genericmap.h +++ b/include/Topology/generic/genericmap.h @@ -147,7 +147,7 @@ protected: /** * Erase a dart of the map */ - virtual void deleteDart(Dart d) ; + virtual void deleteDart(Dart d) = 0; /** * create a copy of a dart (based on its index in m_attribs[DART]) and returns its index @@ -377,9 +377,9 @@ public: protected: /** - * update topo relation after compacting the container: + * compact topo relations */ - virtual void compactTopoRelations(const std::vector& oldnew) = 0 ; + virtual void compactTopo() = 0 ; public: /** @@ -397,9 +397,9 @@ public: */ bool foreach_dart(FunctorType& f) ; - virtual Dart begin() const; - virtual Dart end() const; - virtual void next(Dart& d) const; + virtual Dart begin() const = 0; + virtual Dart end() const = 0; + virtual void next(Dart& d) const = 0; //! Apply a functor on every dart of an orbit /*! @param dim dimension of orbit diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index 179c338a..1ee9b43f 100644 --- a/include/Topology/generic/genericmap.hpp +++ b/include/Topology/generic/genericmap.hpp @@ -297,9 +297,6 @@ inline void GenericMap::disableQuickAdjacentTraversal() } } - - - /**************************************** * ATTRIBUTES MANAGEMENT * ****************************************/ diff --git a/include/Topology/generic/mapMono.h b/include/Topology/generic/mapMono.h index 98f26f89..f6a3b0ce 100644 --- a/include/Topology/generic/mapMono.h +++ b/include/Topology/generic/mapMono.h @@ -94,7 +94,7 @@ protected: template inline void permutationUnsew(Dart d); - inline virtual void compactTopoRelations(const std::vector& oldnew); + inline virtual void compactTopo(); /**************************************** * DARTS TRAVERSALS * diff --git a/include/Topology/generic/mapMono.hpp b/include/Topology/generic/mapMono.hpp index 0811ffbc..9adb4d45 100644 --- a/include/Topology/generic/mapMono.hpp +++ b/include/Topology/generic/mapMono.hpp @@ -146,8 +146,11 @@ inline void MapMono::permutationUnsew(Dart d) (*m_permutation_inv[I])[e.index] = e ; } -inline void MapMono::compactTopoRelations(const std::vector& oldnew) +inline void MapMono::compactTopo() { + std::vector oldnew; + m_attribs[DART].compact(oldnew); + for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i)) { for (unsigned int j = 0; j < m_permutation.size(); ++j) diff --git a/include/Topology/generic/mapMulti.h b/include/Topology/generic/mapMulti.h index 61f81356..cd8e2fd7 100644 --- a/include/Topology/generic/mapMulti.h +++ b/include/Topology/generic/mapMulti.h @@ -162,7 +162,7 @@ protected: template inline void permutationUnsew(Dart d); - inline virtual void compactTopoRelations(const std::vector& oldnew); + inline virtual void compactTopo(); /**************************************** * MR CONTAINER MANAGEMENT * diff --git a/include/Topology/generic/mapMulti.hpp b/include/Topology/generic/mapMulti.hpp index 26ee7cb4..39220291 100644 --- a/include/Topology/generic/mapMulti.hpp +++ b/include/Topology/generic/mapMulti.hpp @@ -268,27 +268,44 @@ inline void MapMulti::permutationUnsew(Dart d) (*m_permutation_inv[I])[e_index] = e ; } -inline void MapMulti::compactTopoRelations(const std::vector& oldnew) +inline void MapMulti::compactTopo() { + std::vector oldnewMR; + m_mrattribs.compact(oldnewMR); + + std::vector oldnew; + m_attribs[DART].compact(oldnew); + + unsigned int nbl = m_mrDarts.size(); + for (unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i)) + { + for (unsigned int level = 0; level < nbl; ++level) + { + unsigned int& d = m_mrDarts[level]->operator[](i); + if (d != oldnew[d]) + d = oldnew[d]; + } + } + for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i)) { for (unsigned int j = 0; j < m_permutation.size(); ++j) { Dart d = (*m_permutation[j])[i]; - if (d.index != oldnew[d.index]) - (*m_permutation[j])[i] = Dart(oldnew[d.index]); + if (d.index != oldnewMR[d.index]) + (*m_permutation[j])[i] = Dart(oldnewMR[d.index]); } for (unsigned int j = 0; j < m_permutation_inv.size(); ++j) { Dart d = (*m_permutation_inv[j])[i]; - if (d.index != oldnew[d.index]) - (*m_permutation_inv[j])[i] = Dart(oldnew[d.index]); + if (d.index != oldnewMR[d.index]) + (*m_permutation_inv[j])[i] = Dart(oldnewMR[d.index]); } for (unsigned int j = 0; j < m_involution.size(); ++j) { Dart d = (*m_involution[j])[i]; - if (d.index != oldnew[d.index]) - (*m_involution[j])[i] = Dart(oldnew[d.index]); + if (d.index != oldnewMR[d.index]) + (*m_involution[j])[i] = Dart(oldnewMR[d.index]); } } } diff --git a/include/Topology/gmap/gmap3.hpp b/include/Topology/gmap/gmap3.hpp index de3768be..163efced 100644 --- a/include/Topology/gmap/gmap3.hpp +++ b/include/Topology/gmap/gmap3.hpp @@ -130,8 +130,8 @@ inline Dart GMap3::phi(Dart d) const } switch(N%10) { - case 1 : return phi1(phi(d)) ; - case 2 : return phi2(phi(d)) ; + case 1 : return this->phi1(phi(d)) ; + case 2 : return this->phi2(phi(d)) ; case 3 : return phi3(phi(d)) ; default : assert(!"Wrong multi-phi relation value") ; return d ; } diff --git a/include/Topology/map/map2.hpp b/include/Topology/map/map2.hpp index abfc7341..06ecd6b3 100644 --- a/include/Topology/map/map2.hpp +++ b/include/Topology/map/map2.hpp @@ -95,7 +95,7 @@ inline Dart Map2::phi(Dart d) const } switch(N%10) { - case 1 : return phi1(phi(d)) ; + case 1 : return this->phi1(phi(d)) ; case 2 : return phi2(phi(d)) ; default : assert(!"Wrong multi-phi relation value") ; return d ; } diff --git a/include/Topology/map/map3.hpp b/include/Topology/map/map3.hpp index cce7e6b1..307aeb59 100644 --- a/include/Topology/map/map3.hpp +++ b/include/Topology/map/map3.hpp @@ -98,8 +98,8 @@ inline Dart Map3::phi(Dart d) const } switch(N%10) { - case 1 : return phi1(phi(d)) ; - case 2 : return phi2(phi(d)) ; + case 1 : return this->phi1(phi(d)) ; + case 2 : return this->phi2(phi(d)) ; case 3 : return phi3(phi(d)) ; default : assert(!"Wrong multi-phi relation value") ; return d ; } diff --git a/src/Topology/generic/genericmap.cpp b/src/Topology/generic/genericmap.cpp index ac019f7d..4b5efb3a 100644 --- a/src/Topology/generic/genericmap.cpp +++ b/src/Topology/generic/genericmap.cpp @@ -454,28 +454,6 @@ void GenericMap::dumpAttributesAndMarkers() void GenericMap::compact() { - // if MR compact the MR attrib container - std::vector oldnewMR; - if (m_isMultiRes) - m_mrattribs.compact(oldnewMR); - - // compacting the orbits attributes -// for (unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit) -// { -// if ((orbit != DART) && (isOrbitEmbedded(orbit))) -// { -// m_attribs[orbit].compact(oldnew); -// -// for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i)) -// { -// unsigned int& idx = m_embeddings[orbit]->operator [](i); -// unsigned int jdx = oldnew[idx]; -// if ((jdx != 0xffffffff) && (jdx != idx)) -// idx = jdx; -// } -// } -// } - // compact embedding attribs std::vector< std::vector* > oldnews; oldnews.resize(NB_ORBITS); @@ -508,29 +486,8 @@ void GenericMap::compact() if ((orbit != DART) && (isOrbitEmbedded(orbit))) delete[] oldnews[orbit]; - //compacting the topo - std::vector oldnew; - m_attribs[DART].compact(oldnew); - - // update MR indices to attribs[DART] - if (m_isMultiRes) - { - unsigned int nbl = m_mrDarts.size(); - for (unsigned int i = m_mrattribs.begin(); i != m_mrattribs.end(); m_mrattribs.next(i)) - { - for (unsigned int j=0; joperator[](i); - if (d_index != oldnew[d_index]) - m_mrDarts[j]->operator[](i) = oldnew[d_index]; - } - } - } - - // update topo relations from real map - compactTopoRelations(oldnewMR); - -// dumpAttributesAndMarkers(); + // compact topo (depends on map implementation) + compactTopo(); } /**************************************** -- GitLab