* 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.
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;
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;
}
}
//=============================================================================
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 );
}
//=============================================================================
virtual GEOM::shape_type GetMinShapeType();
+ virtual GEOM::shape_type GetMaxShapeType();
+
virtual void SetName(const char* theName);
virtual char* GetName();
# 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,
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,
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 );