mapMono.h 4.92 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
/*******************************************************************************
* 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 __MAP_MONO__
#define __MAP_MONO__

Pierre Kraemer's avatar
Pierre Kraemer committed
28
#include "Topology/generic/genericmap.h"
29 30 31 32

namespace CGoGN
{

Pierre Kraemer's avatar
Pierre Kraemer committed
33
class MapMono : public GenericMap
34
{
35
	template<typename MAP> friend class DartMarkerTmpl ;
Pierre Kraemer's avatar
Pierre Kraemer committed
36
	template<typename MAP> friend class DartMarkerStore ;
37

38 39 40 41
public:
	MapMono()
	{}

42 43
	inline virtual void clear(bool removeAttrib);

44
protected:
45 46 47
	// protected copy constructor to prevent the copy of map
	MapMono(const MapMono& m): GenericMap(m){}

48
	std::vector<AttributeMultiVector<Dart>*> m_involution;
49 50 51
	std::vector<AttributeMultiVector<Dart>*> m_permutation;
	std::vector<AttributeMultiVector<Dart>*> m_permutation_inv;

52 53 54
	/****************************************
	 *          DARTS MANAGEMENT            *
	 ****************************************/
55

Pierre Kraemer's avatar
Pierre Kraemer committed
56
	inline Dart newDart();
57

58
	inline virtual void deleteDart(Dart d);
59

Pierre Kraemer's avatar
Pierre Kraemer committed
60 61
public:
	inline unsigned int dartIndex(Dart d) const;
62

Pierre Kraemer's avatar
Pierre Kraemer committed
63
	inline Dart indexDart(unsigned int index) const;
64

65
	inline unsigned int getNbDarts() const;
66

67 68
	inline AttributeContainer& getDartContainer();

69 70 71 72
	/****************************************
	 *        RELATIONS MANAGEMENT          *
	 ****************************************/

73
protected:
74 75
	inline void addInvolution();
	inline void addPermutation();
Sylvain Thery's avatar
Sylvain Thery committed
76
	inline void removeLastInvolutionPtr(); // for moveFrom
77

78 79 80 81
	inline AttributeMultiVector<Dart>* getInvolutionAttribute(unsigned int i);
	inline AttributeMultiVector<Dart>* getPermutationAttribute(unsigned int i);
	inline AttributeMultiVector<Dart>* getPermutationInvAttribute(unsigned int i);

Pierre Kraemer's avatar
Pierre Kraemer committed
82 83 84
	virtual unsigned int getNbInvolutions() const = 0;
	virtual unsigned int getNbPermutations() const = 0;

85
	template <int I>
86
	inline Dart getInvolution(Dart d) const;
87 88

	template <int I>
89
	inline Dart getPermutation(Dart d) const;
90 91

	template <int I>
92
	inline Dart getPermutationInv(Dart d) const;
93 94

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
95
	inline void involutionSew(Dart d, Dart e);
96 97

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
98
	inline void involutionUnsew(Dart d);
99 100

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
101
	inline void permutationSew(Dart d, Dart e);
102 103

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
104
	inline void permutationUnsew(Dart d);
105

Sylvain Thery's avatar
Sylvain Thery committed
106
	virtual void compactTopo();
107

108 109 110
	/****************************************
	 *           DARTS TRAVERSALS           *
	 ****************************************/
111
public:
112 113 114 115
	/**
	 * Begin of map
	 * @return the first dart of the map
	 */
116
	inline Dart begin() const;
117 118 119 120 121

	/**
	 * End of map
	 * @return the end iterator (next of last) of the map
	 */
122
	inline Dart end() const;
123 124 125 126 127 128

	/**
	 * allow to go from a dart to the next
	 * in the order of storage
	 * @param d reference to the dart to be modified
	 */
129 130 131 132
	inline void next(Dart& d) const;

	/**
	 * Apply a functor on each dart of the map
133
	 * @param f a callable taking a Dart parameter
134
	 */
135 136 137 138 139
	template <typename FUNC>
	void foreach_dart(FUNC f) ;

	template <typename FUNC>
	void foreach_dart(FUNC& f) ;
140 141 142 143 144 145 146 147 148 149

	/****************************************
	 *             SAVE & LOAD              *
	 ****************************************/

	bool saveMapBin(const std::string& filename) const;

	bool loadMapBin(const std::string& filename);

	bool copyFrom(const GenericMap& map);
Pierre Kraemer's avatar
Pierre Kraemer committed
150 151

	void restore_topo_shortcuts();
152 153 154 155
} ;

} //namespace CGoGN

156
#include "Topology/generic/mapImpl/mapMono.hpp"
157

158
#endif