Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
XAO_BrepGeometry.hxx
Go to the documentation of this file.
1 // Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
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, or (at your option) any later version.
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.hxx"
30 #include "XAO_XaoUtils.hxx"
31 #include "XAO_Geometry.hxx"
32 
33 #ifdef WIN32
34 #pragma warning(disable:4290) // Warning Exception ...
35 #endif
36 
37 
38 namespace XAO
39 {
45  {
46  public:
50  BrepGeometry();
51 
56  BrepGeometry(const std::string& name);
57 
58  virtual ~BrepGeometry() {}
59 
64  virtual const XAO::Format getFormat() { return XAO::BREP; }
65 
70  virtual const std::string getShapeString();
71 
76  virtual void setShapeString(const std::string& shape);
77 
82  virtual void writeShapeFile(const std::string& fileName) throw (XAO_Exception);
83 
88  virtual void readShapeFile(const std::string& fileName) throw (XAO_Exception);
89 
90 #ifdef SWIG
91  %pythoncode %{
92  def setShape(self, shape):
93  if shape is not None and 'GetShapeStream' in dir(shape):
94  self.setShapeString(shape.GetShapeStream())
95  else:
96  raise XAO_Exception("Cannot set shape")
97  %}
98 #endif
99 
104  TopoDS_Shape getTopoDS_Shape();
105 
110  void setTopoDS_Shape(const TopoDS_Shape& shape);
111 
118  void getEdgeVertices(const int& edgeIndex, int& vertexA, int& vertexB);
119 
125  const int countFaceWires(const int& faceIndex);
126 
133  std::vector<int> getFaceEdges(const int& faceIndex, const int& wireIndex);
134 
140  const int countSolidShells(const int& solidIndex);
141 
148  std::vector<int> getSolidFaces(const int& solidIndex, const int& shellIndex);
149 
157  void getVertexXYZ(const int& vertexIndex, double& xCoord, double& yCoord, double& zCoord)
158  throw (XAO_Exception);
159 
165  const double getEdgeLength(const int& index);
166 
172  const double getFaceArea(const int& index);
173 
179  const double getSolidVolume(const int& index);
180 
186  const int getVertexID(const int& index);
187 
193  const int getEdgeID(const int& index);
194 
200  const int getFaceID(const int& index);
201 
207  const int getSolidID(const int& index);
208 
214  void setVertexID(const int& index, const int& id);
215 
221  void setEdgeID(const int& index, const int& id);
222 
228  void setFaceID(const int& index, const int& id);
229 
235  void setSolidID(const int& index, const int& id);
236 
242  const int findVertex(const int& id);
243 
249  const int findEdge(const int& id);
250 
256  const int findFace(const int& id);
257 
263  const int findSolid(const int& id);
264 
270  const std::string findVertexName(const int& id);
271 
277  const std::string findEdgeName(const int& id);
278 
284  const std::string findFaceName(const int& id);
285 
291  const std::string findSolidName(const int& id);
292 
298  void changeVertexName(const int& id, const std::string& name) throw (XAO_Exception);
299 
305  void changeEdgeName(const int& id, const std::string& name) throw (XAO_Exception);
306 
312  void changeFaceName(const int& id, const std::string& name) throw (XAO_Exception);
313 
319  void changeSolidName(const int& id, const std::string& name) throw (XAO_Exception);
320 
321  private:
322  void initIds();
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);
330 
331  private:
332  TopoDS_Shape m_shape;
333  };
334 }
335 
336 #endif // __XAO_BREPGEOMETRY_HXX__