From e89a0e13c10b9d7a47db5df6eb6e3763a1d870af Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 15 Dec 2010 14:41:17 +0000 Subject: [PATCH] Mantis issue 0021079: overload a global hypo by a local hypo on subshape identical to main shape. --- .../gui/GEOM/input/tui_measurement_tools.doc | 14 ++++++++ src/GEOM_SWIG/GEOM_TestMeasures.py | 11 ++++++ src/GEOM_SWIG/geompyDC.py | 36 +++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/doc/salome/gui/GEOM/input/tui_measurement_tools.doc b/doc/salome/gui/GEOM/input/tui_measurement_tools.doc index 0112bd0da..f8dbcd38c 100644 --- a/doc/salome/gui/GEOM/input/tui_measurement_tools.doc +++ b/doc/salome/gui/GEOM/input/tui_measurement_tools.doc @@ -357,6 +357,20 @@ print "\nBox 100x30x100 description:" print Descr \endcode +

NbShapes and ShapeInfo

+ +\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 +

Check Shape

\code diff --git a/src/GEOM_SWIG/GEOM_TestMeasures.py b/src/GEOM_SWIG/GEOM_TestMeasures.py index 3d7bcc844..8eca09311 100644 --- a/src/GEOM_SWIG/GEOM_TestMeasures.py +++ b/src/GEOM_SWIG/GEOM_TestMeasures.py @@ -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) diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index fc2081f32..4f0bafa32 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -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. -- 2.39.2