mapMono.h 4.68 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()
	{}

Pierre Kraemer's avatar
Pierre Kraemer committed
42
43
	inline virtual void clear(bool removeAttrib);

44
protected:
Pierre Kraemer's avatar
Pierre Kraemer committed
45
	std::vector<AttributeMultiVector<Dart>*> m_involution;
46
47
48
	std::vector<AttributeMultiVector<Dart>*> m_permutation;
	std::vector<AttributeMultiVector<Dart>*> m_permutation_inv;

49
50
51
	/****************************************
	 *          DARTS MANAGEMENT            *
	 ****************************************/
52

Pierre Kraemer's avatar
Pierre Kraemer committed
53
	inline Dart newDart();
54

55
	inline virtual void deleteDart(Dart d);
56

Pierre Kraemer's avatar
Pierre Kraemer committed
57
58
public:
	inline unsigned int dartIndex(Dart d) const;
59

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

Pierre Kraemer's avatar
Pierre Kraemer committed
62
	inline virtual unsigned int getNbDarts() const;
63

64
65
	inline AttributeContainer& getDartContainer();

66
67
68
69
	/****************************************
	 *        RELATIONS MANAGEMENT          *
	 ****************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
70
protected:
71
72
73
	inline void addInvolution();
	inline void addPermutation();

Pierre Kraemer's avatar
Pierre Kraemer committed
74
75
76
77
	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
78
79
80
	virtual unsigned int getNbInvolutions() const = 0;
	virtual unsigned int getNbPermutations() const = 0;

81
	template <int I>
82
	inline Dart getInvolution(Dart d) const;
83
84

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

	template <int I>
88
	inline Dart getPermutationInv(Dart d) const;
89
90

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
91
	inline void involutionSew(Dart d, Dart e);
92
93

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
94
	inline void involutionUnsew(Dart d);
95
96

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
97
	inline void permutationSew(Dart d, Dart e);
98
99

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

102
	inline virtual void compactTopo();
103

104
105
106
	/****************************************
	 *           DARTS TRAVERSALS           *
	 ****************************************/
107
public:
108
109
110
111
	/**
	 * Begin of map
	 * @return the first dart of the map
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
112
	inline Dart begin() const;
113
114
115
116
117

	/**
	 * End of map
	 * @return the end iterator (next of last) of the map
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
118
	inline Dart end() const;
119
120
121
122
123
124

	/**
	 * allow to go from a dart to the next
	 * in the order of storage
	 * @param d reference to the dart to be modified
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
125
126
127
128
129
130
131
	inline void next(Dart& d) const;

	/**
	 * Apply a functor on each dart of the map
	 * @param f a ref to the functor obj
	 */
	bool foreach_dart(FunctorType& f) ;
132
133
134
135
136
137
138
139
140
141

	/****************************************
	 *             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
142
143

	void restore_topo_shortcuts();
144
145
146
147
} ;

} //namespace CGoGN

148
149
#include "Topology/generic/mapMono.hpp"

150
#endif