1 // Copyright (C) 2013 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Frederic Pons (OpenCascade)
21 #ifndef __XAO_BREPGEOMETRY_HXX__
22 #define __XAO_BREPGEOMETRY_HXX__
27 #include <TopoDS_Shape.hxx>
29 #include "XAO_XaoUtils.hxx"
30 #include "XAO_Geometry.hxx"
36 * Representation of a BRep Geometry.
38 class BrepGeometry : public Geometry
42 * Default Constructor.
48 * @param name the name of the geometry.
50 BrepGeometry(const std::string& name);
52 virtual ~BrepGeometry() {}
55 * Gets the format of the geometry.
56 * @return the format of the geometry.
58 virtual const XAO::Format getFormat() { return XAO::BREP; }
61 * Gets the shape as a string.
62 * @return the shape as a string.
64 virtual const std::string getShapeString();
67 * Sets the shape from a string.
68 * @param shape the shape as a string.
70 virtual void setShapeString(const std::string& shape);
74 def setShape(self, shape):
75 if shape is not None and 'GetShapeStream' in dir(shape):
76 self.setShapeString(shape.GetShapeStream())
78 raise XAO_Exception("Cannot set shape")
83 * Gets the shape as a TopoDS_Shape.
84 * @return the TopoDS_Shape.
86 TopoDS_Shape getTopoDS_Shape();
89 * Sets the shape from a TopoDS_Shape.
90 * @param shape the TopoDS_Shape to set.
92 void setTopoDS_Shape(const TopoDS_Shape& shape);
95 * Gives the two extrimities of an edge.
96 * @param edgeIndex the index of the edge.
100 void getEdgeVertices(const int& edgeIndex, int& vertexA, int& vertexB);
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.
107 const int countFaceWires(const int& faceIndex);
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.
115 std::vector<int> getFaceEdges(const int& faceIndex, const int& wireIndex);
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.
122 const int countSolidShells(const int& solidIndex);
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.
130 std::vector<int> getSolidFaces(const int& solidIndex, const int& shellIndex);
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.
139 void getVertexXYZ(const int& vertexIndex, double& xCoord, double& yCoord, double& zCoord)
140 throw (XAO_Exception);
143 * Gets the length of an edge.
144 * @param index the index of the edge.
145 * @return the length of the edge.
147 const double getEdgeLength(const int& index);
150 * Gets the are of a face.
151 * @param index the index of a face.
152 * @return the area of the face.
154 const double getFaceArea(const int& index);
157 * Gets the volume of a solid.
158 * @param index the index of the solid.
159 * @return the volume of the solid.
161 const double getSolidVolume(const int& index);
164 * Gets the ID of a vertex.
165 * @param index the index of the vertex.
166 * @return the ID of the vertex.
168 const int getVertexID(const int& index);
171 * Gets the ID of an edge.
172 * @param index the index of the edge.
173 * @return the ID of the edge.
175 const int getEdgeID(const int& index);
178 * Gets the ID of a face.
179 * @param index the index of the face.
180 * @return the ID of the face.
182 const int getFaceID(const int& index);
185 * Gets the ID of a solid.
186 * @param index the index of the solid.
187 * @return the ID of the solid.
189 const int getSolidID(const int& index);
192 * Sets the ID of a vertex.
193 * @param index the index of the vertex to set.
194 * @param id the id to set.
196 void setVertexID(const int& index, const int& id);
199 * Sets the ID of an edge.
200 * @param index the index of the edge to set.
201 * @param id the id to set.
203 void setEdgeID(const int& index, const int& id);
206 * Sets the ID of a face.
207 * @param index the index of the face to set.
208 * @param id the id to set.
210 void setFaceID(const int& index, const int& id);
213 * Sets the ID of a solid.
214 * @param index the index of the solid to set.
215 * @param id the id to set.
217 void setSolidID(const int& index, const int& id);
220 * Finds a vertex with its ID.
221 * @param id the ID of the vertex.
222 * @return the index of the vertex.
224 const int findVertex(const int& id);
227 * Finds an edge with its ID.
228 * @param id the ID of the edge.
229 * @return the index of the edge.
231 const int findEdge(const int& id);
234 * Finds a face with its ID.
235 * @param id the ID of the face.
236 * @return the index of the face.
238 const int findFace(const int& id);
241 * Finds a solid with its ID.
242 * @param id the ID of the solid.
243 * @return th index of the solid.
245 const int findSolid(const int& id);
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.
252 const std::string findVertexName(const int& id);
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.
259 const std::string findEdgeName(const int& id);
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.
266 const std::string findFaceName(const int& id);
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.
273 const std::string findSolidName(const int& id);
276 * Changes the name of a vertex.
277 * @param id the ID of the vertex.
278 * @param name the name to set.
280 void changeVertexName(const int& id, const std::string& name) throw (XAO_Exception);
283 * Changes the name of an edge.
284 * @param id the ID of the edge
285 * @param name the name to set.
287 void changeEdgeName(const int& id, const std::string& name) throw (XAO_Exception);
290 * Changes the name of a face.
291 * @param id the ID of the face.
292 * @param name the name to set.
294 void changeFaceName(const int& id, const std::string& name) throw (XAO_Exception);
297 * Changes the name of a solid.
298 * @param id the ID of the solid.
299 * @param name the name to set.
301 void changeSolidName(const int& id, const std::string& name) throw (XAO_Exception);
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);
314 TopoDS_Shape m_shape;
318 #endif // __XAO_BREPGEOMETRY_HXX__