From dbb36f8babb5fa213bd05d4eaeb0e38f1817f488 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 13 Dec 2010 09:01:00 +0000 Subject: [PATCH] Issue 0020980: EDF 1226 GEOM: Detect the Resulting Type by default Re-implement to avoid regression in existing scripts --- idl/GEOM_Gen.idl | 11 +++++++++- src/GEOM_I/GEOM_Object_i.cc | 21 +++++++++++++++---- src/GEOM_I/GEOM_Object_i.hh | 2 ++ src/GEOM_SWIG/geompyDC.py | 8 +++---- .../OperationGUI_PartitionDlg.cxx | 4 ++-- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 179ecf35a..d6be57c54 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -180,10 +180,19 @@ module GEOM * This function is useful for the compounds only; for simple shapes it * exactly the same value as GetShapeType(). * Note, that compounds are procesed recursively. - * \sa GetShapeType(), GetTopologyType() + * \sa GetShapeType(), GetTopologyType(), GetMaxShapeType() */ shape_type GetMinShapeType(); + /*! + * Get a maximal type of the top-level shapes contained in the object. + * This function is useful for the compounds only; for simple shapes it + * exactly the same value as GetShapeType(). + * Note, that compounds are procesed recursively. + * \sa GetShapeType(), GetTopologyType(), GetMinShapeType() + */ + shape_type GetMaxShapeType(); + /*! * Set name of the object. * \param theName is a name which will be associated with this object. diff --git a/src/GEOM_I/GEOM_Object_i.cc b/src/GEOM_I/GEOM_Object_i.cc index ad139cb77..0dd22bdf4 100644 --- a/src/GEOM_I/GEOM_Object_i.cc +++ b/src/GEOM_I/GEOM_Object_i.cc @@ -141,7 +141,7 @@ GEOM::shape_type GEOM_Object_i::GetTopologyType() return (GEOM::shape_type)shape.ShapeType(); } -static GEOM::shape_type getMinShapeType( const TopoDS_Shape& shape ) +static GEOM::shape_type getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin ) { if ( shape.IsNull() ) return GEOM::SHAPE; @@ -153,8 +153,11 @@ static GEOM::shape_type getMinShapeType( const TopoDS_Shape& shape ) for (; it.More(); it.Next()) { TopoDS_Shape sub_shape = it.Value(); if ( sub_shape.IsNull() ) continue; - GEOM::shape_type stype = (GEOM::shape_type)sub_shape.ShapeType(); - if ( stype != GEOM::SHAPE && stype > ret ) + GEOM::shape_type stype = (GEOM::shape_type)getMinMaxShapeType( sub_shape, ismin ); + if ( stype == GEOM::SHAPE ) continue; + if ( ismin && stype > ret ) + ret = stype; + else if ( !ismin && ( ret < GEOM::SOLID || stype < ret ) ) ret = stype; } } @@ -169,7 +172,17 @@ static GEOM::shape_type getMinShapeType( const TopoDS_Shape& shape ) //============================================================================= GEOM::shape_type GEOM_Object_i::GetMinShapeType() { - return getMinShapeType( _impl->GetValue() ); + return getMinMaxShapeType( _impl->GetValue(), true ); +} + +//============================================================================= +/*! + * GetMaxShapeType + */ +//============================================================================= +GEOM::shape_type GEOM_Object_i::GetMaxShapeType() +{ + return getMinMaxShapeType( _impl->GetValue(), false ); } //============================================================================= diff --git a/src/GEOM_I/GEOM_Object_i.hh b/src/GEOM_I/GEOM_Object_i.hh index d47306aad..c7ed4c758 100644 --- a/src/GEOM_I/GEOM_Object_i.hh +++ b/src/GEOM_I/GEOM_Object_i.hh @@ -55,6 +55,8 @@ class GEOM_I_EXPORT GEOM_Object_i : public virtual POA_GEOM::GEOM_Object, public virtual GEOM::shape_type GetMinShapeType(); + virtual GEOM::shape_type GetMaxShapeType(); + virtual void SetName(const char* theName); virtual char* GetName(); diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 4c7c7919a..fe8904335 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -2552,8 +2552,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): # Example: see GEOM_TestAll.py if Limit == ShapeType["AUTO"]: # automatic detection of the most appropriate shape limit type - lim = GEOM.SOLID - for s in ListShapes: lim = max( lim, s.GetMinShapeType() ) + lim = GEOM.SHAPE + for s in ListShapes: lim = min( lim, s.GetMaxShapeType() ) Limit = lim._v pass anObj = self.BoolOp.MakePartition(ListShapes, ListTools, @@ -2582,8 +2582,8 @@ class geompyDC(GEOM._objref_GEOM_Gen): ListMaterials=[], KeepNonlimitShapes=0): if Limit == ShapeType["AUTO"]: # automatic detection of the most appropriate shape limit type - lim = GEOM.SOLID - for s in ListShapes: lim = max( lim, s.GetMinShapeType() ) + lim = GEOM.SHAPE + for s in ListShapes: lim = min( lim, s.GetMaxShapeType() ) Limit = lim._v pass anObj = self.BoolOp.MakePartitionNonSelfIntersectedShape(ListShapes, ListTools, diff --git a/src/OperationGUI/OperationGUI_PartitionDlg.cxx b/src/OperationGUI/OperationGUI_PartitionDlg.cxx index 6c4ad4bda..18e456af2 100644 --- a/src/OperationGUI/OperationGUI_PartitionDlg.cxx +++ b/src/OperationGUI/OperationGUI_PartitionDlg.cxx @@ -293,9 +293,9 @@ void OperationGUI_PartitionDlg::SelectionIntoArgument() GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true); //myListMaterials.length( 0 ); // obsolete - GEOM::shape_type type = GEOM::SOLID; + GEOM::shape_type type = GEOM::SHAPE; for (int i = 0; i < myListShapes.length(); i++) - type = qMax( type, myListShapes[i]->GetMinShapeType() ); + type = qMin( type, myListShapes[i]->GetMaxShapeType() ); int idx = qMax( 0, GroupPoints->ComboBox1->findData( type ) ); GroupPoints->ComboBox1->setCurrentIndex( idx ); -- 2.39.2