Salome HOME
Mantis issue 0021079: overload a global hypo by a local hypo on subshape identical...
authorjfa <jfa@opencascade.com>
Wed, 15 Dec 2010 14:41:17 +0000 (14:41 +0000)
committerjfa <jfa@opencascade.com>
Wed, 15 Dec 2010 14:41:17 +0000 (14:41 +0000)
doc/salome/gui/GEOM/input/tui_measurement_tools.doc
src/GEOM_SWIG/GEOM_TestMeasures.py
src/GEOM_SWIG/geompyDC.py

index 0112bd0da4420525ac24b1c74deafc5dced56cd8..f8dbcd38c42efef3fcdc4b6ee12e2a7567c7837c 100644 (file)
@@ -357,6 +357,20 @@ print "\nBox 100x30x100 description:"
 print Descr
 \endcode
 
+<br><h2>NbShapes and ShapeInfo</h2>
+
+\code
+import geompy
+
+# create a box
+box = geompy.MakeBoxDXDYDZ(100,30,100)
+nbSolids = geompy.NbShapes(box, geompy.ShapeType["SOLID"])
+print "\nBox 100x30x100 quantity of solids:", nbSolids
+boxInfo = geompy.ShapeInfo(box)
+print "\nBox 100x30x100 shapes:"
+print boxInfo
+\endcode
+
 <br><h2>Check Shape</h2>
 
 \code
index 3d7bcc844fcc1556d0dd363fdf8e6c97d8aeaee6..8eca09311fd749326e12c8e641d78e86c704640e 100644 (file)
@@ -53,6 +53,17 @@ def TestMeasureOperations (geompy, math):
   print "\nBox 10x30x70 description:"
   print Descr
 
+  ####### NbShapes #######
+
+  NbSolids = geompy.NbShapes(box, geompy.ShapeType["SOLID"])
+  print "\nBox 10x30x70 quantity of solids:", NbSolids
+
+  ####### ShapeInfo #######
+
+  BoxInfo = geompy.ShapeInfo(box)
+  print "\nBox 10x30x70 shapes:"
+  print BoxInfo
+
   ####### BasicProperties #######
 
   Props = geompy.BasicProperties(box)
index fc2081f326efbd7b9818090fad09a3d9eee9f7f5..4f0bafa3223c70dc3f551dfac8b336a6999ca569 100644 (file)
@@ -3411,6 +3411,42 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             RaiseIfFailed("WhatIs", self.MeasuOp)
             return aDescr
 
+        ## Obtain quantity of shapes of the given type in \a theShape.
+        #  If \a theShape is of type \a theType, it is also counted.
+        #  @param theShape Shape to be described.
+        #  @return Quantity of shapes of type \a theType in \a theShape.
+        #
+        #  @ref tui_measurement_tools_page "Example"
+        def NbShapes (self, theShape, theType):
+            # Example: see GEOM_TestMeasures.py
+            listSh = self.SubShapeAllIDs(theShape, theType)
+            Nb = len(listSh)
+            if theShape.GetShapeType()._v == theType:
+                Nb = Nb + 1
+                pass
+            return Nb
+
+        ## Obtain quantity of shapes of each type in \a theShape.
+        #  The \a theShape is also counted.
+        #  @param theShape Shape to be described.
+        #  @return Dictionary of shape types with bound quantities of shapes.
+        #
+        #  @ref tui_measurement_tools_page "Example"
+        def ShapeInfo (self, theShape):
+            # Example: see GEOM_TestMeasures.py
+            aDict = {}
+            for typeSh in ShapeType:
+                if typeSh != "AUTO" and typeSh != "SHAPE":
+                    listSh = self.SubShapeAllIDs(theShape, ShapeType[typeSh])
+                    Nb = len(listSh)
+                    if theShape.GetShapeType()._v == ShapeType[typeSh]:
+                        Nb = Nb + 1
+                        pass
+                    aDict[typeSh] = Nb
+                    pass
+                pass
+            return aDict
+
         ## Get a point, situated at the centre of mass of theShape.
         #  @param theShape Shape to define centre of mass of.
         #  @return New GEOM_Object, containing the created point.