]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Documentation and unit test
authorJérôme <jerome.lucas@cesgenslab.fr>
Mon, 16 Nov 2020 17:33:03 +0000 (18:33 +0100)
committerJérôme <jerome.lucas@cesgenslab.fr>
Mon, 16 Nov 2020 17:33:03 +0000 (18:33 +0100)
src/FeaturesPlugin/Test/TestBoundingBox.py [new file with mode: 0644]
src/FeaturesPlugin/doc/FeaturesPlugin.rst
src/FeaturesPlugin/doc/TUI_BoundingBoxFeature.rst [new file with mode: 0644]
src/FeaturesPlugin/doc/boundingBoxFeature.rst [new file with mode: 0644]
src/FeaturesPlugin/doc/examples/createBoundingBox.py [new file with mode: 0644]
src/FeaturesPlugin/doc/images/BoundinBoxResult.png [new file with mode: 0644]
src/FeaturesPlugin/doc/images/bounding.png [new file with mode: 0644]
src/FeaturesPlugin/doc/images/boundingBoxPropertyPanel.png [new file with mode: 0644]
src/FeaturesPlugin/doc/images/objectBoundinBox.png [new file with mode: 0644]
src/GeomAlgoAPI/CMakeLists.txt

diff --git a/src/FeaturesPlugin/Test/TestBoundingBox.py b/src/FeaturesPlugin/Test/TestBoundingBox.py
new file mode 100644 (file)
index 0000000..e3d7d24
--- /dev/null
@@ -0,0 +1,82 @@
+# 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 Bounding Box  
+#=========================================================================
+def test_Bounding_Box():
+
+    model.begin()
+    file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Step","screw.step")
+    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()
+    ### Create BoundingBox
+    BoundingBox_1 = model.getBoundingBox(Part_1_doc, model.selection("SOLID", "screw_1"))
+    model.end()
+
+    myDelta = 1e-6
+    Props = model.getBasicProperties(Part_1_doc,model.selection("SOLID", "BoundingBox_1_1"))
+
+    print(" Basic Properties:")
+    print(" Wires length: ", Props[0])
+    print(" Surface area: ", Props[1])
+    print(" Volume      : ", Props[2]) 
+    
+    aReflength = 0.32855301948678
+    aReslength = Props[0]
+    assert (math.fabs(aReslength - aReflength) < myDelta), "The surface is wrong: expected = {0}, real = {1}".format(aReflength, aReslength)
+
+    aRefSurface = 0.0041640657342782
+    aResSurface = Props[1]
+    assert (math.fabs(aResSurface - aRefSurface) < myDelta), "The surface is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface)
+
+    aRefVolume = 1.6785355394103e-05
+    aResVolume = Props[2]
+    assert (math.fabs(aResVolume - aRefVolume) < myDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefVolume, aResVolume)
+
+    
+if __name__ == '__main__':
+
+    test_Bounding_Box()
+        
+    #=========================================================================
+    # End of test
+    #=========================================================================
index fb8e2a344b707376d72df48edb52804796a2e7bf..b63fb696dc2f795afedf0a072401ba35f22cd213 100644 (file)
@@ -24,6 +24,7 @@ Features plug-in provides a set of common topological operations. It implements
    importResultFeature.rst
    linearCopyFeature.rst
    measurementFeature.rst
+   boundingBoxFeature.rst
    pipeFeature.rst
    placementFeature.rst
    recoverFeature.rst
diff --git a/src/FeaturesPlugin/doc/TUI_BoundingBoxFeature.rst b/src/FeaturesPlugin/doc/TUI_BoundingBoxFeature.rst
new file mode 100644 (file)
index 0000000..6a94972
--- /dev/null
@@ -0,0 +1,11 @@
+
+  .. _tui_create_Bounding_Box:
+
+Create bounding box
+===================
+
+.. literalinclude:: examples/createBoundingBox.py 
+    :linenos:
+    :language: python
+
+:download:`Download this script <examples/createBoundingBox.py>`
diff --git a/src/FeaturesPlugin/doc/boundingBoxFeature.rst b/src/FeaturesPlugin/doc/boundingBoxFeature.rst
new file mode 100644 (file)
index 0000000..3cab6c3
--- /dev/null
@@ -0,0 +1,51 @@
+.. |boundingBox.icon|    image:: images/bounding.png
+
+Bounding box
+============
+
+The **Bounding box** feature displays the bounding box of sub-elements of a geometrical object (shape).
+
+The property panel displays the coordinates of inferior (**Min**) and superior (**Max**) points.
+the resulting bounding box can be created via a dedicated check-box **Create Box**. If this last is checked corresponding result and feature would be created. 
+
+If the check-box **Create Box** isn't checked, **Apply** button does not generate any result and has the same effect as **Cancel** for this feature.  
+
+To display the bounding box in the active part:
+
+#. select in the Main Menu *Inspection - > Bounding box* item  or
+#. click |boundingBox.icon| **Bounding box** button in the toolbar
+
+Coordinates of the two points (inferior and superior) of the bounding box can be displayed for a selected object in the property panel : 
+
+.. figure:: images/boundingBoxPropertyPanel.png
+   :align: center
+
+   Bounding Box
+
+
+Input fields:
+
+- **Object** contains object selected in 3D OCC viewer or object browser. 
+- **Create box** check-box allow the creation of the bounding box (result and feature). 
+
+Note, the coordinates of two points displayed can be selected.
+
+**TUI Command**:
+
+.. py:function:: model.getBoundingBox(Part_doc, shape)
+    :param part: The current part object.
+    :param object: A shape in format *model.selection("Type", shape)*.
+    :return: Created bounding box.
+
+Result
+""""""
+
+Result of **Bounding box** where **Create box** is checked.
+
+.. figure:: images/BoundinBoxResult.png
+   :align: center
+
+   Object selected
+
+**See Also** a sample TUI Script of :ref:`tui_create_Bounding_Box` operation.
\ No newline at end of file
diff --git a/src/FeaturesPlugin/doc/examples/createBoundingBox.py b/src/FeaturesPlugin/doc/examples/createBoundingBox.py
new file mode 100644 (file)
index 0000000..69143fe
--- /dev/null
@@ -0,0 +1,13 @@
+from salome.shaper import model
+import os
+
+model.begin()
+file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Step","screw.step")
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Import_1 = model.addImport(Part_1_doc,file_path)
+### Create BoundingBox
+BoundingBox_1 = model.getBoundingBox(Part_1_doc, model.selection("SOLID", "screw_1"))
+model.do()
+model.end()
diff --git a/src/FeaturesPlugin/doc/images/BoundinBoxResult.png b/src/FeaturesPlugin/doc/images/BoundinBoxResult.png
new file mode 100644 (file)
index 0000000..89eb127
Binary files /dev/null and b/src/FeaturesPlugin/doc/images/BoundinBoxResult.png differ
diff --git a/src/FeaturesPlugin/doc/images/bounding.png b/src/FeaturesPlugin/doc/images/bounding.png
new file mode 100644 (file)
index 0000000..5a77a45
Binary files /dev/null and b/src/FeaturesPlugin/doc/images/bounding.png differ
diff --git a/src/FeaturesPlugin/doc/images/boundingBoxPropertyPanel.png b/src/FeaturesPlugin/doc/images/boundingBoxPropertyPanel.png
new file mode 100644 (file)
index 0000000..0da9dda
Binary files /dev/null and b/src/FeaturesPlugin/doc/images/boundingBoxPropertyPanel.png differ
diff --git a/src/FeaturesPlugin/doc/images/objectBoundinBox.png b/src/FeaturesPlugin/doc/images/objectBoundinBox.png
new file mode 100644 (file)
index 0000000..fbdb91e
Binary files /dev/null and b/src/FeaturesPlugin/doc/images/objectBoundinBox.png differ
index ade5c32d5af081e88cac2f96a637f77db4eb7c2d..ed4b96a73f776704ffad40efa5509281c85fc32e 100644 (file)
@@ -33,6 +33,7 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_Prism.h
     GeomAlgoAPI_Revolution.h
     GeomAlgoAPI_Boolean.h
+    GeomAlgoAPI_BasicProperties.h
     GeomAlgoAPI_BoundingBox.h
     GeomAlgoAPI_ThroughAll.h
     GeomAlgoAPI_Rotation.h
@@ -99,6 +100,7 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_Prism.cpp
     GeomAlgoAPI_Revolution.cpp
     GeomAlgoAPI_Boolean.cpp
+    GeomAlgoAPI_BasicProperties.cpp
     GeomAlgoAPI_BoundingBox.cpp
     GeomAlgoAPI_ThroughAll.cpp
     GeomAlgoAPI_Rotation.cpp