map2MR_PM.h 4.07 KB
Newer Older
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
/*******************************************************************************
* 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 __MAP2MR_PM__
#define __MAP2MR_PM__

#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"

32
#include "Container/attributeContainer.h"
33 34 35 36 37 38 39

#include "Algo/Decimation/selector.h"
#include "Algo/Decimation/edgeSelector.h"
#include "Algo/Decimation/geometryApproximator.h"
#include "Algo/Decimation/geometryPredictor.h"
#include "Algo/Decimation/lightfieldApproximator.h"

40
#include "Algo/Multiresolution/filter.h"
41 42 43 44 45 46 47

namespace CGoGN
{

namespace Algo
{

48 49 50
namespace Surface
{

51
namespace MR
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
{

template <typename PFP>
class Map2MR_PM
{
public:
	typedef typename PFP::MAP MAP ;
	typedef typename PFP::VEC3 VEC3 ;
	typedef typename PFP::REAL REAL ;

private:
	MAP& m_map ;
	VertexAttribute<VEC3>& m_position;

	bool m_initOk ;

	Algo::Decimation::EdgeSelector<PFP>* m_selector ;
	std::vector<Algo::Decimation::ApproximatorGen<PFP>*> m_approximators ;
	std::vector<Algo::Decimation::PredictorGen<PFP>*> m_predictors ;

	Algo::Decimation::Approximator<PFP, VEC3>* m_positionApproximator ;

74 75 76
	std::vector<Filter*> synthesisFilters ;
	std::vector<Filter*> analysisFilters ;

77
public:
untereiner's avatar
untereiner committed
78
	Map2MR_PM(MAP& map, VertexAttribute<VEC3>& position);
79 80 81

	~Map2MR_PM();

82
	//create a progressive mesh (a coarser level)
untereiner's avatar
untereiner committed
83 84 85
	void createPM(Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a, const FunctorSelect& select = allDarts) ;

	void addNewLevel(unsigned int percentWantedVertices);
86

untereiner's avatar
untereiner committed
87 88
	void collapseEdge(Dart d);

89 90 91 92 93
	//coarsen the mesh -> analysis
	void coarsen() ;

	//refine the mesh -> synthesis
	void refine() ;
94 95

	bool initOk() { return m_initOk; }
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

	void addSynthesisFilter(Filter* f) { synthesisFilters.push_back(f) ; }
	void addAnalysisFilter(Filter* f) { analysisFilters.push_back(f) ; }

	void clearSynthesisFilters() { synthesisFilters.clear() ; }
	void clearAnalysisFilters() { analysisFilters.clear() ; }

	/**
	 * Given the vertex of d in the current level,
	 * return a dart of from the vertex of the current level
	 */
	Dart vertexOrigin(Dart d) ;

//	/**
//	 * Return the level of the vertex of d in the current level map
//	 */
//	unsigned int vertexLevel(Dart d);
113 114 115 116
} ;

} // namespace Multiresolution

117 118
} // namespace Surface

119 120 121 122 123
} // namespace Algo

} // namespace CGoGN


untereiner's avatar
untereiner committed
124
#include "Algo/Multiresolution/Map2MR/map2MR_PM.hpp"
125 126

#endif