geometryApproximator.h 4.72 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
* Copyright (C) 2009, 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: https://iggservis.u-strasbg.fr/CGoGN/                              *
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __GEOMETRY_APPROXIMATOR_H__
#define __GEOMETRY_APPROXIMATOR_H__

#include "Algo/Decimation/approximator.h"

namespace CGoGN
{

namespace Algo
{

namespace Decimation
{

template <typename PFP>
class Approximator_QEM : public Approximator<PFP, typename PFP::VEC3>
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

protected:
	AttributeHandler<Quadric<REAL> > m_quadric ;

public:
	Approximator_QEM(MAP& m, AttributeHandler<VEC3>& pos, Predictor<PFP, VEC3>* pred = NULL) :
		Approximator<PFP, VEC3>(m, pos, EDGE_ORBIT, pred)
	{}
	~Approximator_QEM()
	{}
	ApproximatorType getType() const { return A_QEM ; }
	bool init() ;
	void approximate(Dart d) ;
} ;

Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
61
template <typename PFP>
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
62
class Approximator_QEMhalfEdge : public Approximator<PFP, typename PFP::VEC3>
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
63 64 65 66 67 68 69 70 71 72
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

protected:
	AttributeHandler<Quadric<REAL> > m_quadric ;

public:
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
73
	Approximator_QEMhalfEdge(MAP& m, AttributeHandler<VEC3>& pos, Predictor<PFP, VEC3>* pred = NULL) :
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
74 75
		Approximator<PFP, VEC3>(m, pos, EDGE_ORBIT, pred)
	{}
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
76
	~Approximator_QEMhalfEdge()
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
77
	{}
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
78
	ApproximatorType getType() const { return A_QEMhalfEdge ; }
Kenneth Vanhoey's avatar
Kenneth Vanhoey committed
79 80 81 82
	bool init() ;
	void approximate(Dart d) ;
} ;

Pierre Kraemer's avatar
Pierre Kraemer committed
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
template <typename PFP>
class Approximator_MidEdge : public Approximator<PFP, typename PFP::VEC3>
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

	Approximator_MidEdge(MAP& m, AttributeHandler<VEC3>& pos, Predictor<PFP, VEC3>* pred = NULL) :
		Approximator<PFP, VEC3>(m, pos, EDGE_ORBIT, pred)
	{}
	~Approximator_MidEdge()
	{}
	ApproximatorType getType() const { return A_MidEdge ; }
	bool init() ;
	void approximate(Dart d) ;
} ;

template <typename PFP>
class Approximator_HalfCollapse : public Approximator<PFP, typename PFP::VEC3>
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

	Approximator_HalfCollapse(MAP& m, AttributeHandler<VEC3>& pos, Predictor<PFP, VEC3>* pred = NULL) :
		Approximator<PFP, VEC3>(m, pos, EDGE_ORBIT, pred)
	{}
	~Approximator_HalfCollapse()
	{}
	ApproximatorType getType() const { return A_HalfCollapse ; }
	bool init() ;
	void approximate(Dart d) ;
} ;

template <typename PFP>
class Approximator_CornerCutting : public Approximator<PFP, typename PFP::VEC3>
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

	Approximator_CornerCutting(MAP& m, AttributeHandler<VEC3>& pos, Predictor<PFP, VEC3>* pred = NULL) :
		Approximator<PFP, VEC3>(m, pos, EDGE_ORBIT, pred)
	{}
	~Approximator_CornerCutting()
	{}
	ApproximatorType getType() const { return A_CornerCutting ; }
	bool init() ;
	void approximate(Dart d) ;
} ;

} //namespace Decimation

} //namespace Algo

} //namespace CGoGN

#include "Algo/Decimation/geometryApproximator.hpp"

#endif