Salome HOME
Create goups for stream.
[modules/hydro.git] / src / HYDROData / HYDROData_ShapesTool.cxx
1
2 #include "HYDROData_ShapesTool.h"
3
4 #include <BRep_Tool.hxx>
5
6 #include <gp_Pnt.hxx>
7
8 #include <Precision.hxx>
9
10 #include <TopExp.hxx>
11
12 #include <TopoDS_Shape.hxx>
13 #include <TopoDS_Vertex.hxx>
14
15 #include <TopTools_SequenceOfShape.hxx>
16
17 #include <TopExp_Explorer.hxx>
18
19 void HYDROData_ShapesTool::ExploreShapeToShapes( const TopoDS_Shape&       theInShape,
20                                                  const TopAbs_ShapeEnum&   theExpType,
21                                                  TopTools_SequenceOfShape& theOutShapes )
22 {
23   theOutShapes.Clear();
24
25   if ( theInShape.IsNull() )
26     return;
27
28   TopExp_Explorer anExp( theInShape, theExpType );
29   for ( ; anExp.More(); anExp.Next() )
30   {
31     TopoDS_Shape anExpShape = anExp.Current();
32     theOutShapes.Append( anExpShape );
33   }
34 }
35
36 bool HYDROData_ShapesTool::IsVerticesEquals( const TopoDS_Vertex& theFirstVert,
37                                              const TopoDS_Vertex& theSecondVert )
38 {
39   gp_Pnt aFirstPoint = BRep_Tool::Pnt( theFirstVert );
40   gp_Pnt aSecondPoint = BRep_Tool::Pnt( theSecondVert );
41   return aFirstPoint.IsEqual( aSecondPoint, Precision::Confusion() );
42 }
43
44 bool HYDROData_ShapesTool::IsEdgesEquals( const TopoDS_Edge& theFirstEdge,
45                                           const TopoDS_Edge& theSecondEdge )
46 {
47   TopoDS_Vertex aFFirstVert, aFLastVert, aSFirstVert, aSLastVert;
48   TopExp::Vertices( theFirstEdge, aFFirstVert, aFLastVert );
49   TopExp::Vertices( theSecondEdge, aSFirstVert, aSLastVert );
50   return IsVerticesEquals( aFFirstVert, aSFirstVert ) &&
51          IsVerticesEquals( aFLastVert, aSLastVert );
52 }
53
54