-// Copyright (C) 2014-2021 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
#include "BuildPlugin_Validators.h"
+#include "BuildPlugin_Solid.h"
+#include "BuildPlugin_Face.h"
+#include "BuildPlugin_Wire.h"
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
return false;
}
- /// remove objects of sub-type if ojects of correct type is in List, in some cases :
- /// Wire builder: wires and edges selected
- std::set<GeomAPI_Shape::ShapeType> shapeTypes;
- for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
- AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
- GeomShapePtr aShape = aSelection->value();
- if (aShape.get())
- shapeTypes.insert(aShape->shapeType());
- }
-
- std::set<int> aRemove;
- if (shapeTypes.find(GeomAPI_Shape::WIRE) != shapeTypes.end())
- {
+ if (theFeature->getKind() == BuildPlugin_Wire::ID()) {
+ /// remove objects of sub-type if ojects of correct type is in List, in some cases :
+ /// Wire builder: wires and edges selected
+ std::set<int> aRemove;
for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
GeomShapePtr aShape = aSelection->value();
if (aShape.get()) {
- auto aType = aShape->shapeType();
- if (aType == GeomAPI_Shape::EDGE)
- aRemove.insert(anIndex);
+ GeomAPI_Shape::ShapeType aType = aShape->shapeType();
+ if (aType == GeomAPI_Shape::WIRE) {
+ // check for edges
+ GeomAPI_ShapeExplorer anEdgeExp(aShape, GeomAPI_Shape::EDGE);
+ for (; anEdgeExp.more(); anEdgeExp.next()) {
+ GeomShapePtr aEdge = anEdgeExp.current();
+ for (int i = 0; i < aSelectionList->size(); ++i) {
+ AttributeSelectionPtr aSel = aSelectionList->value(i);
+ GeomShapePtr aShp = aSel->value();
+ if (aShp.get()) {
+ if (aShp->shapeType() == GeomAPI_Shape::EDGE) {
+ if (aShp->isEqual(aEdge) || aShp->isSameGeometry(aEdge))
+ aRemove.insert(i);
+ }
+ }
+ else {
+ aRemove.insert(anIndex);
+ }
+ }
+ }
+ }
}
- else
- aRemove.insert(anIndex);
}
+ if (aRemove.size() > 0)
+ aSelectionList->remove(aRemove);
}
- if (aRemove.size() > 0)
- aSelectionList->remove(aRemove);
-
GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::shapeTypeByStr(theArguments.back());
-
// Collect base shapes.
ListOfShape aListOfShapes;
for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
return false;
}
- /// remove objects of sub-type if ojects of correct type is in List, in some cases :
- /// - Face builder: edges, faces and wires selected
- /// --> remove edges and wires
- std::set<GeomAPI_Shape::ShapeType> shapeTypes;
- for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
- AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
- GeomShapePtr aShape = aSelection->value();
- if (aShape.get())
- shapeTypes.insert(aShape->shapeType());
- }
-
- std::set<int> aRemove;
- if (shapeTypes.find(GeomAPI_Shape::FACE) != shapeTypes.end())
- {
+ if (theFeature->getKind() == BuildPlugin_Face::ID()) {
+ /// remove objects of sub-type if ojects of correct type is in List, in some cases :
+ /// - Face builder: edges, faces and wires selected
+ /// --> remove edges and wires
+ std::set<int> aRemove;
for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
GeomShapePtr aShape = aSelection->value();
if (aShape.get()) {
- auto aType = aShape->shapeType();
- if (aType == GeomAPI_Shape::WIRE || aType == GeomAPI_Shape::EDGE)
- aRemove.insert(anIndex);
+ GeomAPI_Shape::ShapeType aType = aShape->shapeType();
+ if (aType == GeomAPI_Shape::FACE) {
+ // Check for wires
+ GeomAPI_ShapeExplorer anWireExp(aShape, GeomAPI_Shape::WIRE);
+ for (; anWireExp.more(); anWireExp.next()) {
+ GeomShapePtr aWire = anWireExp.current();
+ for (int i = 0; i < aSelectionList->size(); ++i) {
+ AttributeSelectionPtr aSel = aSelectionList->value(i);
+ GeomShapePtr aShp = aSel->value();
+ if (aShp.get()) {
+ if (aShp->shapeType() == GeomAPI_Shape::WIRE) {
+ if (aShp->isEqual(aWire) || aShp->isSameGeometry(aWire))
+ aRemove.insert(i);
+ }
+ }
+ else {
+ aRemove.insert(anIndex);
+ }
+ }
+ }
+
+ // check for edges
+ GeomAPI_ShapeExplorer anEdgeExp(aShape, GeomAPI_Shape::EDGE);
+ for (; anEdgeExp.more(); anEdgeExp.next()) {
+ GeomShapePtr aEdge = anEdgeExp.current();
+ for (int i = 0; i < aSelectionList->size(); ++i) {
+ AttributeSelectionPtr aSel = aSelectionList->value(i);
+ GeomShapePtr aShp = aSel->value();
+ if (aShp.get()) {
+ if (aShp->shapeType() == GeomAPI_Shape::EDGE) {
+ if (aShp->isEqual(aEdge) || aShp->isSameGeometry(aEdge))
+ aRemove.insert(i);
+ }
+ }
+ else {
+ aRemove.insert(anIndex);
+ }
+ }
+ }
+ }
}
- else
- aRemove.insert(anIndex);
}
+ if (aRemove.size() > 0)
+ aSelectionList->remove(aRemove);
}
- if (aRemove.size() > 0)
- aSelectionList->remove(aRemove);
-
bool hasEdgesOrWires = false;
bool hasFaces = false;
return false;
}
- /// remove objects of sub-type if ojects of correct type is in List, in some cases :
- /// Solid builder: faces and shapes shells or solids seleted
- /// --> remove faces
+ if (theFeature->getKind() == BuildPlugin_Solid::ID()) {
+ /// remove objects of sub-type if ojects of correct type is in List, in some cases :
+ /// Solid builder: faces and shapes shells or solids seleted
+ /// --> remove faces
- std::set<GeomAPI_Shape::ShapeType> shapeTypes;
- for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
- AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
- GeomShapePtr aShape = aSelection->value();
- if (aShape.get())
- shapeTypes.insert(aShape->shapeType());
- }
-
- std::set<int> aRemove;
- if (shapeTypes.find(GeomAPI_Shape::SHAPE) != shapeTypes.end() ||
- shapeTypes.find(GeomAPI_Shape::SOLID) != shapeTypes.end() ||
- shapeTypes.find(GeomAPI_Shape::SHELL) != shapeTypes.end())
- {
+ std::set<int> aRemove;
for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
GeomShapePtr aShape = aSelection->value();
if (aShape.get()) {
- auto aType = aShape->shapeType();
- if (aType == GeomAPI_Shape::FACE)
- aRemove.insert(anIndex);
+ GeomAPI_Shape::ShapeType aType = aShape->shapeType();
+ if ((aType == GeomAPI_Shape::SHAPE) ||
+ (aType == GeomAPI_Shape::SOLID) ||
+ (aType == GeomAPI_Shape::SHELL)) {
+
+ GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::FACE);
+ for (; anExp.more(); anExp.next()) {
+ GeomShapePtr aFace = anExp.current();
+ for (int i = 0; i < aSelectionList->size(); ++i) {
+ AttributeSelectionPtr aSel = aSelectionList->value(i);
+ GeomShapePtr aShp = aSel->value();
+ if (aShp.get()) {
+ if (aShp->shapeType() == GeomAPI_Shape::FACE) {
+ if (aShp->isEqual(aFace))
+ aRemove.insert(i);
+ }
+ }
+ else {
+ aRemove.insert(anIndex);
+ }
+ }
+ }
+ }
}
- else
- aRemove.insert(anIndex);
}
+ if (aRemove.size() > 0)
+ aSelectionList->remove(aRemove);
}
- if (aRemove.size() > 0)
- aSelectionList->remove(aRemove);
-
// Collect base shapes.
ListOfShape anOriginalShapes;
for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
theError = aFeature->string(BuildPlugin_Interpolation::EXPRESSION_ERROR_ID())->value();
return theError.empty();
}
-