From: adv Date: Thu, 19 Dec 2013 05:29:52 +0000 (+0000) Subject: Tool methods for shapes are moved to separate class. X-Git-Tag: BR_hydro_v_0_6~36 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9b2bfc45ba9bf3430d7fb6ed9bfe8352a91885a3;p=modules%2Fhydro.git Tool methods for shapes are moved to separate class. --- diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index a3aff835..33fc1993 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -32,6 +32,7 @@ set(PROJECT_HEADERS HYDROData_Region.h HYDROData_River.h HYDROData_ShapesGroup.h + HYDROData_ShapesTool.h HYDROData_SplittedShapesGroup.h HYDROData_SplitToZonesTool.h HYDROData_Stream.h @@ -71,6 +72,7 @@ set(PROJECT_SOURCES HYDROData_Region.cxx HYDROData_River.cxx HYDROData_ShapesGroup.cxx + HYDROData_ShapesTool.cxx HYDROData_SplittedShapesGroup.cxx HYDROData_SplitToZonesTool.cxx HYDROData_Stream.cxx diff --git a/src/HYDROData/HYDROData_ImmersibleZone.cxx b/src/HYDROData/HYDROData_ImmersibleZone.cxx index cd7e4817..ad7a42c3 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.cxx +++ b/src/HYDROData/HYDROData_ImmersibleZone.cxx @@ -5,7 +5,7 @@ #include "HYDROData_Document.h" #include "HYDROData_ShapesGroup.h" #include "HYDROData_PolylineXY.h" -#include "HYDROData_Tool.h" +#include "HYDROData_ShapesTool.h" #include @@ -207,24 +207,24 @@ void HYDROData_ImmersibleZone::createGroupObjects() continue; // Skip the outer wire TopTools_SequenceOfShape anEdges; - HYDROData_Tool::ExploreShapeToShapes( aZoneWire, TopAbs_EDGE, anEdges ); + HYDROData_ShapesTool::ExploreShapeToShapes( aZoneWire, TopAbs_EDGE, anEdges ); anInnerEdges.Append( anEdges ); } // Create outer edges group - QString anOutWiresGroupName = GetName() + "_Outer_Wire"; + QString anOutWiresGroupName = GetName() + "_Outer"; Handle(HYDROData_ShapesGroup) anOutWiresGroup = createGroupObject(); anOutWiresGroup->SetName( anOutWiresGroupName ); TopTools_SequenceOfShape anEdges; - HYDROData_Tool::ExploreShapeToShapes( aZoneOuterWire, TopAbs_EDGE, anEdges ); + HYDROData_ShapesTool::ExploreShapeToShapes( aZoneOuterWire, TopAbs_EDGE, anEdges ); anOutWiresGroup->SetShapes( anEdges ); // Create group for inner edges only if edges is not empty if ( !anInnerEdges.IsEmpty() ) { - QString anInWiresGroupName = GetName() + "_Inner_Wires"; + QString anInWiresGroupName = GetName() + "_Inner"; Handle(HYDROData_ShapesGroup) anInWiresGroup = createGroupObject(); anInWiresGroup->SetName( anInWiresGroupName ); diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index a1807649..345c14a7 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -2,8 +2,8 @@ #include "HYDROData_Obstacle.h" #include "HYDROData_Document.h" -#include "HYDROData_Tool.h" #include "HYDROData_ShapesGroup.h" +#include "HYDROData_ShapesTool.h" #include @@ -355,7 +355,7 @@ void HYDROData_Obstacle::createGroupObjects() if ( !anObstacleShape.IsNull() ) { TopTools_SequenceOfShape aWireEdges; - HYDROData_Tool::ExploreShapeToShapes( anObstacleShape, TopAbs_EDGE, aWireEdges ); + HYDROData_ShapesTool::ExploreShapeToShapes( anObstacleShape, TopAbs_EDGE, aWireEdges ); if ( !aWireEdges.IsEmpty() ) { QString aWireGroupName = GetName() + "_Outer_Wire"; diff --git a/src/HYDROData/HYDROData_ShapesTool.cxx b/src/HYDROData/HYDROData_ShapesTool.cxx new file mode 100644 index 00000000..283d64c0 --- /dev/null +++ b/src/HYDROData/HYDROData_ShapesTool.cxx @@ -0,0 +1,54 @@ + +#include "HYDROData_ShapesTool.h" + +#include + +#include + +#include + +#include + +#include +#include + +#include + +#include + +void HYDROData_ShapesTool::ExploreShapeToShapes( const TopoDS_Shape& theInShape, + const TopAbs_ShapeEnum& theExpType, + TopTools_SequenceOfShape& theOutShapes ) +{ + theOutShapes.Clear(); + + if ( theInShape.IsNull() ) + return; + + TopExp_Explorer anExp( theInShape, theExpType ); + for ( ; anExp.More(); anExp.Next() ) + { + TopoDS_Shape anExpShape = anExp.Current(); + theOutShapes.Append( anExpShape ); + } +} + +bool HYDROData_ShapesTool::IsVerticesEquals( const TopoDS_Vertex& theFirstVert, + const TopoDS_Vertex& theSecondVert ) +{ + gp_Pnt aFirstPoint = BRep_Tool::Pnt( theFirstVert ); + gp_Pnt aSecondPoint = BRep_Tool::Pnt( theSecondVert ); + return aFirstPoint.IsEqual( aSecondPoint, Precision::Confusion() ); +} + +bool HYDROData_ShapesTool::IsEdgesEquals( const TopoDS_Edge& theFirstEdge, + const TopoDS_Edge& theSecondEdge ) +{ + TopoDS_Vertex aFFirstVert, aFLastVert, aSFirstVert, aSLastVert; + TopExp::Vertices( theFirstEdge, aFFirstVert, aFLastVert ); + TopExp::Vertices( theSecondEdge, aSFirstVert, aSLastVert ); + return IsVerticesEquals( aFFirstVert, aSFirstVert ) && + IsVerticesEquals( aFLastVert, aSLastVert ); +} + + diff --git a/src/HYDROData/HYDROData_ShapesTool.h b/src/HYDROData/HYDROData_ShapesTool.h new file mode 100644 index 00000000..e676bf85 --- /dev/null +++ b/src/HYDROData/HYDROData_ShapesTool.h @@ -0,0 +1,50 @@ + +#ifndef HYDROData_ShapesTool_HeaderFile +#define HYDROData_ShapesTool_HeaderFile + +#include "HYDROData.h" + +#include + +class TopoDS_Shape; +class TopoDS_Vertex; +class TopoDS_Edge; +class TopTools_SequenceOfShape; + +class HYDRODATA_EXPORT HYDROData_ShapesTool { + +public: + + /** + * \brief Explore the incoming shape to shapes with given type. + * \param theInShape object to explore + * \param theExpType type to explore + * \param theOutShapes[out] list of result shapes if any + */ + static void ExploreShapeToShapes( const TopoDS_Shape& theInShape, + const TopAbs_ShapeEnum& theExpType, + TopTools_SequenceOfShape& theOutShapes ); + + /** + * \brief Compare two vertices on coordinates equation. + * \param theFirstVert first vertex + * \param theSecondVert second vertex + * \return \c true if cooredinates of vertices is equals + */ + static bool IsVerticesEquals( const TopoDS_Vertex& theFirstVert, + const TopoDS_Vertex& theSecondVert ); + + /** + * \brief Compare two edges on points coordinates equation. + * \param theFirstVert first edge + * \param theSecondVert second edge + * \return \c true if coordinates of all points of given edges is equals + */ + static bool IsEdgesEquals( const TopoDS_Edge& theFirstEdge, + const TopoDS_Edge& theSecondEdge ); +}; + + +#endif + + diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index d05696b7..e507b9f7 100644 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -163,20 +163,3 @@ bool HYDROData_Tool::IsGeometryObject( const Handle(HYDROData_Entity)& theObject theObject->IsKind( STANDARD_TYPE(HYDROData_NaturalObject) ); } -void HYDROData_Tool::ExploreShapeToShapes( const TopoDS_Shape& theInShape, - const TopAbs_ShapeEnum& theExpType, - TopTools_SequenceOfShape& theOutShapes ) -{ - theOutShapes.Clear(); - - if ( theInShape.IsNull() ) - return; - - TopExp_Explorer anExp( theInShape, theExpType ); - for ( ; anExp.More(); anExp.Next() ) - { - TopoDS_Shape anExpShape = anExp.Current(); - theOutShapes.Append( anExpShape ); - } -} - diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index 6aaf6eeb..cf48d52c 100644 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -73,16 +73,6 @@ public: */ static bool IsGeometryObject( const Handle(HYDROData_Entity)& theObject ); - /** - * \brief Explore the incoming shape to shapes with given type. - * \param theInShape object to explore - * \param theExpType type to explore - * \param theOutShapes[out] list of result shapes if any - */ - static void ExploreShapeToShapes( const TopoDS_Shape& theInShape, - const TopAbs_ShapeEnum& theExpType, - TopTools_SequenceOfShape& theOutShapes ); - }; inline bool ValuesEquals( const double& theFirst, const double& theSecond )