ff205346 |
1 | // Copyright (c) 2015 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
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. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #include <ShapePersistent_TopoDS.hxx> |
15 | |
16 | #include <BRep_Builder.hxx> |
17 | |
18 | |
19 | enum |
20 | { |
21 | ModifiedMask = 2, |
22 | CheckedMask = 4, |
23 | OrientableMask = 8, |
24 | ClosedMask = 16, |
25 | InfiniteMask = 32, |
26 | ConvexMask = 64 |
27 | }; |
28 | |
29 | |
30 | //======================================================================= |
31 | //function : Read |
32 | //purpose : Read persistent data from a file |
33 | //======================================================================= |
45d8465e |
34 | void ShapePersistent_TopoDS::HShape::Read (StdObjMgt_ReadData& theReadData) |
ff205346 |
35 | { |
36 | theReadData >> myEntry; |
45d8465e |
37 | StdObject_Shape::read (theReadData); |
ff205346 |
38 | } |
39 | |
40 | void ShapePersistent_TopoDS::pTBase::setFlags |
41 | (const Handle(TopoDS_TShape)& theTShape) const |
42 | { |
43 | theTShape->Free (Standard_False); // Always frozen when coming from DB |
dde68833 |
44 | theTShape->Modified ((myFlags & ModifiedMask) != 0); |
45 | theTShape->Checked ((myFlags & CheckedMask) != 0); |
46 | theTShape->Orientable ((myFlags & OrientableMask) != 0); |
47 | theTShape->Closed ((myFlags & ClosedMask) != 0); |
48 | theTShape->Infinite ((myFlags & InfiniteMask) != 0); |
49 | theTShape->Convex ((myFlags & ConvexMask) != 0); |
ff205346 |
50 | } |
51 | |
52 | static inline void AddShape |
53 | (TopoDS_Shape& theParent, const Handle(StdObjMgt_Persistent)& theRef) |
54 | { |
45d8465e |
55 | Handle(ShapePersistent_TopoDS::HShape) aShape = |
56 | Handle(ShapePersistent_TopoDS::HShape)::DownCast (theRef); |
ff205346 |
57 | |
58 | if (aShape) |
59 | BRep_Builder().Add (theParent, aShape->Import()); |
60 | } |
61 | |
62 | static inline void AddShape |
63 | (TopoDS_Shape& theParent, const StdObject_Shape& theShape) |
64 | { |
65 | BRep_Builder().Add (theParent, theShape.Import()); |
66 | } |
67 | |
68 | template <class ShapesArray> |
69 | void ShapePersistent_TopoDS::pTBase::addShapesT |
70 | (TopoDS_Shape& theParent) const |
71 | { |
45d8465e |
72 | Handle(ShapesArray) aShapes = Handle(ShapesArray)::DownCast (myShapes); |
73 | if (aShapes) |
ff205346 |
74 | { |
75 | typename ShapesArray::Iterator anIter (*aShapes->Array()); |
76 | for (; anIter.More(); anIter.Next()) |
77 | AddShape (theParent, anIter.Value()); |
78 | } |
79 | } |
80 | |
81 | template void ShapePersistent_TopoDS::pTBase::addShapesT |
82 | <StdLPersistent_HArray1::Persistent> (TopoDS_Shape& theParent) const; |
83 | |
84 | template void ShapePersistent_TopoDS::pTBase::addShapesT |
85 | <StdPersistent_HArray1::Shape1> (TopoDS_Shape& theParent) const; |
86 | |
87 | template <class Target> |
88 | Handle(TopoDS_TShape) |
89 | ShapePersistent_TopoDS::pTSimple<Target>::createTShape() const |
90 | { return new Target; } |
91 | |
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>; |