00001
00002
00008 #if !defined(__geom_PointsOnManifoldN11_h__)
00009 #define __geom_PointsOnManifoldN11_h__
00010
00011
00012 BEGIN_NAMESPACE_GEOM
00013
00014
00016
00023 template<int _N, typename T>
00024 class PointsOnManifold<_N,1,1,T> {
00025
00026
00027
00028
00029 public:
00030
00032 enum {N = _N, M = 1, SD = 1};
00033
00034
00035
00036
00037
00038
00039
00040 #ifdef __INTEL_COMPILER
00041 public:
00042 #else
00043 private:
00044 #endif
00045
00047 enum Feature {NullFeature, CornerFeature, SurfaceFeature};
00048
00049
00050
00051
00052
00053 private:
00054
00056 class FaceHandle {
00057 private:
00058
00059 Feature _feature;
00060 int _index;
00061
00062 public:
00063
00064
00065
00066
00067
00069 FaceHandle() :
00070 _feature(NullFeature),
00071 _index(-1)
00072 {}
00073
00075 FaceHandle(const FaceHandle& other) :
00076 _feature(other._feature),
00077 _index(other._index)
00078 {}
00079
00081 FaceHandle&
00082 operator=(const FaceHandle& other) {
00083
00084 if (this != &other) {
00085 _feature = other._feature;
00086 _index = other._index;
00087 }
00088
00089 return *this;
00090 }
00091
00093 FaceHandle(const Feature feature, const int index) :
00094 _feature(feature),
00095 _index(index)
00096 {}
00097
00099 ~FaceHandle()
00100 {}
00101
00102
00103
00104
00105
00107 Feature
00108 getFeature() const {
00109 return _feature;
00110 }
00111
00113 int
00114 getIndex() const {
00115 return _index;
00116 }
00117
00118
00119
00120
00121
00123 void
00124 setFeature(const Feature feature) {
00125 _feature = feature;
00126 }
00127
00129 void
00130 setIndex(const int index) {
00131 _index = index;
00132 }
00133
00135 void
00136 setToNull() {
00137 _feature = NullFeature;
00138 _index = -1;
00139 }
00140 };
00141
00142
00143
00144
00145
00146 private:
00147
00149 typedef IndSimpSetIncAdj<N,M,true,T> SurfaceManifold;
00151 typedef int SizeType;
00153 typedef std::map<int,FaceHandle> PointMap;
00155 typedef typename PointMap::value_type Point;
00156
00157
00158
00159
00160
00161 public:
00162
00164 typedef T Number;
00166 typedef typename SurfaceManifold::Vertex Vertex;
00167
00168
00169
00170
00171
00172 private:
00173
00175 SurfaceManifold _surfaceManifold;
00177 ads::Array<1,int> _cornerIndices;
00179 ads::Array<1,Feature> _vertexFeatures;
00181 PointMap _points;
00183 ISS_SimplexQuery<SurfaceManifold> _simplexQuery;
00185 Number _maxCornerDistance;
00186
00188 mutable int _cachedIdentifier;
00190 mutable FaceHandle _cachedFace;
00191
00192
00193
00194
00195
00196 private:
00197
00199 PointsOnManifold();
00200
00202 PointsOnManifold(const PointsOnManifold&);
00203
00205 PointsOnManifold&
00206 operator=(const PointsOnManifold&);
00207
00208 public:
00209
00210
00213
00215
00227 template<bool A, typename V, typename IS, typename IntInIter>
00228 PointsOnManifold(const IndSimpSet<N,M,A,T,V,IS>& iss,
00229 IntInIter cornersBegin, IntInIter cornersEnd);
00230
00232
00242 template<bool A, typename V, typename IS>
00243 PointsOnManifold(const IndSimpSet<N,M,A,T,V,IS>& iss,
00244 Number maxAngleDeviation = -1);
00245
00247 ~PointsOnManifold()
00248 {}
00249
00251
00254
00256 SizeType
00257 countNumberOfPoints() const {
00258 return SizeType(_points.size());
00259 }
00260
00262 void
00263 countNumberOfPointsOnFeatures(SizeType* surfaceCount, SizeType* cornerCount)
00264 const;
00265
00267 SizeType
00268 countNumberOfSurfacePoints() const;
00269
00271 SizeType
00272 countNumberOfCornerPoints() const;
00273
00275 bool
00276 isVertexASurfaceFeature(const int n) const {
00277 return _vertexFeatures[n] == SurfaceFeature;
00278 }
00279
00281 bool
00282 isVertexACornerFeature(const int n) const {
00283 return _vertexFeatures[n] == CornerFeature;
00284 }
00285
00287 bool
00288 isOnSurface(const int identifier) const {
00289 return isOnFeature(identifier, SurfaceFeature);
00290 }
00291
00293 bool
00294 isOnCorner(const int identifier) const {
00295 return isOnFeature(identifier, CornerFeature);
00296 }
00297
00299 bool
00300 hasPoint(const int identifier) const {
00301 return _points.count(identifier) == 1;
00302 }
00303
00305
00308 int
00309 getSimplexIndex(const int identifier) const;
00310
00312
00315 int
00316 getVertexIndex(const int identifier) const;
00317
00319 Number
00320 getMaxCornerDistance() const {
00321 return _maxCornerDistance;
00322 }
00323
00325 template<typename IntInsertIterator>
00326 void
00327 getNeighborhood(const int identifier, IntInsertIterator iter) const {
00328
00329 if (isOnCorner(identifier)) {
00330 getCornerNeighborhood(getVertexIndex(identifier), iter);
00331 }
00332
00333 else {
00334 getSurfaceNeighborhood(getSimplexIndex(identifier), iter);
00335 }
00336 }
00337
00339 const Vertex&
00340 getSurfaceSimplexVertex(const int simplexIndex, const int m) const {
00341 return _surfaceManifold.getSimplexVertex(simplexIndex, m);
00342 }
00343
00345
00348
00350
00355 void
00356 setMaxCornerDistance(const Number x) {
00357 _maxCornerDistance = x;
00358 }
00359
00361 void
00362 changeIdentifier(int existingIdentifier, int newIdentifier);
00363
00365
00368 Vertex
00369 changeLocation(int pointIdentifier, const Vertex& newLocation);
00370
00372 void
00373 changeSurfaceSimplex(int pointIdentifier, int simplexIndex);
00374
00376
00379
00381 void
00382 insertAtVertex(int pointIdentifier, int vertexIndex);
00383
00385
00388 void
00389 insertAtVertices();
00390
00392
00395 Vertex
00396 insertNearPoint(int newPointID, const Vertex& position, int existingPointID);
00397
00399
00402 Vertex
00403 insertNearPoints(int newPointID, const Vertex& position,
00404 int existingPointID1, int existingPointID2);
00405
00407 Vertex
00408 insertOnASurface(int pointIdentifier, const Vertex& position);
00409
00411
00414 Vertex
00415 insert(int pointIdentifier, const Vertex& position);
00416
00418
00423 template<typename PointInputIterator, typename PointOutputIterator>
00424 void
00425 insert(PointInputIterator locationsBegin, PointInputIterator locationsEnd,
00426 PointOutputIterator closestPoints);
00427
00429
00433 template<bool A, typename V, typename IS>
00434 void
00435 insertBoundaryVertices(IndSimpSetIncAdj<N,M+1,A,T,V,IS>* mesh);
00436
00438
00442 template<template<class> class Node,
00443 template<class> class Cell,
00444 template<class,class> class Container>
00445 void
00446 insertBoundaryVertices(SimpMeshRed<N,M+1,T,Node,Cell,Container>* mesh);
00447
00449 void
00450 erase(int pointIdentifier);
00451
00453 void
00454 clearPoints() {
00455 _points.clear();
00456 }
00457
00459
00462
00464
00470 Vertex
00471 computeClosestPoint(int pointIdentifier, const Vertex& position) const;
00472
00474 void
00475 updatePoint();
00476
00478
00481
00483 void
00484 printInformation(std::ostream& out) const;
00485
00487
00488
00489
00490
00491
00492 private:
00493
00495
00498 Vertex
00499 insertInSimplex(int pointIdentifier, const Vertex& position,
00500 int simplexIndex);
00501
00503
00507 int
00508 findCornerVertex(const Vertex& position) const;
00509
00511
00514 template<typename IntInputIterator>
00515 Vertex
00516 computeClosestPointInSimplices(IntInputIterator indicesBegin,
00517 IntInputIterator indicesEnd,
00518 const Vertex& position) const;
00519
00521 Number
00522 computeClosestPointInSimplex(int simplexIndex, const Vertex& x,
00523 Vertex* closestPoint) const;
00524
00526 Vertex
00527 computeClosestPointInSimplex(int simplexIndex, const Vertex& x) const;
00528
00530 bool
00531 isOnFeature(int identifier, Feature feature) const;
00532
00534 bool
00535 isValid(const FaceHandle& face) const;
00536
00538 template<typename IntInsertIterator>
00539 void
00540 getNeighborhood(const FaceHandle& face, IntInsertIterator iter) const;
00541
00543
00546 template<typename IntInsertIterator>
00547 void
00548 getSurfaceNeighborhood(const int simplexIndex, IntInsertIterator iter) const;
00549
00551 template<typename IntInsertIterator>
00552 void
00553 getCornerNeighborhood(const int vertexIndex, IntInsertIterator iter) const;
00554
00556 void
00557 determineCorners(Number maxAngleDeviation);
00558
00560 void
00561 determineBoundaryCorners();
00562
00564 void
00565 recordCorners();
00566 };
00567
00568 END_NAMESPACE_GEOM
00569
00570 #define __geom_PointsOnManifoldN11_ipp__
00571 #include "PointsOnManifoldN11.ipp"
00572 #undef __geom_PointsOnManifoldN11_ipp__
00573
00574 #endif