traversorFactory.hpp 7.76 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
#include "Topology/generic/traversor1.h"
#include "Topology/generic/traversor2.h"
#include "Topology/generic/traversor3.h"
#include "Topology/generic/traversorCell.h"
29
#include "Topology/generic/traversorDoO.h"
30 31 32 33 34

namespace CGoGN
{

template<typename MAP>
35
Traversor<MAP>* TraversorFactory<MAP>::createIncident(MAP& map, Dart dart, unsigned int dim, unsigned int orbX, unsigned int orbY)
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 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
{
	int code = 0x100*dim + 0x10*(orbX-VERTEX) + orbY-VERTEX;

	switch(code)
	{
		case 0x301:
			return new Traversor3XY<MAP, VERTEX, EDGE>(map,dart);
			break;
		case 0x302:
			return new Traversor3XY<MAP, VERTEX, FACE>(map,dart);
			break;
		case 0x303:
			return new Traversor3XY<MAP, VERTEX, VOLUME>(map,dart);
			break;

		case 0x310:
			return new Traversor3XY<MAP, EDGE, VERTEX>(map,dart);
			break;
		case 0x312:
			return new Traversor3XY<MAP, EDGE, FACE>(map,dart);
			break;
		case 0x313:
			return new Traversor3XY<MAP, EDGE, VOLUME>(map,dart);
			break;

		case 0x320:
			return new Traversor3XY<MAP, FACE, VERTEX>(map,dart);
			break;
		case 0x321:
			return new Traversor3XY<MAP, FACE, EDGE>(map,dart);
			break;
		case 0x323:
			return new Traversor3XY<MAP, FACE, VOLUME>(map,dart);
			break;

		case 0x330:
			return new Traversor3XY<MAP, VOLUME, VERTEX>(map,dart);
			break;
		case 0x331:
			return new Traversor3XY<MAP, VOLUME, EDGE>(map,dart);
			break;
		case 0x332:
			return new Traversor3XY<MAP, VOLUME, FACE>(map,dart);
			break;

		case 0x201:
			return new Traversor2VE<MAP>(map,dart);
			break;
		case 0x202:
			return new Traversor2VF<MAP>(map,dart);
			break;
		case 0x210:
			return new Traversor2EV<MAP>(map,dart);
			break;
		case 0x212:
			return new Traversor2EF<MAP>(map,dart);
			break;
		case 0x220:
			return new Traversor2FV<MAP>(map,dart);
			break;
		case 0x221:
			return new Traversor2FE<MAP>(map,dart);
			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>
115
Traversor<MAP>* TraversorFactory<MAP>::createAdjacent(MAP& map, Dart dart, unsigned int dim, unsigned int orbX, unsigned int orbY)
116 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 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
{
	int code = 0x100*dim + 0x10*(orbX-VERTEX) + orbY-VERTEX;

	switch(code)
	{
		case 0x301:
			return new Traversor3XXaY<MAP, VERTEX, EDGE>(map,dart);
			break;
		case 0x302:
			return new Traversor3XXaY<MAP, VERTEX, FACE>(map,dart);
			break;
		case 0x303:
			return new Traversor3XXaY<MAP, VERTEX, VOLUME>(map,dart);
			break;

		case 0x310:
			return new Traversor3XXaY<MAP, EDGE, VERTEX>(map,dart);
			break;
		case 0x312:
			return new Traversor3XXaY<MAP, EDGE, FACE>(map,dart);
			break;
		case 0x313:
			return new Traversor3XXaY<MAP, EDGE, VOLUME>(map,dart);
			break;

		case 0x320:
			return new Traversor3XXaY<MAP, FACE, VERTEX>(map,dart);
			break;
		case 0x321:
			return new Traversor3XXaY<MAP, FACE, EDGE>(map,dart);
			break;
		case 0x323:
			return new Traversor3XXaY<MAP, FACE, VOLUME>(map,dart);
			break;

		case 0x330:
			return new Traversor3XXaY<MAP, VOLUME, VERTEX>(map,dart);
			break;
		case 0x331:
			return new Traversor3XXaY<MAP, VOLUME, EDGE>(map,dart);
			break;
		case 0x332:
			return new Traversor3XXaY<MAP, VOLUME, FACE>(map,dart);
			break;

		case 0x201:
			return new Traversor2VVaE<MAP>(map,dart);
			break;
		case 0x202:
			return new Traversor2VVaF<MAP>(map,dart);
			break;
		case 0x210:
			return new Traversor2EEaV<MAP>(map,dart);
			break;
		case 0x212:
			return new Traversor2EEaF<MAP>(map,dart);
			break;
		case 0x220:
			return new Traversor2FFaV<MAP>(map,dart);
			break;
		case 0x221:
			return new Traversor2FFaE<MAP>(map,dart);
			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>
195
Traversor<MAP>* TraversorFactory<MAP>::createCell(MAP& map, unsigned int orb, const FunctorSelect& good, bool forceDartMarker, unsigned int thread)
196 197 198
{
	switch(orb)
	{
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
		case VERTEX:
			return new TraversorCell<MAP,VERTEX>(map,good,forceDartMarker,thread);
			break;
		case EDGE:
			return new TraversorCell<MAP,EDGE>(map,good,forceDartMarker,thread);
			break;
		case FACE:
			return new TraversorCell<MAP,FACE>(map,good,forceDartMarker,thread);
			break;
		case VOLUME:
			return new TraversorCell<MAP,VOLUME>(map,good,forceDartMarker,thread);
			break;
		case CC:
			return new TraversorCell<MAP,CC>(map,good,forceDartMarker,thread);
			break;
		case VERTEX1:
			return new TraversorCell<MAP,VERTEX1>(map,good,forceDartMarker,thread);
			break;
		case EDGE1:
			return new TraversorCell<MAP,EDGE1>(map,good,forceDartMarker,thread);
			break;
		case VERTEX2:
			return new TraversorCell<MAP,VERTEX2>(map,good,forceDartMarker,thread);
			break;
		case EDGE2:
			return new TraversorCell<MAP,EDGE2>(map,good,forceDartMarker,thread);
			break;
		case FACE2:
			return new TraversorCell<MAP,FACE2>(map,good,forceDartMarker,thread);
			break;
		default:
			return NULL;
			break;
232 233 234 235
	}
}

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

}