0028643: Coding rules - eliminate GCC compiler warnings -Wmisleading-indentation
[occt.git] / src / ShapeUpgrade / ShapeUpgrade_WireDivide.cxx
old mode 100755 (executable)
new mode 100644 (file)
index bf55c99..9987a8f
@@ -1,66 +1,74 @@
 // Created on: 1999-04-15
 // Created by: Roman LYGIN
 // Copyright (c) 1999-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-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.
 
 //    gka 23.06.99 S4208: using tool SU_TransferParameter 
 //    pdn 13.07.99 synchronizing splitting values on 3d curve and pcurve
 //    abv 14.07.99 dealing with edges without 3d curve
 //    svv 10.01.00 porting on DEC
 
-#include <ShapeUpgrade_WireDivide.ixx>
-#include <ShapeUpgrade.hxx>
-#include <BRep_Tool.hxx>
+#include <Adaptor3d_CurveOnSurface.hxx>
 #include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
 #include <BRepLib_MakeFace.hxx>
 #include <BRepLib_MakeWire.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <ShapeBuild_Edge.hxx>
-#include <ShapeAnalysis_Edge.hxx>
-#include <Precision.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TColStd_HSequenceOfReal.hxx>
-#include <TColGeom_HArray1OfCurve.hxx>
-#include <TColGeom2d_HArray1OfCurve.hxx>
-#include <gp_Pnt.hxx>
-#include <Geom_Curve.hxx>
+#include <Geom2d_BoundedCurve.hxx>
 #include <Geom2d_Curve.hxx>
-#include <ShapeExtend.hxx>
-#include <TColStd_Array1OfBoolean.hxx>
-#include <ShapeBuild_ReShape.hxx>
+#include <Geom2dAdaptor_HCurve.hxx>
+#include <Geom_BoundedCurve.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <GeomAdaptor_HSurface.hxx>
+#include <gp_Pnt.hxx>
+#include <Precision.hxx>
+#include <ShapeAnalysis_Curve.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+#include <ShapeAnalysis_TransferParameters.hxx>
 #include <ShapeAnalysis_TransferParametersProj.hxx>
+#include <ShapeBuild_Edge.hxx>
+#include <ShapeBuild_ReShape.hxx>
+#include <ShapeExtend.hxx>
+#include <ShapeUpgrade.hxx>
+#include <ShapeUpgrade_EdgeDivide.hxx>
 #include <ShapeUpgrade_FixSmallCurves.hxx>
-#include <TopTools_SequenceOfShape.hxx>
+#include <ShapeUpgrade_SplitCurve2d.hxx>
+#include <ShapeUpgrade_SplitCurve3d.hxx>
+#include <ShapeUpgrade_WireDivide.hxx>
+#include <Standard_Type.hxx>
+#include <TColGeom2d_HArray1OfCurve.hxx>
+#include <TColGeom_HArray1OfCurve.hxx>
+#include <TColStd_Array1OfBoolean.hxx>
+#include <TColStd_HSequenceOfReal.hxx>
 #include <TColStd_SequenceOfReal.hxx>
-#include <GeomAdaptor_HSurface.hxx>
-#include <Geom2dAdaptor_HCurve.hxx>
-#include <ShapeAnalysis_Curve.hxx>
-#include <Adaptor3d_CurveOnSurface.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(ShapeUpgrade_WireDivide,ShapeUpgrade_Tool)
 
 //=======================================================================
 //function : ShapeUpgrade_WireDivide
 //purpose  : 
 //=======================================================================
-
 ShapeUpgrade_WireDivide::ShapeUpgrade_WireDivide():
        ShapeUpgrade_Tool(), myStatus(0)
 {
@@ -371,7 +379,7 @@ void ShapeUpgrade_WireDivide::Perform ()
          Handle(TColStd_HSequenceOfReal) revKnots2d = theSplit2dTool->SplitValues();
          if(revKnots2d->Length()!=theKnots2d->Length()) {
            isSeam = Standard_False;
-#ifdef DEB
+#ifdef OCCT_DEBUG
            cout << "Error: ShapeUpgrade_WireDivide: seam has different splitting values on pcurvesd" << endl;
 #endif
          }
@@ -408,7 +416,7 @@ void ShapeUpgrade_WireDivide::Perform ()
 
       //collect NM vertices
      
-      Standard_Real af,al;
+      Standard_Real af = 0.,al = 0.;
       Handle(Geom_Curve) c3d;
       Adaptor3d_CurveOnSurface AdCS;
       if(myEdgeDivide->HasCurve3d()) 
@@ -416,8 +424,8 @@ void ShapeUpgrade_WireDivide::Perform ()
       else if(myEdgeDivide->HasCurve2d() && !Surf.IsNull()) {
        Handle(Geom2d_Curve) c2d;
        sae.PCurve ( E, myFace, c2d, af, al, Standard_False); 
-       Handle(GeomAdaptor_HSurface) AdS = new GeomAdaptor_HSurface(Surf);
-       Handle(Geom2dAdaptor_HCurve) AC2d  = new Geom2dAdaptor_HCurve(c2d,af,al);
+       Handle(Adaptor3d_HSurface) AdS = new GeomAdaptor_HSurface(Surf);
+       Handle(Adaptor2d_HCurve2d) AC2d  = new Geom2dAdaptor_HCurve(c2d,af,al);
        AdCS.Load(AC2d);
        AdCS.Load(AdS);
       }
@@ -451,7 +459,7 @@ void ShapeUpgrade_WireDivide::Perform ()
        if ( !theSegments2d.IsNull() ) {
          Standard_Integer nbc2d = theSegments2d->Length();
          if (nbc!=nbc2d) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
            cout<<"Error: Number of intervals are not equal for 2d 3d. Ignored."<<endl;
 #endif
            nbc = Min( nbc,nbc2d);
@@ -476,7 +484,6 @@ void ShapeUpgrade_WireDivide::Perform ()
       Standard_Integer numE =0;
       gp_Pnt pntV1 = BRep_Tool::Pnt(V1);
       //gp_Pnt pntV2 = BRep_Tool::Pnt(V2); // pntV2 not used - see below (skl)
-      Standard_Real V1Tol = LimitTolerance( BRep_Tool::Tolerance(V1) );
       //Standard_Real V2Tol = LimitTolerance( BRep_Tool::Tolerance(V2) ); // V2Tol not used - see below (skl)
       
       Handle(ShapeUpgrade_FixSmallCurves) FixSmallCurveTool = GetFixSmallCurveTool(); //gka Precision
@@ -586,7 +593,6 @@ void ShapeUpgrade_WireDivide::Perform ()
          if(icurv != nbc)  {
            B.MakeVertex (V, P, TolEdge); //tolerance of the edge
            pntV1 = P;
-           V1Tol = LimitTolerance( TolEdge );
          }
          else V = V2;
         // else  V2;
@@ -679,38 +685,50 @@ void ShapeUpgrade_WireDivide::Perform ()
        else if ( ! myFace.IsNull() ) {
          B.UpdateEdge ( newEdge, theNewPCurve1, myFace, 0. );
        }
-         
+
         if(!theNewCurve3d.IsNull())
          sbe.SetRange3d(newEdge,f3d,l3d);
        if(!theNewPCurve1.IsNull())
+       {
          B.Range ( newEdge, myFace, f2d, l2d);
+       }
        if((!wasSR || !srNew)&&!BRep_Tool::Degenerated(newEdge) )
+       {
          B.SameRange(newEdge, Standard_False);
+       }
 
-         //addition NM vertices to new edges
-         Standard_Real afpar = (myEdgeDivide->HasCurve3d() ? f3d : f2d);
-                               
-         Standard_Real alpar = (myEdgeDivide->HasCurve3d() ? l3d: l2d);
-         Standard_Integer n =1;
-         for( ; n <= aSeqParNM.Length(); n++) {
-           Standard_Real apar = aSeqParNM.Value(n);
-           TopoDS_Vertex aVold = TopoDS::Vertex(aSeqNMVertices.Value(n));
-           TopoDS_Vertex aNMVer =ShapeAnalysis_TransferParametersProj::CopyNMVertex(aVold,newEdge,E);
-           Context()->Replace(aVold,aNMVer);
-           if(fabs(apar - afpar) <= Precision::PConfusion()) 
-             Context()->Replace(aNMVer,V1);
-           else if(fabs(apar - alpar) <= Precision::PConfusion()) 
-             Context()->Replace(aNMVer,V);
-           else if( apar > afpar && apar <alpar) 
-             B.Add (newEdge,aNMVer);
-           else continue;  
-           aSeqNMVertices.Remove(n);
-           aSeqParNM.Remove(n);
-           n--;
-         }
-         
-         
-//     if (ShapeUpgrade::Debug()) cout <<"... New Edge " 
+        //addition NM vertices to new edges
+        Standard_Real afpar = (myEdgeDivide->HasCurve3d () ? f3d : f2d);
+        Standard_Real alpar = (myEdgeDivide->HasCurve3d () ? l3d : l2d);
+        for (Standard_Integer n = 1; n <= aSeqParNM.Length (); ++n)
+        {
+          Standard_Real apar = aSeqParNM.Value (n);
+          TopoDS_Vertex aVold = TopoDS::Vertex (aSeqNMVertices.Value (n));
+          TopoDS_Vertex aNMVer = ShapeAnalysis_TransferParametersProj::CopyNMVertex (aVold, newEdge, E);
+          Context ()->Replace (aVold, aNMVer);
+          if (fabs (apar - afpar) <= Precision::PConfusion ())
+          {
+            Context ()->Replace (aNMVer, V1);
+          }
+          else if (fabs (apar - alpar) <= Precision::PConfusion ())
+          {
+            Context ()->Replace (aNMVer, V);
+          }
+          else if (apar > afpar && apar < alpar)
+          {
+            B.Add (newEdge, aNMVer);
+          }
+          else
+          {
+            continue;
+          }
+
+          aSeqNMVertices.Remove (n);
+          aSeqParNM.Remove (n);
+          n--;
+        }
+
+//     if (ShapeUpgrade::Debug()) cout <<"... New Edge "
 //       <<(void*) &(*newEdge.TShape())<<" on vertices "
 //         <<(void*) &(*V1.TShape())<<", " <<(void*) &(*V.TShape())
 //           <<" with Tolerance "<<TolEdge <<endl;
@@ -720,13 +738,17 @@ void ShapeUpgrade_WireDivide::Perform ()
        V1 = V;
       }
       if(numE)
+      {
+        resWire.Closed (BRep_Tool::IsClosed (resWire));
        Context()->Replace(E,resWire);
+      }
       else
        Context()->Remove(E);
     }
   }
   if ( Status ( ShapeExtend_DONE ) ) {
 //smh#8
+    newWire.Closed (BRep_Tool::IsClosed (newWire));
     TopoDS_Shape tmpW = Context()->Apply ( newWire ).Oriented(myWire.Orientation());
     myWire = TopoDS::Wire (tmpW );
   }