2 #include "HYDROData_ShapesTool.h"
4 #include <BRep_Tool.hxx>
8 #include <Precision.hxx>
13 #include <TopoDS_Edge.hxx>
14 #include <TopoDS_Shape.hxx>
15 #include <TopoDS_Vertex.hxx>
16 #include <TopoDS_Wire.hxx>
18 #include <TopTools_SequenceOfShape.hxx>
20 #include <TopExp_Explorer.hxx>
22 void HYDROData_ShapesTool::ExploreShapeToShapes( const TopoDS_Shape& theInShape,
23 const TopAbs_ShapeEnum& theExpType,
24 TopTools_SequenceOfShape& theOutShapes )
28 if ( theInShape.IsNull() )
31 TopExp_Explorer anExp( theInShape, theExpType );
32 for ( ; anExp.More(); anExp.Next() )
34 TopoDS_Shape anExpShape = anExp.Current();
35 theOutShapes.Append( anExpShape );
39 bool HYDROData_ShapesTool::Vertices( const TopoDS_Shape& theInShape,
40 TopoDS_Vertex& theFirstVertex,
41 TopoDS_Vertex& theLastVertex,
42 const bool theIsCumOri )
44 if ( theInShape.IsNull() )
47 if ( theInShape.ShapeType() == TopAbs_EDGE )
49 TopoDS_Edge anEdge = TopoDS::Edge( theInShape );
50 TopExp::Vertices( anEdge, theFirstVertex, theLastVertex, theIsCumOri );
52 else if ( theInShape.ShapeType() == TopAbs_WIRE )
54 TopoDS_Wire aWire = TopoDS::Wire( theInShape );
55 TopExp::Vertices( aWire, theFirstVertex, theLastVertex );
65 bool HYDROData_ShapesTool::IsVerticesEquals( const TopoDS_Vertex& theFirstVert,
66 const TopoDS_Vertex& theSecondVert,
69 gp_Pnt aFirstPoint = BRep_Tool::Pnt( theFirstVert );
70 gp_Pnt aSecondPoint = BRep_Tool::Pnt( theSecondVert );
72 // Set the Z coord to zero for 2D equations
75 aFirstPoint.SetZ( 0.0 );
76 aSecondPoint.SetZ( 0.0 );
79 return aFirstPoint.IsEqual( aSecondPoint, Precision::Confusion() );
82 bool HYDROData_ShapesTool::IsEdgesEquals( const TopoDS_Edge& theFirstEdge,
83 const TopoDS_Edge& theSecondEdge,
86 TopoDS_Vertex aFFirstVert, aFLastVert, aSFirstVert, aSLastVert;
87 TopExp::Vertices( theFirstEdge, aFFirstVert, aFLastVert );
88 TopExp::Vertices( theSecondEdge, aSFirstVert, aSLastVert );
89 return IsVerticesEquals( aFFirstVert, aSFirstVert, theIs2D ) &&
90 IsVerticesEquals( aFLastVert, aSLastVert, theIs2D );