1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "FeaturesPlugin_Validators.h"
23 #include "FeaturesPlugin_Boolean.h"
24 #include "FeaturesPlugin_BooleanFuse.h"
25 #include "FeaturesPlugin_BooleanSmash.h"
26 #include "FeaturesPlugin_Union.h"
28 #include <Events_InfoMessage.h>
30 #include <ModelAPI_Attribute.h>
31 #include <ModelAPI_AttributeInteger.h>
32 #include <ModelAPI_AttributeSelectionList.h>
33 #include <ModelAPI_AttributeString.h>
34 #include <ModelAPI_AttributeReference.h>
35 #include <ModelAPI_AttributeRefList.h>
36 #include <ModelAPI_Feature.h>
37 #include <ModelAPI_ResultCompSolid.h>
38 #include <ModelAPI_ResultConstruction.h>
39 #include <ModelAPI_Tools.h>
41 #include <GeomValidators_BodyShapes.h>
42 #include <GeomValidators_Face.h>
43 #include <GeomValidators_FeatureKind.h>
44 #include <GeomValidators_ShapeType.h>
46 #include <GeomAPI_DataMapOfShapeShape.h>
47 #include <GeomAPI_Lin.h>
48 #include <GeomAPI_PlanarEdges.h>
49 #include <GeomAPI_Pln.h>
50 #include <GeomAPI_ShapeExplorer.h>
51 #include <GeomAPI_ShapeIterator.h>
53 #include <GeomAlgoAPI_CompoundBuilder.h>
54 #include <GeomAlgoAPI_ShapeBuilder.h>
55 #include <GeomAlgoAPI_ShapeTools.h>
56 #include <GeomAlgoAPI_WireBuilder.h>
58 #define _USE_MATH_DEFINES
61 //==================================================================================================
62 bool FeaturesPlugin_ValidatorPipePath::isValid(const AttributePtr& theAttribute,
63 const std::list<std::string>& theArguments,
64 Events_InfoMessage& theError) const
66 AttributeSelectionPtr aPathAttrSelection =
67 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
68 if(!aPathAttrSelection.get()) {
69 theError = "Error: This validator can only work with path selector in \"Pipe\" feature.";
73 GeomShapePtr aPathShape = aPathAttrSelection->value();
74 ResultPtr aContext = aPathAttrSelection->context();
76 theError = "Error: Empty context.";
79 GeomShapePtr aContextShape = aContext->shape();
80 if(aPathShape.get() && aPathShape->shapeType() == GeomAPI_Shape::WIRE &&
81 !aPathShape->isEqual(aContextShape)) {
82 theError = "Error: Local selection of wires not allowed.";
89 //==================================================================================================
90 bool FeaturesPlugin_ValidatorPipeLocations::isValid(
91 const std::shared_ptr<ModelAPI_Feature>& theFeature,
92 const std::list<std::string>& theArguments,
93 Events_InfoMessage& theError) const
95 static const std::string aCreationMethodID = "creation_method";
96 static const std::string aBaseObjectsID = "base_objects";
97 static const std::string aLocationsID = "locations_objects";
99 if(theFeature->getKind() != "Pipe") {
100 theError = "Error: Feature \"%1\" does not supported by this validator.";
101 theError.arg(theFeature->getKind());
105 AttributeStringPtr aCreationMethodAttr = theFeature->string(aCreationMethodID);
106 if(!aCreationMethodAttr.get()) {
107 theError = "Error: Could not get \"%1\" attribute.";
108 theError.arg(aCreationMethodID);
112 if(aCreationMethodAttr->value() != "locations") {
116 AttributeSelectionListPtr aBaseObjectsSelectionList = theFeature->selectionList(aBaseObjectsID);
117 if(!aBaseObjectsSelectionList.get()) {
118 theError = "Error: Could not get \"%1\" attribute.";
119 theError.arg(aBaseObjectsID);
123 AttributeSelectionListPtr aLocationsSelectionList = theFeature->selectionList(aLocationsID);
124 if(!aLocationsSelectionList.get()) {
125 theError = "Error: Could not get \"%1\" attribute.";
126 theError.arg(aBaseObjectsID);
130 if(aLocationsSelectionList->size() > 0 &&
131 aLocationsSelectionList->size() != aBaseObjectsSelectionList->size()) {
132 theError = "Error: Number of locations should be the same as base objects.";
139 //==================================================================================================
140 bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theAttribute,
141 const std::list<std::string>& theArguments,
142 Events_InfoMessage& theError) const
144 if(theArguments.empty()) {
145 theError = "Error: Validator parameters is empty.";
149 // Checking attribute.
150 if(!isValidAttribute(theAttribute, theArguments, theError)) {
151 if(theError.empty()) {
152 theError = "Error: Attribute contains unacceptable shape.";
157 GeomAPI_DataMapOfShapeShape aSelectedWiresFromObjects;
158 std::string anAttributeType = theAttribute->attributeType();
159 if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
160 AttributeSelectionListPtr aListAttr =
161 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
162 for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
163 AttributeSelectionPtr aSelectionAttr = aListAttr->value(anIndex);
164 ResultPtr aContext = aSelectionAttr->context();
165 if(!aContext.get()) {
166 theError = "Error: Empty context.";
170 ResultConstructionPtr aResultConstruction =
171 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
172 if(!aResultConstruction.get()) {
173 // It is not a result construction.
174 // If shape is compound check that it contains only faces and edges.
175 GeomShapePtr aShape = aSelectionAttr->value();
177 aShape = aContext->shape();
180 if(aShape->shapeType() == GeomAPI_Shape::COMPOUND) {
181 for(GeomAPI_ShapeIterator anIt(aShape); anIt.more(); anIt.next()) {
182 GeomShapePtr aSubShape = anIt.current();
183 if(aSubShape->shapeType() != GeomAPI_Shape::EDGE
184 && aSubShape->shapeType() != GeomAPI_Shape::FACE) {
185 theError = "Error: Compound should contain only faces and edges.";
194 GeomShapePtr aShape = aSelectionAttr->value();
195 GeomShapePtr aContextShape = aResultConstruction->shape();
197 // Whole sketch selected.
200 // Object from sketch selected.
201 for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::WIRE); anExp.more(); anExp.next()) {
202 GeomShapePtr aWire = anExp.current();
203 if(aWire->orientation() != GeomAPI_Shape::FORWARD) {
204 theError = "Error: Wire with wrong orientation selected.";
208 if(aSelectedWiresFromObjects.isBound(aWire)) {
210 "Error: Objects with such wire already selected. Don't allow to select this object.";
214 aSelectedWiresFromObjects.bind(aWire, aWire);
223 //==================================================================================================
224 bool FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects::isValid(
225 const std::shared_ptr<ModelAPI_Feature>& theFeature,
226 const std::list<std::string>& theArguments,
227 Events_InfoMessage& theError) const
229 const std::string aBaseObjectsID = theArguments.front();
231 AttributeSelectionListPtr aListAttr = theFeature->selectionList(aBaseObjectsID);
232 if(!aListAttr.get()) {
233 theError = "Error: Could not get \"%1\" attribute.";
234 theError.arg(aBaseObjectsID);
238 std::set<ResultConstructionPtr> aSelectedSketches;
239 std::set<ResultConstructionPtr> aSelectedSketchesFromObjects;
241 for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
242 AttributeSelectionPtr aSelectionAttr = aListAttr->value(anIndex);
243 ResultPtr aContext = aSelectionAttr->context();
244 if(!aContext.get()) {
245 theError = "Error: Empty context.";
249 ResultConstructionPtr aResultConstruction =
250 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
251 if(!aResultConstruction.get()) {
252 // It is not a result construction.
256 GeomShapePtr aShape = aSelectionAttr->value();
257 GeomShapePtr aContextShape = aResultConstruction->shape();
259 // Whole sketch selected.
260 aSelectedSketches.insert(aResultConstruction);
262 // Object from sketch selected.
263 aSelectedSketchesFromObjects.insert(aResultConstruction);
268 for(std::set<ResultConstructionPtr>::const_iterator anIt = aSelectedSketches.cbegin();
269 anIt != aSelectedSketches.cend();
271 ResultConstructionPtr aResultConstruction = *anIt;
272 if(aSelectedSketchesFromObjects.find(aResultConstruction) !=
273 aSelectedSketchesFromObjects.cend()) {
274 theError = "Sketch and objects from it can not be selected at the same time.";
282 //==================================================================================================
283 bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const AttributePtr& theAttribute,
284 const std::list<std::string>& theArguments,
285 Events_InfoMessage& theError) const
287 if(!theAttribute.get()) {
288 theError = "Error: Empty attribute.";
292 std::string anAttributeType = theAttribute->attributeType();
293 if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
294 AttributeSelectionListPtr aListAttr =
295 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
296 for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
297 // If at least one attribute is invalid, the result is false.
298 if(!isValidAttribute(aListAttr->value(anIndex), theArguments, theError)) {
302 } else if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
304 AttributeSelectionPtr anAttr =
305 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
306 ResultPtr aContext = anAttr->context();
307 if(!aContext.get()) {
308 theError = "Error: Attribute have empty context.";
312 GeomShapePtr aShape = anAttr->value();
313 GeomShapePtr aContextShape = aContext->shape();
315 aShape = aContextShape;
318 theError = "Error: Empty shape selected";
322 ResultConstructionPtr aConstruction =
323 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
324 if(aConstruction.get()) {
325 // Construciotn selected. Check that is is not infinite.
326 if(aConstruction->isInfinite()) {
327 theError = "Error: Infinite constructions is not allowed as base.";
331 if(aShape->isEqual(aContextShape)) {
332 // Whole construction selected. Check that it have faces.
333 if(aConstruction->facesNum() > 0) {
337 // Shape on construction selected. Check that it is a face or wire.
338 if(aShape->shapeType() == GeomAPI_Shape::WIRE ||
339 aShape->shapeType() == GeomAPI_Shape::FACE) {
347 if(!aShape->isEqual(aContextShape)) {
348 // Local selection on body does not allowed.
350 "Error: Selected shape is in the local selection. Only global selection is allowed.";
354 // Check that object is a shape with allowed type.
355 GeomValidators_ShapeType aShapeTypeValidator;
356 if(!aShapeTypeValidator.isValid(anAttr, theArguments, theError)) {
357 theError = "Error: Selected shape has unacceptable type. Acceptable types are: faces or "
358 "wires on sketch, whole sketch(if it has at least one face), "
359 "and whole objects with shape types: %1";
360 std::string anArgumentString;
361 for(auto anIt = theArguments.cbegin(); anIt != theArguments.cend(); ++anIt) {
362 if (!anArgumentString.empty())
363 anArgumentString += ", ";
364 anArgumentString += *anIt;
366 theError.arg(anArgumentString);
371 theError = "Error: Attribute \"%1\" does not supported by this validator.";
372 theError.arg(anAttributeType);
379 //==================================================================================================
380 bool FeaturesPlugin_ValidatorCompositeLauncher::isValid(const AttributePtr& theAttribute,
381 const std::list<std::string>& theArguments,
382 Events_InfoMessage& theError) const
384 if (theAttribute->attributeType() != ModelAPI_AttributeReference::typeId()) {
385 theError = "Error: The attribute with the %1 type is not processed";
386 theError.arg(theAttribute->attributeType());
389 if (theArguments.size() != 2) {
390 theError = "Error: Wrong parameters in XML definition for %1 type";
391 theError.arg(theAttribute->attributeType());
394 // first argument is for the base attribute, second - for skipping feature kind
395 std::list<std::string>::const_iterator anIt = theArguments.begin();
396 std::string aBaseAttributeId = *anIt;
397 FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
398 AttributePtr aBaseAttribute = aFeature->attribute(aBaseAttributeId);
399 if (!aBaseAttribute.get()) {
400 theError = "Wrong parameters in XML definition for %1 type";
401 theError.arg(theAttribute->attributeType());
404 if (aBaseAttribute->isInitialized()) // when base list of composite feature is already filled,
405 // this validator is not necessary anymore
409 std::string aFeatureAttributeKind = *anIt;
410 GeomValidators_FeatureKind* aValidator = new GeomValidators_FeatureKind();
411 // check whether the selection is on the sketch
412 std::list<std::string> anArguments;
413 anArguments.push_back(aFeatureAttributeKind);
415 bool aFeatureKind = aValidator->isValid(theAttribute, theArguments, theError);
416 bool aPlanarFace = false;
417 // check if selection has Face selected
418 GeomValidators_ShapeType* aShapeType = new GeomValidators_ShapeType();
420 anArguments.push_back("face");
421 aPlanarFace = aShapeType->isValid(theAttribute, anArguments, theError);
423 bool aValid = !aFeatureKind && aPlanarFace;
427 //==================================================================================================
428 bool FeaturesPlugin_ValidatorExtrusionDir::isValid(
429 const std::shared_ptr<ModelAPI_Feature>& theFeature,
430 const std::list<std::string>& theArguments,
431 Events_InfoMessage& theError) const
433 if(theArguments.size() != 2) {
434 theError = "Error: Validator should be used with 2 parameters for extrusion.";
438 std::list<std::string>::const_iterator
439 anArgsIt = theArguments.begin(), aLast = theArguments.end();
441 AttributePtr aCheckAttribute = theFeature->attribute(*anArgsIt);
444 GeomShapePtr aDirShape;
445 AttributeSelectionPtr aSelAttr = theFeature->selection(*anArgsIt);
447 aDirShape = aSelAttr->value();
448 if(!aDirShape.get()) {
449 ResultPtr aContext = aSelAttr->context();
451 aDirShape = aContext->shape();
456 if(!aDirShape.get()) {
457 // Check that dir can be empty.
458 if(!isShapesCanBeEmpty(aCheckAttribute, theError)) {
459 theError = "Error: Base objects list contains vertex or edge, so attribute \"%1\" "
460 "can not be used with default value. Select direction for extrusion.";
461 theError.arg(*anArgsIt);
468 std::shared_ptr<GeomAPI_Edge> aDirEdge(new GeomAPI_Edge(aDirShape));
470 // If faces selected check that direction not parallel with them.
471 AttributeSelectionListPtr aListAttr =
472 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aCheckAttribute);
473 for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
474 AttributeSelectionPtr anAttr = aListAttr->value(anIndex);
475 GeomShapePtr aShapeInList = anAttr->value();
476 if(!aShapeInList.get()) {
477 aShapeInList = anAttr->context()->shape();
479 bool isParallel = true;
480 if(aShapeInList->shapeType() == GeomAPI_Shape::FACE ||
481 aShapeInList->shapeType() == GeomAPI_Shape::SHELL) {
482 for(GeomAPI_ShapeExplorer
483 anExp(aShapeInList, GeomAPI_Shape::FACE); anExp.more(); anExp.next()) {
484 std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(anExp.current()));
485 isParallel = GeomAlgoAPI_ShapeTools::isParallel(aDirEdge, aFace);
490 } else if(aShapeInList->shapeType() == GeomAPI_Shape::COMPOUND) {
491 std::shared_ptr<GeomAPI_PlanarEdges> aPlanarEdges =
492 std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapeInList);
493 if(aPlanarEdges.get()) {
494 std::shared_ptr<GeomAPI_Dir> aSketchDir = aPlanarEdges->norm();
495 if(aDirEdge->isLine()) {
496 std::shared_ptr<GeomAPI_Dir> aDir = aDirEdge->line()->direction();
497 isParallel = fabs(aSketchDir->angle(aDir) - M_PI / 2.0) < 10e-7;
509 "Error: Direction is parallel to one of the selected face or face on selected shell.";
517 //==================================================================================================
518 bool FeaturesPlugin_ValidatorExtrusionDir::isShapesCanBeEmpty(const AttributePtr& theAttribute,
519 Events_InfoMessage& theError) const
521 if(!theAttribute.get()) {
525 std::string anAttributeType = theAttribute->attributeType();
526 if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
527 AttributeSelectionListPtr aListAttr =
528 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
529 for(int anIndex = 0; anIndex < aListAttr->size(); ++anIndex) {
530 // If at least one attribute is invalid, the result is false.
531 if(!isShapesCanBeEmpty(aListAttr->value(anIndex), theError)) {
535 } else if(anAttributeType == ModelAPI_AttributeSelection::typeId()) {
537 AttributeSelectionPtr anAttr =
538 std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
539 ResultPtr aContext = anAttr->context();
540 if(!aContext.get()) {
544 GeomShapePtr aShape = anAttr->value();
545 GeomShapePtr aContextShape = aContext->shape();
547 aShape = aContextShape;
553 if(aShape->shapeType() == GeomAPI_Shape::VERTEX ||
554 aShape->shapeType() == GeomAPI_Shape::EDGE ||
555 !aShape->isPlanar()) {
565 //==================================================================================================
566 bool FeaturesPlugin_ValidatorBooleanSelection::isValid(const AttributePtr& theAttribute,
567 const std::list<std::string>& theArguments,
568 Events_InfoMessage& theError) const
570 AttributeSelectionListPtr anAttrSelectionList =
571 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
572 if(!anAttrSelectionList.get()) {
574 "Error: This validator can only work with selection list attributes in \"Boolean\" feature.";
577 std::shared_ptr<FeaturesPlugin_Boolean> aFeature =
578 std::dynamic_pointer_cast<FeaturesPlugin_Boolean>(theAttribute->owner());
579 FeaturesPlugin_Boolean::OperationType anOperationType = aFeature->operationType();
581 for(int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) {
582 AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
583 if(!anAttrSelection.get()) {
584 theError = "Error: Empty attribute selection.";
587 ResultPtr aContext = anAttrSelection->context();
588 if(!aContext.get()) {
589 theError = "Error: Empty selection context.";
592 ResultConstructionPtr aResultConstruction =
593 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
594 if(aResultConstruction.get()) {
595 if (anOperationType != FeaturesPlugin_Boolean::BOOL_FILL
596 || theAttribute->id() != FeaturesPlugin_Boolean::TOOL_LIST_ID()) {
597 theError = "Error: Result construction not allowed for selection.";
601 std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
602 GeomShapePtr aContextShape = aContext->shape();
604 aShape = aContextShape;
607 theError = "Error: Empty shape.";
610 if(!aShape->isEqual(aContextShape)) {
611 theError = "Error: Local selection not allowed.";
615 GeomAPI_Shape::ShapeType aShapeType = aShape->shapeType();
616 std::set<GeomAPI_Shape::ShapeType> anAllowedTypes;
617 if(anOperationType == FeaturesPlugin_Boolean::BOOL_FUSE) {
618 anAllowedTypes.insert(GeomAPI_Shape::EDGE);
619 anAllowedTypes.insert(GeomAPI_Shape::FACE);
620 anAllowedTypes.insert(GeomAPI_Shape::SOLID);
621 anAllowedTypes.insert(GeomAPI_Shape::COMPSOLID);
622 anAllowedTypes.insert(GeomAPI_Shape::COMPOUND);
623 } else if (anOperationType == FeaturesPlugin_Boolean::BOOL_FILL
624 || anOperationType == FeaturesPlugin_Boolean::BOOL_CUT)
626 anAllowedTypes.insert(GeomAPI_Shape::VERTEX);
627 anAllowedTypes.insert(GeomAPI_Shape::EDGE);
628 anAllowedTypes.insert(GeomAPI_Shape::WIRE);
629 anAllowedTypes.insert(GeomAPI_Shape::FACE);
630 anAllowedTypes.insert(GeomAPI_Shape::SHELL);
631 anAllowedTypes.insert(GeomAPI_Shape::SOLID);
632 anAllowedTypes.insert(GeomAPI_Shape::COMPSOLID);
633 anAllowedTypes.insert(GeomAPI_Shape::COMPOUND);
635 anAllowedTypes.insert(GeomAPI_Shape::SOLID);
636 anAllowedTypes.insert(GeomAPI_Shape::COMPSOLID);
637 anAllowedTypes.insert(GeomAPI_Shape::COMPOUND);
640 if(anAllowedTypes.find(aShapeType) == anAllowedTypes.end()
641 || (aResultConstruction.get() && aShapeType != GeomAPI_Shape::FACE)) {
642 theError = "Error: Selected shape has the wrong type.";
651 //==================================================================================================
652 bool FeaturesPlugin_ValidatorFilletSelection::isValid(const AttributePtr& theAttribute,
653 const std::list<std::string>& theArguments,
654 Events_InfoMessage& theError) const
656 AttributeSelectionListPtr anAttrSelectionList =
657 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
658 if(!anAttrSelectionList.get()) {
660 "Error: This validator can only work with selection list attributes in \"Fillet\" feature.";
664 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
665 // Check all selected entities are sub-shapes of single solid
666 GeomShapePtr aBaseSolid;
667 for(int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) {
668 AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
669 if(!anAttrSelection.get()) {
670 theError = "Error: Empty attribute selection.";
673 ResultPtr aContext = anAttrSelection->context();
674 if(!aContext.get()) {
675 theError = "Error: Empty selection context.";
679 ResultCompSolidPtr aContextOwner = ModelAPI_Tools::compSolidOwner(aContext);
680 GeomShapePtr anOwner = aContextOwner.get() ? aContextOwner->shape() : aContext->shape();
682 if (anOwner->shapeType() != GeomAPI_Shape::SOLID &&
683 anOwner->shapeType() != GeomAPI_Shape::COMPSOLID) {
684 theError = "Error: Not all selected shapes are sub-shapes of solids";
689 aBaseSolid = anOwner;
690 else if (!aBaseSolid->isEqual(anOwner)) {
691 theError = "Error: Sub-shapes of different solids have been selected.";
699 //==================================================================================================
700 bool FeaturesPlugin_ValidatorPartitionSelection::isValid(const AttributePtr& theAttribute,
701 const std::list<std::string>& theArguments,
702 Events_InfoMessage& theError) const
704 AttributeSelectionListPtr anAttrSelectionList =
705 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
706 if(!anAttrSelectionList.get()) {
707 theError = "Error: This validator can only work with selection list in \"Partition\" feature.";
711 for(int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) {
712 AttributeSelectionPtr aSelectAttr = anAttrSelectionList->value(anIndex);
714 //GeomValidators_BodyShapes aBodyValidator;
715 //if(aBodyValidator.isValid(aSelectAttr, theArguments, theError)) {
719 GeomValidators_FeatureKind aFeatureKindValidator;
720 if(aFeatureKindValidator.isValid(aSelectAttr, theArguments, theError)) {
724 ResultPtr aContext = aSelectAttr->context();
725 ResultConstructionPtr aResultConstruction =
726 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
727 if(aResultConstruction.get()) {
728 theError = "Error: Only body shapes and construction planes are allowed for selection.";
732 ResultCompSolidPtr aResultCompsolid =
733 std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aContext);
734 if(aResultCompsolid.get()) {
738 theError = "Error: Only body shapes and construction planes are allowed for selection.";
746 //==================================================================================================
747 bool FeaturesPlugin_ValidatorRemoveSubShapesSelection::isValid(const AttributePtr& theAttribute,
748 const std::list<std::string>& theArguments,
749 Events_InfoMessage& theError) const
751 AttributeSelectionListPtr aSubShapesAttrList =
752 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
753 if(!aSubShapesAttrList.get()) {
755 "Error: This validator can only work with selection list in \"Remove Sub-Shapes\" feature.";
759 static const std::string aBaseShapeID = "base_shape";
760 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
761 AttributeSelectionPtr aShapeAttrSelection = aFeature->selection(aBaseShapeID);
763 if(!aShapeAttrSelection.get()) {
764 theError = "Error: Could not get \"%1\" attribute.";
765 theError.arg(aBaseShapeID);
769 GeomShapePtr aBaseShape = aShapeAttrSelection->value();
770 ResultPtr aContext = aShapeAttrSelection->context();
771 if(!aContext.get()) {
772 theError = "Error: Empty context.";
775 if(!aBaseShape.get()) {
776 aBaseShape = aContext->shape();
778 if(!aBaseShape.get()) {
779 theError = "Error: Empty base shape.";
783 for(int anIndex = 0; anIndex < aSubShapesAttrList->size(); ++anIndex) {
784 bool isSameFound = false;
785 AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(anIndex);
786 GeomShapePtr aShapeToAdd = anAttrSelectionInList->value();
787 for(GeomAPI_ShapeIterator anIt(aBaseShape); anIt.more(); anIt.next()) {
788 if(anIt.current()->isEqual(aShapeToAdd)) {
794 theError = "Error: Only sub-shapes of selected shape is allowed for selection.";
802 //==================================================================================================
803 bool FeaturesPlugin_ValidatorRemoveSubShapesResult::isValid(
804 const std::shared_ptr<ModelAPI_Feature>& theFeature,
805 const std::list<std::string>& theArguments,
806 Events_InfoMessage& theError) const
808 static const std::string aBaseShapeID = "base_shape";
809 static const std::string aSubShapesID = "subshapes_to_keep";
811 if(theFeature->getKind() != "Remove_SubShapes") {
812 theError = "Error: Feature \"%1\" does not supported by this validator.";
813 theError.arg(theFeature->getKind());
817 AttributeSelectionPtr aShapeAttrSelection = theFeature->selection(aBaseShapeID);
818 if(!aShapeAttrSelection.get()) {
819 theError = "Error: Could not get \"%1\" attribute.";
820 theError.arg(aBaseShapeID);
824 AttributeSelectionListPtr aSubShapesAttrList = theFeature->selectionList(aSubShapesID);
825 if(!aSubShapesAttrList.get()) {
826 theError = "Error: Could not get \"%1\" attribute.";
827 theError.arg(aSubShapesID);
832 GeomShapePtr aBaseShape = aShapeAttrSelection->value();
833 if(!aBaseShape.get()) {
834 theError = "Error: Base shape is empty.";
837 GeomShapePtr aResultShape = aBaseShape->emptyCopied();
839 if (aSubShapesAttrList->size() == 0) {
840 theError = "Error: Resulting shape is not valid.";
844 // Copy sub-shapes from list to new shape.
845 for(int anIndex = 0; anIndex < aSubShapesAttrList->size(); ++anIndex) {
846 AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(anIndex);
847 GeomShapePtr aShapeToAdd = anAttrSelectionInList->value();
848 GeomAlgoAPI_ShapeBuilder::add(aResultShape, aShapeToAdd);
852 if(!GeomAlgoAPI_ShapeTools::isShapeValid(aResultShape)) {
853 theError = "Error: Resulting shape is not valid.";
860 //==================================================================================================
861 bool FeaturesPlugin_ValidatorUnionSelection::isValid(const AttributePtr& theAttribute,
862 const std::list<std::string>& theArguments,
863 Events_InfoMessage& theError) const
865 AttributeSelectionListPtr aBaseObjectsAttrList =
866 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
867 if(!aBaseObjectsAttrList.get()) {
868 theError = "Error: This validator can only work with selection list in \"%1\" feature.";
869 theError.arg(FeaturesPlugin_Union::ID());
873 for(int anIndex = 0; anIndex < aBaseObjectsAttrList->size(); ++anIndex) {
874 bool isSameFound = false;
875 AttributeSelectionPtr anAttrSelectionInList = aBaseObjectsAttrList->value(anIndex);
876 ResultPtr aContext = anAttrSelectionInList->context();
877 if (!aContext.get()) {
878 theError = "Error: selection is invalid.";
882 ResultConstructionPtr aConstruction =
883 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
884 if(aConstruction.get()) {
885 theError = "Error: Result construction not allowed for selection.";
889 GeomShapePtr aShape = anAttrSelectionInList->value();
890 GeomShapePtr aContextShape = aContext->shape();
891 if (aShape.get() && aContextShape.get() && !aContextShape->isEqual(aShape)) {
892 theError = "Error: Local selection not allowed.";
896 ResultCompSolidPtr aResult =
897 std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aContext);
902 if(aResult->numberOfSubs() > 0) {
903 theError = "Error: Whole compsolids not allowed for selection.";
911 //==================================================================================================
912 bool FeaturesPlugin_ValidatorUnionArguments::isValid(
913 const std::shared_ptr<ModelAPI_Feature>& theFeature,
914 const std::list<std::string>& theArguments,
915 Events_InfoMessage& theError) const
917 // Check feature kind.
918 if(theFeature->getKind() != FeaturesPlugin_Union::ID()) {
919 theError = "Error: This validator supports only \"%1\" feature.";
920 theError.arg(FeaturesPlugin_Union::ID());
924 // Get base objects attribute list.
925 AttributeSelectionListPtr aBaseObejctsAttrList =
926 theFeature->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_ID());
927 if(!aBaseObejctsAttrList.get()) {
928 theError = "Error: Could not get \"%1\" attribute.";
929 theError.arg(FeaturesPlugin_Union::BASE_OBJECTS_ID());
934 GeomAPI_Shape::ShapeType aType = GeomAPI_Shape::COMPSOLID;
935 ListOfShape aBaseShapesList;
936 for(int anIndex = 0; anIndex < aBaseObejctsAttrList->size(); ++anIndex) {
937 AttributeSelectionPtr anAttrSelectionInList = aBaseObejctsAttrList->value(anIndex);
938 GeomShapePtr aShape = anAttrSelectionInList->value();
942 aBaseShapesList.push_back(aShape);
943 aType = aShape->shapeType() == GeomAPI_Shape::FACE ? GeomAPI_Shape::SHELL :
944 GeomAPI_Shape::COMPSOLID;
947 // Make compound and find connected.
948 GeomShapePtr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aBaseShapesList);
949 ListOfShape aCombined, aFree;
950 GeomAlgoAPI_ShapeTools::combineShapes(
956 if(aFree.size() > 0 || aCombined.size() > 1) {
957 theError = "Error: Not all shapes have shared topology.";
964 bool FeaturesPlugin_ValidatorConcealedResult::isValid(const AttributePtr& theAttribute,
965 const std::list<std::string>& theArguments,
966 Events_InfoMessage& theError) const
968 if (theAttribute->attributeType() != ModelAPI_AttributeReference::typeId()) {
969 theError = "Error: The attribute with the %1 type is not processed";
970 theError.arg(theAttribute->attributeType());
974 AttributeReferencePtr aRefAttribute = std::dynamic_pointer_cast<ModelAPI_AttributeReference>
976 ObjectPtr aRefObject = aRefAttribute->value();
977 if (!aRefObject.get()) {
978 theError = "Error: Empty feature.";
982 FeaturePtr aRefFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aRefObject);
983 if (!aRefFeature.get()) {
984 theError = "Error: Empty feature.";
987 std::list<std::shared_ptr<ModelAPI_Result> > aResults;
988 ModelAPI_Tools::getConcealedResults(aRefFeature, aResults);
990 size_t aConcealedResults = aResults.size();
991 if (!aConcealedResults && !theArguments.empty()) {
992 // find if these results are touched by the feature in another attribute
993 std::list<std::string>::const_iterator anIt = theArguments.begin();
994 std::string aRecoveredList = *anIt;
995 if (!aRecoveredList.empty()) {
996 std::shared_ptr<ModelAPI_AttributeRefList> aParameterList =
997 theAttribute->owner()->data()->reflist(aRecoveredList);
998 if (aParameterList.get())
999 aConcealedResults = aParameterList->size();
1003 if (aConcealedResults == 0)
1004 theError = "Error: No concealed results.";
1006 return theError.empty();
1009 bool FeaturesPlugin_ValidatorCircular::isValid(const AttributePtr& theAttribute,
1010 const std::list<std::string>& theArguments,
1011 Events_InfoMessage& theError) const
1013 static std::list<std::string> aEdgeArg(1, "circle");
1014 static std::list<std::string> aFaceArg(1, "cylinder");
1016 Events_InfoMessage aError;
1017 bool isValid = GeomValidators_ShapeType().isValid(theAttribute, aEdgeArg, aError);
1019 isValid = GeomValidators_Face().isValid(theAttribute, aFaceArg, aError);
1021 theError = "The shape neither circle nor cylinder";
1026 //=================================================================================================
1027 bool FeaturesPlugin_ValidatorBooleanArguments::isValid(
1028 const std::shared_ptr<ModelAPI_Feature>& theFeature,
1029 const std::list<std::string>& theArguments,
1030 Events_InfoMessage& theError) const
1032 if (theArguments.size() != 2)
1034 theError = "Wrong number of arguments (expected 2).";
1038 int anObjectsNb = 0, aToolsNb = 0;
1039 //int anOperationType = 0;
1041 std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
1043 bool isAllInSameCompSolid = true;
1044 ResultCompSolidPtr aCompSolid;
1046 AttributeSelectionListPtr anAttrSelList = theFeature->selectionList(*anIt);
1049 anObjectsNb = anAttrSelList->size();
1050 for (int anIndex = 0; anIndex < anObjectsNb; ++anIndex)
1052 AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex);
1053 ResultPtr aContext = anAttr->context();
1054 ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
1055 if (aResCompSolidPtr.get())
1057 if (aCompSolid.get())
1059 isAllInSameCompSolid = aCompSolid == aResCompSolidPtr;
1063 aCompSolid = aResCompSolidPtr;
1068 isAllInSameCompSolid = false;
1076 anAttrSelList = theFeature->selectionList(*anIt);
1079 aToolsNb = anAttrSelList->size();
1080 if (isAllInSameCompSolid)
1082 for (int anIndex = 0; anIndex < aToolsNb; ++anIndex)
1084 AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex);
1085 ResultPtr aContext = anAttr->context();
1086 ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
1087 if (aResCompSolidPtr.get())
1089 if (aCompSolid.get())
1091 isAllInSameCompSolid = aCompSolid == aResCompSolidPtr;
1095 aCompSolid = aResCompSolidPtr;
1100 isAllInSameCompSolid = false;
1108 std::shared_ptr<FeaturesPlugin_Boolean> aFeature =
1109 std::dynamic_pointer_cast<FeaturesPlugin_Boolean>(theFeature);
1110 FeaturesPlugin_Boolean::OperationType anOperationType = aFeature->operationType();
1112 if (anOperationType == FeaturesPlugin_Boolean::BOOL_FUSE)
1115 if (anObjectsNb + aToolsNb < 2)
1117 theError = "Not enough arguments for Fuse operation.";
1120 else if (isAllInSameCompSolid)
1122 theError = "Operations only between sub-shapes of the same shape not allowed.";
1128 if (anObjectsNb < 1)
1130 theError = "Objects not selected.";
1135 theError = "Tools not selected.";
1138 if (isAllInSameCompSolid)
1140 theError = "Operations only between sub-shapes of the same shape not allowed.";
1148 //=================================================================================================
1149 bool FeaturesPlugin_ValidatorBooleanArguments::isNotObligatory(std::string theFeature,
1150 std::string theAttribute)
1152 if (theAttribute == "main_objects" || theAttribute == "tool_objects")
1160 //==================================================================================================
1161 bool FeaturesPlugin_ValidatorBooleanSmashSelection::isValid(
1162 const AttributePtr& theAttribute,
1163 const std::list<std::string>& theArguments,
1164 Events_InfoMessage& theError) const
1166 std::shared_ptr<FeaturesPlugin_BooleanSmash> aFeature =
1167 std::dynamic_pointer_cast<FeaturesPlugin_BooleanSmash>(theAttribute->owner());
1169 AttributeSelectionListPtr anAttrSelectionList =
1170 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
1171 if (!aFeature.get() || !anAttrSelectionList.get()) {
1173 "Error: Validator used in wrong feature or attribute";
1177 AttributeSelectionListPtr anOtherAttrSelectionList;
1178 if (theAttribute->id() == FeaturesPlugin_BooleanSmash::OBJECT_LIST_ID()) {
1179 anOtherAttrSelectionList =
1180 aFeature->selectionList(FeaturesPlugin_BooleanSmash::TOOL_LIST_ID());
1182 anOtherAttrSelectionList =
1183 aFeature->selectionList(FeaturesPlugin_BooleanSmash::OBJECT_LIST_ID());
1186 GeomAPI_Shape::ShapeType aSelectedShapesType = GeomAPI_Shape::SHAPE;
1187 GeomAPI_DataMapOfShapeShape aSelectedCompSolidsInOtherList;
1188 GeomPlanePtr aFacesPln;
1190 for (int anIndex = 0; anIndex < anOtherAttrSelectionList->size(); ++anIndex) {
1191 AttributeSelectionPtr anAttrSelection = anOtherAttrSelectionList->value(anIndex);
1192 ResultPtr aContext = anAttrSelection->context();
1193 std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
1194 GeomShapePtr aContextShape = aContext->shape();
1195 if (!aShape.get()) {
1196 aShape = aContextShape;
1199 if (aShape->isSolid() || aShape->isCompSolid()) {
1200 aSelectedShapesType = GeomAPI_Shape::SOLID;
1201 ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
1202 if (aResCompSolidPtr.get()) {
1203 GeomShapePtr aCompSolidShape = aResCompSolidPtr->shape();
1204 aSelectedCompSolidsInOtherList.bind(aCompSolidShape, aCompSolidShape);
1207 aSelectedShapesType = GeomAPI_Shape::FACE;
1208 GeomAPI_Face aFace(aShape);
1209 aFacesPln = aFace.getPlane();
1214 for (int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) {
1215 AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
1216 if (!anAttrSelection.get()) {
1217 theError = "Error: Empty attribute selection.";
1220 ResultPtr aContext = anAttrSelection->context();
1221 if (!aContext.get()) {
1222 theError = "Error: Empty selection context.";
1225 ResultConstructionPtr aResultConstruction =
1226 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
1227 if (aResultConstruction.get()) {
1228 theError = "Error: Result construction not allowed for selection.";
1231 std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
1232 GeomShapePtr aContextShape = aContext->shape();
1233 if (!aShape.get()) {
1234 aShape = aContextShape;
1236 if (!aShape.get()) {
1237 theError = "Error: Empty shape.";
1240 if (!aShape->isEqual(aContextShape)) {
1241 theError = "Error: Local selection not allowed.";
1245 if (aSelectedShapesType == GeomAPI_Shape::SHAPE) {
1246 // Other list is empty.
1247 if (aShape->isSolid() || aShape->isCompSolid()) {
1248 aSelectedShapesType = GeomAPI_Shape::SOLID;
1250 aSelectedShapesType = GeomAPI_Shape::FACE;
1251 GeomAPI_Face aFace(aShape);
1252 aFacesPln = aFace.getPlane();
1254 if (!aFacesPln.get()) {
1255 theError = "Error: Only planar faces allowed.";
1261 } else if (aSelectedShapesType == GeomAPI_Shape::SOLID) {
1262 if (!aShape->isSolid() && !aShape->isCompSolid()) {
1263 theError = "Error: Selected shapes should have the same type.";
1267 ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
1268 if (aResCompSolidPtr.get()) {
1269 GeomShapePtr aCompSolidShape = aResCompSolidPtr->shape();
1270 if (aSelectedCompSolidsInOtherList.isBound(aCompSolidShape)) {
1271 theError = "Error: Solids from compsolid in other list not allowed.";
1276 GeomAPI_Face aFace(aShape);
1277 GeomPlanePtr aPln = aFace.getPlane();
1280 theError = "Error: Only planar faces allowed.";
1284 if (!aFacesPln->isCoincident(aPln)) {
1285 theError = "Error: Only coincident faces allowed.";
1294 //==================================================================================================
1295 bool FeaturesPlugin_IntersectionSelection::isValid(const AttributePtr& theAttribute,
1296 const std::list<std::string>& theArguments,
1297 Events_InfoMessage& theError) const
1299 if (!theAttribute.get()) {
1300 theError = "Error: empty selection.";
1303 FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
1304 AttributeSelectionListPtr anAttrSelectionList =
1305 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
1306 for (int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) {
1307 AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
1308 if (!anAttrSelection.get()) {
1309 theError = "Error: empty attribute selection.";
1312 ResultPtr aContext = anAttrSelection->context();
1313 if (!aContext.get()) {
1314 theError = "Error: empty selection context.";
1317 FeaturePtr aFeature = ModelAPI_Feature::feature(aContext);
1318 if (!aFeature.get()) {
1319 theError = "Error: empty feature.";
1322 std::string aFeatureKind = aFeature->getKind();
1323 if (aFeatureKind == "Sketch" ||
1324 aFeatureKind == "Plane" ||
1325 aFeatureKind == "Axis") {
1326 theError = "Error: %1 shape is not allowed for selection.";
1327 theError.arg(aFeatureKind);
1330 std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
1331 GeomShapePtr aContextShape = aContext->shape();
1332 if (!aShape.get()) {
1333 aShape = aContextShape;
1335 if (!aShape.get()) {
1336 theError = "Error: empty shape.";
1339 if (!aShape->isEqual(aContextShape)) {
1340 theError = "Error: Local selection not allowed.";
1344 int aShapeType = aShape->shapeType();
1345 // Allow to select edges, faces and solids.
1346 if (aShapeType != GeomAPI_Shape::EDGE &&
1347 aShapeType != GeomAPI_Shape::FACE &&
1348 aShapeType != GeomAPI_Shape::SOLID &&
1349 aShapeType != GeomAPI_Shape::COMPSOLID &&
1350 aShapeType != GeomAPI_Shape::COMPOUND) {
1351 theError = "Error: selected shape has the wrong type.";
1359 //==================================================================================================
1360 bool FeaturesPlugin_ValidatorBooleanFuseSelection::isValid(
1361 const AttributePtr& theAttribute,
1362 const std::list<std::string>& theArguments,
1363 Events_InfoMessage& theError) const
1365 AttributeSelectionListPtr anAttrSelectionList =
1366 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
1367 if (!anAttrSelectionList.get()) {
1369 "Error: This validator can only work with selection list attributes in \"Boolean\" feature.";
1373 for (int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) {
1374 AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex);
1375 if (!anAttrSelection.get()) {
1376 theError = "Error: Empty attribute selection.";
1379 ResultPtr aContext = anAttrSelection->context();
1380 if (!aContext.get()) {
1381 theError = "Error: Empty selection context.";
1384 ResultConstructionPtr aResultConstruction =
1385 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
1386 if (aResultConstruction.get()) {
1387 theError = "Error: Result construction not allowed for selection.";
1390 std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
1391 GeomShapePtr aContextShape = aContext->shape();
1392 if (!aShape.get()) {
1393 aShape = aContextShape;
1395 if (!aShape.get()) {
1396 theError = "Error: Empty shape.";
1399 if (!aShape->isEqual(aContextShape)) {
1400 theError = "Error: Local selection not allowed.";
1408 //=================================================================================================
1409 bool FeaturesPlugin_ValidatorBooleanFuseArguments::isValid(
1410 const std::shared_ptr<ModelAPI_Feature>& theFeature,
1411 const std::list<std::string>& theArguments,
1412 Events_InfoMessage& theError) const
1414 if (theArguments.size() != 2) {
1415 theError = "Wrong number of arguments (expected 2).";
1419 std::shared_ptr<FeaturesPlugin_BooleanFuse> aFeature =
1420 std::dynamic_pointer_cast<FeaturesPlugin_BooleanFuse>(theFeature);
1422 int anObjectsNb = 0, aToolsNb = 0;
1424 std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
1426 bool isAllInSameCompSolid = true;
1427 ResultCompSolidPtr aCompSolid;
1429 AttributeSelectionListPtr anAttrSelList = theFeature->selectionList(*anIt);
1430 if (anAttrSelList) {
1431 anObjectsNb = anAttrSelList->size();
1432 for (int anIndex = 0; anIndex < anObjectsNb; ++anIndex) {
1433 AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex);
1434 ResultPtr aContext = anAttr->context();
1435 ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
1436 if (aResCompSolidPtr.get()) {
1437 if (aCompSolid.get()) {
1438 isAllInSameCompSolid = aCompSolid == aResCompSolidPtr;
1440 aCompSolid = aResCompSolidPtr;
1443 isAllInSameCompSolid = false;
1450 if (aFeature->string(FeaturesPlugin_BooleanFuse::CREATION_METHOD())->value()
1451 == FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED()) {
1452 anAttrSelList = theFeature->selectionList(*anIt);
1453 if (anAttrSelList) {
1454 aToolsNb = anAttrSelList->size();
1455 if (isAllInSameCompSolid) {
1456 for (int anIndex = 0; anIndex < aToolsNb; ++anIndex) {
1457 AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex);
1458 ResultPtr aContext = anAttr->context();
1459 ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
1460 if (aResCompSolidPtr.get()) {
1461 if (aCompSolid.get()) {
1462 isAllInSameCompSolid = aCompSolid == aResCompSolidPtr;
1464 aCompSolid = aResCompSolidPtr;
1467 isAllInSameCompSolid = false;
1477 if (anObjectsNb + aToolsNb < 2) {
1478 theError = "Not enough arguments for Fuse operation.";
1480 } else if (isAllInSameCompSolid) {
1481 theError = "Operations only between sub-shapes of the same shape not allowed.";
1488 //=================================================================================================
1489 bool FeaturesPlugin_ValidatorBooleanFuseArguments::isNotObligatory(
1490 std::string theFeature,
1491 std::string theAttribute)
1493 if (theAttribute == "main_objects" || theAttribute == "tool_objects") {