cad.h

Go to the documentation of this file.
00001 /**
00002  * \file rvc/cad.h
00003  * \brief interface for the RVCCAD class.
00004  *
00005  * \if NODOC
00006  * $Id: cad.h_v 1.65 2005/11/23 23:27:00 scowan Exp $
00007  *
00008  * $Log: cad.h_v $
00009  * Revision 1.65  2005/11/23 23:27:00  scowan
00010  * Updated from 7.0.
00011  *
00012  * Revision 1.64  2005/06/27 17:01:54  scowan
00013  * Added dimension parm to draw methods.
00014  *
00015  * Revision 1.63  2005/06/02 21:11:11  scowan
00016  * Added methods to parse GML element to CAD element.
00017  *
00018  * Revision 1.62  2005/06/01 23:02:41  scowan
00019  * Added get gml element method.
00020  *
00021  * Revision 1.61  2005/04/11 17:05:06  dfriberg
00022  * Added LINKTYPE_DWG
00023  *
00024  * Revision 1.60  2005/01/19 21:12:17  scowan
00025  * Added support for descriptor.
00026  *
00027  * Revision 1.59  2004/12/18 00:07:58  scowan
00028  *  Added component field to findClosestElements.
00029  *
00030  * Revision 1.58  2004/12/01 18:39:31  dfriberg
00031  * LINKTYPE_DGN = 5 (as defined in RVC::CADHANDLE::LINKTYPE)
00032  *
00033  * Revision 1.57  2004/11/30 16:18:22  ldyas
00034  * restore default.
00035  *
00036  * Revision 1.56  2004/11/24 23:17:42  ldyas
00037  * changed default validate in getregion.
00038  *
00039  * Revision 1.55  2004/11/09 00:14:32  dfriberg
00040  * Add DGN to LINKTYPE.
00041  *
00042  * Revision 1.54  2004/09/02 14:13:52  scowan
00043  * Fixed prototype for add element.
00044  *
00045  * Revision 1.53  2004/09/01 22:53:39  scowan
00046  * Changed to use cad handle paradigm.
00047  *
00048  * Revision 1.51  2004/07/28 16:12:41  scowan
00049  * Moved polyline generation from a box to the box class.
00050  *
00051  * Revision 1.50  2004/07/15 17:00:09  scowan
00052  * Added new private element method.
00053  *
00054  * Revision 1.49  2004/07/15 15:47:05  scowan
00055  * Fixed memory leak.
00056  *
00057  * Revision 1.48  2004/07/12 23:21:20  scowan
00058  * Removed use of geo region.
00059  *
00060  * Revision 1.47  2004/06/14 20:09:40  scowan
00061  * Added method to get the text frame parms.
00062  *
00063  * Revision 1.46  2004/06/14 16:20:55  scowan
00064  * Added methods to set and get baseline flags.
00065  *
00066  * Revision 1.45  2004/06/11 16:17:32  scowan
00067  * Addow increment of cad element type enums.
00068  *
00069  * Revision 1.44  2004/06/10 16:53:54  scowan
00070  * Added delete last element method.
00071  *
00072  * Revision 1.43  2004/06/07 15:32:06  scowan
00073  * Added method to update element.
00074  *
00075  * Revision 1.42  2004/06/04 19:25:27  scowan
00076  * Added methods to help in cad merge.
00077  *
00078  * Revision 1.41  2004/05/28 20:35:28  scowan
00079  * Added new mehtods and virtual method overrides.
00080  *
00081  * Revision 1.40  2004/05/28 15:56:57  scowan
00082  * Changed to have element iterator use new element class.
00083  *
00084  * Revision 1.39  2004/05/27 19:59:00  scowan
00085  * Added make parm ctor.
00086  *
00087  * Revision 1.38  2004/05/27 16:11:39  scowan
00088  * Added methods to access certain fields in cad element.
00089  *
00090  * Revision 1.37  2004/05/20 22:05:30  scowan
00091  * Added database index methods.
00092  *
00093  * Revision 1.36  2004/05/20 19:40:03  scowan
00094  * Added cad element class and other sub-classes.
00095  *
00096  * Revision 1.35  2003/11/21 22:17:02  scowan
00097  * Support new Capabilities system.
00098  *
00099  * Revision 1.34  2003/10/13 16:46:37  scowan
00100  * Added cad type to text id method.
00101  *
00102  * Revision 1.33  2003/10/07 17:35:45  scowan
00103  * Object virtual method changes.
00104  *
00105  * Revision 1.32  2003/09/30 16:52:06  dwilliss
00106  * Doxygen
00107  *
00108  * Revision 1.31  2003/09/25 21:20:04  dwilliss
00109  * Fixed doxygen comment
00110  *
00111  * Revision 1.30  2003/09/15 13:49:45  fileserver!dwilliss
00112  * Doxygen
00113  *
00114  * Revision 1.29  2003/08/27 21:28:13  scowan
00115  * Removed unused linkked file virtual methods.
00116  *
00117  * Revision 1.28  2003/06/19 17:46:34  scowan
00118  * Added virtual method.
00119  *
00120  * Revision 1.27  2003/06/04 23:35:06  scowan
00121  * Added find element draw set.
00122  *
00123  * Revision 1.26  2003/05/12 23:33:11  scowan
00124  * Changes to virtual methods.
00125  *
00126  * Revision 1.25  2003/05/07 22:20:36  scowan
00127  * Changed virtual method format.
00128  *
00129  * Revision 1.24  2002/09/30 23:22:18  scowan
00130  * Made element search code const.
00131  *
00132  * Revision 1.23  2002/09/17 22:49:14  scowan
00133  * More virtual method adjustment.
00134  *
00135  * Revision 1.22  2002/09/03 22:18:32  scowan
00136  * More virtual method moves.
00137  *
00138  * Revision 1.21  2002/08/29 22:13:22  scowan
00139  * Virtual method adjustment.
00140  *
00141  * Revision 1.20  2002/06/27 17:57:14  scowan
00142  * nc.
00143  *
00144  * Revision 1.19  2002/06/19 22:24:10  scowan
00145  * More method changes.
00146  *
00147  * Revision 1.18  2002/06/18 22:15:22  scowan
00148  * Added extract interface.
00149  *
00150  * Revision 1.17  2002/04/30 17:33:50  scowan
00151  * Change base make parm class name.
00152  *
00153  * Revision 1.16  2002/04/30 14:40:24  scowan
00154  * Removed namespace from inheritance.
00155  *
00156  * Revision 1.15  2002/04/30 14:03:13  scowan
00157  * More const.
00158  *
00159  * Revision 1.14  2002/04/26 22:44:13  scowan
00160  * Added more virtual methods.
00161  *
00162  * Revision 1.13  2002/03/01 16:19:28  scowan
00163  * Added virtual methods.
00164  *
00165  * Revision 1.12  2002/03/01 15:34:35  scowan
00166  * Added set element ID method.
00167  *
00168  * Revision 1.11  2002/02/27 23:24:46  scowan
00169  * Added get element extents methods.
00170  *
00171  * Revision 1.10  2001/10/18 15:29:32  scowan
00172  * Added update method.
00173  *
00174  * Revision 1.9  2001/10/17 22:49:39  scowan
00175  * Added multiple stuff.
00176  *
00177  * Revision 1.8  2001/10/08 20:50:00  scowan
00178  * Added element region method.
00179  *
00180  * Revision 1.7  2001/09/28 15:29:11  scowan
00181  * Added extents to the make parms.
00182  *
00183  * Revision 1.6  2001/07/31 16:40:38  scowan
00184  * Added new interface methods.
00185  *
00186  * Revision 1.5  2001/07/12 20:14:55  scowan
00187  * Added encoding for linked objects.
00188  *
00189  * Revision 1.4  2001/06/14 16:06:14  scowan
00190  * Changed source type.
00191  *
00192  * Revision 1.3  2001/06/14 15:12:40  scowan
00193  * Added to RVC namespace.
00194  *
00195  * Revision 1.2  2001/06/13 15:51:16  scowan
00196  * Changed objtype enum.
00197  * Added make mehtod.
00198  *
00199  * Revision 1.1  2001/05/29 21:12:27  scowan
00200  * Initial revision
00201  *
00202  * \endif
00203 **/
00204 
00205 //!   \class RVC::CAD rvc/cad.h
00206 //!   \brief Manages RVC::OBJTYPE_CAD RVC objects.  
00207 //!
00208 //!   The interface currently wraps the MfCAD functions.
00209 //!   
00210 //!   RVC Object Types that this class supports: RVC::OBJTYPE_CAD.
00211 //!
00212 //!   Default RVC Object Type for this class: RVC::OBJTYPE_CAD.
00213 //!
00214 //!   Valid parents for this class:
00215 //!      - RVC::OBJTYPE_File
00216 //!      - RVC::OBJTYPE_Folder
00217 
00218 #ifndef INC_RVC_CAD_H
00219 #define INC_RVC_CAD_H
00220 
00221 #ifndef INC_RVC_GEOMETRC_H
00222    #include <rvc/geometrc.h>
00223 #endif
00224 
00225 #ifndef INC_MI32_RVCCAD_H
00226    #include <mi32/rvccad.h>
00227 #endif
00228 
00229 #ifndef INC_MI32_POLYLINE_H
00230    #include <mi32/polyline.h>
00231 #endif
00232 
00233 #ifndef INC_MI32_SCRNUNIT_H
00234    #include <mi32/scrnunit.h>
00235 #endif
00236 
00237 #ifndef INC_RVC_STYLE_H
00238    #include <rvc/style.h>
00239 #endif
00240 #include <utility>
00241 
00242 #ifndef GENERATING_DOXYGEN_OUTPUT   
00243 // Forward Declarations
00244 class BITSET_UNOWNED;
00245 struct CADBLOCK;
00246 class LABELFRAMEPARMS;
00247 struct LINESTYLE;
00248 class PLANECONIC;
00249 struct POINTSTYLE;
00250 struct POLYSTYLE;
00251 class SUBREGION2D;
00252 struct TEXTSTYLE;
00253 class TRANS2D_AFFINE;
00254 #endif // GENERATING_DOXYGEN_OUTPUT
00255 
00256 namespace RVC {
00257 
00258 #ifndef GENERATING_DOXYGEN_OUTPUT   
00259 // Forward Declarations
00260 class CADHANDLE;
00261 class QSEARCHTREE;
00262 #endif // GENERATING_DOXYGEN_OUTPUT
00263 
00264 class CAD : public GEOMETRIC {
00265    public:
00266 
00267       typedef INT32 CADBLOCKNUM;    //!< Typedef for CAD block number type
00268 
00269       enum LINKTYPE {
00270          LINKTYPE_Internal = 0,
00271          LINKTYPE_MapInfo = 1,      //!<  Mapinfo .MIF format 
00272          LINKTYPE_AtlasGIS = 2,     //!<  Atlas GIS 3.0 internal format 
00273          LINKTYPE_Shapefile = 3,    //!<  Arc/Info Shapefile format 
00274          LINKTYPE_DGN = 5,          //!<  MicroStation DGN format
00275          LINKTYPE_DWG = 6,          //!<  AutoCAD DWG format
00276          LINKTYPE_Edit = 1000
00277          };
00278 
00279       #ifndef GENERATING_DOXYGEN_OUTPUT   
00280       class CONST_ELEMITERATOR;
00281       friend class CONST_ELEMITERATOR;
00282       class DRAW;
00283       class ELEMENT;
00284       class LINKPARMS;
00285       class MAKEPARMS;
00286       #endif // GENERATING_DOXYGEN_OUTPUT
00287 
00288       //! Default constructor
00289       CAD (
00290          );
00291 
00292       //! Copy constructor
00293       CAD (
00294          const RVC::CAD& obj
00295          );
00296 
00297       //! Destructor
00298       virtual ~CAD (
00299          );
00300 
00301       //! Assignment, will close and re-open object if possible
00302       RVC::CAD& operator= (
00303          const RVC::CAD& rhs
00304          );
00305 
00306       //! Add an element to the CAD object   
00307       INT32 AddElement (
00308          const ELEMENT& Element
00309          );
00310 
00311       //! Copy a block inside a CAD object
00312       ERRVALUE CopyBlock (
00313          CADBLOCKNUM DestBlockNum,
00314          CADBLOCKNUM SrcBlockNum
00315          );
00316 
00317       //! Delete the element specified.  Only works if the GEOMETRIC::CAPABILITY_CanDeleteAnyElement is available
00318       ERRVALUE DeleteElement (
00319          INT32 ElemNum
00320          );
00321          
00322       ERRVALUE DeleteLastElement (
00323          );
00324          
00325       //! Draws the block by calling the virtual draw routines.
00326       //! @return The number of elements drawn. 
00327       INT32 DrawBlock (
00328          DRAW& Draw,
00329          INT32 BlockNum = 0,
00330          double MinChordDist = 0.0,             //!< Default is to use %5 of the Radius length
00331          DIMENSION dim = DIMENSION_2D
00332          ) const;
00333 
00334       //! Draws an element.
00335       //! Returns > 0 if drawn, 0 if not, > 0 error. 
00336       int DrawElement (                   
00337          DRAW& Draw,
00338          INT32 BlockNum,
00339          INT32 ElemNum,                         //!< Element to draw
00340          double MinChordDist = 0.0,             //!< Default is to use %5 of the Radius length
00341          DIMENSION dim = DIMENSION_2D
00342          ) const;
00343 
00344       //! Obtain a constant iterator to the first CAD element in the current block
00345       //! @return Constant iterator to first CAD element in the current block
00346       CONST_ELEMITERATOR ElementBegin (
00347          ) const;
00348 
00349       //! Obtain an iterator to the last+1 CAD element in the current block
00350       //! @return Constant iterator to last+1 CAD element in the current block
00351       CONST_ELEMITERATOR ElementEnd (
00352          ) const;
00353 
00354       //! Erase all elements from a block
00355       ERRVALUE EraseBlock (
00356          CADBLOCKNUM BlockNum
00357          );
00358 
00359       //! Get the current block number
00360       //! @return Current block number
00361       CADBLOCKNUM GetCurrentBlock (
00362          ) const;
00363 
00364       //! Obtain the link type
00365       //! @return RVCCAD::LINKTYPE
00366       LINKTYPE GetLinkType (
00367          ) const;
00368 
00369       //! Get MAKEPARM values from current CAD object instance       
00370       ERRVALUE GetMakeParms (
00371          RVC::CAD::MAKEPARMS& MakeParms
00372          ) const;
00373          
00374       //! Obtain next available element ID for element ID table
00375       //! @return Next available Element ID
00376       INT32 GetNextElemID (
00377          ) const;
00378 
00379       //! Obtain the number of blocks in this CAD object
00380       //! @return Number of blocks
00381       INT32 GetNumBlocks (
00382          ) const;
00383 
00384       //! Link CAD object to external file
00385       ERRVALUE Link (                        //! Create a raster object
00386          const RVC::OBJECT& parent,
00387          const RVC::DESCRIPTOR& Descriptor,
00388          const LINKPARMS& LinkParms
00389          );
00390 
00391       //! Link CAD object to external file
00392       //! @deprecated Use the Link() method that takes a DESCRIPTOR
00393       DEPRECATED ERRVALUE Link (                      //! Create a raster object
00394          const RVC::OBJECT& parent,
00395          const RVC::OBJECTNAME& name,
00396          const RVC::OBJECTDESC& desc,
00397          const LINKPARMS& LinkParms,
00398          const char* Source = 0
00399          );
00400 
00401       //! Create a new CAD object
00402       ERRVALUE Make (                        //! Create a raster object
00403          const RVC::OBJECT& parent,
00404          const RVC::DESCRIPTOR& Descriptor,
00405          const MAKEPARMS& MakeParms
00406          );
00407 
00408       //! Create a new CAD object
00409       //! @deprecated Use the Make() method that takes a DESCRIPTOR
00410       DEPRECATED ERRVALUE Make (                      //! Create a raster object
00411          const RVC::OBJECT& parent,
00412          const RVC::OBJECTNAME& name,
00413          const RVC::OBJECTDESC& desc,
00414          const MAKEPARMS& MakeParms,
00415          const char* Source = 0
00416          );
00417 
00418       //! Create a new CAD object
00419       ERRVALUE Make (                        //! Create a raster object
00420          const RVC::OBJITEM& ObjItem,
00421          const MAKEPARMS& MakeParms,
00422          const char* Source = 0
00423          );
00424 
00425       //! Read the block information
00426       ERRVALUE ReadBlock (
00427          CADBLOCKNUM BlockNum,
00428          CADBLOCK& block,
00429          bool MakeCurrent = true             //!< Make current block
00430          ) const;
00431 
00432       //! Read next CAD element in the sequence in the current block
00433       ERRVALUE ReadElement (
00434          ELEMENT& Element,
00435          DIMENSION dim = DIMENSION_2D
00436          ) const;
00437 
00438       //! Read specific CAD element in the current block
00439       ERRVALUE ReadElement (
00440          INT32 ElemNum,
00441          ELEMENT& Element,
00442          DIMENSION dim = DIMENSION_2D
00443          ) const;
00444 
00445       //! Rewind CAD object block reading to the begining
00446       ERRVALUE Rewind (
00447          );
00448          
00449       ERRVALUE SetEditBlock (
00450          INT32 BlockNum
00451          );
00452 
00453       //! Set next available element ID for element ID table
00454       ERRVALUE SetNextElemID (
00455          INT32 NextElemID
00456          );
00457 
00458       //! Set CAD object point coordinate type
00459       ERRVALUE SetPointType (
00460          POINTTYPE PointType
00461          );
00462 
00463       //! Change the drawing order of an element in the CAD object         
00464       ERRVALUE SortElement (
00465          INT32 ElemNum,
00466          bool SortToFront
00467          );
00468          
00469       //! Change the drawing order of the set of elements in the CAD object         
00470       ERRVALUE SortElements (
00471          const BITSET_UNOWNED& SortSet,
00472          bool SortToFront
00473          );
00474          
00475       //! Write the block information
00476       ERRVALUE WriteBlock (
00477          CADBLOCKNUM BlockNum,
00478          CADBLOCK& block,
00479          bool MakeCurrent = true             //!< Make current block
00480          );
00481 
00482       //! Write element information, only valid if linktype == LINKTYPE_Edit
00483       ERRVALUE WriteElement (
00484          INT32 ElemNum,
00485          const ELEMENT& Element
00486          );
00487          
00488       //! Update element information (in CADELEMOPT section)
00489       ERRVALUE UpdateElement (
00490          INT32 ElemNum,
00491          const ELEMENT& Element
00492          );
00493          
00494       ERRVALUE UpdateExtentsFromInsertElements (
00495          );
00496 
00497    private:
00498       #ifndef GENERATING_DOXYGEN_OUTPUT
00499 
00500       ERRVALUE CreateAndPopulateSearchTree (INT32 InitialNumElements, const DRECT2D& InitialExtents, QSEARCHTREE& SearchTree) const;
00501       INT32 DrawBlock (DRAW& Draw, INT32 BlockNum, const TRANS2D_AFFINE& BlockToCAD, INT32 InsertLevel, double MinChordDist, DIMENSION dim) const;
00502       int DrawElement (DRAW& Draw, INT32 BlockNum, INT32 ElemNum, const TRANS2D_AFFINE& BlockToCAD, INT32 InsertLevel, double MinChordDist, DIMENSION dim) const;
00503       ERRVALUE DrawInsert (DRAW& Draw, INT32 BlockNum, const ELEMENT& Element, const TRANS2D_AFFINE& BlockToCAD, INT32 InsertLevel, double MinChordDist, DIMENSION dim) const;
00504       
00505       ERRVALUE ExtractToCAD (RVC::GEOMETRIC& DestObj, RVC::GEOMETRIC::ELEMTRANSLIST& TransList, const TRANS2D_MAPGEN& tmg, RVC::GEOMETRIC::EXTRACTFLAGS ExtractFlags, const SIMPLE_ARRAY<INT32>& FontTrans, const SIMPLE_ARRAY<INT32> PattTrans[RVC::STYLE::PATTERN_NumTypes]) const;
00506       ERRVALUE ExtractToRegion (RVC::GEOMETRIC& DestObj, RVC::GEOMETRIC::ELEMTRANSLIST& TransList, const TRANS2D_MAPGEN& tmg, RVC::GEOMETRIC::EXTRACTFLAGS ExtractFlags) const;
00507       ERRVALUE ExtractToVector (RVC::GEOMETRIC& DestObj, RVC::GEOMETRIC::ELEMTRANSLIST& TransList, const TRANS2D_MAPGEN& tmg, RVC::GEOMETRIC::EXTRACTFLAGS ExtractFlags) const;
00508       
00509       INT64 GetCurrentPosition () const;
00510       void SetCurrentPosition (INT64 Position) const;
00511       
00512       int SetupBlockTransList(ELEMTRANSLIST& TransList) const;
00513       int SetupDBRecordTransList(ELEMTRANSLIST& TransList) const;
00514       int SetupElementTransList(const ELEMSELECTPARMS& SelectParms, ELEMTRANSLIST& TransList, RVC::GEOMETRIC::ELEMSELECTFILTER* SelectFilter) const;
00515 
00516       //! Implementation of RVC::OBJECT virtual methods
00517       virtual ERRVALUE v_CloseObject ();              //! Close the open object
00518       virtual RVC::OBJTYPE v_GetDftObjectType () const;
00519       virtual bool v_IsObjectOpen () const;
00520       virtual ERRVALUE v_OpenObject (OPENMODE OpenFlags, MDLGPARENT parent);
00521 
00522       //! Implementation of RVC::GEOSPATIAL virtual methods
00523       virtual void v_GetExtents (DRECT3D &extents) const;
00524       virtual void v_GetScale (double& xscale, double& yscale) const;
00525       virtual double v_GetZScale () const;
00526       virtual double v_GetZOffset () const;
00527       virtual bool v_HasCapability (int Capability) const;
00528       virtual void v_SetScale (double xscale, double yscale);
00529       virtual void v_SetZOffset (double zoffset);
00530       virtual void v_SetZScale (double zscale);
00531       
00532       //! Implementation of RVC::GEOMETRIC virtual methods
00533       virtual ERRVALUE v_AddSearchTreeElement (INT32 elemnum, ELEMTYPE ElemType, const DRECT2D& Extents);
00534       virtual ERRVALUE v_BuildSearchTree (INT32 InitialNumElements, ELEMTYPE ElemType, const DRECT2D& Extents);
00535       virtual ERRVALUE v_ClearSearchTree (INT32 InitialNumElements, ELEMTYPE ElemType, const DRECT2D& Extents);
00536       virtual ERRVALUE v_CopySearchTreeElement (INT32 SourceElement, INT32 DestElement, ELEMTYPE ElemType, const DRECT2D& Extents);
00537       virtual ERRVALUE v_DeleteSearchTreeElement (INT32 elemnum, ELEMTYPE ElemType);
00538       virtual ERRVALUE v_ExtractTo (RVC::GEOMETRIC& DestObj, RVC::GEOMETRIC::ELEMTRANSLIST& TransList, const TRANS2D_MAPGEN& tmg, RVC::GEOMETRIC::EXTRACTFLAGS ExtractFlags) const;
00539       virtual INT32 v_FindClosestElementLow (ELEMTYPE ElemType, const DPOINT2D& SearchPt, SEARCHFILTER* SearchFilter, double SearchDist, double* DistFromElem) const;
00540       virtual ERRVALUE v_FindClosestElementsLow (const DPOINT2D& SearchPt, double SearchDist, SEARCHFILTER* SearchFilter, SIMPLE_ARRAY<RVC::ELEMENT>& ElementList, COMPONENT Component) const;
00541       virtual ERRVALUE v_FindElementDrawSet (ELEMTYPE ElemType, const DRECT2D& SearchExtents, SEARCHRESULT& SearchResult) const;
00542       virtual ERRVALUE v_FindElementSearchSet (ELEMTYPE ElemType, const DRECT2D& SearchExtents, SEARCHRESULT& SearchResult) const;
00543       virtual INT32 v_GetAttachmentIndex (const RVC::ELEMENT& Element) const;
00544       virtual ERRVALUE v_GetElementExtents (ELEMTYPE ElemType, INT32 ElemNum, DRECT3D& Extents) const;
00545       virtual INT32 v_GetNextElementID (ELEMTYPE ElemType) const;
00546       virtual INT32 v_GetNumElements (ELEMTYPE ElemType) const;
00547       virtual POINTTYPE v_GetPointType () const;
00548       virtual INT32 v_GetPointSize () const;
00549       virtual double v_GetTotalLineLength () const;
00550       virtual bool v_IsElementDeleted (const RVC::ELEMENT& Element) const;
00551       virtual bool v_IsEmpty () const;
00552       virtual ERRVALUE v_SaveSearchTrees ();
00553       virtual ERRVALUE v_SetExtents (const DRECT3D &extents);
00554       virtual ERRVALUE v_SetNextElementID (ELEMTYPE ElemType, INT32 NextElementID);
00555       virtual bool v_SetSearchTree (ELEMTYPE ElemType, RVC::QSEARCHTREE* SearchTree, bool ReplaceExisting);
00556       virtual ERRVALUE v_SetTotalLineLength (double length);
00557       virtual int v_SetupElemTransList (const RVC::GEOMETRIC::ELEMSELECTPARMS& SelectParms, RVC::GEOMETRIC::ELEMTRANSLIST& TransList, RVC::GEOMETRIC::ELEMSELECTFILTER* SelectFilter) const;
00558       virtual bool v_TestElementAgainstRegion (const RVC::ELEMENT& Element, const REGION2D& region, TESTCRITERIA TestMode) const;
00559       virtual ERRVALUE v_UpdateExtents (const DRECT3D& extents);
00560          
00561       CADHANDLE* m_CadHandle;
00562       LINKTYPE m_LinkType;       //!< 2   Type of link (DXF, MIF, ...) 
00563       mutable QSEARCHTREE *m_CADQTree;
00564       class OPTIMIZE;
00565       mutable OPTIMIZE* m_Optimize;
00566       mutable bool m_SetInstanceData;     //!< This object set the instance data if true, it needs to remove it on closing
00567       #endif // GENERATING_DOXYGEN_OUTPUT
00568 
00569    };
00570 
00571 
00572 //! CAD Element Definition
00573 //! This class is used to define and use a CAD object element
00574 class CAD::ELEMENT {
00575    public:
00576    
00577       //! Enumeration of the different CAD element types in use
00578       enum TYPE {
00579          TYPE_Insert = 0,
00580          TYPE_Point = 1,
00581          TYPE_Circle = 2,
00582          TYPE_Arc = 3,
00583          TYPE_ArcChord = 4,
00584          TYPE_Text = 5,
00585          TYPE_Line = 7,
00586          TYPE_RotationBox = 8,
00587          TYPE_Polygon = 9,
00588          TYPE_Mesh = 10,
00589          TYPE_Ellipse = 11,
00590          TYPE_EllipticalArc = 12,
00591          TYPE_ArcWedge = 14,
00592          TYPE_EllipticalArcWedge = 15,
00593          TYPE_EllipticalArcChord = 16,
00594          TYPE_MultiLine = 17,
00595          TYPE_MultiPoint = 18,
00596          TYPE_MultiPolygon = 19,
00597          TYPE_LAST
00598          };
00599 
00600       #ifndef GENERATING_DOXYGEN_OUTPUT   
00601       class BOX;
00602       class DRAW;
00603       class INSERT;
00604       class MESH;
00605       #endif
00606 
00607       //! Default Constructor    
00608       ELEMENT (
00609          );
00610 
00611       //! Copy Constructor    
00612       ELEMENT (
00613          const ELEMENT& rhs
00614          );
00615 
00616       //! Destructor    
00617       ~ELEMENT (
00618          );
00619          
00620       //! Assignment Operator
00621       ELEMENT& operator= (
00622          const ELEMENT& rhs
00623          );
00624 
00625       //! Clear the element
00626       void Clear (
00627          );
00628          
00629       //! Compute the closest distance from an element to the point given
00630       //! NOTE: Does not compute distance from a TYPE_Insert element
00631       double ComputeDistanceFrom (
00632          const DPOINT2D& point
00633          ) const;
00634 
00635       //! Compute the extents of this element         
00636       //! NOTE: Does not compute extents from a TYPE_Insert element, use ComputeInsertExtents()
00637       //! @return 'True' if the extents can be calculated, 'false' if not
00638       bool ComputeExtents (
00639          DRECT3D& Extents
00640          ) const;
00641 
00642       //! Compute the border polygon (rotated box) of the inserted CAD block defined by this element
00643       //! @return 'True' if the element is a TYPE_Insert, 'false' if not
00644       bool ComputeInsertBorder (
00645          const CAD& CadObj,
00646          POLYLINE& Border
00647          ) const;
00648 
00649       //! Compute the extents of the inserted CAD block defined by this element
00650       //! @return 'True' if the element is a TYPE_Insert, 'false' if not
00651       bool ComputeInsertExtents (
00652          const CAD& CadObj,
00653          DRECT3D& Extents
00654          ) const;
00655 
00656       //! Convert point coordinates using affine transformation      
00657       void ConvertForward (
00658          const TRANS2D_AFFINE& taf
00659          );
00660       
00661       //! Convert point coordinates using generic transformation     
00662       ERRVALUE ConvertForward (
00663          const TRANS2D_MAPGEN& tmg
00664          );
00665 
00666       //! Convert point coordinates using generic transformation with densification
00667       ERRVALUE ConvertForwardDense (
00668          const TRANS2D_MAPGEN& tmg
00669          );
00670 
00671       //! Convert point coordinates using 3D perspective transformation    
00672       void ConvertForward (
00673          const TRANS3D& t3d
00674          );
00675       
00676       //! Convert point coordinates using affine transformation      
00677       void ConvertInverse (
00678          const TRANS2D_AFFINE& taf
00679          );
00680       
00681       //! Convert point coordinates using generic transformation     
00682       ERRVALUE ConvertInverse (
00683          const TRANS2D_MAPGEN& tmg
00684          );
00685 
00686       //! Convert point coordinates using generic transformation with densification
00687       ERRVALUE ConvertInverseDense (
00688          const TRANS2D_MAPGEN& tmg
00689          );
00690 
00691       //! Convert point coordinates using 3D perspective transformation    
00692       void ConvertInverse (
00693          const TRANS3D& t3d
00694          );
00695 
00696       //! 'Draw' the element using the "DRAW" interface class passed in
00697       //! This method takes the individual elements and does a transformation to a well known construct to simplify
00698       //! handling of multiple data types.  See RVC::CAD::ELEMENT::DRAW class for the primitives that the ELEMENT class 
00699       //! is transformed to.
00700       //! NOTE: Does not 'draw' from an TYPE_Insert element
00701       ERRVALUE DrawElement (
00702          DRAW& Draw,
00703          const TRANS2D_AFFINE& BlockToCAD,      //!< Affine transformation from inserted block to CAD object coordinates
00704          double MinChordDist = 0.0              //!< Default is to use %5 of the Radius length
00705          );
00706 
00707       //! Get the approximate element type
00708       //! @return ELEMTYPE_Point, ELEMTYPE_Line, ELEMTYPE_Polygon, ELEMTYPE_Label, or ELEMTYPE_Empty if cannot be represented
00709       ELEMTYPE GetAppoxElementType (
00710          ) const;
00711          
00712       //! Get the TYPE_RotationBox from this
00713       //! @return 'True' if the element is a TYPE_RotationBox, 'false' if not
00714       bool GetBox (
00715          BOX& Box
00716          ) const;
00717          
00718       //! Get the database index for this element
00719       //! @return '-1' if no database element index exists for this element, >=0 for valid database element index
00720       INT32 GetDatabaseIndex (
00721          ) const;
00722       
00723       //! Get the ELEMENT::TYPE designation for this
00724       //! @return ELEMENT::TYPE
00725       TYPE GetElementType (
00726          ) const;
00727       
00728       //! Get the TEXTID for the CAD::ELEMENT::TYPE specified.
00729       static TEXTID GetElementTypeTextID (
00730          TYPE CadType
00731          );
00732 
00733       //! Get the TEXTSTYLE for this type
00734       //! @return 'true' if the method is able to set the element style based on its element type, 'false' if not
00735       bool GetElementStyle (
00736          TEXTSTYLE& textstyle
00737          ) const;
00738    
00739       //! Get the POINTSTYLE for this type
00740       //! @return 'true' if the method is able to set the element style based on its element type, 'false' if not
00741       bool GetElementStyle (
00742          POINTSTYLE& pointstyle
00743          ) const;
00744    
00745       //! Get the LINESTYLE for this type
00746       //! @return 'true' if the method is able to set the element style based on its element type, 'false' if not
00747       bool GetElementStyle (
00748          LINESTYLE& linestyle
00749          ) const;
00750    
00751       //! Get the POLYSTYLE for this type
00752       //! @return 'true' if the method is able to set the element style based on its element type, 'false' if not
00753       bool GetElementStyle (
00754          POLYSTYLE& polystyle
00755          ) const;
00756          
00757       //! Get the GML element string based on 'this'.
00758       //! @return 'True' if the element can be converted, 'false' if not and the 'GMLElement' will be empty
00759       bool GetGMLElement (
00760          MISTRING& GMLElement,
00761          const MILIST<std::pair<MISTRING, MISTRING> >& AttribList       //!< List of attributes to add to the element definition (first -> name, second -> value)
00762          );
00763          
00764       //! Get the TYPE_Insert from this
00765       //! @return 'True' if the element is a TYPE_Insert, 'false' if not
00766       bool GetInsert (
00767          INSERT& Insert
00768          ) const;
00769       
00770       //! Get the Text Label frame parms information from this
00771       //! @return 'True' if the element is a TYPE_Text type, 'false' if not
00772       bool GetLabelFrameParms (
00773          LABELFRAMEPARMS& FrameParms
00774          ) const;
00775          
00776       //! Get the line primitives from this
00777       //! @return 'True' if the element is made up of a list of POLYLINE's, 'false' if not
00778       bool GetLines (
00779          POLYLINELIST& PolyLineList
00780          ) const;
00781          
00782       //! Get the TYPE_Mesh from this
00783       //! @return 'True' if the element is a TYPE_Mesh, 'false' if not
00784       bool GetMesh (
00785          MESH& Mesh
00786          ) const;
00787       
00788       //! Get the PLANECONIC representation from this
00789       //! @return 'True' if the element is a PLANECONIC type, 'false' if not
00790       bool GetPlaneConic (
00791          PLANECONIC& Conic
00792          ) const;
00793          
00794       //! Get the point primitives from this
00795       //! @return 'True' if the element is made up of one or more points, 'false' if not
00796       bool GetPoints (
00797          POLYLINE& PointArray
00798          ) const;
00799          
00800       //! Get the REGION2D representation from this
00801       //! @return 'True' if the element is a REGION2D type, 'false' if not
00802       bool GetRegion (
00803          REGION2D& Region,
00804          bool Validate = false
00805          ) const;
00806          
00807       //! Get the SUBREGION2D representation from this
00808       //! @return 'True' if the element is a SUBREGION2D type, 'false' if not
00809       bool GetSubRegion (
00810          SUBREGION2D& SubRegion,
00811          bool Validate = false
00812          ) const;
00813          
00814       //! Get the Text element information from this
00815       //! @return 'True' if the element is a TYPE_Text type, 'false' if not
00816       bool GetTextElement (
00817          POLYLINELIST& PolyLineList,      //!< First line is the baseline, the rest are leader lines
00818          MISTRING& text,
00819          TEXTSTYLE& style,
00820          LABELFRAMEPARMS* FrameParms = 0
00821          ) const;
00822          
00823       //! Get the units of width 
00824       SCREENUNIT GetWidthUnits (
00825          ) const;
00826 
00827       //! Get the Z value assiociated with this element
00828       double GetZValue (
00829          ) const;
00830          
00831       //! Does the label follow the baseline?
00832       //! @return 'True' if label follows baseline
00833       bool IsBaselineFit ( 
00834          ) const;
00835 
00836       //! Does the label follow the splined baseline?
00837       //! @return 'True' if label follows the splined baseline
00838       bool IsBaselineSplineFit ( 
00839          ) const;
00840    
00841       //! Clip vector features under the label when rendering
00842       //! @return 'True' if features under the label needs to be clipped
00843       bool IsClipUnderSet (
00844          ) const;
00845          
00846       //! Is the element an insertion element?
00847       //! @return 'True' if the element is a TYPE_Insert, 'false' if not
00848       bool IsInsertion (
00849          ) const;
00850    
00851       //! Can the element be represented by open lines?
00852       //! @return 'True' if the element can be represented by open lines, 'false' if not
00853       bool IsLine (
00854          ) const;
00855    
00856       //! Can the element be represented by a PLANECONIC
00857       //! @return 'True' if the element can be represented by a PLANECONIC, 'false' if not
00858       bool IsPlaneConic (
00859          ) const;
00860    
00861       //! Can the element be represented by one or more points?
00862       //! @return 'True' if the element can be represented by one or more points, 'false' if not
00863       bool IsPoint (
00864          ) const;
00865 
00866       //! Is the point inside the element?   
00867       //! @return 'True' if the element is a polygon (IsPolygon() == true) and the point is inside it, 'false' if not
00868       bool IsPointInside (
00869          const DPOINT2D& pt
00870          ) const;
00871    
00872       //! Can the element be represented by closed lines?
00873       //! @return 'True' if the element can be represented by closed lines, 'false' if not
00874       bool IsPolygon (
00875          ) const;
00876    
00877       //! Is the element a text element?
00878       //! @return 'True' if the element is a TYPE_Text, 'false' if not
00879       bool IsText (
00880          ) const;
00881 
00882       //! Is the element valid?  Does 'this' represent a CAD element
00883       //! @return 'True' if 'this' is a valid CAD element, 'false' if not
00884       bool IsValid (
00885          ) const;
00886    
00887       //! Set the TYPE_RotationBox from 'Box'
00888       void SetBox (
00889          const BOX& Box
00890          );
00891       
00892       //! Set the label to follow the baseline
00893       void SetBaselineFit (
00894          bool value
00895          );
00896          
00897       //! Set the label to follow the splined baseline
00898       void SetBaselineSplineFit (
00899          bool value
00900          );
00901          
00902       //! Set the label clip under flag
00903       void SetClipUnder (
00904          bool value
00905          );
00906          
00907       //! Set the database index for this element: '-1' if no database element index exists for this element, >=0 for valid database element index
00908       void SetDatabaseIndex (
00909          INT32 index
00910          );
00911 
00912       //! Set 'this' based on the GML element which MUST derive from gml:AbstractGeometryType
00913       //! @return 'True' if the element can be converted, 'false' if not
00914       bool SetElementFromGML (
00915          const MISTRING& GMLElement,
00916          MILIST<std::pair<MISTRING, MISTRING> >& AttribList       //!< List of attributes not used in 'this' (first -> name, second -> value)
00917          );
00918       
00919       //! Set the TEXTSTYLE for this type
00920       void SetElementStyle (
00921          const TEXTSTYLE& textstyle
00922          );
00923    
00924       //! Set the POINTSTYLE for this type
00925       void SetElementStyle (
00926          const POINTSTYLE& pointstyle
00927          );
00928    
00929       //! Set the LINESTYLE for this type
00930       void SetElementStyle (
00931          const LINESTYLE& linestyle
00932          );
00933    
00934       //! Set the POLYSTYLE for this type
00935       void SetElementStyle (
00936          const POLYSTYLE& polystyle
00937          );
00938    
00939       //! Set the TYPE_Insert from 'Insert'
00940       void SetInsert (
00941          const INSERT& Insert
00942          );
00943       
00944       //! Set the element type and the data based on 'PolyLineList'
00945       void SetLines (
00946          const POLYLINELIST& PolyLineList
00947          );
00948          
00949       //! Set the TYPE_Mesh from 'Mesh'
00950       void SetMesh (
00951          const MESH& Mesh
00952          );
00953       
00954       //! Set the element type and data based on 'Conic'
00955       void SetPlaneConic (
00956          const PLANECONIC& Conic
00957          );
00958    
00959       //! Set the element type and data based on 'point'
00960       void SetPoint (
00961          const DPOINT3D& point
00962          );
00963          
00964       //! Set the element type and data based on 'PointArray'
00965       void SetPoints (
00966          const POLYLINE& PointArray
00967          );
00968          
00969       //! Set the element type and data based on 'PolyLine'
00970       void SetPolyLine (
00971          const POLYLINE& PolyLine
00972          );
00973          
00974       //! Set the element type and data based on 'Region'
00975       void SetRegion (
00976          const REGION2D& Region
00977          );
00978          
00979       //! Set the element type and data based on 'SubRegion'
00980       void SetSubRegion (
00981          const SUBREGION2D& SubRegion
00982          );
00983          
00984       //! Set the TYPE_Text from the information passed in
00985       void SetTextElement (
00986          const POLYLINELIST& PolyLineList,         //!< First line is the baseline, the rest are leader lines
00987          const MISTRING& text,
00988          const TEXTSTYLE& style,
00989          const LABELFRAMEPARMS* FrameParms = 0
00990          );
00991 
00992       //! Set the units of width 
00993       void SetWidthUnits (
00994          SCREENUNIT WidthUnits
00995          );
00996          
00997       //! Set the Z value assiociated with this element
00998       void SetZValue (
00999          double zvalue
01000          );
01001          
01002       //! Test this to see if it passes the TEXTCRITERIA given using the REGION2D passed in
01003       //! NOTE: Cannot test a TYPE_Insert element
01004       //! @return 'True' if the element met the criteria, 'false' if not
01005       bool TestElement (
01006          const REGION2D& Region,
01007          TESTCRITERIA TestMode
01008          ) const;
01009    
01010    private:
01011       #ifndef GENERATING_DOXYGEN_OUTPUT   
01012       CADELEMHDR m_ElemHdr;
01013       CADELEMOPT m_ElemOpt;
01014       CADELEMDATA m_ElemData;
01015       POLYLINE m_Points;
01016       MISTRING m_String;
01017       SIMPLE_ARRAY<INT32> m_IsleList;
01018       SIMPLE_ARRAY<CADSUBPOLY> m_SubPolyList;
01019 
01020       void ClearGeometric ();
01021       void ComputeStringExtents (DRECT3D& Extents) const;
01022       void GeneratePointsFromBox (POLYLINE& PolyLine) const;
01023       void GetPolyLineList (POLYLINELIST& PolyLineList) const;
01024       void SetPolyLineList (const POLYLINELIST& PolyLineList);
01025       void TranslatePatterns (const SIMPLE_ARRAY<INT32> PattTrans[RVC::STYLE::PATTERN_NumTypes]);
01026 
01027       class GMLSAX;     
01028       friend class GMLSAX;
01029       friend class CAD;
01030       #endif
01031    };
01032    
01033 DEFINE_ENUM_OP_INCREMENT(CAD::ELEMENT::TYPE)
01034 
01035 //! CAD element TYPE_RotationBox class implementation
01036 class CAD::ELEMENT::BOX {
01037    public:
01038       //! Default Constructor    
01039       BOX () : m_Rotation(0.0) {}
01040 
01041       //! Copy Constructor    
01042       BOX (const BOX& rhs) : m_rect(rhs.m_rect), m_Rotation(rhs.m_Rotation) {}
01043 
01044       //! Assignment Operator
01045       BOX& operator= (
01046          const BOX& rhs
01047          ) { 
01048          if (this != &rhs) {
01049             m_rect = rhs.m_rect; 
01050             m_Rotation = rhs.m_Rotation;
01051             } 
01052          return (*this); 
01053          }
01054 
01055       //! Clear the box
01056       void Clear (
01057          ) {
01058          m_rect.SetInvalid();
01059          m_Rotation = 0.0;
01060          return;
01061          }
01062 
01063       // Generate a POLYLINE describing the box       
01064       void GeneratePoints (
01065          POLYLINE& PolyLine,
01066          DIMENSION dim
01067          ) const;
01068       
01069       //! Get the box rectangle, unrotated
01070       //! @return The box rectangle
01071       const DRECT3D& GetBoxExtents (
01072          ) const { return (m_rect); }
01073    
01074       //! Get the box rotation value in radians
01075       //! @return The box rotation value in radians
01076       double GetRotation (
01077          ) const { return (m_Rotation); }
01078    
01079       //! Set the box rectangle, unrotated
01080       void SetBoxExtents (
01081          const DRECT3D& rect
01082          ) { m_rect = rect; }
01083    
01084       //! Set the box rotation value in radians
01085       void SetRotation (
01086          double Rotation
01087          ) { m_Rotation = Rotation; }
01088    
01089    private:
01090       #ifndef GENERATING_DOXYGEN_OUTPUT   
01091       DRECT3D m_rect;
01092       double m_Rotation;
01093       #endif
01094    };
01095 
01096 
01097 //! CAD::ELEMENT Interface class to render and/or transform CAD Elements into common types
01098 class CAD::ELEMENT::DRAW {
01099    public:
01100       DRAW () {}
01101       virtual ~DRAW () {}
01102 
01103       //! First chance to render an element without any transformations to one of methods below.
01104       //! @return >0 if this method used the element and do not call methods below, ==0 if call the methods below, <0 error
01105       int DrawElement (
01106          const CAD::ELEMENT& Element,        //!< Original CAD::ELEMENT
01107          const TRANS2D_AFFINE& BtoC          //!< Block to CAD transformation, methods below will do the transform before sending the converted element
01108          ) { return (v_DrawElement(Element, BtoC)); }
01109 
01110       //! Transform CAD element to a set of one or more lines, only if the element can be represented as lines and not polygons
01111       ERRVALUE DrawLines (
01112          const CAD::ELEMENT& Element,        //!< Original CAD::ELEMENT
01113          const POLYLINELIST& LineList        //!< CAD::ELEMENT transformed to lines
01114          ) { return (v_DrawLines(Element, LineList)); }
01115 
01116       //! Transform CAD element to a set of one or more singular points, only if the element can be represented as singular points
01117       ERRVALUE DrawPoints (
01118          const CAD::ELEMENT& Element,        //!< Original CAD::ELEMENT
01119          const POLYLINE& Points              //!< CAD::ELEMENT transformed to a POLYLINE of points
01120          ) { return (v_DrawPoints(Element, Points)); }
01121 
01122       //! Called if the CAD element is a text label element
01123       ERRVALUE DrawText (
01124          const CAD::ELEMENT& Element,        //!< Original CAD::ELEMENT
01125          const MISTRING& string,             //!< Text string
01126          const POLYLINELIST& LineList        //!< First line is the baseline, all others after that are leader lines
01127          ) { return (v_DrawText(Element, string, LineList)); }
01128 
01129       //! Transform CAD element to a SUBREGION2D, only if the element can be represented as a SUBREGION2D
01130       //! Multiple calls to this method will be done if one SUBREGION2D is not enough (CAD::ELEMENT::TYPE_MultiPolygon)
01131       ERRVALUE DrawSubRegion (
01132          const CAD::ELEMENT& Element,        //!< Original CAD::ELEMENT
01133          const SUBREGION2D& SubRegion        //!< SubRegion to fill
01134          ) { return (v_DrawSubRegion(Element, SubRegion)); }
01135          
01136    private:
01137 
01138       virtual int v_DrawElement (const CAD::ELEMENT& Element, const TRANS2D_AFFINE& BtoC) { return (0); }
01139       virtual ERRVALUE v_DrawLines (const CAD::ELEMENT& Element, const POLYLINELIST& LineList) { return (0); }
01140       virtual ERRVALUE v_DrawPoints (const CAD::ELEMENT& Element, const POLYLINE& Points) { return (0); }
01141       virtual ERRVALUE v_DrawText (const CAD::ELEMENT& Element, const MISTRING& string, const POLYLINELIST& LineList) { return (0); }
01142       virtual ERRVALUE v_DrawSubRegion (const CAD::ELEMENT& Element, const SUBREGION2D& SubRegion) { return (0); }
01143    };
01144 
01145 
01146 //! CAD Interface class to filter CAD elements before drawing
01147 //! Inherits from CAD::ELEMENT::DRAW
01148 class CAD::DRAW : public CAD::ELEMENT::DRAW {
01149    public:
01150       DRAW () {}
01151       virtual ~DRAW () {}
01152    
01153       //! Filter CAD elements before they are rendered.  Specific place to modify certain attributes of the element and update element status
01154       //! @return >0 if the element is to be rendered, ==0 if not, <0 error
01155       int FilterElement (
01156          CAD::ELEMENT& Element,              //!< Original CAD::ELEMENT, can change specific items in the element in the filter call
01157          const TRANS2D_AFFINE& BtoC,         //!< Block to CAD transformation
01158          INT32 InsertLevel,                  //!< How deep the block insertion stack is, 0 for main block
01159          INT32 ElemNum,                      //!< Element number in the current drawing block
01160          const DRECT3D& Extents              //!< Element extents, maybe invalid
01161          ) { return (v_FilterElement(Element, BtoC, InsertLevel, ElemNum, Extents)); }
01162          
01163    private:
01164       virtual int v_FilterElement (CAD::ELEMENT& Element, const TRANS2D_AFFINE& BtoC, INT32 InsertLevel, INT32 ElemNum, const DRECT3D& Extents) { return (1); }
01165    };
01166    
01167 
01168 //! CAD element TYPE_Insert class implementation
01169 class CAD::ELEMENT::INSERT {
01170    public:
01171       //! Default Constructor    
01172       INSERT (
01173          ) :
01174          m_InsertPt(0.0,0.0,0.0),
01175          m_BlockNum(-1),
01176          m_rotate(0.0),
01177          m_xscale(1.0),
01178          m_yscale(1.0),
01179          m_zscale(1.0),
01180          m_numlins(1),
01181          m_numcols(1),
01182          m_linspace(0.0),
01183          m_colspace(0.0)
01184          {}
01185          
01186       //! Set the INSERT class back to its ctor'd state
01187       void Clear (
01188          ) {
01189          m_InsertPt.x = m_InsertPt.y = m_InsertPt.z = m_linspace = m_colspace = m_rotate = 0.0;
01190          m_BlockNum = -1;
01191          m_xscale = m_yscale = m_zscale = 1.0;
01192          m_numlins = m_numcols = 1;
01193          return;
01194          }
01195          
01196       //! Get the CAD block number to insert
01197       //! @return The CAD block number to insert      
01198       INT32 GetBlockNum (
01199          ) const { return (m_BlockNum); }
01200          
01201       //! Get the column spacing between block array insertions
01202       //! only useful if GetNumColumns() > 1
01203       //! @return Column spacing between block array insertions
01204       double GetColumnSpace (
01205          ) const { return (m_colspace); }
01206 
01207       //! Get the block insertion point location
01208       //! @return Block insertion point
01209       const DPOINT3D& GetInsertPoint (
01210          ) const { return (m_InsertPt); }
01211 
01212       //! Get the line spacing between block array insertions
01213       //! only useful if GetNumLines() > 1
01214       //! @return Line spacing between block array insertions
01215       double GetLineSpace (
01216          ) const { return (m_linspace); }
01217 
01218       //! Get the number of columns in a multi-block array insert
01219       //! @return Number of columns in a multi-block array insert
01220       INT32 GetNumColumns (
01221          ) const { return (m_numcols); }
01222          
01223       //! Get the number of lines in a multi-block array insert
01224       //! @return Number of lines in a multi-block array insert
01225       INT32 GetNumLines (
01226          ) const { return (m_numlins); }
01227          
01228       //! Get the rotation angle (in radians) that the block is rotated around the insertion point
01229       //! @return Insertion rotation angle in radians
01230       double GetRotation (
01231          ) const { return (m_rotate); }
01232 
01233       //! Get the x scale factor that the block is scaled around the insertion point
01234       //! @return Insertion X scale factor
01235       double GetXScale (
01236          ) const { return (m_xscale); }
01237 
01238       //! Get the y scale factor that the block is scaled around the insertion point
01239       //! @return Insertion Y scale factor
01240       double GetYScale (
01241          ) const { return (m_yscale); }
01242 
01243       //! Get the z scale factor that the block is scaled around the insertion point
01244       //! @return Insertion Z scale factor
01245       double GetZScale (
01246          ) const { return (m_zscale); }
01247 
01248       //! Set the CAD block number to insert
01249       void SetBlockNum (
01250          INT32 BlockNum
01251          ) { m_BlockNum = BlockNum; }
01252          
01253       //! Set the column spacing between block array insertions
01254       //! only useful if GetNumColumns() > 1
01255       void SetColumnSpace (
01256          double ColumnSpace
01257          ) { m_colspace = ColumnSpace; }
01258 
01259       //! Set the block insertion point location
01260       void SetInsertPoint (
01261          const DPOINT3D& InsertPt
01262          ) { m_InsertPt = InsertPt; }
01263 
01264       //! Set the line spacing between block array insertions
01265       //! only useful if GetNumLines() > 1
01266       void SetLineSpace (
01267          double LineSpace
01268          ) { m_linspace = LineSpace; }
01269 
01270       //! Set the number of columns in a multi-block array insert
01271       void SetNumColumns (
01272          INT32 NumColumns
01273          ) { m_numcols = static_cast<UINT16>(NumColumns); if (m_numcols == 0) m_numcols = 1; }
01274          
01275       //! Set the number of lines in a multi-block array insert
01276       void SetNumLines (
01277          INT32 NumLines
01278          ) { m_numlins = static_cast<UINT16>(NumLines); if (m_numlins == 0) m_numlins = 1; }
01279          
01280       //! Set the rotation angle (in radians) that the block is rotated around the insertion point
01281       void SetRotation (
01282          double rotate
01283          ) { m_rotate = rotate; }
01284 
01285       //! Set the x scale factor that the block is scaled around the insertion point
01286       void SetXScale (
01287          double xscale
01288          ) { m_xscale = xscale; if (m_xscale == 0.0) m_xscale = 1.0; }
01289 
01290       //! Set the y scale factor that the block is scaled around the insertion point
01291       void SetYScale (
01292          double yscale
01293          ) { m_yscale = yscale; if (m_yscale == 0.0) m_yscale = 1.0; }
01294 
01295       //! Set the z scale factor that the block is scaled around the insertion point
01296       void SetZScale (
01297          double zscale
01298          ) { m_zscale = zscale; if (m_zscale == 0.0) m_zscale = 1.0; }
01299 
01300    private:
01301       #ifndef GENERATING_DOXYGEN_OUTPUT   
01302       DPOINT3D m_InsertPt;             //!<  Point where to insert the block 
01303       INT32 m_BlockNum;                //!<  Index of block to insert 
01304       double m_rotate;                 //!<  Rotation angle 
01305       double m_xscale;                 //!<  X Scale factor
01306       double m_yscale;                 //!<  Y Scale factor
01307       double m_zscale;                 //!<  Z Scale factor
01308       UINT16 m_numlins;                //!<  Number of lines
01309       UINT16 m_numcols;                //!<  Number of columns
01310       double m_linspace;               //!<  Spacing between lines 
01311       double m_colspace;               //!<  Spacing between columns 
01312       #endif
01313    };
01314 
01315 
01316 //! CAD element TYPE_Mesh class implementation
01317 class CAD::ELEMENT::MESH {
01318    public:
01319       //! Default Constructor    
01320       MESH (
01321          ) : 
01322          m_NumLineVertices(0),
01323          m_NumColumnVertices(0),
01324          m_TopBottomClosed(false),
01325          m_LeftRightClosed(false)
01326          {}
01327          
01328       //! Set the MESH class back to its ctor'd state
01329       void Clear (
01330          ) {
01331          m_MeshPoints.Clear();         
01332          m_NumLineVertices = m_NumColumnVertices = 0;
01333          m_TopBottomClosed = m_LeftRightClosed = false;
01334          return;
01335          }
01336             
01337       //! Get the mesh point array.  
01338       //! The number of points is equal to GetNumColumnVertices() * GetNumLineVertices()
01339       //! @return A POLYLINE containing the mesh points
01340       const POLYLINE& GetMeshPoints (
01341          ) const { return (m_MeshPoints); }
01342       
01343       //! Get the number of columns in the mesh
01344       //! @return Number of columns in the mesh
01345       UINT32 GetNumColumnVertices (
01346          ) const { return (m_NumColumnVertices); }
01347          
01348       //! Get the number of lines in the mesh
01349       //! @return Number of lines in the mesh
01350       UINT32 GetNumLineVertices (
01351          ) const { return (m_NumLineVertices); }
01352          
01353       //! Determine if the left and right sides of the mesh are to be closed
01354       //! @return 'True' if the left and right sides are to be closed, 'false' if not
01355       bool IsLeftRightClosed (
01356          ) const { return (m_LeftRightClosed); }
01357    
01358       //! Determine if the top and bottom sides of the mesh are to be closed
01359       //! @return 'True' if the top and bottom sides are to be closed, 'false' if not
01360       bool IsTopBottomClosed (
01361          ) const { return (m_TopBottomClosed); }
01362 
01363       //! Set flag to state that the left and right sides of the mesh are to be closed
01364       void SetLeftRightClosed (
01365          bool LeftRightClosed
01366          ) { m_LeftRightClosed = LeftRightClosed; }
01367          
01368       //! Set the mesh point array.  
01369       //! The number of points is equal to GetNumColumnVertices() * GetNumLineVertices()
01370       void SetMeshPoints (
01371          const POLYLINE& MeshPoints
01372          ) { m_MeshPoints = MeshPoints; }
01373    
01374       //! Set the number of columns in the mesh
01375       void SetNumColumnVertices (
01376          UINT32 NumColumnVertices
01377          ) { m_NumColumnVertices = NumColumnVertices; }
01378          
01379       //! Set the number of lines in the mesh
01380       void SetNumLineVertices (
01381          UINT32 NumLineVertices
01382          ) { m_NumLineVertices = NumLineVertices; }
01383          
01384       //! Set flag to state that the top and bottom sides of the mesh are to be closed
01385       void SetTopBottomClosed (
01386          bool TopBottomClosed
01387          ) { m_TopBottomClosed = TopBottomClosed; }
01388          
01389    private:
01390       #ifndef GENERATING_DOXYGEN_OUTPUT   
01391       UINT32 m_NumLineVertices;                 //!<  Number of X vertices for mesh 
01392       UINT32 m_NumColumnVertices;               //!<  Number of Y vertices for mesh 
01393       bool m_TopBottomClosed;
01394       bool m_LeftRightClosed;
01395       POLYLINE m_MeshPoints;
01396       #endif
01397    };
01398 
01399 
01400 //! Constant element iterator class
01401 //!
01402 //! This class is used to iterate through a CAD object's elements.  See methods ElementBegin() and ElementEnd() for obtaining a 
01403 //! CAD object element iterator
01404 class CAD::CONST_ELEMITERATOR {
01405    public:
01406       //! Default constructor
01407       CONST_ELEMITERATOR (
01408          ) : 
01409          m_CADObj(0),
01410          m_Element(0),
01411          m_ReachedEnd(false)
01412          {}
01413 
01414       //! Copy constructor
01415       CONST_ELEMITERATOR (
01416          const CONST_ELEMITERATOR& rhs
01417          ) : 
01418          m_Element(0),
01419          m_CADObj(rhs.m_CADObj),
01420          m_ReachedEnd(rhs.m_ReachedEnd)
01421          {
01422          if (rhs.m_Element != 0) m_Element = new ELEMENT(*rhs.m_Element);
01423          }
01424 
01425       #ifndef GENERATING_DOXYGEN_OUTPUT
01426       //! Internal constructor used by ElementEnd() methods
01427       CONST_ELEMITERATOR (
01428          const RVC::CAD* CADObj,
01429          INT32 LastElemNum
01430          ) : 
01431          m_Element(0),
01432          m_CADObj(CADObj),
01433          m_ReachedEnd(true)
01434          {}
01435 
01436       //! Internal constructor used by ElementBegin() methods
01437       CONST_ELEMITERATOR (
01438          const RVC::CAD* CADObj
01439          ) :
01440          m_Element(0),
01441          m_CADObj(CADObj),
01442          m_ReachedEnd(false)
01443          {
01444          ERRORPOSNDISABLE disable;
01445          const_cast<CAD*>(CADObj)->Rewind();
01446          m_Element = new ELEMENT;
01447          m_ReachedEnd = (CADObj->ReadElement(*m_Element) == R_BadCADElemNum);
01448          }
01449             
01450       #endif // GENERATING_DOXYGEN_OUTPUT
01451 
01452       //! Destructor
01453       virtual ~CONST_ELEMITERATOR (
01454          ) {
01455          delete m_Element;
01456          }
01457 
01458       //! Assignment
01459       CONST_ELEMITERATOR& operator= (
01460          const CONST_ELEMITERATOR& rhs
01461          ) {
01462          if (this != &rhs) {
01463             delete m_Element;
01464             m_Element = 0;
01465             if (rhs.m_Element != 0) m_Element = new ELEMENT(*rhs.m_Element);
01466             m_CADObj = rhs.m_CADObj;
01467             m_ReachedEnd = rhs.m_ReachedEnd;
01468             }
01469          return (*this);
01470          }
01471 
01472       //! Dereference
01473       const ELEMENT& operator* (
01474          ) const { return (*m_Element); }
01475 
01476       //! Dereference arrow
01477       const ELEMENT* operator-> (
01478          ) const { return (&**this); }
01479 
01480       //! Pre-increment
01481       CONST_ELEMITERATOR& operator++ (
01482          ) {
01483          ERRORPOSNDISABLE disable;
01484          m_ReachedEnd = (m_CADObj->ReadElement(*m_Element) == R_BadCADElemNum);
01485          return (*this);
01486          }
01487 
01488       //! Comparison for equality
01489       bool operator== (
01490          const CONST_ELEMITERATOR& rhs
01491          ) const { return (m_CADObj == rhs.m_CADObj && m_ReachedEnd == rhs.m_ReachedEnd); }
01492 
01493       //! Comparison for inequality
01494       bool operator!= (
01495          const CONST_ELEMITERATOR& rhs
01496          ) const { return (!(*this == rhs)); }
01497 
01498    private:
01499       #ifndef GENERATING_DOXYGEN_OUTPUT
01500       ELEMENT* m_Element;
01501       const CAD* m_CADObj;
015