Commit 059d7f9c authored by untereiner's avatar untereiner

adding Attribute template to topo3PrimalRender + changing filters

parent 69cfee5d
......@@ -54,14 +54,44 @@ void subdivideEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position, SubdivideType sType = S_TRI);
template <typename PFP>
Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
template <typename PFP>
void subdivideEdgeWrong(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position) ;
template <typename PFP>
void subdivideFaceWrong(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position, SubdivideType sType = S_TRI);
template <typename PFP>
Dart subdivideVolumeClassicWrong(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
template <typename PFP>
Dart subdivideVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
template <typename PFP>
Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
template <typename PFP>
Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
template <typename PFP>
Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
......
......@@ -246,6 +246,161 @@ public:
template <typename PFP>
class LerpTriOddSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
public:
LerpTriOddSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorW<typename PFP::MAP> travW(m_map) ;
for (Dart d = travW.begin(); d != travW.end(); d = travW.next())
{
if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d))
{
typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
unsigned int count = 0;
typename PFP::VEC3 ec(0.0);
Traversor3WE<typename PFP::MAP> travWE(m_map, d);
for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next())
{
m_map.incCurrentLevel();
ec += m_position[m_map.phi1(dit)];
m_map.decCurrentLevel();
++count;
}
ec /= count;
ec *= 3;
count = 0;
typename PFP::VEC3 fc(0.0);
Traversor3WF<typename PFP::MAP> travWF(m_map, d);
for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next())
{
m_map.incCurrentLevel();
fc += m_position[m_map.phi1(m_map.phi1(dit))];
m_map.decCurrentLevel();
++count;
}
fc /= count;
fc *= 3;
m_map.incCurrentLevel() ;
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d)));
m_position[midV] += vc + ec + fc;
m_map.decCurrentLevel() ;
}
}
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5);
m_map.incCurrentLevel() ;
Dart midE = m_map.phi1(d) ;
m_position[midE] += ve;
m_map.decCurrentLevel() ;
}
}
};
template <typename PFP>
class LerpTriOddAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
public:
LerpTriOddAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5);
m_map.incCurrentLevel() ;
Dart midE = m_map.phi1(d) ;
m_position[midE] -= ve;
m_map.decCurrentLevel() ;
}
TraversorW<typename PFP::MAP> travW(m_map) ;
for (Dart d = travW.begin(); d != travW.end(); d = travW.next())
{
if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d))
{
typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
unsigned int count = 0;
typename PFP::VEC3 ec(0.0);
Traversor3WE<typename PFP::MAP> travWE(m_map, d);
for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next())
{
m_map.incCurrentLevel();
ec += m_position[m_map.phi1(dit)];
m_map.decCurrentLevel();
++count;
}
ec /= count;
ec *= 3;
count = 0;
typename PFP::VEC3 fc(0.0);
Traversor3WF<typename PFP::MAP> travWF(m_map, d);
for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next())
{
m_map.incCurrentLevel();
fc += m_position[m_map.phi1(m_map.phi1(dit))];
m_map.decCurrentLevel();
++count;
}
fc /= count;
fc *= 3;
m_map.incCurrentLevel() ;
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d)));
m_position[midV] -= vc + ec + fc;
m_map.decCurrentLevel() ;
}
}
}
};
/*****************************************************************************************/
......@@ -429,7 +584,8 @@ public:
m_map.incCurrentLevel() ;
Dart midV = m_map.phi_1(m_map.phi2(d));
Dart midV = m_map.phi_1(m_map.phi2(d));
//Dart midV = m_map.phi_1(d);
m_position[midV] = p;
m_map.decCurrentLevel() ;
......
......@@ -160,19 +160,18 @@ void Map3MR<PFP>::addNewLevelSqrt3(bool embedNewVertices)
Algo::Volume::Modelisation::Tetrahedralization::flip1To4<PFP>(m_map, dit);
}
//
// 2-3 swap of all old interior faces
//
TraversorF<typename PFP::MAP> tF(m_map);
for(Dart dit = tF.begin() ; dit != tF.end() ; dit = tF.next())
{
if(m.isMarked(dit))
{
m.unmarkOrbit<FACE>(dit);
Algo::Volume::Modelisation::Tetrahedralization::swap2To3<PFP>(m_map, dit);
}
}
//
// 2-3 swap of all old interior faces
//
TraversorF<typename PFP::MAP> tF(m_map);
for(Dart dit = tF.begin() ; dit != tF.end() ; dit = tF.next())
{
if(m.isMarked(dit))
{
m.unmarkOrbit<FACE>(dit);
Algo::Volume::Modelisation::Tetrahedralization::swap2To3<PFP>(m_map, dit);
}
}
/*
//
......@@ -357,7 +356,7 @@ void Map3MR<PFP>::addNewLevelTetraOcta()
}
m_map.setCurrentLevel(m_map.getMaxLevel() - 1) ;
}
}
}
m_map.popLevel() ;
}
......
......@@ -261,6 +261,9 @@ public:
template<typename PFP>
void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf);
template<typename PFP, typename EMBV, typename EMB>
void updateDataGen(typename PFP::MAP& mapx, const EMBV& positions, float ke, float kf);
/**
* update color buffer with color attribute handler
* @param map the map
......
......@@ -115,13 +115,17 @@ Dart Topo3PrimalRender::picking(typename PFP::MAP& map, int x, int y)
template<typename PFP>
void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf)
{
typedef typename PFP::VEC3 VEC3;
updateDataGen<PFP, VertexAttribute<typename PFP::VEC3>, typename PFP::VEC3>(mapx,positions,ke,kf);
}
template<typename PFP, typename EMBV, typename EMB>
void Topo3PrimalRender::updateDataGen(typename PFP::MAP& mapx, const EMBV& positions, float ke, float kf)
{
typedef EMB VEC3;
typedef typename PFP::REAL REAL;
Map3& map = dynamic_cast<Map3&>(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");
......@@ -161,7 +165,7 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribut
std::vector<VEC3> vecPos;
vecPos.reserve(16);
VEC3 centerFace = Algo::Surface::Geometry::faceCentroidELW<PFP>(mapx,d,positions);
VEC3 centerFace = Algo::Surface::Geometry::faceCentroidELWGen<PFP, EMBV, EMB>(mapx,d,positions);
//shrink the face
float okf = 1.0f - kf;
......@@ -184,8 +188,11 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribut
VEC3 P = vecPos[i]*ke + vecPos[i+1]*oke;
VEC3 Q = vecPos[i+1]*ke + vecPos[i]*oke;
VEC3 PP = 0.52f*P + 0.48f*Q;
VEC3 QQ = 0.52f*Q + 0.48f*P;
// VEC3 PP = 0.52f*P + 0.48f*Q;
// VEC3 QQ = 0.52f*Q + 0.48f*P;
VEC3 PP = 0.56f*P + 0.44f*Q;
VEC3 QQ = 0.56f*Q + 0.44f*P;
*positionDartBuf++ = P;
*positionDartBuf++ = PP;
......
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