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>
19 #include <TopTools_ListOfShape.hxx>
20 #include <TopTools_ListIteratorOfListOfShape.hxx>
22 #include <TopExp_Explorer.hxx>
24 void HYDROData_ShapesTool::ExploreShapeToShapes( const TopoDS_Shape& theInShape,
25 const TopAbs_ShapeEnum& theExpType,
26 TopTools_SequenceOfShape& theOutShapes )
30 if ( theInShape.IsNull() )
33 TopExp_Explorer anExp( theInShape, theExpType );
34 for ( ; anExp.More(); anExp.Next() )
36 TopoDS_Shape anExpShape = anExp.Current();
37 theOutShapes.Append( anExpShape );
41 bool HYDROData_ShapesTool::Vertices( const TopoDS_Shape& theInShape,
42 TopoDS_Vertex& theFirstVertex,
43 TopoDS_Vertex& theLastVertex,
44 const bool theIsCumOri )
46 if ( theInShape.IsNull() )
49 if ( theInShape.ShapeType() == TopAbs_EDGE )
51 TopoDS_Edge anEdge = TopoDS::Edge( theInShape );
52 TopExp::Vertices( anEdge, theFirstVertex, theLastVertex, theIsCumOri );
54 else if ( theInShape.ShapeType() == TopAbs_WIRE )
56 TopoDS_Wire aWire = TopoDS::Wire( theInShape );
57 TopExp::Vertices( aWire, theFirstVertex, theLastVertex );
67 bool HYDROData_ShapesTool::IsVerticesEquals( const TopoDS_Vertex& theFirstVert,
68 const TopoDS_Vertex& theSecondVert,
71 gp_Pnt aFirstPoint = BRep_Tool::Pnt( theFirstVert );
72 gp_Pnt aSecondPoint = BRep_Tool::Pnt( theSecondVert );
74 // Set the Z coord to zero for 2D equations
77 aFirstPoint.SetZ( 0.0 );
78 aSecondPoint.SetZ( 0.0 );
81 return aFirstPoint.IsEqual( aSecondPoint, Precision::Confusion() );
84 bool HYDROData_ShapesTool::IsEdgesEquals( const TopoDS_Edge& theFirstEdge,
85 const TopoDS_Edge& theSecondEdge,
88 TopoDS_Vertex aFFirstVert, aFLastVert, aSFirstVert, aSLastVert;
89 TopExp::Vertices( theFirstEdge, aFFirstVert, aFLastVert );
90 TopExp::Vertices( theSecondEdge, aSFirstVert, aSLastVert );
91 return IsVerticesEquals( aFFirstVert, aSFirstVert, theIs2D ) &&
92 IsVerticesEquals( aFLastVert, aSLastVert, theIs2D );
95 void HYDROData_ShapesTool::AddShapes( TopTools_SequenceOfShape& theShapes,
96 const TopTools_SequenceOfShape& theShapesToAdd )
98 for ( int i = 1, n = theShapesToAdd.Length(); i <= n; ++i )
100 const TopoDS_Shape& aShape = theShapesToAdd.Value( i );
101 theShapes.Append( aShape );
105 void HYDROData_ShapesTool::AddShapes( TopTools_SequenceOfShape& theShapes,
106 const TopTools_ListOfShape& theShapesToAdd )
108 TopTools_ListIteratorOfListOfShape anIter( theShapesToAdd );
109 for ( ; anIter.More(); anIter.Next() )
111 const TopoDS_Shape& aShape = anIter.Value();
112 theShapes.Append( aShape );
116 void HYDROData_ShapesTool::AddShapes( TopTools_ListOfShape& theShapes,
117 const TopTools_SequenceOfShape& theShapesToAdd )
119 for ( int i = 1, n = theShapesToAdd.Length(); i <= n; ++i )
121 const TopoDS_Shape& aShape = theShapesToAdd.Value( i );
122 theShapes.Append( aShape );
126 void HYDROData_ShapesTool::AddShapes( TopTools_ListOfShape& theShapes,
127 const TopTools_ListOfShape& theShapesToAdd )
129 TopTools_ListIteratorOfListOfShape anIter( theShapesToAdd );
130 for ( ; anIter.More(); anIter.Next() )
132 const TopoDS_Shape& aShape = anIter.Value();
133 theShapes.Append( aShape );