Salome HOME
Implemented [bos #35094] [EDF] (2023-T1) X,Y,Z to U,V.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_FillingDriver.cxx
index a079774f79a6f422bd55b10bead6873b42921dce..6d6f846b437c3e3bd53526b2aa3278644c14c109 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -28,8 +28,6 @@
 
 #include <GEOM_Function.hxx>
 
-#include <Basics_OCCTVersion.hxx>
-
 #include <BRepAlgo.hxx>
 #include <BRepBuilderAPI_Copy.hxx>
 #include <BRepBuilderAPI_MakeFace.hxx>
@@ -94,7 +92,7 @@ GEOMImpl_FillingDriver::GEOMImpl_FillingDriver()
 //function : Execute
 //purpose  :
 //=======================================================================
-Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
+Standard_Integer GEOMImpl_FillingDriver::Execute(Handle(TFunction_Logbook)& log) const
 {
   if (Label().IsNull()) return 0;
   Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
@@ -176,7 +174,7 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
       Standard_Integer aMethod = IF.GetMethod();
 
       GeomFill_SectionGenerator Section;
-      Standard_Integer i = 0;
+      Standard_Integer aNumSection = 0;
       Handle(Geom_Curve) aLastC;
       gp_Pnt PL1,PL2;
       for (Ex.Init(aShape, TopAbs_EDGE); Ex.More(); Ex.Next()) {
@@ -198,7 +196,7 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
           C->Reverse();
         }
         else if (aMethod == 2) {
-          if (i == 0) {
+          if (aNumSection == 0) {
             PL1 = P1;
             PL2 = P2;
           }
@@ -218,12 +216,17 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
         }
 
         Section.AddCurve(C);
-        i++;
+        aNumSection++;
       }
 
       /* a 'tolerance' is used to compare 2 knots : see GeomFill_Generator.cdl */
       Section.Perform(Precision::PConfusion());
-      Handle(GeomFill_Line) Line = new GeomFill_Line(i);
+      //imn: to fix the bug 23351: "Crash is filling has only one edge"
+      //after fix related occt bug 27875 must be removed
+      if (aNumSection < 2) {
+        Standard_ConstructionError::Raise("Input must contain more than one edge");
+      }
+      Handle(GeomFill_Line) Line = new GeomFill_Line(aNumSection);
 
       GeomFill_AppSurf App (mindeg, maxdeg, tol3d, tol2d, nbiter); /* user parameters */
       App.Perform(Line, Section);
@@ -314,7 +317,7 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
 
     Handle(TColStd_HSequenceOfTransient) aConstraints = IF.GetShapes();
 
-    for ( unsigned int ind = 1; ind <= aConstraints->Length(); ind++ ) {
+    for ( int ind = 1; ind <= aConstraints->Length(); ind++ ) {
       TopoDS_Edge E;
       TopoDS_Face F;
       Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast( aConstraints->Value(ind) );
@@ -352,7 +355,7 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const
 
   aFunction->SetValue(aShape);
 
-  log.SetTouched(Label());
+  log->SetTouched(Label());
   return 1;
 }
 
@@ -393,7 +396,7 @@ GetCreationInformation(std::string&             theOperationName,
   }
   case FILLING_ON_CONSTRAINTS:
   {
-       theOperationName = "FACE";
+        theOperationName = "FACE";
     AddParam( theParams, "Edges/Faces", aCI.GetShapes() );
     break;
   }
@@ -404,5 +407,4 @@ GetCreationInformation(std::string&             theOperationName,
   return true;
 }
 
-IMPLEMENT_STANDARD_HANDLE (GEOMImpl_FillingDriver,GEOM_BaseDriver);
-IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_FillingDriver,GEOM_BaseDriver);
+IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_FillingDriver,GEOM_BaseDriver)