traversorFactory.hpp 7.78 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
/*******************************************************************************
* 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                                        *
*                                                                              *
*******************************************************************************/
24

25 26 27 28 29
#include "Topology/generic/traversor/traversor1.h"
#include "Topology/generic/traversor/traversor2Virt.h"
#include "Topology/generic/traversor/traversor3Virt.h"
#include "Topology/generic/traversor/traversorCellVirt.h"
#include "Topology/generic/traversor/traversorDoO.h"
30 31 32 33 34

namespace CGoGN
{

template<typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
35
Traversor* TraversorFactory<MAP>::createIncident(MAP& map, Dart dart, unsigned int dim, unsigned int orbX, unsigned int orbY)
36 37 38 39 40 41
{
	int code = 0x100*dim + 0x10*(orbX-VERTEX) + orbY-VERTEX;

	switch(code)
	{
		case 0x301:
Sylvain Thery's avatar
Sylvain Thery committed
42
			return new VTraversor3XY<MAP, VERTEX, EDGE>(map,dart);
43 44
			break;
		case 0x302:
Sylvain Thery's avatar
Sylvain Thery committed
45
			return new VTraversor3XY<MAP, VERTEX, FACE>(map,dart);
46 47
			break;
		case 0x303:
Sylvain Thery's avatar
Sylvain Thery committed
48
			return new VTraversor3XY<MAP, VERTEX, VOLUME>(map,dart);
49 50 51
			break;

		case 0x310:
Sylvain Thery's avatar
Sylvain Thery committed
52
			return new VTraversor3XY<MAP, EDGE, VERTEX>(map,dart);
53 54
			break;
		case 0x312:
Sylvain Thery's avatar
Sylvain Thery committed
55
			return new VTraversor3XY<MAP, EDGE, FACE>(map,dart);
56 57
			break;
		case 0x313:
Sylvain Thery's avatar
Sylvain Thery committed
58
			return new VTraversor3XY<MAP, EDGE, VOLUME>(map,dart);
59 60 61
			break;

		case 0x320:
Sylvain Thery's avatar
Sylvain Thery committed
62
			return new VTraversor3XY<MAP, FACE, VERTEX>(map,dart);
63 64
			break;
		case 0x321:
Sylvain Thery's avatar
Sylvain Thery committed
65
			return new VTraversor3XY<MAP, FACE, EDGE>(map,dart);
66 67
			break;
		case 0x323:
Sylvain Thery's avatar
Sylvain Thery committed
68
			return new VTraversor3XY<MAP, FACE, VOLUME>(map,dart);
69 70 71
			break;

		case 0x330:
Sylvain Thery's avatar
Sylvain Thery committed
72
			return new VTraversor3XY<MAP, VOLUME, VERTEX>(map,dart);
73 74
			break;
		case 0x331:
Sylvain Thery's avatar
Sylvain Thery committed
75
			return new VTraversor3XY<MAP, VOLUME, EDGE>(map,dart);
76 77
			break;
		case 0x332:
Sylvain Thery's avatar
Sylvain Thery committed
78
			return new VTraversor3XY<MAP, VOLUME, FACE>(map,dart);
79 80 81
			break;

		case 0x201:
Sylvain Thery's avatar
Sylvain Thery committed
82
			return new VTraversor2VE<MAP>(map,dart);
83 84
			break;
		case 0x202:
Sylvain Thery's avatar
Sylvain Thery committed
85
			return new VTraversor2VF<MAP>(map,dart);
86 87
			break;
		case 0x210:
Sylvain Thery's avatar
Sylvain Thery committed
88
			return new VTraversor2EV<MAP>(map,dart);
89 90
			break;
		case 0x212:
Sylvain Thery's avatar
Sylvain Thery committed
91
			return new VTraversor2EF<MAP>(map,dart);
92 93
			break;
		case 0x220:
Sylvain Thery's avatar
Sylvain Thery committed
94
			return new VTraversor2FV<MAP>(map,dart);
95 96
			break;
		case 0x221:
Sylvain Thery's avatar
Sylvain Thery committed
97
			return new VTraversor2FE<MAP>(map,dart);
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
			break;


		case 0x101:
			return new Traversor1VE<MAP>(map,dart);
			break;
		case 0x110:
			return new Traversor1EV<MAP>(map,dart);
			break;
		default:
			return NULL;
			break;
	}
	return NULL;
}

template<typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
115
Traversor* TraversorFactory<MAP>::createAdjacent(MAP& map, Dart dart, unsigned int dim, unsigned int orbX, unsigned int orbY)
116 117 118 119 120 121
{
	int code = 0x100*dim + 0x10*(orbX-VERTEX) + orbY-VERTEX;

	switch(code)
	{
		case 0x301:
Sylvain Thery's avatar
Sylvain Thery committed
122
			return new VTraversor3XXaY<MAP, VERTEX, EDGE>(map,dart);
123 124
			break;
		case 0x302:
Sylvain Thery's avatar
Sylvain Thery committed
125
			return new VTraversor3XXaY<MAP, VERTEX, FACE>(map,dart);
126 127
			break;
		case 0x303:
Sylvain Thery's avatar
Sylvain Thery committed
128
			return new VTraversor3XXaY<MAP, VERTEX, VOLUME>(map,dart);
129 130 131
			break;

		case 0x310:
Sylvain Thery's avatar
Sylvain Thery committed
132
			return new VTraversor3XXaY<MAP, EDGE, VERTEX>(map,dart);
133 134
			break;
		case 0x312:
Sylvain Thery's avatar
Sylvain Thery committed
135
			return new VTraversor3XXaY<MAP, EDGE, FACE>(map,dart);
136 137
			break;
		case 0x313:
Sylvain Thery's avatar
Sylvain Thery committed
138
			return new VTraversor3XXaY<MAP, EDGE, VOLUME>(map,dart);
139 140 141
			break;

		case 0x320:
Sylvain Thery's avatar
Sylvain Thery committed
142
			return new VTraversor3XXaY<MAP, FACE, VERTEX>(map,dart);
143 144
			break;
		case 0x321:
Sylvain Thery's avatar
Sylvain Thery committed
145
			return new VTraversor3XXaY<MAP, FACE, EDGE>(map,dart);
146 147
			break;
		case 0x323:
Sylvain Thery's avatar
Sylvain Thery committed
148
			return new VTraversor3XXaY<MAP, FACE, VOLUME>(map,dart);
149 150 151
			break;

		case 0x330:
Sylvain Thery's avatar
Sylvain Thery committed
152
			return new VTraversor3XXaY<MAP, VOLUME, VERTEX>(map,dart);
153 154
			break;
		case 0x331:
Sylvain Thery's avatar
Sylvain Thery committed
155
			return new VTraversor3XXaY<MAP, VOLUME, EDGE>(map,dart);
156 157
			break;
		case 0x332:
Sylvain Thery's avatar
Sylvain Thery committed
158
			return new VTraversor3XXaY<MAP, VOLUME, FACE>(map,dart);
159 160 161
			break;

		case 0x201:
Sylvain Thery's avatar
Sylvain Thery committed
162
			return new VTraversor2VVaE<MAP>(map,dart);
163 164
			break;
		case 0x202:
Sylvain Thery's avatar
Sylvain Thery committed
165
			return new VTraversor2VVaF<MAP>(map,dart);
166 167
			break;
		case 0x210:
Sylvain Thery's avatar
Sylvain Thery committed
168
			return new VTraversor2EEaV<MAP>(map,dart);
169 170
			break;
		case 0x212:
Sylvain Thery's avatar
Sylvain Thery committed
171
			return new VTraversor2EEaF<MAP>(map,dart);
172 173
			break;
		case 0x220:
Sylvain Thery's avatar
Sylvain Thery committed
174
			return new VTraversor2FFaV<MAP>(map,dart);
175 176
			break;
		case 0x221:
Sylvain Thery's avatar
Sylvain Thery committed
177
			return new VTraversor2FFaE<MAP>(map,dart);
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
			break;

		case 0x101:
			return new Traversor1VVaE<MAP>(map,dart);
			break;
		case 0x110:
			return new Traversor1EEaV<MAP>(map,dart);
			break;
		default:
			return NULL;
			break;
	}

	return NULL;
}

template<typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
195
Traversor* TraversorFactory<MAP>::createCell(MAP& map, unsigned int orb, bool forceDartMarker, unsigned int thread)
196 197 198
{
	switch(orb)
	{
199
		case VERTEX:
Sylvain Thery's avatar
Sylvain Thery committed
200
			return new VTraversorCell<MAP,VERTEX>(map,forceDartMarker,thread);
201 202
			break;
		case EDGE:
Sylvain Thery's avatar
Sylvain Thery committed
203
			return new VTraversorCell<MAP,EDGE>(map,forceDartMarker,thread);
204 205
			break;
		case FACE:
Sylvain Thery's avatar
Sylvain Thery committed
206
			return new VTraversorCell<MAP,FACE>(map,forceDartMarker,thread);
207 208
			break;
		case VOLUME:
Sylvain Thery's avatar
Sylvain Thery committed
209
			return new VTraversorCell<MAP,VOLUME>(map,forceDartMarker,thread);
210 211
			break;
		case CC:
Sylvain Thery's avatar
Sylvain Thery committed
212
			return new VTraversorCell<MAP,CC>(map,forceDartMarker,thread);
213 214
			break;
		case VERTEX1:
Sylvain Thery's avatar
Sylvain Thery committed
215
			return new VTraversorCell<MAP,VERTEX1>(map,forceDartMarker,thread);
216 217
			break;
		case EDGE1:
Sylvain Thery's avatar
Sylvain Thery committed
218
			return new VTraversorCell<MAP,EDGE1>(map,forceDartMarker,thread);
219 220
			break;
		case VERTEX2:
Sylvain Thery's avatar
Sylvain Thery committed
221
			return new VTraversorCell<MAP,VERTEX2>(map,forceDartMarker,thread);
222 223
			break;
		case EDGE2:
Sylvain Thery's avatar
Sylvain Thery committed
224
			return new VTraversorCell<MAP,EDGE2>(map,forceDartMarker,thread);
225 226
			break;
		case FACE2:
Sylvain Thery's avatar
Sylvain Thery committed
227
			return new VTraversorCell<MAP,FACE2>(map,forceDartMarker,thread);
228 229 230 231
			break;
		default:
			return NULL;
			break;
232 233 234 235
	}
}

template<typename MAP>
Sylvain Thery's avatar
Sylvain Thery committed
236
Traversor* TraversorFactory<MAP>::createDartsOfOrbits(MAP& map, Dart dart, unsigned int orb)
237 238 239
{
	switch(orb)
	{
240
		case VERTEX:
241
			return new VTraversorDartsOfOrbit<MAP,VERTEX>(map,dart);
242 243
			break;
		case EDGE:
244
			return new VTraversorDartsOfOrbit<MAP,EDGE>(map,dart);
245 246
			break;
		case FACE:
247
			return new VTraversorDartsOfOrbit<MAP,FACE>(map,dart);
248 249
			break;
		case VOLUME:
250
			return new VTraversorDartsOfOrbit<MAP,VOLUME>(map,dart);
251 252
			break;
		case CC:
253
			return new VTraversorDartsOfOrbit<MAP,CC>(map,dart);
254 255
			break;
		case VERTEX1:
256
			return new VTraversorDartsOfOrbit<MAP,VERTEX1>(map,dart);
257 258
			break;
		case EDGE1:
259
			return new VTraversorDartsOfOrbit<MAP,EDGE1>(map,dart);
260 261
			break;
		case VERTEX2:
262
			return new VTraversorDartsOfOrbit<MAP,VERTEX2>(map,dart);
263 264
			break;
		case EDGE2:
265
			return new VTraversorDartsOfOrbit<MAP,EDGE2>(map,dart);
266 267
			break;
		case FACE2:
268
			return new VTraversorDartsOfOrbit<MAP,FACE2>(map,dart);
269 270 271 272
			break;
		default:
			return NULL;
			break;
273 274 275 276
	}
}

}