1 // Copyright (c) 2015 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #ifndef _ShapePersistent_TopoDS_HeaderFile
16 #define _ShapePersistent_TopoDS_HeaderFile
18 #include <ShapePersistent_TriangleMode.hxx>
20 #include <StdPersistent_TopoDS.hxx>
21 #include <StdPersistent_HArray1.hxx>
22 #include <StdLPersistent_HArray1.hxx>
23 #include <StdObject_Shape.hxx>
24 #include <StdObjMgt_TransientPersistentMap.hxx>
26 #include <TopoDS_TWire.hxx>
27 #include <TopoDS_TShell.hxx>
28 #include <TopoDS_TSolid.hxx>
29 #include <TopoDS_TCompSolid.hxx>
30 #include <TopoDS_TCompound.hxx>
33 class ShapePersistent_TopoDS : public StdPersistent_TopoDS
36 class HShape : public StdObjMgt_Persistent, public StdObject_Shape
39 //! Read persistent data from a file.
40 Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
41 //! Write persistent data to a file
42 Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
43 //! Gets persistent child objects
44 Standard_EXPORT virtual void PChildren(SequenceOfPersistent& theChildren) const;
45 //! Returns persistent type name
46 Standard_EXPORT virtual Standard_CString PName() const { return "PTopoDS_HShape"; }
49 Handle(StdObjMgt_Persistent) myEntry;
53 class pTBase : public pTShape
56 inline Handle(TopoDS_TShape) Import() const
58 Handle(TopoDS_TShape) aTShape = createTShape();
60 TopoDS_Shape aWrapperShape;
61 aWrapperShape.TShape (aTShape);
62 addShapes (aWrapperShape);
70 virtual Handle(TopoDS_TShape) createTShape() const = 0;
72 virtual void addShapes (TopoDS_Shape& theParent) const = 0;
74 void setFlags (const Handle(TopoDS_TShape)& theTShape) const;
77 template <class ShapesArray>
78 void addShapesT (TopoDS_Shape& theParent) const;
82 template <class Target>
83 class pTSimple : public pTBase
85 virtual Handle(TopoDS_TShape) createTShape() const;
87 inline Standard_CString PName() const;
90 template <class Persistent, class ShapesArray>
91 class pTObject : public Persistent
93 virtual void addShapes (TopoDS_Shape& theParent) const
94 { pTBase::addShapesT<ShapesArray> (theParent); }
97 template <class Persistent, class ShapesArray>
98 struct tObjectT : public Delayed <DelayedBase<TShape, TopoDS_TShape, pTBase>,
99 pTObject<Persistent, ShapesArray> >
100 { typedef pTObject<Persistent, ShapesArray> pTObjectT; };
103 template <class Persistent>
104 struct tObject : public tObjectT<Persistent, StdLPersistent_HArray1::Persistent> { };
106 template <class Persistent>
107 struct tObject1 : public tObjectT<Persistent, StdPersistent_HArray1::Shape1> { };
110 typedef tObject <pTSimple<TopoDS_TWire> > TWire;
111 typedef tObject <pTSimple<TopoDS_TShell> > TShell;
112 typedef tObject <pTSimple<TopoDS_TSolid> > TSolid;
113 typedef tObject <pTSimple<TopoDS_TCompSolid> > TCompSolid;
114 typedef tObject <pTSimple<TopoDS_TCompound> > TCompound;
116 typedef tObject1 <pTSimple<TopoDS_TWire> > TWire1;
117 typedef tObject1 <pTSimple<TopoDS_TShell> > TShell1;
118 typedef tObject1 <pTSimple<TopoDS_TSolid> > TSolid1;
119 typedef tObject1 <pTSimple<TopoDS_TCompSolid> > TCompSolid1;
120 typedef tObject1 <pTSimple<TopoDS_TCompound> > TCompound1;
123 //! Create a persistent object for a shape
124 Standard_EXPORT static Handle(HShape) Translate (const TopoDS_Shape& theShape,
125 StdObjMgt_TransientPersistentMap& theMap,
126 ShapePersistent_TriangleMode theTriangleMode);
130 inline Standard_CString ShapePersistent_TopoDS::pTSimple<TopoDS_TWire>::PName() const
131 { return "PTopoDS_TWire"; }
134 inline Standard_CString ShapePersistent_TopoDS::pTSimple<TopoDS_TShell>::PName() const
135 { return "PTopoDS_TShell"; }
138 inline Standard_CString ShapePersistent_TopoDS::pTSimple<TopoDS_TSolid>::PName() const
139 { return "PTopoDS_TSolid"; }
142 inline Standard_CString ShapePersistent_TopoDS::pTSimple<TopoDS_TCompSolid>::PName() const
143 { return "PTopoDS_TCompSolid"; }
146 inline Standard_CString ShapePersistent_TopoDS::pTSimple<TopoDS_TCompound>::PName() const
147 { return "PTopoDS_TCompound"; }