| 1 | -- Created on: 2004-05-11 |
| 2 | -- Created by: Sergey ZARITCHNY <szy@opencascade.com> |
| 3 | -- Copyright (c) 2004-2012 OPEN CASCADE SAS |
| 4 | -- |
| 5 | -- The content of this file is subject to the Open CASCADE Technology Public |
| 6 | -- License Version 6.5 (the "License"). You may not use the content of this file |
| 7 | -- except in compliance with the License. Please obtain a copy of the License |
| 8 | -- at http://www.opencascade.org and read it completely before using this file. |
| 9 | -- |
| 10 | -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
| 11 | -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
| 12 | -- |
| 13 | -- The Original Code and all software distributed under the License is |
| 14 | -- distributed on an "AS IS" basis, without warranty of any kind, and the |
| 15 | -- Initial Developer hereby disclaims all such warranties, including without |
| 16 | -- limitation, any warranties of merchantability, fitness for a particular |
| 17 | -- purpose or non-infringement. Please see the License for the specific terms |
| 18 | -- and conditions governing the rights and limitations under the License. |
| 19 | |
| 20 | |
| 21 | |
| 22 | class ShapeSet from BinTools |
| 23 | |
| 24 | ---Purpose: Writes topology in OStream in binary format |
| 25 | |
| 26 | uses |
| 27 | Shape from TopoDS, |
| 28 | IndexedMapOfShape from TopTools, |
| 29 | ShapeEnum from TopAbs, |
| 30 | Builder from BRep, |
| 31 | ShapeEnum from TopAbs, |
| 32 | LocationSet from BinTools, |
| 33 | SurfaceSet from BinTools, |
| 34 | CurveSet from BinTools, |
| 35 | Curve2dSet from BinTools, |
| 36 | IndexedMapOfTransient from TColStd |
| 37 | |
| 38 | |
| 39 | is |
| 40 | |
| 41 | |
| 42 | Create(isWithTriangles: Boolean from Standard = Standard_False) |
| 43 | returns ShapeSet from BinTools; |
| 44 | ---Purpose: Builds an empty ShapeSet. |
| 45 | -- Parameter <isWithTriangles> is added for XML Persistence |
| 46 | |
| 47 | Delete(me:out) is virtual; |
| 48 | ---C++: alias "Standard_EXPORT virtual ~BinTools_ShapeSet(){Delete() ; }" |
| 49 | |
| 50 | SetFormatNb(me : out; theFormatNb : Integer) is static; |
| 51 | |
| 52 | FormatNb(me) returns Integer is static; |
| 53 | ---Purpose: two formats available for the moment: |
| 54 | -- First: does not write CurveOnSurface UV Points into the file |
| 55 | -- on reading calls Check() method. |
| 56 | -- Second: stores CurveOnSurface UV Points. |
| 57 | -- On reading format is recognized from Version string. |
| 58 | |
| 59 | Clear(me : in out) |
| 60 | ---Purpose: Clears the content of the set. |
| 61 | is virtual; |
| 62 | |
| 63 | Add(me : in out; S : Shape from TopoDS) returns Integer |
| 64 | ---Purpose: Stores <S> and its sub-shape. Returns the index of <S>. |
| 65 | -- The method AddGeometry is called on each sub-shape. |
| 66 | is static; |
| 67 | |
| 68 | Shape(me; I : Integer) returns Shape from TopoDS |
| 69 | ---Purpose: Returns the sub-shape of index <I>. |
| 70 | -- |
| 71 | ---C++: return const & |
| 72 | is static; |
| 73 | |
| 74 | Index(me; S : Shape from TopoDS) returns Integer |
| 75 | ---Purpose: Returns the index of <S>. |
| 76 | is static; |
| 77 | |
| 78 | Locations(me) returns LocationSet from BinTools |
| 79 | ---C++: return const & |
| 80 | is static; |
| 81 | |
| 82 | ChangeLocations(me : in out) returns LocationSet from BinTools |
| 83 | ---C++: return & |
| 84 | is static; |
| 85 | |
| 86 | NbShapes(me) returns Integer; |
| 87 | ---Purpose:Returns number of shapes read from file. |
| 88 | |
| 89 | Write(me; OS : in out OStream) |
| 90 | ---Purpose: Writes the content of me on the stream <OS> in binary |
| 91 | -- format that can be read back by Read. |
| 92 | -- |
| 93 | -- Writes the locations. |
| 94 | -- |
| 95 | -- Writes the geometry calling WriteGeometry. |
| 96 | -- |
| 97 | -- Dumps the shapes from last to first. |
| 98 | -- For each shape : |
| 99 | -- Write the type. |
| 100 | -- calls WriteGeometry(S). |
| 101 | -- Write the flags, the subshapes. |
| 102 | is virtual; |
| 103 | |
| 104 | Read(me : in out; IS : in out IStream) |
| 105 | ---Purpose: Reads the content of me from the binary stream <IS>. me |
| 106 | -- is first cleared. |
| 107 | -- |
| 108 | -- Reads the locations. |
| 109 | -- |
| 110 | -- Reads the geometry calling ReadGeometry. |
| 111 | -- |
| 112 | -- Reads the shapes. |
| 113 | -- For each shape |
| 114 | -- Reads the type. |
| 115 | -- calls ReadGeometry(T,S). |
| 116 | -- Reads the flag, the subshapes. |
| 117 | is virtual; |
| 118 | |
| 119 | Write(me; S : Shape from TopoDS; OS : in out OStream) |
| 120 | ---Purpose: Writes on <OS> the shape <S>. Writes the |
| 121 | -- orientation, the index of the TShape and the index |
| 122 | -- of the Location. |
| 123 | is virtual; |
| 124 | |
| 125 | WriteGeometry(me; OS : in out OStream) |
| 126 | ---Purpose: Writes the geometry of me on the stream <OS> in a |
| 127 | -- binary format that can be read back by Read. |
| 128 | is virtual; |
| 129 | |
| 130 | ReadGeometry(me : in out; IS : in out IStream) |
| 131 | ---Purpose: Reads the geometry of me from the stream <IS>. |
| 132 | is virtual; |
| 133 | |
| 134 | Read(me; S : in out Shape from TopoDS; IS : in out IStream; |
| 135 | NbShapes : Integer) |
| 136 | ---Purpose: Reads from <IS> a shape and returns it in S. |
| 137 | -- <NbShapes> is the number of tshapes in the set. |
| 138 | is virtual; |
| 139 | |
| 140 | WriteGeometry(me; S : Shape from TopoDS; OS : in out OStream) |
| 141 | ---Purpose: Writes the geometry of <S> on the stream <OS> in a |
| 142 | -- binary format that can be read back by Read. |
| 143 | is virtual; |
| 144 | |
| 145 | ReadGeometry(me : in out; T : ShapeEnum from TopAbs; |
| 146 | IS : in out IStream; |
| 147 | S : out Shape from TopoDS) |
| 148 | ---Purpose: Reads the geometry of a shape of type <T> from the |
| 149 | -- stream <IS> and returns it in <S>. |
| 150 | is virtual; |
| 151 | |
| 152 | AddGeometry(me : in out; S : Shape from TopoDS) |
| 153 | ---Purpose: Stores the goemetry of <S>. |
| 154 | is virtual; |
| 155 | |
| 156 | -- WriteLocations(me; OS: in out OStream from Standard) is static; |
| 157 | |
| 158 | -- ReadLocations(me: in out; OS: in out IStream from Standard) is static; |
| 159 | |
| 160 | AddShapes(me : in out; S1 : in out Shape from TopoDS; |
| 161 | S2 : Shape from TopoDS) |
| 162 | ---Purpose: Inserts the shape <S2> in the shape <S1>. |
| 163 | is virtual; |
| 164 | |
| 165 | ReadPolygon3D(me: in out; IS: in out IStream) |
| 166 | ---Purpose: Reads the 3d polygons of me |
| 167 | -- from the stream <IS>. |
| 168 | is static; |
| 169 | |
| 170 | WritePolygon3D(me; OS: in out OStream) |
| 171 | ---Purpose: Writes the 3d polygons |
| 172 | -- on the stream <OS> in a format that can |
| 173 | -- be read back by Read. |
| 174 | is static; |
| 175 | |
| 176 | ReadTriangulation(me: in out; IS: in out IStream) |
| 177 | ---Purpose: Reads the triangulation of me |
| 178 | -- from the stream <IS>. |
| 179 | is static; |
| 180 | |
| 181 | WriteTriangulation(me; OS: in out OStream) |
| 182 | ---Purpose: Writes the triangulation |
| 183 | -- on the stream <OS> in a format that can |
| 184 | -- be read back by Read. |
| 185 | is static; |
| 186 | |
| 187 | ReadPolygonOnTriangulation(me: in out; IS: in out IStream) |
| 188 | ---Purpose: Reads the polygons on triangulation of me |
| 189 | -- from the stream <IS>. |
| 190 | is static; |
| 191 | |
| 192 | WritePolygonOnTriangulation(me; OS: in out OStream) |
| 193 | ---Purpose: Writes the polygons on triangulation |
| 194 | -- on the stream <OS> in a format that can |
| 195 | -- be read back by Read. |
| 196 | is static; |
| 197 | |
| 198 | fields |
| 199 | myShapes : IndexedMapOfShape from TopTools; |
| 200 | myLocations : LocationSet from BinTools; |
| 201 | myFormatNb : Integer from Standard; -- jfa 26.09.2001 |
| 202 | myBuilder : Builder from BRep; |
| 203 | mySurfaces : SurfaceSet from BinTools; |
| 204 | myCurves : CurveSet from BinTools; |
| 205 | myCurves2d : Curve2dSet from BinTools; |
| 206 | myPolygons2D: IndexedMapOfTransient from TColStd; |
| 207 | myPolygons3D: IndexedMapOfTransient from TColStd; |
| 208 | myTriangulations: IndexedMapOfTransient from TColStd; |
| 209 | myNodes : IndexedMapOfTransient from TColStd; |
| 210 | myWithTriangles: Boolean from Standard; |
| 211 | end ShapeSet; |