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.
14 #include <ShapePersistent_TopoDS.hxx>
16 #include <BRep_Builder.hxx>
30 //=======================================================================
32 //purpose : Read persistent data from a file
33 //=======================================================================
34 void ShapePersistent_TopoDS::Shape::Read (StdObjMgt_ReadData& theReadData)
36 theReadData >> myEntry;
37 myShape.Read (theReadData);
40 void ShapePersistent_TopoDS::pTBase::setFlags
41 (const Handle(TopoDS_TShape)& theTShape) const
43 theTShape->Free (Standard_False); // Always frozen when coming from DB
44 theTShape->Modified (myFlags & ModifiedMask);
45 theTShape->Checked (myFlags & CheckedMask);
46 theTShape->Orientable (myFlags & OrientableMask);
47 theTShape->Closed (myFlags & ClosedMask);
48 theTShape->Infinite (myFlags & InfiniteMask);
49 theTShape->Convex (myFlags & ConvexMask);
52 static inline void AddShape
53 (TopoDS_Shape& theParent, const Handle(StdObjMgt_Persistent)& theRef)
55 Handle(ShapePersistent_TopoDS::Shape) aShape =
56 Handle(ShapePersistent_TopoDS::Shape)::DownCast (theRef);
59 BRep_Builder().Add (theParent, aShape->Import());
62 static inline void AddShape
63 (TopoDS_Shape& theParent, const StdObject_Shape& theShape)
65 BRep_Builder().Add (theParent, theShape.Import());
68 template <class ShapesArray>
69 void ShapePersistent_TopoDS::pTBase::addShapesT
70 (TopoDS_Shape& theParent) const
72 Handle(ShapesArray) aShapes;
73 if (myShapes.Cast (aShapes))
75 typename ShapesArray::Iterator anIter (*aShapes->Array());
76 for (; anIter.More(); anIter.Next())
77 AddShape (theParent, anIter.Value());
81 template void ShapePersistent_TopoDS::pTBase::addShapesT
82 <StdLPersistent_HArray1::Persistent> (TopoDS_Shape& theParent) const;
84 template void ShapePersistent_TopoDS::pTBase::addShapesT
85 <StdPersistent_HArray1::Shape1> (TopoDS_Shape& theParent) const;
87 template <class Target>
89 ShapePersistent_TopoDS::pTSimple<Target>::createTShape() const
90 { return new Target; }
92 template class ShapePersistent_TopoDS::pTSimple<TopoDS_TWire>;
93 template class ShapePersistent_TopoDS::pTSimple<TopoDS_TShell>;
94 template class ShapePersistent_TopoDS::pTSimple<TopoDS_TSolid>;
95 template class ShapePersistent_TopoDS::pTSimple<TopoDS_TCompSolid>;
96 template class ShapePersistent_TopoDS::pTSimple<TopoDS_TCompound>;