Commit 02b8e252 authored by untereiner's avatar untereiner

new polyhedron embedding function / pb with border deleting in map3

parent a55f60bf
......@@ -350,6 +350,8 @@ public:
*/
void embedCube(float sx, float sy, float sz);
void embedCube(VEC3 origin, float sx, float sy, float sz);
/**
* embed the a grid into a twister open ribbon
* with turns=PI it is a Moebius strip, needs only to be closed (if model allow it)
......
......@@ -928,6 +928,70 @@ void Polyhedron<PFP>::embedCube(float sx, float sy, float sz)
}
}
template <typename PFP>
void Polyhedron<PFP>::embedCube(VEC3 origin, float sx, float sy, float sz)
{
typedef typename PFP::VEC3 VEC3 ;
if (m_kind != CUBE)
{
CGoGNerr << "Warning try to embedCube something that is not a cube"<<CGoGNendl;
return;
}
float dz = sz/float(m_nz);
float dy = sy/float(m_ny);
float dx = sx/float(m_nx);
// first embedding the sides
int index = 0;
for (unsigned int k = 0; k <= m_nz; ++k)
{
float z = float(k)*dz - sz/2.0f;
for (unsigned int i = 0; i < m_nx; ++i)
{
float x = float(i)*dx - sx/2.0f;
m_positions[ m_tableVertDarts[ index++ ] ] = origin + VEC3(x, -sy/2.0f, z);
}
for (unsigned int i = 0; i < m_ny; ++i)
{
float y = float(i)*dy - sy/2.0f;
m_positions[ m_tableVertDarts[ index++ ] ] = origin + VEC3(sx/2.0f, y, z);
}
for (unsigned int i = 0; i < m_nx; ++i)
{
float x = sx/2.0f-float(i)*dx;
m_positions[ m_tableVertDarts[ index++ ] ] = origin + VEC3(x, sy/2.0f, z);
}
for (unsigned int i = 0; i < m_ny ;++i)
{
float y = sy/2.0f - float(i)*dy;
m_positions[ m_tableVertDarts[ index++ ] ] = origin + VEC3(-sx/2.0f, y, z);
}
}
// the top
for(unsigned int i = 1; i <m_ny; ++i)
{
for(unsigned int j = 1; j < m_nx; ++j)
{
VEC3 pos(-sx/2.0f+float(j)*dx, -sy/2.0f+float(i)*dy, sz/2.0f);
m_positions[ m_tableVertDarts[ index++ ] ] = origin + pos;
}
}
// the bottom
for(unsigned int i = 1; i < m_ny; ++i)
{
for(unsigned int j = 1; j < m_nx; ++j)
{
VEC3 pos(-sx/2.0f+float(j)*dx, sy/2.0f-float(i)*dy, -sz/2.0f);
m_positions[ m_tableVertDarts[ index++ ] ] = origin + pos;
}
}
}
template <typename PFP>
void Polyhedron<PFP>::computeCenter()
{
......
......@@ -147,7 +147,7 @@ Dart Primitive3D<PFP>::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned
m_tableVertDarts.push_back(dd);
}
m_map.closeMap() ;
std::cout << m_map.closeMap() << std::endl;
return d0;
}
......
......@@ -99,11 +99,6 @@ public:
m_map.decCurrentLevel() ;
}
}
void operator() (bool filtering)
{
}
};
// Tri/quad refinement
......@@ -161,11 +156,6 @@ public:
m_map.decCurrentLevel() ;
}
}
void operator() (bool filtering)
{
}
};
/*********************************************************************************
......@@ -224,11 +214,6 @@ public:
m_map.decCurrentLevel() ;
}
}
void operator() (bool filtering)
{
}
};
// Tri/quad refinement
......@@ -286,11 +271,6 @@ public:
}
}
}
void operator() (bool filtering)
{
}
};
} // namespace Filters
......
......@@ -55,59 +55,202 @@ namespace Filters
template <typename PFP>
class LerpOddSynthesisFilter : public Filter
class LerpQuadOddSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
public:
LerpOddSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
LerpQuadOddSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorW<typename PFP::MAP> travW(m_map) ;
for (Dart d = travW.begin(); d != travW.end(); d = travW.next())
{
typename PFP::VEC3 vc = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
unsigned int count = 0;
typename PFP::VEC3 ec(0.0);
Traversor3WE<typename PFP::MAP> travWE(m_map, d);
for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next())
{
m_map.incCurrentLevel();
ec += m_position[m_map.phi1(dit)];
m_map.decCurrentLevel();
++count;
}
ec /= count;
ec *= 3;
count = 0;
typename PFP::VEC3 fc(0.0);
Traversor3WF<typename PFP::MAP> travWF(m_map, d);
for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next())
{
m_map.incCurrentLevel();
fc += m_position[m_map.phi1(m_map.phi1(dit))];
m_map.decCurrentLevel();
++count;
}
fc /= count;
fc *= 3;
m_map.incCurrentLevel() ;
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d)));
if(m_position[midV] != typename PFP::VEC3(0.0f,0.0f,0.0f))
{
std::cout << "position[midV] = " << m_position[midV] << std::endl;
}
else
m_position[midV] += vc + ec + fc;
m_map.decCurrentLevel() ;
}
TraversorF<typename PFP::MAP> travF(m_map) ;
for (Dart d = travF.begin(); d != travF.end(); d = travF.next())
{
typename PFP::VEC3 vf(0.0);
typename PFP::VEC3 ef(0.0);
unsigned int count = 0;
Traversor3FE<typename PFP::MAP> travFE(m_map, d);
for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next())
{
vf += m_position[dit];
m_map.incCurrentLevel();
ef += m_position[m_map.phi1(dit)];
m_map.decCurrentLevel();
++count;
}
ef /= count;
ef *= 2.0;
vf /= count;
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(m_map.phi1(d));
if(m_position[midF] != typename PFP::VEC3(0.0f,0.0f,0.0f))
{
std::cout << "position[midF] = " << m_position[midF] << std::endl;
//m_position[midF] = vf + ef ;
}
else
m_position[midF] += vf + ef ;
m_map.decCurrentLevel() ;
}
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
typename PFP::VEC3 p = (m_position[d] + m_position[m_map.phi2(d)]) * typename PFP::REAL(0.5);
typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5);
m_map.incCurrentLevel() ;
Dart midE = m_map.phi1(d) ;
if(m_position[midE] != typename PFP::VEC3(0.0f,0.0f,0.0f))
{
std::cout << "position[midE] = " << m_position[midE] << std::endl;
//m_position[midE] = ve;
}
else
m_position[midE] += ve;
m_map.decCurrentLevel() ;
}
}
};
Dart midV = m_map.phi2(d) ;
m_position[midV] += p ;
template <typename PFP>
class LerpQuadOddAnalysisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
public:
LerpQuadOddAnalysisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorE<typename PFP::MAP> travE(m_map) ;
for (Dart d = travE.begin(); d != travE.end(); d = travE.next())
{
typename PFP::VEC3 ve = (m_position[d] + m_position[m_map.phi1(d)]) * typename PFP::REAL(0.5);
m_map.incCurrentLevel() ;
Dart midE = m_map.phi1(d) ;
m_position[midE] -= ve;
m_map.decCurrentLevel() ;
}
TraversorF<typename PFP::MAP> travF(m_map) ;
for (Dart d = travF.begin(); d != travF.end(); d = travF.next())
{
typename PFP::VEC3 p = Algo::Geometry::faceCentroid<PFP>(m_map, d, m_position);
typename PFP::VEC3 vf(0.0);
typename PFP::VEC3 ef(0.0);
m_map.incCurrentLevel() ;
unsigned int count = 0;
Traversor3FE<typename PFP::MAP> travFE(m_map, d);
for (Dart dit = travFE.begin(); dit != travFE.end(); dit = travFE.next())
{
vf += m_position[dit];
m_map.incCurrentLevel();
ef += m_position[m_map.phi1(dit)];
m_map.decCurrentLevel();
++count;
}
ef /= count;
ef *= 2.0;
Dart midF = m_map.phi2(m_map.phi1(d));
m_position[midF] += p ;
vf /= count;
m_map.incCurrentLevel() ;
Dart midF = m_map.phi1(m_map.phi1(d));
m_position[midF] -= vf;// + ef ;
m_map.decCurrentLevel() ;
}
TraversorW<typename PFP::MAP> travW(m_map) ;
for (Dart d = travW.begin(); d != travW.end(); d = travW.next())
{
if(!Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d) && !Algo::Modelisation::isPrism<PFP>(m_map,d) && !Algo::Modelisation::isPyra<PFP>(m_map,d))
{
typename PFP::VEC3 p = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
typename PFP::VEC3 vc = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
m_map.incCurrentLevel() ;
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d)));
m_position[midV] += p ;
unsigned int count = 0;
typename PFP::VEC3 ec(0.0);
Traversor3WE<typename PFP::MAP> travWE(m_map, d);
for (Dart dit = travWE.begin(); dit != travWE.end(); dit = travWE.next())
{
m_map.incCurrentLevel();
ec += m_position[m_map.phi1(dit)];
m_map.decCurrentLevel();
++count;
}
ec /= count;
ec *= 3;//12 * m_a * m_a;
m_map.decCurrentLevel() ;
count = 0;
typename PFP::VEC3 fc(0.0);
Traversor3WF<typename PFP::MAP> travWF(m_map, d);
for (Dart dit = travWF.begin(); dit != travWF.end(); dit = travWF.next())
{
m_map.incCurrentLevel();
fc += m_position[m_map.phi1(m_map.phi1(dit))];
m_map.decCurrentLevel();
++count;
}
fc /= count;
fc *= 3;//6 * m_a;
m_map.incCurrentLevel() ;
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d)));
m_position[midV] -= vc;// + ec + fc;
m_map.decCurrentLevel() ;
}
}
......@@ -115,6 +258,19 @@ public:
template <typename PFP>
class LerpEdgeSynthesisFilter : public Filter
{
......@@ -220,8 +376,8 @@ public:
TraversorW<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
if(!Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d) && !Algo::Modelisation::isPrism<PFP>(m_map,d) && !Algo::Modelisation::isPyra<PFP>(m_map,d))
{
//if(!Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d) && !Algo::Modelisation::isPrism<PFP>(m_map,d) && !Algo::Modelisation::isPyra<PFP>(m_map,d))
//{
typename PFP::VEC3 p = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
m_map.incCurrentLevel() ;
......@@ -230,7 +386,7 @@ public:
m_position[midV] = p ;
m_map.decCurrentLevel() ;
}
//}
}
}
} ;
......
......@@ -81,37 +81,44 @@ void Map3::compactTopoRelations(const std::vector<unsigned int>& oldnew)
void Map3::deleteVolume(Dart d)
{
DartMarkerStore mark(*this); // Lock a marker
std::vector<Dart> visitedFaces; // Faces that are traversed
visitedFaces.reserve(512);
visitedFaces.push_back(d); // Start with the face of d
mark.markOrbit<FACE2>(d) ;
// DartMarkerStore mark(*this); // Lock a marker
//
// std::vector<Dart> visitedFaces; // Faces that are traversed
// visitedFaces.reserve(512);
// visitedFaces.push_back(d); // Start with the face of d
//
// mark.markOrbit<FACE2>(d) ;
//
//
// for(unsigned int i = 0; i < visitedFaces.size(); ++i)
// {
// Dart e = visitedFaces[i] ;
//
// if(!isBoundaryFace(e))
// unsewVolumes(e) ;
//
// do // add all face neighbours to the table
// {
// Dart ee = phi2(e) ;
// if(!mark.isMarked(ee)) // not already marked
// {
// visitedFaces.push_back(ee) ;
// mark.markOrbit<FACE2>(ee) ;
// }
// e = phi1(e) ;
// } while(e != visitedFaces[i]) ;
// }
for(unsigned int i = 0; i < visitedFaces.size(); ++i)
Traversor3WF<Map3> tWF(*this,d);
for(Dart dit = tWF.begin() ; dit != tWF.end() ; dit = tWF.next())
{
Dart e = visitedFaces[i] ;
if(!isBoundaryFace(e))
unsewVolumes(e) ;
do // add all face neighbours to the table
{
Dart ee = phi2(e) ;
if(!mark.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mark.markOrbit<FACE2>(ee) ;
}
e = phi1(e) ;
} while(e != visitedFaces[i]) ;
if(!isBoundaryFace(dit))
unsewVolumes(dit) ;
}
Dart dd = phi3(d) ;
Map2::deleteCC(d) ; //deleting the volume
Map2::deleteCC(dd) ; //deleting its border (created from the unsew operation)
// Map2::deleteCC(dd) ; //deleting its border (created from the unsew operation)
}
void Map3::fillHole(Dart d)
......
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