Commit c21de25f authored by untereiner's avatar untereiner

Derniere changements

parent 67ac3d0d
......@@ -639,6 +639,11 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
Algo::Export::exportOFF<PFP>(myMap, position, "export.off") ;
break ;
}
case 'n':
{
myMap.saveMapBin("plop");
}
}
}
......
......@@ -437,6 +437,23 @@ int main(int argc, char **argv)
// Algo::Import::importInESS<PFP>(myMap, argv[1], attrNames);
// position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
if(argc == 3)
{
std::cout << argv[2] << std::endl;
std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(myMap, argv[2], attrNames))
{
std::cerr << "could not import " << std::endl ;
return 1 ;
}
position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
// std::cout << argv[2] << std::endl;
// myMap.loadMapXml(argv[2]);
dglobal = myMap.begin();
}
else
{
position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT,"position");
......@@ -446,7 +463,7 @@ int main(int argc, char **argv)
nb = atoi(argv[1]);
dglobal = prim.hexaGrid_topo(nb,nb,nb);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
}
// Geom::Matrix44f mat;
// mat.identity();
......
......@@ -146,8 +146,8 @@ bool exportScenePov(typename PFP::MAP& map, typename PFP::TVEC3& position, const
out << "object {myMesh" << std::endl;
out << "translate <" << translate[0] << "," << translate[1] << "," << translate[2] << ">" << std::endl;
out << "rotate <" << angleX << "," << angleY << "," << angleZ << "> " << std::endl;
out << "texture{ pigment{ color rgb<1.0,1.0,1>} finish { ambient rgb 0.05 brilliance 0.5 } } }" << std::endl;
out << "texture{ pigment{ color rgb<1.0,1.0,1,0.7>} finish { ambient rgb 0.05 brilliance 0.5 } } }" << std::endl;
//rajouter f avec coeff
out.close();
return true;
}
......@@ -158,4 +158,4 @@ bool exportScenePov(typename PFP::MAP& map, typename PFP::TVEC3& position, const
}
#endif
\ No newline at end of file
#endif
......@@ -37,8 +37,11 @@ namespace Algo
namespace IHM
{
template<typename T> class AttributeHandler_IHM ;
class ImplicitHierarchicalMap3 : public EmbeddedMap3<Map3>
{
template<typename T> friend class AttributeHandler_IHM ;
public:
unsigned int m_curLevel ;
......@@ -59,6 +62,17 @@ public:
void init() ;
/***************************************************
* ATTRIBUTES MANAGEMENT *
***************************************************/
template <typename T>
AttributeHandler_IHM<T> addAttribute(unsigned int orbit, const std::string& nameAttr) ;
template <typename T>
AttributeHandler_IHM<T> getAttribute(unsigned int orbit, const std::string& nameAttr) ;
/***************************************************
* MAP TRAVERSAL *
***************************************************/
......@@ -103,6 +117,16 @@ public:
virtual bool foreach_dart_of_cc(Dart d, FunctorType& f) ;
/****************************************************
* EMBEDDED FUNCTIONS *
****************************************************/
// virtual void cutEdge(Dart d);
//
// virtual void splitFace(Dart d, Dart e);
//
// virtual void sewVolumes(Dart d, Dart e);
/***************************************************
* LEVELS MANAGEMENT *
***************************************************/
......@@ -222,6 +246,42 @@ public:
bool volumeIsSubdivided(Dart d);
} ;
template <typename T>
class AttributeHandler_IHM : public AttributeHandler<T>
{
public:
typedef T DATA_TYPE ;
AttributeHandler_IHM() : AttributeHandler<T>()
{}
AttributeHandler_IHM(GenericMap* m, AttributeMultiVector<T>* amv) : AttributeHandler<T>(m, amv)
{}
AttributeMultiVector<T>* getDataVector() const
{
return AttributeHandler<T>::getDataVector() ;
}
bool isValid() const
{
return AttributeHandler<T>::isValid() ;
}
T& operator[](Dart d) ;
const T& operator[](Dart d) const ;
T& operator[](unsigned int a)
{
return AttributeHandler<T>::operator[](a) ;
}
const T& operator[](unsigned int a) const
{
return AttributeHandler<T>::operator[](a) ;
}
} ;
} //namespace IHM
......
......@@ -31,6 +31,38 @@ namespace Algo
namespace IHM
{
/***************************************************
* ATTRIBUTES MANAGEMENT *
***************************************************/
template <typename T>
AttributeHandler_IHM<T> ImplicitHierarchicalMap3::addAttribute(unsigned int orbit, const std::string& nameAttr)
{
bool addNextLevelCell = false ;
if(!isOrbitEmbedded(orbit))
addNextLevelCell = true ;
AttributeHandler<T> h = Map3::addAttribute<T>(orbit, nameAttr) ;
if(addNextLevelCell)
{
AttributeContainer& cellCont = m_attribs[orbit] ;
AttributeMultiVector<unsigned int>* amv = cellCont.addAttribute<unsigned int>("nextLevelCell") ;
m_nextLevelCell[orbit] = amv ;
for(unsigned int i = cellCont.begin(); i < cellCont.end(); cellCont.next(i))
amv->operator[](i) = EMBNULL ;
}
return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
}
template <typename T>
AttributeHandler_IHM<T> ImplicitHierarchicalMap3::getAttribute(unsigned int orbit, const std::string& nameAttr)
{
AttributeHandler<T> h = Map2::getAttribute<T>(orbit, nameAttr) ;
return AttributeHandler_IHM<T>(this, h.getDataVector()) ;
}
/***************************************************
* MAP TRAVERSAL *
***************************************************/
......@@ -51,8 +83,10 @@ inline Dart ImplicitHierarchicalMap3::phi1(Dart d)
unsigned int edgeId = m_edgeId[d] ;
Dart it = d ;
do
{
it = Map3::phi1(it) ;
if(m_dartLevel[it] <= m_curLevel)
finished = true ;
......@@ -60,6 +94,7 @@ inline Dart ImplicitHierarchicalMap3::phi1(Dart d)
{
while(m_edgeId[it] != edgeId)
it = Map3::phi1(phi2bis(it));
}
} while(!finished) ;
......@@ -81,7 +116,7 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d)
{
it = Map3::phi_1(it) ;
while(m_edgeId[it] != edgeId)
it = Map3::phi_1(phi2bis(it)) ;
it = Map3::phi_1(phi2bis(it));
}
} while(!finished) ;
......@@ -92,16 +127,19 @@ inline Dart ImplicitHierarchicalMap3::phi_1(Dart d)
inline Dart ImplicitHierarchicalMap3::phi2bis(Dart d)
{
unsigned int faceId = m_faceId[d];
Dart it = d;
it = Map3::phi2(it) ;
if(m_faceId[it] == faceId)
return it;
else
{
while(m_faceId[it] != faceId)
do
{
it = Map3::phi2(Map3::phi3(it));
}
while(m_faceId[it] != faceId);
return it;
}
......@@ -138,45 +176,45 @@ inline Dart ImplicitHierarchicalMap3::alpha1(Dart d)
inline Dart ImplicitHierarchicalMap3::alpha2(Dart d)
{
// assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//
// Dart e = phi2(d);
// Dart f = phi3(e);
//
// if (f != e)
// return f;
//
// f = d;
// e = phi3(f);
// while (e != f)
// {
// f = phi2(e);
// e = phi3(f);
// }
// return f;
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
Dart e = phi2(d);
Dart f = phi3(e);
if (f != e)
return f;
return Map3::alpha2(d);
f = d;
e = phi3(f);
while (e != f)
{
f = phi2(e);
e = phi3(f);
}
return f;
//return Map3::alpha2(d);
}
inline Dart ImplicitHierarchicalMap3::alpha_2(Dart d)
{
// assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//
// Dart e = phi3(d);
//
// if (e != d)
// return phi2(e);
//
// e = d;
// Dart f = phi2(d);
// while (phi3(f) != f)
// {
// e = phi3(f);
// f = phi2(e);
// }
// return e;
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
Dart e = phi3(d);
if (e != d)
return phi2(e);
e = d;
Dart f = phi2(d);
while (phi3(f) != f)
{
e = phi3(f);
f = phi2(e);
}
return e;
return Map3::alpha_2(d);
//return Map3::alpha_2(d);
}
inline Dart ImplicitHierarchicalMap3::begin()
......@@ -325,6 +363,99 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_cc(Dart d, FunctorType& f)
return foreach_dart_of_oriented_volume(d, f) ;
}
/**************************************************
* EMBEDDED FUNCTIONS *
**************************************************/
//void ImplicitHierarchicalMap3::cutEdge(Dart d)
//{
// Dart dd = phi2(d) ;
// EmbeddedMap3<Map3>::cutEdge(d);
//
// //
// //mise a jour de l'id d'arrete sur chaque moitie d'arete
// //
// unsigned int eId;
//
// //Test si id existe
// if(m_edgeId[d] == EMBNULL)
// {
// eId = getNewEdgeId();
// }
// else
// {
// eId = getEdgeId(d) ;
// }
//
// //tour de la 1ere moitie de l'arete avec modification
// Dart e = d;
// do
// {
// m_edgeId[e] = eId; //cas ou l'arete n'est pas du tout plonge
// m_edgeId[Map3::phi2(e)] = eId;
//
// e = Map3::alpha2(e);
// } while(e != d);
//
//
// e = dd;
// do
// {
// m_edgeId[e] = eId;
// m_edgeId[Map3::phi2(e)] = eId;
//
// e = Map3::alpha2(e);
// } while(e != dd);
//
//
// //
// //mise a jour de l'id de face sur chaque brin de chaque moitie d'arete
// //
//
//}
//
//void ImplicitHierarchicalMap3::splitFace(Dart d, Dart e)
//{
// //
// //Verification que les brins precedents ceux que l'on split n'ont pas le meme id
// //
// if(m_edgeId[d] == m_edgeId[Map3::phi_1(d)])
// {
// unsigned int eId = getNewEdgeId() ;
//
// Dart e = d;
// do
// {
// m_edgeId[e] = eId; //cas ou l'arete n'est pas du tout plonge
// m_edgeId[Map3::phi2(e)] = eId;
//
// e = Map3::alpha2(e);
// } while(e != d);
// }
//
// EmbeddedMap3<Map3>::splitFace(d,e);
//
// //
// //creation d'un id d'arete sur la nouvelle arete
// //
//
// unsigned int eId = getNewEdgeId() ;
// Dart a =Map3:: phi_1(d);
//
// do
// {
// m_edgeId[a] = eId;
// m_edgeId[Map3::phi2(a)] = eId;
//
// a = Map3::alpha2(a);
// } while(a != Map3::phi_1(d));
//
//}
//
//void ImplicitHierarchicalMap3::sewVolumes(Dart d, Dart e)
//{
//
//}
/***************************************************
* LEVELS MANAGEMENT *
***************************************************/
......@@ -484,6 +615,67 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d)
return r;
}
/***************************************************
* ATTRIBUTE HANDLER *
***************************************************/
template <typename T>
T& AttributeHandler_IHM<T>::operator[](Dart d)
{
ImplicitHierarchicalMap3* m = reinterpret_cast<ImplicitHierarchicalMap3*>(this->m_map) ;
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(d, orbit) ;
if(index == EMBNULL)
{
index = m->embedNewCell(orbit, d) ;
m->m_nextLevelCell[orbit]->operator[](index) = EMBNULL ;
}
AttributeContainer& cont = m->getAttributeContainer(orbit) ;
unsigned int step = 0 ;
while(step < nbSteps)
{
step++ ;
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 ;
cont.refLine(index) ;
}
index = nextIdx ;
}
return this->m_attrib->operator[](index);
}
template <typename T>
const T& AttributeHandler_IHM<T>::operator[](Dart d) const
{
ImplicitHierarchicalMap3* m = reinterpret_cast<ImplicitHierarchicalMap3*>(this->m_map) ;
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(d, orbit) ;
unsigned int step = 0 ;
while(step < nbSteps)
{
step++ ;
unsigned int next = m->m_nextLevelCell[orbit]->operator[](index) ;
if(next != EMBNULL) index = next ;
else break ;
}
return this->m_attrib->operator[](index);
}
} //namespace IHM
......
......@@ -48,9 +48,19 @@ template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType = S_QUAD);
template <typename PFP>
void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType = S_QUAD);
void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void subdivideLoop(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
/*******************************************************
*
*/
template <typename PFP>
void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType);
template <typename PFP>
Dart subdivideFaceTri(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
......@@ -59,7 +69,14 @@ template <typename PFP>
void subdivideVolumeTri(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void catmullClarck(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
void macCrackenJoy(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void bajaj(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
typename PFP::VEC3 bajajMask(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
} //namespace IHM
......
......@@ -72,7 +72,11 @@ template <typename PFP>
bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
template <typename PFP>
bool importInESS(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames);
bool importInESSSurfacique(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames);
template <typename PFP>
bool importInESSVolumique(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames);
} // namespace Import
......
......@@ -73,7 +73,7 @@ unsigned int gcd(unsigned int a, unsigned int b)
}
template <typename PFP>
bool importInESS(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames)
bool importInESSSurfacique(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames)
{
typedef typename PFP::VEC3 VEC3;
......@@ -455,6 +455,101 @@ bool importInESS(typename PFP::MAP& map, const std::string& filename, std::vecto
return true;
}
template <typename PFP>
bool importInESSVolumique(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames)
{
typedef typename PFP::VEC3 VEC3;
AttributeHandler<VEC3> position = map.template addAttribute<VEC3>(VERTEX_ORBIT, "position") ;
attrNames.push_back(position.name()) ;
AttributeHandler<int> objects = map.template addAttribute<int>(FACE_ORBIT, "objects") ;
attrNames.push_back(objects.name()) ;
//stocker les boundingbox contenu dans le fichier
std::vector<std::pair<VEC3,VEC3> > coordonnees; //tableau de paires (x,y)
coordonnees.reserve(50);
//classer les coordonnees en x
std::multimap<int, unsigned int> coordonneesX;
//classer les coordonnees en y
std::multimap<int, unsigned int> coordonneesY;
std::set<int> sx;
std::set<int> sy;
// open file
std::ifstream fp(filename.c_str(), std::ios::in);
if (!fp.good())
{
std::cerr << "Unable to open file " << filename << std::endl;
return false;
}
//
// Lecture du fichier
//
std::string line;
size_t posData, posCoord;
std::string bg;
unsigned int size = 0;
//two columns cutted
std::getline(fp, line);
posData = line.find("\t");
// First column
//Bounding box : first coord & second coord
bg = line.substr(0, posData);
posCoord = bg.find(") (");
VEC3 c1 = stringToEmb<PFP>(bg.substr(0, posCoord));
VEC3 c2 = stringToEmb<PFP>(bg.substr(posCoord+3));
std::cout << std::endl;
//coordonnees.push_back(std::pair<VEC3,VEC3>(c1,c2));
// coordonneesX.insert(std::pair<int, unsigned int >(c1[0],size));
// coordonneesY.insert(std::pair<int, unsigned int >(c1[1],size));
sx.insert(c1[0]);
sx.insert(c2[0]);
sy.insert(c1[1]);
sy.insert(c2[1]);
size++;
while ( std::getline( fp, line ) )
{
posData = line.find("\t");
// First column
//Bounding box : first coord & second coord
bg = line.substr(0, posData);
posCoord = bg.find(") (");
VEC3 c1 = stringToEmb<PFP>(bg.substr(0, posCoord));
VEC3 c2 = stringToEmb<PFP>(bg.substr(posCoord+3));
std::cout << std::endl;
coordonnees.push_back(std::pair<VEC3,VEC3>(c1,c2));
// coordonneesX.insert(std::pair<int, unsigned int >(c1[0],size));
// coordonneesY.insert(std::pair<int, unsigned int >(c1[1],size));
sx.insert(c1[0]);
sx.insert(c2[0]);
sy.insert(c1[1]);
sy.insert(c2[1]);
size++;
}
fp.close();
return true;
}
} // namespace Import
} // namespace Algo
......
......@@ -385,6 +385,9 @@ void MapRender_VBO::initPrimitives(typename PFP::MAP& map, const FunctorSelect&
{
std::vector<GLuint> tableIndices;
if (map.dimension()>2)
optimized=false;
// indice du VBO a utiliser
int vbo_ind = 0;
switch(prim)
......
......@@ -101,6 +101,7 @@ void EmbeddedMap3<MAP3>::sewVolumes(Dart d, Dart e)
dd = MAP3::phi1(dd) ;
} while(dd != d) ;
}
}
template <typename MAP3>
......
......@@ -88,6 +88,8 @@ public:
// add a dart to the list
virtual void add(Dart d) = 0;
virtual void popFront() = 0;
void addSelected(MAP& map, const FunctorSelect& fs)
{
for (Dart d = map.begin(); d != map.end(); map.next(d))
......@@ -125,6 +127,9 @@ public:
/// add a dart to linked list
void add(Dart d) { m_links[d.index] = this->m_first; this->m_first = d; }
//pop the first
void popFront() { this->m_first = m_links[this->m_first.index]; }
};
/**
......@@ -152,6 +157,9 @@ public:
/// add a dart to linked list
void add(Dart d) { m_links[d.index] = this->m_first; this->m_first = d; }
//pop the first
void popFront() { this->m_first = m_links[this->m_first.index]; }
};
} // end namespace CGoGN
......
......@@ -205,6 +205,8 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//std::cout << "volumeLevel" << std::endl;
if(m_curLevel == 0)
return 0 ;
......@@ -229,6 +231,8 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d)
{
Dart e = *face ;
//std::cout << "dart from face = " << e << std::endl;
// in a first time, the level of a face
//the level of the volume is the minimum of the
//levels of its faces
......@@ -294,6 +298,7 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d)
do
{
Dart ee = phi2(e) ;
//std::cout << "\t face a cote =" << ee << std::endl;
if(!mark.isMarked(ee)) // not already marked