Commit e3b35f88 authored by Pierre Kraemer's avatar Pierre Kraemer

debut correction meshTableVolume

parent a4d40b86
......@@ -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);
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>
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>
bool importInESS(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames);
......
......@@ -130,10 +130,9 @@ public:
template <typename PFP>
class MeshTablesVolume
{
public:
protected:
typename PFP::MAP& m_map;
unsigned m_nbVertices;
unsigned m_nbFaces;
......@@ -150,16 +149,6 @@ protected:
*/
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);
public:
......@@ -170,7 +159,7 @@ public:
typedef Geom::Matrix<3,3,DATA_TYPE> MAT33;
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; }
......@@ -184,23 +173,17 @@ public:
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 importMesh(const std::string& filename, ImportVolumique::ImportType kind, float scaleFactor);
bool importPly(const std::string& filename, std::vector<std::string>& attrNames);
MeshTablesVolume(AttribContainer& container, typename PFP::TVEC3& pos ):
m_container(container), m_positions(pos)
{
}
bool importTrianBinGz(const std::string& filename, std::vector<std::string>& attrNames);
MeshTablesVolume(AttribContainer& container, typename PFP::TVEC3& pos, const std::string& filename):
m_container(container), m_positions(pos)
MeshTablesVolume(typename PFP::MAP& map):
m_map(map)
{
importMesh(filename);
}
};
......
......@@ -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))
return ImportVolumique::TET;
if ((filename.rfind(".trianbgz")!=std::string::npos) || (filename.rfind(".TRIANBGZ")!=std::string::npos))
return ImportVolumique::TRIANBGZ;
if ((filename.rfind(".ply")!=std::string::npos) || (filename.rfind(".PLY")!=std::string::npos))
return ImportVolumique::PLY;
......@@ -45,7 +47,7 @@ ImportVolumique::ImportType MeshTablesVolume<PFP>::getFileType(const std::string
}
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)
kind = getFileType(filename);
......@@ -53,13 +55,13 @@ bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, ImportVolumi
switch (kind)
{
case ImportVolumique::PLY:
return importPly(filename);
return importPly(filename, attrNames);
break;
case ImportVolumique::TET:
return importTet(filename,scaleFactor);
return importTet(filename, attrNames, scaleFactor);
break;
case ImportVolumique::TRIANBGZ:
return importTrianBinGz(filename);
return importTrianBinGz(filename, attrNames);
break;
default:
std::cerr << "Not yet supported" << std::endl;
......@@ -69,8 +71,12 @@ bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, ImportVolumi
}
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
std::ifstream fp(filename.c_str(), std::ios::in);
if (!fp.good())
......@@ -79,7 +85,6 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac
return false;
}
std::string ligne;
int nbv,nbt;
// lecture des nombres de sommets/tetra
......@@ -116,8 +121,8 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac
//std::cout << "VEC3 = " << pos << std::endl;
unsigned int id = m_container.insertLine();
m_positions[id] = pos;
unsigned int id = container.insertLine();
positions[id] = pos;
verticesID.push_back(id);
}
......@@ -133,7 +138,7 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac
m_nbFaces=nbt*4;
m_emb.reserve(nbt*12);
for (unsigned i=0; i<m_nbVolumes ;++i)
for (unsigned int i = 0; i < m_nbVolumes ; ++i)
{
do
{
......@@ -183,7 +188,7 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename,float scaleFac
}
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
// igzstream fs(filename.c_str(), std::ios::in|std::ios::binary);
......@@ -246,7 +251,7 @@ bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename)
}
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;
//
......@@ -286,7 +291,6 @@ bool MeshTablesVolume<PFP>::importPly(const std::string& filename)
// m_emb.push_back(vertices[ indices[j] ]);
// }
// }
return true;
}
......
......@@ -439,13 +439,11 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector
}
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, kind))
if(!mtv.importMesh(filename, attrNames, kind))
return false;
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