/******************************************************************************* * 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_COMMON__ #define __MAP_COMMON__ #include "Topology/generic/attributeHandler.h" #include "Topology/generic/cells.h" namespace CGoGN { template class MapCommon : public MAP_IMPL { typedef MAP_IMPL IMPL; protected: // protected copy constructor to prevent the copy of map MapCommon(const MapCommon& m) : MAP_IMPL(m) {} public: MapCommon() {} /**************************************** * DARTS TRAVERSALS * ****************************************/ public: //! For an orbit of a given dimension, return the number of incident cells of an other given dimension /*! @param d a dart */ template unsigned int degree(Dart d) const; template bool sameOrbit(Cell c1, Cell c2, unsigned int thread = 0) const; /**************************************** * EMBEDDING MANAGEMENT * ****************************************/ /** * get the cell index of the given dimension associated to dart d * @return EMBNULL if the orbit of d is not attached to any cell */ template inline unsigned int getEmbedding(Cell d) const; /** * Set the cell index of the given dimension associated to dart d */ template void setDartEmbedding(Dart d, unsigned int emb) ; /** * Set the cell index of the given dimension associated to dart d * !!! WARNING !!! use only on freshly inserted darts (no unref is done on old embedding) !!! WARNING !!! */ template void initDartEmbedding(Dart d, unsigned int emb) ; /** * Copy the index of the cell associated to a dart over an other dart * @param orbit the id of orbit embedding * @param dest the dart to overwrite * @param src the dart to copy */ template inline void copyDartEmbedding(Dart dest, Dart src) ; /** * Set the index of the associated cell to all the darts of an orbit * @param orbit orbit to embed * @param d a dart of the topological vertex * @param em index of attribute to store as embedding */ template void setOrbitEmbedding(Cell d, unsigned int em) ; /** * Set the index of the associated cell to all the darts of an orbit * !!! WARNING !!! use only on freshly inserted darts (no unref is done on old embedding)!!! WARNING !!! */ template void initOrbitEmbedding(Cell d, unsigned int em) ; /** * Associate an new cell to all darts of an orbit * @param orbit orbit to embed * @param d a dart of the topological cell * @return index of the attribute in table */ template unsigned int setOrbitEmbeddingOnNewCell(Cell d) ; /** * Associate an new cell to all darts of an orbit * !!! WARNING !!! use only on freshly inserted darts (no unref is done on old embedding)!!! WARNING !!! */ template unsigned int initOrbitEmbeddingOnNewCell(Cell d) ; /** * Copy the cell associated to a dart over an other dart * @param orbit attribute orbit to use * @param d the dart to overwrite (dest) * @param e the dart to copy (src) */ template void copyCellAttributes(Cell d, Cell e) ; /**************************************** * BOUNDARY MANAGEMENT * ****************************************/ protected: /** * mark a dart as belonging to boundary */ template void boundaryMark(Dart d) ; /** * unmark a dart from the boundary */ template void boundaryUnmark(Dart d) ; /** * mark an orbit as belonging to boundary */ template void boundaryMarkOrbit(Cell c) ; /** * unmark an orbit from the boundary */ template void boundaryUnmarkOrbit(Cell c) ; /** * clear all boundary markers */ template void boundaryUnmarkAll() ; public: /** * test if a dart belong to the boundary */ template inline bool isBoundaryMarked(Dart d) const ; inline bool isBoundaryMarkedCurrent(Dart d) const ; inline bool isBoundaryMarked(unsigned int dim, Dart d) const ; /**************************************** * ATTRIBUTES MANAGEMENT * ****************************************/ /** * Create an attribute for a given orbit * @param nameAttr attribute name * @return an AttributeHandler */ template inline AttributeHandler addAttribute(const std::string& nameAttr = "") ; /** * remove an attribute * @param attr a handler to the attribute to remove * @return true if remove succeed else false */ template inline bool removeAttribute(AttributeHandler& attr) ; /** * search an attribute for a given orbit * @param nameAttr attribute name * @return an AttributeHandler */ template inline AttributeHandler getAttribute(const std::string& nameAttr) ; /** * check if an attribute exist ( get, test if valid and add if necessary) * @param nameAttr attribute name * @return an AttributeHandler */ template AttributeHandler checkAttribute(const std::string& nameAttr) ; /** * swap the content of two attributes (efficient, only swap pointers) */ template bool swapAttributes(AttributeHandler& attr1, AttributeHandler& attr2) ; /** * copy the content of src attribute to dst attribute */ template bool copyAttribute(AttributeHandler& dst, AttributeHandler& src) ; /** * get a DartAttribute to an involution of the map */ inline DartAttribute getInvolution(unsigned int i); /** * get a DartAttribute to a permutation of the map */ inline DartAttribute getPermutation(unsigned int i); /** * get a DartAttribute to a permutation of the map */ inline DartAttribute getPermutationInv(unsigned int i); /**************************************** * QUICK TRAVERSAL MANAGEMENT * ****************************************/ template void enableQuickTraversal() ; template void updateQuickTraversal() ; template const AttributeMultiVector* getQuickTraversal() const; template void disableQuickTraversal() ; template void enableQuickIncidentTraversal(); template void updateQuickIncidentTraversal(); template const AttributeMultiVector > >* getQuickIncidentTraversal() const; template void disableQuickIncidentTraversal(); template void enableQuickAdjacentTraversal(); template void updateQuickAdjacentTraversal(); template const AttributeMultiVector > >* getQuickAdjacentTraversal() const; template void disableQuickAdjacentTraversal(); }; } //namespace CGoGN #include "Topology/generic/mapCommon.hpp" #endif