dart.h 4.42 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
*                                                                              *
* 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.           *
*                                                                              *
20
* Web site: http://cgogn.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24 25 26 27 28
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef DART_H_
#define DART_H_

#include <iostream>
29
#include <string>
Pierre Kraemer's avatar
Pierre Kraemer committed
30 31 32 33

namespace CGoGN
{

CGoGN GIT Supervisor's avatar
CGoGN GIT Supervisor committed
34
const unsigned int EMBNULL = 0xffffffff;
Pierre Kraemer's avatar
Pierre Kraemer committed
35
const unsigned int MRNULL = 0xffffffff;
36

37
const unsigned int NB_THREADS = 16;
38

Pierre Kraemer's avatar
Pierre Kraemer committed
39
// DO NOT MODIFY (ORBIT_IN_PARENT function in Map classes)
40 41 42 43

const unsigned int NB_ORBITS	= 11;

const unsigned int DART			= 0;
44

45 46 47 48 49 50 51 52 53 54 55 56 57
const unsigned int VERTEX		= 1;
const unsigned int EDGE			= 2;
const unsigned int FACE			= 3;
const unsigned int VOLUME		= 4;
const unsigned int CC			= 5;

const unsigned int VERTEX1		= 6;
const unsigned int EDGE1		= 7;

const unsigned int VERTEX2		= 8;
const unsigned int EDGE2		= 9;
const unsigned int FACE2		= 10;

Pierre Kraemer's avatar
Pierre Kraemer committed
58 59 60 61 62 63 64 65 66 67
struct Dart
{
	unsigned int index;

	Dart(): index(0xffffffff) {}

	static Dart nil() { Dart d; d.index = 0xffffffff; return d; }

	static Dart create(unsigned int i) { Dart d; d.index = i; return d; }

68
	explicit Dart(unsigned int v): index(v) {}
Pierre Kraemer's avatar
Pierre Kraemer committed
69

70
	bool isNil() const { return index == 0xffffffff ; }
Pierre Kraemer's avatar
Pierre Kraemer committed
71 72 73 74 75 76 77 78 79 80 81

	/**
	 * affectation operator
	 * @param d the dart to store in this
	 */
	Dart operator=(Dart d) { index = d.index; return *this; }

	/**
	 * equality operator
	 * @param d the dart to compare with
	 */
82
	bool operator==(Dart d) const { return d.index == index; }
Pierre Kraemer's avatar
Pierre Kraemer committed
83 84 85 86 87

	/**
	 * different operator
	 * @param d the dart to compare with
	 */
88
	bool operator!=(Dart d) const { return d.index != index; }
Pierre Kraemer's avatar
Pierre Kraemer committed
89 90 91 92 93

	/**
	 * less operator, can be used for sorting
	 * @param d the dart to compare with
	 */
94
	bool operator<(Dart d) const { return index < d.index; }
Pierre Kraemer's avatar
Pierre Kraemer committed
95 96 97 98

	friend std::ostream& operator<<( std::ostream &out, const Dart& fa ) { return out << fa.index; }
	friend std::istream& operator>>( std::istream &in, Dart& fa ) { in >> fa.index; return in; }

99 100 101 102
	void operator += (const Dart& /*fa*/) {}
	void operator -= (const Dart& /*fa*/) {}
	void operator *= (double /*v*/) {}
	void operator /= (double /*v*/) {}
Pierre Kraemer's avatar
Pierre Kraemer committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116

	/**
	 * CGoGN name
	 */
	static std::string CGoGNnameOfType() { return "Dart"; }

	/**
	 * label is the index (cleaner that use d.index outside of maps
	 */
	unsigned int label() { return index; }
};

const Dart NIL = Dart::nil();

117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
inline std::string orbitName(unsigned int orbit)
{
	switch(orbit)
	{
	case DART:
		return "DART";
		break;
	case VERTEX:
		return "VERTEX";
		break;
	case EDGE:
		return "EDGE";
		break;
	case FACE:
		return "FACE";
		break;
	case VOLUME:
		return "VOLUME";
		break;
	case CC:
		return "CC";
		break;
	case VERTEX1:
		return "VERTEX1";
		break;
	case EDGE1:
		return "EDGE1";
		break;
	case VERTEX2:
		return "VERTEX2";
		break;
	case EDGE2:
		return "EDGE2";
		break;
	case FACE2:
		return "FACE2";
	default:
		break;

	}
	return "UNKNOWN";
}


Pierre Kraemer's avatar
Pierre Kraemer committed
161 162 163
}

#endif /* DART_H_ */