From: Jérôme Date: Mon, 16 Nov 2020 14:48:46 +0000 (+0100) Subject: Add Documentation and unit test X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aabad9fd3b7ab6713fe27af3a213eac73c54bc75;p=modules%2Fshaper.git Add Documentation and unit test --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 8d7002a61..ab56bb256 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -701,4 +701,5 @@ ADD_UNIT_TESTS(TestExtrusion.py TestFillet1D_Wire_3.py TestFillet1D_Wire_4.py TestFillet1D_Wire_5.py + TestBasicProperties.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.h b/src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.h index df95636d1..a41e85365 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_GeometryCalculation.h @@ -91,7 +91,7 @@ public: FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); /// Reimplemented from ModelAPI_Feature::isMacro(). Returns true. - virtual bool isMacro() const { return true; } + FEATURESPLUGIN_EXPORT virtual bool isMacro() const { return true; } /// Use plugin manager for features creation FeaturesPlugin_GeometryCalculation(); diff --git a/src/FeaturesPlugin/Test/TestBasicProperties.py b/src/FeaturesPlugin/Test/TestBasicProperties.py new file mode 100644 index 000000000..2604c9ac3 --- /dev/null +++ b/src/FeaturesPlugin/Test/TestBasicProperties.py @@ -0,0 +1,80 @@ +# Copyright (C) 2014-2020 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 +# + +""" + Unit test of ... +""" +#========================================================================= +# Initialization of the test +#========================================================================= + +import salome + +import os +import math + +from ModelAPI import * +from salome.shaper import model + + + +__updated__ = "2020-11-12" + + +#========================================================================= +# test basic properties +#========================================================================= +def test_Basic_properties(): + + model.begin() + file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Brep","box1.brep") + partSet = model.moduleDocument() + Part_1 = model.addPart(partSet) + Part_1_doc = Part_1.document() + Import_1 = model.addImport(Part_1_doc,file_path) + model.do() + + myDelta = 1e-6 + Props = model.getBasicProperties(Part_1_doc,model.selection("SOLID", "box1_1")) + + print(" Basic Properties:") + print(" Wires length: ", Props[0]) + print(" Surface area: ", Props[1]) + print(" Volume : ", Props[2]) + + aReflength = 2400 + aReslength = Props[0] + assert (math.fabs(aReslength - aReflength) < myDelta), "The surface is wrong: expected = {0}, real = {1}".format(aReflength, aReslength) + + aRefSurface = 240000 + aResSurface = Props[1] + assert (math.fabs(aResSurface - aRefSurface) < myDelta), "The surface is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface) + + aRefVolume = 8000000 + aResVolume = Props[2] + assert (math.fabs(aResVolume - aRefVolume) < myDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefVolume, aResVolume) + + +if __name__ == '__main__': + + test_Basic_properties() + + #========================================================================= + # End of test + #========================================================================= diff --git a/src/FeaturesPlugin/doc/FeaturesPlugin.rst b/src/FeaturesPlugin/doc/FeaturesPlugin.rst index fb8e2a344..cb35ea50a 100644 --- a/src/FeaturesPlugin/doc/FeaturesPlugin.rst +++ b/src/FeaturesPlugin/doc/FeaturesPlugin.rst @@ -24,6 +24,7 @@ Features plug-in provides a set of common topological operations. It implements importResultFeature.rst linearCopyFeature.rst measurementFeature.rst + geometryCalculationFeature.rst pipeFeature.rst placementFeature.rst recoverFeature.rst diff --git a/src/FeaturesPlugin/doc/geometryCalculationFeature.rst b/src/FeaturesPlugin/doc/geometryCalculationFeature.rst new file mode 100644 index 000000000..a90d5bc8b --- /dev/null +++ b/src/FeaturesPlugin/doc/geometryCalculationFeature.rst @@ -0,0 +1,28 @@ +.. |basicproperties.icon| image:: images/basicproperties.png + +Geometry calculation +==================== + +The **Geometry calculation** feature displays basic properties of sub-elements of a geometrical object (shape). + +The basic properties displayed in the property panel are lenght, area and volume. + +**Apply** button does not generate any result and has the same effect as **Cancel** for this feature. + +To display basic properties in the active part: + +#. select in the Main Menu *Inspection - > Geometry calculation* item or +#. click |basicproperties.icon| **Geometry calculation** button in the toolbar + +The basic properties can be displayed for a selected object in the property panel : + +.. figure:: images/basicPropertiesPropertyPanel.png + :align: center + + Geometry calculation + +Input fields: + +- **Object** contains an object selected in 3D OCC viewer or object browser. + +The basic properties displayed can be selected. diff --git a/src/FeaturesPlugin/doc/images/basicPropertiesPropertyPanel.png b/src/FeaturesPlugin/doc/images/basicPropertiesPropertyPanel.png new file mode 100644 index 000000000..17f8cd7ef Binary files /dev/null and b/src/FeaturesPlugin/doc/images/basicPropertiesPropertyPanel.png differ diff --git a/src/FeaturesPlugin/doc/images/basicproperties.png b/src/FeaturesPlugin/doc/images/basicproperties.png new file mode 100644 index 000000000..f46c0da7a Binary files /dev/null and b/src/FeaturesPlugin/doc/images/basicproperties.png differ diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index 88b649b33..00dddaf5f 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -175,7 +175,7 @@ + icon="icons/Features/basicproperties.png" helpfile="geometryCalculationFeature.html" abort_confirmation="false">