Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_Filling.cpp
index 338409aa5b32d38e8a04e18b0b94759f94ec8e8b..c80cd56911a1903e31cabe32b9a9ae3f154ffc00 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-20xx  CEA/DEN, EDF R&D
+// Copyright (C) 2017-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "GeomAlgoAPI_Filling.h"
@@ -97,13 +96,23 @@ void GeomAlgoAPI_Filling::buildByEdges()
 
   // a 'tolerance' is used to compare 2 knots
   aSection.Perform(Precision::PConfusion());
-  Handle(GeomFill_Line) aLine = new GeomFill_Line((int)aCurves.size());
+  int aNbCurves = (int)aCurves.size();
+  Handle(GeomFill_Line) aLine = new GeomFill_Line(aNbCurves);
+
+  // check myMaxDegree >= aCurves.size() - 1 to be able to interpolate a surface
+  if (myMaxDegree + 1 < aNbCurves) {
+    myError = "Unable to interpolate surface,"
+       " Max deg + 1 should be greater or equal than number of sections.";
+    return;
+  }
 
   // perform filling by sections
   GeomFill_AppSurf anAppSurf(myMinDegree, myMaxDegree, myTol3D, myTol2D, myNbIter);
   anAppSurf.Perform(aLine, aSection);
-  if (!anAppSurf.IsDone())
+  if (!anAppSurf.IsDone()) {
+    myError = "Approximation algorithm failed.";
     return;
+  }
 
   // build calculated surface
   Standard_Integer UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, NbVKnots;