Salome HOME
Issue #1343 Fixes
authordbv <dbv@opencascade.com>
Thu, 7 Apr 2016 09:11:20 +0000 (12:11 +0300)
committerdbv <dbv@opencascade.com>
Thu, 7 Apr 2016 09:11:33 +0000 (12:11 +0300)
src/FeaturesPlugin/FeaturesPlugin_Validators.cpp
src/FeaturesPlugin/extrusion_widget.xml
src/FeaturesPlugin/extrusioncut_widget.xml
src/FeaturesPlugin/extrusionfuse_widget.xml
src/FeaturesPlugin/revolution_widget.xml
src/FeaturesPlugin/revolutioncut_widget.xml
src/FeaturesPlugin/revolutionfuse_widget.xml
src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp

index 9e5a3a3b9f28653e53287d4ab3883396f04ae2ce..0de4d856a96de2bc262914492e50ad51b971cb81 100644 (file)
@@ -222,21 +222,13 @@ bool FeaturesPlugin_ValidatorCanBeEmpty::isValid(const std::shared_ptr<ModelAPI_
                                                  const std::list<std::string>& 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<std::string>::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_ptr<ModelAPI_
     return true;
   }
 
-  if(aSelectedMethod == aCreationMethod) {
-    ++anArgsIt;
-    ++anArgsIt;
+  AttributeSelectionPtr aSelAttr = theFeature->selection(*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;
index f02bd84f2c71d7fbfee5a5c5524f131afcdc7aa7..9ed078fbb49ad7a06a12800ac4e284c11926a69d 100644 (file)
@@ -83,5 +83,5 @@
     </box>
   </toolbox>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,BySizes,base,to_size,from_size,to_object,to_offset,from_object,from_offset"/>
-  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,BySizes,base,to_object,from_object,direction_object"/>
+  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="base,direction_object"/>
 </source>
index e6feeafd7cd5c16d0240892378fe750e2cc8193c..7f6bf48ff5f143cecc6484b1bc36976f3934e2c9 100755 (executable)
@@ -92,5 +92,5 @@
     <validator id="GeomValidators_ShapeType" parameters="solid"/>
   </multi_selector>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,BySizes,sketch_selection,to_size,from_size,to_object,to_offset,from_object,from_offset"/>
-  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,BySizes,base,to_object,from_object,direction_object"/>
+  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="base,direction_object"/>
 </source>
index 1f8046c3a77c88ddd4304dcedf665692af6b6a66..f6d9675c92eaa43f014b25271c762765189ea562 100644 (file)
@@ -92,5 +92,5 @@
     <validator id="GeomValidators_ShapeType" parameters="solid"/>
   </multi_selector>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,BySizes,sketch_selection,to_size,from_size,to_object,to_offset,from_object,from_offset"/>
-  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,BySizes,base,to_object,from_object,direction_object"/>
+  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="base,direction_object"/>
 </source>
index bf0607ecf42a0f0678cc19a07f583790d747edbe..facc8895d45853bc1f07408a7495c436026fccb1 100644 (file)
@@ -83,5 +83,4 @@
     </box>
   </toolbox>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,ByAngles,base,to_angle,from_angle,to_object,to_offset,from_object,from_offset"/>
-  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,ByAngles,base,to_object,from_object"/>
 </source>
index d41197a7aaa1c5deaf5b74dcf61add5930f7fc3f..06730b5e183f233a1f9cd46deb46532380ede511 100644 (file)
@@ -92,5 +92,4 @@
     <validator id="GeomValidators_ShapeType" parameters="solid"/>
   </multi_selector>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,ByAngles,sketch_selection,to_angle,from_angle,to_object,to_offset,from_object,from_offset"/>
-  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,ByAngles,base,to_object,from_object"/>
 </source>
index 01eb5f5ebb31e726f7ca808a4c01847624227d65..e023b8ed4be437eb377a38c29d992d389c34ef95 100644 (file)
@@ -92,5 +92,4 @@
     <validator id="GeomValidators_ShapeType" parameters="solid"/>
   </multi_selector>
   <validator id="GeomValidators_ZeroOffset" parameters="CreationMethod,ByAngles,sketch_selection,to_angle,from_angle,to_object,to_offset,from_object,from_offset"/>
-  <validator id="FeaturesPlugin_ValidatorCanBeEmpty" parameters="CreationMethod,ByAngles,base,to_object,from_object"/>
 </source>
index d8599e7675406d5728d8532664929d3c6ebb0bd8..b9d9a670efbe6b4957b3b599ab028b7a5e5e5721 100644 (file)
@@ -111,6 +111,7 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr&                theBaseShape,
   }
 
   // Getting direction.
+  gp_Pnt aLoc;
   gp_Vec aDirVec;
   std::shared_ptr<GeomAPI_Pnt> aBaseLoc;
   std::shared_ptr<GeomAPI_Dir> 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_Dir>();
+    gp_XYZ aDirXYZ = aDirVec.XYZ();
+    Standard_Real aMinParam = std::numeric_limits<double>::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) {