region2d.h

Go to the documentation of this file.
00001 /**
00002  * \file region2d.h <mi32/region2d.h>
00003  * \brief Functions and structure for regions
00004  *
00005  * \if NODOC
00006  * $Id: region2d.h_v 1.47 2004/11/16 17:15:04 dwilliss Exp $
00007  *
00008  * $Log: region2d.h_v $
00009  * Revision 1.47  2004/11/16 17:15:04  dwilliss
00010  * Added ConvertToLongTruncate
00011  *
00012  * Revision 1.46  2004/09/21 17:31:30  mju
00013  * Add clearCoordRefSys.
00014  *
00015  * Revision 1.45  2004/08/30 17:01:42  scowan
00016  * Added reverse method.
00017  *
00018  * Revision 1.44  2004/08/17 21:30:43  mju
00019  * Add updateExtentsRect for subregion and region.
00020  *
00021  * Revision 1.43  2004/08/09 23:54:01  scowan
00022  * Added set orientation methods.
00023  *
00024  * Revision 1.42  2004/07/27 15:22:34  scowan
00025  * Added private method.
00026  *
00027  * Revision 1.41  2004/07/20 16:02:18  scowan
00028  * Removed legacy region methods.
00029  *
00030  * Revision 1.40  2004/07/16 17:31:13  scowan
00031  * Added some friends.
00032  *
00033  * Revision 1.39  2004/07/09 22:26:17  scowan
00034  * Updated docs to the changes in the region code.
00035  *
00036  * Revision 1.38  2004/07/08 13:21:19  mju
00037  * Add region2d ctor/op= from subregion2d.
00038  *
00039  * Revision 1.37  2004/06/29 20:58:05  scowan
00040  * Added mem func preventors.
00041  *
00042  * Revision 1.36  2004/06/29 17:03:59  scowan
00043  * Change docs.
00044  *
00045  * Revision 1.35  2004/06/29 16:37:50  scowan
00046  * Added comments about conversion.
00047  *
00048  * Revision 1.34  2004/06/28 20:29:43  scowan
00049  * *** empty log message ***
00050  *
00051  * Revision 1.33  2004/06/28 20:29:02  scowan
00052  * Added convert to method.
00053  *
00054  * Revision 1.32  2004/06/25 21:31:47  mju
00055  * Make serializer a friend.
00056  *
00057  * Revision 1.31  2004/06/25 15:10:12  scowan
00058  * Added deprecated method to get legacy region.
00059  *
00060  * Revision 1.30  2004/06/24 20:18:22  dwilliss
00061  * forward declare COORDOP
00062  *
00063  * Revision 1.29  2004/06/24 16:00:16  scowan
00064  * Added method to set the z range.
00065  *
00066  * Revision 1.28  2004/06/24 14:55:31  scowan
00067  * Added convert methods for coord op.
00068  *
00069  * Revision 1.27  2004/06/23 22:53:39  scowan
00070  * Added coord ref sys to region2d.
00071  *
00072  * Revision 1.26  2004/03/30 22:02:13  scowan
00073  * Added get numislands method.
00074  *
00075  * Revision 1.25  2004/03/02 15:23:10  scowan
00076  * Something.
00077  *
00078  * Revision 1.24  2004/03/02 15:11:46  scowan
00079  * Removed defines when done.
00080  *
00081  * Revision 1.23  2004/03/02 00:24:47  scowan
00082  * Export from geom the class.
00083  *
00084  * Revision 1.22  2003/11/28 16:52:25  scowan
00085  * Added threshold to is equiv to method.
00086  *
00087  * Revision 1.21  2003/11/25 00:30:28  scowan
00088  * Added is equivalent to methods.
00089  *
00090  * Revision 1.20  2003/09/26 21:52:25  scowan
00091  * Added flag to convert legacy region dest to new region.
00092  *
00093  * Revision 1.19  2003/09/15 13:49:56  fileserver!dwilliss
00094  * Doxygen
00095  *
00096  * Revision 1.18  2003/09/09 17:56:39  scowan
00097  * Added another convert to long method.
00098  *
00099  * Revision 1.17  2003/08/27 21:31:04  scowan
00100  * Removed map proj param from assign method.
00101  *
00102  * Revision 1.16  2003/06/12 19:45:15  scowan
00103  * More const.
00104  *
00105  * Revision 1.15  2003/06/11 16:03:36  scowan
00106  * nc.
00107  *
00108  * Revision 1.14  2003/06/06 21:34:56  scowan
00109  * Added methods.
00110  *
00111  * Revision 1.13  2003/05/08 22:27:01  scowan
00112  * Chagned to use a 3d rect.
00113  *
00114  * Revision 1.12  2003/05/07 15:26:22  scowan
00115  * *** empty log message ***
00116  *
00117  * Revision 1.11  2003/05/07 15:24:56  scowan
00118  * Added test and assignment methods.
00119  *
00120  * Revision 1.10  2003/04/23 21:59:00  scowan
00121  * Added methods.
00122  *
00123  * Revision 1.9  2002/12/10 18:16:21  scowan
00124  * Added more friends.
00125  *
00126  * Revision 1.8  2002/11/26 21:30:17  dwilliss
00127  * never mind...
00128  *
00129  * Revision 1.7  2002/11/21 18:59:48  dwilliss
00130  * Added constructor taking MILIST<POLYLINE>&
00131  *
00132  * Revision 1.6  2002/11/13 18:22:28  scowan
00133  * Added begin and end iterators for both classes.
00134  *
00135  * Revision 1.5  2002/10/23 16:27:58  scowan
00136  * Code completed, not tested.
00137  *
00138  * Revision 1.4  2002/10/22 22:24:29  scowan
00139  * Added parameters.
00140  *
00141  * Revision 1.3  2002/10/11 21:47:06  scowan
00142  * Added intersect code.
00143  *
00144  * Revision 1.2  2002/10/11 17:07:41  scowan
00145  * Allowed vector interface class as a friend.
00146  *
00147  * Revision 1.1  2002/10/09 22:32:03  scowan
00148  * Initial revision
00149  *
00150  * \endif
00151 **/
00152 
00153 #ifndef  INC_MI32_REGION2D_H
00154 #define  INC_MI32_REGION2D_H
00155 
00156 #ifndef  INC_MI32_POLYLINE_H
00157    #include <mi32/polyline.h>
00158 #endif
00159 
00160 #ifndef  INC_MI32_RECT_H
00161    #include <mi32/rect.h>
00162 #endif
00163 
00164 #ifndef  INC_MI32_MILIST_H
00165    #include <mi32/milist.h>
00166 #endif
00167 
00168 #ifndef  INC_MI32_SPATREF_H
00169    #include <mi32/spatref.h>
00170 #endif
00171 
00172 #ifdef GEOMDLL
00173    #define GEOMLIBEXPORT MI_DLLEXPORT
00174    #define GEOMLIBCLASSEXPORT MI_DLLCLASSEXPORT
00175 #else
00176    #define GEOMLIBEXPORT MI_DLLIMPORT
00177    #define GEOMLIBCLASSEXPORT MI_DLLCLASSIMPORT
00178 #endif
00179 
00180 #ifndef GENERATING_DOXYGEN_OUTPUT
00181 class TRANS2D_AFFINE;      //!< Forward declarations
00182 class TRANS2D_MAPGEN;
00183 class REGION2D;
00184 class SERIALIZER;
00185 namespace RVC {
00186    class VECTOR;
00187    class REGION;
00188    class REGIONHANDLE;
00189    }
00190 namespace SPATREF {
00191    class COORDOP;
00192    }
00193 #endif //!< GENERATING_DOXYGEN_OUTPUT
00194 #pragma warning(disable:4251) // Stop complaining about the need to have a dll interface
00195 
00196 //! SUBREGION2D class - Definitions and methods to support a generic 2D sub-region object in memory.
00197 //! The sub-region can be represented by either a single rectangle or as a polygon and a list of zero
00198 //! or more islands.  All POLYLINE's stored in the SUBREGION are closed.
00199 
00200 class GEOMLIBCLASSEXPORT SUBREGION2D {
00201    public:
00202    
00203       typedef MILIST<POLYLINE>::CONST_ITERATOR CONST_ITERATOR;
00204    
00205       //! Default Constructor
00206       SUBREGION2D (
00207          );
00208          
00209       //! Copy Constructor
00210       SUBREGION2D (
00211          const SUBREGION2D& rhs
00212          );
00213          
00214       //! Constructor from DRECT2D
00215       SUBREGION2D (
00216          const DRECT2D& rect
00217          );
00218          
00219       //! Destructor
00220       ~SUBREGION2D (
00221          );
00222          
00223       //! Assignment operator
00224       SUBREGION2D& operator= (
00225          const SUBREGION2D& rhs
00226          );
00227 
00228       //! Assignment operator from rectangle
00229       SUBREGION2D& operator= (
00230          const DRECT2D& rhs
00231          );
00232 
00233       //! Assigns the sub-region to the passed in polygon
00234       //! This will clear any existing information in 'this'
00235       ERRVALUE Assign (
00236          const POLYLINE& Polygon
00237          );
00238 
00239       //! Assigns the sub-region to the passed in polygon.
00240       //! A validated polygon is a polygon that does not intersect itself.
00241       //! This will clear any existing information in 'this'
00242       void AssignValidated (
00243          const POLYLINE& Polygon
00244          );
00245          
00246       //! Get the beginning of the list of POLYLINE's.
00247       //! The first item is the shell polygon, the rest following are islands.
00248       //! @return Iterator to the beginning of the POLYLINE list
00249       CONST_ITERATOR Begin (
00250          ) const { return (m_ItemList.Begin()); }
00251 
00252       //! Clear the sub-region
00253       void Clear (
00254          );
00255          
00256       //! Clip a polyline to a sub-region, call the ClipTarget for each segment
00257       //! @return TRUE if part of the line is clipped, FALSE if not, < 0 error
00258       int ClipLine (
00259          POLYLINE& PolyLine,
00260          POLYLINE::CLIP& ClipTarget,
00261          CLIPMODE ClipMode = CLIPMODE_Inside
00262          ) const;
00263          
00264       //! Compute the sub-region area in sub-region units
00265       double ComputeArea (
00266          ) const;
00267    
00268       //! Compute the sub-region area in sub-region units but do not exclude islands in the calculation
00269       double ComputeAreaNoIslands (
00270          ) const;
00271    
00272       //! Compute the sub-region perimeter in sub-region units
00273       double ComputePerimeter (
00274          ) const;
00275    
00276       //! Compute the sub-region perimeter in sub-region units but do not include islands in the calculation
00277       double ComputePerimeterNoIslands (
00278          ) const;
00279    
00280       //! Translate the sub-region using an affine transformation
00281       void ConvertForward (
00282          const TRANS2D_AFFINE& taf
00283          );
00284    
00285       //! Translate the sub-region using a mapgen transformation
00286       ERRVALUE ConvertForward (
00287          const TRANS2D_MAPGEN& tmg
00288          );
00289    
00290       //! Translate the subregion using a coordinate operation (SPATREF::COORDOP) transformation
00291       ERRVALUE ConvertForward (
00292          const SPATREF::COORDOP& Op
00293          );
00294    
00295       //! Translate the sub-region using a mapgen transformation with densification
00296       //! If the sub-region is the extents only, this will convert it to a polygon sub-region
00297       //! before doing the transformation
00298       ERRVALUE ConvertForwardDense (
00299          const TRANS2D_MAPGEN& tmg
00300          );
00301    
00302       //! Translate the region using a coordinate operation (SPATREF::COORDOP) transformation with densification
00303       //! If the region is the extents only, this will convert it to a proper sub-region
00304       //! before doing the transformation
00305       ERRVALUE ConvertForwardDense (
00306          const SPATREF::COORDOP& Op,
00307          double tolerance
00308          );
00309 
00310       //! Translate the sub-region using an affine transformation
00311       void ConvertInverse (
00312          const TRANS2D_AFFINE& taf
00313          );
00314    
00315       //! Translate the sub-region using a mapgen transformation
00316       ERRVALUE ConvertInverse (
00317          const TRANS2D_MAPGEN& tmg
00318          );
00319    
00320       //! Translate the sub-region using a mapgen transformation with densification
00321       //! If the sub-region is the extents only, this will convert it to a polygon sub-region
00322       //! before doing the transformation
00323       ERRVALUE ConvertInverseDense (
00324          const TRANS2D_MAPGEN& tmg
00325          );
00326          
00327       //! Translate the subregion using a coordinate operation (SPATREF::COORDOP) transformation
00328       ERRVALUE ConvertReverse (
00329          const SPATREF::COORDOP& Op
00330          );
00331    
00332       //! Translate the subregion using a coordinate operation (SPATREF::COORDOP) transformation with densification
00333       //! If the subregion is the extents only, this will convert it to a proper sub-region
00334       //! before doing the transformation
00335       ERRVALUE ConvertReverseDense (
00336          const SPATREF::COORDOP& Op,
00337          double tolerance
00338          );
00339    
00340       //! Convert subregion from double's to INT32's with rounding, removes duplicate points
00341       ERRVALUE ConvertToLongRound (
00342          SIMPLE_ARRAY<LPOLYGON>& PolygonArray,
00343          SIMPLE_ARRAY<LPOINT2D>& PointArray
00344          ) const;
00345    
00346       //! Convert subregion from double's to INT32's, truncating towards 0, removes duplicate points
00347       ERRVALUE ConvertToLongTruncate (
00348          SIMPLE_ARRAY<LPOLYGON>& PolygonArray,
00349          SIMPLE_ARRAY<LPOINT2D>& PointArray
00350          ) const;
00351    
00352       //! Get the end of the list of POLYLINE's
00353       //! @return End of POLYLINE list, see Begin() for details
00354       CONST_ITERATOR End (
00355          ) const { return (m_ItemList.End()); }
00356 
00357       //! Get sub-region extents
00358       //! @return Extents of the sub-region
00359       const DRECT3D& GetExtents (
00360          ) const { return (m_Extents); }
00361    
00362       //! Get sub-region extents
00363       //! @return Extents of the sub-region
00364       const DRECT2D& GetExtents2D (
00365          ) const { return (m_Extents); }
00366    
00367       //! Get number of islands in the sub-region
00368       //! @return Number of islands in the sub-region
00369       INT32 GetNumIslands (
00370          ) const { return (m_ItemList.GetNumItems()-1); }
00371    
00372       //! Intersect an specified rectangle area with the sub-region
00373       //! If the rectangle does not intersect with the sub-region area, 'this' will be set to empty
00374       ERRVALUE Intersect (
00375          const DRECT2D& Rect,
00376          MILIST<SUBREGION2D>& SubRegionList        //!< Filled in if operation creates more than one sub-region
00377          );
00378 
00379       //! Intersect an specified area against the sub-region
00380       //! If the polygon does not intersect the sub-region area, 'this' will be set to empty
00381       //! If the "PolyLine" passed in is invalid, this method will only use one of the 
00382       //! valid polygons it finds, otherwise the results will be in error.
00383       ERRVALUE Intersect (
00384          const POLYLINE& PolyLine,
00385          MILIST<SUBREGION2D>& SubRegionList        //!< Filled in if operation creates more than one sub-region
00386          );
00387 
00388       //! Intersect an specified area against the sub-region
00389       //! If the "SubRegion" does not intersect with the sub-region area, 'this' will be set to empty
00390       ERRVALUE Intersect (
00391          const SUBREGION2D& SubRegion,
00392          MILIST<SUBREGION2D>& SubRegionList        //!< Filled in if operation creates more than one sub-region
00393          );
00394 
00395       //! Intersect an specified area from the sub-region known to be valid
00396       //! A validated polygon is a polygon that does not intersect itself.
00397       //! If the polygon does not intersect the sub-region area, 'this' will be set to empty
00398       ERRVALUE IntersectValidated (
00399          const POLYLINE& PolyLine,
00400          MILIST<SUBREGION2D>& SubRegionList        //!< Filled in if operation creates more than one sub-region
00401          );
00402          
00403       //! Determine if the two subregions are equivalent 
00404       //! This method uses "Fuzzy" vertex comparisons and the direction and order of the elements are not relevant
00405       //! Specify a different threshold to allow greater distances
00406       //! @return 'True' if they are, 'False' if not
00407       bool IsEquivalentTo (
00408          const SUBREGION2D& rhs,
00409          double threshold = 0.0        //!< Default threshold is max absolute value of rectangle coordinate * 1.0E-13
00410          ) const;
00411    
00412       //! Determine if the point falls inside the sub-region
00413       //! @return 'True' if point is inside the sub-region, 'false' if not
00414       bool IsPointInside (
00415          const DPOINT2D& point
00416          ) const;
00417    
00418       //! Is the sub-region an empty sub-region
00419       bool IsEmpty (
00420          ) const { return (!m_Extents.IsValid()); }
00421 
00422       //! Is the sub-region a simple rectangle region?         
00423       bool IsRectangle (
00424          ) const { return (m_IsRectangle); }
00425 
00426       //! Reverse the orientation of the polygons and islands in the subregion
00427       void Reverse (
00428          );
00429 
00430       //! Set subregion orientation
00431       //! Outer shell polygon is set to the orientation specified in respect to itself. 
00432       //! Islands are set in the opposite orientation in respect to themselves
00433       void SetOrientation (
00434          ORIENTATION Orientation
00435          );
00436          
00437       //! Remove an specified area from the sub-region
00438       //! If the island removes the entire sub-region area, 'this' will be set to empty
00439       //! If the "Island" passed in is invalid, this method will only use one of the 
00440       //! valid polygons it finds, otherwise the results will be in error.
00441       ERRVALUE Subtract (
00442          const POLYLINE& Island,
00443          MILIST<SUBREGION2D>& SubRegionList        //!< Filled in if operation creates more than one sub-region
00444          );
00445 
00446       //! Remove an specified area from the sub-region
00447       //! If the "SubRegion" removes the entire sub-region area, 'this' will be set to empty
00448       ERRVALUE Subtract (
00449          const SUBREGION2D& SubRegion,
00450          MILIST<SUBREGION2D>& SubRegionList        //!< Filled in if operation creates more than one sub-region
00451          );
00452 
00453       //! Remove an specified rectangle area from the sub-region
00454       //! If the island removes the entire sub-region area, 'this' will be set to empty
00455       ERRVALUE Subtract (
00456          const DRECT2D& IslandRect,
00457          MILIST<SUBREGION2D>& SubRegionList        //!< Filled in if operation creates more than one sub-region
00458          );
00459 
00460       //! Remove an specified area from the sub-region known to be valid
00461       //! A validated polygon is a polygon that does not intersect itself.
00462       //! If the island removes the entire sub-region area, 'this' will be set to empty
00463       ERRVALUE SubtractValidated (
00464          const POLYLINE& Island,
00465          MILIST<SUBREGION2D>& SubRegionList        //!< Filled in if operation creates more than one sub-region
00466          );
00467          
00468       //! Test the line given the test criteria against the sub-region
00469       //! @return "True" if the line meets the criteria, "false" if not
00470       bool TestLine (
00471          const POLYLINE& PolyLine,
00472          TESTCRITERIA TestCriteria
00473          ) const;
00474 
00475       //! Test the line against the sub-region
00476       //! @return POLYLINE::COMPRESULT
00477       POLYLINE::COMPRESULT TestLine (
00478          const POLYLINE& PolyLine
00479          ) const;
00480 
00481       //! Test the point given the test criteria against the sub-region
00482       //! @return "True" if the point meets the criteria, "false" if not
00483       bool TestPoint (
00484          const DPOINT2D& Point,
00485          TESTCRITERIA TestCriteria
00486          ) const;
00487 
00488       //! Test the polygon given the test criteria against the sub-region
00489       //! @return "True" if the polygon meets the criteria, "false" if not
00490       bool TestPolygon (
00491          const POLYLINE& PolyLine,
00492          TESTCRITERIA TestCriteria
00493          ) const;
00494 
00495       //! Test the polygon against the sub-region
00496       //! @return POLYLINE::COMPRESULT
00497       POLYLINE::COMPRESULT TestPolygon (
00498          const POLYLINE& PolyLine
00499          ) const;
00500 
00501       //! Test the subregion given the test criteria against 'this'
00502       //! @return "True" if the subregion meets the criteria, "false" if not
00503       bool TestSubRegion (
00504          const SUBREGION2D& SubRegion,
00505          TESTCRITERIA TestCriteria
00506          ) const;
00507 
00508       //! Test the subregion against 'this'
00509       //! @return POLYLINE::COMPRESULT
00510       POLYLINE::COMPRESULT TestSubRegion (
00511          const SUBREGION2D& SubRegion
00512          ) const;
00513 
00514       //! Union (ADD) a rectangle to the sub-region
00515       ERRVALUE Union (
00516          const DRECT2D& Rect,
00517          MILIST<SUBREGION2D>& SubRegionList,       //!< Filled in if operation creates more than one sub-region
00518          POLYLINE::COMBINERESULT& CombineResult
00519          );
00520 
00521       //! Union (ADD) a Polygon to the sub-region
00522       ERRVALUE Union (
00523          const POLYLINE& PolyLine,
00524          MILIST<SUBREGION2D>& SubRegionList        //!< Filled in if operation creates more than one sub-region
00525          );
00526 
00527       //! Union (ADD) a sub-region to the sub-region
00528       ERRVALUE Union (
00529          const SUBREGION2D& SubRegion,
00530          MILIST<SUBREGION2D>& SubRegionList,       //!< Filled in if operation creates more than one sub-region
00531          POLYLINE::COMBINERESULT& CombineResult
00532          );
00533 
00534       //! Union (ADD) a polygon to the sub-region
00535       ERRVALUE UnionValidated (
00536          const POLYLINE& PolyLine,
00537          MILIST<SUBREGION2D>& SubRegionList,       //!< Filled in if operation creates more than one sub-region
00538          POLYLINE::COMBINERESULT& CombineResult
00539          );
00540          
00541    private:
00542       #ifndef GENERATING_DOXYGEN_OUTPUT
00543    
00544       POLYLINELIST m_ItemList;
00545       DRECT3D m_Extents;
00546       bool m_IsRectangle;
00547       
00548       void UpdateExtentsRect ();
00549       ERRVALUE UpdateFromShells (MILIST<POLYLINE>& PolyLineList, MILIST<SUBREGION2D>& SubRegionList);
00550    
00551       friend class RVC::VECTOR;        //!< For RVC::VECTOR::ReadSubRegion() and RVC::VECTOR::ReadRegion()
00552       friend class RVC::REGION;        //!< For RVC::REGION::GetRegion() and RVC::REGION::SetRegion()
00553       friend class REGION2D;           //!< For RVC::REGION::Assign()
00554       friend class RVC::REGIONHANDLE;
00555       friend class SERIALIZER;
00556       #endif // GENERATING_DOXYGEN_OUTPUT
00557    };
00558          
00559 
00560 //! REGION2D class - Definitions and methods to support a generic 2D region object in memory.  
00561 //! The region can be represented by either a single rectangle or as a list of sub-regions.
00562 class GEOMLIBCLASSEXPORT REGION2D {
00563    public:
00564 
00565       typedef MILIST<SUBREGION2D>::CONST_ITERATOR CONST_ITERATOR;
00566       
00567       //! Default constructor, initializes to an invalid region      
00568       REGION2D (
00569          );
00570    
00571       //! Copy constructor
00572       REGION2D (
00573          const REGION2D& rhs
00574          );
00575    
00576       //! Constructor from DRECT2D
00577       REGION2D (
00578          const DRECT2D& rhs
00579          );
00580 
00581       //! Constructor from SUBREGION2D.
00582       REGION2D (
00583          const SUBREGION2D& SubRegion
00584          );
00585    
00586       //! Constructor from a list of polylines
00587       REGION2D (
00588          const MILIST<POLYLINE>&
00589          );
00590    
00591       //! Destructor
00592       ~REGION2D (
00593          );
00594          
00595       //! Assignment
00596       REGION2D& operator= (
00597          const REGION2D& rhs
00598          );
00599          
00600       //! Assignment from DRECT2D.
00601       REGION2D& operator= (
00602          const DRECT2D& rhs
00603          );
00604 
00605       //! Assignment from SUBREGION2D.
00606       REGION2D& operator= (
00607          const SUBREGION2D& SubRegion
00608          );
00609    
00610       //! Assign from a POLYLINE and an index array defining how the polyline is formatted
00611       ERRVALUE Assign (
00612          const POLYLINE& PolyLine,
00613          const SIMPLE_ARRAY<INT32>& Index       //!< Each entry is the number of points >0 is shell <0 is island
00614          );
00615          
00616       //! Get the beginning of the list of SUBREGION's.
00617       //! @return Iterator to the beginning of the subregion list
00618       CONST_ITERATOR Begin (
00619          ) const { return (m_SubList.Begin()); }
00620 
00621       //! Clear the region
00622       void Clear (
00623          );
00624          
00625       //! Clear coordinate reference system.
00626       void ClearCoordRefSys (
00627          );
00628          
00629       //! Clip a polyline to a region, call the ClipTarget for each segment
00630       //! @return TRUE if part of the line is clipped, FALSE if not, < 0 error
00631       int ClipLine (
00632          POLYLINE& PolyLine,
00633          POLYLINE::CLIP& ClipTarget,
00634          CLIPMODE ClipMode = CLIPMODE_Inside
00635          ) const;
00636          
00637       //! Compute the region area in region units
00638       double ComputeArea (
00639          ) const;
00640    
00641       //! Compute the region area in region units but do not exclude islands in the calculation
00642       double ComputeAreaNoIslands (
00643          ) const;
00644    
00645       //! Compute the region perimeter in region units
00646       double ComputePerimeter (
00647          ) const;
00648    
00649       //! Compute the region perimeter in region units but do not include sub-region islands in the calculation
00650       double ComputePerimeterNoIslands (
00651          ) const;
00652    
00653       //! Translate the region using an affine transformation
00654       //! If the COORDREFSYS of 'this' is set, it will be changed to "Undefined"
00655       void ConvertForward (
00656          const TRANS2D_AFFINE& taf
00657          );
00658    
00659       //! Translate the region using a mapgen transformation
00660       //! An error will occur if the COORDREFSYS of 'this' is not local and the TRANS2D_MAPGEN's input transformation is not identity or
00661       //! the COORDREFSYS of 'this' does not match the TRANS2D_MAPGEN's input COORDREFSYS.
00662       //! If the TRANS2D_MAPGEN's output transformation is identity, 'this' COORDREFSYS will be set to the TRANS2D_MAPGEN's output COORDREFSYS.
00663       //! otherwise it will be set to "Undefined".
00664       ERRVALUE ConvertForward (
00665          const TRANS2D_MAPGEN& tmg
00666          );
00667    
00668       //! Translate the region using a coordinate operation (SPATREF::COORDOP) transformation
00669       //! Region coordinate reference system "GetCoordRefSys()' must equate to the Op.GetSourceCRS().
00670       //! The Op.GetTargetCRS() is assigned as the region's COORDREFSYS after the transformation.
00671       ERRVALUE ConvertForward (
00672          const SPATREF::COORDOP& Op
00673          );
00674    
00675       //! Translate the region using a mapgen transformation with densification
00676       //! An error will occur if the COORDREFSYS of 'this' is not local and the TRANS2D_MAPGEN's input transformation is not identity or
00677       //! the COORDREFSYS of 'this' does not match the TRANS2D_MAPGEN's input COORDREFSYS.
00678       //! If the TRANS2D_MAPGEN's output transformation is identity, 'this' COORDREFSYS will be set to the TRANS2D_MAPGEN's output COORDREFSYS.
00679       //! otherwise it will be set to "Undefined".
00680       ERRVALUE ConvertForwardDense (
00681          const TRANS2D_MAPGEN& tmg
00682          );
00683    
00684       //! Translate the region using a coordinate operation (SPATREF::COORDOP) transformation with densification
00685       //! Region coordinate reference system "GetCoordRefSys()' must equate to the Op.GetSourceCRS().
00686       //! The Op.GetTargetCRS() is assigned as the region's COORDREFSYS after the transformation.
00687       ERRVALUE ConvertForwardDense (
00688          const SPATREF::COORDOP& Op,
00689          double tolerance
00690          );
00691    
00692       //! Translate the region using an affine transformation
00693       //! If the COORDREFSYS of 'this' is set, it will be changed to "Undefined"
00694       void ConvertInverse (
00695          const TRANS2D_AFFINE& taf
00696          );
00697    
00698       //! Translate the region using a mapgen transformation
00699       //! An error will occur if the COORDREFSYS of 'this' is not local and the TRANS2D_MAPGEN's output transformation is not identity or
00700       //! the COORDREFSYS of 'this' does not match the TRANS2D_MAPGEN's output COORDREFSYS.
00701       //! If the TRANS2D_MAPGEN's input transformation is identity, 'this' COORDREFSYS will be set to the TRANS2D_MAPGEN's input COORDREFSYS
00702       //! otherwise it will be set to "Undefined".
00703       ERRVALUE ConvertInverse (
00704          const TRANS2D_MAPGEN& tmg
00705          );
00706    
00707       //! Translate the region using a mapgen transformation with densification
00708       //! An error will occur if the COORDREFSYS of 'this' is not local and the TRANS2D_MAPGEN's output transformation is not identity or
00709       //! the COORDREFSYS of 'this' does not match the TRANS2D_MAPGEN's output COORDREFSYS.
00710       //! If the TRANS2D_MAPGEN's input transformation is identity, 'this' COORDREFSYS will be set to the TRANS2D_MAPGEN's input COORDREFSYS.
00711       //! otherwise it will be set to "Undefined".
00712       ERRVALUE ConvertInverseDense (
00713          const TRANS2D_MAPGEN& tmg
00714          );
00715          
00716       //! Translate the region using a coordinate operation (SPATREF::COORDOP) transformation
00717       //! Region coordinate reference system "GetCoordRefSys()' must equate to the Op.GetTargetCRS().
00718       //! The Op.GetSourceCRS() is assigned as the region's COORDREFSYS after the transformation.
00719       ERRVALUE ConvertReverse (
00720          const SPATREF::COORDOP& Op
00721          );
00722    
00723       //! Translate the region using a coordinate operation (SPATREF::COORDOP) transformation with densification
00724       //! Region coordinate reference system "GetCoordRefSys()' must equate to the Op.GetTargetCRS().
00725       //! The Op.GetSourceCRS() is assigned as the region's COORDREFSYS after the transformation.
00726       ERRVALUE ConvertReverseDense (
00727          const SPATREF::COORDOP& Op,
00728          double tolerance
00729          );
00730 
00731       //! Convert 'this' to a different COORDREFSYS.
00732       ERRVALUE ConvertTo (
00733          const SPATREF::COORDREFSYS& DestCoordRefSys,
00734          double tolerance = 0.0
00735          );
00736    
00737       //! Get the end of the list of SUBREGION's
00738       //! @return End of SUBREGION list, see Begin() for details
00739       CONST_ITERATOR End (
00740          ) const { return (m_SubList.End()); }
00741 
00742       //! Exclusive Union (XOR) RegionB with 'this'
00743       ERRVALUE ExclusiveUnion (
00744          const REGION2D& RegionB
00745          );
00746          
00747       //! Exclusive Union (XOR) RegionB with RegionA and place in 'this'
00748       //! Will convert 'this' to RegionA's SPATREF::COORDREFSYS
00749       ERRVALUE ExclusiveUnion (
00750          const REGION2D& RegionA,
00751          const REGION2D& RegionB
00752          );
00753          
00754       //! Get the region's coordinate reference system
00755       //! @return SPATREF::COORDREFSYS of the region
00756       const SPATREF::COORDREFSYS& GetCoordRefSys (
00757          ) const { return (m_CoordRefSys); }
00758          
00759       //! Get region extents
00760       //! @return Extents of the entire region
00761       const DRECT3D& GetExtents (
00762          ) const { return (m_Extents); }
00763    
00764       //! Get region extents
00765       //! @return Extents of the entire region
00766       const DRECT2D& GetExtents2D (
00767          ) const { return (m_Extents); }
00768    
00769       //! Get number of sub-regions
00770       //! @return Number of sub-regions
00771       INT32 GetNumSubRegions (
00772          ) const;
00773          
00774       //! Intersect rectangle with 'this'
00775       ERRVALUE Intersect (
00776          const DRECT2D& Rect
00777          );
00778          
00779       //! Intersect a polygon with 'this'
00780       ERRVALUE Intersect (
00781          const POLYLINE& PolyLine
00782          );
00783          
00784       //! Intersect a sub-region with 'this'
00785       ERRVALUE Intersect (
00786          const SUBREGION2D& SubRegion
00787          );
00788          
00789       //! Intersect RegionB with 'this'
00790       ERRVALUE Intersect (
00791          const REGION2D& RegionB
00792          );
00793          
00794       //! Intersect RegionB with RegionA and place in 'this'
00795       //! Will convert 'this' to RegionA's SPATREF::COORDREFSYS
00796       ERRVALUE Intersect (
00797          const REGION2D& RegionA,
00798          const REGION2D& RegionB
00799          );
00800          
00801       //! Intersect a validated polygon with 'this'
00802       ERRVALUE IntersectValidated (
00803          const POLYLINE& PolyLine
00804          );
00805          
00806       //! Is the region an empty region
00807       bool IsEmpty (
00808          ) const { return (!m_Extents.IsValid()); }
00809 
00810       //! Determine if the two regions are equivalent 
00811       //! This method uses "Fuzzy" vertex comparisons and the direction and order of the elements are not relevant
00812       //! Specify a different threshold to allow greater distances
00813       //! @return 'True' if they are, 'False' if not
00814       bool IsEquivalentTo (
00815          const REGION2D& rhs,
00816          double threshold = 0.0        //!< Default threshold is max absolute value of rectangle coordinate * 1.0E-13
00817          ) const;
00818    
00819       //! Determine if the point falls inside the region
00820       //! @return 'True' if point is inside region, 'false' if not
00821       bool IsPointInside (
00822          const DPOINT2D& point
00823          ) const;
00824          
00825       //! Is the region a simple rectangle region?
00826       bool IsRectangle (
00827          ) const { return (m_IsRectangle); }
00828          
00829       //! Reverse the orientation of the subregions in the region
00830       void Reverse (
00831          );
00832 
00833       //! Set the region's coordinate reference system
00834       //! Does not do any transformations of the region, 
00835       //! assumes that the region is in the system specified
00836       void SetCoordRefSys (
00837          const SPATREF::COORDREFSYS& CoordSysRef
00838          ) { m_CoordRefSys = CoordSysRef; }
00839 
00840       //! Set region orientation
00841       //! Each subregion is set using SUBREGION2D::SetOrientation()
00842       void SetOrientation (
00843          ORIENTATION Orientation
00844          );
00845          
00846       //! Set the Z init and Z last fields of the extents box        
00847       void SetZRange (
00848          const DOUBLE_RANGE& range
00849          );
00850          
00851       //! Subtract rectangle from 'this'
00852       ERRVALUE Subtract (
00853          const DRECT2D& Rect
00854          );
00855          
00856       //! Subtract a polygon from 'this'
00857       ERRVALUE Subtract (
00858          const POLYLINE& PolyLine
00859          );
00860          
00861       //! Subtract a sub-region from 'this'
00862       ERRVALUE Subtract (
00863          const SUBREGION2D& SubRegion
00864          );
00865          
00866       //! Subtract RegionB from 'this'
00867       ERRVALUE Subtract (
00868          const REGION2D& RegionB
00869          );
00870          
00871       //! Subtract RegionB from RegionA and place in 'this'
00872       //! Will convert 'this' to RegionA's SPATREF::COORDREFSYS
00873       ERRVALUE Subtract (
00874          const REGION2D& RegionA,
00875          const REGION2D& RegionB
00876          );
00877          
00878       //! Subtract a validated polygon from 'this'
00879       ERRVALUE SubtractValidated (
00880          const POLYLINE& PolyLine
00881          );
00882          
00883       //! Test the line given the test criteria against the region
00884       //! @return "True" if the line meets the criteria, "false" if not
00885       bool TestLine (
00886          const POLYLINE& PolyLine,
00887          TESTCRITERIA TestCriteria
00888          ) const;
00889 
00890       //! Test the point given the test criteria against the sub-region
00891       //! @return "True" if the point meets the criteria, "false" if not
00892       bool TestPoint (
00893          const DPOINT2D& Point,
00894          TESTCRITERIA TestCriteria
00895          ) const;
00896 
00897       //! Test the polygon given the test criteria against the region
00898       //! @return "True" if the polygon meets the criteria, "false" if not
00899       bool TestPolygon (
00900          const POLYLINE& PolyLine,
00901          TESTCRITERIA TestCriteria
00902          ) const;
00903 
00904       //! Test the sub-region given the test criteria against the region
00905       //! @return "True" if the sub-region meets the criteria, "false" if not
00906       bool TestSubRegion (
00907          const SUBREGION2D& SubRegion,
00908          TESTCRITERIA TestCriteria
00909          ) const;
00910 
00911       //! Union (ADD) rectangle to 'this'
00912       ERRVALUE Union (
00913          const DRECT2D& Rect
00914          );
00915          
00916       //! Union (ADD) a polygon to 'this'
00917       ERRVALUE Union (
00918          const POLYLINE& PolyLine
00919          );
00920          
00921       //! Union (ADD) a sub-region to the region
00922       ERRVALUE Union (
00923          const SUBREGION2D& SubRegion
00924          );
00925          
00926       //! Union (ADD) RegionB to RegionA and place in 'this'
00927       //! Will convert 'this' to RegionA's SPATREF::COORDREFSYS
00928       ERRVALUE Union (
00929          const REGION2D& RegionA,
00930          const REGION2D& RegionB
00931          );
00932          
00933       //! Union (ADD) RegionB to 'this'
00934       ERRVALUE Union (
00935          const REGION2D& RegionB
00936          );
00937          
00938       //! Union (ADD) a validated polygon to 'this'
00939       ERRVALUE UnionValidated (
00940          const POLYLINE& PolyLine
00941          );
00942          
00943    private:
00944       #ifndef GENERATING_DOXYGEN_OUTPUT
00945    
00946       MILIST<SUBREGION2D> m_SubList;
00947       DRECT3D m_Extents;
00948       SPATREF::COORDREFSYS m_CoordRefSys;
00949       bool m_IsRectangle;
00950       
00951       void AppendDisjointRegion (const REGION2D& rhs);
00952       void AppendDisjointSubRegion (const SUBREGION2D& rhs);
00953       bool UnionRectangle (const DRECT2D& Rect);
00954       void UpdateExtentsRect ();
00955    
00956       class INTERSECTREGION;
00957       friend class INTERSECTREGION;
00958       friend class RVC::VECTOR;           //!< For RVC::VECTOR::ReadRegion()
00959       friend class RVC::REGION;           //!< For RVC::REGION::GetRegion() and RVC::REGION::SetRegion()
00960       friend class RVC::REGIONHANDLE;
00961       friend class SERIALIZER;
00962       #endif // GENERATING_DOXYGEN_OUTPUT
00963    };
00964 
00965 PREVENT_MEMFUNC(SUBREGION2D);
00966 PREVENT_MEMFUNC(REGION2D);
00967    
00968 #pragma warning(default:4251) // Start complaining about the need to have a dll interface
00969 #undef GEOMLIBEXPORT
00970 #undef GEOMLIBCLASSEXPORT
00971 
00972 #endif      //!< INC_MI32_REGION2D_H

Generated on Tue Dec 14 13:18:32 2004 for TNTsdk by  doxygen 1.3.8-20040913