dart.h 3.86 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 29 30 31 32
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef DART_H_
#define DART_H_

#include <iostream>

namespace CGoGN
{

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

Pierre Kraemer's avatar
Pierre Kraemer committed
36
const unsigned int NB_THREAD = 16;
37

Pierre Kraemer's avatar
Pierre Kraemer committed
38
// DO NOT MODIFY (ORBIT_IN_PARENT function in Map classes)
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

const unsigned int NB_ORBITS	= 11;

const unsigned int DART			= 0;
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;


CGoGN GIT Supervisor's avatar
CGoGN GIT Supervisor committed
57

Pierre Kraemer's avatar
Pierre Kraemer committed
58 59 60 61 62 63 64 65 66 67 68 69
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; }

	Dart(unsigned int v): index(v) {}

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 117 118 119

	/**
	 * 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();

}

#endif /* DART_H_ */