Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
GEOMUtils.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 #ifndef _GEOMUtils_HXX_
24 #define _GEOMUtils_HXX_
25 
26 #include <Standard_Macro.hxx>
27 #include <TopoDS_Shape.hxx>
28 #include <TopoDS_Vertex.hxx>
29 
30 #include <TopTools_ListOfShape.hxx>
31 
32 #include <TopAbs.hxx>
33 
34 #include <gp_Ax3.hxx>
35 #include <gp_Vec.hxx>
36 
37 #include <V3d_View.hxx>
38 
39 #include <NCollection_DataMap.hxx>
40 
41 #include <functional>
42 
43 #include <map>
44 #include <vector>
45 #include <string>
46 #include <utility>
47 
48 class Bnd_Box;
49 
50 inline Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2)
51 {
52  return S1.IsSame(S2);
53 }
54 
55 namespace GEOMUtils
56 {
57 
66  };
67 
68  typedef std::vector<std::string> NodeLinks;
69  typedef std::map<std::string, NodeLinks> LevelInfo;
70  typedef std::vector<LevelInfo> LevelsList;
71  typedef std::map<std::string,std::pair<LevelsList,LevelsList> > TreeModel;
72 
92  Standard_EXPORT std::pair<double, double> ShapeToDouble (const TopoDS_Shape& theShape,
93  bool isOldSorting = false);
94 
102  Standard_EXPORT gp_Ax3 GetPosition (const TopoDS_Shape& theShape);
103 
112  Standard_EXPORT gp_Vec GetVector (const TopoDS_Shape& theShape,
113  Standard_Boolean doConsiderOrientation);
114 
119  struct CompareShapes : public std::binary_function<TopoDS_Shape, TopoDS_Shape, bool>
120  {
121  CompareShapes (bool isOldSorting)
122  : myIsOldSorting(isOldSorting) {}
123 
124  bool operator() (const TopoDS_Shape& lhs, const TopoDS_Shape& rhs);
125 
126  typedef NCollection_DataMap<TopoDS_Shape, std::pair<double, double> > GEOMUtils_DataMapOfShapeDouble;
129  };
130 
134  Standard_EXPORT void SortShapes (TopTools_ListOfShape& SL,
135  const Standard_Boolean isOldSorting = Standard_True);
136 
145  Standard_EXPORT TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
146 
155  Standard_EXPORT void AddSimpleShapes (const TopoDS_Shape& theShape,
156  TopTools_ListOfShape& theList);
157 
163  Standard_EXPORT bool CheckTriangulation (const TopoDS_Shape& theShape);
164 
170  Standard_EXPORT TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape);
171 
179  Standard_EXPORT TopoDS_Shape GetEdgeNearPoint (const TopoDS_Shape& theShape,
180  const TopoDS_Vertex& thePoint);
181 
189  Standard_EXPORT Standard_Boolean PreciseBoundingBox(const TopoDS_Shape &theShape, Bnd_Box &theBox);
190 
201  Standard_EXPORT Standard_Real GetMinDistanceSingular(const TopoDS_Shape& aSh1,
202  const TopoDS_Shape& aSh2,
203  gp_Pnt& Ptmp1, gp_Pnt& Ptmp2);
204 
214  Standard_EXPORT Standard_Real GetMinDistance(const TopoDS_Shape& theShape1,
215  const TopoDS_Shape& theShape2,
216  gp_Pnt& thePnt1, gp_Pnt& thePnt2);
217 
226  Standard_EXPORT gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) theView );
227 
234  Standard_EXPORT void ConvertTreeToString( const TreeModel& tree,
235  std::string& dependencyStr );
236 
243  Standard_EXPORT void ConvertStringToTree( const std::string& dependencyStr,
244  TreeModel& tree );
245 
254  Standard_EXPORT bool CheckShape( TopoDS_Shape& shape, bool checkGeometry = false );
255 
263  Standard_EXPORT bool CheckBOPArguments(const TopoDS_Shape &theShape);
264 
280  Standard_EXPORT bool FixShapeTolerance( TopoDS_Shape& shape,
281  TopAbs_ShapeEnum type,
282  Standard_Real tolerance = Precision::Confusion(),
283  bool checkGeometry = false );
284 
289  Standard_EXPORT bool FixShapeTolerance( TopoDS_Shape& shape,
290  Standard_Real tolerance = Precision::Confusion(),
291  bool checkGeometry = false );
292 
297  Standard_EXPORT bool FixShapeTolerance( TopoDS_Shape& shape,
298  bool checkGeometry );
299 
312  Standard_EXPORT bool FixShapeCurves( TopoDS_Shape& shape );
313 
320  Standard_EXPORT bool Write( const TopoDS_Shape& shape,
321  const char* fileName );
322 
333  Standard_EXPORT TopoDS_Shape ReduceCompound( const TopoDS_Shape& shape );
334 
342  Standard_EXPORT void MeshShape( const TopoDS_Shape shape,
343  double deflection, bool forced = true );
344 
349  Standard_EXPORT double DefaultDeflection();
350 
361  Standard_EXPORT bool IsOpenPath(const TopoDS_Shape &theShape);
362 
377  Standard_EXPORT int CompareToleranceValues(const double theTolShape,
378  const double theTolRef);
379 
389  Standard_EXPORT bool IsFitCondition(const ComparisonCondition theCondition,
390  const double theTolShape,
391  const double theTolRef);
392 
393 };
394 
395 #endif