Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

SIG_GeometryIterator.h

00001 #ifndef SIGEL_ROBOT_SIG_GEOMETRYITERATOR_H
00002 #define SIGEL_ROBOT_SIG_GEOMETRYITERATOR_H
00003 
00004 namespace SIGEL_Robot { class SIG_GeometryIterator; }
00005 
00006 #include "SIGEL_Robot/SIG_Geometry.h"
00007 #include "SIGEL_Robot/SIG_Polygon.h"
00008 
00009 namespace SIGEL_Robot {
00021   class SIG_GeometryIterator {
00022   private:
00023     SIG_Geometry const *iterating;
00024     int iteration;
00025 
00026   public:
00033     SIG_GeometryIterator (SIG_Geometry const *over);
00037     ~SIG_GeometryIterator (void);
00038 
00042     bool valid (void) const;
00046     operator bool (void) const { return valid (); }
00050     SIG_Polygon const & current (void) const;
00054     void next (void);
00058     inline SIG_Polygon const & iterate (void)
00059       { SIG_Polygon const & a = current (); next (); return a; }
00060   };
00061 }
00062 
00063 /* 
00064 How to use the geometry iterator:
00065 
00066 Say you have got a geometry g for which you want to know
00067 the data of all polygons.
00068 
00069 SIG_Geometry *g = ......;
00070 
00071 SIG_GeometryIterator git (g);
00072 while (git) {
00073     SIG_Polygon const & poly = git.iterate ();
00074     cout << "The polygon has "
00075          << poly.getNumVertices ()
00076          << " vertices.\n";
00077     cout << "They are:\n";
00078     for (int i = 0; i < poly.getNumVertices (); i++) {
00079         cout << "With index "
00080              << poly.getVertexIndex (i)
00081              << ": ";
00082         DL_vector v = poly.getVertex (i);
00083         cout << v.get (0) << ","
00084              << v.get (1) << ","
00085              << v.get (2) << "\n";
00086     }
00087 }
00088 */
00089 
00090 #endif

Generated at Mon Sep 3 01:32:22 2001 for PG 368 - SIGEL by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000