0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepBlend / BRepBlend_RstRstLineBuilder.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 167837f..32af8c8
@@ -1,37 +1,43 @@
 // Created on: 1997-01-24
 // Created by: Laurent BOURESCHE
 // Copyright (c) 1997-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.
-
-
-#include <stdio.h>
-
-#include <BRepBlend_RstRstLineBuilder.ixx>
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <Adaptor2d_HCurve2d.hxx>
+#include <Adaptor3d_HSurface.hxx>
+#include <Adaptor3d_HVertex.hxx>
+#include <Adaptor3d_TopolTool.hxx>
+#include <Blend_CurvPointFuncInv.hxx>
+#include <Blend_Point.hxx>
+#include <Blend_RstRstFunction.hxx>
+#include <Blend_SurfCurvFuncInv.hxx>
 #include <BRepBlend_BlendTool.hxx>
-#include <TopAbs.hxx>
-#include <IntSurf.hxx>
-#include <math_FunctionSetRoot.hxx>
-#include <gp_Pnt2d.hxx>
+#include <BRepBlend_Extremity.hxx>
+#include <BRepBlend_Line.hxx>
+#include <BRepBlend_RstRstLineBuilder.hxx>
 #include <gp_Pnt.hxx>
-#include <gp_Vec2d.hxx>
+#include <gp_Pnt2d.hxx>
 #include <gp_Vec.hxx>
+#include <gp_Vec2d.hxx>
+#include <IntSurf.hxx>
+#include <IntSurf_Transition.hxx>
+#include <math_FunctionSetRoot.hxx>
+#include <TopAbs.hxx>
 
-#ifdef DEB
+#include <stdio.h>
+#ifdef OCCT_DEBUG
 #include <TColStd_Array1OfInteger.hxx>
 #include <TColStd_Array1OfReal.hxx>
 #include <TColgp_Array1OfPnt2d.hxx>
@@ -45,6 +51,7 @@
 static Standard_Integer IndexOfSection = 0;
 extern Standard_Boolean Blend_GettraceDRAWSECT(); 
 
+#ifdef OCCT_DEBUG_BBPP_N_TRDERIV
 //-----------------------------------------------------
 // For debug : visualisation of the section
 static Standard_Boolean BBPP(const Standard_Real param,
@@ -118,7 +125,7 @@ static void tracederiv(Blend_RstRstFunction& Func,
     cout<<"dy estimated  : "<<scal*(TP2d1(i).Y()-TP2d2(i).Y())<<endl;
   }
 }
-
+#endif
 
 //-----------------------------------------------------
 static void Drawsect(const Standard_Real param,
@@ -239,7 +246,7 @@ void BRepBlend_RstRstLineBuilder::Perform(Blend_RstRstFunction&   Func,
   if (State != Blend_OK) {
     return;
   }
-#ifdef DEB
+#ifdef OCCT_DEBUG
   if (Blend_GettraceDRAWSECT()){
     Drawsect(param, Func);
   }
@@ -309,13 +316,8 @@ Standard_Boolean BRepBlend_RstRstLineBuilder::PerformFirstSection
   
   Standard_Boolean recadp1, recadp2, recadrst1, recadrst2;
   Standard_Real wp1, wp2, wrst1, wrst2;
-#ifndef DEB
   Blend_Status State = Blend_OnRst12;
   Standard_Real trst11 = 0., trst12 = 0., trst21 = 0., trst22 = 0.;
-#else
-  Blend_Status State;
-  Standard_Real trst11, trst12, trst21, trst22;
-#endif
   math_Vector infbound(1, 2), supbound(1, 2), tolerance(1, 2);
   math_Vector solinvp1(1, 2), solinvp2(1, 2), solinvrst1(1, 3), solinvrst2(1, 3);
   Handle(Adaptor3d_HVertex) Vtxp1, Vtxp2, Vtxrst1, Vtxrst2, Vtxc;
@@ -555,15 +557,10 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
   if (sens* (parprec - Bound) >= -tolgui) {
     return;
   }
-#ifndef DEB
   Blend_Status State = Blend_OnRst12;
   Standard_Real trst11 = 0., trst12 = 0., trst21 = 0., trst22 = 0.;
-#else
-  Blend_Status State;
-  Standard_Real trst11, trst12, trst21, trst22;
-#endif
-  TopAbs_State situonc1, situonc2;
-  Blend_DecrochStatus decroch;
+  TopAbs_State situonc1 = TopAbs_UNKNOWN, situonc2 = TopAbs_UNKNOWN;
+  Blend_DecrochStatus decroch = Blend_NoDecroch;
   Standard_Boolean Arrive, recadp1, recadp2, recadrst1, recadrst2, echecrecad;
   Standard_Real wp1, wp2, wrst1, wrst2;
   math_Vector infbound(1, 2), supbound(1, 2);
@@ -590,7 +587,7 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
 
   while (!Arrive) {
     Standard_Boolean bonpoint = 1;
-#if 0
+#ifdef OCCT_DEBUG_BBPP_N_TRDERIV
     //debdebdebdebdebdeb
     Func.Set(param);
     rsnld.Perform(Func, parinit, infbound, supbound);
@@ -827,7 +824,9 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
       }
       else{
        // reframing failed. Leave with PointsConfondus
+#ifdef OCCT_DEBUG
        cout<<"reframing failed"<<endl;
+#endif
        State = Blend_SamePoints;
       }
     }
@@ -835,7 +834,7 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
     switch (State) {
     case Blend_OK :
       {
-#ifdef DEB
+#ifdef OCCT_DEBUG
        if (Blend_GettraceDRAWSECT()){
          Drawsect(param, Func);
        }
@@ -878,10 +877,12 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
                           previousP.ParameterOnC2(),
                           previousP.Parameter(), tolesp);
          Arrive = Standard_True;
+#ifdef OCCT_DEBUG
          if (line->NbPoints()>=2) {
            // Show that there is a stop during processing 
            cout<<"No more advancement in the processing"<<endl;
          }
+#endif
        }
        else {
          param = parprec + sens * stepw;  // there is no risk to exceed Bound.
@@ -891,7 +892,7 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
       
     case Blend_StepTooSmall :
       {
-#ifdef DEB
+#ifdef OCCT_DEBUG
        if (Blend_GettraceDRAWSECT()){
          Drawsect(param,Func);
        }
@@ -926,7 +927,7 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
       
     case Blend_OnRst1  :
       {
-#ifdef DEB
+#ifdef OCCT_DEBUG
        if (Blend_GettraceDRAWSECT()){
          Drawsect(param, Func);
        }
@@ -945,7 +946,7 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
       
     case Blend_OnRst2  :
       {
-#ifdef DEB
+#ifdef OCCT_DEBUG
        if (Blend_GettraceDRAWSECT()){
          Drawsect(param, Func);
        }
@@ -965,7 +966,7 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
       
     case Blend_OnRst12  :
       {
-#ifdef DEB
+#ifdef OCCT_DEBUG
        if (Blend_GettraceDRAWSECT()){
          Drawsect(param, Func);
        }
@@ -986,7 +987,9 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
     case Blend_SamePoints :
       {
        // Stop
+#ifdef OCCT_DEBUG
        cout << " Mixed points in the processing" << endl;
+#endif
        Extrst1.SetValue(previousP.PointOnC1(),
                         previousP.ParameterOnC1(),
                         previousP.Parameter(), tolesp);
@@ -996,10 +999,8 @@ void BRepBlend_RstRstLineBuilder::InternalPerform(Blend_RstRstFunction&   Func,
        Arrive = Standard_True;
       }
       break;
-#ifndef DEB
     default:
       break;
-#endif
     }
     if (Arrive) {
       if (sens > 0.) {
@@ -1037,7 +1038,9 @@ Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre1(Blend_RstRstFunction&
   math_FunctionSetRoot rsnld(Finv, toler, 30);
   rsnld.Perform(Finv, Solinv, infb, supb);
   if (!rsnld.IsDone()) {
+#ifdef OCCT_DEBUG
     cout << "RSNLD not done "<< endl << endl;
+#endif
     return Standard_False;
   }
 
@@ -1117,7 +1120,9 @@ Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre2(Blend_RstRstFunction&
   math_FunctionSetRoot rsnld(Finv, toler, 30);
   rsnld.Perform(Finv, Solinv, infb, supb);
   if (!rsnld.IsDone()) {
+#ifdef OCCT_DEBUG
     cout << "RSNLD not done "<< endl << endl;
+#endif
     return Standard_False;
   }
 
@@ -1201,7 +1206,9 @@ Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre1(Blend_CurvPointFuncInv&
   math_FunctionSetRoot rsnld(FinvP, toler, 30);
   rsnld.Perform(FinvP, Solinv, infb, supb);
   if (!rsnld.IsDone()) {
+#ifdef OCCT_DEBUG
     cout << "RSNLD not done "<< endl << endl;
+#endif
     return Standard_False;
   }
   rsnld.Root(Solinv);
@@ -1267,7 +1274,9 @@ Standard_Boolean BRepBlend_RstRstLineBuilder::Recadre2(Blend_CurvPointFuncInv&
   math_FunctionSetRoot rsnld(FinvP, toler, 30);
   rsnld.Perform(FinvP, Solinv, infb, supb);
   if (!rsnld.IsDone()) {
+#ifdef OCCT_DEBUG
     cout << "RSNLD not done "<< endl << endl;
+#endif
     return Standard_False;
   }
   rsnld.Root(Solinv);
@@ -1390,11 +1399,7 @@ void BRepBlend_RstRstLineBuilder::MakeExtremity(BRepBlend_Extremity&
   else {
     Extrem.SetVertex(Vtx);
     while (Iter->More()) {
-//#ifndef DEB
       Handle(Adaptor2d_HCurve2d) arc = Iter->Value();
-//#else
-//      Handle(Adaptor2d_HCurve2d)& arc = Iter->Value();
-//#endif
      if (arc != Arc) {
        Iter->Initialize(arc);
        Iter->InitVertexIterator();
@@ -1441,15 +1446,10 @@ Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst1(const Blend_Poin
   if(!prevpointistangent){
     prevTg = previousP.TangentOnC1();
   }
-  Standard_Real Norme, curNorme;
-#ifndef DEB
+  Standard_Real Norme;
   Standard_Real prevNorme = 0.;
-#else
-  Standard_Real prevNorme;
-#endif
   gp_Vec Corde(prevP, Psurf);
   Norme = Corde.SquareMagnitude();
-  if (!curpointistangent) curNorme = Tgsurf.SquareMagnitude();
   if (!prevpointistangent) prevNorme = prevTg.SquareMagnitude();
 
   if (Norme <= tolesp * tolesp) {
@@ -1523,15 +1523,10 @@ Blend_Status BRepBlend_RstRstLineBuilder::CheckDeflectionOnRst2(const Blend_Poin
   if (!prevpointistangent) {
     prevTg = previousP.TangentOnC2();
   }
-  Standard_Real Norme, curNorme;
-#ifndef DEB
+  Standard_Real Norme;
   Standard_Real prevNorme = 0.;
-#else
-  Standard_Real prevNorme;
-#endif
   gp_Vec Corde(prevP, Psurf);
   Norme = Corde.SquareMagnitude();
-  if (!curpointistangent) curNorme   = Tgsurf.SquareMagnitude();
   if (!prevpointistangent) prevNorme = prevTg.SquareMagnitude();
 
   if (Norme <= tolesp * tolesp){
@@ -1598,11 +1593,7 @@ Blend_Status BRepBlend_RstRstLineBuilder::TestArret(Blend_RstRstFunction& Func,
   gp_Vec tgrst1, tgrst2;
   gp_Vec2d tg2drst1, tg2drst2;
   Blend_Status StateRst1, StateRst2;
-#ifndef DEB
   IntSurf_TypeTrans trarst1 = IntSurf_Undecided, trarst2 = IntSurf_Undecided;
-#else
-  IntSurf_TypeTrans trarst1, trarst2;
-#endif
   Blend_Point curpoint;
 
   if (Func.IsSolution(sol, tolesp)) {