// // Copyright (c) 2000 by Tech Soft 3D, LLC. // The information contained herein is confidential and proprietary to // Tech Soft 3D, LLC., and considered a trade secret as defined under // civil and criminal statutes. Tech Soft 3D shall pursue its civil // and criminal remedies in the event of unauthorized use or misappropriation // of its trade secrets. Use of this information by anyone other than // authorized employees of Tech Soft 3D, LLC. is granted only under a // written non-disclosure agreement, expressly prescribing the scope and // manner of such use. // // $Header: /files/homes/master/cvs/hoops_master/hoops_appwizard/VCWizards/HOOPSAppWiz_NET2008/Templates/1033/3daf/HMSFileToolkit.h,v 1.1 2008-04-16 23:14:27 stage Exp $ // #ifndef _HMSFILETOOLKIT_H_ #define _HMSFILETOOLKIT_H_ #include "afxtempl.h" #include "HStream.h" #include "HOpcodeShell.h" #include "HPolyPoly.h" class HBaseModel; //! The CModellerObject class is used to store and manage information about an solid modeler object /*! Assuming a BRep model, this class stores the information about it's (body, face, edge etc.) and also about its parents and childern. This class is expected to be used as a base class for different type of modeller objects your geometry kernel may have. */ class CModellerObject { public: HC_KEY *m_keys; /*!< Array of HOOPS keys associated with this modeller object */ int m_numchildren; /*!< Number of children this object has */ long *m_children; /*!< Array of ids of children of this object */ long *m_parents; /*!< Array of ids of parents of this object */ int m_identifier; /*!< Solid modeler identifier (tag/pointer) of this object */ /*! Constructs CModellerObject object */ CModellerObject() { m_keys = 0; m_numchildren=0; m_children = 0; m_parents = 0; m_identifier = 0; } /*! Destroys the CModeller object and frees up memory associated with it */ ~CModellerObject() { delete [] m_keys; delete [] m_children; delete [] m_parents; } /*! Returns the class of the object (body/face/edge). Should be overridden by the derived class */ virtual int AskClass() { return 0; } /*! Returns the number of keys associated with this model. Should be overridden */ virtual long GetKeyNum() { if (!m_keys) return 0; else return 1; } /*! Associates the given key with the modeller object. It erases any previously associated keys */ virtual void SetKey(HC_KEY key) { if (m_keys!=0) delete m_keys; if (key!=0) { m_keys = new HC_KEY; m_keys[0] = key; } } /*! Associates the given id as a parent of this modeller object. It erases any previously associated parent */ virtual void SetParent(long parent) { if (m_parents!=0) delete m_parents; m_parents = new long; m_parents[0] = parent; } /*! Sets the children count and allocated memory to store the ids. It erases any previously associated children */ void SetChildNum(int numchildren) { m_numchildren = numchildren; if (m_children) delete [] m_children; m_children = new long[numchildren]; } }; //! The CBaseModellerObject class is used to store and manage information about an solid modeler object /*! This class can be use to extend the base class and create a more specific modeller object (e.g. BRep object). Currently, there it is not utilised in that way. */ class CBaseModellerObject : public CModellerObject { public: /*! Constructor */ CBaseModellerObject() : CModellerObject() {} /*! Returns the class of the object (body/face/edge). Should be overridden by the derived class */ virtual int AskClass() { return 0; } }; //! The CBodyModellerObject class represents a BODY type of solid modeller object /*! The CBodyModellerObject class represents a BODY type of solid modeller object */ class CBodyModellerObject : public CModellerObject { public: /*! Constructor */ CBodyModellerObject() : CModellerObject() {} /*! Returns the class of the object - which in this case is BODY */ virtual int AskClass() { return BODY_TYPE; } }; //! The CFaceModellerObject class represents a FACE type of solid modeller object /*! The CFaceModellerObject class represents a FACE type of solid modeller object */ class CFaceModellerObject : public CModellerObject { public: /*! Constructor */ CFaceModellerObject() : CModellerObject() {} /*! Returns the class of the object - which in this case is FACE */ virtual int AskClass() { return FACE_TYPE; } }; //! The CEdgeModellerObject class represents a EDGE type of solid modeller object /*! The CEdgeModellerObject class represents a EDGE type of solid modeller object */ class CEdgeModellerObject : public CModellerObject { public: int m_numkeys; /*!< Number of keys associated with this object */ int m_numparents; /*!< Number of parents associated with this object */ /*! Constructor */ CEdgeModellerObject() : CModellerObject() {m_numparents=0;} /*! Returns the class of the object - which in this case is EDGE */ virtual int AskClass() { return EDGE_TYPE; } /*! Associates a key to the object. The key is inserted in the list at the given position */ void SetKey(int pos, int key) { m_keys[pos] = key; } /*! Sets the associated keys count and allocated memory to store the ids. It erases any previously associated keys */ void SetKeyNum(int numkeys) { if (m_keys!=0) delete m_keys; m_keys = new HC_KEY[numkeys]; m_numkeys = numkeys; } /*! Adds the given id to the parents array of the object. The parent is ignored if the object has already more than one parent associated */ void AddParent(int parent) { if (m_numparents == 0) { delete m_parents; m_parents = new long[2]; } if (m_numparents<2) m_parents[m_numparents++] = parent; } /*! Returns the number of keys associated */ long GetKeyNum() { return m_numkeys; } }; //! The CModellerInfo class manages the associativity information /*! The CModellerInfo uses a hash map to store the associativity information between the solid modeller and HOOPS */ class CModellerInfo { public: int m_objectnum; /*!< Number of objects */ bool m_bIsValid; /*!< Is the object valid for use */ CModellerObject **m_objects; /*!< Solid modeler object information */ CMap m_map; /*!< Hash map storing the associativity information */ bool m_bTesselatedFaces; /*!< true if the body is tessleated at face level */ bool m_bPSF; /*!< true if the modeler file is embedded into the hsf file */ /*! Constructor */ CModellerInfo() { m_objects=0; m_objectnum = 0; m_map.InitHashTable(1201); m_bIsValid = false; m_bTesselatedFaces = false; m_bPSF = false; } /*! Destroys the CModellerInfo object and frees up memory associated with it */ ~CModellerInfo() { if( m_objects ) { for (int i=0;i