Commit 751b9077 authored by Lionel Untereiner's avatar Lionel Untereiner

import mesh for mixed hex/tet meshes

parent 08553e53
......@@ -177,8 +177,8 @@ void MyQT::cb_Open()
// if (v>maxV)
// maxV=v;
if(myMap.isVolumeIncidentToBoundary(d))
color[d] = PFP::VEC3(0,0,0);
//if(myMap.isVolumeIncidentToBoundary(d))
// color[d] = PFP::VEC3(0,0,0);
}
// for (unsigned int i = color.begin(); i != color.end(); color.next(i))
// {
......@@ -423,7 +423,7 @@ int main(int argc, char **argv)
// maxV=v;
if(myMap.isVolumeIncidentToBoundary(d))
color[d] = PFP::VEC3(0,0,0);
color[d] = PFP::VEC3(1,0.41,0.706);
//else
// color[d] = PFP::VEC3(1.0,0,0);
}
......
......@@ -550,6 +550,21 @@ bool importMeshSurfToVol(typename PFP::MAP& map, Surface::Import::MeshTablesSurf
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), map.phi_1(dquad), false);
map.sewFaces(map.phi_1(dtri2), dquad, false);
map.sewFaces(map.phi1(dtri2), map.phi1(dquad), false);
map.sewFaces(map.phi_1(dtri1), map.phi1(map.phi1(dquad)), false);
return dquad;
}
template <typename PFP>
bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
......@@ -577,6 +592,22 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
// store volume in buffer, removing degenated faces
unsigned int nbf = mtv.getNbFacesVolume(i);
if(nbf == 3)
{
edgesBuffer.clear();
unsigned int prec = EMBNULL;
for (unsigned int j = 0; j < nbf+1; ++j)
{
unsigned int em = mtv.getEmbIdx(index++);
if (em != prec)
{
prec = em;
edgesBuffer.push_back(em);
}
}
}
else
{
edgesBuffer.clear();
unsigned int prec = EMBNULL;
for (unsigned int j = 0; j < nbf; ++j)
......@@ -588,8 +619,48 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
edgesBuffer.push_back(em);
}
}
}
if(nbf == 4) //tetrahedral case
if(nbf == 3) //connector case
{
Dart d = createStampVolume<PFP>(map);
//Embed four vertices
// 1.
vemb = edgesBuffer[0]; // get embedding
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
Dart dd = d;
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);
// 2.
d = map.phi1(d);
vemb = edgesBuffer[1];
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);
// 3.
d = map.phi1(d);
vemb = edgesBuffer[2];
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);
// 4.
d = map.phi1(d);
vemb = edgesBuffer[3];
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
dd = d;
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);
}
else if(nbf == 4) //tetrahedral case
{
Dart d = Surface::Modelisation::createTetrahedron<PFP>(map,false);
......@@ -676,8 +747,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd); dd = map.phi1(map.phi2(dd));
vecDartsPerVertex[vemb].push_back(dd); m.mark(dd);
}
else
if(nbf == 6) //prism case
else if(nbf == 6) //prism case
{
Dart d = Surface::Modelisation::createTriangularPrism<PFP>(map,false);
......@@ -814,8 +884,65 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
}
std ::cout << " elements created " << std::endl;
std::cout << " elements created " << std::endl;
//reconstruct neighbourhood
unsigned int nbBoundaryFaces = 0 ;
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (m.isMarked(d))
{
std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];
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))))
{
good_dart = *it ;
}
}
if (good_dart != NIL)
{
unsigned int degD = map.faceDegree(d);
unsigned int degGD = map.faceDegree(good_dart);
//std::cout << "degD = " << degD << " et degGD = " << degGD << std::endl;
if(degD == degGD)
{
map.sewVolumes(d, good_dart, false);
m.template unmarkOrbit<FACE>(d);
}
// else
// std::cout << "erreur : degD != degGD" << std::endl;
}
else
{
m.template unmarkOrbit<PFP::MAP::FACE_OF_PARENT>(d);
++nbBoundaryFaces;
}
}
}
/*
//reconstruct neighbourhood
unsigned int nbBoundaryFaces = 0 ;
//unsigned int nbFakeElements = 0;
......@@ -871,7 +998,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
if(another_good_dart != NIL)
{
Dart dquad = createStampVolume<PFP>(map);
//Dart dquad = createStampVolume<PFP>(map);
// Dart d1 = map.newFace(4, false);
// Dart d2 = map.newFace(3, false);
......@@ -897,13 +1024,13 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
//// 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);
// 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);
// m.template unmarkOrbit<FACE>(d);
// m.template unmarkOrbit<FACE>(good_dart);
// m.template unmarkOrbit<FACE>(another_good_dart);
}
}
else
......@@ -969,6 +1096,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
}
}
}
*/
if (nbBoundaryFaces > 0)
{
......@@ -979,44 +1107,6 @@ 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)
{
......
......@@ -190,6 +190,8 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<s
m_nbFaces.reserve(m_nbVolumes*4);
m_emb.reserve(m_nbVolumes*12);
unsigned int nbc = 0;
for (unsigned int i = 0; i < m_nbVolumes ; ++i)
{
do
......@@ -201,8 +203,35 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<s
int n;
oss >> n; // type of volumes
if(!oss.good())
{
oss.clear();
char dummy;
oss >> dummy; // type of volumes
oss >> dummy;
if(dummy == 'C')// connector
{
++nbc;
m_nbFaces.push_back(3);
int s0,s1,s2,s3;
oss >> s0;
oss >> s1;
oss >> s2;
oss >> s3;
//std::cout << "connector " << s0 << " " << s1 << " " << s2 << " " << s3 << std::endl;
m_emb.push_back(verticesID[s0]);
m_emb.push_back(verticesID[s1]);
m_emb.push_back(verticesID[s2]);
m_emb.push_back(verticesID[s3]);
}
}
//tetrahedron
if(n == 4)
else if(n == 4)
{
m_nbFaces.push_back(4);
......@@ -218,7 +247,7 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<s
typename PFP::VEC3 B = position[verticesID[s2]];
typename PFP::VEC3 C = position[verticesID[s3]];
if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::UNDER)
if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::OVER)
{
int ui = s1;
s1 = s2;
......@@ -340,7 +369,7 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<s
typename PFP::VEC3 C = position[verticesID[s2]];
// 1 hexa ok avec cette partie
if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::UNDER)
if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::OVER)
{
unsigned int pt[8];
pt[0] = s0;
......@@ -371,9 +400,10 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<s
m_emb.push_back(verticesID[s6]);
m_emb.push_back(verticesID[s7]);
}
}
std::cout << "#connectors = " << nbc << std::endl;
fp.close();
return true;
}
......
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