Commit ed5a6193 authored by Thomas's avatar Thomas
Browse files

starting import function for Moka and improving export for povray

parent 06d3b960
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <iostream> #include <iostream>
//#define WITH_GMAP 1 #define WITH_GMAP 1
#include "Topology/generic/parameters.h" #include "Topology/generic/parameters.h"
#ifdef WITH_GMAP #ifdef WITH_GMAP
......
...@@ -15,13 +15,13 @@ namespace ExportPov ...@@ -15,13 +15,13 @@ namespace ExportPov
{ {
template <typename PFP> template <typename PFP>
void exportTriangleWire(std::ofstream& out,typename PFP::VEC3& p1,typename PFP::VEC3& p2,typename PFP::VEC3& p3) void exportTriangleWire(std::ofstream& out,typename PFP::VEC3& p1,typename PFP::VEC3& p2,typename PFP::VEC3& p3, float width)
{ {
out << "cylinder { <" << p1[0] << "," << p1[2] << "," << p1[1] << ">, <" << p2[0] << "," << p2[2] << "," << p2[1] << ">, 0.5 }" << std::endl; out << "cylinder { <" << p1[0] << "," << p1[1] << "," << p1[2] << ">, <" << p2[0] << "," << p2[1] << "," << p2[2] << ">, " << width << "}" << std::endl;
out << "cylinder { <" << p1[0] << "," << p1[2] << "," << p1[1] << ">, <" << p3[0] << "," << p3[2] << "," << p3[1] << ">, 0.5 }" << std::endl; out << "cylinder { <" << p1[0] << "," << p1[1] << "," << p1[2] << ">, <" << p3[0] << "," << p3[1] << "," << p3[2] << ">, " << width << "}" << std::endl;
out << "cylinder { <" << p3[0] << "," << p3[2] << "," << p3[1] << ">, <" << p2[0] << "," << p2[2] << "," << p2[1] << ">, 0.5 }" << std::endl; out << "cylinder { <" << p3[0] << "," << p3[1] << "," << p3[2] << ">, <" << p2[0] << "," << p2[1] << "," << p2[2] << ">, " << width << "}" << std::endl;
} }
template <typename PFP> template <typename PFP>
...@@ -173,42 +173,22 @@ void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, typename ...@@ -173,42 +173,22 @@ void export3MeshPlainSmooth(std::ofstream& out, typename PFP::MAP& map, typename
} }
template <typename PFP> template <typename PFP>
void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, typename PFP::TVEC3& position, const std::string& meshName, const FunctorSelect& good = allDarts) void exportMeshWire(std::ofstream& out, typename PFP::MAP& map, typename PFP::TVEC3& position, const std::string& meshName, float width=0.5f, const FunctorSelect& good = allDarts)
{ {
out << "#declare " << meshName << "= union {" << std::endl; out << "#declare " << meshName << "= union {" << std::endl;
DartMarkerStore traite(map); TraversorE<typename PFP::MAP > travE(map);
for(Dart d = map.begin() ; d!= map.end() ; map.next(d)) for(Dart d = travE.begin() ; d!= travE.end() ; d = travE.next())
{ {
if(good(d) && !traite.isMarked(d)) if(good(d))
{ {
unsigned int nb = 0; Dart dd = map.phi2(d);
Dart dd = d;
do
{
traite.markOrbit(DART, dd);
dd = map.phi1(dd);
nb++;
} while(dd != d);
if(nb == 3) out << "cylinder{ " << std::endl;
Algo::ExportPov::exportTriangleWire<PFP>(out,position[dd],position[map.phi1(dd)],position[map.phi1(map.phi1(dd))]); out << "<" << position[d][0] << "," << position[d][1] << "," << position[d][2] << ">," << std::endl;
else out << "<" << position[dd][0] << "," << position[dd][1] << "," << position[dd][2] << ">," << width << std::endl;
{ out << "}" << std::endl;
dd = d;
do
{
if(position[dd][0]!=position[map.phi1(dd)][0] || position[dd][1]!=position[map.phi1(dd)][1] || position[dd][2]!=position[map.phi1(dd)][2])
{
out << "cylinder{ " << std::endl;
out << "<" << position[dd][0] << "," << position[dd][2] << "," << position[dd][1] << ">," << std::endl;
out << "<" << position[map.phi1(dd)][0] << "," << position[map.phi1(dd)][2] << "," << position[map.phi1(dd)][1] << ">, 0.5" << std::endl;
out << "}" << std::endl;
}
dd = map.phi1(dd);
} while(dd != d);
}
} }
} }
......
...@@ -44,10 +44,9 @@ namespace Import ...@@ -44,10 +44,9 @@ namespace Import
* import a mesh * import a mesh
* @param map the map in which the function imports the mesh * @param map the map in which the function imports the mesh
* @param filename (*.{trian,trianbgz,off,obj,ply}) * @param filename (*.{trian,trianbgz,off,obj,ply})
* @param positions table of vertices positions attribute * @param attrNames table of attributes names
* @param m a marker that will be set by the function. If closeObject=false the phi2 that have fixed point are marked, else the created darts of the boundary are marked.
* @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values) * @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values)
* @param closeObject a boolean indicating if the imported mesh should be closed * @param mergeCloseVertices a boolean indicating if the imported mesh should have its vertices merged
* @return a boolean indicating if import was successfull * @return a boolean indicating if import was successfull
*/ */
template <typename PFP> template <typename PFP>
...@@ -85,10 +84,14 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, const std::string& file ...@@ -85,10 +84,14 @@ bool importOFFWithELERegions(typename PFP::MAP& the_map, const std::string& file
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>
bool importMoka(typename PFP::MAP& the_gmap, const std::string& filename, std::vector<std::string>& attrNames);
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);
} // namespace Import } // namespace Import
} // namespace Algo } // namespace Algo
...@@ -99,6 +102,7 @@ bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vect ...@@ -99,6 +102,7 @@ bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vect
//#include "Algo/Import/importObjTex.hpp" //#include "Algo/Import/importObjTex.hpp"
#include "Algo/Import/importObjEle.hpp" #include "Algo/Import/importObjEle.hpp"
#include "Algo/Import/importTet.hpp" #include "Algo/Import/importTet.hpp"
#include "Algo/Import/importMoka.hpp"
#include "Algo/Import/importTs.hpp" #include "Algo/Import/importTs.hpp"
#endif #endif
...@@ -57,7 +57,7 @@ namespace Import ...@@ -57,7 +57,7 @@ namespace Import
namespace ImportVolumique namespace ImportVolumique
{ {
enum ImportType { UNKNOWNVOLUME ,TET ,TRIANBGZ ,PLY ,OFF, OBJ }; enum ImportType { UNKNOWNVOLUME ,TET ,TRIANBGZ ,PLY ,OFF, OBJ, MOKA };
} }
...@@ -184,6 +184,8 @@ public: ...@@ -184,6 +184,8 @@ public:
bool importTet(const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor); bool importTet(const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor);
bool importMoka(const std::string& filename, std::vector<std::string>& attrNames);
bool importPly(const std::string& filename, std::vector<std::string>& attrNames); bool importPly(const std::string& filename, std::vector<std::string>& attrNames);
bool importTrianBinGz(const std::string& filename, std::vector<std::string>& attrNames); bool importTrianBinGz(const std::string& filename, std::vector<std::string>& attrNames);
......
...@@ -43,6 +43,9 @@ ImportVolumique::ImportType MeshTablesVolume<PFP>::getFileType(const std::string ...@@ -43,6 +43,9 @@ ImportVolumique::ImportType MeshTablesVolume<PFP>::getFileType(const std::string
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;
if ((filename.rfind(".moka")!=std::string::npos) || (filename.rfind(".MOKA")!=std::string::npos))
return ImportVolumique::MOKA;
return ImportVolumique::UNKNOWNVOLUME; return ImportVolumique::UNKNOWNVOLUME;
} }
...@@ -63,6 +66,9 @@ bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, std::vector< ...@@ -63,6 +66,9 @@ bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, std::vector<
case ImportVolumique::TRIANBGZ: case ImportVolumique::TRIANBGZ:
return importTrianBinGz(filename, attrNames); return importTrianBinGz(filename, attrNames);
break; break;
// case ImportVolumique::MOKA:
// return importMoka(filename,attrNames);
// break;
default: default:
CGoGNerr << "Not yet supported" << CGoGNendl; CGoGNerr << "Not yet supported" << CGoGNendl;
break; break;
...@@ -193,6 +199,83 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<s ...@@ -193,6 +199,83 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<s
return true; return true;
} }
//template <typename PFP>
//bool MeshTablesVolume<PFP>::importMoka(const std::string& filename, std::vector<std::string>& attrNames)
//{
// // open file
// igzstream fp(filename.c_str(), std::ios::in|std::ios::binary);
//
// if (!fp.good())
// {
// CGoGNerr << "Unable to open file " << filename << CGoGNendl;
// return false;
// }
//
// AttributeContainer& container = m_map.getAttributeContainer(VERTEX);
//
// AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position");
// if (!positions.isValid())
// positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "position");
//
// attrNames.push_back(positions.name());
//
// std::string ligne;
// int nbv,nbt;
// std::getline (fp, ligne);
//
// //check if the file format is in ascii
// if(ligne.compare("Moka file [ascii]")!=0)
// {
// CGoGNerr << "Unable to load this moka file " << filename << CGoGNendl;
// return false;
// }
//
// std::getline (fp, ligne);
// std::cout << "line 2 : " << ligne << std::endl;
//
// unsigned int dartNb=0;
// while(!std::getline(fp, ligne).eof())
// {
// dartNb++;
//
// std::stringstream oss(ligne);
// unsigned int beta0,beta1,beta2,beta3;
//
// //read involutions
// oss >> beta0;
// oss >> beta1;
// oss >> beta2;
// oss >> beta3;
//
// std::cout << "dart : " << dartNb << std::endl;
// std::cout<< "beta0 : " << beta0 << std::endl;
// std::cout << "beta1 : " << beta1 << std::endl;
// std::cout<< "beta2 : " << beta2 << std::endl;
// std::cout<< "beta3 : " << beta3 << std::endl;
//
// //ignore markers
// unsigned int tmp;
// oss >> tmp;
// oss >> tmp;
// oss >> tmp;
//
// //check if contains embedding
// unsigned int emb;
// oss >> emb;
//
// if(emb==1)
// {
// typename PFP::VEC3 pos;
// oss >> pos[0];
// oss >> pos[1];
// oss >> pos[2];
// }
// }
//
// fp.close();
// return true;
//}
template <typename PFP> template <typename PFP>
bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename, std::vector<std::string>& attrNames) bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename, std::vector<std::string>& attrNames)
{ {
...@@ -202,7 +285,7 @@ bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename, std::v ...@@ -202,7 +285,7 @@ bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename, std::v
// if (!fs.good()) // if (!fs.good())
// { // {
// CGoGNerr << "Unable to open file " << filename << CGoGNendl; // CGoGNerr << "Unable to open file " << filename << CGoGNendl;
// return false; return false;
// } // }
// // read nb of points // // read nb of points
// int nbp; // int nbp;
...@@ -253,7 +336,7 @@ bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename, std::v ...@@ -253,7 +336,7 @@ bool MeshTablesVolume<PFP>::importTrianBinGz(const std::string& filename, std::v
// } // }
// //
// fs.close(); // fs.close();
return true; // return true;
} }
template<typename PFP> template<typename PFP>
......
...@@ -353,7 +353,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv) ...@@ -353,7 +353,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
//ALGO //ALGO
// précondition // précondition
// indexer le tableau du nombre d'arrete par faces par le nombre de faces par volume // indexer le tableau du nombre d'arête par faces par le nombre de faces par volume
// //
//creation d'une sous-carte (2-carte) pour les faces d'un volume en fonction du nombre d'arete grace a un meshtableSurface //creation d'une sous-carte (2-carte) pour les faces d'un volume en fonction du nombre d'arete grace a un meshtableSurface
//avoir un tableau_de_sommets[nbsommets] indexe par les sommets dans lequel on comptera le nombre de fois qu'on a croisé un sommet //avoir un tableau_de_sommets[nbsommets] indexe par les sommets dans lequel on comptera le nombre de fois qu'on a croisé un sommet
...@@ -379,8 +379,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv) ...@@ -379,8 +379,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
unsigned int nbEdges = mtv.getNbEdgesFace(j); unsigned int nbEdges = mtv.getNbEdgesFace(j);
// std::vector<unsigned int> edgesBuffer; // std::vector<unsigned int> edgesBuffer;
// edgesBuffer.reserve(8); // edgesBuffer.reserve(8);
// //
...@@ -420,13 +418,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv) ...@@ -420,13 +418,6 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
} }
int index = 0; int index = 0;
// buffer for tempo faces (used to remove degenerated edges) // buffer for tempo faces (used to remove degenerated edges)
std::vector<unsigned int> edgesBuffer; std::vector<unsigned int> edgesBuffer;
......
...@@ -648,7 +648,7 @@ bool AttributeContainer::loadBin(CGoGNistream& fs) ...@@ -648,7 +648,7 @@ bool AttributeContainer::loadBin(CGoGNistream& fs)
if (bs != _BLOCKSIZE_) if (bs != _BLOCKSIZE_)
{ {
CGoGNerr << "Chargement impossible, tailles de block differentes: "<<_BLOCKSIZE_<<" / " << bs << CGoGNendl; CGoGNerr << "Loading unavailable, different block sizes: "<<_BLOCKSIZE_<<" / " << bs << CGoGNendl;
return false; return false;
} }
......
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