mapMono.h 4.36 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 44 45 46
protected:
	std::vector<AttributeMultiVector<Dart>*> m_permutation;
	std::vector<AttributeMultiVector<Dart>*> m_permutation_inv;
	std::vector<AttributeMultiVector<Dart>*> m_involution;

47 48 49
	/****************************************
	 *          DARTS MANAGEMENT            *
	 ****************************************/
50

51
	inline virtual Dart newDart();
52

53
	inline virtual void deleteDart(Dart d);
54

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

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

60 61
	inline virtual unsigned int getNbDarts();

Pierre Kraemer's avatar
Pierre Kraemer committed
62
protected:
63 64
	inline AttributeContainer& getDartContainer();

65 66 67 68 69 70 71 72
	/****************************************
	 *        RELATIONS MANAGEMENT          *
	 ****************************************/

	inline void addInvolution();

	inline void addPermutation();

Pierre Kraemer's avatar
Pierre Kraemer committed
73 74 75
	virtual unsigned int getNbInvolutions() const = 0;
	virtual unsigned int getNbPermutations() const = 0;

76
	template <int I>
77
	inline Dart getInvolution(Dart d) const;
78 79

	template <int I>
80
	inline Dart getPermutation(Dart d) const;
81 82

	template <int I>
83
	inline Dart getPermutationInv(Dart d) const;
84 85

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
86
	inline void involutionSew(Dart d, Dart e);
87 88

	template <int I>
Pierre Kraemer's avatar
Pierre Kraemer committed
89
	inline void involutionUnsew(Dart d);
90 91

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

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

97 98
	inline virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);

99 100 101
	/****************************************
	 *           DARTS TRAVERSALS           *
	 ****************************************/
102
public:
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
	/**
	 * Begin of map
	 * @return the first dart of the map
	 */
	inline virtual Dart begin() const;

	/**
	 * End of map
	 * @return the end iterator (next of last) of the map
	 */
	inline virtual Dart end() const;

	/**
	 * allow to go from a dart to the next
	 * in the order of storage
	 * @param d reference to the dart to be modified
	 */
	inline virtual void next(Dart& d) const;
121 122 123 124 125 126 127 128 129 130

	/****************************************
	 *             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
131 132

	void restore_topo_shortcuts();
133 134 135 136
} ;

} //namespace CGoGN

137 138
#include "Topology/generic/mapMono.hpp"

139
#endif