Commit cc9276e7 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

decimationVolumique ok

parent 7e940260
...@@ -348,12 +348,10 @@ void maillageTest() ...@@ -348,12 +348,10 @@ void maillageTest()
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
//Initilisation du plongement geometrique
position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position");
/* /*
* Chargement de maillages * Chargement de maillages
*/ */
std::vector<std::string> attrNames ;
if(argc < 2) if(argc < 2)
{ {
std::cerr << "usage : " << argv[0] << " -off" << std::endl; std::cerr << "usage : " << argv[0] << " -off" << std::endl;
...@@ -371,7 +369,8 @@ int main(int argc, char **argv) ...@@ -371,7 +369,8 @@ int main(int argc, char **argv)
return 1; return 1;
} }
Algo::Import::importOFFWithELERegions<PFP>(myMap,position,argv[2],argv[3]); Algo::Import::importOFFWithELERegions<PFP>(myMap,argv[2],argv[3],attrNames);
position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
} }
else if(std::string(argv[1]) == "-tet") else if(std::string(argv[1]) == "-tet")
{ {
...@@ -380,7 +379,8 @@ int main(int argc, char **argv) ...@@ -380,7 +379,8 @@ int main(int argc, char **argv)
return 1; return 1;
} }
Algo::Import::importTet<PFP>(myMap,position,argv[2]); Algo::Import::importTet<PFP>(myMap,argv[2],attrNames);
position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
} }
else if(std::string(argv[1]) == "-ts") else if(std::string(argv[1]) == "-ts")
{ {
...@@ -389,7 +389,8 @@ int main(int argc, char **argv) ...@@ -389,7 +389,8 @@ int main(int argc, char **argv)
return 1; return 1;
} }
Algo::Import::importTs<PFP>(myMap,position,argv[2]); Algo::Import::importTs<PFP>(myMap,argv[2],attrNames);
position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, attrNames[0]) ;
//scalar = myMap.getAttribute<PFP::REAL>(VERTEX_ORBIT, "scalar"); //scalar = myMap.getAttribute<PFP::REAL>(VERTEX_ORBIT, "scalar");
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* Contact information: cgogn@unistra.fr * * Contact information: cgogn@unistra.fr *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef __DECIMATIONVOLUMIQUE__ #ifndef __DECIMATIONVOLUMIQUE__
#define __DECIMATIONVOLUMIQUE__ #define __DECIMATIONVOLUMIQUE__
...@@ -45,30 +46,25 @@ ...@@ -45,30 +46,25 @@
using namespace CGoGN ; using namespace CGoGN ;
struct PFP { struct PFP
// definition de la carte {
// definition of the map
typedef Map3 MAP; typedef Map3 MAP;
// definition du type de reel utilise // definition of the type of real value
typedef float REAL; typedef float REAL;
// definition du type de vecteur (point) utilise
// other types definitions
typedef Geom::Vector<3,REAL> VEC3; typedef Geom::Vector<3,REAL> VEC3;
// definition du type de matrice 3x3 utilise typedef Geom::Vector<6,REAL> VEC6;
typedef Geom::Matrix<3,3,REAL> MATRIX33; typedef Geom::Matrix<3,3,REAL> MATRIX33;
// definition du type de matrice 4x4 utilise
typedef Geom::Matrix<4,4,REAL> MATRIX44; typedef Geom::Matrix<4,4,REAL> MATRIX44;
typedef Geom::Matrix<3,6,REAL> MATRIX36;
// definition du type du AttributeHandler de vecteur 3D
typedef AttributeHandler<VEC3> TVEC3; typedef AttributeHandler<VEC3> TVEC3;
// definition du type du AttributeHandler de reels
typedef AttributeHandler<REAL> TREAL; typedef AttributeHandler<REAL> TREAL;
}; };
// qq initialisation cachees (car penible syntaxiquement)
INIT_STATICS_MAP();
PFP::MAP myMap; PFP::MAP myMap;
SelectorTrue allDarts; SelectorTrue allDarts;
PFP::TVEC3 position ; PFP::TVEC3 position ;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* Contact information: cgogn@unistra.fr * * Contact information: cgogn@unistra.fr *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef __SQUELETTE3CARTE__ #ifndef __SQUELETTE3CARTE__
#define __SQUELETTE3CARTE__ #define __SQUELETTE3CARTE__
...@@ -45,29 +46,25 @@ ...@@ -45,29 +46,25 @@
using namespace CGoGN ; using namespace CGoGN ;
struct PFP { struct PFP
// definition de la carte {
// definition of the map
typedef Map3 MAP; typedef Map3 MAP;
// definition du type de reel utilise // definition of the type of real value
typedef float REAL; typedef float REAL;
// definition du type de vecteur (point) utilise
// other types definitions
typedef Geom::Vector<3,REAL> VEC3; typedef Geom::Vector<3,REAL> VEC3;
// definition du type de matrice 3x3 utilise typedef Geom::Vector<6,REAL> VEC6;
typedef Geom::Matrix<3,3,REAL> MATRIX33; typedef Geom::Matrix<3,3,REAL> MATRIX33;
// definition du type de matrice 4x4 utilise
typedef Geom::Matrix<4,4,REAL> MATRIX44; typedef Geom::Matrix<4,4,REAL> MATRIX44;
typedef Geom::Matrix<3,6,REAL> MATRIX36;
// definition du type du AttributeHandler de vecteur 3D
typedef AttributeHandler<VEC3> TVEC3; typedef AttributeHandler<VEC3> TVEC3;
// definition du type du AttributeHandler de reels
typedef AttributeHandler<REAL> TREAL; typedef AttributeHandler<REAL> TREAL;
}; };
// qq initialisation cachees (car penible syntaxiquement)
INIT_STATICS_MAP();
PFP::MAP myMap; PFP::MAP myMap;
SelectorTrue allDarts; SelectorTrue allDarts;
......
...@@ -49,10 +49,6 @@ namespace Import ...@@ -49,10 +49,6 @@ namespace Import
template <typename PFP> template <typename PFP>
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, ImportSurfacique::ImportType kind = ImportSurfacique::UNKNOWNSURFACE); bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, ImportSurfacique::ImportType kind = ImportSurfacique::UNKNOWNSURFACE);
template <typename PFP>
bool importPLYPTM(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& positions, ImportSurfacique::ImportType kind,
typename PFP::TFRAME& frame, typename PFP::TRGBFUNCTIONS& funcs);
/** /**
* import a volumic mesh * import a volumic mesh
*/ */
...@@ -63,27 +59,26 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, typename PF ...@@ -63,27 +59,26 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, typename PF
//bool importObjWithTex(typename PFP::MAP& map, const std::string& filename); //bool importObjWithTex(typename PFP::MAP& map, const std::string& filename);
// //
/* /*
* TODO a transformer en utilisant un MeshTableVolume. * TODO a transformer en utilisant un MeshTableVolume.
*/ */
template <typename PFP> template <typename PFP>
bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, char* filenameOFF,char * filenameELE); bool importOFFWithELERegions(typename PFP::MAP& the_map, char* filenameOFF,char * filenameELE, std::vector<std::string>& attrNames);
template <typename PFP> template <typename PFP>
bool importTet(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, char* filename, float scaleFactor=1.0f); bool importTet(typename PFP::MAP& the_map, char* filename, std::vector<std::string>& attrNames, float scaleFactor=1.0f);
template <typename PFP> template <typename PFP>
bool importTs(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, char* filename, float scaleFactor=1.0f); bool importTs(typename PFP::MAP& the_map, char* filename, std::vector<std::string>& attrNames, float scaleFactor=1.0f);
template <typename PFP> template <typename PFP>
bool importInESS(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, char* filename); bool importInESS(typename PFP::MAP& the_map, char* filename, std::vector<std::string>& attrNames);
} } // namespace Import
} } // namespace Algo
} } // namespace CGoGN
#include "Algo/Import/importMesh.hpp" #include "Algo/Import/importMesh.hpp"
//#include "Algo/Import/importObjTex.hpp" //#include "Algo/Import/importObjTex.hpp"
......
...@@ -50,12 +50,12 @@ namespace Import ...@@ -50,12 +50,12 @@ namespace Import
namespace ImportSurfacique namespace ImportSurfacique
{ {
enum ImportType {UNKNOWNSURFACE,TRIAN,TRIANBGZ,PLY,PLYPTM,OFF,OBJ,CTM,VRML}; enum ImportType { UNKNOWNSURFACE, TRIAN, TRIANBGZ, PLY, PLYPTM, OFF, OBJ, CTM, VRML };
} }
namespace ImportVolumique namespace ImportVolumique
{ {
enum ImportType {UNKNOWNVOLUME,TET,TRIANBGZ,PLY}; enum ImportType { UNKNOWNVOLUME ,TET ,TRIANBGZ ,PLY };
} }
......
...@@ -45,6 +45,7 @@ ImportSurfacique::ImportType MeshTablesSurface<PFP>::getFileType(const std::stri ...@@ -45,6 +45,7 @@ ImportSurfacique::ImportType MeshTablesSurface<PFP>::getFileType(const std::stri
{ {
if ((filename.rfind(".trianbgz")!=std::string::npos) || (filename.rfind(".TRIANBGZ")!=std::string::npos)) if ((filename.rfind(".trianbgz")!=std::string::npos) || (filename.rfind(".TRIANBGZ")!=std::string::npos))
return ImportSurfacique::TRIANBGZ; return ImportSurfacique::TRIANBGZ;
if ((filename.rfind(".trian")!=std::string::npos) || (filename.rfind(".TRIAN")!=std::string::npos)) if ((filename.rfind(".trian")!=std::string::npos) || (filename.rfind(".TRIAN")!=std::string::npos))
return ImportSurfacique::TRIAN; return ImportSurfacique::TRIAN;
...@@ -53,10 +54,13 @@ ImportSurfacique::ImportType MeshTablesSurface<PFP>::getFileType(const std::stri ...@@ -53,10 +54,13 @@ ImportSurfacique::ImportType MeshTablesSurface<PFP>::getFileType(const std::stri
if ((filename.rfind(".ply")!=std::string::npos) || (filename.rfind(".PLY")!=std::string::npos)) if ((filename.rfind(".ply")!=std::string::npos) || (filename.rfind(".PLY")!=std::string::npos))
return ImportSurfacique::PLY; return ImportSurfacique::PLY;
if ((filename.rfind(".off")!=std::string::npos) || (filename.rfind(".OFF")!=std::string::npos)) if ((filename.rfind(".off")!=std::string::npos) || (filename.rfind(".OFF")!=std::string::npos))
return ImportSurfacique::OFF; return ImportSurfacique::OFF;
if ((filename.rfind(".obj")!=std::string::npos) || (filename.rfind(".OBJ")!=std::string::npos)) if ((filename.rfind(".obj")!=std::string::npos) || (filename.rfind(".OBJ")!=std::string::npos))
return ImportSurfacique::OBJ; return ImportSurfacique::OBJ;
if ((filename.rfind(".ctm")!=std::string::npos) || (filename.rfind(".OBJ")!=std::string::npos)) if ((filename.rfind(".ctm")!=std::string::npos) || (filename.rfind(".OBJ")!=std::string::npos))
return ImportSurfacique::CTM; return ImportSurfacique::CTM;
...@@ -93,6 +97,10 @@ bool MeshTablesSurface<PFP>::importMesh(const std::string& filename, std::vector ...@@ -93,6 +97,10 @@ bool MeshTablesSurface<PFP>::importMesh(const std::string& filename, std::vector
std::cout << "TYPE: PLY" << std::endl; std::cout << "TYPE: PLY" << std::endl;
return importPly(filename, attrNames); return importPly(filename, attrNames);
break; break;
case ImportSurfacique::PLYPTM:
std::cout << "TYPE: PLYPTM" << std::endl;
return importPlyPTM(filename, attrNames);
break;
case ImportSurfacique::OBJ: case ImportSurfacique::OBJ:
std::cout << "TYPE: OBJ" << std::endl; std::cout << "TYPE: OBJ" << std::endl;
return importObj(filename, attrNames); return importObj(filename, attrNames);
......
...@@ -33,7 +33,7 @@ namespace Import ...@@ -33,7 +33,7 @@ namespace Import
{ {
template <typename PFP> template <typename PFP>
typename PFP::VEC3 stringToEmb(std::string s) typename PFP::VEC3 stringToEmb(std::string& s)
{ {
if(s[0] == '(') if(s[0] == '(')
s.erase(0,2); s.erase(0,2);
...@@ -55,10 +55,13 @@ typename PFP::VEC3 stringToEmb(std::string s) ...@@ -55,10 +55,13 @@ typename PFP::VEC3 stringToEmb(std::string s)
} }
template <typename PFP> template <typename PFP>
bool importInESS(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, char* filename) bool importInESS(typename PFP::MAP& map, char* filename, std::vector<std::string>& attrNames)
{ {
typedef typename PFP::VEC3 VEC3; typedef typename PFP::VEC3 VEC3;
AttribContainer& container = map.getAttributeContainer(VERTEX_CELL) ;
AttributeHandler<VEC3> position = map.template addAttribute<VEC3>(VERTEX_ORBIT, "position") ;
attrNames.push_back(position.name()) ;
// open file // open file
std::ifstream fp(filename, std::ios::in); std::ifstream fp(filename, std::ios::in);
...@@ -85,10 +88,8 @@ bool importInESS(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, ch ...@@ -85,10 +88,8 @@ bool importInESS(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, ch
stringToEmb<PFP>(bg.substr(0,posCoord)); stringToEmb<PFP>(bg.substr(0,posCoord));
stringToEmb<PFP>(bg.substr(posCoord+3)); stringToEmb<PFP>(bg.substr(posCoord+3));
while ( std::getline( fp, line ) ) while ( std::getline( fp, line ) )
{ {
posData = line.find("\t"); posData = line.find("\t");
// First column // First column
...@@ -107,14 +108,12 @@ bool importInESS(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, ch ...@@ -107,14 +108,12 @@ bool importInESS(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, ch
++count; ++count;
} }
fp.close(); fp.close();
return true; return true;
} }
} // namespace Import
} // namespace Algo
} } // namespace CGoGN
} // end namespaces
}
...@@ -430,8 +430,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv) ...@@ -430,8 +430,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
template <typename PFP> template <typename PFP>
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, ImportSurfacique::ImportType kind) bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, ImportSurfacique::ImportType kind)
{ {
// AttribContainer& vertexContainer = map.getAttributeContainer(VERTEX_ORBIT);
MeshTablesSurface<PFP> mts(map); MeshTablesSurface<PFP> mts(map);
if(!mts.importMesh(filename, attrNames, kind)) if(!mts.importMesh(filename, attrNames, kind))
...@@ -440,20 +438,6 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector ...@@ -440,20 +438,6 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector
return importMesh<PFP>(map, mts); return importMesh<PFP>(map, mts);
} }
template <typename PFP>
bool importPLYPTM(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& positions, ImportSurfacique::ImportType kind,
typename PFP::TFRAME& Frame, typename PFP::TRGBFUNCS& RGBfunctions)
{
AttribContainer& vertexContainer = map.getAttributeContainer(VERTEX_ORBIT);
MeshTablesSurface<PFP> mts(vertexContainer, positions);
if(!mts.importPlyPTM(filename, Frame, RGBfunctions))
return false;
return importMesh<PFP>(map, mts);
}
template <typename PFP> template <typename PFP>
bool importMesh(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& positions, ImportVolumique::ImportType kind) bool importMesh(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& positions, ImportVolumique::ImportType kind)
{ {
......
...@@ -27,19 +27,25 @@ ...@@ -27,19 +27,25 @@
namespace CGoGN namespace CGoGN
{ {
namespace Algo namespace Algo
{ {
namespace Import
namespace Import
{ {
template<typename PFP> template<typename PFP>
bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_position, char* filenameOFF, char * filenameELE) bool importOFFWithELERegions(typename PFP::MAP& map, char* filenameOFF, char * filenameELE, std::vector<std::string>& attrNames)
{ {
typedef typename PFP::VEC3 VEC3; typedef typename PFP::VEC3 VEC3;
AttribContainer& container = map.getAttributeContainer(VERTEX_CELL) ;
AttributeHandler<VEC3> position = map.template addAttribute<VEC3>(VERTEX_ORBIT, "position") ;
attrNames.push_back(position.name()) ;
unsigned int m_nbVertices=0, m_nbFaces=0, m_nbEdges=0, m_nbVolumes=0; unsigned int m_nbVertices=0, m_nbFaces=0, m_nbEdges=0, m_nbVolumes=0;
AutoAttributeHandler< NoMathIONameAttribute< std::vector<Dart> > > vecDartsPerVertex(the_map, VERTEX_ORBIT, "incidents"); AutoAttributeHandler< NoMathIONameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, VERTEX_ORBIT, "incidents");
// open files // open files
std::ifstream foff(filenameOFF, std::ios::in); std::ifstream foff(filenameOFF, std::ios::in);
...@@ -67,7 +73,6 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_ ...@@ -67,7 +73,6 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
return false; return false;
} }
//Reading number of vertex/faces/edges in OFF file //Reading number of vertex/faces/edges in OFF file
int nbe; int nbe;
{ {
...@@ -98,13 +103,11 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_ ...@@ -98,13 +103,11 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
std::cout << "nb points = " << m_nbVertices << " / nb faces = " << m_nbFaces << " / nb edges = " << m_nbEdges << " / nb tet = " << m_nbVolumes << std::endl; std::cout << "nb points = " << m_nbVertices << " / nb faces = " << m_nbFaces << " / nb edges = " << m_nbEdges << " / nb tet = " << m_nbVolumes << std::endl;
AttribContainer& m_container = the_map.getAttributeContainer(VERTEX_ORBIT);
//Reading vertices //Reading vertices
std::vector<unsigned int> verticesID; std::vector<unsigned int> verticesID;
verticesID.reserve(m_nbVertices); verticesID.reserve(m_nbVertices);
for(unsigned int i=0 ; i < m_nbVertices ; ++i) for(unsigned int i = 0 ; i < m_nbVertices ; ++i)
{ {
do do
{ {
...@@ -120,8 +123,8 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_ ...@@ -120,8 +123,8 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
//we can read colors informations if exists //we can read colors informations if exists
VEC3 pos(x,y,z); VEC3 pos(x,y,z);
unsigned int id = m_container.insertLine(); unsigned int id = container.insertLine();
m_position[id] = pos; position[id] = pos;
// std::cout << "emb : " << pos << " / id = " << id << std::endl; // std::cout << "emb : " << pos << " / id = " << id << std::endl;
verticesID.push_back(id); verticesID.push_back(id);
...@@ -142,8 +145,8 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_ ...@@ -142,8 +145,8 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
oss >> nbe; oss >> nbe;
// std::cout << "tetra number : " << nbe << std::endl; // std::cout << "tetra number : " << nbe << std::endl;
//Algo::Modelisation::Polyhedron<PFP>::createOrientedTetra(the_map); //Algo::Modelisation::Polyhedron<PFP>::createOrientedTetra(map);
Dart d = Algo::Modelisation::Polyhedron<PFP>::createOrientedPolyhedron(the_map,4); Dart d = Algo::Modelisation::Polyhedron<PFP>::createOrientedPolyhedron(map,4);
Geom::Vec4ui pt; Geom::Vec4ui pt;
oss >> pt[0]; oss >> pt[0];
oss >> pt[1]; oss >> pt[1];
...@@ -160,33 +163,33 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_ ...@@ -160,33 +163,33 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, typename PFP::TVEC3& m_
{ {
// std::cout << "\t embedding number : " << pt[j]; // std::cout << "\t embedding number : " << pt[j];
FunctorSetEmb<typename PFP::MAP> femb(the_map,VERTEX_ORBIT,verticesID[pt[j]]); FunctorSetEmb<typename PFP::MAP> femb(map,VERTEX_ORBIT,verticesID[pt[j]]);
Dart dd = d; Dart dd = d;
do { do {
femb(dd); femb(dd);
//vecDartPtrEmb[pt[j]].push_back(dd); //vecDartPtrEmb[pt[j]].push_back(dd);
vecDartsPerVertex[pt[j]].push_back(dd); vecDartsPerVertex[pt[j]].push_back(dd);
dd = the_map.phi1(the_map.phi2(dd)); dd = map.phi1(map.phi2(dd));
} while(dd!=d); } while(dd!=d);
d = the_map.phi1(d); d = map.phi1(d);
// std::cout << " done" << std::endl; // std::cout << " done" << std::endl;
} }
//Embed the last vertex //Embed the last vertex
// std::cout << "\t embedding number : " << pt[3] << std::endl; // std::cout << "\t embedding number : " << pt[3] << std::endl;
d = the_map.phi_1(the_map.phi2(d)); d = map.phi_1(map.phi2(d));
FunctorSetEmb<typename PFP::MAP> femb(the_map,VERTEX_ORBIT,verticesID[pt[3]]);