]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Tool methods for shapes are moved to separate class.
authoradv <adv@opencascade.com>
Thu, 19 Dec 2013 05:29:52 +0000 (05:29 +0000)
committeradv <adv@opencascade.com>
Thu, 19 Dec 2013 05:29:52 +0000 (05:29 +0000)
src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData_ImmersibleZone.cxx
src/HYDROData/HYDROData_Obstacle.cxx
src/HYDROData/HYDROData_ShapesTool.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_ShapesTool.h [new file with mode: 0644]
src/HYDROData/HYDROData_Tool.cxx
src/HYDROData/HYDROData_Tool.h

index a3aff83555e9eccb10271ec5195757493b5211e9..33fc199387ec2bdc7269792c73b602d7e3b79afd 100644 (file)
@@ -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
index cd7e48178cb4e581f8c9e72081e8632ac459b824..ad7a42c37332be19cd99f66555ae18b88f4b4a19 100644 (file)
@@ -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 <BRepBuilderAPI_MakeFace.hxx>
 
@@ -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 );
index a1807649fd95f864d1fe72addab69ab62439b0c5..345c14a7fa9010e33af31ff3a37013ca3e40248f 100644 (file)
@@ -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 <Basics_Utils.hxx>
 
@@ -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 (file)
index 0000000..283d64c
--- /dev/null
@@ -0,0 +1,54 @@
+
+#include "HYDROData_ShapesTool.h"
+
+#include <BRep_Tool.hxx>
+
+#include <gp_Pnt.hxx>
+
+#include <Precision.hxx>
+
+#include <TopExp.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+#include <TopTools_SequenceOfShape.hxx>
+
+#include <TopExp_Explorer.hxx>
+
+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 (file)
index 0000000..e676bf8
--- /dev/null
@@ -0,0 +1,50 @@
+
+#ifndef HYDROData_ShapesTool_HeaderFile
+#define HYDROData_ShapesTool_HeaderFile
+
+#include "HYDROData.h"
+
+#include <TopAbs_ShapeEnum.hxx>
+
+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
+
+
index d05696b77801cfdc49df41a44322ab9fd036ccaa..e507b9f778d4869dcc5e5620458a8082143a4048 100644 (file)
@@ -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 );
-  }
-}
-
index 6aaf6eeb6931da53ed0781dd277894b0c706346a..cf48d52c107b21de103a075864394d1a68db2021 100644 (file)
@@ -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 )