traversorFactory.hpp 7.79 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
#include "Topology/generic/traversor/traversor1Virt.h"
26 27 28 29
#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
			break;

		case 0x101:
101
			return new VTraversor1VE<MAP>(map,dart);
102 103
			break;
		case 0x110:
104
			return new VTraversor1EV<MAP>(map,dart);
105 106 107 108 109 110 111 112 113
			break;
		default:
			return NULL;
			break;
	}
	return NULL;
}

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

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

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

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

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

		case 0x201:
Sylvain Thery's avatar
Sylvain Thery committed
161
			return new VTraversor2VVaE<MAP>(map,dart);
162 163
			break;
		case 0x202:
Sylvain Thery's avatar
Sylvain Thery committed
164
			return new VTraversor2VVaF<MAP>(map,dart);
165 166
			break;
		case 0x210:
Sylvain Thery's avatar
Sylvain Thery committed
167
			return new VTraversor2EEaV<MAP>(map,dart);
168 169
			break;
		case 0x212:
Sylvain Thery's avatar
Sylvain Thery committed
170
			return new VTraversor2EEaF<MAP>(map,dart);
171 172
			break;
		case 0x220:
Sylvain Thery's avatar
Sylvain Thery committed
173
			return new VTraversor2FFaV<MAP>(map,dart);
174 175
			break;
		case 0x221:
Sylvain Thery's avatar
Sylvain Thery committed
176
			return new VTraversor2FFaE<MAP>(map,dart);
177 178 179
			break;

		case 0x101:
180
			return new VTraversor1VVaE<MAP>(map,dart);
181 182
			break;
		case 0x110:
183
			return new VTraversor1EEaV<MAP>(map,dart);
184 185 186 187 188 189 190 191 192 193
			break;
		default:
			return NULL;
			break;
	}

	return NULL;
}

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

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

}