Commit 869a9658 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' of icube-forge.unistra.fr:cgogn/cgogn into develop

parents f6eda487 49adae74
......@@ -74,9 +74,15 @@ typename PFP::REAL vertexBarycentricArea(typename PFP::MAP& map, Vertex v, const
template <typename PFP>
typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Vertex v, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position) ;
template <typename PFP>
typename PFP::REAL edgeArea(typename PFP::MAP& map, Edge e, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
template <typename PFP>
void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, FaceAttribute<typename PFP::REAL, typename PFP::MAP>& face_area) ;
template <typename PFP>
void computeAreaEdges(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edge_area);
template <typename PFP>
void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP>& vertex_area) ;
......@@ -88,9 +94,16 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
namespace Parallel
{
template <typename PFP>
typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position) ;
template <typename PFP>
void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, FaceAttribute<typename PFP::REAL, typename PFP::MAP>& area);
template <typename PFP>
void computeAreaEdges(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& area);
template <typename PFP>
void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP>& area);
......@@ -99,8 +112,10 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut
template <typename PFP>
void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP>& area);
} // namespace Parallel
} // namespace Geometry
} // namespace Surface
......
......@@ -74,15 +74,19 @@ typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Face d, const VertexAt
template <typename PFP>
typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position)
{
typename PFP::REAL area(0) ;
if (CGoGN::Parallel::NumberOfThreads > 1)
{
return Parallel::totalArea<PFP>(map, position);
}
typename PFP::REAL area(0);
foreach_cell<FACE>(map, [&] (Face f)
{
area += convexFaceArea<PFP>(map, f, position);
}
,AUTO);
return area ;
return area;
}
template <typename PFP>
......@@ -137,12 +141,23 @@ typename PFP::REAL vertexVoronoiArea(typename PFP::MAP& map, Vertex v, const Ver
}
template <typename PFP>
void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, FaceAttribute<typename PFP::REAL, typename PFP::MAP>& face_area)
typename PFP::REAL edgeArea(typename PFP::MAP& map, Edge e, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position)
{
typename PFP::REAL area(0) ;
foreach_incident2<FACE>(map, e, [&] (Face f)
{
area += convexFaceArea<PFP>(map, f, position) / map.faceDegree(f) ;
});
return area ;
}
template <typename PFP>
void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, FaceAttribute<typename PFP::REAL, typename PFP::MAP>& face_area)
{
if (CGoGN::Parallel::NumberOfThreads > 1)
{
Parallel::computeAreaFaces<PFP>(map,position,face_area);
Parallel::computeAreaFaces<PFP>(map, position, face_area);
return;
}
......@@ -151,7 +166,22 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP
face_area[f] = convexFaceArea<PFP>(map, f, position) ;
}
,AUTO);
}
template <typename PFP>
void computeAreaEdges(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edge_area)
{
if (CGoGN::Parallel::NumberOfThreads > 1)
{
Parallel::computeAreaEdges<PFP>(map, position, edge_area);
return;
}
foreach_cell<EDGE>(map, [&] (Edge e)
{
edge_area[e] = edgeArea<PFP>(map, e, position) ;
}
,AUTO);
}
template <typename PFP>
......@@ -215,6 +245,24 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
namespace Parallel
{
template <typename PFP>
typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position)
{
std::vector<typename PFP::REAL> areas;
areas.resize(CGoGN::Parallel::NumberOfThreads);
CGoGN::Parallel::foreach_cell<FACE>(map, [&] (Face f, unsigned int thr)
{
areas[thr-1] += convexFaceArea<PFP>(map, f, position);
}
,AUTO);
typename PFP::REAL area(0);
for (typename PFP::REAL a : areas)
area += a;
return area;
}
template <typename PFP>
void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, FaceAttribute<typename PFP::REAL, typename PFP::MAP>& area)
{
......@@ -239,6 +287,14 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP
});
}
template <typename PFP>
void computeAreaEdges(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& area)
{
CGoGN::Parallel::foreach_cell<EDGE>(map, [&] (Edge e, unsigned int /*thr*/)
{
area[e] = edgeArea<PFP>(map, e, position) ;
});
}
template <typename PFP>
void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, VertexAttribute<typename PFP::REAL, typename PFP::MAP>& area)
......
......@@ -57,6 +57,58 @@ inline typename PFP::REAL edgeLength(typename PFP::MAP& map, Dart d, const Verte
return v.norm() ;
}
namespace Parallel
{
template <typename PFP>
typename PFP::REAL meanEdgeLength(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position)
{
std::vector<typename PFP::REAL> lengths;
std::vector<unsigned int> nbedges;
lengths.resize(CGoGN::Parallel::NumberOfThreads);
nbedges.resize(CGoGN::Parallel::NumberOfThreads);
CGoGN::Parallel::foreach_cell<EDGE>(map, [&] (Edge e, unsigned int thr)
{
lengths[thr-1] += edgeLength<PFP>(map, e, position);
++nbedges[thr-1];
}
,AUTO);
typename PFP::REAL length(0);
unsigned int nbe = 0;
for (unsigned int i = 0; i < CGoGN::Parallel::NumberOfThreads; ++i)
{
length += lengths[i];
nbe += nbedges[i];
}
return length / nbe;
}
} // namespace Parallel
template <typename PFP>
inline typename PFP::REAL meanEdgeLength(typename PFP::MAP& map,const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position)
{
if (CGoGN::Parallel::NumberOfThreads > 1)
{
return Parallel::meanEdgeLength<PFP>(map, position);
}
typename PFP::REAL length(0);
unsigned int nbe = 0;
foreach_cell<EDGE>(map, [&] (Edge e)
{
length += edgeLength<PFP>(map, e, position);
++nbe;
}
,AUTO);
return length / nbe;
}
template <typename PFP>
inline float angle(typename PFP::MAP& map, Dart d1, Dart d2, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position)
{
......
......@@ -113,6 +113,7 @@ void computeCurvatureVertices_NormalCycles(
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
......@@ -127,6 +128,7 @@ void computeCurvatureVertex_NormalCycles(
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
......@@ -160,6 +162,7 @@ void computeCurvatureVertices_NormalCycles_Projected(
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
......@@ -174,6 +177,7 @@ void computeCurvatureVertex_NormalCycles_Projected(
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
......@@ -189,6 +193,7 @@ void computeCurvatureVertices_NormalCycles(
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
......@@ -202,6 +207,7 @@ void computeCurvatureVertex_NormalCycles(
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
......@@ -215,6 +221,7 @@ void computeCurvatureVertices_NormalCycles_Projected(
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
......@@ -228,6 +235,7 @@ void computeCurvatureVertex_NormalCycles_Projected(
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
......@@ -245,6 +253,7 @@ void computeCurvatureVertices_NormalCycles(
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
......@@ -258,6 +267,7 @@ void computeCurvatureVertices_NormalCycles_Projected(
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position,
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgeangle,
const EdgeAttribute<typename PFP::REAL, typename PFP::MAP>& edgearea,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmax,
VertexAttribute<typename PFP::REAL, typename PFP::MAP>& kmin,
VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& Kmax,
......
This diff is collapsed.
......@@ -83,7 +83,7 @@ bool areTrianglesInIntersection(typename PFP::MAP& map, Face t1, Face t2, const
* et v1 et v2 les deux sommets de l'arête
*/
template <typename PFP>
bool intersectionSphereEdge(typename PFP::MAP& map, typename PFP::VEC3& center, typename PFP::REAL radius, Edge e, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, typename PFP::REAL& alpha) ;
bool intersectionSphereEdge(typename PFP::MAP& map, const typename PFP::VEC3& center, typename PFP::REAL radius, Edge e, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, typename PFP::REAL& alpha) ;
} // namespace Geometry
......
......@@ -238,7 +238,7 @@ bool areTrianglesInIntersection(typename PFP::MAP& map, Face t1, Face t2, const
}
template <typename PFP>
bool intersectionSphereEdge(typename PFP::MAP& map, typename PFP::VEC3& center, typename PFP::REAL radius, Edge e, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, typename PFP::REAL& alpha)
bool intersectionSphereEdge(typename PFP::MAP& map, const typename PFP::VEC3& center, typename PFP::REAL radius, Edge e, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, typename PFP::REAL& alpha)
{
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
......
......@@ -122,16 +122,12 @@ public:
template <typename PPFP>
friend std::ostream& operator<<(std::ostream &out, const Collector<PPFP>& c);
virtual REAL computeArea (const VertexAttribute<VEC3, MAP>& /*pos*/)
virtual REAL computeArea (const VertexAttribute<VEC3, MAP>& /*pos*/, const EdgeAttribute<REAL, MAP>& /*edgearea*/)
{
assert(!"Warning: Collector<PFP>::computeArea() should be overloaded in non-virtual derived classes");
return 0.0;
}
virtual void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& /*pos*/, const EdgeAttribute<REAL, MAP>& /*edgeangle*/, typename PFP::MATRIX33&)
{
assert(!"Warning: Collector<PFP>::computeNormalCyclesTensor() should be overloaded in non-virtual derived classes");
}
virtual void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& /*pos*/, typename PFP::MATRIX33&)
virtual void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& /*pos*/, const EdgeAttribute<REAL, MAP>& /*edgeangle*/, const EdgeAttribute<REAL, MAP>& /*edgearea*/, typename PFP::MATRIX33&)
{
assert(!"Warning: Collector<PFP>::computeNormalCyclesTensor() should be overloaded in non-virtual derived classes");
}
......@@ -162,9 +158,8 @@ public:
void collectAll(Dart d);
void collectBorder(Dart d);
REAL computeArea(const VertexAttribute<VEC3, MAP>& pos);
void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& pos, const EdgeAttribute<REAL, MAP>& edgeangle, typename PFP::MATRIX33&);
void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& pos, typename PFP::MATRIX33&);
REAL computeArea(const VertexAttribute<VEC3, MAP>& pos, const EdgeAttribute<REAL, MAP>& edgearea);
void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& pos, const EdgeAttribute<REAL, MAP>& edgeangle, const EdgeAttribute<REAL, MAP>& edgearea, typename PFP::MATRIX33&);
};
/*********************************************************
......@@ -194,10 +189,8 @@ public:
void collectAll(Dart d);
void collectBorder(Dart d);
REAL computeArea(const VertexAttribute<VEC3, MAP>& pos);
void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& pos, const EdgeAttribute<REAL, MAP>& edgeangle, typename PFP::MATRIX33&);
void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& pos, typename PFP::MATRIX33&);
REAL computeArea(const VertexAttribute<VEC3, MAP>& pos, const EdgeAttribute<REAL, MAP>& edgearea);
void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& pos, const EdgeAttribute<REAL, MAP>& edgeangle, const EdgeAttribute<REAL, MAP>& edgearea, typename PFP::MATRIX33&);
};
/*********************************************************
......@@ -234,9 +227,8 @@ public:
void collectAll(Dart d);
void collectBorder(Dart d);
REAL computeArea(const VertexAttribute<VEC3, MAP>& pos);
void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& pos, const EdgeAttribute<REAL, MAP>& edgeangle, typename PFP::MATRIX33&);
void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& pos, typename PFP::MATRIX33&);
REAL computeArea(const VertexAttribute<VEC3, MAP>& pos, const EdgeAttribute<REAL, MAP>& edgearea);
void computeNormalCyclesTensor (const VertexAttribute<VEC3, MAP>& pos, const EdgeAttribute<REAL, MAP>& edgeangle, const EdgeAttribute<REAL, MAP>& edgearea, typename PFP::MATRIX33&);
};
/*********************************************************
......
This diff is collapsed.
......@@ -44,10 +44,12 @@ template <typename PFP>
void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
{
// nb vertices
int nb = x*y +1;
unsigned int nbV = x*y +1;
unsigned int nbF = x*y;
// vertice reservation
this->m_tableVertDarts.reserve(nb);
this->m_tableVertDarts.reserve(nbV);
this->m_tableFaceDarts.reserve(nbF);
// creation of triangles and storing vertices
for (unsigned int i = 0; i < y; ++i)
......@@ -61,6 +63,7 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
this->m_tableVertDarts.push_back(this->m_map.phi_1(d));
if (j == x)
this->m_tableVertDarts.push_back(this->m_map.phi1(this->m_map.phi1(d)));
this->m_tableFaceDarts.push_back(d);
}
}
......
......@@ -46,10 +46,12 @@ template <typename PFP>
void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
{
// nb vertices
int nb = (x+1)*(y+1);
unsigned int nbV = (x+1)*(y+1);
unsigned int nbF = x*y;
// vertice reservation
this->m_tableVertDarts.reserve(nb);
this->m_tableVertDarts.reserve(nbV);
this->m_tableFaceDarts.reserve(nbF);
// creation of quads and storing vertices
for (unsigned int i = 0; i < y; ++i)
......@@ -60,6 +62,7 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
this->m_tableVertDarts.push_back(d);
if (j == x)
this->m_tableVertDarts.push_back(this->m_map.phi1(d));
this->m_tableFaceDarts.push_back(d);
}
}
......@@ -174,10 +177,12 @@ void Grid<PFP>::embedIntoHelicoid(VertexAttribute<VEC3, MAP>& position, float ra
template <typename PFP>
void Cylinder<PFP>::cylinder(unsigned int n, unsigned int z)
{
int nb = (n)*(z+1)+2;
unsigned int nbV = (n)*(z+1)+2;
unsigned int nbF = n*z;
// vertice reservation
this->m_tableVertDarts.reserve(nb);
this->m_tableVertDarts.reserve(nbV);
this->m_tableFaceDarts.reserve(nbF);
// creation of quads and storing vertices
for (unsigned int i = 0; i < z; ++i)
......@@ -186,6 +191,7 @@ void Cylinder<PFP>::cylinder(unsigned int n, unsigned int z)
{
Dart d = this->m_map.newFace(4, false);
this->m_tableVertDarts.push_back(d);
this->m_tableFaceDarts.push_back(d);
}
}
......@@ -405,13 +411,16 @@ void Cube<PFP>::cube(unsigned int x, unsigned int y, unsigned int z)
this->m_ny = y;
this->m_nz = z;
int nb = 2*(x+y)*(z+1) + 2*(x-1)*(y-1);
this->m_tableVertDarts.reserve(nb);
unsigned int nbV = 2*(x+y)*(z+1) + 2*(x-1)*(y-1);
unsigned int nbF = 2*(x+y)*z + 2*x*y;
this->m_tableVertDarts.reserve(nbV);
this->m_tableFaceDarts.reserve(nbF);
// we now have the 4 sides, just need to create store and sew top & bottom
// the top
Grid<PFP> gtop(this->m_map,x,y,false);
std::vector<Dart>& tableTop = gtop.getVertexDarts();
Grid<PFP> gTop(this->m_map,x,y,false);
std::vector<Dart>& tableTop = gTop.getVertexDarts();
int index_side = 2*(x+y)*z;
for(unsigned int i = 0; i < x; ++i)
......@@ -488,6 +497,17 @@ void Cube<PFP>::cube(unsigned int x, unsigned int y, unsigned int z)
this->m_tableVertDarts.push_back(tableBottom[i*(x+1)+j]);
}
const std::vector<Dart>& tableTopFaces = gTop.getFaceDarts();
for (Dart f : tableTopFaces)
{
this->m_tableFaceDarts.push_back(f);
}
const std::vector<Dart>& tableBottomFaces = gBottom.getFaceDarts();
for (Dart f : tableBottomFaces)
{
this->m_tableFaceDarts.push_back(f);
}
}
template <typename PFP>
......
......@@ -44,10 +44,12 @@ template <typename PFP>
void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
{
// nb vertices
int nb = (x+1)*(y+1);
unsigned int nbV = (x+1)*(y+1);
unsigned int nbF = 2*x*y;
// vertices reservation
this->m_tableVertDarts.reserve(nb);
this->m_tableVertDarts.reserve(nbV);
this->m_tableFaceDarts.reserve(nbF);
// creation of triangles and storing vertices
for (unsigned int i = 0; i < y; ++i)
......@@ -59,6 +61,9 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
this->m_map.sewFaces(this->m_map.phi1(d), this->m_map.phi_1(d2), false);
this->m_tableVertDarts.push_back(d);
this->m_tableFaceDarts.push_back(d);
this->m_tableFaceDarts.push_back(d2);
if (j == x)
this->m_tableVertDarts.push_back(d2);
}
......@@ -179,10 +184,12 @@ template <typename PFP>
void Cylinder<PFP>::cylinder(unsigned int n, unsigned int z)
{
// nb vertices
int nb = (n)*(z+1)+2;
unsigned int nbV = (n)*(z+1)+2;
unsigned int nbF = 2*n*z;
// vertices reservation
this->m_tableVertDarts.reserve(nb);
this->m_tableVertDarts.reserve(nbV);
this->m_tableFaceDarts.reserve(nbF);
// creation of triangles and storing vertices
for (unsigned int i = 0; i < z; ++i)
......@@ -193,6 +200,8 @@ void Cylinder<PFP>::cylinder(unsigned int n, unsigned int z)
Dart d2 = this->m_map.newFace(3, false);
this->m_map.sewFaces(this->m_map.phi1(d), this->m_map.phi_1(d2), false);
this->m_tableVertDarts.push_back(d);
this->m_tableFaceDarts.push_back(d);
this->m_tableFaceDarts.push_back(d2);
}
}
......@@ -413,8 +422,11 @@ void Cube<PFP>::cube(unsigned int x, unsigned int y, unsigned int z)
this->m_ny = y;
this->m_nz = z;
int nb = 2*(x+y)*(z+1) + 2*(x-1)*(y-1);
this->m_tableVertDarts.reserve(nb);
unsigned int nbV = 2*(x+y)*(z+1) + 2*(x-1)*(y-1);
unsigned int nbF = 2* (2*(x+y)*z + 2*x*y);
this->m_tableVertDarts.reserve(nbV);
this->m_tableFaceDarts.reserve(nbF);
// we now have the 4 sides, just need to create store and sew top & bottom
// the top
......@@ -500,6 +512,17 @@ void Cube<PFP>::cube(unsigned int x, unsigned int y, unsigned int z)
this->m_tableVertDarts.push_back(tableBottom[i*(x+1)+j]);
}
const std::vector<Dart>& tableTopFaces = gTop.getFaceDarts();
for (Dart f : tableTopFaces)
{
this-m_tableFaceDarts.push_back(f);
}
const std::vector<Dart>& tableBottomFaces = gBottom.getFaceDarts();
for (Dart f : tableBottomFaces)
{
this-m_tableFaceDarts.push_back(f);
}
}
template <typename PFP>
......
......@@ -69,6 +69,12 @@ protected:
*/
std::vector<Dart> m_tableVertDarts;
/**
* Table of vertex darts (one dart per vertex)
* Order depend on tiling kind
*/
std::vector<Dart> m_tableFaceDarts;
public:
Tiling(MAP& map, unsigned int x, unsigned int y, unsigned int z):
m_map(map),
......@@ -83,10 +89,15 @@ public:
Tiling(const Tiling<PFP>& t1, const Tiling<PFP> t2);
/**
* get the table of darts (one per vertex)
* get the table of vertex darts (one per vertex)
*/
std::vector<Dart>& getVertexDarts() { return m_tableVertDarts; }
/**
* get the table of face darts (one per face)
*/
std::vector<Dart>& getFaceDarts() { return m_tableFaceDarts; }
void computeCenter(VertexAttribute<VEC3, MAP>& position);
//void Polyhedron<PFP>::transform(float* matrice)
......
......@@ -272,9 +272,19 @@ void Surface_DifferentialProperties_Plugin::computeCurvature(
if(!edgeAngle.isValid())
edgeAngle = mh->addAttribute<PFP2::REAL, EDGE>("edgeAngle");
EdgeAttribute<PFP2::REAL, PFP2::MAP> edgeArea = mh->getAttribute<PFP2::REAL, EDGE>("edgeArea");
if(!edgeArea.isValid())
edgeArea = mh->addAttribute<PFP2::REAL, EDGE>("edgeArea");
PFP2::MAP* map = mh->getMap();
Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges<PFP2>(*map, position, edgeAngle);
Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles_Projected<PFP2>(*map, 0.01f * mh->getBBdiagSize(), position, normal, edgeAngle, kmax, kmin, Kmax, Kmin, Knormal);
Algo::Surface::Geometry::computeAreaEdges<PFP2>(*map, position, edgeArea);
PFP2::REAL meanEdgeLength = Algo::Surface::Geometry::meanEdgeLength<PFP2>(*map, position);
float radius = 2.0f * meanEdgeLength;
Algo::Surface::Geometry::computeCurvatureVertices_NormalCycles_Projected<PFP2>(*map, radius, position, normal, edgeAngle, edgeArea, kmax, kmin, Kmax, Kmin, Knormal);
computeCurvatureLastParameters[mapName] =
ComputeCurvatureParameters(
......
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