Commit 2ac35316 authored by Sylvain Thery's avatar Sylvain Thery

add test compil

parent 357fd727
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __ALGO_BOOLEANOPERATOR_VERTICES_H__
#define __ALGO_BOOLEANOPERATOR_VERTICES_H__
#include "Geometry/basic.h"
#include "Geometry/inclusion.h"
#include "Geometry/orientation.h"
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace BooleanOperator
{
template <typename PFP>
bool isBetween(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& positions, Dart d, Dart e, Dart f) ;
template <typename PFP>
void mergeVertex(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& positions, Dart d, Dart e);
template <typename PFP>
void mergeVertices(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& positions);
}
}
}
}
#include "mergeVertices.hpp"
#endif
cmake_minimum_required(VERSION 2.6)
project(testing_algo)
#add_subdirectory(BooleanOperator)
#add_subdirectory(Decimation)
#add_subdirectory(Export)
#add_subdirectory(Filtering)
add_subdirectory(Geometry)
#add_subdirectory(Histogram)
#add_subdirectory(ImplicitHierarchicalMesh)
#add_subdirectory(Import)
#add_subdirectory(LinearSolving)
#add_subdirectory(MC)
#add_subdirectory(Modelisation)
#add_subdirectory(MovingObjects)
#add_subdirectory(Multiresolution)
#add_subdirectory(ProgressiveMesh)
#add_subdirectory(Remeshing)
#add_subdirectory(Render)
#add_subdirectory(Selection)
#add_subdirectory(Simulation)
#add_subdirectory(Tiling)
#add_subdirectory(Topo)
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2013, IGG Team, ICube, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Algo/Decimation/predictor.h"
#ifndef __APPROXIMATOR_H__
#define __APPROXIMATOR_H__
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace Decimation
{
enum ApproximatorType
{
// One approx per edge
// Geometry approximators
A_QEM = 0, /**< Approximates the geometry of an edge collapse by quadric error metric minimization [GH97]. */
A_MidEdge = 1, /**< Approximates the geometry of an edge collapse by placing the resulting vertex in its middle. */
A_CornerCutting = 2,
A_TangentPredict1 = 3,
A_TangentPredict2 = 4,
A_NormalArea = 5, /**< EXPERIMENTAL Approximates the geometry of an edge collapse by minimization of its normal times area measure [Sauvage] */
// Geometry + color approximators
A_ColorNaive = 6, /**< Approximates the color of the resulting vertex by linear interpolation (based on the approximated position) of its two predecessors. */
A_ColorQEMext = 7, /**< Approximates both geometry and color of the resulting vertex by minimization of the extended (R^6) quadric error metric [GH98]. */
A_GeomColorOpt = 8, /**< EXPERIMENTAL. */
// One approx per half-edge
// Generic (considers all provided attributes) approximator
A_hHalfCollapse = 9, /**< Approximates all provided attributes of a half-edge collapse by keeping the attributes of the first of two vertices. */
// Geometry approximator
A_hQEM = 10, /**< Approximates the geometry of a full-edge collapse by quadric error metric minimization [GH97]. Compatible version for half-edge selectors. */
A_OTHER /**< Can be used for extensions. */
} ;
/*!
* \class ApproximatorGen
* \brief Generic class holder for approximators
*/
template <typename PFP>
class ApproximatorGen
{
protected:
typename PFP::MAP& m_map ;
public:
ApproximatorGen(typename PFP::MAP& m) : m_map(m)
{}
virtual ~ApproximatorGen()
{}
virtual const std::string& getApproximatedAttributeName() const = 0 ;
virtual ApproximatorType getType() const = 0 ;
virtual bool init() = 0 ;
virtual void approximate(Dart d) = 0 ;
virtual void saveApprox(Dart d) = 0 ;
virtual void affectApprox(Dart d) = 0 ;
virtual const PredictorGen<PFP>* getPredictor() const = 0 ;
// virtual REAL detailMagnitude(Dart d) = 0 ;
// virtual void addDetail(Dart d, double amount, bool sign, typename PFP::MATRIX33* detailTransform) = 0 ;
} ;
/*!
* \class Approximator
* \brief Generic class for approximators
*/
template <typename PFP, typename T, unsigned int ORBIT>
class Approximator : public ApproximatorGen<PFP>
{
typedef typename PFP::MAP MAP ;
protected:
VertexAttribute<T, MAP>& m_attr ; // vertex attribute to be approximated
AttributeHandler<T, ORBIT, MAP> m_approx ; // attribute to store approximation result
AttributeHandler<T, ORBIT, MAP> m_detail ; // attribute to store detail information for reconstruction
T m_app ;
Predictor<PFP, T>* m_predictor ;
public:
Approximator(MAP& m, VertexAttribute<T, MAP>& attr, Predictor<PFP, T>* predictor) ;
virtual ~Approximator() ;
const VertexAttribute<T, MAP>& getApproximatedAttribute() const ;
VertexAttribute<T, MAP>& getApproximatedAttribute() ;
const std::string& getApproximatedAttributeName() const ;
const AttributeHandler<T, ORBIT, MAP>& getApproximationResultAttribute() const;
void saveApprox(Dart d) ;
void affectApprox(Dart d) ;
const T& getApprox(Dart d) const ;
const Predictor<PFP, T>* getPredictor() const ;
const T& getDetail(Dart d) const ;
void setDetail(Dart d, const T& val) ;
// REAL detailMagnitude(Dart d) ; // TODO works only for vector types !!
// void addDetail(Dart d, double amount, bool sign, typename PFP::MATRIX33* detailTransform) ; // TODO works only for vector types !!
} ;
} // namespace Decimation
} // namespace surface
} // namespace Algo
} // namespace CGoGN
#include "Algo/Decimation/approximator.hpp"
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2013, IGG Team, ICube, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __COLOR_APPROXIMATOR_H__
#define __COLOR_APPROXIMATOR_H__
#include "Algo/Decimation/approximator.h"
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace Decimation
{
template <typename PFP>
class Approximator_ColorNaive : public Approximator<PFP, typename PFP::VEC3, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected:
const VertexAttribute<VEC3, MAP>& m_position ;
const EdgeAttribute<VEC3, MAP>& m_approximatedPosition ;
public:
Approximator_ColorNaive(MAP& m, VertexAttribute<VEC3, MAP>& color, const VertexAttribute<VEC3, MAP>& position, const EdgeAttribute<VEC3, MAP>& approximatedPosition, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3, EDGE>(m, color, pred),
m_position(position),
m_approximatedPosition(approximatedPosition)
{}
~Approximator_ColorNaive()
{}
ApproximatorType getType() const { return A_ColorNaive ; }
bool init();
void approximate(Dart d) ;
} ;
/*
template <typename PFP>
class Approximator_ColorQEMext : public Approximator<PFP, typename PFP::VEC3, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::REAL REAL ;
typedef typename PFP::VEC3 VEC3 ;
typedef Geom::Vector<6, REAL> VEC6 ;
protected:
VertexAttribute<Utils::QuadricNd<REAL,6>, MAP> m_quadric ;
VertexAttribute<VEC3, MAP>* m_position ;
VertexAttribute<VEC3, MAP>* m_color ;
public:
Approximator_ColorQEMext(MAP& m, VertexAttribute<VEC3, MAP>& position, VertexAttribute<VEC3, MAP>& color, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3, EDGE>(m, position, pred),
m_position(position),
m_color(color)
{}
~Approximator_ColorQEMext()
{}
ApproximatorType getType() const { return A_ColorQEMext ; }
bool init() ;
void approximate(Dart d) ;
} ;
template <typename PFP>
class Approximator_GeomColOpt : public Approximator<PFP, typename PFP::VEC3, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::REAL REAL ;
typedef typename PFP::VEC3 VEC3 ;
protected:
VertexAttribute<Utils::Quadric<REAL>, MAP> m_quadric ;
VertexAttribute<VEC3, MAP>* m_position ;
VertexAttribute<VEC3, MAP>* m_color ;
public:
Approximator_GeomColOpt(MAP& m, std::vector<VertexAttribute<VEC3, MAP>*>& attr, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3, EDGE>(m, attr, pred)
{
assert(attr.size() > 1 || !"Approximator_GeomColOpt: there are not sufficient attributes provided") ;
m_position = this->m_attrV[0] ;
m_color = this->m_attrV[1] ;
}
~Approximator_GeomColOpt()
{}
ApproximatorType getType() const
{
return A_GeomColorOpt ;
}
bool init() ;
void approximate(Dart d) ;
} ;
*/
} // namespace Decimation
} // namespace Surface
} // namespace Algo
} // namespace CGoGN
#include "Algo/Decimation/colorPerVertexApproximator.hpp"
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2013, IGG Team, ICube, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __DECIMATION_H__
#define __DECIMATION_H__
#include "Algo/Decimation/edgeSelector.h"
#include "Algo/Decimation/halfEdgeSelector.h"
#include "Algo/Decimation/geometryApproximator.h"
#include "Algo/Decimation/colorPerVertexApproximator.h"
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace Decimation
{
/**
* \fn decimate
* Function that decimates the provided mesh through successive edge collapses
* by using a declared selector and approximator type (see \file approximator.h and \file selector.h).
*
* \param map the map to decimate
* \param s the SelectorType
* \param a the ApproximatorType
* \param position the vertex position embeddings
* \param nbWantedVertices the aimed amount of vertices after decimation
* \param edgeErrors will (if not null) contain the edge errors computed by the approximator/selector (default NULL)
* \param callback_wrapper a callback function for progress monitoring (default NULL)
* \param callback_object the object to call the callback on (default NULL)
*
* \return >= 0 if finished correctly : 1 if no more edges are collapsible, 0 is nbWantedVertices achieved, -1 if the initialisation of the selector failed
*/
template <typename PFP, typename T>
int decimate(
typename PFP::MAP& map,
SelectorType s,
ApproximatorType a,
std::vector<VertexAttribute<T, typename PFP::MAP> >& attribs,
unsigned int nbWantedVertices,
EdgeAttribute<typename PFP::REAL, typename PFP::MAP>* edgeErrors = NULL,
void (*callback_wrapper)(void*, const void*) = NULL,
void* callback_object = NULL
) ;
/**
*\fn decimate
* Function that decimates the provided mesh through successive edge collapses
* by providing the selector and the approximators
*
* \param map the map to decimate
* \param s the selector
* \param a a vector containing the approximators
* \param nbWantedVertices the aimed amount of vertices after decimation
* \param recomputePriorityList if false and a priority list exists, it is not recomputed
* \param edgeErrors will (if not null) contain the edge errors computed by the approximator/selector (default NULL)
* \param callback_wrapper a callback function for progress monitoring (default NULL)
* \param callback_object the object to call the callback on (default NULL)
*
* \return >= 0 if finished correctly : 1 if no more edges are collapsible, 0 is nbWantedVertices achieved, -1 if the initialisation of the selector failed
*/
template <typename PFP>
int decimate(
typename PFP::MAP& map,
Selector<PFP>* s,
std::vector<ApproximatorGen<PFP>*>& a,
unsigned int nbWantedVertices,
bool recomputePriorityList = true,
EdgeAttribute<typename PFP::REAL,
typename PFP::MAP>* edgeErrors = NULL,
void (*callback_wrapper)(void*, const void*) = NULL,
void* callback_object = NULL
) ;
} // namespace Decimation
} // namespace Surface
} // namespace Algo
} // namespace CGoGN
#include "Algo/Decimation/decimation.hpp"
#endif
This diff is collapsed.
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2013, IGG Team, ICube, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __GEOMETRY_APPROXIMATOR_H__
#define __GEOMETRY_APPROXIMATOR_H__
#include "Algo/Decimation/approximator.h"
#include "Utils/convertType.h"
#include <Eigen/Dense>
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace Decimation
{
template <typename PFP>
class Approximator_QEM : public Approximator<PFP, typename PFP::VEC3, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected:
VertexAttribute<Utils::Quadric<REAL>, MAP> m_quadric ;
public:
Approximator_QEM(MAP& m, VertexAttribute<VEC3, MAP>& attr, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3, EDGE>(m, attr, pred)
{}
~Approximator_QEM()
{}
ApproximatorType getType() const { return A_QEM ; }
bool init() ;
void approximate(Dart d) ;
} ;
template <typename PFP>
class Approximator_QEMhalfEdge : public Approximator<PFP, typename PFP::VEC3, DART>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected:
VertexAttribute<Utils::Quadric<REAL>, MAP> m_quadric ;
public:
Approximator_QEMhalfEdge(MAP& m, VertexAttribute<VEC3, MAP>& attr, Predictor<PFP, VEC3>* pred = NULL) :
Approximator<PFP, VEC3, DART>(m, attr, pred)
{}
~Approximator_QEMhalfEdge()
{}
ApproximatorType getType() const { return A_hQEM ; }
bool init() ;
void approximate(Dart d) ;
} ;
template <typename PFP, typename T>
class Approximator_MidEdge : public Approximator<PFP, T, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::REAL REAL ;
Approximator_MidEdge(MAP& m, VertexAttribute<T, MAP>& attr, Predictor<PFP, T>* pred = NULL) :
Approximator<PFP, T, EDGE>(m, attr, pred)
{}
~Approximator_MidEdge()
{}
ApproximatorType getType() const { return A_MidEdge ; }
bool init() ;
void approximate(Dart d) ;
} ;
template <typename PFP, typename T>
class Approximator_InterpolateAlongEdge : public Approximator<PFP, T, EDGE>
{
public:
typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected:
const VertexAttribute<VEC3, MAP>& m_position ;
const EdgeAttribute<VEC3, MAP>& m_approximatedPosition ;
public:
Approximator_InterpolateAlongEdge(MAP& m, VertexAttribute<T, MAP>& attr, const VertexAttribute<VEC3, MAP>& position, const EdgeAttribute<VEC3, MAP>& approximatedPosition, Predictor<PFP, T>* pred = NULL) :
Approximator<PFP, T, EDGE>(m, attr, pred),
m_position(position),
m_approximatedPosition(approximatedPosition)
{}
~Approximator_InterpolateAlongEdge()
{}
ApproximatorType getType() const { return A_OTHER ; }
bool init() ;
void approximate(Dart d) ;
} ;
template <typename PFP, typename T>
class Approximator_HalfCollapse : public Approximator<PFP, T, DART>
{
public:
typedef typename PFP::MAP MAP ;
Approximator_HalfCollapse(MAP& m, VertexAttribute<T, MAP>& attr, Predictor<PFP, T>* pred = NULL) :
Approximator<PFP, T, DART>(m, attr, pred)
{}