Commit 4056172d authored by Sylvain Thery's avatar Sylvain Thery

update explodeVolumeRender

modification topoRender for using dartIndex
parent 9a7fe051
......@@ -78,23 +78,23 @@ public:
* @param good functor that return true for darts of part to draw
* @param type_vbo vbo to alloc ( VBO_P, VBO_PN, VBO_PNC, VBO_PC ..)
*/
ExplodeVolumeRender();
ExplodeVolumeRender() ;
/**
* Destructor
*/
~ExplodeVolumeRender();
~ExplodeVolumeRender() ;
/**
* return a ptr on used shader do not forgot to register
*/
Utils::GLSLShader* shaderFaces() { return m_shader;}
Utils::GLSLShader* shaderFaces() ;
/**
* return a ptr on used shader do not forgot to register
*/
Utils::GLSLShader* shaderLines() { return m_shaderL;}
Utils::GLSLShader* shaderLines() ;
/**
......@@ -104,29 +104,52 @@ public:
* @param good selector
*/
template<typename PFP>
void updateData(typename PFP::MAP& map, typename PFP::TVEC3& positions, const FunctorSelect& good = allDarts);
void updateData(typename PFP::MAP& map, typename PFP::TVEC3& positions, const FunctorSelect& good = allDarts) ;
/**
* draw edges
*/
void drawEdges();
void drawEdges() ;
/**
* draw edges
*/
void drawFaces();
void drawFaces() ;
void setExplodeVolumes(float explode) { m_shader->setExplodeVolumes(explode);m_shaderL->setExplodeVolumes(explode);}
/**
* set exploding volume coefficient parameter
*/
void setExplodeVolumes(float explode) ;
void setClippingPlane(const Geom::Vec4f& p) {m_shader->setClippingPlane(p); m_shaderL->setClippingPlane(p);}
/**
* set clipping plane
*/
void setClippingPlane(const Geom::Vec4f& p) ;
void setNoClippingPlane() { Geom::Vec4f p(0.0f,0.0f,10000.0f,100000000000000000000000000.0f); m_shader->setClippingPlane(p); m_shaderL->setClippingPlane(p);}
/**
* unset clipping plane
*/
void setNoClippingPlane() ;
void setAmbiant(const Geom::Vec4f& ambiant) { m_shader->setAmbiant(ambiant);}
/**
* set ambiant color parameter
*/
void setAmbiant(const Geom::Vec4f& ambiant) ;
void setDiffuse(const Geom::Vec4f& diffuse) { m_shader->setDiffuse(diffuse);}
/**
* set diffuse color parameter
*/
void setDiffuse(const Geom::Vec4f& diffuse) ;
void setLightPosition(const Geom::Vec3f& lp) { m_shader->setLightPosition(lp);}
/**
* set light position parameter
*/
void setLightPosition(const Geom::Vec3f& lp) ;
/**
* set color parameter for edge drawing
*/
void setColorLine(const Geom::Vec4f& col) ;
};
}//end namespace GL2
......
......@@ -83,7 +83,8 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, typename PFP::TVEC3
std::vector<VEC3> buffer;
buffer.reserve(16384);
TraversorOF<typename PFP::MAP> traFace(map,good);
TraversorCell<typename PFP::MAP> traFace(map, PFP::MAP::ORBIT_IN_PARENT(FACE),good);
for (Dart d=traFace.begin(); d!=traFace.end(); d=traFace.next())
{
Dart a = d;
......@@ -115,33 +116,15 @@ void ExplodeVolumeRender::updateData(typename PFP::MAP& map, typename PFP::TVEC3
buffer.clear();
// TraversorE<typename PFP::MAP> traEdge(map,good);
// for (Dart d=traEdge.begin(); d!=traEdge.end(); d=traEdge.next())
// {
// buffer.push_back(centerVolumes[d]);
// buffer.push_back(positions[d]);
// buffer.push_back(positions[ map.phi1(d)]);
// }
// TO A REFAIRE AVEC LE BON TRAVERSOR DE LA BONNE ORBITE QUAND ELLE EXISTERA
DartMarker dm(map);
for (Dart d=map.begin(); d!=map.end(); map.next(d))
{
if (good(d) && !dm.isMarked(d))
TraversorCell<typename PFP::MAP> traEdge(map, PFP::MAP::ORBIT_IN_PARENT(EDGE),good);
for (Dart d=traEdge.begin(); d!=traEdge.end(); d=traEdge.next())
{
buffer.push_back(centerVolumes[d]);
buffer.push_back(positions[d]);
buffer.push_back(positions[ map.phi1(d)]);
dm.mark(d);
dm.mark(map.phi2(d));
}
}
m_nbLines = buffer.size()/3;
m_vboPosLine->allocate(buffer.size());
......@@ -172,6 +155,55 @@ inline void ExplodeVolumeRender::drawEdges()
}
inline void ExplodeVolumeRender::setExplodeVolumes(float explode)
{
m_shader->setExplodeVolumes(explode);
m_shaderL->setExplodeVolumes(explode);
}
inline void ExplodeVolumeRender::setClippingPlane(const Geom::Vec4f& p)
{
m_shader->setClippingPlane(p);
m_shaderL->setClippingPlane(p);
}
inline void ExplodeVolumeRender::setNoClippingPlane()
{
Geom::Vec4f p(1.0f,1.0f,1.0f,-99999999.9f);
m_shader->setClippingPlane(p);
m_shaderL->setClippingPlane(p);
}
inline void ExplodeVolumeRender::setAmbiant(const Geom::Vec4f& ambiant)
{
m_shader->setAmbiant(ambiant);
}
inline void ExplodeVolumeRender::setDiffuse(const Geom::Vec4f& diffuse)
{
m_shader->setDiffuse(diffuse);
}
inline void ExplodeVolumeRender::setLightPosition(const Geom::Vec3f& lp)
{
m_shader->setLightPosition(lp);
}
inline void ExplodeVolumeRender::setColorLine(const Geom::Vec4f& col)
{
m_shaderL->setColor(col);
}
inline Utils::GLSLShader* ExplodeVolumeRender::shaderFaces()
{
return m_shader;
}
inline Utils::GLSLShader* ExplodeVolumeRender::shaderLines()
{
return m_shaderL;
}
}//end namespace VBO
......
......@@ -91,12 +91,14 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV
// compute center of each volumes
CellMarker cmv(map,VOLUME);
AutoAttributeHandler<VEC3> centerVolumes(map,VOLUME,"centerVolumes");
TraversorW<Map3> traVol(map,good);
for (Dart d=traVol.begin(); d!=traVol.end(); d=traVol.next())
{
centerVolumes[d] = Algo::Geometry::volumeCentroid<PFP>(mapx, d, positions);
}
// TraversorW<Map3> traVol(map,good);
// for (Dart d=traVol.begin(); d!=traVol.end(); d=traVol.next())
// {
// centerVolumes[d] = Algo::Geometry::volumeCentroid<PFP>(mapx, d, positions);
// }
Algo::Geometry::computeCentroidVolumes<PFP>(mapx,positions,centerVolumes,good);
// debut phi1
AutoAttributeHandler<VEC3> fv1(map, DART);
......@@ -347,11 +349,12 @@ void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const typename PFP::T
// compute center of each volumes
AutoAttributeHandler<VEC3> centerVolumes(map,VOLUME,"centerVolumes");
TraversorW<GMap3> traVol(map,good);
for (Dart d=traVol.begin(); d!=traVol.end(); d=traVol.next())
{
centerVolumes[d] = Algo::Geometry::volumeCentroid<PFP>(mapx, d, positions);
}
// TraversorW<GMap3> traVol(map,good);
// for (Dart d=traVol.begin(); d!=traVol.end(); d=traVol.next())
// {
// centerVolumes[d] = Algo::Geometry::volumeCentroid<PFP>(mapx, d, positions);
// }
Algo::Geometry::computeCentroidVolumes<PFP>(mapx,positions,centerVolumes,good);
// beta1
......
......@@ -102,7 +102,8 @@ protected:
Dart colToDart(float* color);
void dartToCol(Dart d, float& r, float& g, float& b);
template<typename PFP>
void dartToCol(typename PFP::MAP& map, Dart d, float& r, float& g, float& b);
Dart pickColor(unsigned int x, unsigned int y);
......
......@@ -139,7 +139,7 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const typename PFP::TVEC
m_attIndex[d] = indexDC;
indexDC+=2;
*positionDartBuf++ = P;
*colorDartBuf++ = VEC3(1.,0.,0.);
*colorDartBuf++ = VEC3(1.,1.,1.);
*positionDartBuf++ = Q;
*colorDartBuf++ = VEC3(1.,1.,1.);
VEC3 f = P*0.5f + Q*0.5f;
......@@ -179,7 +179,8 @@ void TopoRender::updateDataMap(typename PFP::MAP& mapx, const typename PFP::TVEC
Dart e = map.phi2(d);
if (good(e) && (e.index > d.index))
// if (good(e) && (e.index > d.index))
if (good(e) && (d < e ))
{
*positionF2++ = fv2[d];
*positionF2++ = fv2[e];
......@@ -340,7 +341,8 @@ void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const typename PFP::TVE
Dart e = map.beta2(d);
if (good(e) && (e.index > d.index))
// if (good(e) && (e.index > d.index))
if (good(e) && (d < e ))
{
*positionF2++ = fv2[d];
*positionF2++ = fv2[e];
......@@ -360,6 +362,19 @@ void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const typename PFP::TVE
}
template<typename PFP>
void TopoRender::dartToCol(typename PFP::MAP& map, Dart d, float& r, float& g, float& b)
{
unsigned int lab = map.dartIndex(d) + 1; // add one to avoid picking the black of screen
r = float(lab%255) / 255.0f; lab = lab/255;
g = float(lab%255) / 255.0f; lab = lab/255;
b = float(lab%255) / 255.0f; lab = lab/255;
if (lab!=0)
CGoGNerr << "Error picking color, too many darts"<< CGoGNendl;
}
template<typename PFP>
void TopoRender::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& good)
......@@ -376,7 +391,7 @@ void TopoRender::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& go
if (nb < m_nbDarts)
{
float r,g,b;
dartToCol(d, r,g,b);
dartToCol<PFP>(map,d, r,g,b);
float* local = colorBuffer+3*m_attIndex[d]; // get the right position in VBO
*local++ = r;
*local++ = g;
......
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