Commit 5e2f8327 authored by Etienne Schmitt's avatar Etienne Schmitt

improvements

Signed-off-by: Etienne Schmitt's avatarÉtienne Schmitt <etienne.schmitt@inria.fr>
parent 289da2a2
......@@ -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 ;
......
......@@ -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<PFPSurface> mapOperator;
VertexAttribute<VEC3, SurfaceMap> positionSurface ; //position
VertexAttribute<int, SurfaceMap> indexParticule; // index des particules de chaque sommet
FaceAttribute<VEC3,SurfaceMap> faceColor;
FaceAttribute<int, SurfaceMap> indexTriangle;
unsigned int nbVertices;
unsigned int nbTriangles;
......@@ -80,16 +122,6 @@ public:
std::vector<Particule*> parts_ ;
std::vector<Triangle *> triangles_;
SURFACE surfaceMap; // map
CGoGN::Algo::MR::Primal::Adaptive::IHM2<PFPSurface> mapOperator;
VertexAttribute<VEC3, SURFACE> positionSurface ; //position
VertexAttribute<int, SURFACE> indexParticule; // index des particules de chaque sommet
FaceAttribute<int, SURFACE> indexTriangle;
FaceAttribute<VEC3,SURFACE> 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
};
......
......@@ -434,16 +434,16 @@ void EnvMap::FirstRegistrationTriangle(Triangle * o)// réenregistre l'Triangle
Dart cell =o->cell;
std::vector<Dart> memo;
for(Edge e : edgesIncidentToFace2<SURFACE>(mo->surfaceMap,cell)) // first mark inside
for(Edge e : edgesIncidentToFace2<SurfaceMap>(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)
{
......
......@@ -16,13 +16,13 @@ Surface::Surface(Simulator* sim,VEC3 offset):
distanceColorationMini=2.0f;
surfaceMap.initImplicitProperties();
positionSurface = surfaceMap.addAttribute<VEC3, VERTEX, SURFACE>("positionSurface");
positionSurface = surfaceMap.addAttribute<VEC3, VERTEX, SurfaceMap>("positionSurface");
initOperators(LERP);
initPlane();
indexParticule = surfaceMap.addAttribute<int, VERTEX, SURFACE>("indexParticule");
indexTriangle= surfaceMap.addAttribute<int, FACE, SURFACE>("indexTriangle");
faceColor=surfaceMap.addAttribute<VEC3, FACE, SURFACE>("faceColor");
indexParticule = surfaceMap.addAttribute<int, VERTEX, SurfaceMap>("indexParticule");
indexTriangle= surfaceMap.addAttribute<int, FACE, SurfaceMap>("indexTriangle");
faceColor=surfaceMap.addAttribute<VEC3, FACE, SurfaceMap>("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<SURFACE> tv(surfaceMap);
TraversorV<SurfaceMap> 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<SURFACE> tF2(surfaceMap);
TraversorE<SurfaceMap> 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<SURFACE> tE(surfaceMap);
TraversorF<SurfaceMap> 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<SURFACE> tv(surfaceMap);
TraversorV<SurfaceMap> tv(surfaceMap);
for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next())
{
positionSurface[d]*=4;
......@@ -153,7 +153,7 @@ void Surface::initPlane()
TraversorF<SURFACE> tF(surfaceMap);
TraversorF<SurfaceMap> 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<Dart> toCheck;
TraversorF<SURFACE> tF(surfaceMap);
TraversorF<SurfaceMap> 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<PFPSurface,VertexAttribute<VEC3,SURFACE>>(surfaceMap,face,positionSurface);
VEC3 center = Algo::Surface::Geometry::faceCentroid<PFPSurface,VertexAttribute<VEC3,SurfaceMap>>(surfaceMap,face,positionSurface);
REAL res = (positionSurface[d]-center).norm2();
for ( Vertex vert : verticesIncidentToFace2(surfaceMap,face))
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment