From f259a8b0372f21a7fe65e13456fd23a20126f37c Mon Sep 17 00:00:00 2001 From: dbv Date: Thu, 7 Apr 2016 12:11:20 +0300 Subject: [PATCH] Issue #1343 Fixes --- .../FeaturesPlugin_Validators.cpp | 47 +++++++------------ src/FeaturesPlugin/extrusion_widget.xml | 2 +- src/FeaturesPlugin/extrusioncut_widget.xml | 2 +- src/FeaturesPlugin/extrusionfuse_widget.xml | 2 +- src/FeaturesPlugin/revolution_widget.xml | 1 - src/FeaturesPlugin/revolutioncut_widget.xml | 1 - src/FeaturesPlugin/revolutionfuse_widget.xml | 1 - src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp | 21 +++++++-- 8 files changed, 36 insertions(+), 41 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 9e5a3a3b9..0de4d856a 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -222,21 +222,13 @@ bool FeaturesPlugin_ValidatorCanBeEmpty::isValid(const std::shared_ptr& theArguments, std::string& theError) const { - if(theArguments.size() != 5 && theArguments.size() != 6) { - theError = "Validator should be used with 6 parameters for extrusion and with 5 for revolution."; + if(theArguments.size() != 2) { + theError = "Validator should be used with 2 parameters for extrusion."; return false; } std::list::const_iterator anArgsIt = theArguments.begin(), aLast = theArguments.end(); - std::string aSelectedMethod; - if(theFeature->string(*anArgsIt)) { - aSelectedMethod = theFeature->string(*anArgsIt)->value(); - } - ++anArgsIt; - std::string aCreationMethod = *anArgsIt; - ++anArgsIt; - AttributePtr aCheckAttribute = theFeature->attribute(*anArgsIt); ++anArgsIt; @@ -244,33 +236,26 @@ bool FeaturesPlugin_ValidatorCanBeEmpty::isValid(const std::shared_ptrselection(*anArgsIt); + if(!aSelAttr.get()) { + theError = "Could not get selection attribute \"" + *anArgsIt + "\"."; + return false; } - for(; anArgsIt != theArguments.cend(); ++anArgsIt) { - AttributeSelectionPtr aSelAttr = theFeature->selection(*anArgsIt); - if(!aSelAttr.get()) { - theError = "Could not get selection attribute \"" + *anArgsIt + "\"."; + GeomShapePtr aShape = aSelAttr->value(); + if(!aShape.get()) { + ResultPtr aContext = aSelAttr->context(); + if(!aContext.get()) { + theError = "Selection attribute \"" + *anArgsIt + "\" can not be empty."; return false; } - GeomShapePtr aShape = aSelAttr->value(); - if(!aShape.get()) { - ResultPtr aContext = aSelAttr->context(); - if(!aContext.get()) { - theError = "Selection attribute \"" + *anArgsIt + "\" can not be empty."; - return false; - } - - aShape = aContext->shape(); - } + aShape = aContext->shape(); + } - if(!aShape.get()) { - theError = "Selection attribute \"" + *anArgsIt + "\" can not be empty."; - return false; - } + if(!aShape.get()) { + theError = "Selection attribute \"" + *anArgsIt + "\" can not be empty."; + return false; } return true; diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index f02bd84f2..9ed078fbb 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -83,5 +83,5 @@ - + diff --git a/src/FeaturesPlugin/extrusioncut_widget.xml b/src/FeaturesPlugin/extrusioncut_widget.xml index e6feeafd7..7f6bf48ff 100755 --- a/src/FeaturesPlugin/extrusioncut_widget.xml +++ b/src/FeaturesPlugin/extrusioncut_widget.xml @@ -92,5 +92,5 @@ - + diff --git a/src/FeaturesPlugin/extrusionfuse_widget.xml b/src/FeaturesPlugin/extrusionfuse_widget.xml index 1f8046c3a..f6d9675c9 100644 --- a/src/FeaturesPlugin/extrusionfuse_widget.xml +++ b/src/FeaturesPlugin/extrusionfuse_widget.xml @@ -92,5 +92,5 @@ - + diff --git a/src/FeaturesPlugin/revolution_widget.xml b/src/FeaturesPlugin/revolution_widget.xml index bf0607ecf..facc8895d 100644 --- a/src/FeaturesPlugin/revolution_widget.xml +++ b/src/FeaturesPlugin/revolution_widget.xml @@ -83,5 +83,4 @@ - diff --git a/src/FeaturesPlugin/revolutioncut_widget.xml b/src/FeaturesPlugin/revolutioncut_widget.xml index d41197a7a..06730b5e1 100644 --- a/src/FeaturesPlugin/revolutioncut_widget.xml +++ b/src/FeaturesPlugin/revolutioncut_widget.xml @@ -92,5 +92,4 @@ - diff --git a/src/FeaturesPlugin/revolutionfuse_widget.xml b/src/FeaturesPlugin/revolutionfuse_widget.xml index 01eb5f5eb..e023b8ed4 100644 --- a/src/FeaturesPlugin/revolutionfuse_widget.xml +++ b/src/FeaturesPlugin/revolutionfuse_widget.xml @@ -92,5 +92,4 @@ - diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp index d8599e767..b9d9a670e 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp @@ -111,6 +111,7 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, } // Getting direction. + gp_Pnt aLoc; gp_Vec aDirVec; std::shared_ptr aBaseLoc; std::shared_ptr aBaseDir; @@ -120,21 +121,33 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, if(aBaseShape.ShapeType() == TopAbs_VERTEX || aBaseShape.ShapeType() == TopAbs_EDGE || aFindPlane.Found() != Standard_True) { // Direction and both bounding planes should be set or empty. - if(!theDirection.get() || (isBoundingShapesSet && (!theToShape.get() || !theFromShape.get()))) { + if(!theDirection.get()) { return; } aBaseDir = theDirection; aDirVec = theDirection->impl(); + gp_XYZ aDirXYZ = aDirVec.XYZ(); + Standard_Real aMinParam = std::numeric_limits::max(); + + for(TopExp_Explorer anExp(aBaseShape, TopAbs_VERTEX); anExp.More(); anExp.Next()) { + const TopoDS_Shape& aVertex = anExp.Current(); + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aVertex)); + double aParam = aDirXYZ.Dot(aPnt.XYZ()); + if(aParam < aMinParam) { + aMinParam = aParam; + aLoc = aPnt; + } + } } else { Handle(Geom_Plane) aPlane = aFindPlane.Plane(); - gp_Pnt aLoc = aPlane->Axis().Location(); + aLoc = aPlane->Axis().Location(); aDirVec = aPlane->Axis().Direction(); - aBaseLoc.reset(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z())); aBaseDir.reset(new GeomAPI_Dir(aDirVec.X(), aDirVec.Y(), aDirVec.Z())); - aBasePlane = GeomAlgoAPI_FaceBuilder::planarFace(aBaseLoc, aBaseDir); } + aBaseLoc.reset(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z())); + aBasePlane = GeomAlgoAPI_FaceBuilder::planarFace(aBaseLoc, aBaseDir); TopoDS_Shape aResult; if(!isBoundingShapesSet) { -- 2.39.2