diff --git a/include/Algo/Modelisation/polyhedron.hpp b/include/Algo/Modelisation/polyhedron.hpp index 847e823e2db2cf85ff4e7c5e8ab2d0565a60e166..7e37e47cddd1addde48eb0a6b412874f71aa8e26 100644 --- a/include/Algo/Modelisation/polyhedron.hpp +++ b/include/Algo/Modelisation/polyhedron.hpp @@ -134,22 +134,55 @@ Dart createPrism(typename PFP::MAP& map, unsigned int n) template Dart createDiamond(typename PFP::MAP& map, unsigned int nbSides) { + Dart dres = Dart::nil(); + std::vector m_tableVertDarts; + + + unsigned int nbt = 2*nbSides -1 ; // -1 for computation optimization + m_tableVertDarts.reserve(n); + + + // creation of triangles around circunference and storing vertices + for (unsigned int i = 0; i <= nbt; ++i) + { + Dart d = map.newFace(3, false); + m_tableVertDarts.push_back(d); + } -// TODO A REFAIRE + // sewing the triangles + for (unsigned int i = 0; i < nbSides-1; ++i) + { + Dart d = m_tableVertDarts[i]; + d = map.phi_1(d); + Dart e = m_tableVertDarts[i+1]; + e = map.phi1(e); + map.sewFaces(d, e, false); + } + //sewing the last with the first + map.sewFaces(map.phi1(m_tableVertDarts[0]), map.phi_1(m_tableVertDarts[nbSides-1]), false); -// Dart res = Dart::nil(); -// -// Dart firstP = createPyramid(map,nbSides); -// Dart secondP = createPyramid(map,nbSides); -// -// res = map.phi2(firstP); -// -// map.sewVolumes(firstP, secondP); -// //map.mergeVolumes(firstP); -// -// return res; -} + for (unsigned int i = nbSides; i <= nbt; ++i) + { + Dart d = m_tableVertDarts[i]; + d = map.phi_1(d); + Dart e = m_tableVertDarts[i+1]; + e = map.phi1(e); + map.sewFaces(d, e, false); + } + //sewing the last with the first + map.sewFaces(map.phi1(m_tableVertDarts[nbSides]), map.phi_1(m_tableVertDarts[nbt]), false); + + + //sewing the the two opened pyramids together + for(unsigned int i = 0; i < nbSides ; ++i) + { + map.sewFaces(m_tableVertDarts[i], m_tableVertDarts[nbt-i], false); + d1 = map.phi1(d1); + } + //return a dart from the base + return m_tableVertDarts[0]; +} /**