From e450289112dfe41e289924ab7f3558233646abde Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 11 Feb 2015 19:15:22 +0300 Subject: [PATCH] 0022862: EDF GEOM: MakeFillet returns a compound --- src/GEOMImpl/GEOMImpl_FilletDriver.cxx | 2 +- src/GEOMUtils/GEOMUtils.cxx | 19 +++++++++++++++++++ src/GEOMUtils/GEOMUtils.hxx | 12 ++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/GEOMImpl/GEOMImpl_FilletDriver.cxx b/src/GEOMImpl/GEOMImpl_FilletDriver.cxx index f49fb08f7..034d2f274 100644 --- a/src/GEOMImpl/GEOMImpl_FilletDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FilletDriver.cxx @@ -130,7 +130,7 @@ Standard_Integer GEOMImpl_FilletDriver::Execute(TFunction_Logbook& log) const if (!fill.IsDone()) { StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius"); } - aShape = fill.Shape(); + aShape = GEOMUtils::ReduceCompound( fill.Shape() ); if (aShape.IsNull()) return 0; diff --git a/src/GEOMUtils/GEOMUtils.cxx b/src/GEOMUtils/GEOMUtils.cxx index 3087c82d3..6d9643f0c 100644 --- a/src/GEOMUtils/GEOMUtils.cxx +++ b/src/GEOMUtils/GEOMUtils.cxx @@ -1174,3 +1174,22 @@ bool GEOMUtils::Write( const TopoDS_Shape& shape, const char* fileName ) { return BRepTools::Write( shape, fileName ); } + +TopoDS_Shape GEOMUtils::ReduceCompound( const TopoDS_Shape& shape ) +{ + TopoDS_Shape result = shape; + + if ( shape.ShapeType() == TopAbs_COMPOUND || + shape.ShapeType() == TopAbs_COMPSOLID ) { + + TopTools_ListOfShape l; + + TopoDS_Iterator it ( shape ); + for ( ; it.More(); it.Next() ) + l.Append( it.Value() ); + if ( l.Extent() == 1 && l.First() != shape ) + result = ReduceCompound( l.First() ); + } + + return result; +} diff --git a/src/GEOMUtils/GEOMUtils.hxx b/src/GEOMUtils/GEOMUtils.hxx index 2a35dceda..b673ea807 100644 --- a/src/GEOMUtils/GEOMUtils.hxx +++ b/src/GEOMUtils/GEOMUtils.hxx @@ -300,6 +300,18 @@ namespace GEOMUtils */ Standard_EXPORT bool Write( const TopoDS_Shape& shape, const char* fileName ); + + /*! + * \brief Extract single SOLID from COMPSOLID or COMPOUND. + * + * If the argument shape is a COMPUND or COMPSOLID and there's + * only single simple-shape type inside, this sub-shape is returned as a result; + * otherwise, the shape is not changed. + * + * \param shape compound or compsolid being processed. + * \retval TopoDS_Shape resulting shape + */ + Standard_EXPORT TopoDS_Shape ReduceCompound( const TopoDS_Shape& shape ); }; #endif -- 2.39.2