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

debut correction meshTableVolume

parent a4d40b86
...@@ -66,10 +66,10 @@ template <typename PFP> ...@@ -66,10 +66,10 @@ template <typename PFP>
bool importOFFWithELERegions(typename PFP::MAP& the_map, const std::string& filenameOFF, const std::string& filenameELE, std::vector<std::string>& attrNames); bool importOFFWithELERegions(typename PFP::MAP& the_map, const std::string& filenameOFF, const std::string& filenameELE, std::vector<std::string>& attrNames);
template <typename PFP> template <typename PFP>
bool importTet(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor=1.0f); bool importTet(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
template <typename PFP> template <typename PFP>
bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor=1.0f); bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
template <typename PFP> template <typename PFP>
bool importInESS(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames); bool importInESS(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames);
......
...@@ -130,10 +130,9 @@ public: ...@@ -130,10 +130,9 @@ public:
template <typename PFP> template <typename PFP>
class MeshTablesVolume class MeshTablesVolume
{ {
public:
protected: protected:
typename PFP::MAP& m_map;
unsigned m_nbVertices; unsigned m_nbVertices;
unsigned m_nbFaces; unsigned m_nbFaces;
...@@ -150,16 +149,6 @@ protected: ...@@ -150,16 +149,6 @@ protected:
*/ */
std::vector<unsigned int> m_emb; std::vector<unsigned int> m_emb;
/**
* we need direct access to container itself to insert new lines while reading points
*/
AttribContainer& m_container;
/**
* table of positions
*/
typename PFP::TVEC3& m_positions;
static ImportVolumique::ImportType getFileType(const std::string& filename); static ImportVolumique::ImportType getFileType(const std::string& filename);
public: public:
...@@ -170,7 +159,7 @@ public: ...@@ -170,7 +159,7 @@ public:
typedef Geom::Matrix<3,3,DATA_TYPE> MAT33; typedef Geom::Matrix<3,3,DATA_TYPE> MAT33;
typedef Geom::Matrix<3,6,DATA_TYPE> MAT36; typedef Geom::Matrix<3,6,DATA_TYPE> MAT36;
inline short getNbEdgesFace(int i) const { return m_nbEdges[i];} inline short getNbEdgesFace(int i) const { return m_nbEdges[i]; }
inline unsigned getNbVolumes() const { return m_nbVolumes; } inline unsigned getNbVolumes() const { return m_nbVolumes; }
...@@ -184,23 +173,17 @@ public: ...@@ -184,23 +173,17 @@ public:
inline unsigned int getEmbIdx(int i) { return m_emb[i]; } inline unsigned int getEmbIdx(int i) { return m_emb[i]; }
bool importTet(const std::string& filename,float scaleFactor); bool importMesh(const std::string& filename, std::vector<std::string>& attrNames, ImportVolumique::ImportType kind, float scaleFactor);
bool importPly(const std::string& filename); bool importTet(const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor);
bool importTrianBinGz(const std::string& filename); bool importPly(const std::string& filename, std::vector<std::string>& attrNames);
bool importMesh(const std::string& filename, ImportVolumique::ImportType kind, float scaleFactor);
MeshTablesVolume(AttribContainer& container, typename PFP::TVEC3& pos ): bool importTrianBinGz(const std::string& filename, std::vector<std::string>& attrNames);
m_container(container), m_positions(pos)
{
}
MeshTablesVolume(AttribContainer& container, typename PFP::TVEC3& pos, const std::string& filename): MeshTablesVolume(typename PFP::MAP& map):
m_container(container), m_positions(pos) m_map(map)
{ {
importMesh(filename);
} }
}; };
......
...@@ -36,8 +36,10 @@ ImportVolumique::ImportType MeshTablesVolume<PFP>::getFileType(const std::string ...@@ -36,8 +36,10 @@ ImportVolumique::ImportType MeshTablesVolume<PFP>::getFileType(const std::string
{ {
if ((filename.rfind(".tet")!=std::string::npos) || (filename.rfind(".TET")!=std::string::npos)) if ((filename.rfind(".tet")!=std::string::npos) || (filename.rfind(".TET")!=std::string::npos))
return ImportVolumique::TET; return ImportVolumique::TET;
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 ImportVolumique::TRIANBGZ; return ImportVolumique::TRIANBGZ;
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 ImportVolumique::PLY; return ImportVolumique::PLY;
...@@ -45,7 +47,7 @@ ImportVolumique::ImportType MeshTablesVolume<PFP>::getFileType(const std::string ...@@ -45,7 +47,7 @@ ImportVolumique::ImportType MeshTablesVolume<PFP>::getFileType(const std::string
} }
template <typename PFP> template <typename PFP>
bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, ImportVolumique::ImportType kind,float scaleFactor=1.0f) bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, std::vector<std::string>& attrNames, ImportVolumique::ImportType kind, float scaleFactor=1.0f)
{ {
if (kind == ImportVolumique::UNKNOWNVOLUME) if (kind == ImportVolumique::UNKNOWNVOLUME)
kind = getFileType(filename); kind = getFileType(filename);
...@@ -53,13 +55,13 @@ bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, ImportVolumi ...@@ -53,13 +55,13 @@ bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, ImportVolumi
switch (kind) switch (kind)
{ {
case ImportVolumique::PLY: case ImportVolumique::PLY:
return importPly(filename); return importPly(filename, attrNames);
break; break;
case ImportVolumique::TET: case ImportVolumique::TET:
return importTet(filename,scaleFactor); return importTet(filename, attrNames, scaleFactor);
break; break;
case ImportVolumique::TRIANBGZ: case ImportVolumique::TRIANBGZ:
return importTrianBinGz(filename); return importTrianBinGz(filename, attrNames);
break; break;
default: default:
std::cerr << "Not yet supported" << std::endl; std::cerr << "Not yet supported" << std::endl;
...@@ -69,8 +71,12 @@ bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, ImportVolumi ...@@ -69,8 +71,12 @@ bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, ImportVolumi
} }
template <typename PFP> template <typename PFP>
bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFactor=1.0f) bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor=1.0f)
{ {
AttribContainer& container = m_map.getAttributeContainer(VERTEX_CELL) ;
AttributeHandler<typename PFP::VEC3> positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX_ORBIT, "position") ;
attrNames.push_back(positions.name()) ;
// open file // open file
std::ifstream fp(filename.c_str(), std::ios::in); std::ifstream fp(filename.c_str(), std::ios::in);
if (!fp.good()) if (!fp.good())
...@@ -79,7 +85,6 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac ...@@ -79,7 +85,6 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac
return false; return false;
} }
std::string ligne; std::string ligne;
int nbv,nbt; int nbv,nbt;
// lecture des nombres de sommets/tetra // lecture des nombres de sommets/tetra
...@@ -116,8 +121,8 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac ...@@ -116,8 +121,8 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac
//std::cout << "VEC3 = " << pos << std::endl; //std::cout << "VEC3 = " << pos << std::endl;
unsigned int id = m_container.insertLine(); unsigned int id = container.insertLine();
m_positions[id] = pos; positions[id] = pos;
verticesID.push_back(id); verticesID.push_back(id);
} }
...@@ -133,7 +138,7 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac ...@@ -133,7 +138,7 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac
m_nbFaces=nbt*4; m_nbFaces=nbt*4;
m_emb.reserve(nbt*12); m_emb.reserve(nbt*12);
for (unsigned i=0; i<m_nbVolumes ;++i) for (unsigned int i = 0; i < m_nbVolumes ; ++i)
{ {
do do
{ {
...@@ -183,7 +188,7 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac ...@@ -183,7 +188,7 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac
} }
template <typename PFP> template <typename PFP>
bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename) bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename, std::vector<std::string>& attrNames)
{ {
// // open file // // open file
// igzstream fs(filename.c_str(), std::ios::in|std::ios::binary); // igzstream fs(filename.c_str(), std::ios::in|std::ios::binary);
...@@ -246,7 +251,7 @@ bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename) ...@@ -246,7 +251,7 @@ bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename)
} }
template<typename PFP> template<typename PFP>
bool MeshTablesVolume<PFP>::importPly(const std::string& filename) bool MeshTablesVolume<PFP>::importPly(const std::string& filename, std::vector<std::string>& attrNames)
{ {
// PlyImportData pid; // PlyImportData pid;
// //
...@@ -286,7 +291,6 @@ bool MeshTablesVolume<PFP>::importPly(const std::string& filename) ...@@ -286,7 +291,6 @@ bool MeshTablesVolume<PFP>::importPly(const std::string& filename)
// m_emb.push_back(vertices[ indices[j] ]); // m_emb.push_back(vertices[ indices[j] ]);
// } // }
// } // }
return true; return true;
} }
......
...@@ -439,13 +439,11 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector ...@@ -439,13 +439,11 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector
} }
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, std::vector<std::string>& attrNames, ImportVolumique::ImportType kind)
{ {
AttribContainer& vertexContainer = map.getAttributeContainer(VERTEX_ORBIT); MeshTablesVolume<PFP> mtv(map);
MeshTablesVolume<PFP> mtv(vertexContainer, positions); if(!mtv.importMesh(filename, attrNames, kind))
if(!mtv.importMesh(filename, kind))
return false; return false;
return importMesh<PFP>(map, mtv); return importMesh<PFP>(map, mtv);
......
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