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