Commit 96ca248e authored by Sylvain Thery's avatar Sylvain Thery

add updateDataGen template version

parent f04f4224
......@@ -322,6 +322,12 @@ void computeCentroidELWVolumes(typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3>& position, VolumeAttribute<typename PFP::VEC3>& vol_centroid,
unsigned int nbth = 0) ;
template <typename PFP, typename EMBV, typename EMB>
void computeCentroidELWVolumesGen(typename PFP::MAP& map,
const EMBV& position, VolumeAttribute<typename PFP::VEC3>& vol_centroid,
unsigned int nbth = 0) ;
template <typename PFP>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
......
......@@ -347,6 +347,35 @@ void computeCentroidELWVolumes(typename PFP::MAP& map,
}
template <typename PFP, typename EMBV, typename EMB>
class FunctorComputeCentroidELWVolumesGen: public FunctorMapThreaded<typename PFP::MAP >
{
const EMBV& m_position;
VolumeAttribute<typename PFP::VEC3>& m_vol_centroid;
public:
FunctorComputeCentroidELWVolumesGen<PFP,EMBV,EMB>( typename PFP::MAP& map, const EMBV& position, VolumeAttribute<typename PFP::VEC3>& vol_centroid):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_vol_centroid(vol_centroid)
{ }
void run(Dart d, unsigned int threadID)
{
m_vol_centroid[d] = Surface::Geometry::volumeCentroidELWGen<PFP,EMBV,EMB>(this->m_map, d, m_position,threadID) ;
}
};
template <typename PFP, typename EMBV, typename EMB>
void computeCentroidELWVolumesGen(typename PFP::MAP& map,
const EMBV& position, VolumeAttribute<typename PFP::VEC3>& vol_centroid,
unsigned int nbth = 0)
{
FunctorComputeCentroidELWVolumesGen<PFP,EMBV,EMB> funct(map,position,vol_centroid);
Algo::Parallel::foreach_cell<typename PFP::MAP,VOLUME>(map, funct, nbth, true);
}
template <typename PFP>
class FunctorComputeNeighborhoodCentroidVertices: public FunctorMapThreaded<typename PFP::MAP >
{
......
......@@ -275,6 +275,9 @@ public:
* @param kf exploding coef for face
* @param kv exploding coef for face
*/
template<typename PFP, typename EMBV, typename EMB>
void updateDataGen(typename PFP::MAP& map, const EMBV& positions, float ke, float kf, float kv);
template<typename PFP>
void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv);
......@@ -283,8 +286,12 @@ public:
* @param map the map
* @param colors attribute of dart's colors
*/
template<typename PFP, typename EMBV, typename EMB>
void updateColorsGen(typename PFP::MAP& map, const EMBV& colors);
template<typename PFP>
void updateColors(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& colors);
void updateColors(typename PFP::MAP& map, const VertexAttribute<Geom::Vec3f>& colors);
/**
* Get back middle position of drawn darts
......@@ -320,8 +327,8 @@ protected:
* @param kf exploding coef for face
* @param kv exploding coef for face
*/
template<typename PFP>
void updateDataMap3(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv);
template<typename PFP, typename EMBV, typename EMB>
void updateDataMap3(typename PFP::MAP& map, const EMBV& positions, float ke, float kf, float kv);
/**
* update all drawing buffers to render a gmap
......@@ -331,8 +338,8 @@ protected:
* @param kf exploding coef for face
* @param kv exploding coef for face
*/
template<typename PFP>
void updateDataGMap3(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv);
template<typename PFP, typename EMBV, typename EMB>
void updateDataGMap3(typename PFP::MAP& map, const EMBV& positions, float ke, float kf, float kv);
};
......
......@@ -52,19 +52,38 @@ void Topo3Render::updateData(typename PFP::MAP& map, const VertexAttribute<typen
Map3* ptrMap3 = dynamic_cast<Map3*>(&map);
if (ptrMap3 != NULL)
{
updateDataMap3<PFP>(map,positions,ke,kf,kv);
updateDataMap3<PFP, VertexAttribute<typename PFP::VEC3>, typename PFP::VEC3 >(map,positions,ke,kf,kv);
}
GMap3* ptrGMap3 = dynamic_cast<GMap3*>(&map);
if (ptrGMap3 != NULL)
{
updateDataGMap3<PFP>(map,positions,ke,kf,kv);
updateDataGMap3<PFP, VertexAttribute<typename PFP::VEC3>, typename PFP::VEC3>(map,positions,ke,kf,kv);
}
}
template<typename PFP>
void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv)
template<typename PFP, typename EMBV, typename EMB>
void Topo3Render::updateDataGen(typename PFP::MAP& map, const EMBV& positions, float ke, float kf, float kv)
{
Map3* ptrMap3 = dynamic_cast<Map3*>(&map);
if (ptrMap3 != NULL)
{
updateDataMap3<PFP,EMBV,EMB>(map,positions,ke,kf,kv);
}
GMap3* ptrGMap3 = dynamic_cast<GMap3*>(&map);
if (ptrGMap3 != NULL)
{
updateDataGMap3<PFP,EMBV,EMB>(map,positions,ke,kf,kv);
}
}
template<typename PFP, typename EMBV, typename EMB>
void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const EMBV& positions, float ke, float kf, float kv)
{
typedef typename PFP::VEC3 VEC3;
typedef EMB VEC3;
typedef typename PFP::REAL REAL;
m_attIndex = mapx.template getAttribute<unsigned int, DART>("dart_index");
......@@ -264,11 +283,11 @@ void Topo3Render::setDartsIdColor(typename PFP::MAP& map)
glUnmapBuffer(GL_ARRAY_BUFFER);
}
template<typename PFP>
void Topo3Render::updateColors(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& colors)
template<typename PFP, typename EMBV, typename EMB>
void Topo3Render::updateColorsGen(typename PFP::MAP& map, const EMBV& colors)
{
m_vbo4->bind();
Geom::Vec3f* colorBuffer = reinterpret_cast<Geom::Vec3f*>(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE));
EMB* colorBuffer = reinterpret_cast<EMB*>(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE));
unsigned int nb=0;
for (Dart d = map.begin(); d != map.end(); map.next(d))
......@@ -290,6 +309,12 @@ void Topo3Render::updateColors(typename PFP::MAP& map, const VertexAttribute<typ
glUnmapBuffer(GL_ARRAY_BUFFER);
}
template<typename PFP>
void Topo3Render::updateColors(typename PFP::MAP& map, const VertexAttribute<Geom::Vec3f>& colors)
{
updateColorsGen<PFP, Geom::Vec3f, VertexAttribute<Geom::Vec3f> >(map,colors);
}
template<typename PFP>
Dart Topo3Render::picking(typename PFP::MAP& map, int x, int y)
{
......@@ -300,17 +325,14 @@ Dart Topo3Render::picking(typename PFP::MAP& map, int x, int y)
return d;
}
template<typename PFP>
void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv)
template<typename PFP, typename EMBV, typename EMB>
void Topo3Render::updateDataGMap3(typename PFP::MAP& mapx, const EMBV& positions, float ke, float kf, float kv)
{
typedef typename PFP::VEC3 VEC3;
typedef EMB VEC3;
typedef typename PFP::REAL REAL;
GMap3& map = dynamic_cast<GMap3&>(mapx); // TODO reflechir comment virer ce warning quand on compile avec PFP::MAP=Map3
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
if (m_attIndex.map() != &mapx)
m_attIndex = mapx.template getAttribute<unsigned int, DART>("dart_index");
if (!m_attIndex.isValid())
......
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