ihm3.h 9.06 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 32 33 34 35 36 37 38 39
/*******************************************************************************
* 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 __IMPLICIT_HIERARCHICAL_MAP3__
#define __IMPLICIT_HIERARCHICAL_MAP3__

#include "Topology/map/embeddedMap3.h"

namespace CGoGN
{

template<typename T, unsigned int ORBIT> class AttributeHandler_IHM ;



class ImplicitHierarchicalMap3 : public EmbeddedMap3
{
    template<typename T, unsigned int ORBIT> friend class AttributeHandler_IHM ;
40
	typedef EmbeddedMap3::TOPO_MAP TOPO_MAP;
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

private:
    unsigned int m_curLevel ;
    unsigned int m_maxLevel ;
    unsigned int m_edgeIdCount ;
    unsigned int m_faceIdCount;

    DartAttribute<unsigned int, ImplicitHierarchicalMap3> m_dartLevel ;
    DartAttribute<unsigned int, ImplicitHierarchicalMap3> m_edgeId ;
    DartAttribute<unsigned int, ImplicitHierarchicalMap3> m_faceId ;

    AttributeMultiVector<unsigned int>* m_nextLevelCell[NB_ORBITS] ;

public:
    ImplicitHierarchicalMap3() ;

    ~ImplicitHierarchicalMap3() ;

    static const unsigned int DIMENSION = 3 ;

    //!
    /*!
     *
     */
    void update_topo_shortcuts();

    //!
    /*!
     *
     */
    void initImplicitProperties();

    /**
     * clear the map
     * @param remove attrib remove attribute (not only clear the content)
     */
    void clear(bool removeAttrib);

    /***************************************************
     *             ATTRIBUTES MANAGEMENT               *
     ***************************************************/

83 84
//	template <typename T, unsigned int ORBIT, typename MAP>
//	AttributeHandler_IHM<T, ORBIT, MAP> addAttribute(const std::string& nameAttr) ;
85

86 87
//	template <typename T, unsigned int ORBIT, typename MAP>
//	AttributeHandler_IHM<T, ORBIT, MAP> getAttribute(const std::string& nameAttr) ;
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

    /***************************************************
     *                 MAP TRAVERSAL                   *
     ***************************************************/

    inline Dart newDart() ;

    inline Dart phi1(Dart d) const;

    inline Dart phi_1(Dart d) const;

    inline Dart phi2(Dart d) const;

private:
    inline Dart phi2bis(Dart d) const;

public:
    inline Dart phi3(Dart d) const;

    inline Dart alpha0(Dart d) const;

    inline Dart alpha1(Dart d) const;

    inline Dart alpha2(Dart d) const;

    inline Dart alpha_2(Dart d) const;

    inline Dart begin() const;

    inline Dart end() const;

    inline void next(Dart& d) const ;

    template <unsigned int ORBIT, typename FUNC>
122
	void foreach_dart_of_orbit(Cell<ORBIT> c, FUNC f) const ;
123
    template <unsigned int ORBIT, typename FUNC>
124
	void foreach_dart_of_orbit(Cell<ORBIT> c, FUNC& f) const ;
125 126

    template <typename FUNC>
127
	void foreach_dart_of_vertex(Dart d, FUNC& f) const ;
128 129

    template <typename FUNC>
130
	void foreach_dart_of_edge(Dart d, FUNC& f) const ;
131 132

    template <typename FUNC>
133
	void foreach_dart_of_oriented_face(Dart d, FUNC& f) const;
134 135

    template <typename FUNC>
136
	void foreach_dart_of_face(Dart d, FUNC& f) const ;
137 138

    template <typename FUNC>
139
	void foreach_dart_of_oriented_volume(Dart d, FUNC& f) const;
140 141

    template <typename FUNC>
142
	void foreach_dart_of_volume(Dart d, FUNC& f) const ;
143 144

    template <typename FUNC>
145
	void foreach_dart_of_vertex1(Dart d, FUNC& f) const;
146 147

    template <typename FUNC>
148
	void foreach_dart_of_edge1(Dart d, FUNC& f) const;
149 150

    template <typename FUNC>
151
	void foreach_dart_of_vertex2(Dart d, FUNC& f) const;
152 153

    template <typename FUNC>
154
	void foreach_dart_of_edge2(Dart d, FUNC& f) const;
155 156

    template <typename FUNC>
157
	void foreach_dart_of_face2(Dart d, FUNC& f) const;
158 159

    template <typename FUNC>
160
	void foreach_dart_of_cc(Dart d, FUNC& f) const ;
161 162 163 164 165

    /***************************************************
     *               MAP MANIPULATION                  *
     ***************************************************/

166

167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
    /***************************************************
     *              LEVELS MANAGEMENT                  *
     ***************************************************/
    void incCurrentLevel();

    void decCurrentLevel();

    unsigned int getCurrentLevel() const ;

    void setCurrentLevel(unsigned int l) ;

    unsigned int getMaxLevel() const ;

    unsigned int getDartLevel(Dart d) const ;

    void setDartLevel(Dart d, unsigned int i) ;

    /***************************************************
     *                  ID MANAGEMENT                  *
     ***************************************************/
    //! Give a new unique id to all the edges of the map
    /*!
     */
    void initEdgeId() ;

    //! Return the next available edge id
    /*!
     */
    unsigned int getNewEdgeId() ;

    //! Return the id of the edge of d
    /*!
     */
    unsigned int getEdgeId(Dart d) ;

    //! Set an edge id to all darts from an orbit of d
    /*!
     */
205 206 207
	void setEdgeId(Dart d, unsigned int i); //TODO a virer
	void setDartEdgeId(Dart d, unsigned int i);

Lionel Untereiner's avatar
Lionel Untereiner committed
208
	unsigned int triRefinementEdgeId(Dart d);
209

Lionel Untereiner's avatar
Lionel Untereiner committed
210
	unsigned int quadRefinementEdgeId(Dart d);
211 212 213



214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229

    //! Give a new unique id to all the faces of the map
    /*!
     */
    void initFaceId() ;

    //! Return the next available face id
    /*!
     */
    unsigned int getNewFaceId() ;

    //! Return the id of the face of d
    /*!
     */
    unsigned int getFaceId(Dart d) ;

Lionel Untereiner's avatar
Lionel Untereiner committed
230 231
	unsigned int faceId(Dart d);

232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
    //! Set a face id to all darts from an orbit of d
    /*!
     */
    void setFaceId(Dart d, unsigned int i, unsigned int orbit); //TODO a virer
    void setFaceId(unsigned int orbit, Dart d);

    /***************************************************
     *               CELLS INFORMATION                 *
     ***************************************************/

    //! Return the level of insertion of the vertex of d
    /*!
     */
    unsigned int vertexInsertionLevel(Dart d) const;
};

//TODO existe deja dans le fichier ihm2.h
//template <typename T, unsigned int ORBIT>
//class AttributeHandler_IHM : public AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>
//{
//public:
//    typedef T DATA_TYPE ;

//    AttributeHandler_IHM() : AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>()
//    {}

//    AttributeHandler_IHM(ImplicitHierarchicalMap3* m, AttributeMultiVector<T>* amv) : AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>(m, amv)
//    {}

//    AttributeMultiVector<T>* getDataVector() const
//    {
//        return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>::getDataVector() ;
//    }

//    bool isValid() const
//    {
//        return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>::isValid() ;
//    }

//    virtual T& operator[](Dart d) ;

//    virtual const T& operator[](Dart d) const ;

//    T& operator[](unsigned int a)
//    {
//        return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>::operator[](a) ;
//    }

//    const T& operator[](unsigned int a) const
//    {
//        return AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3>::operator[](a) ;
//    }

//} ;

//template <typename T>
//class VertexAttribute_IHM : public AttributeHandler_IHM<T, VERTEX>
//{
//public:
//    VertexAttribute_IHM() : IHM::AttributeHandler_IHM<T, VERTEX>() {}
//    VertexAttribute_IHM(const IHM::AttributeHandler_IHM<T, VERTEX>& ah) : IHM::AttributeHandler_IHM<T, VERTEX>(ah) {}
////	VertexAttribute_IHM<T>& operator=(const IHM::AttributeHandler_IHM<T, VERTEX>& ah) { this->IHM::AttributeHandler_IHM<T, VERTEX>::operator=(ah); return *this; }
//};


} //namespace CGoGN

#include "Topology/ihmap/ihm3.hpp"

#endif