/******************************************************************************* * 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 * * * *******************************************************************************/ namespace CGoGN { template TraversorCell::TraversorCell(MAP& map, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) : m(map), dmark(NULL), cmark(NULL), quickTraversal(NULL), current(NIL), firstTraversal(true), m_good(good) { if(forceDartMarker) dmark = new DartMarker(map, thread) ; else { quickTraversal = map.template getQuickTraversal() ; if(quickTraversal != NULL) { cont = &(m.template getAttributeContainer()) ; } else { if(map.template isOrbitEmbedded()) cmark = new CellMarker(map, thread) ; else dmark = new DartMarker(map, thread) ; } } } template TraversorCell::~TraversorCell() { if(dmark) delete dmark ; else if(cmark) delete cmark ; } template Dart TraversorCell::begin() { if(quickTraversal != NULL) { qCurrent = cont->begin() ; current = (*quickTraversal)[qCurrent] ; } else { if(!firstTraversal) { if(dmark) dmark->unmarkAll() ; else cmark->unmarkAll() ; } current = m.begin() ; while(current != m.end() && (m.template isBoundaryMarked(current) || !m_good(current))) m.next(current) ; if(current == m.end()) current = NIL ; else { if(dmark) dmark->markOrbit(current) ; else cmark->mark(current) ; } firstTraversal = false ; } return current ; } template Dart TraversorCell::end() { return NIL ; } template Dart TraversorCell::next() { if(current != NIL) { if(quickTraversal != NULL) { cont->next(qCurrent) ; current = (*quickTraversal)[qCurrent] ; } else { if(dmark) { bool ismarked = dmark->isMarked(current) ; while(current != NIL && (ismarked || m.template isBoundaryMarked(current) || !m_good(current))) { m.next(current) ; if(current == m.end()) current = NIL ; else ismarked = dmark->isMarked(current) ; } if(current != NIL) dmark->markOrbit(current) ; } else { bool ismarked = cmark->isMarked(current) ; while(current != NIL && (ismarked || m.template isBoundaryMarked(current) || !m_good(current))) { m.next(current) ; if(current == m.end()) current = NIL ; else ismarked = cmark->isMarked(current) ; } if(current != NIL) cmark->mark(current) ; } } } return current ; } template void TraversorCell::skip(Dart d) { if(dmark) dmark->markOrbit(d) ; else cmark->mark(d) ; } //special version (partial specialization) for Genric Map template TraversorCell::TraversorCell(GenericMap& map, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) : m(map), dmark(NULL), cmark(NULL), quickTraversal(NULL), current(NIL), firstTraversal(true), m_good(good) { if(forceDartMarker) dmark = new DartMarker(map, thread) ; else { quickTraversal = map.template getQuickTraversal() ; if(quickTraversal != NULL) { cont = &(m.template getAttributeContainer()) ; } else { if(map.template isOrbitEmbedded()) cmark = new CellMarker(map, thread) ; else dmark = new DartMarker(map, thread) ; } } } template TraversorCell::~TraversorCell() { if(dmark) delete dmark ; else if(cmark) delete cmark ; } template Dart TraversorCell::begin() { if(quickTraversal != NULL) { qCurrent = cont->begin() ; current = (*quickTraversal)[qCurrent] ; } else { if(!firstTraversal) { if(dmark) dmark->unmarkAll() ; else cmark->unmarkAll() ; } current = m.begin() ; while(current != m.end() && (m.isBoundaryMarkedCurrent(current) || !m_good(current))) m.next(current) ; if(current == m.end()) current = NIL ; else { if(dmark) dmark->markOrbit(current) ; else cmark->mark(current) ; } firstTraversal = false ; } return current ; } template Dart TraversorCell::end() { return NIL ; } template Dart TraversorCell::next() { if(current != NIL) { if(quickTraversal != NULL) { cont->next(qCurrent) ; current = (*quickTraversal)[qCurrent] ; } else { if(dmark) { bool ismarked = dmark->isMarked(current) ; while(current != NIL && (ismarked || m.isBoundaryMarkedCurrent(current) || !m_good(current))) { m.next(current) ; if(current == m.end()) current = NIL ; else ismarked = dmark->isMarked(current) ; } if(current != NIL) dmark->markOrbit(current) ; } else { bool ismarked = cmark->isMarked(current) ; while(current != NIL && (ismarked || m.isBoundaryMarkedCurrent(current) || !m_good(current))) { m.next(current) ; if(current == m.end()) current = NIL ; else ismarked = cmark->isMarked(current) ; } if(current != NIL) cmark->mark(current) ; } } } return current ; } template void TraversorCell::skip(Dart d) { if(dmark) dmark->markOrbit(d) ; else cmark->mark(d) ; } } // namespace CGoGN