diff --git a/include/pfp.h b/include/pfp.h index 34a9d8ada90e32e66bc66b2a5b8261e553daf5d7..59d6ac22979645847d4fed07bb07ec290049f089 100644 --- a/include/pfp.h +++ b/include/pfp.h @@ -61,7 +61,7 @@ struct PFPSurface : public PFP_STANDARD } ; -typedef PFPSurface::MAP SURFACE; +typedef PFPSurface::MAP SurfaceMap; typedef PFP::MAP MAP; typedef PFP::VEC3 VEC3 ; typedef PFP::REAL REAL ; diff --git a/include/surface.h b/include/surface.h index 45211bff2e6829fe69d22fc5766467b1da3dfedc..004d5563ed6810fd46d23dc7e77ca9e7abe167f7 100644 --- a/include/surface.h +++ b/include/surface.h @@ -25,9 +25,10 @@ class Surface { public: Surface(Simulator* sim, VEC3 offset) ; + ~Surface(); - inline const VEC3& getPosition(int index) const + inline const VEC3& getParticlePosition(int index) const { return getParticule(index)->getPosition(); } @@ -42,6 +43,44 @@ public: return parts_[index]; } + inline int getIndexOfParticuleAtVertex(Dart d) const + { + return indexParticule[d]; + } + + inline const VEC3& getFaceColor(Dart d) const + { + return faceColor[d]; + } + + + inline const VEC3& getSurfacePosition(Dart d) const + { + return positionSurface[d]; + } + + void changeColor(Triangle *t, float distance); + + + inline int getIndexOfTriangle(Dart d) const + { + return indexTriangle[d]; + } + + inline const SurfaceMap& getSurfaceMap() const + { + return surfaceMap; + } + + Utils::ShaderColorPerVertex * getShader() + { + return m_shader; + } + + Utils::ShaderSimpleColor * getSimpleColorShader() + { + return m_simpleColorShader; + } void initPlane(); //initialisation d'une grille REAL faceMaxdistance(Face face); //calcul du rayon max d'une face @@ -64,15 +103,18 @@ public: Simulator* sim_; unsigned int index_surface; - - float r; // indice de couleur rouge - float g; // indice de couleur vert - float b; // indice de couleur bleu - float distanceColorationMini; // distance minimale pour commencer a virer rouge - float distanceColorationMaxi; // distance a partir de laquelle on est completement rouge - + // visualisation + void initGL(); // initialisation GL + void draw(); // redessiner l'objet +private: + SurfaceMap surfaceMap; // map + CGoGN::Algo::MR::Primal::Adaptive::IHM2 mapOperator; + VertexAttribute positionSurface ; //position + VertexAttribute indexParticule; // index des particules de chaque sommet + FaceAttribute faceColor; + FaceAttribute indexTriangle; unsigned int nbVertices; unsigned int nbTriangles; @@ -80,16 +122,6 @@ public: std::vector parts_ ; std::vector triangles_; - SURFACE surfaceMap; // map - CGoGN::Algo::MR::Primal::Adaptive::IHM2 mapOperator; - VertexAttribute positionSurface ; //position - VertexAttribute indexParticule; // index des particules de chaque sommet - FaceAttribute indexTriangle; - FaceAttribute faceColor; - // visualisation - void initGL(); // initialisation GL - void draw(); // redessiner l'objet - void changeColor(Triangle *t, float distance); Algo::Render::GL2::MapRender* m_render_map; // render de l'objet Algo::Render::GL2::ColorPerFaceRender * m_render; Utils::VBO* m_positionVBO; //VBO @@ -97,6 +129,12 @@ public: Utils::ShaderSimpleColor* m_simpleColorShader; // shader Utils::ShaderColorPerVertex * m_shader; + float r; // indice de couleur rouge + float g; // indice de couleur vert + float b; // indice de couleur bleu + float distanceColorationMini; // distance minimale pour commencer a virer rouge + float distanceColorationMaxi; // distance a partir de laquelle on est completement rouge + }; diff --git a/src/env_map.cpp b/src/env_map.cpp index f4484f8326d8be5ab8b67dd48e14a1d4db4b6661..420e4cdfa71fd919ec7dd164c729a9cdc5337982 100644 --- a/src/env_map.cpp +++ b/src/env_map.cpp @@ -434,16 +434,16 @@ void EnvMap::FirstRegistrationTriangle(Triangle * o)// réenregistre l'Triangle Dart cell =o->cell; std::vector memo; - for(Edge e : edgesIncidentToFace2(mo->surfaceMap,cell)) // first mark inside + for(Edge e : edgesIncidentToFace2(mo->getSurfaceMap(),cell)) // first mark inside { - Dart cell2=mo->surfaceMap.phi1(e); + Dart cell2=mo->getSurfaceMap().phi1(e); // on récupère les aprticules correspondant a chaque edge du triangle a enregistrer - const Particule * p1 = mo->getParticule(mo->indexParticule[cell]); + const Particule * p1 = mo->getParticule(mo->getIndexOfParticuleAtVertex(cell)); Dart d1=p1->getCell(); // darts de la carte 3D contenant les particules - memo = getMemoCross(p1->getPosition(),mo->positionSurface[cell2],d1); + memo = getMemoCross(p1->getPosition(),mo->getSurfacePosition(cell2),d1); for (Dart d : memo) inside.mark(d); @@ -519,8 +519,7 @@ void EnvMap::popTriangle(Triangle* o) { Dart cell =o->cell; - int n = mo->indexTriangle[cell]; - + int n = mo->getIndexOfTriangle(cell); for (Dart d : mo->belonging_cells[n]) @@ -838,11 +837,11 @@ void EnvMap::resetPartSubdiv(Triangle * o) Surface * mo = o->surf; Dart cell =o->cell; - Dart cell2 = mo->surfaceMap.phi1(cell); - Dart cell3 = mo->surfaceMap.phi1(cell2); - Particule * p = mo->getParticule(mo->indexParticule[cell]); - Particule * p2 = mo->getParticule(mo->indexParticule[cell2]); - Particule * p3 = mo->getParticule(mo->indexParticule[cell3]); + Dart cell2 = mo->getSurfaceMap().phi1(cell); + Dart cell3 = mo->getSurfaceMap().phi1(cell2); + Particule * p = mo->getParticule(mo->getIndexOfParticuleAtVertex(cell)); + Particule * p2 = mo->getParticule(mo->getIndexOfParticuleAtVertex(cell2)); + Particule * p3 = mo->getParticule(mo->getIndexOfParticuleAtVertex(cell3)); if (mo != NULL) { diff --git a/src/surface.cpp b/src/surface.cpp index cedf1b9e4f004baf8b07390462213988373f4eef..792c025f4849b889ee01b85f046550160e663d48 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -16,13 +16,13 @@ Surface::Surface(Simulator* sim,VEC3 offset): distanceColorationMini=2.0f; surfaceMap.initImplicitProperties(); - positionSurface = surfaceMap.addAttribute("positionSurface"); + positionSurface = surfaceMap.addAttribute("positionSurface"); initOperators(LERP); initPlane(); - indexParticule = surfaceMap.addAttribute("indexParticule"); - indexTriangle= surfaceMap.addAttribute("indexTriangle"); - faceColor=surfaceMap.addAttribute("faceColor"); + indexParticule = surfaceMap.addAttribute("indexParticule"); + indexTriangle= surfaceMap.addAttribute("indexTriangle"); + faceColor=surfaceMap.addAttribute("faceColor"); index_surface=sim->surfaces.size(); @@ -30,7 +30,7 @@ Surface::Surface(Simulator* sim,VEC3 offset): // initialisation des particules et des attributs de sommet - TraversorV tv(surfaceMap); + TraversorV tv(surfaceMap); for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next()) { positionSurface[d]+=offset; @@ -39,7 +39,7 @@ Surface::Surface(Simulator* sim,VEC3 offset): nbVertices ++; } // initialisation tableaux de vecteurs qui vont stocker les belonging cells - TraversorE tF2(surfaceMap); + TraversorE tF2(surfaceMap); for(Dart d = tF2.begin(), end = tF2.end() ; d != end ; d = tF2.next()) { nbTriangles ++; @@ -49,7 +49,7 @@ Surface::Surface(Simulator* sim,VEC3 offset): // initialisation des segments et des attributs d'edge - TraversorF tE(surfaceMap); + TraversorF tE(surfaceMap); for(Dart d = tE.begin() , end = tE.end(); d != end ; d = tE.next()) { faceColor[d]=VEC3(r,g,b); @@ -143,7 +143,7 @@ void Surface::initPlane() prim.embedIntoGrid(positionSurface,1.0f,1.0f, 0.0f) ; - TraversorV tv(surfaceMap); + TraversorV tv(surfaceMap); for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next()) { positionSurface[d]*=4; @@ -153,7 +153,7 @@ void Surface::initPlane() - TraversorF tF(surfaceMap); + TraversorF tF(surfaceMap); for(Dart d = tF.begin() ; d != tF.end() ; d = tF.next()) { REAL dist = faceMaxdistance(d); @@ -177,7 +177,7 @@ bool Surface::subdiveMap() { bool res = true; std::vector toCheck; - TraversorF tF(surfaceMap); + TraversorF tF(surfaceMap); surfaceMap.setCurrentLevel(surfaceMap.getMaxLevel()) ; for(Dart d = tF.begin() ; d != tF.end() ; d = tF.next()) { @@ -209,7 +209,7 @@ REAL Surface::faceMaxdistance(Face face) { Dart d = face; - VEC3 center = Algo::Surface::Geometry::faceCentroid>(surfaceMap,face,positionSurface); + VEC3 center = Algo::Surface::Geometry::faceCentroid>(surfaceMap,face,positionSurface); REAL res = (positionSurface[d]-center).norm2(); for ( Vertex vert : verticesIncidentToFace2(surfaceMap,face)) diff --git a/src/viewer.cpp b/src/viewer.cpp index f2c5d067b720dbfee7046e4d7d0eddab04f4e117..efa65522c12cb09832b6e057223e7cec861ecd90 100644 --- a/src/viewer.cpp +++ b/src/viewer.cpp @@ -262,8 +262,8 @@ void Volusion::cb_initGL() for(Surface * surf : simul.surfaces) { surf->initGL(); - registerShader(surf->m_shader); - registerShader(surf->m_simpleColorShader); + registerShader(surf->getShader()); + registerShader(surf->getSimpleColorShader()); // for(Triangle * t : surf->triangles_) // { // data[j]=t->closest_point;