Commit db1e08e4 authored by Lionel Untereiner's avatar Lionel Untereiner

uniformisation import volumique suite

parent 0a0477b6
......@@ -145,8 +145,8 @@ void MyQT::cb_Open()
std::vector<std::string> attrNames ;
//size_t pos = filename.rfind("."); // position of "." in filename
//std::string extension = filename.substr(pos);
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
// if(extension == std::string(".off"))
// {
......@@ -161,8 +161,19 @@ void MyQT::cb_Open()
// myMap.closeMap();
// }
// }
// else
// {
/*
if(extension == std::string(".msh"))
{
if(!Algo::Volume::Import::importMSH<PFP>(myMap,filename, attrNames))
{
std::cerr << "could not import " << filename << std::endl ;
return;
}
else
position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]);
}
else
{*/
if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
{
std::cerr << "could not import " << filename << std::endl ;
......@@ -170,7 +181,7 @@ void MyQT::cb_Open()
}
else
position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]) ;
// }
//}
color = myMap.addAttribute<PFP::VEC3, VOLUME>("color");
......@@ -387,8 +398,8 @@ int main(int argc, char **argv)
{
std::vector<std::string> attrNames ;
std::string filename(argv[1]);
// size_t pos = filename.rfind("."); // position of "." in filename
// std::string extension = filename.substr(pos);
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
/*
if(extension == std::string(".off"))
{
......@@ -405,14 +416,28 @@ int main(int argc, char **argv)
}
else
{
*/ if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
if(extension == std::string(".nas"))
{
if(!Algo::Volume::Import::importNAS<PFP>(myMap,filename, attrNames))
{
std::cerr << "could not import " << filename << std::endl ;
return 1;
}
else
position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]);
}
else
{
*/
if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
{
std::cerr << "could not import " << filename << std::endl ;
return 1;
}
else
position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]) ;
// }
//}
color = myMap.addAttribute<PFP::VEC3, VOLUME>("color");
......
......@@ -236,7 +236,7 @@ void MyQT::triangularTiling(int code)
case 1:
{
std::cout << "triangle grid tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,10,6,true);
Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,1,5,true);
g.embedIntoGrid(position,1,1);
break;
......@@ -319,6 +319,96 @@ void MyQT::triangularTiling(int code)
}
}
void MyQT::hexagonalTiling(int code)
{
switch(code)
{
case 1:
{
std::cout << "hexagonal grid tiling" << std::endl;
Algo::Surface::Tilings::Hexagonal::Grid<PFP> g(myMap,10,6,true);
g.embedIntoGrid(position,1,1);
break;
}
case 2:
{
// std::cout << "hexagonal grid twisted strip tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,10,10,true);
// g.embedIntoTwistedStrip(position, 0.3, 0.8, 5);
break;
}
case 3:
{
// std::cout << "hexagonal grid helocoid tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,20,20,true);
// g.embedIntoHelicoid(position, 0.3, 0.8, 5.0, 2.0);
break;
}
case 4:
{
// std::cout << "hexagonal cylinder tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
// c.embedIntoCylinder(position,0.5,0.7,5.0);
break;
}
case 5:
{
// std::cout << "hexagonal cylinder tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
// c.triangleBottom();
// c.triangleTop();
// c.embedIntoCylinder(position,0.5,0.7,5.0);
break;
}
case 6:
{
// std::cout << "hexagonal cylinder sphere tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
// c.triangleTop();
// c.triangleBottom();
// c.embedIntoSphere(position,0.5);
break;
}
case 7:
{
// std::cout << "hexagonal cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
// c.triangleTop();
// c.triangleBottom();
// c.embedIntoCone(position,0.5, 5.0);
break;
}
case 8:
{
// std::cout << "hexagonal cube tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Cube<PFP> c(myMap,4,4,4);
// c.embedIntoCube(position,5.0,5.0, 5.0);
break;
}
case 9:
{
// std::cout << "hexagonal tore tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Tore<PFP> c(myMap,20,10);
// c.embedIntoTore(position,5.0,2.0);
break;
}
default:
{
break;
}
}
}
int main(int argc, char **argv)
{
// interface:
......@@ -340,6 +430,10 @@ int main(int argc, char **argv)
sqt.squareTiling(atoi(argv[2]));
else if(argv[1][0] == 'T')
sqt.triangularTiling(atoi(argv[2]));
else if(argv[1][0] == 'H')
sqt.hexagonalTiling(atoi(argv[2]));
else
return -1;
}
myMap.check();
......
......@@ -43,7 +43,7 @@
#include "Algo/Tiling/Surface/square.h"
#include "Algo/Tiling/Surface/triangular.h"
#include "Algo/Tiling/Surface/hexagonal.h"
// forward definitions (minimize includes)
namespace CGoGN { namespace Algo { namespace Render { namespace GL1 { class MapRender; } } } }
......@@ -79,8 +79,8 @@ public:
{}
void squareTiling(int code);
void triangularTiling(int code);
void hexagonalTiling(int code);
protected:
......
......@@ -118,8 +118,8 @@ bool importMeshSAsV(typename PFP::MAP& map, const std::string& filename, std::ve
* TODO ADD TO MeshTablesVolume
*/
template <typename PFP>
bool importMSH(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
//template <typename PFP>
//bool importMSH(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
template <typename PFP>
bool importVTU(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
......@@ -144,7 +144,7 @@ bool importVBGZ(typename PFP::MAP& the_map, const std::string& filename, std::ve
#include "Algo/Import/importChoupi.hpp"
#include "Algo/Import/importMSH.hpp"
//#include "Algo/Import/importMSH.hpp"
#include "Algo/Import/importVTU.hpp"
#include "Algo/Import/importNAS.hpp"
#include "Algo/Import/importVBGZ.hpp"
......
......@@ -536,7 +536,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, "incidents");
unsigned int nbv = mtv.getNbVolumes();
int index = 0;
unsigned int index = 0;
// buffer for tempo faces (used to remove degenerated edges)
std::vector<unsigned int> edgesBuffer;
edgesBuffer.reserve(16);
......@@ -602,7 +602,125 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
} while(dd != d);
}
else if(nbf == 6) //hexahedral case
else if(nbf == 5) //pyramidal case
{
Dart d = Surface::Modelisation::createQuadrangularPyramid<PFP>(map,false);
// 1.
unsigned int em = edgesBuffer[0]; // get embedding
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
Dart dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
// 2.
d = map.phi1(d);
em = edgesBuffer[1];
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
// 3.
d = map.phi1(d);
em = edgesBuffer[2];
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
// 4.
d = map.phi1(d);
em = edgesBuffer[3];
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
// 5.
d = map.phi_1(map.phi2(d));
em = edgesBuffer[4];
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
}
else if(nbf == 6) //prism case
{
Dart d = Surface::Modelisation::createTriangularPrism<PFP>(map,false);
// 1.
unsigned int em = edgesBuffer[0]; // get embedding
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
Dart dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
// 2.
d = map.phi1(d);
em = edgesBuffer[1];
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
// 3.
d = map.phi1(d);
em = edgesBuffer[2];
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
// 5.
d = map.template phi<2112>(d);
em = edgesBuffer[3];
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
// 6.
d = map.phi_1(d);
em = edgesBuffer[4];
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
// 7.
d = map.phi_1(d);
em = edgesBuffer[5];
fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[em].push_back(dd); m.mark(dd);
}
else if(nbf == 8) //hexahedral case
{
Dart d = Surface::Modelisation::createHexahedron<PFP>(map,false);
......@@ -688,7 +806,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
} //end of hexa
}
std::cout << " elements created " << std::endl;
//reconstruct neighbourhood
unsigned int nbBoundaryFaces = 0 ;
for (Dart d = map.begin(); d != map.end(); map.next(d))
......@@ -701,7 +819,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
for(typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{
if(map.template getEmbedding<VERTEX>(map.phi1(*it)) == map.template getEmbedding<VERTEX>(d) &&
map.template getEmbedding<VERTEX>(map.phi_1(*it)) == map.template getEmbedding<VERTEX>(map.phi_1(d)))
map.template getEmbedding<VERTEX>(map.phi_1(*it)) == map.template getEmbedding<VERTEX>(map.phi1(map.phi1(d))))
{
good_dart = *it ;
}
......
......@@ -189,7 +189,7 @@ private:
bool importTs(const std::string& filename, std::vector<std::string>& attrNames);
//
//TODO Hexahedra : not working yet
bool importMSH(const std::string& filename, std::vector<std::string>& attrNames);
......
This diff is collapsed.
......@@ -54,17 +54,20 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
{
for (unsigned int j = 1; j <= x; ++j)
{
Dart d = this->m_map.newFace(3, false);
Dart d = this->m_map.newFace(6, false);
this->m_tableVertDarts.push_back(d);
this->m_tableVertDarts.push_back(this->m_map.phi1(d));
if (j== 1)
this->m_tableVertDarts.push_back(this->m_map.phi_1(d));
if (j == x)
this->m_tableVertDarts.push_back(this->m_map.phi1(d));
this->m_tableVertDarts.push_back(this->m_map.phi1(this->m_map.phi1(d)));
}
}
// store last row of vertices
for (unsigned int i = 0; i < x; ++i)
{
//this->m_tableVertDarts.push_back(this->m_map.phi_1(this->m_tableVertDarts[(y-1)*(x+1) + i]) );
this->m_tableVertDarts.push_back(this->m_map.phi_1(this->m_tableVertDarts[(y-1)*(x+1) + i]) );
}
//this-> m_tableVertDarts.push_back(this->m_map.phi1(this->m_tableVertDarts[(y-1)*(x+1) +x]) );
......
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