0030895: Coding Rules - specify std namespace explicitly for std::cout and streams
[occt.git] / src / XSAlgo / XSAlgo_AlgoContainer.cxx
index 3ee0d3a..20d1702 100644 (file)
@@ -63,6 +63,9 @@
 #include <UnitsMethods.hxx>
 #include <XSAlgo_AlgoContainer.hxx>
 #include <XSAlgo_ToolContainer.hxx>
+#include <TopExp_Explorer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XSAlgo_AlgoContainer,Standard_Transient)
 
 //=======================================================================
 //function : XSAlgo_AlgoContainer
@@ -94,7 +97,8 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape,
                                                  const Standard_CString prscfile,
                                                  const Standard_CString pseq,
                                                  Handle(Standard_Transient)& info,
-                                                 const Handle(Message_ProgressIndicator)& progress) const
+                                                 const Handle(Message_ProgressIndicator)& progress,
+                                                 const Standard_Boolean NonManifold) const
 {
   if ( shape.IsNull() ) return shape;
   
@@ -109,6 +113,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape,
     if ( !progress.IsNull() )
       context->SetProgress(progress);
   }
+  context->SetNonManifold(NonManifold);
   info = context;
   
   Standard_CString seq = Interface_Static::CVal ( pseq );
@@ -124,8 +129,8 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape,
     {
       static Standard_Integer time = 0;
       if ( ! time )
-       cout << "Warning: XSAlgo_AlgoContainer::ProcessShape(): Sequence " << str.ToCString() << 
-               " is not defined in " << prscfile << " resource; do default processing" << endl;
+       std::cout << "Warning: XSAlgo_AlgoContainer::ProcessShape(): Sequence " << str.ToCString() << 
+               " is not defined in " << prscfile << " resource; do default processing" << std::endl;
       time++;
     }
 #endif
@@ -149,12 +154,13 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape,
          context->SetResult ( S );
        }
       }
-      catch (Standard_Failure) {
+      catch (Standard_Failure const& anException) {
 #ifdef OCCT_DEBUG
-       cout << "Error: XSAlgo_AlgoContainer::ProcessShape(): Exception in ShapeFix::Shape" << endl;
-        Standard_Failure::Caught()->Print(cout); cout << endl;
+       std::cout << "Error: XSAlgo_AlgoContainer::ProcessShape(): Exception in ShapeFix::Shape" << std::endl;
+        anException.Print(std::cout); std::cout << std::endl;
 #endif
-      }  
+       (void)anException;
+      }
       return context->Result();
     }
     // for writing, define default sequence of DirectFaces
@@ -238,7 +244,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::PerformFixShape(const TopoDS_Shape& S,
   }
   catch (Standard_Failure) {
 #ifdef OCCT_DEBUG
-    cout << "Error: XSAlgo_AlgoContainer::PerformFixShape(): Exception in ShapeFix::Shape" << endl;
+    std::cout << "Error: XSAlgo_AlgoContainer::PerformFixShape(): Exception in ShapeFix::Shape" << std::endl;
 #endif
   }   
   return shape;
@@ -300,7 +306,7 @@ Standard_Boolean XSAlgo_AlgoContainer::CheckPCurve (const TopoDS_Edge& E,
   if ( DU/8. > (UL/6. - UF/6.) || DV/8. > (VL/6. - VF/6.) ) {
     ShapeBuild_Edge().RemovePCurve(E,face);
 #ifdef OCCT_DEBUG
-    cout<<"Removing pcuve periodic"<<endl;
+    std::cout<<"Removing pcuve periodic"<<std::endl;
 #endif      
     return Standard_False;
   }
@@ -325,7 +331,7 @@ Standard_Boolean XSAlgo_AlgoContainer::CheckPCurve (const TopoDS_Edge& E,
   if (!((Dist11 <= preci) && (Dist22 <= preci))) {
     ShapeBuild_Edge().RemovePCurve(E,face);
 #ifdef OCCT_DEBUG
-    cout<<"Removing pcurve points"<<endl;
+    std::cout<<"Removing pcurve points"<<std::endl;
 #endif      
     return Standard_False;
   }
@@ -427,19 +433,50 @@ void XSAlgo_AlgoContainer::MergeTransferInfo(const Handle(Transfer_TransientProc
     return;
 
   Standard_Integer i = ( startTPitem >0 ? startTPitem : 1 );
-  for ( ; i <= TP->NbMapped(); i++ ) {
+  for ( ; i <= TP->NbMapped(); i++ )
+  {
     Handle(Transfer_Binder) bnd = TP->MapItem ( i );
     Handle(TransferBRep_ShapeBinder) sb = Handle(TransferBRep_ShapeBinder)::DownCast ( bnd );
     if ( sb.IsNull() || sb->Result().IsNull() ) continue;
-      
+
     TopoDS_Shape orig = sb->Result();
-    if ( map.IsBound ( orig ) ) sb->SetResult ( map.Find ( orig ) );
+
+    if ( map.IsBound ( orig ) )
+    {
+      sb->SetResult ( map.Find ( orig ) );
+    }
     else if ( !orig.Location().IsIdentity() )
     {
       TopLoc_Location aNullLoc;
       TopoDS_Shape atmpSh = orig.Located(aNullLoc);
       if ( map.IsBound ( atmpSh ) ) sb->SetResult ( map.Find ( atmpSh ) );
     }
+    else
+    {
+      // Some of edges may be modified.
+      BRepTools_ReShape aReShape;
+      Standard_Boolean hasModifiedEdges = Standard_False;
+      TopExp_Explorer anExpSE(orig, TopAbs_EDGE);
+
+      // Remember modifications.
+      for( ; anExpSE.More() ; anExpSE.Next() )
+      {
+        if (  map.IsBound ( anExpSE.Current() ) )
+        {
+          hasModifiedEdges = Standard_True;
+          TopoDS_Shape aModifiedShape = map.Find( anExpSE.Current() );
+          aReShape.Replace(anExpSE.Current(), aModifiedShape);
+        }
+      }
+
+      // Apply modifications and store result in binder.
+      if (hasModifiedEdges)
+      {
+        TopoDS_Shape aRes = aReShape.Apply(orig);
+        sb->SetResult ( aRes );
+      }
+    }
+
       
     // update messages
     if ( ! msg.IsNull() ) {
@@ -498,12 +535,12 @@ void XSAlgo_AlgoContainer::MergeTransferInfo(const Handle(Transfer_FinderProcess
           resBinder->AddResult(TransientListBinder);
 //       resBinder->SetNext(TransientListBinder, Standard_True);
 #ifdef OCCT_DEBUG
-         cout<<"Info: TransientListBinder created for splitted shape"<<endl;
+         std::cout<<"Info: TransientListBinder created for splitted shape"<<std::endl;
        } 
        else {
-         cout<<"Warning: XSAlgo_AlgoContainer::MergeTransferInfo() "
-           <<"No results were found for splitted shape. "<<endl;
-         //<<"Transfer_FinderProcess->NbMapped() = "<<FP->NbMapped()<<endl;
+         std::cout<<"Warning: XSAlgo_AlgoContainer::MergeTransferInfo() "
+           <<"No results were found for splitted shape. "<<std::endl;
+         //<<"Transfer_FinderProcess->NbMapped() = "<<FP->NbMapped()<<std::endl;
 #endif   
        }
       }