contrib/gel/vsol/vsol_region_2d.h
Go to the documentation of this file.
00001 #ifndef vsol_region_2d_h_
00002 #define vsol_region_2d_h_
00003 //*****************************************************************************
00004 //:
00005 // \file
00006 // \brief  Region of a 2D space
00007 //
00008 // \author
00009 // François BERTEL
00010 //
00011 // \verbatim
00012 //  Modifications
00013 //   2000/05/02 François BERTEL Creation
00014 //   2000/06/17 Peter Vanroose  Implemented all operator==()s and type info
00015 //   2003/01/08 Peter Vanroose  Added pure virtual is_convex()
00016 //   2003/11/06 Amir Tamrakar   Added safe cast methods to polygon_2d
00017 //   2004/10/09 Peter Vanroose  Inlined all 1-line methods in class decl
00018 // \endverbatim
00019 //*****************************************************************************
00020 
00021 #include <vsol/vsol_spatial_object_2d.h>
00022 #include <vsol/vsol_point_2d_sptr.h>
00023 class vsol_polygon_2d;
00024 class vsol_poly_set_2d;
00025 
00026 class vsol_region_2d : public vsol_spatial_object_2d
00027 {
00028  protected:
00029   enum vsol_region_2d_type
00030   { REGION_NO_TYPE=0,
00031     POLYGON,
00032     POLYGON_SET,
00033     NUM_REGION_TYPES
00034   };
00035 
00036   //---------------------------------------------------------------------------
00037   //: Return the region type
00038   //---------------------------------------------------------------------------
00039   virtual vsol_region_2d_type region_type(void) const { return vsol_region_2d::REGION_NO_TYPE; }
00040 
00041  public:
00042   //---------------------------------------------------------------------------
00043   //: Return the spatial type
00044   //---------------------------------------------------------------------------
00045   vsol_spatial_object_2d_type spatial_type(void) const { return vsol_spatial_object_2d::REGION; }
00046 
00047   //***************************************************************************
00048   // Initialization
00049   //***************************************************************************
00050 
00051   //---------------------------------------------------------------------------
00052   // Destructor
00053   //---------------------------------------------------------------------------
00054   virtual ~vsol_region_2d() {}
00055 
00056   //***************************************************************************
00057   // virtuals of vsol_spatial_object_2d
00058   //***************************************************************************
00059 
00060   virtual vsol_region_2d* cast_to_region(void) { return this; }
00061   virtual vsol_region_2d const* cast_to_region(void) const { return this; }
00062 
00063   virtual vsol_polygon_2d* cast_to_polygon(void) { return 0; }
00064   virtual vsol_polygon_2d const* cast_to_polygon(void) const { return 0; }
00065 
00066   virtual vsol_poly_set_2d* cast_to_poly_set(void) { return 0; }
00067   virtual vsol_poly_set_2d const* cast_to_poly_set(void) const { return 0; }
00068   //***************************************************************************
00069   // Status report
00070   //***************************************************************************
00071 
00072   //---------------------------------------------------------------------------
00073   //: Return the area of `this'
00074   //---------------------------------------------------------------------------
00075   virtual double area(void) const=0;
00076 
00077   //---------------------------------------------------------------------------
00078   //: Return the centroid of `this'
00079   //---------------------------------------------------------------------------
00080   virtual vsol_point_2d_sptr centroid(void) const=0;
00081 
00082   //---------------------------------------------------------------------------
00083   //: Return true if this region is convex
00084   //---------------------------------------------------------------------------
00085   virtual bool is_convex(void) const=0;
00086 
00087   //: Return a platform independent string identifying the class
00088   virtual vcl_string is_a() const { return vcl_string("vsol_region_2d"); }
00089 
00090   //: Return true if the argument matches the string identifying the class or any parent class
00091   virtual bool is_class(const vcl_string& cls) const { return cls==is_a(); }
00092 };
00093 
00094 #endif // vsol_region_2d_h_