Commit b7931eb0 authored by untereiner's avatar untereiner

Merge cgogn:~thery/CGoGN

parents d980362e 10cf0a32
......@@ -31,7 +31,6 @@
#include "Algo/Geometry/normal.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Topology/generic/mapBrowser.h"
using namespace CGoGN ;
......
/*******************************************************************************
* 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 __CONTAINER_BROWSER__
#define __CONTAINER_BROWSER__
#include "Container/attributeContainer.h"
#include "Topology/generic/functor.h"
class AttribMap;
namespace CGoGN
{
/**
* Browser that traverses all darts and jumps over
* those not selected by the selector
*/
class DartContainerBrowserSelector : public ContainerBrowser
{
protected:
AttributeContainer* m_cont ;
const FunctorSelect* m_selector ;
public:
DartContainerBrowserSelector(AttribMap& m, const FunctorSelect& fs);
~DartContainerBrowserSelector();
unsigned int begin() const;
unsigned int end() const;
void next(unsigned int& it) const;
void enable();
void disable();
} ;
template <unsigned int CELL>
class ContainerBrowserCellMarked : public ContainerBrowser
{
protected:
AttributeContainer* m_cont ;
CellMarker<CELL>& m_marker ;
public:
ContainerBrowserCellMarked(AttribMap& m, CellMarker<CELL>& cm);
~ContainerBrowserCellMarked();
unsigned int begin() const;
unsigned int end() const;
void next(unsigned int& it) const;
void enable();
void disable();
} ;
class ContainerBrowserLinked : public ContainerBrowser
{
protected:
// The browsed map
AttributeContainer* m_cont ;
AttributeMultiVector<unsigned int>* m_links ;
bool autoAttribute ;
unsigned int m_first ;
unsigned int m_end ;
public:
ContainerBrowserLinked(AttribMap& m, unsigned int orbit);
ContainerBrowserLinked(AttributeContainer& c);
ContainerBrowserLinked(AttributeContainer& c, AttributeMultiVector<unsigned int>* links);
/**
* @brief ContainerBrowserLinked contructor that share the container and links
* @param cbl the ContainerBrowserLinked
*/
ContainerBrowserLinked(ContainerBrowserLinked& cbl);
~ContainerBrowserLinked();
unsigned int begin() const;
unsigned int end() const;
void next(unsigned int& it) const;
void enable();
void disable();
void clear();
void pushBack(unsigned int it);
// void popFront();
// void addSelected(const FunctorSelect& fs);
// void append(MapBrowserLinked& mbl);
} ;
class MapBrowserLinked : public FunctorType
{
protected:
ContainerBrowserLinked m_cbrowser;
public:
MapBrowserLinked(AttribMap& m);
Dart begin() const;
Dart end() const;
void next(Dart& d) const;
bool operator()(Dart d);
ContainerBrowserLinked& getContainerBrowser();
};
} // namespace CGoGN
#include "containerBrowser.hpp"
#endif
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#include "Topology/generic/dart.h"
#include "Topology/generic/attribmap.h"
namespace CGoGN
{
inline DartContainerBrowserSelector::DartContainerBrowserSelector(AttribMap& m, const FunctorSelect& fs)
{
m_cont = &(m.getAttributeContainer<DART>());
m_selector = fs.copy();
}
inline DartContainerBrowserSelector::~DartContainerBrowserSelector()
{
delete m_selector;
}
inline unsigned int DartContainerBrowserSelector::begin() const
{
unsigned int it = m_cont->realBegin() ;
while ( (it != m_cont->realEnd()) && !m_selector->operator()(Dart(it)) )
m_cont->realNext(it);
return it;
}
inline unsigned int DartContainerBrowserSelector::end() const
{
return m_cont->realEnd();
}
inline void DartContainerBrowserSelector::next(unsigned int& it) const
{
do
{
m_cont->realNext(it) ;
}
while ( (it != m_cont->realEnd()) && !m_selector->operator()(Dart(it)) ) ;
}
inline void DartContainerBrowserSelector::enable()
{
m_cont->setContainerBrowser(this);
}
inline void DartContainerBrowserSelector::disable()
{
m_cont->setContainerBrowser(NULL);
}
inline ContainerBrowserLinked::ContainerBrowserLinked(AttribMap& m, unsigned int orbit):
autoAttribute(true), m_first(0xffffffff), m_end(0xffffffff)
{
m_cont = &(m.getAttributeContainer(orbit));
m_links = m_cont->addAttribute<unsigned int>("Browser_Links") ;
}
inline ContainerBrowserLinked::ContainerBrowserLinked(AttributeContainer& c):
m_cont(&c), autoAttribute(true), m_first(0xffffffff), m_end(0xffffffff)
{
m_links = m_cont->addAttribute<unsigned int>("Browser_Links") ;
}
inline ContainerBrowserLinked::ContainerBrowserLinked(AttributeContainer& c, AttributeMultiVector<unsigned int>* links):
m_cont(&c), m_links(links), autoAttribute(false), m_first(0xffffffff), m_end(0xffffffff)
{}
inline ContainerBrowserLinked::ContainerBrowserLinked(ContainerBrowserLinked& cbl):
m_cont(cbl.m_cont), m_links(cbl.m_links), m_first(0xffffffff), m_end(0xffffffff)
{}
inline ContainerBrowserLinked::~ContainerBrowserLinked()
{
if (autoAttribute)
m_cont->removeAttribute<unsigned int>("Browser_Links") ;
}
inline void ContainerBrowserLinked::clear()
{
m_first = 0xffffffff;
m_end = 0xffffffff;
}
inline unsigned int ContainerBrowserLinked::begin() const
{
return m_first ;
}
inline unsigned int ContainerBrowserLinked::end() const
{
return 0xffffffff;
}
inline void ContainerBrowserLinked::next(unsigned int& it) const
{
it = (*m_links)[it] ;
}
inline void ContainerBrowserLinked::pushBack(unsigned int it)
{
(*m_links)[it] = 0xffffffff ;
if (m_first == 0xffffffff) // empty list
{
m_first = it ;
m_end = it ;
}
else
{
(*m_links)[m_end] = it ;
m_end = it ;
}
}
inline void ContainerBrowserLinked::enable()
{
m_cont->setContainerBrowser(this);
}
inline void ContainerBrowserLinked::disable()
{
m_cont->setContainerBrowser(NULL);
}
template <unsigned int CELL>
inline ContainerBrowserCellMarked<CELL>::ContainerBrowserCellMarked(AttribMap& m, CellMarker<CELL>& cm):
m_marker(cm)
{
m_cont = &(m.getAttributeContainer<CELL>());
}
template <unsigned int CELL>
inline ContainerBrowserCellMarked<CELL>::~ContainerBrowserCellMarked()
{
}
template <unsigned int CELL>
inline unsigned int ContainerBrowserCellMarked<CELL>::begin() const
{
unsigned int it = m_cont->realBegin() ;
while ( (it != m_cont->realEnd()) && !m_marker.isMarked(it) )
m_cont->realNext(it);
return it;
}
template <unsigned int CELL>
inline unsigned int ContainerBrowserCellMarked<CELL>::end() const
{
return m_cont->realEnd();
}
template <unsigned int CELL>
inline void ContainerBrowserCellMarked<CELL>::next(unsigned int& it) const
{
do
{
m_cont->realNext(it) ;
}
while ( (it != m_cont->realEnd()) && !m_marker.isMarked(it) );
}
template <unsigned int CELL>
inline void ContainerBrowserCellMarked<CELL>::enable()
{
m_cont->setContainerBrowser(this);
}
template <unsigned int CELL>
inline void ContainerBrowserCellMarked<CELL>::disable()
{
m_cont->setContainerBrowser(NULL);
}
inline MapBrowserLinked::MapBrowserLinked(AttribMap& m):
m_cbrowser(m, DART)
{}
inline Dart MapBrowserLinked::begin() const
{
return Dart(m_cbrowser.begin());
}
inline Dart MapBrowserLinked::end() const
{
return NIL;
}
inline void MapBrowserLinked::next(Dart& d) const
{
m_cbrowser.next(d.index);
}
inline bool MapBrowserLinked::operator()(Dart d)
{
m_cbrowser.pushBack(d.index);
return false;
}
inline ContainerBrowserLinked& MapBrowserLinked::getContainerBrowser()
{
return m_cbrowser;
}
} // namespace CGoGN
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment