0026762: Static parameter "read.scale.unit" is not used
[occt.git] / src / XSAlgo / XSAlgo_AlgoContainer.cxx
old mode 100755 (executable)
new mode 100644 (file)
index ded190c..edd5a75
@@ -1,75 +1,76 @@
 // Created on: 2000-01-19
 // Created by: data exchange team
-// Copyright (c) 2000-2012 OPEN CASCADE SAS
+// Copyright (c) 2000-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 
-
-#include <XSAlgo_AlgoContainer.ixx>
-
-#include <Standard_ErrorHandler.hxx>
-#include <Standard_Failure.hxx>
-
-#include <Message_ListOfMsg.hxx>
-#include <Message_ListIteratorOfListOfMsg.hxx>
-
-#include <gp_Pnt.hxx>
-#include <gp_Pnt2d.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom2d_Curve.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TopExp.hxx>
-#include <BRep_Tool.hxx>
 #include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
 #include <BRepBuilderAPI_MakeEdge.hxx>
-#include <TopTools_DataMapOfShapeShape.hxx>
-#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
-
-#include <ShapeProcess.hxx>
-#include <ShapeProcess_ShapeContext.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+#include <Interface_Static.hxx>
+#include <Message_ListIteratorOfListOfMsg.hxx>
+#include <Message_ListOfMsg.hxx>
+#include <Message_Msg.hxx>
+#include <Message_ProgressIndicator.hxx>
+#include <Resource_Manager.hxx>
 #include <ShapeAlgo.hxx>
 #include <ShapeAlgo_AlgoContainer.hxx>
 #include <ShapeAlgo_ToolContainer.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+#include <ShapeBuild_Edge.hxx>
 #include <ShapeBuild_ReShape.hxx>
+#include <ShapeCustom.hxx>
 #include <ShapeExtend_DataMapOfShapeListOfMsg.hxx>
 #include <ShapeExtend_MsgRegistrator.hxx>
-#include <ShapeFix_Shape.hxx>
-#include <ShapeBuild_Edge.hxx>
-#include <ShapeAnalysis_Edge.hxx>
 #include <ShapeFix_Edge.hxx>
-#include <UnitsMethods.hxx>
-#include <ShapeCustom.hxx>
-
+#include <ShapeFix_Shape.hxx>
+#include <ShapeProcess.hxx>
+#include <ShapeProcess_ShapeContext.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+#include <Standard_Transient.hxx>
+#include <Standard_Type.hxx>
+#include <TopExp.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <Transfer_FinderProcess.hxx>
+#include <Transfer_TransientListBinder.hxx>
+#include <Transfer_TransientProcess.hxx>
 #include <TransferBRep.hxx>
-#include <TransferBRep_ShapeMapper.hxx>
 #include <TransferBRep_ShapeBinder.hxx>
-#include <Transfer_TransientListBinder.hxx>
-#include <Resource_Manager.hxx>
-#include <Interface_Static.hxx>
-#include <Message_Msg.hxx>
+#include <TransferBRep_ShapeMapper.hxx>
+#include <UnitsMethods.hxx>
+#include <XSAlgo_AlgoContainer.hxx>
+#include <XSAlgo_ToolContainer.hxx>
+#include <TopExp_Explorer.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XSAlgo_AlgoContainer,MMgt_TShared)
 
 //=======================================================================
 //function : XSAlgo_AlgoContainer
 //purpose  : 
 //=======================================================================
-
 XSAlgo_AlgoContainer::XSAlgo_AlgoContainer()
 {
   myTC = new XSAlgo_ToolContainer;
@@ -122,7 +123,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape,
   TCollection_AsciiString str ( seq );
   str += ".exec.op";
   if ( ! rsc->Find ( str.ToCString() ) ) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     {
       static Standard_Integer time = 0;
       if ( ! time )
@@ -131,7 +132,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape,
       time++;
     }
 #endif
-    // if FromSTEP or FromIGES, do default ShapeFix
+    // if reading, do default ShapeFix
     if ( ! strncmp ( pseq, "read.", 5 ) ) {
       try {
         OCC_CATCH_SIGNALS
@@ -152,18 +153,15 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape,
        }
       }
       catch (Standard_Failure) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
        cout << "Error: XSAlgo_AlgoContainer::ProcessShape(): Exception in ShapeFix::Shape" << endl;
         Standard_Failure::Caught()->Print(cout); cout << endl;
 #endif
       }  
       return context->Result();
     }
-    // if ToSTEP or ToIGES, define sequence of DirectFaces
-    else if ( ! strcmp ( pseq, "write.step.sequence" ) ) {
-      rsc->SetResource ( str.ToCString(), "DirectFaces" );
-    }
-    else if ( ! strcmp ( pseq, "write.iges.sequence" ) ) {
+    // for writing, define default sequence of DirectFaces
+    else if ( ! strncmp ( pseq, "write.", 6 ) ) {
       rsc->SetResource ( str.ToCString(), "DirectFaces" );
     }
   }
@@ -173,7 +171,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape,
   rsc->SetResource ( "Runtime.MaxTolerance", maxTol );
 
   if ( !ShapeProcess::Perform(context, seq) )
-    return TopoDS_Shape(); // Null shape
+    return shape; // return original shape
 
   return context->Result();
 }
@@ -242,7 +240,7 @@ TopoDS_Shape XSAlgo_AlgoContainer::PerformFixShape(const TopoDS_Shape& S,
     }
   }
   catch (Standard_Failure) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     cout << "Error: XSAlgo_AlgoContainer::PerformFixShape(): Exception in ShapeFix::Shape" << endl;
 #endif
   }   
@@ -304,7 +302,7 @@ Standard_Boolean XSAlgo_AlgoContainer::CheckPCurve (const TopoDS_Edge& E,
   Standard_Real DV = Abs (PUV1.Y() - PUV2.Y());
   if ( DU/8. > (UL/6. - UF/6.) || DV/8. > (VL/6. - VF/6.) ) {
     ShapeBuild_Edge().RemovePCurve(E,face);
-#ifdef DEBUG
+#ifdef OCCT_DEBUG
     cout<<"Removing pcuve periodic"<<endl;
 #endif      
     return Standard_False;
@@ -329,7 +327,7 @@ Standard_Boolean XSAlgo_AlgoContainer::CheckPCurve (const TopoDS_Edge& E,
     
   if (!((Dist11 <= preci) && (Dist22 <= preci))) {
     ShapeBuild_Edge().RemovePCurve(E,face);
-#ifdef DEBUG      
+#ifdef OCCT_DEBUG
     cout<<"Removing pcurve points"<<endl;
 #endif      
     return Standard_False;
@@ -432,19 +430,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() ) {
@@ -502,7 +531,7 @@ void XSAlgo_AlgoContainer::MergeTransferInfo(const Handle(Transfer_FinderProcess
        else if ( TransientListBinder->NbTransients() > 1 ) {
           resBinder->AddResult(TransientListBinder);
 //       resBinder->SetNext(TransientListBinder, Standard_True);
-#ifdef DEB
+#ifdef OCCT_DEBUG
          cout<<"Info: TransientListBinder created for splitted shape"<<endl;
        } 
        else {