]> SALOME platform Git repositories - modules/geom.git/blob - src/XAO/XAO_BrepGeometry.hxx
Salome HOME
Merge from BR_V7_main_Field branch (02/09/2013)
[modules/geom.git] / src / XAO / XAO_BrepGeometry.hxx
1 // Copyright (C) 2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Frederic Pons (OpenCascade)
20
21 #ifndef __XAO_BREPGEOMETRY_HXX__
22 #define __XAO_BREPGEOMETRY_HXX__
23
24 #include <string>
25 #include <vector>
26
27 #include <TopoDS_Shape.hxx>
28
29 #include "XAO_XaoUtils.hxx"
30 #include "XAO_Geometry.hxx"
31
32 namespace XAO
33 {
34     /**
35      * @class BrepGeometry
36      * Representation of a BRep Geometry.
37      */
38     class BrepGeometry : public Geometry
39     {
40     public:
41         /**
42          * Default Constructor.
43          */
44         BrepGeometry();
45
46         /**
47          * Constructor.
48          * @param name the name of the geometry.
49          */
50         BrepGeometry(const std::string& name);
51
52         virtual ~BrepGeometry() {}
53
54         /**
55          * Gets the format of the geometry.
56          * @return the format of the geometry.
57          */
58         virtual const XAO::Format getFormat() { return XAO::BREP; }
59
60         /**
61          * Gets the shape as a string.
62          * @return the shape as a string.
63          */
64         virtual const std::string getShapeString();
65
66         /**
67          * Sets the shape from a string.
68          * @param shape the shape as a string.
69          */
70         virtual void setShapeString(const std::string& shape);
71
72 #ifdef SWIG
73         %pythoncode %{
74         def setShape(self, shape):
75             if shape is not None and 'GetShapeStream' in dir(shape):
76                 self.setShapeString(shape.GetShapeStream())
77             else:
78                 raise XAO_Exception("Cannot set shape")
79         %}
80 #endif
81
82         /**
83          * Gets the shape as a TopoDS_Shape.
84          * @return the TopoDS_Shape.
85          */
86         TopoDS_Shape getTopoDS_Shape();
87
88         /**
89          * Sets the shape from a TopoDS_Shape.
90          * @param shape the TopoDS_Shape to set.
91          */
92         void setTopoDS_Shape(const TopoDS_Shape& shape);
93
94         /**
95          * Gives the two extrimities of an edge.
96          * @param edgeIndex the index of the edge.
97          * @param vertexA
98          * @param vertexB
99          */
100         void getEdgeVertices(const int& edgeIndex, int& vertexA, int& vertexB);
101
102         /**
103          * Gets the number of wires of a face (including holes).
104          * @param faceIndex the index of the face.
105          * @return the number of wires.
106          */
107         const int countFaceWires(const int& faceIndex);
108
109         /**
110          * Gets the indices of the wires of the face.
111          * @param faceIndex the index of the face.
112          * @param wireIndex the index of the wire.
113          * @return the list of wires for the given face.
114          */
115         std::vector<int> getFaceEdges(const int& faceIndex, const int& wireIndex);
116
117         /**
118          * Gets the number of shells of a solid (including cavities).
119          * @param solidIndex the index of the solid.
120          * @return the number of shells.
121          */
122         const int countSolidShells(const int& solidIndex);
123
124         /**
125          * Gets the indices of the shells of the solids.
126          * @param solidIndex the index of the solid.
127          * @param shellIndex the index of the shell (for the given solid).
128          * @return the list of shells for the given solid.
129          */
130         std::vector<int> getSolidFaces(const int& solidIndex, const int& shellIndex);
131
132         /**
133          * Gets the coordinates of a vertex.
134          * @param vertexIndex the index of the vertex.
135          * @param xCoord the X coordinate.
136          * @param yCoord the Y coordinate.
137          * @param zCoord the Z coordinate.
138          */
139         void getVertexXYZ(const int& vertexIndex, double& xCoord, double& yCoord, double& zCoord)
140         throw (XAO_Exception);
141
142         /**
143          * Gets the length of an edge.
144          * @param index the index of the edge.
145          * @return the length of the edge.
146          */
147         const double getEdgeLength(const int& index);
148
149         /**
150          * Gets the are of a face.
151          * @param index the index of a face.
152          * @return the area of the face.
153          */
154         const double getFaceArea(const int& index);
155
156         /**
157          * Gets the volume of a solid.
158          * @param index the index of the solid.
159          * @return the volume of the solid.
160          */
161         const double getSolidVolume(const int& index);
162
163         /**
164          * Gets the ID of a vertex.
165          * @param index the index of the vertex.
166          * @return the ID of the vertex.
167          */
168         const int getVertexID(const int& index);
169
170         /**
171          * Gets the ID of an edge.
172          * @param index the index of the edge.
173          * @return the ID of the edge.
174          */
175         const int getEdgeID(const int& index);
176
177         /**
178          * Gets the ID of a face.
179          * @param index the index of the face.
180          * @return the ID of the face.
181          */
182         const int getFaceID(const int& index);
183
184         /**
185          * Gets the ID of a solid.
186          * @param index the index of the solid.
187          * @return the ID of the solid.
188          */
189         const int getSolidID(const int& index);
190
191         /**
192          * Sets the ID of a vertex.
193          * @param index the index of the vertex to set.
194          * @param id the id to set.
195          */
196         void setVertexID(const int& index, const int& id);
197
198         /**
199          * Sets the ID of an edge.
200          * @param index the index of the edge to set.
201          * @param id the id to set.
202          */
203         void setEdgeID(const int& index, const int& id);
204
205         /**
206          * Sets the ID of a face.
207          * @param index the index of the face to set.
208          * @param id the id to set.
209          */
210         void setFaceID(const int& index, const int& id);
211
212         /**
213          * Sets the ID of a solid.
214          * @param index the index of the solid to set.
215          * @param id the id to set.
216          */
217         void setSolidID(const int& index, const int& id);
218
219         /**
220          * Finds a vertex with its ID.
221          * @param id the ID of the vertex.
222          * @return the index of the vertex.
223          */
224         const int findVertex(const int& id);
225
226         /**
227          * Finds an edge with its ID.
228          * @param id the ID of the edge.
229          * @return the index of the edge.
230          */
231         const int findEdge(const int& id);
232
233         /**
234          * Finds a face with its ID.
235          * @param id the ID of the face.
236          * @return the index of the face.
237          */
238         const int findFace(const int& id);
239
240         /**
241          * Finds a solid with its ID.
242          * @param id the ID of the solid.
243          * @return th index of the solid.
244          */
245         const int findSolid(const int& id);
246
247         /**
248          * Finds the name of a vertex with its ID.
249          * @param id the ID of the vertex.
250          * @return the name of the vertex.
251          */
252         const std::string findVertexName(const int& id);
253
254         /**
255          * Finds the name of an edge with its ID.
256          * @param id the ID of the edge.
257          * @return the name of the edge.
258          */
259         const std::string findEdgeName(const int& id);
260
261         /**
262          * Finds the name of a face with its ID.
263          * @param id the ID of the face.
264          * @return the name of the face.
265          */
266         const std::string findFaceName(const int& id);
267
268         /**
269          * Finds the name of a solid with its ID.
270          * @param id the ID of the solid.
271          * @return the name of the solid.
272          */
273         const std::string findSolidName(const int& id);
274
275         /**
276          * Changes the name of a vertex.
277          * @param id the ID of the vertex.
278          * @param name the name to set.
279          */
280         void changeVertexName(const int& id, const std::string& name) throw (XAO_Exception);
281
282         /**
283          * Changes the name of an edge.
284          * @param id the ID of the edge
285          * @param name the name to set.
286          */
287         void changeEdgeName(const int& id, const std::string& name) throw (XAO_Exception);
288
289         /**
290          * Changes the name of a face.
291          * @param id the ID of the face.
292          * @param name the name to set.
293          */
294         void changeFaceName(const int& id, const std::string& name) throw (XAO_Exception);
295
296         /**
297          * Changes the name of a solid.
298          * @param id the ID of the solid.
299          * @param name the name to set.
300          */
301         void changeSolidName(const int& id, const std::string& name) throw (XAO_Exception);
302
303     private:
304         void initIds();
305         void initListIds(const TopAbs_ShapeEnum& shapeType, GeometricElementList& eltList);
306         TopoDS_Shape getSubShape(const TopoDS_Shape& mainShape, const TopAbs_ShapeEnum& shapeType, const int& shapeIndex)
307             throw (XAO_Exception);
308         const int countGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType);
309         std::vector<int> getGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType, const XAO::Dimension& dim);
310         const int findElement(const XAO::Dimension& dim, const int& id)
311             throw (XAO_Exception);
312
313     private:
314         TopoDS_Shape m_shape;
315     };
316 }
317
318 #endif // __XAO_BREPGEOMETRY_HXX__