Salome HOME
bos #29484 Add a test service to build tesselation on a shape
authorvsr <vsr@opencascade.com>
Tue, 19 Apr 2022 16:54:37 +0000 (19:54 +0300)
committervsr <vsr@opencascade.com>
Thu, 21 Apr 2022 09:40:44 +0000 (12:40 +0300)
30 files changed:
CMakeLists.txt
CTestTestfileInstall.cmake
doc/salome/CMakeLists.txt
doc/salome/examples/0README [new file with mode: 0644]
doc/salome/examples/CMakeLists.txt
doc/salome/examples/CTestTestfileInstall.cmake
doc/salome/examples/testme.py [deleted file]
doc/salome/examples/tests.py.in [deleted file]
doc/salome/examples/tests.set
idl/GEOM_Gen.idl
src/GEOMImpl/CMakeLists.txt
src/GEOMImpl/GEOMImpl_Gen.cxx
src/GEOMImpl/GEOMImpl_Gen.hxx
src/GEOMImpl/GEOMImpl_ITestOperations.cxx [new file with mode: 0644]
src/GEOMImpl/GEOMImpl_ITestOperations.hxx [new file with mode: 0644]
src/GEOM_I/CMakeLists.txt
src/GEOM_I/GEOM_Gen_i.cc
src/GEOM_I/GEOM_Gen_i.hh
src/GEOM_I/GEOM_ITestOperations_i.cc [new file with mode: 0644]
src/GEOM_I/GEOM_ITestOperations_i.hh [new file with mode: 0644]
src/GEOM_SWIG/geomBuilder.py
src/XAO/tests/CMakeLists.txt
src/XAO/tests/CTestTestfileInstall.cmake
test/0README [new file with mode: 0644]
test/CMakeLists.txt [new file with mode: 0644]
test/CTestTestfileInstall.cmake [new file with mode: 0644]
test/data/test_performance_01.brep [new file with mode: 0644]
test/test_helper.py [new file with mode: 0755]
test/test_perf_01.py [new file with mode: 0644]
test/tests.set [new file with mode: 0644]

index 5cd5827c133cbf0534f2ee8be872e1eca777bf9b..385105ccaee7968b1469b5d559013d9f812fb30d 100644 (file)
@@ -200,6 +200,15 @@ SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOM
                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
 
+# For salome test
+# ===============
+SET(GEOM_TEST_DIR ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test)
+IF(SALOME_BUILD_TESTS)
+  INSTALL(FILES CTestTestfileInstall.cmake
+          DESTINATION ${GEOM_TEST_DIR}
+          RENAME CTestTestfile.cmake)
+ENDIF()
+
 # Sources
 # ========
 ADD_SUBDIRECTORY(idl)
@@ -208,8 +217,9 @@ ADD_SUBDIRECTORY(adm_local)
 ADD_SUBDIRECTORY(resources)
 ADD_SUBDIRECTORY(bin)
 ADD_SUBDIRECTORY(src)
-IF(SALOME_BUILD_DOC)
-  ADD_SUBDIRECTORY(doc)
+ADD_SUBDIRECTORY(doc)
+IF(SALOME_BUILD_TESTS)
+  ADD_SUBDIRECTORY(test)
 ENDIF()
 
 # Header configuration
@@ -304,8 +314,3 @@ INSTALL(FILES
 # Install the export set for use with the install-tree
 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
         FILE ${PROJECT_NAME}Targets.cmake)
-
-# Application tests
-INSTALL(FILES CTestTestfileInstall.cmake
-  DESTINATION ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test
-  RENAME CTestTestfile.cmake)
index ed7c74822b8ba44805fa7199b61f980eb47c2684..01240f1c7ab693d017981ebf18de7dec8568a560 100644 (file)
@@ -18,9 +18,7 @@
 #
 
 SET(PYTHON_TEST_DRIVER "$ENV{KERNEL_ROOT_DIR}/bin/salome/appliskel/python_test_driver.py")
-
 SET(COMPONENT_NAME GEOM)
 SET(TIMEOUT        300)
 
-SUBDIRS(examples)
-SUBDIRS(xao)
+SUBDIRS(examples xao other)
index 28fe8fe845817230ab549f77a24651480dacde6d..24a74560c5fbaf3e3c5862513f93f22fc260fed6 100644 (file)
@@ -20,6 +20,8 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-ADD_SUBDIRECTORY(tui)
-ADD_SUBDIRECTORY(gui)
-ADD_SUBDIRECTORY(examples)
\ No newline at end of file
+ADD_SUBDIRECTORY(examples)
+IF(SALOME_BUILD_DOC)
+  ADD_SUBDIRECTORY(tui)
+  ADD_SUBDIRECTORY(gui)
+ENDIF()
diff --git a/doc/salome/examples/0README b/doc/salome/examples/0README
new file mode 100644 (file)
index 0000000..c1d0f14
--- /dev/null
@@ -0,0 +1,7 @@
+This folder contains example Python scripts which are used in the documentation of Geometry module,
+i.e. those mentioned in *.doc files in {root_src}/doc/salome/gui/GEOM/input folder.
+
+These tests are exported into the ${GEOM_ROOT_DIR}/share/doc/salome/examples/GEOM folder and can be
+executed with the `salome test` command, as a part of whole testing procedure.
+
+Other Python scripts aimed for testing purposes must be put into the ${root_src}/test folder!
index ab59a76f6077bdb12e76ca633b3189ecc8b87464..f039dc1579157f5e359110114abc190a48228151 100644 (file)
 
 INCLUDE(tests.set)
 
-SET(TEST_REINIT_SALOME "False")
-SALOME_CONFIGURE_FILE(tests.py.in tests.py)
+SET(TEST_INSTALL_DIRECTORY ${GEOM_TEST_DIR}/examples)
+SET(EXAMPLES_INSTALL_DIRECTORY ${SALOME_INSTALL_DOC}/examples/GEOM)
 
-SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+IF(SALOME_BUILD_TESTS)
+
+  # Install 'salome test' staff
+  # ---------------------------
+
+  INSTALL(FILES CTestTestfileInstall.cmake
+          DESTINATION ${TEST_INSTALL_DIRECTORY}
+          RENAME CTestTestfile.cmake)
+  INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+  # Add tests for 'make test'
+  # -------------------------
+
+  SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
 
-IF(GEOM_JOIN_TESTS)
-  ADD_TEST(NAME GEOM_examples COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py tests.py)
-ELSE(GEOM_JOIN_TESTS)
   FOREACH(test ${GOOD_TESTS})
     GET_FILENAME_COMPONENT(testname ${test} NAME_WE)
     ADD_TEST(NAME ${testname}
-             COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/doc/salome/examples/testme.py ${CMAKE_CURRENT_SOURCE_DIR}/${test})
-    SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}")
+             COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/test/test_helper.py ${CMAKE_CURRENT_SOURCE_DIR}/${test})
+    SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}" LABELS "examples")
   ENDFOREACH()
-ENDIF(GEOM_JOIN_TESTS)
-
-# install Python scripts
-SALOME_INSTALL_SCRIPTS("${EXAMPLES_TESTS}" ${SALOME_INSTALL_DOC}/examples/GEOM)
 
-# Application tests
+ENDIF()
 
-SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/examples)
-INSTALL(FILES ${GOOD_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY})
+# Install example scripts and data
+# --------------------------------
 
-INSTALL(FILES CTestTestfileInstall.cmake
-        DESTINATION ${TEST_INSTALL_DIRECTORY}
-        RENAME CTestTestfile.cmake)
-INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
+IF(SALOME_BUILD_TESTS OR SALOME_BUILD_DOC)
+  INSTALL(FILES ${GOOD_TESTS} ${BAD_TESTS} DESTINATION ${EXAMPLES_INSTALL_DIRECTORY})
+ENDIF()
index 324ae5ba4e82b25915d7bc1215739c785c21d2e3..02bf867c723d111393b1d356d664b31a3c9b1423 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+SET(SCRIPTS_DIR "../../../../share/doc/salome/examples/GEOM")
+
 INCLUDE(tests.set)
 
 FOREACH(tfile ${GOOD_TESTS})
   GET_FILENAME_COMPONENT(BASE_NAME ${tfile} NAME_WE)
-  SET(TEST_NAME GEOM_${BASE_NAME})
-  ADD_TEST(${TEST_NAME} python ${PYTHON_TEST_DRIVER} ${TIMEOUT} ${tfile})
-  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}")
+  SET(TEST_NAME ${COMPONENT_NAME}_${BASE_NAME})
+  ADD_TEST(${TEST_NAME} python ${PYTHON_TEST_DRIVER} ${TIMEOUT} ${SCRIPTS_DIR}/${tfile})
+  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME};${COMPONENT_NAME}_examples")
 ENDFOREACH()
diff --git a/doc/salome/examples/testme.py b/doc/salome/examples/testme.py
deleted file mode 100755 (executable)
index 3f4515f..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env python3
-# Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# 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
-#
-
-
-import unittest, sys, os
-
-class SalomeSession(object):
-    def __init__(self, script):
-        import runSalomeOld as runSalome
-        run_script = "runSalomeOld.py"
-        if sys.platform == 'win32':
-            module_dir = os.getenv("KERNEL_ROOT_DIR")
-            if module_dir: run_script = os.path.join(module_dir, "bin", "salome", run_script)
-            pass
-        sys.argv  = [run_script]
-        sys.argv += ["--terminal"]
-        sys.argv += ["--modules=GEOM"]
-        sys.argv += ["%s" % script]
-        if sys.platform == 'win32':
-            main_module_path = sys.modules['__main__'].__file__
-            sys.modules['__main__'].__file__ = ''
-        clt, d = runSalome.main()
-        if sys.platform == 'win32':
-            sys.modules['__main__'].__file__ = main_module_path
-        return
-
-    def __del__(self):
-        port = os.getenv('NSPORT')
-        import killSalomeWithPort
-        killSalomeWithPort.killMyPort(port)
-        return
-    pass
-
-class MyTest(unittest.TestCase):
-    def testFunction(self):
-        SalomeSession(sys.argv[1])
-    pass
-
-unittest.main(argv=sys.argv[:1])
diff --git a/doc/salome/examples/tests.py.in b/doc/salome/examples/tests.py.in
deleted file mode 100644 (file)
index 3b1f880..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright (C) 2018-2021  CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# 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
-#
-
-DIR='@CMAKE_CURRENT_SOURCE_DIR@'
-TESTS='@GOOD_TESTS@'
-REINIT_SALOME=@TEST_REINIT_SALOME@
-
-import os
-import unittest
-import salome
-
-class MyTest(unittest.TestCase):
-    def setUp(self):
-        if REINIT_SALOME:
-            salome.salome_init()
-    def tearDown(self):
-        if REINIT_SALOME:
-            salome.salome_close()
-    pass
-
-if __name__ == "__main__":
-    tests = TESTS.split(';')
-    for test in tests:
-        file_name = os.path.basename(test)
-        if os.path.isabs(test):
-            file_path = file_name
-        else:
-            file_path = os.path.join(DIR, file_name)
-        case_name = 'test_' + file_name[:-3]
-        code = """
-def func(self):
-  with open('{}') as f:
-    exec(f.read())
-"""
-        exec(code.format(file_path))
-        setattr(MyTest, case_name, func)
-
-    unittest.main()
index eee7f4cc4adbbcc8d466d8e1016dabb8768f87d3..c4499a3426d3d3101f3f4699d5840b163bd96429 100644 (file)
@@ -134,5 +134,3 @@ SET(GOOD_TESTS
   GEOM_Field.py
   check_self_intersections_fast.py # OCC > 6.9.0
 )
-
-SET(EXAMPLES_TESTS ${BAD_TESTS} ${GOOD_TESTS} testme.py)
index c9b0664e07d56b4c30129c043ec4ac3a717aa21c..b28c461ec77ecfabf20f3e374e4db94889d56af4 100644 (file)
@@ -4890,7 +4890,25 @@ module GEOM
     long GetNbSubShapes(in GEOM_Object shape, in short fieldDim);
   };
 
- // # GEOM_Gen:
+  // # GEOM_ITestOperations:
+  /*!
+   *  \brief Interface for testing operations.
+   */
+  interface GEOM_ITestOperations : GEOM_IOperations
+  {
+    /*!
+     *  \brief Build a mesh on the given shape.
+     *  \param shape is a source object
+     *  \param linearDeflection is a linear deflection
+     *  \param isRelative says if given value of deflection is relative to shape's bounding box
+     *  \param angularDeflection is an angular deflection for edges in radians
+     *  \return true in case of success; otherwise false.
+     */
+    boolean Tesselate(in GEOM_Object shape, in double linearDeflection,
+                      in boolean isRelative, in double angularDeflection);
+  };
+
+  // # GEOM_Gen:
   /*!
    *  \brief Interface to access other GEOM interfaces.
    *
@@ -5016,6 +5034,7 @@ module GEOM
     GEOM_IBlocksOperations    GetIBlocksOperations   () raises (SALOME::SALOME_Exception);
     GEOM_IGroupOperations     GetIGroupOperations    () raises (SALOME::SALOME_Exception);
     GEOM_IFieldOperations     GetIFieldOperations    () raises (SALOME::SALOME_Exception);
+    GEOM_ITestOperations      GetITestOperations     () raises (SALOME::SALOME_Exception);
 
     GEOM_IOperations GetPluginOperations (in string theLibName) raises (SALOME::SALOME_Exception);
 
index fc7e092915f4f499c2a8d3366eae4c2d675e9aa5..96fdde01f3d8ba5a807bb24fe79a7e21b94d99ed 100644 (file)
@@ -70,6 +70,7 @@ SET(GEOMImpl_HEADERS
   GEOMImpl_IGroupOperations.hxx
   GEOMImpl_IFieldOperations.hxx
   GEOMImpl_IBaseIEOperations.hxx
+  GEOMImpl_ITestOperations.hxx
   GEOMImpl_IGlue.hxx
   GEOMImpl_PointDriver.hxx
   GEOMImpl_IPoint.hxx
@@ -198,6 +199,7 @@ SET(GEOMImpl_SOURCES
   GEOMImpl_IGroupOperations.cxx
   GEOMImpl_IFieldOperations.cxx
   GEOMImpl_IBaseIEOperations.cxx
+  GEOMImpl_ITestOperations.cxx
   GEOMImpl_IPolyline2D.cxx
   GEOMImpl_ITransferData.cxx
   GEOMImpl_Gen.cxx
index aac8f9f460f4a7cbecc0a4cb4c0d65a83395bbbb..99f93be005689e3b49bfde090c2e65c590e46aec 100644 (file)
@@ -182,6 +182,7 @@ GEOMImpl_Gen::GEOMImpl_Gen()
    _MeasureOperations = new GEOMImpl_IMeasureOperations( this );
    _GroupOperations = new GEOMImpl_IGroupOperations( this );
    _FieldOperations = new GEOMImpl_IFieldOperations( this );
+   _TestOperations = new GEOMImpl_ITestOperations( this );
 }
 
 //=============================================================================
@@ -338,3 +339,13 @@ GEOMImpl_IFieldOperations* GEOMImpl_Gen::GetIFieldOperations()
 {
   return _FieldOperations;
 }
+
+//=============================================================================
+/*!
+ * GetITestOperations
+ */
+//=============================================================================
+GEOMImpl_ITestOperations* GEOMImpl_Gen::GetITestOperations()
+{
+  return _TestOperations;
+}
index 517922d5475e8d2b31d65675f8174ba15d8a96f1..4fad2a9d9dabbfe8f88f097b777128fe33cbfb57 100644 (file)
@@ -40,6 +40,7 @@
 #include "GEOMImpl_IMeasureOperations.hxx"
 #include "GEOMImpl_IGroupOperations.hxx"
 #include "GEOMImpl_IFieldOperations.hxx"
+#include "GEOMImpl_ITestOperations.hxx"
 #include "GEOM_Engine.hxx"
 
 class GEOMIMPL_EXPORT GEOMImpl_Gen : public GEOM_Engine
@@ -74,6 +75,8 @@ class GEOMIMPL_EXPORT GEOMImpl_Gen : public GEOM_Engine
 
   GEOMImpl_IFieldOperations* GetIFieldOperations();
 
+  GEOMImpl_ITestOperations* GetITestOperations();
+
  private:
 
   GEOMImpl_IBasicOperations*     _BasicOperations;
@@ -89,6 +92,7 @@ class GEOMIMPL_EXPORT GEOMImpl_Gen : public GEOM_Engine
   GEOMImpl_IMeasureOperations*   _MeasureOperations;
   GEOMImpl_IGroupOperations*     _GroupOperations;
   GEOMImpl_IFieldOperations*     _FieldOperations;
+  GEOMImpl_ITestOperations*      _TestOperations;
 };
 
 #endif
diff --git a/src/GEOMImpl/GEOMImpl_ITestOperations.cxx b/src/GEOMImpl/GEOMImpl_ITestOperations.cxx
new file mode 100644 (file)
index 0000000..1fc7098
--- /dev/null
@@ -0,0 +1,108 @@
+// Copyright (C) 2007-2021  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
+//
+// 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
+//
+
+#include <GEOMImpl_ITestOperations.hxx>
+
+#include <BRepBndLib.hxx>
+#include <BRepBuilderAPI_Copy.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
+#include <BRepTools.hxx>
+#include <Bnd_Box.hxx>
+#include <utilities.h>
+
+#ifndef MAX2
+#define MAX2(X, Y)    (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y))
+#endif
+#ifndef MAX3
+#define MAX3(X, Y, Z) (MAX2(MAX2(X, Y), Z))
+#endif
+
+//=============================================================================
+/*!
+ *   constructor:
+ */
+//=============================================================================
+GEOMImpl_ITestOperations::GEOMImpl_ITestOperations(GEOM_Engine* theEngine)
+: GEOM_IOperations(theEngine)
+{
+  MESSAGE("GEOMImpl_ITestOperations::GEOMImpl_ITestOperations");
+}
+
+//=============================================================================
+/*!
+ *  destructor
+ */
+//=============================================================================
+GEOMImpl_ITestOperations::~GEOMImpl_ITestOperations()
+{
+  MESSAGE("GEOMImpl_ITestOperations::~GEOMImpl_ITestOperations");
+}
+
+
+//=============================================================================
+/*!
+ *  \brief Build a mesh on (a copy of ) the given shape.
+ *
+ *  This test function is aimed for checking performance of OCCT tesselation
+ *  algorithm on particlar geometrical shapes.
+ *
+ *  \param theShape is a source object
+ *  \param theLinearDeflection is a value of deflection coefficient
+ *  \param theIsRelative says if given value of deflection is relative to shape's bounding box
+ *  \param theAngularDeflection is a angular deflection for edges in radians
+ *  \return \c true in case of success; otherwise \c false.
+ */
+//=============================================================================
+bool GEOMImpl_ITestOperations::Tesselate(Handle(GEOM_Object) theShape,
+                                        double theLinearDeflection,
+                                        bool theIsRelative,
+                                        double theAngularDeflection)
+{
+  // ATTENTION!
+  // We don't need results of this method to be present in the data tree;
+  // so we don't need a driver for it.
+
+  // reset error code
+  SetErrorCode(KO);
+  // create a copy of the source shape
+  TopoDS_Shape aShape = BRepBuilderAPI_Copy(theShape->GetValue()).Shape();
+  // use default deflection if necessary
+  if (theLinearDeflection <= 0)
+    theLinearDeflection = 0.001;
+  // compute absolute deflection if necessary: 0.001
+  if (theIsRelative) {
+    Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+    Bnd_Box bndBox;
+    BRepBndLib::Add(aShape, bndBox);
+    bndBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+    theLinearDeflection = MAX3(aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * theLinearDeflection * 4;
+  }
+  // use default deviation angle if necessary: 20 degrees
+  if (theAngularDeflection <= 0)
+    theAngularDeflection = 20. * M_PI / 180.;
+  // compute triangulation
+  BRepTools::Clean(aShape);
+  BRepMesh_IncrementalMesh aMesh(aShape, theLinearDeflection, Standard_False, theAngularDeflection);
+  // set OK status and return
+  SetErrorCode(OK);
+  return true;
+}
diff --git a/src/GEOMImpl/GEOMImpl_ITestOperations.hxx b/src/GEOMImpl/GEOMImpl_ITestOperations.hxx
new file mode 100644 (file)
index 0000000..cb94e13
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright (C) 2007-2021  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
+//
+// 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
+//
+
+#ifndef _GEOMImpl_ITestOperations_HXX_
+#define _GEOMImpl_ITestOperations_HXX_
+
+#include "Utils_SALOME_Exception.hxx"
+#include "GEOM_IOperations.hxx"
+#include "GEOM_Engine.hxx"
+#include "GEOM_Object.hxx"
+
+class GEOMImpl_ITestOperations : public GEOM_IOperations {
+ public:
+  Standard_EXPORT GEOMImpl_ITestOperations(GEOM_Engine* theEngine);
+  Standard_EXPORT ~GEOMImpl_ITestOperations();
+
+  Standard_EXPORT bool Tesselate(Handle(GEOM_Object) theShape,
+                                double theLinearDeflection,
+                                bool theIsRelative,
+                                double theAngularDeflection);
+};
+
+#endif // _GEOMImpl_ITestOperations_HXX_
index 176e8666255ab646d49a6d85a631c3efe21b97ab..9c2e253211edfdfb0e1130607dee1b580f0c3c5b 100644 (file)
@@ -77,6 +77,7 @@ SET(GEOMEngine_HEADERS
   GEOM_ITransformOperations_i.hh
   GEOM_IMeasureOperations_i.hh
   GEOM_IGroupOperations_i.hh
+  GEOM_ITestOperations_i.hh
   GEOM_Gen_i.hh
   GEOM_Gen_Session_i.hh
   GEOM_Gen_No_Session_i.hh
@@ -103,6 +104,7 @@ SET(GEOMEngine_SOURCES
   GEOM_IMeasureOperations_i.cc
   GEOM_IGroupOperations_i.cc
   GEOM_IFieldOperations_i.cc
+  GEOM_ITestOperations_i.cc
   GEOM_Gen_i.cc
   GEOM_Gen_Session_i.cc
   GEOM_Gen_No_Session_i.cc
index 32f638ba0a17e0f5e6f6cdd1a8336ec22cc56813..00c865c457e1fc682fcd6b861b3ddd6423d297b7 100644 (file)
@@ -2466,6 +2466,25 @@ GEOM::GEOM_IFieldOperations_ptr GEOM_Gen_i::GetIFieldOperations()
   return operations._retn();
 }
 
+//============================================================================
+// function : GetITestOperations
+// purpose  :
+//============================================================================
+GEOM::GEOM_ITestOperations_ptr GEOM_Gen_i::GetITestOperations()
+{
+  Unexpect aCatch(SALOME_SalomeException);
+  MESSAGE( "GEOM_Gen_i::GetITestOperations" );
+
+  GEOM::GEOM_Gen_ptr engine = _this();
+
+  GEOM_ITestOperations_i* aServant =
+    new GEOM_ITestOperations_i(_poa, engine, _impl->GetITestOperations());
+
+  // activate the CORBA servant
+  GEOM::GEOM_ITestOperations_var operations = aServant->_this();
+  return operations._retn();
+}
+
 //============================================================================
 // function : GetPluginOperations
 // purpose  :
index cc1abbad416bd3ae6ecc1d0fba98be6b3c94ad1d..a9b8141c259b2b90c0c398267d901d122b969847 100644 (file)
@@ -51,6 +51,7 @@
 #include "GEOM_IMeasureOperations_i.hh"
 #include "GEOM_IGroupOperations_i.hh"
 #include "GEOM_IFieldOperations_i.hh"
+#include "GEOM_ITestOperations_i.hh"
 #include "GEOMUtils.hxx"
 
 #include <TopTools_IndexedMapOfShape.hxx>
@@ -254,6 +255,10 @@ class GEOM_I_EXPORT GEOM_Gen_i : public POA_GEOM::GEOM_Gen, public Engines_Compo
   virtual GEOM::GEOM_IFieldOperations_ptr GetIFieldOperations()
     ;
 
+  //Returns a pointer to TestOperations interface
+  virtual GEOM::GEOM_ITestOperations_ptr GetITestOperations()
+    ;
+
   //Returns a pointer to corresponding plugin operations interface
   virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (const char* theLibName)
     ;
diff --git a/src/GEOM_I/GEOM_ITestOperations_i.cc b/src/GEOM_I/GEOM_ITestOperations_i.cc
new file mode 100644 (file)
index 0000000..83680d3
--- /dev/null
@@ -0,0 +1,75 @@
+// Copyright (C) 2007-2021  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
+//
+// 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
+//
+
+#include "GEOM_ITestOperations_i.hh"
+
+#include "utilities.h"
+#include "OpUtil.hxx"
+#include "Utils_ExceptHandlers.hxx"
+
+#include "GEOM_Engine.hxx"
+#include "GEOM_Object.hxx"
+
+//=============================================================================
+/*!
+ *   constructor:
+ */
+//=============================================================================
+GEOM_ITestOperations_i::GEOM_ITestOperations_i (PortableServer::POA_ptr thePOA,
+                                               GEOM::GEOM_Gen_ptr theEngine,
+                                               ::GEOMImpl_ITestOperations* theImpl)
+  :GEOM_IOperations_i(thePOA, theEngine, theImpl)
+{
+  MESSAGE("GEOM_ITestOperations_i::GEOM_ITestOperations_i");
+}
+
+//=============================================================================
+/*!
+ *  destructor
+ */
+//=============================================================================
+GEOM_ITestOperations_i::~GEOM_ITestOperations_i()
+{
+  MESSAGE("GEOM_ITestOperations_i::~GEOM_ITestOperations_i");
+}
+
+
+//=============================================================================
+/*!
+ *  Tesselate
+ */
+//=============================================================================
+CORBA::Boolean GEOM_ITestOperations_i::Tesselate(GEOM::GEOM_Object_ptr theShape,
+                                                CORBA::Double theLinearDeflection,
+                                                CORBA::Boolean theIsRelative,
+                                                CORBA::Double theAngularDeflection)
+{
+  // Set a not done flag
+  GetOperations()->SetNotDone();
+
+  // Get the source object
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
+  if (aShape.IsNull()) return false;
+
+  // Tesselate
+  return GetOperations()->Tesselate(aShape, theLinearDeflection, theIsRelative, theAngularDeflection);
+}
diff --git a/src/GEOM_I/GEOM_ITestOperations_i.hh b/src/GEOM_I/GEOM_ITestOperations_i.hh
new file mode 100644 (file)
index 0000000..4da6696
--- /dev/null
@@ -0,0 +1,54 @@
+// Copyright (C) 2007-2021  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
+//
+// 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
+//
+
+#ifndef _GEOM_ITestOperations_i_HeaderFile
+#define _GEOM_ITestOperations_i_HeaderFile
+
+#include "GEOMImpl_Gen.hxx"
+
+#include <SALOMEconfig.h>
+
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+#include "GEOM_IOperations_i.hh"
+#include "GEOM_Object_i.hh"
+
+#include "GEOMImpl_ITestOperations.hxx"
+
+class GEOM_I_EXPORT GEOM_ITestOperations_i :
+    public virtual POA_GEOM::GEOM_ITestOperations,
+    public virtual GEOM_IOperations_i
+{
+ public:
+   GEOM_ITestOperations_i(PortableServer::POA_ptr thePOA,
+                          GEOM::GEOM_Gen_ptr theEngine,
+                          ::GEOMImpl_ITestOperations* theImpl);
+   ~GEOM_ITestOperations_i();
+
+   CORBA::Boolean Tesselate(GEOM::GEOM_Object_ptr theShape,
+                            CORBA::Double theLinearDeflection,
+                            CORBA::Boolean theIsRelative,
+                            CORBA::Double theAngularDeflection);
+
+   ::GEOMImpl_ITestOperations* GetOperations() { return (::GEOMImpl_ITestOperations*)GetImpl(); }
+};
+
+#endif // _GEOM_ITestOperations_i_HeaderFile
index efb57f1270a91ac59e0246edb2c25a66799ce205..6f3f010d61addce619abc40a8990d3ebe4a99dfa 100644 (file)
 ##   @}
 ##   @defgroup l2_measure       Using measurement tools
 ##   @defgroup l2_field         Field on Geometry
+##   @defgroup l2_testing       Testing
 
 ## @}
 
@@ -745,6 +746,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
               self.BlocksOp = None
               self.GroupOp  = None
               self.FieldOp  = None
+              self.TestOp   = None
             pass
 
         ## Process object publication in the study, as follows:
@@ -852,6 +854,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
             self.BlocksOp = self.GetIBlocksOperations   ()
             self.GroupOp  = self.GetIGroupOperations    ()
             self.FieldOp  = self.GetIFieldOperations    ()
+            self.TestOp   = self.GetITestOperations     ()
 
             notebook.myStudy = self.myStudy
             pass
@@ -13898,6 +13901,37 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
         # end of l2_field
         ## @}
 
+        ## @addtogroup l2_testing
+        ## @{
+
+        ## Build a mesh on the given shape.
+        # @param shape the source shape
+        # @param linear_deflection linear deflection coefficient
+        # @param is_relative says if given value of deflection is relative to shape's bounding box
+        # @param angular_deflection angular deflection for edges in degrees
+        # @return True in case of success; otherwise False.
+        @ManageTransactions("TestOp")
+        def Tesselate(self, shape, linear_deflection=0, is_relative=True, angular_deflection=0):
+            """Build a mesh on the given shape.
+
+            Parameters:
+                shape the source shape
+                linear_deflection linear deflection coefficient
+                is_relative says if given value of deflection is relative to shape's bounding box
+                angular_deflection angular deflection for edges in degrees
+
+            Returns:
+                True in case of success; otherwise False.
+            """
+            if angular_deflection > 0:
+                angular_deflection = angular_deflection * math.pi / 180.
+            r = self.TestOp.Tesselate(shape, linear_deflection, is_relative, angular_deflection)
+            RaiseIfFailed("Tesselate", self.TestOp)
+            return r
+
+        # end of l2_testing
+        ## @}
+
 
 # Register the new proxy for GEOM_Gen
 omniORB.registerObjref(GEOM._objref_GEOM_Gen._NP_RepositoryId, geomBuilder)
index 397f4f15758e0dab169cd08e1b684fd097c68320..112b8068faf17aa013a0f4b04170f4bf4df33a7a 100644 (file)
@@ -60,7 +60,7 @@ SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
 SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/xao)
 
 ADD_TEST(TestXAO TestXAO)
-SET_TESTS_PROPERTIES(TestXAO PROPERTIES ENVIRONMENT "XAO_DATA_DIR=${CMAKE_CURRENT_SOURCE_DIR}/data;${tests_env}")
+SET_TESTS_PROPERTIES(TestXAO PROPERTIES ENVIRONMENT "XAO_DATA_DIR=${CMAKE_CURRENT_SOURCE_DIR}/data;${tests_env}" LABELS "xao")
 
 INSTALL(TARGETS TestXAO DESTINATION ${SALOME_INSTALL_BINS})
 
index 09e8b4d031c101d6286960fdb52dfb0f86e948dc..b4c8baf27cd3562d7505be7fcb4e928b160bf241 100644 (file)
@@ -19,5 +19,5 @@
 
 ADD_TEST(GEOM_TestXAO python ${PYTHON_TEST_DRIVER} ${TIMEOUT} TestXAO)
 SET_TESTS_PROPERTIES(GEOM_TestXAO PROPERTIES
-    LABELS "${COMPONENT_NAME}"
+    LABELS "${COMPONENT_NAME};${COMPONENT_NAME}_xao"
     ENVIRONMENT "XAO_DATA_DIR=$ENV{GEOM_ROOT_DIR}/bin/salome/test/xao/data")
diff --git a/test/0README b/test/0README
new file mode 100644 (file)
index 0000000..7b15cc9
--- /dev/null
@@ -0,0 +1,7 @@
+This folder contains test scripts for GEOM module.
+
+These tests are exported into the ${GEOM_ROOT_DIR}/bin/test folder and can be executed with the
+`salome test` command, as a part of whole testing procedure.
+
+The example Python scripts to be used in the documentation of Geometry module, must be put into the
+{root_src}/doc/salome/examples folder!
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..68cd636
--- /dev/null
@@ -0,0 +1,64 @@
+# Copyright (C) 2007-2021  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
+#
+# 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
+#
+
+INCLUDE(tests.set)
+
+SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository")
+SET(TEST_INSTALL_DIRECTORY ${GEOM_TEST_DIR}/other)
+
+# Install 'salome test' staff
+# ---------------------------
+
+INSTALL(FILES CTestTestfileInstall.cmake
+        DESTINATION ${TEST_INSTALL_DIRECTORY}
+        RENAME CTestTestfile.cmake)
+INSTALL(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY})
+INSTALL(FILES ${ALL_TESTS} DESTINATION ${TEST_INSTALL_DIRECTORY})
+INSTALL(DIRECTORY data DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+# Add tests for 'make test'
+# -------------------------
+
+SALOME_GENERATE_TESTS_ENVIRONMENT(_test_env)
+
+# 1. Tests from here
+# ------------------
+
+FOREACH(_test ${ALL_TESTS})
+  GET_FILENAME_COMPONENT(testname ${_test} NAME_WE)
+  ADD_TEST(NAME ${testname}
+           COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/test/test_helper.py ${CMAKE_CURRENT_SOURCE_DIR}/${_test})
+  SET_TESTS_PROPERTIES(${testname} PROPERTIES ENVIRONMENT "${tests_env}" LABELS "tests")
+ENDFOREACH()
+
+# 2. Tests from RESTRICTED repository
+# -----------------------------------
+
+IF(EXISTS ${RESTRICTED_ROOT_DIR}/GEOM)
+  FILE(GLOB _restricted_tests "${RESTRICTED_ROOT_DIR}/GEOM/*.py")
+  FOREACH(_test ${_restricted_tests})
+    GET_FILENAME_COMPONENT(_test_name ${_test} NAME_WE)
+    ADD_TEST(NAME ${_test_name}
+             COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_SOURCE_DIR}/test/test_helper.py ${_test})
+    SET_TESTS_PROPERTIES(${_test_name} PROPERTIES ENVIRONMENT "${_test_env}" LABELS "restricted")
+  ENDFOREACH()
+ENDIF()
diff --git a/test/CTestTestfileInstall.cmake b/test/CTestTestfileInstall.cmake
new file mode 100644 (file)
index 0000000..3ac85eb
--- /dev/null
@@ -0,0 +1,27 @@
+# Copyright (C) 2015-2021  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+
+INCLUDE(tests.set)
+
+FOREACH(tfile ${ALL_TESTS})
+  GET_FILENAME_COMPONENT(BASE_NAME ${tfile} NAME_WE)
+  SET(TEST_NAME ${COMPONENT_NAME}_${BASE_NAME})
+  ADD_TEST(${TEST_NAME} python ${tfile})
+  SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME};${COMPONENT_NAME}_tests")
+endforeach()
diff --git a/test/data/test_performance_01.brep b/test/data/test_performance_01.brep
new file mode 100644 (file)
index 0000000..7b73d08
--- /dev/null
@@ -0,0 +1,141 @@
+DBRep_DrawableShape
+
+CASCADE Topology V1, (c) Matra-Datavision
+Locations 8
+1
+              1 2.44929359829471e-16               0               0 
+-2.44929359829471e-16               1               0 -4.89858719658941e-15 
+              0               0               1               0 
+1
+              1               0 -2.44929359829471e-16 4.89858719658941e-15 
+              0               1               0               0 
+2.44929359829471e-16               0               1               0 
+2  1 1 2 1 0
+1
+             -1               0 1.22464679914735e-16 -2.44929359829471e-15 
+              0               1               0               0 
+-1.22464679914735e-16               0              -1              40 
+2  1 1 2 1 4 1 0
+2  2 -1 0
+2  4 -1 2 -1 0
+2  2 1 4 1 0
+Curve2ds 10
+1 0 0 1 0 
+1 0 6.2831853071795862 1 0 
+2 0 0 -1 0 0 1 9.9999999999766942e-05
+1 0 0 0 1 
+1 3.1415926535897931 0 0 1 
+1 0 0 1 0 
+1 0 6.2831853071795862 1 0 
+2 0 0 -1 -4.8988262214224833e-28 -4.8988262214224833e-28 1 2
+1 0 0 0 1 
+1 3.1415926535897931 0 0 1 
+Curves 4
+2 0 -2.4492935982841007e-20 20 0 1 0 -1 0 -1.7763657212288565e-16 -1.7763657212288565e-16 0 1 19.9999
+2 -20 0 20 0 0 1 1 -2.4492935982898091e-16 0 2.4492935982898091e-16 1 -0 9.9999999999766942e-05
+2 0 -4.8985871965894138e-16 20 0 1 0 -1 0 -1.9737298215558337e-16 -1.9737298215558337e-16 0 1 18
+2 -20 0 20 0 0 1 1 -2.4492935982947069e-16 0 2.4492935982947069e-16 1 -0 2
+Polygon3D 0
+PolygonOnTriangulations 0
+Surfaces 3
+7 0 0 20 0 1 0 
+8 0 6.2831853071795862
+2 -20 0 19.999999999999996 -2.4492935982947064e-16 0 1 1 -2.4492935982898091e-16 2.4492935982947064e-16 2.4492935982898091e-16 1 5.9990391306354351e-32 9.9999999999766942e-05
+1 -20 0 20 0 0 1 -1 2.4492935982898091e-16 -0 2.4492935982898091e-16 1 -0 
+7 0 0 20 0 1 0 
+8 0 6.2831853071795862
+2 -20 0 19.999999999999996 -2.4492935982947064e-16 0 1 1 -2.4492935982947069e-16 2.4492935982947064e-16 2.4492935982947069e-16 1 5.9990391306474315e-32 2
+Triangulations 0
+
+TShapes 15
+Ve
+1e-07
+-19.9999 0 20
+0 0
+
+0101101
+*
+Ed
+ 1e-07 1 1 0
+1  1 0 0 3.14159265358979
+3  1 2CN 1 0 0 3.14159265358979
+0
+
+0101000
++15 3 -15 5 *
+Ed
+ 1e-07 1 1 0
+1  2 0 0 6.28318530717959
+2  3 2 0 0 6.28318530717959
+2  4 1 6 0 6.28318530717959
+2  5 1 7 0 6.28318530717959
+0
+
+0101000
++15 1 -15 1 *
+Wi
+
+0101100
++14 0 -14 0 -13 2 +13 8 *
+Fa
+0  1e-07 1 0
+
+0101000
++12 0 *
+Ve
+1e-07
+-18 0 20
+0 0
+
+0101101
+*
+Ed
+ 1e-07 1 1 0
+1  3 0 0 3.14159265358979
+3  6 7CN 3 0 0 3.14159265358979
+0
+
+0101000
++10 3 -10 5 *
+Ed
+ 1e-07 1 1 0
+1  4 0 0 6.28318530717959
+2  8 2 0 0 6.28318530717959
+2  9 3 6 0 6.28318530717959
+2  10 3 7 0 6.28318530717959
+0
+
+0101000
++10 1 -10 1 *
+Wi
+
+0101100
++9 0 -9 0 -8 2 +8 8 *
+Fa
+0  1e-07 3 0
+
+0101000
++7 0 *
+Wi
+
+0101100
++13 0 *
+Wi
+
+0101100
+-8 0 *
+Fa
+0  1e-07 2 0
+
+0101000
++5 0 +4 0 *
+Sh
+
+0101100
++11 0 -6 0 +3 2 -3 8 *
+So
+
+1100000
++2 0 *
+
++1 0 
\ No newline at end of file
diff --git a/test/test_helper.py b/test/test_helper.py
new file mode 100755 (executable)
index 0000000..3f4515f
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/env python3
+# Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+
+
+import unittest, sys, os
+
+class SalomeSession(object):
+    def __init__(self, script):
+        import runSalomeOld as runSalome
+        run_script = "runSalomeOld.py"
+        if sys.platform == 'win32':
+            module_dir = os.getenv("KERNEL_ROOT_DIR")
+            if module_dir: run_script = os.path.join(module_dir, "bin", "salome", run_script)
+            pass
+        sys.argv  = [run_script]
+        sys.argv += ["--terminal"]
+        sys.argv += ["--modules=GEOM"]
+        sys.argv += ["%s" % script]
+        if sys.platform == 'win32':
+            main_module_path = sys.modules['__main__'].__file__
+            sys.modules['__main__'].__file__ = ''
+        clt, d = runSalome.main()
+        if sys.platform == 'win32':
+            sys.modules['__main__'].__file__ = main_module_path
+        return
+
+    def __del__(self):
+        port = os.getenv('NSPORT')
+        import killSalomeWithPort
+        killSalomeWithPort.killMyPort(port)
+        return
+    pass
+
+class MyTest(unittest.TestCase):
+    def testFunction(self):
+        SalomeSession(sys.argv[1])
+    pass
+
+unittest.main(argv=sys.argv[:1])
diff --git a/test/test_perf_01.py b/test/test_perf_01.py
new file mode 100644 (file)
index 0000000..3e02241
--- /dev/null
@@ -0,0 +1,49 @@
+from contextlib import contextmanager
+from datetime import datetime, timedelta
+from inspect import getfile
+from os.path import abspath, dirname, join
+from unittest import TestCase, main
+
+import salome
+salome.salome_init_without_session()
+
+from salome.geom import geomBuilder
+geom_builder = geomBuilder.New()
+
+data_dir = abspath(join(dirname(getfile(lambda: None)), 'data'))
+
+@contextmanager
+def no_longer_than(seconds):
+    """
+    Context mananger to check that an execution of given code does not
+    exceed maximum expected time.   
+
+    Example of usage:
+
+        with wait(5):
+            do_something_that_should_take_no_more_than_five_seconds()
+
+    Arguments:
+        seconds: max time limit
+
+    Raises:
+        AssertionError: if time limit is exceeded.
+    """
+    expected = timedelta(seconds=seconds)
+    start = datetime.now()
+    yield
+    end = datetime.now()
+    spent = end-start
+    assert spent <= expected, f'Expected maximum delay is exceeded: {spent.total_seconds():.2f} > {seconds:.2f}!'
+
+class TesselationTest(TestCase):
+    """Test Tesselate() method."""
+
+    def test_performance_01(self):
+        """Check performance of Tesselate() method: case 01."""
+        shape = geom_builder.ImportBREP(join(data_dir, 'test_performance_01.brep'))
+        with no_longer_than(5):
+            geom_builder.Tesselate(shape, 0.17, False, 20)
+
+if __name__ == "__main__":
+    main()
diff --git a/test/tests.set b/test/tests.set
new file mode 100644 (file)
index 0000000..5464848
--- /dev/null
@@ -0,0 +1,22 @@
+# Copyright (C) 2015-2021  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+
+SET(ALL_TESTS
+  test_perf_01.py
+  )