00001
00002
00008 #if !defined(__geom_IndSimpSetIncAdj_h__)
00009 #define __geom_IndSimpSetIncAdj_h__
00010
00011 #if defined(DEBUG_geom) && !defined(DEBUG_IndSimpSetIncAdj)
00012 #define DEBUG_IndSimpSetIncAdj
00013 #endif
00014
00015 #ifdef DEBUG_IndSimpSetIncAdj
00016 #ifndef DEBUG_IndSimpSet
00017 #define DEBUG_IndSimpSet
00018 #endif
00019 #endif
00020
00021 #include "IndSimpSet.h"
00022 #include "SimplexAdj.h"
00023 #include "VertexSimplexInc.h"
00024 #include "IssiaFaceIterator.h"
00025
00026 BEGIN_NAMESPACE_GEOM
00027
00029
00067 template<int _N,
00068 int _M = _N,
00069 bool _A = true,
00070 typename T = double,
00071 typename V = ads::FixedArray<_N,T>,
00072 typename IS = Simplex<_M,int> >
00073 class IndSimpSetIncAdj :
00074 public IndSimpSet<_N,_M,_A,T,V,IS> {
00075
00076
00077
00078
00079 public:
00080
00082 typedef IndSimpSet<_N,_M,_A,T,V,IS> Base;
00083
00084
00085
00086
00087
00088 public:
00089
00091 enum {N = Base::N, M = Base::M, A = Base::A};
00092
00093
00094
00095
00096
00097 public:
00098
00099
00100
00101
00102
00104 typedef typename Base::Number Number;
00106 typedef typename Base::Vertex Vertex;
00108 typedef typename Base::Simplex Simplex;
00110 typedef typename Base::SimplexFace SimplexFace;
00111
00113 typedef typename Base::IndexedSimplex IndexedSimplex;
00115 typedef typename Base::IndexedSimplexFace IndexedSimplexFace;
00116
00118 typedef typename Base::VertexContainer VertexContainer;
00120 typedef typename Base::VertexConstIterator VertexConstIterator;
00122 typedef typename Base::VertexIterator VertexIterator;
00123
00125 typedef typename Base::IndexedSimplexContainer IndexedSimplexContainer;
00127 typedef typename Base::IndexedSimplexConstIterator
00128 IndexedSimplexConstIterator;
00130 typedef typename Base::IndexedSimplexIterator IndexedSimplexIterator;
00131
00133 typedef typename Base::SimplexConstIterator SimplexConstIterator;
00134
00136 typedef typename Base::SizeType SizeType;
00137
00138
00139
00140
00141
00143 typedef VertexSimplexInc<M> IncidenceContainer;
00145 typedef typename IncidenceContainer::ConstIterator IncidenceConstIterator;
00146
00148 typedef SimplexAdj<M> AdjacencyContainer;
00149
00150
00151
00153 typedef std::pair<int,int> Face;
00155 typedef IssiaFaceIterator<IndSimpSetIncAdj> FaceIterator;
00156
00157
00158
00159
00160
00161 private:
00162
00164 IncidenceContainer _vertexSimplexIncidence;
00166 AdjacencyContainer _simplexAdjacencies;
00167
00168 public:
00169
00170
00173
00175 IndSimpSetIncAdj() :
00176 Base(),
00177 _vertexSimplexIncidence(),
00178 _simplexAdjacencies()
00179 {}
00180
00182 IndSimpSetIncAdj(const IndSimpSetIncAdj& other) :
00183 Base(other),
00184 _vertexSimplexIncidence(other._vertexSimplexIncidence),
00185 _simplexAdjacencies(other._simplexAdjacencies)
00186 {}
00187
00189 IndSimpSetIncAdj&
00190 operator=(const IndSimpSetIncAdj& other) {
00191 if (&other != this) {
00192 Base::operator=(other);
00193 _vertexSimplexIncidence = other._vertexSimplexIncidence;
00194 _simplexAdjacencies = other._simplexAdjacencies;
00195 }
00196 return *this;
00197 }
00198
00200
00208 template <bool A1, bool A2>
00209 IndSimpSetIncAdj(const ads::Array<1,Vertex,A1>& vertices,
00210 const ads::Array<1,IndexedSimplex,A2>& indexedSimplices) :
00211 Base(vertices, indexedSimplices),
00212 _vertexSimplexIncidence(getVerticesSize(), getIndexedSimplices()),
00213 _simplexAdjacencies(getIndexedSimplices(), _vertexSimplexIncidence)
00214 {}
00215
00217
00223 template <bool A1, bool A2>
00224 void
00225 build(const ads::Array<1,Vertex,A1>& vertices,
00226 const ads::Array<1,IndexedSimplex,A2>& indexedSimplices) {
00227 Base::build(vertices, indexedSimplices);
00228 updateTopology();
00229 }
00230
00232
00245 IndSimpSetIncAdj(const SizeType numVertices,
00246 void* verticesData,
00247 const SizeType numSimplices,
00248 void* indexedSimplicesData) :
00249 Base(numVertices, verticesData, numSimplices,
00250 indexedSimplicesData),
00251 _vertexSimplexIncidence(getVerticesSize(), getIndexedSimplices()),
00252 _simplexAdjacencies(getIndexedSimplices(), _vertexSimplexIncidence)
00253 {}
00254
00256
00264 void
00265 build(const SizeType numVertices, void* verticesData,
00266 const SizeType numSimplices, void* indexedSimplicesData) {
00267 Base::build(numVertices, verticesData, numSimplices, indexedSimplicesData);
00268 updateTopology();
00269 }
00270
00272
00284 IndSimpSetIncAdj(const SizeType numVertices,
00285 const void* verticesData,
00286 const SizeType numSimplices,
00287 const void* indexedSimplicesData) :
00288 Base(numVertices, verticesData, numSimplices,
00289 indexedSimplicesData),
00290 _vertexSimplexIncidence(getVerticesSize(), getIndexedSimplices()),
00291 _simplexAdjacencies(getIndexedSimplices(), _vertexSimplexIncidence)
00292 {}
00293
00295
00303 void
00304 build(const SizeType numVertices, const void* verticesData,
00305 const SizeType numSimplices, const void* indexedSimplicesData) {
00306 Base::build(numVertices, verticesData, numSimplices, indexedSimplicesData);
00307 updateTopology();
00308 }
00309
00311
00320 IndSimpSetIncAdj(const SizeType numVertices, const SizeType numSimplices) :
00321 Base(numVertices, numSimplices),
00322 _vertexSimplexIncidence(),
00323 _simplexAdjacencies()
00324 {}
00325
00327
00333 void
00334 build(const SizeType numVertices, const SizeType numSimplices) {
00335 Base::build(numVertices, numSimplices);
00336 {
00337
00338 IncidenceContainer empty;
00339 _vertexSimplexIncidence.swap(empty);
00340 }
00341 {
00342
00343 AdjacencyContainer empty;
00344 _simplexAdjacencies.swap(empty);
00345 }
00346 }
00347
00349 void
00350 swap(IndSimpSetIncAdj& x) {
00351 Base::swap(x);
00352 _vertexSimplexIncidence.swap(x._vertexSimplexIncidence);
00353 _simplexAdjacencies.swap(x._simplexAdjacencies);
00354 }
00355
00357
00360 IndSimpSetIncAdj(const Base& iss) :
00361 Base(iss),
00362 _vertexSimplexIncidence(getVerticesSize(), getIndexedSimplices()),
00363 _simplexAdjacencies(getIndexedSimplices(), _vertexSimplexIncidence)
00364 {}
00365
00367 virtual
00368 ~IndSimpSetIncAdj()
00369 {}
00370
00372
00376
00377
00379 using Base::getSpaceDimension;
00380
00382 using Base::getVerticesSize;
00383
00385 using Base::areVerticesEmpty;
00386
00388 using Base::getVerticesBeginning;
00389
00391 using Base::getVerticesEnd;
00392
00394 using Base::getVertex;
00395
00397 using Base::getVertices;
00398
00400
00404
00405
00407 using Base::getSimplexDimension;
00408
00410 using Base::getSimplicesSize;
00411
00413 using Base::areSimplicesEmpty;
00414
00416 using Base::isEmpty;
00417
00419 using Base::getIndexedSimplicesBeginning;
00420
00422 using Base::getIndexedSimplicesEnd;
00423
00425 using Base::getIndexedSimplex;
00426
00428 using Base::getIndexedSimplices;
00429
00431 using Base::getSimplicesBeginning;
00432
00434 using Base::getSimplicesEnd;
00435
00437 using Base::getSimplexVertex;
00438
00440 using Base::getSimplex;
00441
00443
00444
00446
00449
00451 const IncidenceContainer&
00452 getVertexSimplexIncidence() const {
00453 return _vertexSimplexIncidence;
00454 }
00455
00457 SizeType
00458 getIncidentSize(const int n) const {
00459 return _vertexSimplexIncidence.getSize(n);
00460 }
00461
00463 bool
00464 isIncidentEmpty(const int n) const {
00465 return _vertexSimplexIncidence.isEmpty(n);
00466 }
00467
00469 IncidenceConstIterator
00470 getIncidentBeginning(const int n) const {
00471 return _vertexSimplexIncidence.getBeginning(n);
00472 }
00473
00475 IncidenceConstIterator
00476 getIncidentEnd(const int n) const {
00477 return _vertexSimplexIncidence.getEnd(n);
00478 }
00479
00481 int
00482 getIncident(const int n, const int m) const {
00483 return _vertexSimplexIncidence(n, m);
00484 }
00485
00487
00490
00492 const AdjacencyContainer&
00493 getSimplexAdjacencies() const {
00494 return _simplexAdjacencies;
00495 }
00496
00498 int
00499 getAdjacentSize(const int n) const {
00500 return _simplexAdjacencies.getSize(n);
00501 }
00502
00504
00507 int
00508 getAdjacent(const int n, const int m) const {
00509 return _simplexAdjacencies(n, m);
00510 }
00511
00513 int
00514 getMirrorIndex(const int n, const int m) const {
00515 const int a = getAdjacent(n, m);
00516 if (a == -1) {
00517 return -1;
00518 }
00519 #ifdef DEBUG_geom
00520 const int mi = _simplexAdjacencies(a).find_index(n);
00521 assert(0 <= mi && mi < M + 1);
00522 return mi;
00523 #else
00524 return _simplexAdjacencies(a).find_index(n);
00525 #endif
00526 }
00527
00529
00532
00534
00537 SizeType
00538 computeFacesSize() const {
00539 return int(std::distance(getFacesBeginning(), getFacesEnd()));
00540 }
00541
00543 FaceIterator
00544 getFacesBeginning() const {
00545 FaceIterator x(this, 0);
00546 return x;
00547 }
00548
00550 FaceIterator
00551 getFacesEnd() const {
00552 return FaceIterator(this, getSimplicesSize());
00553 }
00554
00556 bool
00557 isOnBoundary(const Face& f) const {
00558 return getAdjacent(f.first, f.second) == -1;
00559 }
00560
00562 bool
00563 isOnBoundary(const FaceIterator& f) const {
00564 return isOnBoundary(*f);
00565 }
00566
00568
00571
00573
00576 bool
00577 isVertexOnBoundary(int index) const;
00578
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00608 void
00609 reverseOrientation(const int n) {
00610 std::swap(getIndexedSimplices()[n][0], getIndexedSimplices()[n][1]);
00611 std::swap(_simplexAdjacencies(n)[0], _simplexAdjacencies(n)[1]);
00612 }
00613
00615
00618
00620
00624 virtual
00625 void
00626 updateTopology() {
00627 _vertexSimplexIncidence.build(getVerticesSize(), getIndexedSimplices());
00628 _simplexAdjacencies.build(getIndexedSimplices(), _vertexSimplexIncidence);
00629 }
00630
00632 };
00633
00634 END_NAMESPACE_GEOM
00635
00636 #define __geom_IndSimpSetIncAdj_ipp__
00637 #include "IndSimpSetIncAdj.ipp"
00638 #undef __geom_IndSimpSetIncAdj_ipp__
00639
00640 #endif