//=================================================================================================
FeaturesAPI_Recover::FeaturesAPI_Recover(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Reference& theBaseFeature,
- const std::list<ModelHighAPI_Selection>& theRecoveredList, const bool thePersistent)
+ const std::list<ModelHighAPI_Selection>& theRecoveredList,
+ const bool theRecoverCompound)
: ModelHighAPI_Interface(theFeature)
{
if(initialize()) {
+ std::string aMethod = theRecoverCompound ? FeaturesPlugin_Recover::METHOD_COMPOUND()
+ : FeaturesPlugin_Recover::METHOD_DEFAULT();
+ fillAttribute(aMethod, theFeature->string(FeaturesPlugin_Recover::METHOD()));
+
setBaseFeature(theBaseFeature);
setRecoveredList(theRecoveredList);
}
FeaturePtr aFeature = ModelAPI_Feature::feature(anAttrBaseFeature->value());
theDumper << aBase << " = model.addRecover(" << aDocName << ", "
- << aFeature << ", " << anAttrRecoveredEntities << ")" << std::endl;
+ << aFeature << ", " << anAttrRecoveredEntities;
+
+ AttributeStringPtr aMethod = aBase->string(FeaturesPlugin_Recover::METHOD());
+ if (aMethod && aMethod->isInitialized() &&
+ aMethod->value() != FeaturesPlugin_Recover::METHOD_DEFAULT())
+ theDumper << ", " << true;
+
+ theDumper << ")" << std::endl;
}
//=================================================================================================
RecoverPtr addRecover(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Reference& theBaseFeature,
- const std::list<ModelHighAPI_Selection>& theRecoveredList, const bool thePersistent)
+ const std::list<ModelHighAPI_Selection>& theRecoveredList, const bool theRecoverCompound)
{
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Recover::ID());
return RecoverPtr(new FeaturesAPI_Recover(
- aFeature, theBaseFeature, theRecoveredList, thePersistent));
+ aFeature, theBaseFeature, theRecoveredList, theRecoverCompound));
}
FeaturesAPI_Recover(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Reference& theBaseFeature,
const std::list<ModelHighAPI_Selection>& theRecoveredList,
- const bool thePersistent = false);
+ const bool theRecoverCompound = false);
/// Destructor.
FEATURESAPI_EXPORT
RecoverPtr addRecover(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Reference& theBaseFeature,
const std::list<ModelHighAPI_Selection>& theRecoveredList,
- const bool thePersistent = false);
+ const bool theRecoverCompound = false);
#endif // FeaturesAPI_Recover_H_
TestPipe_Compound.py
TestPipe_ErrorMsg.py
TestRecover.py
+ TestRecover_Compound.py
+ TestRecover_Compsolid1.py
+ TestRecover_Compsolid2.py
TestRecover1798.py
TestSplitEdgeVertex.py
TestSplitEdgeEdge.py
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeString.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Result.h>
data()->addAttribute(BASE_FEATURE(), ModelAPI_AttributeReference::typeId());
data()->addAttribute(RECOVERED_ENTITIES(), ModelAPI_AttributeRefList::typeId());
+ data()->addAttribute(METHOD(), ModelAPI_AttributeString::typeId());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), METHOD());
}
void FeaturesPlugin_Recover::execute()
removeResults(aResultIndex);
}
+
+void FeaturesPlugin_Recover::attributeChanged(const std::string& theID)
+{
+ if (theID == METHOD())
+ reflist(RECOVERED_ENTITIES())->clear();
+}
return MY_RECOVERED_ENTITIES_ID;
}
+ /// Attribute name of the type of recover.
+ inline static const std::string& METHOD()
+ {
+ static const std::string MY_METHOD_ID("method");
+ return MY_METHOD_ID;
+ }
+
+ /// Value of default method, recovering concealed objects only.
+ inline static const std::string& METHOD_DEFAULT()
+ {
+ static const std::string MY_METHOD_ID("default");
+ return MY_METHOD_ID;
+ }
+ /// Value of method, recovering parent compounds of concealed objects.
+ inline static const std::string& METHOD_COMPOUND()
+ {
+ static const std::string MY_METHOD_ID("compound");
+ return MY_METHOD_ID;
+ }
+
/// Returns the kind of a feature
FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
{
/// Request for initialization of data model of the feature: adding all attributes
FEATURESPLUGIN_EXPORT virtual void initAttributes();
+ /// Called on change of any argument-attribute of this object
+ /// \param theID identifier of changed attribute
+ FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
/// Use plugin manager for features creation
FeaturesPlugin_Recover();
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 10, 50)
+LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1")], model.selection("EDGE", "PartSet/OX"), 50, 2)
+LinearCopy_2 = model.addMultiTranslation(Part_1_doc, [model.selection("COMPOUND", "LinearCopy_1_1")], model.selection("EDGE", "PartSet/OY"), 50, 3)
+Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
+SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "([LinearCopy_2_1_2_1/MF:Translated&Cylinder_1_1/Face_1][LinearCopy_2_1_2_1/MF:Translated&Cylinder_1_1/Face_2])([LinearCopy_2_1_2_1/MF:Translated&Cylinder_1_1/Face_1][LinearCopy_2_1_2_1/MF:Translated&Cylinder_1_1/Face_3])"), False)
+SketchLine_1 = SketchProjection_1.createdFeature()
+SketchCircle_1 = Sketch_1.addCircle(50, 25, 5)
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 5)
+SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchCircle_1.center(), SketchLine_1.result())
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f")], model.selection(), 100, 0)
+Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "LinearCopy_2_1_2_2")], [model.selection("SOLID", "Extrusion_1_1")], 20190506)
+Recover_1 = model.addRecover(Part_1_doc, Cut_1, [LinearCopy_2.result()], True)
+model.do()
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Part_1, 1)
+model.testNbSubResults(Part_1, [0])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [12])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [37])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [82])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [164])
+model.testResultsVolumes(Part_1, [186975.51922585917])
+
+assert(model.checkPythonDump())
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+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(31.9410018961801, -31.48668563219184, -26.28238891138439, -31.48668563219184)
+SketchLine_2 = Sketch_1.addLine(-26.28238891138439, -31.48668563219184, -26.28238891138439, 32.16845339608692)
+SketchLine_3 = Sketch_1.addLine(-26.28238891138439, 32.16845339608692, 31.9410018961801, 32.16845339608692)
+SketchLine_4 = Sketch_1.addLine(31.9410018961801, 32.16845339608692, 31.9410018961801, -31.48668563219184)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchLine_5 = Sketch_1.addLine(-26.28238891138439, -12.06888707668976, 31.9410018961801, 21.15910771625288)
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_2.result())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_4.result())
+SketchLine_6 = Sketch_1.addLine(-0.02931756086478185, 2.913698204490415, 1.128717663020605, -31.48668563219184)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.startPoint(), SketchLine_5.result())
+SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_1.result())
+model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 50, 0)
+Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_4"))
+SketchCircle_1 = Sketch_2.addCircle(-4.420087352215441, 24.04732854606771, 12.87676926472621)
+model.do()
+Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_2/Face-SketchCircle_1_2r_wire")], model.selection(), 20, 80)
+Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1_2")], [model.selection("SOLID", "Extrusion_2_1")], 20190506)
+Recover_1 = model.addRecover(Part_1_doc, Cut_1, [Extrusion_1.result()], True)
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Part_1, 1)
+model.testNbSubResults(Part_1, [0])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [6])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [41])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [182])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [364])
+model.testResultsVolumes(Part_1, [354429.714290673])
+
+assert(model.checkPythonDump())
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 100, 100, 100)
+Translation_1 = model.addTranslation(Part_1_doc, [model.selection("SOLID", "Box_1_1")], -50, -50, -50)
+Partition_1_objects = [model.selection("SOLID", "Translation_1_1"), model.selection("FACE", "PartSet/XOY"), model.selection("FACE", "PartSet/YOZ"), model.selection("FACE", "PartSet/XOZ")]
+Partition_1 = model.addPartition(Part_1_doc, Partition_1_objects, 20190506)
+CompSolid_1_objects = [model.selection("SOLID", "Partition_1_1_1"), model.selection("SOLID", "Partition_1_1_5"), model.selection("SOLID", "Partition_1_1_6"), model.selection("SOLID", "Partition_1_1_8")]
+CompSolid_1 = model.addCompSolid(Part_1_doc, CompSolid_1_objects)
+Recover_1 = model.addRecover(Part_1_doc, CompSolid_1, [Partition_1.result()], True)
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Part_1, 1)
+model.testNbSubResults(Part_1, [0])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.SOLID, [12])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.FACE, [72])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.EDGE, [288])
+model.testNbSubShapes(Part_1, GeomAPI_Shape.VERTEX, [576])
+model.testResultsVolumes(Part_1, [1500000])
+
+assert(model.checkPythonDump())
tooltip="Select a feature that conceals results.">
<validator id="FeaturesPlugin_ValidatorConcealedResult" parameters="recovered"/>
</feature_selector>
- <concealed_objects_view id="recovered"
- tooltip="Concealed results to be recevered"
- base_shape_attribute="base_feature"/>
+ <toolbox id="method">
+ <box id="default" title="Concealed results" icon="icons/Features/recover_default_32x32.png">
+ <concealed_objects_view id="recovered"
+ tooltip="Concealed results to be recevered"
+ base_shape_attribute="base_feature"/>
+ </box>
+ <box id="compound" title="Concealed compounds" icon="icons/Features/recover_compound_32x32.png">
+ <concealed_objects_view id="recovered"
+ tooltip="Concealed results to be recevered"
+ base_shape_attribute="base_feature"
+ pick_concealed_parents="1"/>
+ </box>
+ </toolbox>
</source>
#include <ModuleBase_Tools.h>
#include <ModelAPI_Result.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_Session.h>
#include <QCheckBox>
#include <QVBoxLayout>
+#include <algorithm>
+
const int DEFAULT_NAME_COLUMN_WIDTH = 200;
ModuleBase_WidgetConcealedObjects::ModuleBase_WidgetConcealedObjects(QWidget* theParent,
: ModuleBase_ModelWidget(theParent, theData)
{
myBaseShapeAttribute = theData->getProperty("base_shape_attribute");
+ std::string aPickParents = theData->getProperty("pick_concealed_parents");
+ std::transform(aPickParents.begin(), aPickParents.end(), aPickParents.begin(), std::tolower);
+ myPickConcealedParents = aPickParents == "1" || aPickParents == "true" || aPickParents == "yes";
+
QGridLayout* aMainLay = new QGridLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
myBaseFeature = aBaseFeature;
if (myBaseFeature.get()) {
std::list<std::shared_ptr<ModelAPI_Result> > aResults;
+ std::set<ResultBodyPtr> aParents;
ModelAPI_Tools::getConcealedResults(myBaseFeature, aResults);
std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator anIt = aResults.begin(),
aLast = aResults.end();
for (; anIt != aLast; anIt++) {
ResultPtr aResult = *anIt;
+ if (myPickConcealedParents) {
+ // pick the parent result of the concealed object
+ ResultBodyPtr aRootParent = ModelAPI_Tools::bodyOwner(aResult, true);
+ if (aRootParent) {
+ if (aParents.find(aRootParent) == aParents.end()) {
+ aResult = aRootParent;
+ aParents.insert(aRootParent);
+ }
+ else // do not add parent compound once again
+ continue;
+ }
+ }
int aRowId = myView->rowCount();
addViewRow(aResult);
private:
std::string myBaseShapeAttribute; ///< attribute of the base object
+ bool myPickConcealedParents; ///< select parent compsolid/compounds of concealed objects
QTableWidget* myView; ///< table view of visibility states
std::shared_ptr<ModelAPI_Feature> myBaseFeature; ///< backup of feature of filling the table view