]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #585: merge
authorasl <asl@opencascade.com>
Fri, 26 Jun 2015 13:00:34 +0000 (16:00 +0300)
committerasl <asl@opencascade.com>
Fri, 26 Jun 2015 13:00:34 +0000 (16:00 +0300)
src/HYDROData/HYDROData_PolylineOperator.cxx
src/HYDROData/HYDROData_PolylineOperator.h

index 43eda5fffb3deba980892dca8e7510ca41d04cb5..757805c153a54f82611f58dbcb8cdc296f1fbeac 100644 (file)
@@ -51,7 +51,7 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD
   for( int i=0, n=aCurves.size(); i<n; i++ )
   {
     std::vector<TopoDS_Shape> aCurvesList = Split( aCurves[i], thePoint, theTolerance );
-    bool isLocalOK = CreatePolylines( theDoc, thePolyline->GetName(), aCurvesList );
+    bool isLocalOK = CreatePolylines( theDoc, thePolyline->GetName(), aCurvesList, true );
     isOK = isOK && isLocalOK;
   }
   return isOK;
@@ -74,8 +74,8 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD
   int f = thePolylines.Lower(), l = thePolylines.Upper();
   for( int i=f; i<=l; i++ )
   {
-    Handle( HYDROData_PolylineXY ) aPolylineI = Handle( HYDROData_PolylineXY )::DownCast( thePolylines.Value( i ) );
-    if( !split( theDoc, aPolylineI, thePolylines, theTolerance, i ) )
+    Handle( HYDROData_PolylineXY ) aPolyline = Handle( HYDROData_PolylineXY )::DownCast( thePolylines.Value( i ) );
+    if( !split( theDoc, aPolyline, thePolylines, theTolerance, i ) )
       return false;
   }
   return true;
@@ -89,15 +89,30 @@ bool HYDROData_PolylineOperator::Merge( const Handle( HYDROData_Document )& theD
 {
   TopoDS_Shape aMergedPolyline;
 
-  //TODO
+  int f = thePolylines.Lower(), l = thePolylines.Upper();
+  for( int i=f; i<=l; i++ )
+  {
+    Handle( HYDROData_PolylineXY ) aPolyline = Handle( HYDROData_PolylineXY )::DownCast( thePolylines.Value( i ) );
+    std::vector<TopoDS_Wire> aCurves = GetWires( aPolyline );
+    for( int j=0, m=aCurves.size(); j<m; j++ )
+      if( !Merge( aMergedPolyline, aCurves[j], isConnectByNewSegment, theTolerance ) )
+        return false;
+  }
 
   std::vector<TopoDS_Shape> aShapes( 1 );
   aShapes[0] = aMergedPolyline;
-  CreatePolylines( theDoc, theName, aShapes );
+  CreatePolylines( theDoc, theName, aShapes, false );
 
   return true;
 }
 
+bool HYDROData_PolylineOperator::Merge( TopoDS_Shape& theShape, const TopoDS_Wire& theWire, 
+                                        bool isConnectByNewSegment, double theTolerance )
+{
+  //TODO
+  return true;
+}
+
 bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theDoc,
                                         const Handle( HYDROData_PolylineXY )& thePolyline,
                                         const HYDROData_SequenceOfObjects& theTools,
@@ -132,7 +147,7 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD
     aResults = aNewResults;
   }
 
-  CreatePolylines( theDoc, thePolyline->GetName(), aResults );
+  CreatePolylines( theDoc, thePolyline->GetName(), aResults, true );
 
   return isOK;
 }
@@ -186,7 +201,8 @@ std::vector<TopoDS_Shape> HYDROData_PolylineOperator::Split( const std::vector<T
 
 bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Document )& theDoc,
                                                   const QString& theNamePrefix,
-                                                  const std::vector<TopoDS_Shape>& theShapes )
+                                                  const std::vector<TopoDS_Shape>& theShapes,
+                                                  bool isUseIndices )
 {
   if( theDoc.IsNull() )
     return false;
index 0613c23923a5e47b623fab7914c4a6e752d0fed2..3f92f0befff43394b0cdf9c4223241bcbdac71f7 100644 (file)
@@ -64,9 +64,13 @@ protected:
   static std::vector<TopoDS_Shape> Split( const std::vector<TopoDS_Wire>& theWires,
                                           double theTolerance );
 
+  static bool Merge( TopoDS_Shape& theShape, const TopoDS_Wire& theWire, 
+                     bool isConnectByNewSegment, double theTolerance );
+
   static bool CreatePolylines( const Handle( HYDROData_Document )& theDoc,
                                const QString& theNamePrefix,
-                               const std::vector<TopoDS_Shape>& theShape );
+                               const std::vector<TopoDS_Shape>& theShape,
+                               bool isUseIndices );
 };
 
 #endif