00001
00002
00003
00004
00005
00006 #ifndef BALL_STRUCTURE_TRIANGULATEDSURFACE_H
00007 #define BALL_STRUCTURE_TRIANGULATEDSURFACE_H
00008
00009 #ifndef BALL_STRUCTURE_TRIANGLE_H
00010 # include <BALL/STRUCTURE/triangle.h>
00011 #endif
00012
00013 #ifndef BALL_STRUCTURE_TRIANGLEEDGE_H
00014 # include <BALL/STRUCTURE/triangleEdge.h>
00015 #endif
00016
00017 #ifndef BALL_STRUCTURE_TRIANGLEPOINT_H
00018 # include <BALL/STRUCTURE/trianglePoint.h>
00019 #endif
00020
00021 #ifndef BALL_MATHS_PLANE3_H
00022 # include <BALL/MATHS/plane3.h>
00023 #endif
00024
00025 #ifndef BALL_MATHS_SURFACE_H
00026 # include <BALL/MATHS/surface.h>
00027 #endif
00028
00029 #ifndef BALL_MATHS_VECTOR3_H
00030 # include <BALL/MATHS/vector3.h>
00031 #endif
00032
00033 #include <list>
00034 #include <vector>
00035
00036 namespace BALL
00037 {
00041 class BALL_EXPORT TriangulatedSurface
00042 {
00043
00044 public:
00045
00046 BALL_CREATE(TriangulatedSurface)
00047
00048
00051
00052 typedef std::list<TrianglePoint*>::iterator
00053 PointIterator;
00054 typedef std::list<TrianglePoint*>::const_iterator
00055 ConstPointIterator;
00056 typedef std::list<TriangleEdge*>::iterator
00057 EdgeIterator;
00058 typedef std::list<TriangleEdge*>::const_iterator
00059 ConstEdgeIterator;
00060 typedef std::list<Triangle*>::iterator
00061 TriangleIterator;
00062 typedef std::list<Triangle*>::const_iterator
00063 ConstTriangleIterator;
00064
00066
00069
00073 TriangulatedSurface()
00074 ;
00075
00081 TriangulatedSurface(const TriangulatedSurface& surface, bool = true)
00082 ;
00083
00087 virtual ~TriangulatedSurface()
00088 ;
00090
00094
00104 static TriangulatedSurface* createTube(unsigned int num_vertices, unsigned int subdiv = 0, bool closed = false, bool out = true);
00105
00113 static TriangulatedSurface* createDisk(unsigned int num_vertices, bool out = true);
00115
00119
00122 void clear()
00123 ;
00124
00129 void set(const TriangulatedSurface& surface, bool = true)
00130 ;
00131
00135 TriangulatedSurface& operator = (const TriangulatedSurface& surface)
00136 ;
00137
00139
00143
00147 void insert(TrianglePoint* point);
00148
00152 void insert(TriangleEdge* edge);
00153
00157 void insert(Triangle* triangle);
00158
00162 BALL_DEPRECATED Size numberOfPoints() const;
00163
00167 Size getNumberOfPoints() const;
00168
00172 BALL_DEPRECATED Size numberOfEdges() const;
00173
00176 Size getNumberOfEdges() const;
00177
00181 BALL_DEPRECATED Size numberOfTriangles() const;
00182
00186 Size getNumberOfTriangles() const;
00187
00193 void remove(TrianglePoint* point, bool deep = true);
00194
00201 void remove(PointIterator p, bool deep = true);
00202
00208 void remove(TriangleEdge* edge, bool deep = true);
00209
00216 void remove(EdgeIterator e, bool deep = true);
00217
00223 void remove(Triangle* triangle, bool deep = true);
00224
00232 void remove(TriangleIterator t, bool deep = true);
00233
00237 void exportSurface(Surface& surface);
00238
00245 TriangulatedSurface& operator += (const TriangulatedSurface& surface);
00246
00253 void join(TriangulatedSurface& source);
00254
00259 void shift(const TVector3<double>& c);
00260
00265 void blowUp(const double& r);
00266
00269 void setIndices();
00270
00273 void setDensity(const double& density);
00274
00277 double getDensity() const;
00278
00283 void cut(const TPlane3<double>& plane, const double& fuzzy = 0);
00284
00287 void shrink();
00288
00291 void deleteIsolatedEdges();
00292
00295 void deleteIsolatedPoints();
00296
00301 void getBorder(std::list<TriangleEdge*>& border);
00302
00304
00307
00308 PointIterator beginPoint();
00309
00310 ConstPointIterator beginPoint() const;
00311
00312 PointIterator endPoint();
00313
00314 ConstPointIterator endPoint() const;
00315
00316 EdgeIterator beginEdge();
00317
00318 ConstEdgeIterator beginEdge() const;
00319
00320 EdgeIterator endEdge();
00321
00322 ConstEdgeIterator endEdge() const;
00323
00324 TriangleIterator beginTriangle();
00325
00326 ConstTriangleIterator beginTriangle() const;
00327
00328 TriangleIterator endTriangle();
00329
00330 ConstTriangleIterator endTriangle() const;
00331
00333
00334
00336
00337 protected:
00338
00339
00340
00341 bool canBeCopied() const;
00342
00343
00344
00345 void copy(const TriangulatedSurface& surface);
00346
00348
00349 protected:
00350
00351
00352
00354
00355
00356
00357 Size number_of_points_;
00358
00359
00360 std::list<TrianglePoint*> points_;
00361
00362
00363 Size number_of_edges_;
00364
00365
00366 std::list<TriangleEdge*> edges_;
00367
00368
00369 Size number_of_triangles_;
00370
00371
00372 std::list<Triangle*> triangles_;
00373
00374
00375
00376 double density_;
00377
00379
00380 };
00381
00386
00389 BALL_EXPORT std::ostream& operator << (std::ostream& s,
00390 const TriangulatedSurface& surface);
00391
00393
00394
00395
00396
00403 class BALL_EXPORT TriangulatedSphere : public TriangulatedSurface
00404 {
00405
00406 public:
00407
00408 BALL_CREATE(TriangulatedSphere)
00409
00410 struct Face
00411 {
00412 TrianglePoint* p[6];
00413 TriangleEdge* e[9];
00414 Position pcount;
00415 Position ecount;
00416 };
00417
00421
00425 TriangulatedSphere()
00426 ;
00427
00433 TriangulatedSphere(const TriangulatedSphere& sphere, bool = true)
00434 ;
00435
00439 virtual ~TriangulatedSphere()
00440 ;
00442
00446
00451 void set(const TriangulatedSphere& sphere, bool = true)
00452 ;
00453
00457 TriangulatedSphere& operator = (const TriangulatedSphere& sphere)
00458 ;
00459
00461
00465
00472 void icosaeder(bool out = true);
00473
00480 void pentakisDodecaeder(bool out = true);
00481
00487 void refine(Position iterations, bool out = true);
00488
00489
00490 private:
00491
00492
00493
00494 void refine(bool out);
00495
00496 void buildFourTriangles
00497 (Face face,
00498 Triangle* face0,
00499 Triangle* face1,
00500 Triangle* face2,
00501 Triangle* face3)
00502 ;
00503
00504
00505
00506 void setIncidences();
00507
00509
00510 };
00511
00512 }
00513
00514
00515 #endif // BALL_STRUCTURE_TRIANGULATEDSURFACE_H
00516
00517