Commit 192f8eaf authored by untereiner's avatar untereiner

Begin Implicit vertex attributes in ihm3

parent 4887cf73
......@@ -162,6 +162,11 @@ public:
void deleteVertexSubdividedFace(Dart d);
//@}
void setVertexVertexFunctor(FunctorType* f) { vertexVertexFunctor = f ; }
void setEdgeVertexFunctor(FunctorType* f) { edgeVertexFunctor = f ; }
void setFaceVertexFunctor(FunctorType* f) { faceVertexFunctor = f ; }
void setVolumeVertexFunctor(FunctorType* f) { volumeVertexFunctor = f ; }
void computeVertexVertexFunctor(Dart d) { (*vertexVertexFunctor)(d); }
void computeEdgeVertexFunctor(Dart d) { (*edgeVertexFunctor)(d); }
void computeFaceVertexFunctor(Dart d) { (*faceVertexFunctor)(d); }
......@@ -373,7 +378,8 @@ public:
virtual bool foreach_dart_of_face2(Dart d, FunctorType& f, unsigned int thread = 0);
//@}
template <unsigned int ORBIT>
unsigned int getEmbedding(Dart d);
} ;
template <typename T, unsigned int ORBIT>
......@@ -398,9 +404,9 @@ public:
return AttributeHandler<T, ORBIT>::isValid() ;
}
T& operator[](Dart d) ;
virtual T& operator[](Dart d) ;
const T& operator[](Dart d) const ;
virtual const T& operator[](Dart d) const ;
T& operator[](unsigned int a)
{
......@@ -411,6 +417,7 @@ public:
{
return AttributeHandler<T, ORBIT>::operator[](a) ;
}
} ;
template <typename T>
......
......@@ -601,6 +601,25 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d)
return r;
}
template <unsigned int ORBIT>
inline unsigned int ImplicitHierarchicalMap3::getEmbedding(Dart d)
{
unsigned int nbSteps = m_curLevel - vertexInsertionLevel(d);
unsigned int index = EmbeddedMap3::getEmbedding<ORBIT>(d);
unsigned int step = 0;
while(step < nbSteps)
{
step++;
unsigned int next = m_nextLevelCell[ORBIT]->operator[](index);
index = next;
//if(next != EMBNULL) index = next;
//else break;
}
return index;
}
/***************************************************
* ATTRIBUTE HANDLER *
......@@ -613,14 +632,20 @@ T& AttributeHandler_IHM<T, ORBIT>::operator[](Dart d)
assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ;
assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ;
unsigned int orbit = this->getOrbit() ;
std::cout << std::endl << "vertexInsertionLevel[" << d <<"] = " << m->vertexInsertionLevel(d) << "\t";
unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
unsigned int index = m->getEmbedding<ORBIT>(d) ;
unsigned int index = m->EmbeddedMap3::getEmbedding<ORBIT>(d) ;
// std::cout << " m->vertexInsertionLevel(d) = " << m->vertexInsertionLevel(d) << std::endl;
// std::cout << "m_curLevel = " << m->m_curLevel << std::endl;
// std::cout << " nbSteps = " << nbSteps << std::endl;
// std::cout << "index EmbMap3 = " << index << std::endl;
if(index == EMBNULL)
{
index = m->setOrbitEmbeddingOnNewCell<ORBIT>(d) ;
m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ;
m->m_nextLevelCell[ORBIT]->operator[](index) = EMBNULL ;
}
AttributeContainer& cont = m->getAttributeContainer<ORBIT>() ;
......@@ -628,17 +653,24 @@ T& AttributeHandler_IHM<T, ORBIT>::operator[](Dart d)
while(step < nbSteps)
{
step++ ;
unsigned int nextIdx = m->m_nextLevelCell[orbit]->operator[](index) ;
unsigned int nextIdx = m->m_nextLevelCell[ORBIT]->operator[](index) ;
if (nextIdx == EMBNULL)
{
nextIdx = m->newCell<ORBIT>() ;
m->copyCell<ORBIT>(nextIdx, index) ;
m->m_nextLevelCell[orbit]->operator[](index) = nextIdx ;
m->m_nextLevelCell[orbit]->operator[](nextIdx) = EMBNULL ;
m->m_nextLevelCell[ORBIT]->operator[](index) = nextIdx ;
m->m_nextLevelCell[ORBIT]->operator[](nextIdx) = EMBNULL ;
cont.refLine(index) ;
}
index = nextIdx ;
}
std::cout << "emb = " << index << std::endl;
// std::cout << "index IHM = " << index << std::endl;
// if(index != EMBNULL)
// std::cout << " emb = " << this->m_attrib->operator[](index) << std::endl << std::endl;
return this->m_attrib->operator[](index);
}
......@@ -649,21 +681,30 @@ const T& AttributeHandler_IHM<T, ORBIT>::operator[](Dart d) const
assert(m->m_dartLevel[d] <= m->m_curLevel || !"Access to a dart introduced after current level") ;
assert(m->vertexInsertionLevel(d) <= m->m_curLevel || !"Access to the embedding of a vertex inserted after current level") ;
unsigned int orbit = this->getOrbit() ;
unsigned int nbSteps = m->m_curLevel - m->vertexInsertionLevel(d) ;
unsigned int index = m->getEmbedding<ORBIT>(d) ;
unsigned int index = m->EmbeddedMap3::getEmbedding<ORBIT>(d) ;
// std::cout << "(const) m->vertexInsertionLevel(d) = " << m->vertexInsertionLevel(d) << std::endl;
// std::cout << "(const) m_curLevel = " << m->m_curLevel << std::endl;
// std::cout << "(const) nbSteps = " << nbSteps << std::endl;
// std::cout << "(const) index EmbMap3 = " << index << std::endl;
unsigned int step = 0 ;
while(step < nbSteps)
{
step++ ;
unsigned int next = m->m_nextLevelCell[orbit]->operator[](index) ;
if(next != EMBNULL) index = next ;
unsigned int nextIdx = m->m_nextLevelCell[ORBIT]->operator[](index) ;
if(nextIdx != EMBNULL) index = nextIdx ;
else break ;
}
// if(index != EMBNULL)
// std::cout << "(const) emb = " << this->m_attrib->operator[](index) << std::endl << std::endl;
return this->m_attrib->operator[](index);
}
} //namespace IHM
} // Volume
} //namespace Algo
......
......@@ -65,8 +65,8 @@ void subdivideEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
map.setFaceId(EDGE, d) ; //mise a jour de l'id de face sur chaque brin de chaque moitie d'arete
map.setFaceId(EDGE, dd) ;
position[map.phi1(d)] = (p1 + p2) * typename PFP::REAL(0.5) ;
//map.computeEdgeVertexFunctor(map.phi1(d));
// position[map.phi1(d)] = (p1 + p2) * typename PFP::REAL(0.5) ;
map.computeEdgeVertexFunctor(map.phi1(d));
map.setCurrentLevel(cur) ;
}
......@@ -121,8 +121,8 @@ void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
Dart dd = map.phi1(old) ;
Dart e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ; // insert a new edge
//unsigned int id = map.getNewEdgeId() ;
//map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id
unsigned int id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id
unsigned int idface = map.getFaceId(old);
map.setFaceId(dd, idface, FACE) ;
......@@ -131,8 +131,8 @@ void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
dd = e ;
e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ;
//id = map.getNewEdgeId() ;
//map.setEdgeId(map.phi_1(dd), id, EDGE) ;
id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ;
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
......@@ -140,8 +140,8 @@ void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
dd = e ;
e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ;
//id = map.getNewEdgeId() ;
//map.setEdgeId(map.phi_1(dd), id, EDGE) ;
id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ;
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
......@@ -202,8 +202,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
id = map.getNewEdgeId() ;
map.setEdgeId(ne2, id, EDGE) ;
position[map.phi1(ne)] = p ;
//map.computeFaceVertexFunctor(map.phi1(ne));
//position[map.phi1(ne)] = p ;
dd = map.phi1(map.phi1(map.phi1(map.phi1(ne)))) ;
while(dd != ne)
......@@ -227,6 +226,9 @@ void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
dd = map.phi2(map.phi1(dd));
}
while(dd != ne);
map.computeFaceVertexFunctor(map.phi1(ne));
//position[map.phi1(ne)] = p ;
}
map.setCurrentLevel(cur) ;
......@@ -353,14 +355,14 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typ
//Second step : deconnect each corner, close each hole, subdivide each new face into 3
for (std::vector<Dart>::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge)
{
Dart e = *edge;
std::vector<Dart> v ;
do
{
v.push_back(map.phi1(map.phi1(e)));
v.push_back(map.phi1(e));
v.push_back(map.phi1(map.phi1(e)));
e = map.phi2(map.phi_1(e));
}
......@@ -378,7 +380,7 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typ
Dart ne = map.phi1(map.phi1(old)) ;
map.cutEdge(ne);
position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ????
//position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ????
centralDart = map.phi1(ne);
newEdges.push_back(ne);
newEdges.push_back(map.phi1(ne));
......@@ -403,12 +405,11 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typ
}
while(dd != stop);
//map.computeVertexVertexFunctor(e);
}
map.deleteVolume(map.phi3(map.phi2(map.phi1(oldEdges.front()))));
//map.computerVolumeVertexFunctor(oldEdges.front());
//Third step : 3-sew internal faces
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
{
......@@ -445,6 +446,20 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typ
}
}
// std::cout << map.getCurrentLevel() << std::endl;
// //Second step : deconnect each corner, close each hole, subdivide each new face into 3
for (std::vector<Dart>::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge)
{
Dart e = *edge;
//std::cout << "emb ? " << map.template getEmbedding<VERTEX>(e) << std::endl;
//if(map.template getEmbedding<VERTEX>(e) == EMBNULL)
map.computeVertexVertexFunctor(e);
//std::cout << "emb = " << map.template getEmbedding<VERTEX>(e) << " / dartlevel = " << map.getDartLevel(e) << std::endl;
}
std::cout << std::endl;
map.computerVolumeVertexFunctor(centralDart);
map.setCurrentLevel(cur) ;
return centralDart; //subdividedfaces.begin()->first;
......
......@@ -41,7 +41,7 @@ namespace MovingObjects
template <typename PFP>
class ParticleBase
{
private:
protected:
typename PFP::VEC3 m_position ;
unsigned int m_state ;
......
#ifndef PARTCELL_H
#define PARTCELL_H
#include "particle_base.h"
#include "Algo/MovingObjects/particle_base.h"
#include "Algo/Geometry/inclusion.h"
#include "Geometry/intersection.h"
......@@ -31,12 +31,12 @@ enum {
};
template <typename PFP>
class ParticleCell3D : public Algo::MovingObjects::ParticleBase
class ParticleCell3D : public Algo::MovingObjects::ParticleBase<PFP>
{
public :
typedef typename PFP::MAP Map;
typedef typename PFP::VEC3 VEC3;
typedef VertexAttribute<typename PFP::VEC3> TAB_POS;
typedef VertexAttribute<VEC3> TAB_POS;
Map& m;
......@@ -55,7 +55,11 @@ public :
{}
ParticleCell3D(Map& map, Dart belonging_cell, VEC3 pos, const TAB_POS& tabPos) :
Algo::MovingObjects::ParticleBase(pos), m(map), position(tabPos), d(belonging_cell), state(3)
Algo::MovingObjects::ParticleBase<PFP>(pos),
m(map),
position(tabPos),
d(belonging_cell),
state(3)
{
m_positionFace = pointInFace(d);
}
......@@ -107,7 +111,7 @@ public :
{
crossCell = NO_CROSS ;
if(!Geom::arePointsEquals(newCurrent, m_position))
if(!Geom::arePointsEquals(newCurrent, this->getPosition()))
{
switch(state) {
case VERTEX : vertexState(newCurrent); break;
......@@ -121,10 +125,10 @@ public :
}
};
}
}
}
}
} //MovingObjects
} //Volume
} //Algo
} //CGoGN
#include "particle_cell_3D.hpp"
......
......@@ -63,9 +63,17 @@ public:
{
m_map.decCurrentLevel() ;
typename PFP::VEC3 p = m_position[d] ;
// std::cout << " p du niv i-1 = " << p << std::endl;
m_map.incCurrentLevel() ;
m_position[d] = p ;
// std::cout << " p du niv i+1 = " << p << std::endl;
m_position[d] = p;
// m_map.decCurrentLevel() ;
// std::cout << "dec = " << m_position[d] << std::endl;
// m_map.incCurrentLevel();
// std::cout << "inc = " << m_position[d] << std::endl << std::endl;
return false ;
}
......
......@@ -45,7 +45,7 @@ namespace Adaptive
template <typename PFP>
Map3MR<PFP>::Map3MR(typename PFP::MAP& map) :
m_map(map),
shareVertexEmbeddings(true),
shareVertexEmbeddings(false),
vertexVertexFunctor(NULL),
edgeVertexFunctor(NULL),
faceVertexFunctor(NULL),
......@@ -461,6 +461,20 @@ void Map3MR<PFP>::subdivideEdge(Dart d)
m_map.incCurrentLevel();
if(!shareVertexEmbeddings)
{
// if(m_map.template getEmbedding<VERTEX>(d) == EMBNULL)
// {
// std::cout << "plop" << std::endl;
m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(d) ;
// }
// if(m_map.template getEmbedding<VERTEX>(m_map.phi1(d)) == EMBNULL)
// {
// std::cout << "plop2" << std::endl;
m_map.template setOrbitEmbeddingOnNewCell<VERTEX>(d) ;
// }
}
Dart nd = cutEdge(d);
(*edgeVertexFunctor)(nd) ;
......@@ -896,6 +910,14 @@ unsigned int Map3MR<PFP>::subdivideHexa(Dart d, bool OneLevelDifference)
if(m_map.getCurrentLevel() == m_map.getMaxLevel())
m_map.addLevelBack() ;
// std::vector<Dart> vertices;
// Traversor3WV<typename PFP::MAP> traWV(m_map, d);
// for(Dart ditWV = traWV.begin(); ditWV != traWV.end(); ditWV = traWV.next())
// {
// vertices.push_back(ditWV);
// std::cout << "back" << std::endl;
// }
//
// Subdivide Faces and Edges
//
......@@ -910,10 +932,16 @@ unsigned int Map3MR<PFP>::subdivideHexa(Dart d, bool OneLevelDifference)
std::vector<std::pair<Dart, Dart> > subdividedFaces;
subdividedFaces.reserve(128);
Dart centralDart = NIL;
// for(std::vector<Dart>::iterator it = vertices.begin() ; it != vertices.end() ; ++it)
// {
// Dart ditWV = *it;
Traversor3WV<typename PFP::MAP> traWV(m_map, d);
for(Dart ditWV = traWV.begin(); ditWV != traWV.end(); ditWV = traWV.next())
{
m_map.incCurrentLevel() ;
(*vertexVertexFunctor)(ditWV) ;
Dart e = ditWV;
......@@ -954,8 +982,6 @@ unsigned int Map3MR<PFP>::subdivideHexa(Dart d, bool OneLevelDifference)
}
m_map.decCurrentLevel() ;
}
m_map.incCurrentLevel();
......@@ -975,6 +1001,25 @@ unsigned int Map3MR<PFP>::subdivideHexa(Dart d, bool OneLevelDifference)
(*volumeVertexFunctor)(centralDart) ;
{
m_map.decCurrentLevel() ;
Traversor3WV<typename PFP::MAP> traWV(m_map, d);
for(Dart ditWV = traWV.begin(); ditWV != traWV.end(); ditWV = traWV.next())
{
std::cout << "plop" << std::endl;
}
m_map.incCurrentLevel();
}
m_map.popLevel() ;
return vLevel;
......
......@@ -72,15 +72,14 @@ void ImplicitHierarchicalMap3::clear(bool removeAttrib)
void ImplicitHierarchicalMap3::initImplicitProperties()
{
//initEdgeId() ;
//initFaceId();
for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
{
m_edgeId[d] = 0;
m_faceId[d] = 0;
}
initEdgeId() ;
initFaceId();
// for(Dart d = Map3::begin(); d != Map3::end(); Map3::next(d))
// {
// m_edgeId[d] = 0;
// m_faceId[d] = 0;
// }
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
......
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