Salome HOME
updated copyright message
[modules/shaper.git] / src / BuildPlugin / Test / TestInterpolation.py
index 656351a488264cbf118aaaafa9a8965802cb7b52..1e5bdbf41b3abd16e7d17d54106df3595be6a60c 100644 (file)
@@ -1,25 +1,26 @@
-## Copyright (C) 2014-2017  CEA/DEN, EDF R&D
-##
-## This library is free software; you can redistribute it and/or
-## modify it under the terms of the GNU Lesser General Public
-## License as published by the Free Software Foundation; either
-## version 2.1 of the License, or (at your option) any later version.
-##
-## This library is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## Lesser General Public License for more details.
-##
-## 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
-##
-## See http:##www.salome-platform.org/ or
-## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
-##
+# Copyright (C) 2014-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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# 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
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
 
 from salome.shaper import model
 
+import math
+
 # Create document
 model.begin()
 partSet = model.moduleDocument()
@@ -45,12 +46,12 @@ SketchLine_2 = Sketch_1.addLine(0, 0, 45, 45)
 model.do()
 
 # Get sketch points
-base_name = "Sketch_1/Vertex-SketchPoint_"
+base_name = "Sketch_1/SketchPoint_"
 p_1, p_2, p_3, p_4, p_5 = [model.selection("VERTEX", base_name + str(i + 1)) for i in range(0, 5)]
 
 # Get sketch edges
-Tangent_1 = model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")
-Tangent_2 = model.selection("EDGE", "Sketch_1/Edge-SketchLine_2")
+Tangent_1 = model.selection("EDGE", "Sketch_1/SketchLine_1")
+Tangent_2 = model.selection("EDGE", "Sketch_1/SketchLine_2")
 
 # =============================================================================
 # Test 1. Create curve 1-2-3-4-5, closed off, reorder off, without tangents
@@ -117,14 +118,14 @@ Part_2 = model.addPart(partSet)
 Part_2_doc = Part_2.document()
 Box_1 = model.addBox(Part_2_doc, 10, 10, 10)
 
-point_names = ("Box_1_1/Back&Box_1_1/Left&Box_1_1/Bottom",
-               "Box_1_1/Back&Box_1_1/Left&Box_1_1/Top",
-               "Box_1_1/Front&Box_1_1/Left&Box_1_1/Top",
-               "Box_1_1/Front&Box_1_1/Left&Box_1_1/Bottom",
-               "Box_1_1/Front&Box_1_1/Right&Box_1_1/Bottom",
-               "Box_1_1/Front&Box_1_1/Right&Box_1_1/Top",
-               "Box_1_1/Back&Box_1_1/Right&Box_1_1/Top",
-               "Box_1_1/Back&Box_1_1/Right&Box_1_1/Bottom")
+point_names = ("[Box_1_1/Back][Box_1_1/Left][Box_1_1/Bottom]",
+               "[Box_1_1/Back][Box_1_1/Left][Box_1_1/Top]",
+               "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Top]",
+               "[Box_1_1/Front][Box_1_1/Left][Box_1_1/Bottom]",
+               "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Bottom]",
+               "[Box_1_1/Front][Box_1_1/Right][Box_1_1/Top]",
+               "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Top]",
+               "[Box_1_1/Back][Box_1_1/Right][Box_1_1/Bottom]")
 points = [model.selection("VERTEX", name) for name in point_names]
 
 Interpolation_8 = model.addInterpolation(Part_2_doc, points, False, False)
@@ -140,8 +141,8 @@ Part_3_doc = Part_3.document()
 Box_1 = model.addBox(Part_3_doc, 20, 30, 40)
 
 points = [model.selection("VERTEX", name) for name in point_names]
-Tangent_1 = model.selection("EDGE", "Box_1_1/Back&Box_1_1/Top")
-Tangent_2 = model.selection("EDGE", "Box_1_1/Left&Box_1_1/Top")
+Tangent_1 = model.selection("EDGE", "[Box_1_1/Back][Box_1_1/Top]")
+Tangent_2 = model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]")
 
 Interpolation_9 = model.addInterpolation(Part_3_doc, points,
                                          Tangent_1, Tangent_2, False, False)
@@ -173,6 +174,22 @@ model.testHaveNamingSubshapes(Interpolation_9, model, Part_3_doc)
 model.end()
 
 # =============================================================================
-# Test 12. Check Python dump
+# Test 12. Create curve using an analytical expression
+# =============================================================================
+Part_5 = model.addPart(partSet)
+Part_5_doc = Part_5.document()
+
+Interpolation_11 = model.addInterpolation(Part_5_doc, "sin(t)","cos(t)","t", 0, 100, 100)
+model.do()
+model.testNbResults(Interpolation_11, 1)
+myDelta = 1e-6
+Props = model.getGeometryCalculation(Part_5_doc,model.selection("EDGE", "Interpolation_1_1"))
+model.do()
+aRefLength = 141.32010978124
+aResLength = Props[0]
+assert (math.fabs(aResLength - aRefLength) < myDelta), "The length is wrong: expected = {0}, real = {1}".format(aRefLength, aResLength)
+model.end()
+# =============================================================================
+# Test 13. Check Python dump
 # =============================================================================
-assert(model.checkPythonDump())
+assert(model.checkPythonDump(model.ModelHighAPI.CHECK_NAMING))