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 ;
00149
00153 void insert(TriangleEdge* edge)
00154 ;
00155
00159 void insert(Triangle* triangle)
00160 ;
00161
00165 BALL_DEPRECATED Size numberOfPoints() const
00166 ;
00167
00171 Size getNumberOfPoints() const
00172 ;
00173
00177 BALL_DEPRECATED Size numberOfEdges() const
00178 ;
00179
00182 Size getNumberOfEdges() const
00183 ;
00184
00188 BALL_DEPRECATED Size numberOfTriangles() const
00189 ;
00190
00194 Size getNumberOfTriangles() const
00195 ;
00196
00202 void remove(TrianglePoint* point, bool deep = true)
00203 ;
00204
00211 void remove(PointIterator p, bool deep = true)
00212 ;
00213
00219 void remove(TriangleEdge* edge, bool deep = true)
00220 ;
00221
00228 void remove(EdgeIterator e, bool deep = true)
00229 ;
00230
00236 void remove(Triangle* triangle, bool deep = true)
00237 ;
00238
00246 void remove(TriangleIterator t, bool deep = true)
00247 ;
00248
00252 void exportSurface(Surface& surface)
00253 ;
00254
00261 TriangulatedSurface& operator += (const TriangulatedSurface& surface)
00262 ;
00263
00270 void join(TriangulatedSurface& source)
00271 ;
00272
00277 void shift(const TVector3<double>& c);
00278
00283 void blowUp(const double& r);
00284
00287 void setIndices();
00288
00293 void cut(const TPlane3<double>& plane, const double& fuzzy = 0);
00294
00297 void shrink();
00298
00301 void deleteIsolatedEdges()
00302 ;
00303
00306 void deleteIsolatedPoints()
00307 ;
00308
00313 void getBorder(std::list<TriangleEdge*>& border);
00314
00316
00319
00320 PointIterator beginPoint()
00321 ;
00322 ConstPointIterator beginPoint() const
00323 ;
00324 PointIterator endPoint()
00325 ;
00326 ConstPointIterator endPoint() const
00327 ;
00328
00329 EdgeIterator beginEdge()
00330 ;
00331 ConstEdgeIterator beginEdge() const
00332 ;
00333 EdgeIterator endEdge()
00334 ;
00335 ConstEdgeIterator endEdge() const
00336 ;
00337
00338 TriangleIterator beginTriangle()
00339 ;
00340 ConstTriangleIterator beginTriangle() const
00341 ;
00342 TriangleIterator endTriangle()
00343 ;
00344 ConstTriangleIterator endTriangle() const
00345 ;
00346
00348
00349
00351
00352 protected:
00353
00354
00355
00356 bool canBeCopied() const
00357 ;
00358
00359
00360
00361 void copy(const TriangulatedSurface& surface)
00362 ;
00363
00365
00366 protected:
00367
00368
00369
00371
00372
00373
00374 Size number_of_points_;
00375
00376
00377 std::list<TrianglePoint*> points_;
00378
00379
00380 Size number_of_edges_;
00381
00382
00383 std::list<TriangleEdge*> edges_;
00384
00385
00386 Size number_of_triangles_;
00387
00388
00389 std::list<Triangle*> triangles_;
00390
00392
00393 };
00394
00399
00402 BALL_EXPORT std::ostream& operator << (std::ostream& s,
00403 const TriangulatedSurface& surface);
00404
00406
00407
00408
00409
00416 class BALL_EXPORT TriangulatedSphere : public TriangulatedSurface
00417 {
00418
00419 public:
00420
00421 BALL_CREATE(TriangulatedSphere)
00422
00423 struct Face
00424 {
00425 TrianglePoint* p[6];
00426 TriangleEdge* e[9];
00427 Position pcount;
00428 Position ecount;
00429 };
00430
00434
00438 TriangulatedSphere()
00439 ;
00440
00446 TriangulatedSphere(const TriangulatedSphere& sphere, bool = true)
00447 ;
00448
00452 virtual ~TriangulatedSphere()
00453 ;
00455
00459
00464 void set(const TriangulatedSphere& sphere, bool = true)
00465 ;
00466
00470 TriangulatedSphere& operator = (const TriangulatedSphere& sphere)
00471 ;
00472
00474
00478
00485 void icosaeder(bool out = true);
00486
00493 void pentakisDodecaeder(bool out = true);
00494
00500 void refine(Position iterations, bool out = true);
00501
00502
00503 private:
00504
00505
00506
00507 void refine(bool out);
00508
00509 void buildFourTriangles
00510 (Face face,
00511 Triangle* face0,
00512 Triangle* face1,
00513 Triangle* face2,
00514 Triangle* face3)
00515 ;
00516
00517
00518
00519 void setIncidences();
00520
00522
00523 };
00524
00525 }
00526
00527
00528 #endif // BALL_STRUCTURE_TRIANGULATEDSURFACE_H
00529
00530