From b0a70a88ca0ed35259e1f3249e5f0342a57432d1 Mon Sep 17 00:00:00 2001 From: Florian BRUNET Date: Mon, 4 May 2015 15:04:24 +0200 Subject: [PATCH] Minor fixes to handle boundary values of the angle for the portion of cylinder primitive. --- src/GEOM_SWIG/geomBuilder.py | 12 ++++++++---- src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index ccbad10f6..5bbfc8e60 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -3055,10 +3055,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): theR,theH,theA,Parameters = ParseParameters(theR, theH, theA) if flag: theA = theA*math.pi/180. - anObj = self.PrimOp.MakeCylinderPntVecRHA(thePnt, theAxis, theR, theH, theA) - RaiseIfFailed("MakeCylinderPntVecRHA", self.PrimOp) - anObj.SetParameters(Parameters) - self._autoPublish(anObj, theName, "cylinder") + anObj = self.PrimOp.MakeCylinderPntVecRHA(thePnt, theAxis, theR, theH, theA) + if theA<=0. or theA>=2*math.pi: + raise ValueError("The angle parameter should be strictly between 0 and 2*pi.") + RaiseIfFailed("MakeCylinderPntVecRHA", self.PrimOp) + anObj.SetParameters(Parameters) + self._autoPublish(anObj, theName, "cylinder") return anObj ## Create a cylinder with given radius and height at @@ -3137,6 +3139,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): if flag: theA = theA*math.pi/180. anObj = self.PrimOp.MakeCylinderRHA(theR, theH, theA) + if theA<=0. or theA>=2*math.pi: + raise ValueError("The angle parameter should be strictly between 0 and 2*pi.") RaiseIfFailed("MakeCylinderRHA", self.PrimOp) anObj.SetParameters(Parameters) self._autoPublish(anObj, theName, "cylinder") diff --git a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx index 9149eee9f..fd30c9b44 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_CylinderDlg.cxx @@ -411,7 +411,7 @@ bool PrimitiveGUI_CylinderDlg::isValid (QString& msg) { ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && - ( GroupDimensions->checkBox->isChecked() || GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) ); + ( !GroupDimensions->checkBox->isChecked() || GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) ); if ( GroupDimensions->checkBox->isChecked() && ( GroupDimensions->SpinBox_DZ->value() <= 0. || GroupDimensions->SpinBox_DZ->value() >= 360. ) ) { msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n"; -- 2.39.2