cells.h 4.73 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 CELLS_H_
#define CELLS_H_

Pierre Kraemer's avatar
Pierre Kraemer committed
28
#include "Topology/generic/dart.h"
29 30
//#include "Topology/generic/traversor/traversor2.h"
//#include "Topology/generic/traversor/traversor3.h"
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

namespace CGoGN
{

/**
 * class for cellular typing
 *
 * warning to automatic conversion
 * cell -> Dart (or const Dart&) ok
 * Dart -> Cell (or const Cell&) ok
 */
template <unsigned int ORBIT>
class Cell
{
public:
Sylvain Thery's avatar
Sylvain Thery committed
46
	Dart dart;
Pierre Kraemer's avatar
Pierre Kraemer committed
47 48

	/// empty construtor
Sylvain Thery's avatar
Sylvain Thery committed
49
	Cell(): dart() {}
Pierre Kraemer's avatar
Pierre Kraemer committed
50

Sylvain Thery's avatar
Sylvain Thery committed
51
	/// constructor from Dart
Sylvain Thery's avatar
Sylvain Thery committed
52
	inline Cell(Dart d): dart(d) {}
Pierre Kraemer's avatar
Pierre Kraemer committed
53

54
	/// copy constructor
Sylvain Thery's avatar
Sylvain Thery committed
55
	inline Cell(const Cell<ORBIT>& c): dart(c.dart) {}
Pierre Kraemer's avatar
Pierre Kraemer committed
56

57
	/// Dart cast operator
Pierre Kraemer's avatar
Pierre Kraemer committed
58 59
	inline operator Dart() const { return dart; }

60
	friend std::ostream& operator<<( std::ostream &out, const Cell<ORBIT>& fa ) { return out << fa.dart; }
Pierre Kraemer's avatar
Pierre Kraemer committed
61 62

	inline bool valid() const { return !dart.isNil(); }
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 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

//	template <unsigned int ORBIT_TO, typename MAP, typename FUNC>
//	inline void foreach_incident(MAP& map, FUNC f)
//	{
//		switch (MAP::DIMENSION)
//		{
//			case 2 : foreach_incident2(map, f); break;
//			case 3 : foreach_incident3(map, f); break;
//		}
//	}

//	template <unsigned int ORBIT_TO, typename MAP, typename FUNC>
//	inline void foreach_adjacent(MAP& map, FUNC f)
//	{
//		switch (MAP::DIMENSION)
//		{
//			case 2 : foreach_adjacent2(map, f); break;
//			case 3 : foreach_adjacent3(map, f); break;
//		}
//	}

//	template <unsigned int ORBIT_TO, typename MAP, typename FUNC>
//	inline void foreach_incident2(MAP& map, FUNC f)
//	{
//		IncidentTrav2<MAP,ORBIT,ORBIT_TO> trav(const_cast<const MAP&>(map), *this);
//		for (Cell<ORBIT_TO> c = trav.t.begin(), e = trav.t.end(); c.dart != e.dart; c = trav.t.next())
//			f(c);
//	}

//	template <unsigned int THRU, typename MAP, typename FUNC>
//	inline void foreach_adjacent2(MAP& map, FUNC f)
//	{
//		AdjacentTrav2<MAP,ORBIT,THRU> trav(const_cast<const MAP&>(map), *this);
//		for (Cell<ORBIT> c = trav.t.begin(), e = trav.t.end(); c.dart != e.dart; c = trav.t.next())
//			f(c);
//	}

//	template <unsigned int ORBIT_TO, typename MAP, typename FUNC>
//	inline void foreach_incident3(MAP& map, FUNC f, bool forceDartMarker = false, unsigned int thread = 0)
//	{
//		Traversor3XY<MAP,ORBIT,ORBIT_TO> trav(const_cast<const MAP&>(map),*this,forceDartMarker,thread);
//		for (Cell<ORBIT_TO> c = trav.begin(), e = trav.end(); c.dart != e.dart; c = trav.next())
//			f(c);
//	}

//	template <unsigned int THRU, typename MAP, typename FUNC>
//	inline void foreach_adjacent3(MAP& map, FUNC f, bool forceDartMarker = false, unsigned int thread = 0)
//	{
//		Traversor3XXaY<MAP,ORBIT,THRU> trav(const_cast<const MAP&>(map),*this,forceDartMarker,thread);
//		for (Cell<ORBIT> c = trav.begin(), e = trav.end(); c.dart != e.dart; c = trav.next())
//			f(c);
//	}
115 116 117 118 119
};

typedef Cell<VERTEX> Vertex;
typedef Cell<EDGE>   Edge;
typedef Cell<FACE>   Face;
Sylvain Thery's avatar
Sylvain Thery committed
120
typedef Cell<VOLUME> Vol;  // not Volume because of the namespace Volume
121

Sylvain Thery's avatar
Sylvain Thery committed
122 123 124 125 126 127

namespace Parallel
{
const unsigned int SIZE_BUFFER_THREAD = 8192;
}

128 129 130
}

#endif /* CELLS_H_ */