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;
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;
</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>
<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>
<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>
</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>
<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>
<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>
}
// Getting direction.
+ gp_Pnt aLoc;
gp_Vec aDirVec;
std::shared_ptr<GeomAPI_Pnt> aBaseLoc;
std::shared_ptr<GeomAPI_Dir> aBaseDir;
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) {