BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_STRUCTURE_TRIANGULATEDSURFACE_H 00006 #define BALL_STRUCTURE_TRIANGULATEDSURFACE_H 00007 00008 #ifndef BALL_STRUCTURE_TRIANGLE_H 00009 # include <BALL/STRUCTURE/triangle.h> 00010 #endif 00011 00012 #ifndef BALL_STRUCTURE_TRIANGLEEDGE_H 00013 # include <BALL/STRUCTURE/triangleEdge.h> 00014 #endif 00015 00016 #ifndef BALL_STRUCTURE_TRIANGLEPOINT_H 00017 # include <BALL/STRUCTURE/trianglePoint.h> 00018 #endif 00019 00020 #ifndef BALL_MATHS_PLANE3_H 00021 # include <BALL/MATHS/plane3.h> 00022 #endif 00023 00024 #ifndef BALL_MATHS_SURFACE_H 00025 # include <BALL/MATHS/surface.h> 00026 #endif 00027 00028 #ifndef BALL_MATHS_VECTOR3_H 00029 # include <BALL/MATHS/vector3.h> 00030 #endif 00031 00032 #include <list> 00033 #include <vector> 00034 00035 namespace BALL 00036 { 00040 class BALL_EXPORT TriangulatedSurface 00041 { 00042 00043 public: 00044 00045 BALL_CREATE(TriangulatedSurface) 00046 00047 00050 00051 typedef std::list<TrianglePoint*>::iterator 00052 PointIterator; 00053 typedef std::list<TrianglePoint*>::const_iterator 00054 ConstPointIterator; 00055 typedef std::list<TriangleEdge*>::iterator 00056 EdgeIterator; 00057 typedef std::list<TriangleEdge*>::const_iterator 00058 ConstEdgeIterator; 00059 typedef std::list<Triangle*>::iterator 00060 TriangleIterator; 00061 typedef std::list<Triangle*>::const_iterator 00062 ConstTriangleIterator; 00063 00065 00068 00072 TriangulatedSurface() 00073 ; 00074 00080 TriangulatedSurface(const TriangulatedSurface& surface, bool = true) 00081 ; 00082 00086 virtual ~TriangulatedSurface() 00087 ; 00089 00093 00103 static TriangulatedSurface* createTube(unsigned int num_vertices, unsigned int subdiv = 0, bool closed = false, bool out = true); 00104 00112 static TriangulatedSurface* createDisk(unsigned int num_vertices, bool out = true); 00114 00118 00121 void clear() 00122 ; 00123 00128 void set(const TriangulatedSurface& surface, bool = true) 00129 ; 00130 00134 TriangulatedSurface& operator = (const TriangulatedSurface& surface) 00135 ; 00136 00138 00142 00146 void insert(TrianglePoint* point); 00147 00151 void insert(TriangleEdge* edge); 00152 00156 void insert(Triangle* triangle); 00157 00161 BALL_DEPRECATED Size numberOfPoints() const; 00162 00166 Size getNumberOfPoints() const; 00167 00171 BALL_DEPRECATED Size numberOfEdges() const; 00172 00175 Size getNumberOfEdges() const; 00176 00180 BALL_DEPRECATED Size numberOfTriangles() const; 00181 00185 Size getNumberOfTriangles() const; 00186 00192 void remove(TrianglePoint* point, bool deep = true); 00193 00200 void remove(PointIterator p, bool deep = true); 00201 00207 void remove(TriangleEdge* edge, bool deep = true); 00208 00215 void remove(EdgeIterator e, bool deep = true); 00216 00222 void remove(Triangle* triangle, bool deep = true); 00223 00231 void remove(TriangleIterator t, bool deep = true); 00232 00236 void exportSurface(Surface& surface); 00237 00244 TriangulatedSurface& operator += (const TriangulatedSurface& surface); 00245 00252 void join(TriangulatedSurface& source); 00253 00258 void shift(const TVector3<double>& c); 00259 00264 void blowUp(const double& r); 00265 00268 void setIndices(); 00269 00272 void setDensity(const double& density); 00273 00276 double getDensity() const; 00277 00282 void cut(const TPlane3<double>& plane, const double& fuzzy = 0); 00283 00286 void shrink(); 00287 00290 void deleteIsolatedEdges(); 00291 00294 void deleteIsolatedPoints(); 00295 00300 void getBorder(std::list<TriangleEdge*>& border); 00301 00303 00306 00307 PointIterator beginPoint(); 00308 00309 ConstPointIterator beginPoint() const; 00310 00311 PointIterator endPoint(); 00312 00313 ConstPointIterator endPoint() const; 00314 00315 EdgeIterator beginEdge(); 00316 00317 ConstEdgeIterator beginEdge() const; 00318 00319 EdgeIterator endEdge(); 00320 00321 ConstEdgeIterator endEdge() const; 00322 00323 TriangleIterator beginTriangle(); 00324 00325 ConstTriangleIterator beginTriangle() const; 00326 00327 TriangleIterator endTriangle(); 00328 00329 ConstTriangleIterator endTriangle() const; 00330 00332 /*_ @name protected help functions 00333 */ 00335 00336 protected: 00337 00338 /*_ Test whether a TriangulatedSurface object can be copied 00339 */ 00340 bool canBeCopied() const; 00341 00342 /*_ Copy a TriangulatedSurface object 00343 */ 00344 void copy(const TriangulatedSurface& surface); 00345 00347 00348 protected: 00349 00350 /*_ @name Attributes 00351 */ 00353 00354 /*_ the number of points of the triangulated surface 00355 */ 00356 Size number_of_points_; 00357 /*_ the points of the surface. 00358 */ 00359 std::list<TrianglePoint*> points_; 00360 /*_ the number of edges of the triangulated surface 00361 */ 00362 Size number_of_edges_; 00363 /*_ the edges of the surface. 00364 */ 00365 std::list<TriangleEdge*> edges_; 00366 /*_ the number of triangles of the triangulated surface 00367 */ 00368 Size number_of_triangles_; 00369 /*_ the triangles of the surface. 00370 */ 00371 std::list<Triangle*> triangles_; 00372 00373 /*_ the density used by triangulation algorithms 00374 */ 00375 double density_; 00376 00378 00379 }; 00380 00385 00388 BALL_EXPORT std::ostream& operator << (std::ostream& s, 00389 const TriangulatedSurface& surface); 00390 00392 00393 00394 00395 00402 class BALL_EXPORT TriangulatedSphere : public TriangulatedSurface 00403 { 00404 00405 public: 00406 00407 BALL_CREATE(TriangulatedSphere) 00408 00409 struct Face 00410 { 00411 TrianglePoint* p[6]; 00412 TriangleEdge* e[9]; 00413 Position pcount; 00414 Position ecount; 00415 }; 00416 00420 00424 TriangulatedSphere() 00425 ; 00426 00432 TriangulatedSphere(const TriangulatedSphere& sphere, bool = true) 00433 ; 00434 00438 virtual ~TriangulatedSphere() 00439 ; 00441 00445 00450 void set(const TriangulatedSphere& sphere, bool = true) 00451 ; 00452 00456 TriangulatedSphere& operator = (const TriangulatedSphere& sphere) 00457 ; 00458 00460 00464 00471 void icosaeder(bool out = true); 00472 00479 void pentakisDodecaeder(bool out = true); 00480 00486 void refine(Position iterations, bool out = true); 00487 00488 00489 private: 00490 00491 /*_ Refine a triangulated sphere once. 00492 */ 00493 void refine(bool out); 00494 00495 void buildFourTriangles 00496 (Face face, 00497 Triangle* face0, 00498 Triangle* face1, 00499 Triangle* face2, 00500 Triangle* face3) 00501 ; 00502 00503 /*_ Set the incidences of a refined triangulated sphere. 00504 */ 00505 void setIncidences(); 00506 00508 00509 }; 00510 00511 } // namespace BALL 00512 00513 00514 #endif // BALL_STRUCTURE_TRIANGULATEDSURFACE_H 00515 00516