// 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 "ShapePersistent_TriangleMode.hxx" #include "StdPersistent_HArray1.hxx" #include "StdLPersistent_HArray1.hxx" #include "StdObject_Shape.hxx" #include "NCollection_DataMap.hxx" #include "TopoDS_TWire.hxx" #include "TopoDS_TShell.hxx" #include "TopoDS_TSolid.hxx" #include "TopoDS_TCompSolid.hxx" #include "TopoDS_TCompound.hxx" class Standard_Transient; class StdObjMgt_Persistent; class ShapePersistent_TopoDS : public StdPersistent_TopoDS { public: class HShape : public StdObjMgt_Persistent, public StdObject_Shape { public: //! Read persistent data from a file. Standard_EXPORT void Read(StdObjMgt_ReadData& theReadData) override; //! Write persistent data to a file Standard_EXPORT void Write(StdObjMgt_WriteData& theWriteData) const override; //! Gets persistent child objects Standard_EXPORT void PChildren(SequenceOfPersistent& theChildren) const override; //! Returns persistent type name const char* PName() const override { return "PTopoDS_HShape"; } private: occ::handle myEntry; }; protected: class pTBase : public pTShape { public: inline occ::handle Import() const { occ::handle aTShape = createTShape(); TopoDS_Shape aWrapperShape; aWrapperShape.TShape(aTShape); addShapes(aWrapperShape); setFlags(aTShape); return aTShape; } private: virtual occ::handle createTShape() const = 0; virtual void addShapes(TopoDS_Shape& theParent) const = 0; void setFlags(const occ::handle& theTShape) const; protected: template void addShapesT(TopoDS_Shape& theParent) const; }; private: template class pTSimple : public pTBase { occ::handle createTShape() const override; public: inline const char* PName() const; }; template class pTObject : public Persistent { void addShapes(TopoDS_Shape& theParent) const override { 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 occ::handle Translate( const TopoDS_Shape& theShape, NCollection_DataMap, occ::handle>& theMap, ShapePersistent_TriangleMode theTriangleMode); }; template <> inline const char* ShapePersistent_TopoDS::pTSimple::PName() const { return "PTopoDS_TWire"; } template <> inline const char* ShapePersistent_TopoDS::pTSimple::PName() const { return "PTopoDS_TShell"; } template <> inline const char* ShapePersistent_TopoDS::pTSimple::PName() const { return "PTopoDS_TSolid"; } template <> inline const char* ShapePersistent_TopoDS::pTSimple::PName() const { return "PTopoDS_TCompSolid"; } template <> inline const char* ShapePersistent_TopoDS::pTSimple::PName() const { return "PTopoDS_TCompound"; } #endif