// Copyright (c) 2015 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #ifndef _ShapePersistent_TopoDS_HeaderFile #define _ShapePersistent_TopoDS_HeaderFile #include #include #include #include #include #include #include #include #include #include #include class ShapePersistent_TopoDS : public StdPersistent_TopoDS { public: class HShape : public StdObjMgt_Persistent, public StdObject_Shape { public: //! Read persistent data from a file. Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData); //! Write persistent data to a file Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const; //! Gets persistent child objects Standard_EXPORT virtual void PChildren(SequenceOfPersistent& theChildren) const; //! Returns persistent type name virtual Standard_CString PName() const { return "PTopoDS_HShape"; } private: Handle(StdObjMgt_Persistent) myEntry; }; protected: class pTBase : public pTShape { public: inline Handle(TopoDS_TShape) Import() const { Handle(TopoDS_TShape) aTShape = createTShape(); TopoDS_Shape aWrapperShape; aWrapperShape.TShape (aTShape); addShapes (aWrapperShape); setFlags (aTShape); return aTShape; } private: virtual Handle(TopoDS_TShape) createTShape() const = 0; virtual void addShapes (TopoDS_Shape& theParent) const = 0; void setFlags (const Handle(TopoDS_TShape)& theTShape) const; protected: template void addShapesT (TopoDS_Shape& theParent) const; }; private: template class pTSimple : public pTBase { virtual Handle(TopoDS_TShape) createTShape() const; public: inline Standard_CString PName() const; }; template class pTObject : public Persistent { virtual void addShapes (TopoDS_Shape& theParent) const { pTBase::addShapesT (theParent); } }; template struct tObjectT : public Delayed , pTObject > { typedef pTObject pTObjectT; }; protected: template struct tObject : public tObjectT { }; template struct tObject1 : public tObjectT { }; public: typedef tObject > TWire; typedef tObject > TShell; typedef tObject > TSolid; typedef tObject > TCompSolid; typedef tObject > TCompound; typedef tObject1 > TWire1; typedef tObject1 > TShell1; typedef tObject1 > TSolid1; typedef tObject1 > TCompSolid1; typedef tObject1 > TCompound1; public: //! Create a persistent object for a shape Standard_EXPORT static Handle(HShape) Translate (const TopoDS_Shape& theShape, StdObjMgt_TransientPersistentMap& theMap, ShapePersistent_TriangleMode theTriangleMode); }; template<> inline Standard_CString ShapePersistent_TopoDS::pTSimple::PName() const { return "PTopoDS_TWire"; } template<> inline Standard_CString ShapePersistent_TopoDS::pTSimple::PName() const { return "PTopoDS_TShell"; } template<> inline Standard_CString ShapePersistent_TopoDS::pTSimple::PName() const { return "PTopoDS_TSolid"; } template<> inline Standard_CString ShapePersistent_TopoDS::pTSimple::PName() const { return "PTopoDS_TCompSolid"; } template<> inline Standard_CString ShapePersistent_TopoDS::pTSimple::PName() const { return "PTopoDS_TCompound"; } #endif