if(theInitFlags & InitBaseObjectsList) {
data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
myCurrentSelectionType = selectionList(BASE_OBJECTS_ID())->selectionType();
+ selectionList(BASE_OBJECTS_ID())->setWholeResultAllowed(true);
}
}
#include <GeomAPI_PlanarEdges.h>
#include <GeomAPI_ShapeIterator.h>
+#include <GeomValidators_ShapeType.h>
+
//==================================================================================================
void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody,
const ListOfShape& theBaseShapes,
theError = "Error: Selected sketches does not have results.";
return false;
}
- int aFacesNum = aConstruction->facesNum();
+ GeomValidators_ShapeType::TypeOfShape aSelType =
+ GeomValidators_ShapeType::shapeType(theSelectionList->selectionType());
+ int aFacesNum = 0;
+ if (aSelType != GeomValidators_ShapeType::Vertex &&
+ aSelType != GeomValidators_ShapeType::Edge)
+ aFacesNum = aConstruction->facesNum();
if(aFacesNum == 0) {
// Probably it can be construction.
aBaseShape = aConstruction->shape();
if(aBaseShape.get() && !aBaseShape->isNull()) {
GeomAPI_Shape::ShapeType aST = aBaseShape->shapeType();
- if(aST != GeomAPI_Shape::VERTEX && aST != GeomAPI_Shape::EDGE &&
- aST != GeomAPI_Shape::WIRE &&
- aST != GeomAPI_Shape::FACE && aST != GeomAPI_Shape::SHELL) {
+ if(aST == GeomAPI_Shape::SOLID || aST == GeomAPI_Shape::COMPSOLID) {
theError = "Error: Selected shapes has unsupported type.";
return false;
}
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAlgoAPI_WireBuilder.h>
+#include <algorithm>
+
#define _USE_MATH_DEFINES
#include <math.h>
if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
AttributeSelectionListPtr aListAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+
+ const std::string& aSelType = aListAttr->selectionType();
+ std::list<std::string> anApplicableTypes;
+ switch (GeomValidators_ShapeType::shapeType(aSelType)) {
+ case GeomValidators_ShapeType::Vertex:
+ anApplicableTypes.push_back("vertex");
+ break;
+ case GeomValidators_ShapeType::Edge:
+ anApplicableTypes.push_back("edge");
+ anApplicableTypes.push_back("wire");
+ break;
+ case GeomValidators_ShapeType::Face:
+ anApplicableTypes.push_back("face");
+ anApplicableTypes.push_back("shell");
+ break;
+ default:
+ anApplicableTypes = theArguments;
+ break;
+ }
+
for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
// If at least one attribute is invalid, the result is false.
- if(!isValidAttribute(aListAttr->value(anIndex), theArguments, theError)) {
+ if(!isValidAttribute(aListAttr->value(anIndex), anApplicableTypes, theError)) {
return false;
}
}
aContextShape = aContext->shape();
if(aShape->isEqual(aContextShape)) {
- // Whole construction selected. Check that it have faces.
- if(aConstruction->facesNum() > 0) {
+ // Whole construction selected. Check that it has faces.
+ if((theArguments.front() == "face" && aConstruction->facesNum() > 0) ||
+ theArguments.front() == "edge") {
return true;
}
} else {
return MyShapeTypes[aType];
// LCOV_EXCL_START
- Events_InfoMessage("Shape type defined in XML is not implemented!").send();
+ //Events_InfoMessage("Shape type defined in XML is not implemented!").send();
return AnyShape;
// LCOV_EXCL_STOP
}
GEOMVALIDATORS_EXPORT virtual bool isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const;
-protected:
+
/// Convert string to TypeOfShape value
/// \param theType a string value
GEOMVALIDATORS_EXPORT static TypeOfShape shapeType(const std::string& theType);
+protected:
/// Returns true if the attibute's object type satisfies the argument value
/// \param[in] theAttribute a checked attribute
/// \param[in] theShapeType a type of shape