1 // Copyright (C) 2013-2019 CEA/DEN, EDF R&D, OPEN CASCADE
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, or (at your option) any later version.
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>
30 #include "XAO_XaoUtils.hxx"
31 #include "XAO_Geometry.hxx"
34 #pragma warning(disable:4290) // Warning Exception ...
42 * Representation of a BRep Geometry.
44 class XAO_EXPORT BrepGeometry : public Geometry
48 * Default Constructor.
54 * @param name the name of the geometry.
56 BrepGeometry(const std::string& name);
58 virtual ~BrepGeometry() {}
61 * Gets the format of the geometry.
62 * @return the format of the geometry.
64 virtual const XAO::Format getFormat() { return XAO::BREP; }
67 * Gets the shape as a string.
68 * @return the shape as a string.
70 virtual const std::string getShapeString();
73 * Sets the shape from a string.
74 * @param shape the shape as a string.
76 virtual void setShapeString(const std::string& shape);
79 * Writes shape to a file
80 * @param fileName the path to the file
82 virtual void writeShapeFile(const std::string& fileName) throw (XAO_Exception);
85 * Reads shape from a file
86 * @param fileName the path to the file
88 virtual void readShapeFile(const std::string& fileName) throw (XAO_Exception);
92 def setShape(self, shape):
93 if shape is not None and 'GetShapeStream' in dir(shape):
94 self.setShapeString(shape.GetShapeStream())
96 raise XAO_Exception("Cannot set shape")
101 * Gets the shape as a TopoDS_Shape.
102 * @return the TopoDS_Shape.
104 TopoDS_Shape getTopoDS_Shape();
107 * Sets the shape from a TopoDS_Shape.
108 * @param shape the TopoDS_Shape to set.
110 void setTopoDS_Shape(const TopoDS_Shape& shape);
113 * Gives the two extrimities of an edge.
114 * @param edgeIndex the index of the edge.
118 void getEdgeVertices(const int& edgeIndex, int& vertexA, int& vertexB);
121 * Gets the number of wires of a face (including holes).
122 * @param faceIndex the index of the face.
123 * @return the number of wires.
125 const int countFaceWires(const int& faceIndex);
128 * Gets the indices of the wires of the face.
129 * @param faceIndex the index of the face.
130 * @param wireIndex the index of the wire.
131 * @return the list of wires for the given face.
133 std::vector<int> getFaceEdges(const int& faceIndex, const int& wireIndex);
136 * Gets the number of shells of a solid (including cavities).
137 * @param solidIndex the index of the solid.
138 * @return the number of shells.
140 const int countSolidShells(const int& solidIndex);
143 * Gets the indices of the shells of the solids.
144 * @param solidIndex the index of the solid.
145 * @param shellIndex the index of the shell (for the given solid).
146 * @return the list of shells for the given solid.
148 std::vector<int> getSolidFaces(const int& solidIndex, const int& shellIndex);
151 * Gets the coordinates of a vertex.
152 * @param vertexIndex the index of the vertex.
153 * @param xCoord the X coordinate.
154 * @param yCoord the Y coordinate.
155 * @param zCoord the Z coordinate.
157 void getVertexXYZ(const int& vertexIndex, double& xCoord, double& yCoord, double& zCoord)
158 throw (XAO_Exception);
161 * Gets the length of an edge.
162 * @param index the index of the edge.
163 * @return the length of the edge.
165 const double getEdgeLength(const int& index);
168 * Gets the are of a face.
169 * @param index the index of a face.
170 * @return the area of the face.
172 const double getFaceArea(const int& index);
175 * Gets the volume of a solid.
176 * @param index the index of the solid.
177 * @return the volume of the solid.
179 const double getSolidVolume(const int& index);
182 * Gets the ID of a vertex.
183 * @param index the index of the vertex.
184 * @return the ID of the vertex.
186 const int getVertexID(const int& index);
189 * Gets the ID of an edge.
190 * @param index the index of the edge.
191 * @return the ID of the edge.
193 const int getEdgeID(const int& index);
196 * Gets the ID of a face.
197 * @param index the index of the face.
198 * @return the ID of the face.
200 const int getFaceID(const int& index);
203 * Gets the ID of a solid.
204 * @param index the index of the solid.
205 * @return the ID of the solid.
207 const int getSolidID(const int& index);
210 * Sets the ID of a vertex.
211 * @param index the index of the vertex to set.
212 * @param id the id to set.
214 void setVertexID(const int& index, const int& id);
217 * Sets the ID of an edge.
218 * @param index the index of the edge to set.
219 * @param id the id to set.
221 void setEdgeID(const int& index, const int& id);
224 * Sets the ID of a face.
225 * @param index the index of the face to set.
226 * @param id the id to set.
228 void setFaceID(const int& index, const int& id);
231 * Sets the ID of a solid.
232 * @param index the index of the solid to set.
233 * @param id the id to set.
235 void setSolidID(const int& index, const int& id);
238 * Finds a vertex with its ID.
239 * @param id the ID of the vertex.
240 * @return the index of the vertex.
242 const int findVertex(const int& id);
245 * Finds an edge with its ID.
246 * @param id the ID of the edge.
247 * @return the index of the edge.
249 const int findEdge(const int& id);
252 * Finds a face with its ID.
253 * @param id the ID of the face.
254 * @return the index of the face.
256 const int findFace(const int& id);
259 * Finds a solid with its ID.
260 * @param id the ID of the solid.
261 * @return th index of the solid.
263 const int findSolid(const int& id);
266 * Finds the name of a vertex with its ID.
267 * @param id the ID of the vertex.
268 * @return the name of the vertex.
270 const std::string findVertexName(const int& id);
273 * Finds the name of an edge with its ID.
274 * @param id the ID of the edge.
275 * @return the name of the edge.
277 const std::string findEdgeName(const int& id);
280 * Finds the name of a face with its ID.
281 * @param id the ID of the face.
282 * @return the name of the face.
284 const std::string findFaceName(const int& id);
287 * Finds the name of a solid with its ID.
288 * @param id the ID of the solid.
289 * @return the name of the solid.
291 const std::string findSolidName(const int& id);
294 * Changes the name of a vertex.
295 * @param id the ID of the vertex.
296 * @param name the name to set.
298 void changeVertexName(const int& id, const std::string& name) throw (XAO_Exception);
301 * Changes the name of an edge.
302 * @param id the ID of the edge
303 * @param name the name to set.
305 void changeEdgeName(const int& id, const std::string& name) throw (XAO_Exception);
308 * Changes the name of a face.
309 * @param id the ID of the face.
310 * @param name the name to set.
312 void changeFaceName(const int& id, const std::string& name) throw (XAO_Exception);
315 * Changes the name of a solid.
316 * @param id the ID of the solid.
317 * @param name the name to set.
319 void changeSolidName(const int& id, const std::string& name) throw (XAO_Exception);
323 void initListIds(const TopAbs_ShapeEnum& shapeType, GeometricElementList& eltList);
324 TopoDS_Shape getSubShape(const TopoDS_Shape& mainShape, const TopAbs_ShapeEnum& shapeType, const int& shapeIndex)
325 throw (XAO_Exception);
326 const int countGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType);
327 std::vector<int> getGeometricalElements(const TopoDS_Shape& shape, const TopAbs_ShapeEnum& shapeType, const XAO::Dimension& dim);
328 const int findElement(const XAO::Dimension& dim, const int& id)
329 throw (XAO_Exception);
332 TopoDS_Shape m_shape;
336 #endif // __XAO_BREPGEOMETRY_HXX__