Commit 08553e53 authored by Lionel Untereiner's avatar Lionel Untereiner

import tet/hex meshes

parent 6acacc13
......@@ -29,6 +29,7 @@
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Import/import.h"
#include "Algo/Geometry/volume.h"
#include "Algo/Modelisation/tetrahedralization.h"
#include "Utils/chrono.h"
......@@ -455,6 +456,9 @@ int main(int argc, char **argv)
// Algo::Volume::Export::exportNAS<PFP>(myMap,position,"/tmp/test1.nas");
// Algo::Volume::Export::exportVTU<PFP>(myMap,position,"/tmp/test3.vtu");
}
myMap.check();
// un peu d'interface
QApplication app(argc, argv);
MyQT sqt;
......
......@@ -818,7 +818,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
//reconstruct neighbourhood
unsigned int nbBoundaryFaces = 0 ;
unsigned int nbFakeElements = 0;
//unsigned int nbFakeElements = 0;
std::vector<Dart> vFake;
vFake.reserve(1024);
for (Dart d = map.begin(); d != map.end(); map.next(d))
......@@ -830,8 +830,10 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
Dart good_dart = NIL;
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.phi1(map.phi1(d))))
if(map.template getEmbedding<VERTEX>(map.phi1(*it)) == map.template getEmbedding<VERTEX>(d)
// needed because several tetrahedra can have 2 identical vertices
&& ( map.template getEmbedding<VERTEX>(map.phi_1(*it)) == map.template getEmbedding<VERTEX>(map.phi1(map.phi1(d)))
|| map.template getEmbedding<VERTEX>(map.phi_1(*it)) == map.template getEmbedding<VERTEX>(map.phi_1(d))))
{
good_dart = *it ;
}
......@@ -846,7 +848,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
{
map.sewVolumes(d, good_dart, false);
m.template unmarkOrbit<FACE>(d);
}
}
else
{
// face of d is quad
......@@ -865,47 +867,99 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
}
}
std::cout << "is nil ? " << (another_good_dart == NIL) << std::endl;
//std::cout << "is nil ? " << (another_good_dart == NIL) << std::endl;
if(another_good_dart != NIL)
{
Dart dquad = createStampVolume<PFP>(map);
// Dart d1 = map.newFace(4, false);
// Dart d2 = map.newFace(3, false);
// Dart d3 = map.newFace(3, false);
// map.sewFaces(d1, d2, false);
//// map.template setOrbitEmbedding<VERTEX>(d1, map.template getEmbedding<VERTEX>(another_d)) ;
//// map.template setOrbitEmbedding<VERTEX>(d2, map.template getEmbedding<VERTEX>(map.phi1(d))) ;
// map.sewFaces(map.phi1(d1), map.phi_1(d2), false);
//// map.template setOrbitEmbedding<VERTEX>(map.phi1(d1), map.template getEmbedding<VERTEX>(map.phi1(d))) ;
//// map.template setOrbitEmbedding<VERTEX>(map.phi_1(d2), map.template getEmbedding<VERTEX>(d)) ;
// map.sewFaces(map.phi1(d2), d3, false);
//// map.template setOrbitEmbedding<VERTEX>(map.phi1(d2), map.template getEmbedding<VERTEX>(another_d)) ;
//// map.template setOrbitEmbedding<VERTEX>(d3, map.template getEmbedding<VERTEX>(d)) ;
// map.sewFaces(map.phi_1(d1), map.phi1(d3), false);
//// map.template setOrbitEmbedding<VERTEX>(map.phi_1(d1), map.template getEmbedding<VERTEX>(another_good_dart)) ;
//// map.template setOrbitEmbedding<VERTEX>(map.phi1(d3), map.template getEmbedding<VERTEX>(another_d)) ;
// map.sewFaces(map.phi1(map.phi1(d1)), map.phi_1(d3), false);
//// map.template setOrbitEmbedding<VERTEX>(map.phi1(map.phi1(d1)), map.template getEmbedding<VERTEX>(d)) ;
//// map.template setOrbitEmbedding<VERTEX>(map.phi_1(d3), map.template getEmbedding<VERTEX>(another_good_dart)) ;
map.sewVolumes(map.phi1(d), dquad, false);
map.sewVolumes(good_dart, d2, false);
map.sewVolumes(another_good_dart, map.phi_1(d3), false);
m.template unmarkOrbit<FACE>(d);
m.template unmarkOrbit<FACE>(good_dart);
m.template unmarkOrbit<FACE>(another_good_dart);
}
}
else
{
// face of d is tri
Dart another_good_dart = map.phi1(map.phi1(d));
std::vector<Dart>& vec = vecDartsPerVertex[another_good_dart];
Dart another_d = NIL;
for(typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && another_d == NIL; ++it)
{
if(map.template getEmbedding<VERTEX>(map.phi1(*it)) == map.template getEmbedding<VERTEX>(map.phi_1(another_good_dart)) &&
map.template getEmbedding<VERTEX>(map.phi1(map.phi1(*it))) == map.template getEmbedding<VERTEX>(map.phi1(another_good_dart)))
{
another_d = *it ;
}
}
//std::cout << "is nil ? " << (another_good_dart == NIL) << std::endl;
if(another_d != NIL)
{
Dart d1 = map.newFace(4, false);
Dart d2 = map.newFace(3, false);
Dart d3 = map.newFace(3, false);
map.sewFaces(d1, d2, false);
map.template setOrbitEmbedding<VERTEX>(d1, map.template getEmbedding<VERTEX>(another_d)) ;
map.template setOrbitEmbedding<VERTEX>(d2, map.template getEmbedding<VERTEX>(map.phi1(d))) ;
// map.template setOrbitEmbedding<VERTEX>(d1, map.template getEmbedding<VERTEX>(another_d)) ;
// map.template setOrbitEmbedding<VERTEX>(d2, map.template getEmbedding<VERTEX>(map.phi1(d))) ;
map.sewFaces(map.phi1(d1), map.phi_1(d2), false);
map.template setOrbitEmbedding<VERTEX>(map.phi1(d1), map.template getEmbedding<VERTEX>(map.phi1(d))) ;
map.template setOrbitEmbedding<VERTEX>(map.phi_1(d2), map.template getEmbedding<VERTEX>(d)) ;
// map.template setOrbitEmbedding<VERTEX>(map.phi1(d1), map.template getEmbedding<VERTEX>(map.phi1(d))) ;
// map.template setOrbitEmbedding<VERTEX>(map.phi_1(d2), map.template getEmbedding<VERTEX>(d)) ;
map.sewFaces(map.phi1(d2), d3, false);
map.template setOrbitEmbedding<VERTEX>(map.phi1(d2), map.template getEmbedding<VERTEX>(another_d)) ;
map.template setOrbitEmbedding<VERTEX>(d3, map.template getEmbedding<VERTEX>(d)) ;
// map.template setOrbitEmbedding<VERTEX>(map.phi1(d2), map.template getEmbedding<VERTEX>(another_d)) ;
// map.template setOrbitEmbedding<VERTEX>(d3, map.template getEmbedding<VERTEX>(d)) ;
map.sewFaces(map.phi_1(d1), map.phi1(d3), false);
map.template setOrbitEmbedding<VERTEX>(map.phi_1(d1), map.template getEmbedding<VERTEX>(another_good_dart)) ;
map.template setOrbitEmbedding<VERTEX>(map.phi1(d3), map.template getEmbedding<VERTEX>(another_d)) ;
// map.template setOrbitEmbedding<VERTEX>(map.phi_1(d1), map.template getEmbedding<VERTEX>(another_good_dart)) ;
// map.template setOrbitEmbedding<VERTEX>(map.phi1(d3), map.template getEmbedding<VERTEX>(another_d)) ;
map.sewFaces(map.phi1(map.phi1(d1)), map.phi_1(d3), false);
map.template setOrbitEmbedding<VERTEX>(map.phi1(map.phi1(d1)), map.template getEmbedding<VERTEX>(d)) ;
map.template setOrbitEmbedding<VERTEX>(map.phi_1(d3), map.template getEmbedding<VERTEX>(another_good_dart)) ;
// map.template setOrbitEmbedding<VERTEX>(map.phi1(map.phi1(d1)), map.template getEmbedding<VERTEX>(d)) ;
// map.template setOrbitEmbedding<VERTEX>(map.phi_1(d3), map.template getEmbedding<VERTEX>(another_good_dart)) ;
map.sewVolumes(map.phi1(d), d1, false);
map.sewVolumes(good_dart, d2, false);
map.sewVolumes(another_good_dart, map.phi_1(d3), false);
map.sewVolumes(d, d2, false);
//map.sewVolumes(another_d, d3, false);
map.sewVolumes(good_dart, d1, false);
m.template unmarkOrbit<FACE>(d);
m.template unmarkOrbit<FACE>(another_d);
m.template unmarkOrbit<FACE>(good_dart);
m.template unmarkOrbit<FACE>(another_good_dart);
}
}
else
{
//TODO
}
}
}
else
......@@ -925,6 +979,44 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
return true;
}
template <typename PFP>
Dart createStampVolume(typename PFP::MAP& map)
{
Dart dquad = map.newFace(4, false);
Dart dtri1 = map.newFace(3, false);
Dart dtri2 = map.newFace(3, false);
map.sewFaces(dtri1, dtri2, false);
map.sewFaces(map.phi1(dtri1), dquad, false);
map.sewFaces(map.phi_1(dtri1), map.phi_1(dquad), false);
map.sewFaces(map.phi1(dtri2), map.phi1(map.phi1(dquad)), false);
map.sewFaces(map.phi_1(dtri2), map.phi1(dquad), false);
return dquad;
// map.template setOrbitEmbedding<VERTEX>(d1, map.template getEmbedding<VERTEX>(another_d)) ;
// map.template setOrbitEmbedding<VERTEX>(d2, map.template getEmbedding<VERTEX>(map.phi1(d))) ;
// map.sewFaces(map.phi1(d1), map.phi_1(d2), false);
// map.template setOrbitEmbedding<VERTEX>(map.phi1(d1), map.template getEmbedding<VERTEX>(map.phi1(d))) ;
// map.template setOrbitEmbedding<VERTEX>(map.phi_1(d2), map.template getEmbedding<VERTEX>(d)) ;
// map.sewFaces(map.phi1(d2), d3, false);
// map.template setOrbitEmbedding<VERTEX>(map.phi1(d2), map.template getEmbedding<VERTEX>(another_d)) ;
// map.template setOrbitEmbedding<VERTEX>(d3, map.template getEmbedding<VERTEX>(d)) ;
// map.sewFaces(map.phi_1(d1), map.phi1(d3), false);
// map.template setOrbitEmbedding<VERTEX>(map.phi_1(d1), map.template getEmbedding<VERTEX>(another_good_dart)) ;
// map.template setOrbitEmbedding<VERTEX>(map.phi1(d3), map.template getEmbedding<VERTEX>(another_d)) ;
// map.sewFaces(map.phi1(map.phi1(d1)), map.phi_1(d3), false);
// map.template setOrbitEmbedding<VERTEX>(map.phi1(map.phi1(d1)), map.template getEmbedding<VERTEX>(d)) ;
// map.template setOrbitEmbedding<VERTEX>(map.phi_1(d3), map.template getEmbedding<VERTEX>(another_good_dart)) ;
}
template <typename PFP>
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, bool mergeCloseVertices)
{
......
......@@ -136,6 +136,8 @@ bool isPyra(typename PFP::MAP& map, Dart d, unsigned int thread = 0);
template <typename PFP>
bool isPrism(typename PFP::MAP& map, Dart d, unsigned int thread = 0);
template <typename PFP>
bool isHexahedron(typename PFP::MAP& the_map, Dart d, unsigned int thread=0);
template <typename PFP>
Dart embedPrism(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position, unsigned int n, bool withBoundary, float bottom_radius, float top_radius, float height);
......
......@@ -415,6 +415,27 @@ bool isPrism(typename PFP::MAP& map, Dart d, unsigned int thread)
return true;
}
template <typename PFP>
bool isHexahedron(typename PFP::MAP& the_map, Dart d, unsigned int thread)
{
unsigned int nbFaces = 0;
//Test the number of faces end its valency
Traversor3WF<typename PFP::MAP> travWF(the_map, d, false, thread);
for(Dart dit = travWF.begin() ; dit != travWF.end(); dit = travWF.next())
{
//increase the number of faces
nbFaces++;
if(nbFaces > 6) //too much faces
return false;
//test the valency of this face
if(the_map.faceDegree(dit) != 4)
return false;
}
return true;
}
template <typename PFP>
void explodPolyhedron(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& position)
......
......@@ -42,9 +42,6 @@ namespace Volume
namespace Modelisation
{
template <typename PFP>
bool isHexahedron(typename PFP::MAP& the_map, Dart d, unsigned int thread=0);
/**
* Cut a 3D ear from a mesh : the ear is sewn by phi3 to the rest of the volume
* @param d dart of the point of the ear
......
......@@ -42,28 +42,6 @@ namespace Volume
namespace Modelisation
{
template <typename PFP>
bool isHexahedron(typename PFP::MAP& the_map, Dart d, unsigned int thread)
{
unsigned int nbFaces = 0;
//Test the number of faces end its valency
Traversor3WF<typename PFP::MAP> travWF(the_map, d, false, thread);
for(Dart dit = travWF.begin() ; dit != travWF.end(); dit = travWF.next())
{
//increase the number of faces
nbFaces++;
if(nbFaces > 6) //too much faces
return false;
//test the valency of this face
if(the_map.faceDegree(dit) != 4)
return false;
}
return true;
}
template <typename PFP>
Dart cut3Ear(typename PFP::MAP& map, Dart d)
{
......
......@@ -470,7 +470,7 @@ Dart splitVertex(typename PFP::MAP& map, std::vector<Dart>& vd)
*************************************************************************************************/
template <typename PFP>
bool isTetrahedron(typename PFP::MAP& map, Vol v, unsigned int thread)
bool isTetrahedron(typename PFP::MAP& map, Dart v, unsigned int thread)
{
unsigned int nbFaces = 0;
......
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