#include "BuildPlugin_CompSolid.h"
-#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAlgoAPI_MakeVolume.h>
#include <ModelAPI_AttributeSelectionList.h>
//=================================================================================================
//=================================================================================================
void BuildPlugin_CompSolid::execute()
{
+ // all the needed checkings are in validator, so, here just make and store result
ListOfShape anOriginalShapes;
- std::shared_ptr<GeomAlgoAPI_MakeShape> aVolumeMaker;
- if (!build(anOriginalShapes, aVolumeMaker))
- return;
-
- GeomShapePtr aVolumeRes = aVolumeMaker->shape();
+ AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
+ for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
+ AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
+ GeomShapePtr aShape = aSelection->value();
+ if (!aShape.get())
+ aShape = aSelection->context()->shape();
+ anOriginalShapes.push_back(aShape);
+ }
+ std::shared_ptr<GeomAlgoAPI_MakeVolume> anAlgo(new GeomAlgoAPI_MakeVolume(anOriginalShapes));
+ GeomShapePtr aVolumeRes = anAlgo->shape();
// check and process result of volume maker
- GeomShapePtr aResShape = getSingleSubshape(aVolumeRes, GeomAPI_Shape::COMPSOLID);
- if (!aResShape) // try to build a solid
- aResShape = getSingleSubshape(aVolumeRes, GeomAPI_Shape::SOLID);
-
- int anIndex = 0;
- if (aResShape) {
- storeResult(anOriginalShapes, aResShape, aVolumeMaker);
- ++anIndex;
- }
- removeResults(anIndex);
+ GeomShapePtr aResShape = getSingleSubshape(aVolumeRes);
+ storeResult(anOriginalShapes, aResShape, anAlgo);
}
new BuildPlugin_ValidatorBaseForWire());
aFactory->registerValidator("BuildPlugin_ValidatorBaseForFace",
new BuildPlugin_ValidatorBaseForFace());
+ aFactory->registerValidator("BuildPlugin_ValidatorBaseForSolids",
+ new BuildPlugin_ValidatorBaseForSolids());
aFactory->registerValidator("BuildPlugin_ValidatorSubShapesSelection",
new BuildPlugin_ValidatorSubShapesSelection());
aFactory->registerValidator("BuildPlugin_ValidatorFillingSelection",
//=================================================================================================
void BuildPlugin_Solid::execute()
{
+ // all the needed checkings are in validator, so, here just make and store result
ListOfShape anOriginalShapes;
- std::shared_ptr<GeomAlgoAPI_MakeShape> aVolumeMaker;
- if (!build(anOriginalShapes, aVolumeMaker))
- return;
-
- // check and process result of volume maker
- GeomShapePtr aResShape = getSingleSubshape(aVolumeMaker->shape(), GeomAPI_Shape::SOLID);
- int anIndex = 0;
- if (aResShape) {
- storeResult(anOriginalShapes, aResShape, aVolumeMaker);
- ++anIndex;
- }
- removeResults(anIndex);
-}
-
-//=================================================================================================
-bool BuildPlugin_Solid::build(ListOfShape& theOriginalShapes,
- std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
-{
- // Get base objects list.
AttributeSelectionListPtr aSelectionList = selectionList(BASE_OBJECTS_ID());
- if (!aSelectionList.get()) {
- setError("Error: Could not get selection list.");
- return false;
- }
- if (aSelectionList->size() == 0) {
- setError("Error: Empty selection list.");
- return false;
- }
-
- // Collect base shapes.
for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
GeomShapePtr aShape = aSelection->value();
if (!aShape.get())
aShape = aSelection->context()->shape();
- theOriginalShapes.push_back(aShape);
+ anOriginalShapes.push_back(aShape);
}
-
- theAlgorithm =
- std::shared_ptr<GeomAlgoAPI_MakeVolume>(new GeomAlgoAPI_MakeVolume(theOriginalShapes));
- return !isAlgorithmFailed(theAlgorithm);
+ std::shared_ptr<GeomAlgoAPI_MakeVolume> anAlgo(new GeomAlgoAPI_MakeVolume(anOriginalShapes));
+ // check and process result of volume maker
+ GeomShapePtr aResShape = getSingleSubshape(anAlgo->shape());
+ storeResult(anOriginalShapes, aResShape, anAlgo);
}
void BuildPlugin_Solid::storeResult(const ListOfShape& theOriginalShapes,
aResultBody->loadAndOrientModifiedShapes(theAlgorithm.get(), aShape, GeomAPI_Shape::FACE,
aModifiedTag, "Modified_Face", *aMapOfSubs.get(), false, true, true);
}
-
setResult(aResultBody);
}
-GeomShapePtr BuildPlugin_Solid::getSingleSubshape(const GeomShapePtr& theCompound,
- const GeomAPI_Shape::ShapeType theShapeType)
+GeomShapePtr BuildPlugin_Solid::getSingleSubshape(const GeomShapePtr& theCompound)
{
- if (theCompound->shapeType() == theShapeType)
- return theCompound;
- else if (theCompound->shapeType() == GeomAPI_Shape::COMPOUND) {
+ if (theCompound->shapeType() == GeomAPI_Shape::COMPOUND) {
GeomAPI_ShapeIterator anIt(theCompound);
GeomShapePtr aFoundSub;
for (; anIt.more() && !aFoundSub; anIt.next()) {
- aFoundSub = anIt.current();
- if (aFoundSub->shapeType() != theShapeType)
- return GeomShapePtr(); // not alone sub-shape
+ return anIt.current();
}
- if (anIt.more()) {
- std::string anError = "Error: unable to build a ";
- switch (theShapeType) {
- case GeomAPI_Shape::SOLID: anError += "solid"; break;
- case GeomAPI_Shape::COMPSOLID: anError += "compsolid"; break;
- default: anError += "subshape"; break;
- }
- setError(anError);
- } else
- return aFoundSub;
- }
- // not a solid
- return GeomShapePtr();
-}
-
-bool BuildPlugin_Solid::isAlgorithmFailed(
- const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm)
-{
- if (!theAlgorithm->isDone()) {
- static const std::string aFeatureError = "Error: MakeVolume algorithm failed.";
- setError(aFeatureError);
- return true;
- }
- if (theAlgorithm->shape()->isNull()) {
- static const std::string aShapeError = "Error: Resulting shape of MakeVolume is Null.";
- setError(aShapeError);
- return true;
- }
- if (!theAlgorithm->isValid()) {
- std::string aFeatureError = "Error: Resulting shape of MakeVolume is not valid.";
- setError(aFeatureError);
- return true;
}
- return false;
+ return theCompound;
}
BUILDPLUGIN_EXPORT virtual void execute();
protected:
- /// Build result
- /// \param[out] theOriginalShapes list of original shapes
- /// \param[out] theAlgorithm algorithm to build result
- /// \return \c true if algorithm finished without errors
- bool build(ListOfShape& theOriginalShapes, std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
-
/// Store result of algorithm
void storeResult(const ListOfShape& theOriginalShapes,
const GeomShapePtr& theResultShape,
const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
- /// Check the algorithm is failed
- bool isAlgorithmFailed(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgorithm);
-
- /// Explode compound to get single shape of specified type
- /// \return Empty shape if there is more than one shape in compound
- GeomShapePtr getSingleSubshape(const GeomShapePtr& theCompound,
- const GeomAPI_Shape::ShapeType theShapeType);
+ /// Explode compound to get single shape
+ GeomShapePtr getSingleSubshape(const GeomShapePtr& theCompound);
};
#endif
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAlgoAPI_SketchBuilder.h>
#include <GeomAlgoAPI_WireBuilder.h>
+#include <GeomAlgoAPI_MakeVolume.h>
+#include <GeomAPI_ShapeIterator.h>
+#include <GeomAPI_ShapeExplorer.h>
#include <GeomValidators_FeatureKind.h>
#include <GeomValidators_ShapeType.h>
return true;
}
-//=================================================================================================
-bool BuildPlugin_ValidatorBaseForWire::isNotObligatory(std::string theFeature,
- std::string theAttribute)
-{
- return false;
-}
-
//=================================================================================================
bool BuildPlugin_ValidatorBaseForFace::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
}
//=================================================================================================
-bool BuildPlugin_ValidatorBaseForFace::isNotObligatory(std::string theFeature,
- std::string theAttribute)
+bool BuildPlugin_ValidatorBaseForSolids::isValid(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature, const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
{
- return false;
+ // Get base objects list.
+ AttributeSelectionListPtr aSelectionList = theFeature->selectionList(theArguments.front());
+ if (!aSelectionList.get()) {
+ theError = "Could not get selection list.";
+ return false;
+ }
+ if (aSelectionList->size() == 0) {
+ theError = "Empty selection list.";
+ return false;
+ }
+
+ // Collect base shapes.
+ ListOfShape anOriginalShapes;
+ for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
+ AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
+ GeomShapePtr aShape = aSelection->value();
+ if (!aShape.get())
+ aShape = aSelection->context()->shape();
+ anOriginalShapes.push_back(aShape);
+ }
+
+ std::shared_ptr<GeomAlgoAPI_MakeVolume> anAlgorithm(new GeomAlgoAPI_MakeVolume(anOriginalShapes));
+
+ if (!anAlgorithm->isDone()) {
+ theError = "MakeVolume algorithm failed.";
+ return false;
+ }
+ if (anAlgorithm->shape()->isNull()) {
+ theError = "Resulting shape of MakeVolume is Null.";
+ return false;
+ }
+ if (!anAlgorithm->isValid()) {
+ theError = "Resulting shape of MakeVolume is not valid.";
+ return false;
+ }
+
+ // set of allowed types of results
+ std::set<GeomAPI_Shape::ShapeType> aResultType;
+ std::string aType = theArguments.back();
+ if (aType == "solid")
+ aResultType.insert(GeomAPI_Shape::SOLID);
+ else if (aType == "compsolid") {
+ aResultType.insert(GeomAPI_Shape::COMPSOLID);
+ aResultType.insert(GeomAPI_Shape::SOLID);
+ }
+
+ GeomShapePtr aCompound = anAlgorithm->shape();
+ if (aCompound->shapeType() == GeomAPI_Shape::COMPOUND) {
+ GeomAPI_ShapeIterator anIt(aCompound);
+ GeomShapePtr aFoundSub;
+ for (; anIt.more() && !aFoundSub; anIt.next()) {
+ aFoundSub = anIt.current();
+ if (aResultType.count(aFoundSub->shapeType()) == 0) {
+ theError = "Unable to build a solid";
+ return false;
+ }
+ }
+ if (anIt.more() || !aFoundSub.get()) {
+ theError = "Unable to build a solid";
+ return false;
+ }
+ } else if (aResultType.count(aCompound->shapeType()) == 0) {
+ theError = "Unable to build a solid";
+ return false;
+ }
+ // check the internal faces presence
+ for(GeomAPI_ShapeExplorer aFaces(aCompound, GeomAPI_Shape::FACE); aFaces.more(); aFaces.next()) {
+ if (aFaces.current()->orientation() == GeomAPI_Shape::INTERNAL) {
+ theError = "Internal faces are not allowed in the resulting solid";
+ return false;
+ }
+ }
+
+ return true;
}
+
//=================================================================================================
bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const;
-
- /// \return true if the attribute in feature is not obligatory for the feature execution
- virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
};
/// \class BuildPlugin_ValidatorBaseForFace
virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const;
+};
- /// \return true if the attribute in feature is not obligatory for the feature execution
- virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
+/// \class BuildPlugin_ValidatorBaseForSolids
+/// \ingroup Validators
+/// \brief A validator for selection base shapes for solid. Allows to select faces closed enough
+/// to create a solid.
+class BuildPlugin_ValidatorBaseForSolids: public ModelAPI_FeatureValidator
+{
+public:
+ //! Returns true if attributes is ok.
+ //! \param theFeature the checked feature.
+ //! \param theArguments arguments of the feature.
+ //! \param theError error message.
+ virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const;
};
/// \class BuildPlugin_ValidatorSubShapesSelection
concealment="true">
<validator id="BuildPlugin_ValidatorBaseForBuild" parameters="face,shell,solid,compsolid"/>
</multi_selector>
+ <validator id="BuildPlugin_ValidatorBaseForSolids" parameters="base_objects,compsolid"/>
</source>
concealment="true">
<validator id="BuildPlugin_ValidatorBaseForBuild" parameters="face,shell"/>
</multi_selector>
+ <validator id="BuildPlugin_ValidatorBaseForSolids" parameters="base_objects,solid"/>
</source>
return true;
}
-//==================================================================================================
-bool FeaturesPlugin_ValidatorPipeLocations::isNotObligatory(std::string theFeature,
- std::string theAttribute)
-{
- return false;
-}
-
//==================================================================================================
bool FeaturesPlugin_ValidatorBaseForGeneration::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
return true;
}
-//==================================================================================================
-bool FeaturesPlugin_ValidatorBaseForGenerationSketchOrSketchObjects::isNotObligatory(
- std::string theFeature,
- std::string theAttribute)
-{
- return false;
-}
-
//==================================================================================================
bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
return true;
}
-//==================================================================================================
-bool FeaturesPlugin_ValidatorExtrusionDir::isNotObligatory(std::string theFeature,
- std::string theAttribute)
-{
- return false;
-}
-
//==================================================================================================
bool FeaturesPlugin_ValidatorExtrusionDir::isShapesCanBeEmpty(const AttributePtr& theAttribute,
Events_InfoMessage& theError) const
return true;
}
-//==================================================================================================
-bool FeaturesPlugin_ValidatorRemoveSubShapesResult::isNotObligatory(std::string theFeature,
- std::string theAttribute)
-{
- return false;
-}
-
//==================================================================================================
bool FeaturesPlugin_ValidatorUnionSelection::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
return true;
}
-//==================================================================================================
-bool FeaturesPlugin_ValidatorUnionArguments::isNotObligatory(std::string theFeature,
- std::string theAttribute)
-{
- return false;
-}
-
bool FeaturesPlugin_ValidatorConcealedResult::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const;
-
- /// Returns true if the attribute in feature is not obligatory for the feature execution
- virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
};
/// \class FeaturesPlugin_ValidatorBaseForGeneration
virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const;
-
- /// Returns true if the attribute in feature is not obligatory for the feature execution
- virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
};
/// \class FeaturesPlugin_ValidatorCompositeLauncher
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const;
- /// \return true if the attribute in feature is not obligatory for the feature execution
- virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
-
private:
bool isShapesCanBeEmpty(const AttributePtr& theAttribute,
Events_InfoMessage& theError) const;
virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const;
-
- /// \return true if the attribute in feature is not obligatory for the feature execution
- virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
};
/// \class FeaturesPlugin_ValidatorUnionSelection
virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const;
-
- /// \return true if the attribute in feature is not obligatory for the feature execution
- virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
};
/// \class FeaturesPlugin_ValidatorConcealedResult
return true;
}
-
-//================================================================================================
-bool GeomValidators_MinObjectsSelected::isNotObligatory(std::string theFeature,
- std::string theAttribute)
-{
- return false;
-}
GEOMVALIDATORS_EXPORT virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const;
-
- /// \return true if the attribute in feature is not obligatory for the feature execution.
- GEOMVALIDATORS_EXPORT virtual bool isNotObligatory(std::string theFeature,
- std::string theAttribute);
};
#endif
Test2358_2.py
Test2396.py
Test2401.py
+ Test2413.py
)
{
}
+
+bool ModelAPI_FeatureValidator::isNotObligatory(std::string theFeature, std::string theAttribute)
+{
+ return false;
+}
\ No newline at end of file
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const = 0;
- /// Returns true if the attribute in feature is not obligatory for the feature execution
- virtual bool isNotObligatory(std::string theFeature, std::string theAttribute) = 0;
+ /// Returns true if the attribute in feature is not obligatory for the feature execution.
+ ///Returns false by default.
+ virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
};
#endif
--- /dev/null
+## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(0, 0, 0, 50)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.result())
+SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
+SketchLine_2 = SketchProjection_2.createdFeature()
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.result())
+SketchArc_1 = Sketch_1.addArc(0, 0, 0, 50, 50, 0, True)
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.center())
+SketchLine_3 = Sketch_1.addLine(0, 0, 50, 0)
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
+SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
+SketchLine_4 = SketchProjection_3.createdFeature()
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.result())
+SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.endPoint())
+SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint())
+SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 50)
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchArc_1_2f-SketchLine_3f")], model.selection(), 100, 0)
+model.do()
+Solid_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face_3")]
+Solid_1 = model.addSolid(Part_1_doc, Solid_1_objects)
+# check that resulting build-solid feature is invalid: only one not-closed face is used
+from ModelAPI import *
+aFactory = ModelAPI_Session.get().validators()
+assert(aFactory.validate(Solid_1.feature()) == False)
+ModelAPI_Session.get().abortOperation()
+# another try: to make a solid with a face inside
+model.begin()
+Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1"), 70, True)
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
+SketchLine_5 = Sketch_2.addLine(14.9039069695087, 8.923908092675951, 26.86805702948195, 11.13714035991706)
+SketchLine_6 = Sketch_2.addLine(26.86805702948195, 11.13714035991706, 18.50962242738747, 32.13572332177004)
+SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_9")
+SketchLine_7 = Sketch_2.addLine(18.50962242738747, 32.13572332177004, 14.9039069695087, 8.923908092675951)
+SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
+SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10")
+SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_7.endPoint())
+SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11")
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f")])
+Solid_2_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), model.selection("FACE", "Extrusion_1_1/Generated_Face_2"), model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("FACE", "Extrusion_1_1/From_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), model.selection("FACE", "Face_1_1")]
+Solid_2 = model.addSolid(Part_1_doc, Solid_2_objects)
+model.end()
+
+assert(aFactory.validate(Solid_2.feature()) == False)
+
+assert(model.checkPythonDump())
#include <ModelAPI_Feature.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
+#include <ModelAPI_Result.h>
#include "ModelHighAPI_Selection.h"
//--------------------------------------------------------------------------------------
ModelHighAPI_Selection ModelHighAPI_Interface::result() const
{
- const_cast<ModelHighAPI_Interface*>(this)->execute();
-
- return ModelHighAPI_Selection(feature()->firstResult());
+ std::list<ModelHighAPI_Selection> aResults = results();
+ if (aResults.empty())
+ return ModelHighAPI_Selection(std::shared_ptr<ModelAPI_Result>());
+ return aResults.front();
}
std::list<ModelHighAPI_Selection> ModelHighAPI_Interface::results() const
std::list<std::shared_ptr<ModelAPI_Result> > aResults = feature()->results();
for (auto it = aResults.begin(), end = aResults.end(); it != end; ++it) {
- aSelectionList.push_back(ModelHighAPI_Selection(*it));
+ if (!(*it)->isDisabled())
+ aSelectionList.push_back(ModelHighAPI_Selection(*it));
}
return aSelectionList;