Commit b9ae811b authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' of cgogn:~kraemer/CGoGN into develop

parents fb69d9f9 9ec8e54b
......@@ -78,7 +78,7 @@ template <typename MAP, typename ATT>
void applySmooth(MAP& map, const ATT& att_in, ATT& att_out)
{
// check at compile if ATT is an AttributeHandler on orbit VERTEX
CHECK_ATTRIBUTEHANDER_ORBIT_TYPE(ATT,VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(ATT, VERTEX);
foreach_cell<VERTEX>(map,[&](Vertex v) // for all vertex v of map do
{
......
......@@ -112,15 +112,15 @@ void computeNewPositions(MAP& map, VertexAttribute<VEC3, MAP>& pos)
template<typename ATTRIB>
void dumpAttribute(const ATTRIB& attr)
{
CHECK_ATTRIBUTEHANDER__TYPE(ATTRIB);
CHECK_ATTRIBUTEHANDLER(ATTRIB);
std::cout << "Attribute " <<attr.name() << " of orbit "<< orbitName(attr.getOrbit())<< " of type "<< attr.typeName()<< std::endl;
std::cout << "Attribute " << attr.name() << " of orbit " << orbitName(attr.getOrbit()) << " of type " << attr.typeName() << std::endl;
// NEVER USE 0 AND ++ IN FOR LOOP ON ATTRIBUTE !
// USE ONLY BEGIN / END / NEXT (for hole jumping over)
for (unsigned int i=attr.begin(); i!=attr.end(); attr.next(i))
for (unsigned int i = attr.begin(); i != attr.end(); attr.next(i))
{
std::cout << attr.name() << "["<< i << "] = "<<attr[i]<< std::endl;
std::cout << attr.name() << "[" << i << "] = " << attr[i] << std::endl;
}
}
......
......@@ -45,6 +45,8 @@ namespace Geometry
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE triangleNormal(typename PFP::MAP& map, Face f, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typename V_ATT::DATA_TYPE N = Geom::triangleNormal(
position[f.dart],
position[map.phi1(f)],
......@@ -57,6 +59,8 @@ typename V_ATT::DATA_TYPE triangleNormal(typename PFP::MAP& map, Face f, const V
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE newellNormal(typename PFP::MAP& map, Face f, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typedef typename V_ATT::DATA_TYPE VEC3;
VEC3 N(0);
......@@ -76,6 +80,8 @@ typename V_ATT::DATA_TYPE newellNormal(typename PFP::MAP& map, Face f, const V_A
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE faceNormal(typename PFP::MAP& map, Face f, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
if(map.faceDegree(f) == 3)
return triangleNormal<PFP>(map, f, position) ;
else
......@@ -85,7 +91,7 @@ typename V_ATT::DATA_TYPE faceNormal(typename PFP::MAP& map, Face f, const V_ATT
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDER_ORBIT_TYPE(V_ATT,VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typedef typename V_ATT::DATA_TYPE VEC3 ;
......@@ -111,11 +117,10 @@ typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V
return N ;
}
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexBorderNormal(typename PFP::MAP& map, Vertex v, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
assert(map.dimension() == 3);
typedef typename V_ATT::DATA_TYPE VEC3 ;
......@@ -151,6 +156,9 @@ typename V_ATT::DATA_TYPE vertexBorderNormal(typename PFP::MAP& map, Vertex v, c
template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_normal, unsigned int thread)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(F_ATT, FACE);
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread == 0))
{
Parallel::computeNormalFaces<PFP,V_ATT,F_ATT>(map, position, face_normal);
......@@ -166,6 +174,8 @@ void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& fa
template <typename PFP, typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal, unsigned int thread)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread == 0))
{
Parallel::computeNormalVertices<PFP,V_ATT>(map, position, normal);
......@@ -181,6 +191,8 @@ void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT&
template <typename PFP, typename V_ATT>
typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Edge e, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typedef typename V_ATT::DATA_TYPE VEC3 ;
if(map.isBoundaryEdge(e))
......@@ -214,6 +226,9 @@ typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Edge
template <typename PFP, typename V_ATT, typename E_ATT>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles, unsigned int thread)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(E_ATT, EDGE);
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread == 0))
{
Parallel::computeAnglesBetweenNormalsOnEdges<PFP,V_ATT,E_ATT>(map, position, angles);
......@@ -233,6 +248,8 @@ namespace Parallel
template <typename PFP, typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CGoGN::Parallel::foreach_cell<VERTEX>(map, [&] (Vertex v, unsigned int /*thr*/)
{
normal[v] = vertexNormal<PFP>(map, v, position) ;
......@@ -242,6 +259,9 @@ void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT&
template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& normal)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(F_ATT, FACE);
CGoGN::Parallel::foreach_cell<FACE>(map, [&] (Face f, unsigned int /*thr*/)
{
normal[f] = faceNormal<PFP>(map, f, position) ;
......@@ -251,6 +271,9 @@ void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& no
template <typename PFP, typename V_ATT, typename E_ATT>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(E_ATT, EDGE);
CGoGN::Parallel::foreach_cell<EDGE>(map,[&](Edge e, unsigned int /*thr*/)
{
angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ;
......
......@@ -33,13 +33,14 @@
#include "Container/fakeAttribute.h"
#include "Topology/generic/cells.h"
/// Macro that check if ATTRIBUTEHANDLER type is an AttributeHandler of orbit ORBITVALUE
#define CHECK_ATTRIBUTEHANDER_ORBIT_TYPE(ATTRIBUTEHANDLER, ORBITVALUE) \
static_assert(std::is_base_of<AttributeHandlerGen,ATTRIBUTEHANDLER>::value, "Error not AttributeHandler");\
static_assert(ATTRIBUTEHANDLER::ORBIT==ORBITVALUE,"Error wrong orbit of AttributeHandler");
/// Macro that checks if ATTRIBUTEHANDLER type is an AttributeHandler
#define CHECK_ATTRIBUTEHANDLER(ATTRIBUTEHANDLER)\
static_assert(std::is_base_of<AttributeHandlerGen, ATTRIBUTEHANDLER>::value, "Error not AttributeHandler");
#define CHECK_ATTRIBUTEHANDER__TYPE(ATTRIBUTEHANDLER) \
static_assert(std::is_base_of<AttributeHandlerGen,ATTRIBUTEHANDLER>::value, "Error not AttributeHandler");
/// Macro that checks if ATTRIBUTEHANDLER type is an AttributeHandler of orbit ORBITVALUE
#define CHECK_ATTRIBUTEHANDLER_ORBIT(ATTRIBUTEHANDLER, ORBITVALUE)\
static_assert(std::is_base_of<AttributeHandlerGen, ATTRIBUTEHANDLER>::value, "Error not AttributeHandler");\
static_assert(ATTRIBUTEHANDLER::ORBIT == ORBITVALUE, "Error wrong orbit of AttributeHandler");
namespace CGoGN
{
......@@ -58,10 +59,7 @@ public:
valid(v)
{}
bool isValid() const
{
return valid ;
}
bool isValid() const { return valid ; }
virtual int getSizeOfType() const = 0;
......@@ -73,10 +71,7 @@ public:
virtual AttributeMultiVectorGen* getDataVectorGen() const = 0;
protected:
void setInvalid()
{
valid = false ;
}
void setInvalid() { valid = false ; }
} ;
/**
......
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