Create returns FixSmallSolid;
---Purpose: Construct
+ SetFixMode (me: mutable; theMode: Integer);
+ ---Purpose: Set working mode for operator:
+ -- - theMode = 0 use both WidthFactorThreshold and VolumeThreshold parameters
+ -- - theMode = 1 use only WidthFactorThreshold parameter
+ -- - theMode = 2 use only VolumeThreshold parameter
+
SetVolumeThreshold (me: mutable; theThreshold: Real = -1.0);
---Purpose: Set or clear volume threshold for small solids
IsSmall (me; theSolid: Shape from TopoDS) returns Boolean is private;
+ IsUsedWidthFactorThreshold (me) returns Boolean is private;
+
+ IsUsedVolumeThreshold (me) returns Boolean is private;
+
fields
+ myFixMode : Integer;
myVolumeThreshold : Real;
myWidthFactorThreshold : Real;
//purpose : Construct
//=======================================================================
ShapeFix_FixSmallSolid::ShapeFix_FixSmallSolid()
- : myVolumeThreshold (Precision::Infinite())
+ : myFixMode (0)
+ , myVolumeThreshold (Precision::Infinite())
, myWidthFactorThreshold (Precision::Infinite()) {}
+//=======================================================================
+//function : SetFixMode
+//purpose : Set the mode for applying fixes of small solids.
+//=======================================================================
+void ShapeFix_FixSmallSolid::SetFixMode (
+ const Standard_Integer theMode)
+{
+ myFixMode = (theMode < 0 || theMode > 2) ? 0 : theMode;
+}
+
//=======================================================================
//function : SetVolumeThreshold
//purpose : Set or clear volume threshold for small solids
//=======================================================================
Standard_Boolean ShapeFix_FixSmallSolid::IsThresholdsSet() const
{
- return myVolumeThreshold < Precision::Infinite()
- || myWidthFactorThreshold < Precision::Infinite();
+ return (IsUsedVolumeThreshold() && myVolumeThreshold < Precision::Infinite()) ||
+ (IsUsedWidthFactorThreshold() && myWidthFactorThreshold < Precision::Infinite());
}
//=======================================================================
Standard_Boolean ShapeFix_FixSmallSolid::IsSmall (const TopoDS_Shape& theSolid)
const
{
- // If the volume threshold is set and the solid's volume exceeds it,
- // consider the solid as not small
+ // If the volume threshold is used and set, and the solid's volume exceeds
+ // threshold value, consider the solid as not small
Standard_Real aVolume = ShapeVolume (theSolid);
- if (aVolume > myVolumeThreshold)
+ if (IsUsedVolumeThreshold() && aVolume > myVolumeThreshold)
return Standard_False;
- // If the width factor threshold is set
- // and the solid's width factor exceeds it
+ // If the width factor threshold is used and set,
+ // and the solid's width factor exceeds threshold value,
// consider the solid as not small
- if (myWidthFactorThreshold < Precision::Infinite())
+ if (IsUsedWidthFactorThreshold() && myWidthFactorThreshold < Precision::Infinite())
{
Standard_Real anArea = ShapeArea (theSolid);
if (aVolume > myWidthFactorThreshold * anArea * 0.5)
// Both thresholds are met - consider the solid as small
return Standard_True;
}
+//=======================================================================
+//function : IsUsedWidthFactorThreshold
+//purpose : Check if width factor threshold criterion is used
+//=======================================================================
+Standard_Boolean ShapeFix_FixSmallSolid::IsUsedWidthFactorThreshold() const
+{
+ return myFixMode == 0 || myFixMode == 1;
+}
+//=======================================================================
+//function : IsUsedVolumeThreshold
+//purpose : Check if volume threshold criterion is used
+//=======================================================================
+Standard_Boolean ShapeFix_FixSmallSolid::IsUsedVolumeThreshold() const
+{
+ return myFixMode == 0 || myFixMode == 2;
+}