#include "FeaturesPlugin_BooleanCut.h"
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Tools.h>
return;
}
ResultPtr aContext = anObjectAttr->context();
- ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
+ ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext);
if (aResCompSolidPtr.get())
{
std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
if(aResultBody.get()) {
continue;
}
+ FeaturePtr aResultFeature = aSelectAttr->contextFeature();
+ if(aResultFeature.get()) {
+ bool aOkRes = false;
+ std::list<ResultPtr>::const_iterator aFRes = aResultFeature->results().cbegin();
+ for(; aFRes != aResultFeature->results().cend() && !aOkRes; aFRes++) {
+ ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aFRes);
+ if (aBody.get() && !aBody->isDisabled())
+ aOkRes = true;
+ }
+ if (aOkRes)
+ continue;
+ }
theError = "Error: Only body shapes and construction planes are allowed for selection.";
return false;
model.end()
PartitionFeature = Partition_1.feature()
assert(len(PartitionFeature.results()) == 1)
-PartitionResult = modelAPI_ResultCompSolid(modelAPI_ResultBody(PartitionFeature.firstResult()))
+PartitionResult = modelAPI_ResultBody(PartitionFeature.firstResult())
assert(PartitionResult.numberOfSubs() == 22)
assert(model.checkPythonDump())
#=========================================================================
aSession.startOperation()
aBooleanFt = aPart.addFeature("Cut")
-aBooleanFt.selectionList("main_objects").append(modelAPI_ResultCompSolid(extrudedObjects[0]).subResult(1), None)
+aBooleanFt.selectionList("main_objects").append(extrudedObjects[0].subResult(1), None)
aBooleanFt.selectionList("tool_objects").append(extrudedObjects[1], None)
aBooleanFt.execute()
aSession.finishOperation()
#=========================================================================
aSession.startOperation()
aBooleanFt = aPart.addFeature("Fuse")
-aBooleanFt.selectionList("main_objects").append(modelAPI_ResultCompSolid(extrudedObjects[0]).subResult(1), None)
+aBooleanFt.selectionList("main_objects").append(extrudedObjects[0].subResult(1), None)
aBooleanFt.selectionList("tool_objects").append(extrudedObjects[1], None)
aBooleanFt.execute()
aSession.finishOperation()
aFromShape = modelAPI_ResultConstruction(aFromResult).shape()
anExtrusionCutFt.selection("from_object").setValue(aFromResult, aFromShape)
anExtrusionCutFt.real("from_offset").setValue(0)
-anExtrusionCutFt.selectionList("main_objects").append(modelAPI_ResultCompSolid(anExtrusionResult).subResult(1), None)
+anExtrusionCutFt.selectionList("main_objects").append(anExtrusionResult.subResult(1), None)
aSession.finishOperation()
aSession.finishOperation()
anRevolutionFuseFt.real("to_offset").setValue(0)
anRevolutionFuseFt.selection("from_object").setValue(None, None)
anRevolutionFuseFt.real("from_offset").setValue(0)
-anRevolutionFuseFt.selectionList("main_objects").append(modelAPI_ResultCompSolid(anExtrusionResult).subResult(1), None)
+anRevolutionFuseFt.selectionList("main_objects").append(anExtrusionResult.subResult(1), None)
aSession.finishOperation()
aSession.finishOperation()
anExtrusionFeature.real("from_offset").setValue(0) #TODO: remove
anExtrusionFeature.execute()
aSession.finishOperation()
-anExtrusionResult = modelAPI_ResultCompSolid(modelAPI_ResultBody(anExtrusionFeature.firstResult()))
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFeature.firstResult())
#=========================================================================
# Remove sub-shapes
aRemoveSubShapesFeature.selectionList("subshapes_to_keep").removeLast();
aSession.finishOperation()
assert (len(aRemoveSubShapesFeature.results()) > 0)
-anUnionResult = modelAPI_ResultCompSolid(modelAPI_ResultBody(aRemoveSubShapesFeature.firstResult()))
+anUnionResult = modelAPI_ResultBody(aRemoveSubShapesFeature.firstResult())
assert (anUnionResult.numberOfSubs() == 2)
from salome.shaper import model
anExtrusionFeature.real("from_offset").setValue(0) #TODO: remove
anExtrusionFeature.execute()
aSession.finishOperation()
-anExtrusionResult = modelAPI_ResultCompSolid(modelAPI_ResultBody(anExtrusionFeature.firstResult()))
+anExtrusionResult = modelAPI_ResultBody(anExtrusionFeature.firstResult())
#=========================================================================
# Make union on extrusion
aUnionFeature.selectionList("base_objects").append(anExtrusionResult.subResult(2), None);
aSession.finishOperation()
assert (len(aUnionFeature.results()) > 0)
-anUnionResult = modelAPI_ResultCompSolid(modelAPI_ResultBody(aUnionFeature.firstResult()))
+anUnionResult = modelAPI_ResultBody(aUnionFeature.firstResult())
assert (anUnionResult.numberOfSubs() == 0)
from salome.shaper import model
--- /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>
+//
+
+#include <GeomAPI_Interface.h>
+
+GeomAPI_Interface::GeomAPI_Interface()
+{
+
+}
+
+GeomAPI_Interface::~GeomAPI_Interface()
+{
+
+}
+
+bool GeomAPI_Interface::empty() const
+{
+ return myImpl.get() == 0;
+}
}
ResultPtr Model_AttributeSelection::context()
+{
if (!ModelAPI_AttributeSelection::isInitialized() && !myTmpContext.get() && !myTmpSubShape.get())
return ResultPtr();
return FeaturePtr(); // feature can not be selected temporarily
}
return std::dynamic_pointer_cast<ModelAPI_Feature>(myRef.value());
-
}
-
+ObjectPtr Model_AttributeSelection::contextObject() {
+ ResultPtr aRes = context();
+ if (aRes.get())
+ return aRes;
+ return contextFeature();
+}
void Model_AttributeSelection::setObject(const std::shared_ptr<ModelAPI_Object>& theObject)
aNS = TNaming_Tool::CurrentNamedShape(aNS);
if (!aNS.IsNull() && scope().Contains(aNS->Label())) { // scope check is for 2228
TDF_Label aLab = aNS->Label();
- while(aLab.Depth() != 7 && aLab.Depth() > 5)
+ if (aLab.Depth() % 2 == 0)
aLab = aLab.Father();
ObjectPtr anObj = aDoc->objects()->object(aLab);
+ while(!anObj.get() && aLab.Depth() > 5) {
+ aLab = aLab.Father().Father();
+ anObj = aDoc->objects()->object(aLab);
+ }
+
if (anObj.get()) {
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
if (aRes)
if (aComp && aComp->numberOfSubs()) {
std::list<ResultPtr> allSubs;
ModelAPI_Tools::allSubs(aComp, allSubs);
- std::list<ResultPtr>::reverse_iterator aS = allSubs.rbegin(); // iterate from lower level
- for(; aS != allSubs.rend(); aS++) {
- ResultPtr aSub = *aS;
- if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aShapeToBeSelected)) {
+ std::list<ResultPtr>::iterator aS = allSubs.begin();
+ for(; aS != allSubs.end(); aS++) {
+ ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aS);
+ if (aSub && aSub->numberOfSubs() == 0 && aSub->shape().get() &&
+ aSub->shape()->isSubShape(aShapeToBeSelected)) {
aCont = aSub;
break;
}
while(aFindNewContext && aCont.get()) {
aFindNewContext = false;
// take references to all results: root one, any sub
- ResultBodyPtr aCompContext = ModelAPI_Tools::bodyOwner(aCont);
+ ResultBodyPtr aCompContext = ModelAPI_Tools::bodyOwner(aCont, true);
std::list<ResultPtr> allRes;
- if (aCompContext.get())
+ if (aCompContext.get()) {
ModelAPI_Tools::allSubs(aCompContext, allRes);
- allRes.push_back(aCont);
+ allRes.push_back(aCompContext);
+ } else {
+ allRes.push_back(aCont);
+ }
for(std::list<ResultPtr>::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) {
ResultPtr aResCont = *aSub;
+ ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResCont);
+ // only lower and higher level subs are counted
+ if (aResBody.get() && aResBody->numberOfSubs() > 0 && aResBody != aCompContext)
+ continue;
const std::set<AttributePtr>& aRefs = aResCont->data()->refsToMe();
std::set<AttributePtr>::const_iterator aRef = aRefs.begin();
for(; !aFindNewContext && aRef != aRefs.end(); aRef++) {
/// Returns the context of the selection if the whole feature was selected
MODEL_EXPORT virtual FeaturePtr contextFeature();
+ /// Returns the context of the selection : result or feature
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Object> contextObject();
/// Sets the feature object
MODEL_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject);
void Model_BodyBuilder::evolutionToSelection(const bool theFlag)
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
- if (!aData) // unknown case
+ if (!aData || !aData->isValid()) // unknown case
return;
TDF_Label& aShapeLab = aData->shapeLab();
evolutionToSelectionRec(aShapeLab, theFlag);
std::shared_ptr<GeomAPI_Shape> Model_BodyBuilder::shape()
{
std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(data());
- if (aData) {
+ if (aData && aData->isValid()) {
TDF_Label aShapeLab = aData->shapeLab();
Handle(TDF_Reference) aRef;
if (aShapeLab.FindAttribute(TDF_Reference::GetID(), aRef)) {
bool isUserDefined = true;
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
if (aResult) {
- std::string aDefaultName = ModelAPI_Tools::getDefaultName(aResult).first;
+ std::string aDefaultName = ModelAPI_Tools::getDefaultName(aResult, false).first;
isUserDefined = aDefaultName != theName;
}
if (isUserDefined) {
if (aSub.get()) {
std::shared_ptr<Model_Data> aSubData = std::dynamic_pointer_cast<Model_Data>(
aSub->data());
- if (aSubData->label().Father().IsEqual(aSubLab.ChangeValue())) {
+ const TDF_Label& aSubLabVal = aSubLab.ChangeValue();
+ if (aSubData->label().Father().IsEqual(aSubLabVal)) {
aCurrentResult = aSub;
break;
}
}*/
(*aSubIter)->loadAndOrientModifiedShapes(
theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
- theIsStoreAsGenerated);
+ theIsStoreAsGenerated, theSplitInSubs);
}
} else { // do for this directly
- myBuilder->loadAndOrientGeneratedShapes(
- theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
+ myBuilder->loadAndOrientModifiedShapes(
+ theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
+ theIsStoreAsGenerated);
}
}
!aNS->Label().IsDescendant(aContextData->label())) {
isNeedContextName = false;
TDF_Label aNSDataLab = aNS->Label();
- while(aNSDataLab.Depth() != 7 && aNSDataLab.Depth() > 5)
+ if (aNSDataLab.Depth() % 2 == 0)
aNSDataLab = aNSDataLab.Father();
ObjectPtr aNewContext = theDoc->objects()->object(aNSDataLab);
- if (!aNewContext.get() && aNSDataLab.Depth() == 7) {
+ while(!aNewContext.get() && aNSDataLab.Depth() > 5) {
aNSDataLab = aNSDataLab.Father().Father();
aNewContext = theDoc->objects()->object(aNSDataLab);
}
/// Returns the context of the selection if the whole feature was selected
virtual std::shared_ptr<ModelAPI_Feature> contextFeature() = 0;
+ /// Returns the context of the selection : result or feature
+ virtual std::shared_ptr<ModelAPI_Object> contextObject() = 0;
/// Updates the underlied selection due to the changes in the referenced objects
/// \returns false if update is failed
ModelAPI_ResultBody::~ModelAPI_ResultBody()
{
- if (myBuilder)
- delete myBuilder;
}
std::string ModelAPI_ResultBody::groupName()
return CompositeFeaturePtr(); // not found
}
-ResultBodyPtr bodyOwner(const ResultPtr& theSub)
+ResultBodyPtr bodyOwner(const ResultPtr& theSub, const bool theRoot)
{
if (theSub.get()) {
ObjectPtr aParent = theSub->document()->parent(theSub);
if (aParent.get()) {
+ if (theRoot) { // try to find parent of parent
+ ResultPtr aResultParent = std::dynamic_pointer_cast<ModelAPI_Result>(aParent);
+ ResultBodyPtr aGrandParent = bodyOwner(aResultParent, true);
+ if (aGrandParent.get())
+ aParent = aGrandParent;
+ }
return std::dynamic_pointer_cast<ModelAPI_ResultBody>(aParent);
}
}
}
}
-std::pair<std::string, bool> getDefaultName(const std::shared_ptr<ModelAPI_Result>& theResult)
+std::pair<std::string, bool> getDefaultName(const std::shared_ptr<ModelAPI_Result>& theResult,
+ const bool theInherited)
{
typedef std::list< std::pair < std::string, std::list<ObjectPtr> > > ListOfReferences;
DataPtr aData = anOwner->data();
ListOfReferences aReferences;
- aData->referencesToObjects(aReferences);
-
// find first result with user-defined name
ListOfReferences::const_iterator aFoundRef = aReferences.end();
- for (ListOfReferences::const_iterator aRefIt = aReferences.begin();
- aRefIt != aReferences.end(); ++aRefIt) {
- bool isConcealed = aSession->validators()->isConcealed(anOwner->getKind(), aRefIt->first);
- bool isMainArg = isConcealed &&
- aSession->validators()->isMainArgument(anOwner->getKind(), aRefIt->first);
- if (isConcealed) {
- // check the referred object is a Body
- // (for example, ExtrusionCut has a sketch as a first attribute which is concealing)
- bool isBody = aRefIt->second.size() > 1 || (aRefIt->second.size() == 1 &&
- aRefIt->second.front()->groupName() == ModelAPI_ResultBody::group());
- if (isBody && (isMainArg || aFoundRef == aReferences.end() ||
- aData->isPrecedingAttribute(aRefIt->first, aFoundRef->first)))
- aFoundRef = aRefIt;
-
- if (isMainArg)
- break;
+ if (theInherited) {
+ aData->referencesToObjects(aReferences);
+
+ for (ListOfReferences::const_iterator aRefIt = aReferences.begin();
+ aRefIt != aReferences.end(); ++aRefIt) {
+ bool isConcealed = aSession->validators()->isConcealed(anOwner->getKind(), aRefIt->first);
+ bool isMainArg = isConcealed &&
+ aSession->validators()->isMainArgument(anOwner->getKind(), aRefIt->first);
+ if (isConcealed) {
+ // check the referred object is a Body
+ // (for example, ExtrusionCut has a sketch as a first attribute which is concealing)
+ bool isBody = aRefIt->second.size() > 1 || (aRefIt->second.size() == 1 &&
+ aRefIt->second.front()->groupName() == ModelAPI_ResultBody::group());
+ if (isBody && (isMainArg || aFoundRef == aReferences.end() ||
+ aData->isPrecedingAttribute(aRefIt->first, aFoundRef->first)))
+ aFoundRef = aRefIt;
+
+ if (isMainArg)
+ break;
+ }
}
}
// get the result number in the feature
/*!
* Returns the result - parent of this result.
* \param theSub the sub-element of composit result
+ * \param theRoot if it is true, returns the root father
* \returns null if it is not sub-element of composite
*/
MODELAPI_EXPORT std::shared_ptr<ModelAPI_ResultBody>
- bodyOwner(const std::shared_ptr<ModelAPI_Result>& theSub);
+ bodyOwner(const std::shared_ptr<ModelAPI_Result>& theSub, const bool theRoot = false);
/*!
* Returns index of this result in parent (if parent exists, returned by bodyOwner)
* \returns zero-base index, or -1 if not found
* (means that concealing result has user-defined name).
*/
MODELAPI_EXPORT std::pair<std::string, bool> getDefaultName(
- const std::shared_ptr<ModelAPI_Result>& theResult);
+ const std::shared_ptr<ModelAPI_Result>& theResult, const bool theInherited = true);
}
#endif
AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(attributeID());
for (int i = 0; i < aSelectionListAttr->size(); i++) {
AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
- bool aFound = findInSelection(anAttr->context(), anAttr->value(), aGeomSelection,
- myWorkshop);
+ bool aFound = findInSelection(
+ anAttr->contextObject(), anAttr->value(), aGeomSelection, myWorkshop);
if (!aFound)
anIndicesToBeRemoved.insert(i);
}
if (aCompRes.get()) {
VisibilityState aState = aCompRes->numberOfSubs(true) == 0 ?
(aWork->isVisible(aCompRes) ? Visible : Hidden) : NoneState;
- for (int i = 0; i < aCompRes->numberOfSubs(true); i++) {
- ResultPtr aSubRes = aCompRes->subResult(i, true);
+ std::list<ResultPtr> aResultsList;
+ ModelAPI_Tools::allSubs(aCompRes, aResultsList);
+
+ std::list<ResultPtr>::const_iterator aIt;
+ //for (int i = 0; i < aCompRes->numberOfSubs(true); i++) {
+ for (aIt = aResultsList.cbegin(); aIt != aResultsList.cend(); aIt++) {
+ ResultPtr aSubRes = (*aIt); // aCompRes->subResult(i, true);
VisibilityState aS = aWork->isVisible(aSubRes) ? Visible : Hidden;
if (aState == NoneState)
aState = aS;
return NoneState;
}
+void PartSet_ObjectNode::update()
+{
+ ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myObject);
+ if (aCompRes.get()) {
+ int aNb = aCompRes->numberOfSubs(true);
+ ModuleBase_ITreeNode* aNode;
+ ResultBodyPtr aBody;
+ int i;
+ for (i = 0; i < aNb; i++) {
+ aBody = aCompRes->subResult(i, true);
+ if (i < myChildren.size()) {
+ aNode = myChildren.at(i);
+ if (aNode->object() != aBody) {
+ ((PartSet_ObjectNode*)aNode)->setObject(aBody);
+ }
+ } else {
+ aNode = new PartSet_ObjectNode(aBody, this);
+ myChildren.append(aNode);
+ }
+ }
+ // Delete extra objects
+ while (myChildren.size() > aNb) {
+ aNode = myChildren.takeLast();
+ delete aNode;
+ }
+ foreach(ModuleBase_ITreeNode* aNode, myChildren) {
+ aNode->update();
+ }
+ }
+}
+
+QTreeNodesList PartSet_ObjectNode::objectCreated(const QObjectPtrList& theObjects)
+{
+ QTreeNodesList aResult;
+
+ ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myObject);
+ if (aCompRes.get()) {
+ int aNb = aCompRes->numberOfSubs(true);
+ ModuleBase_ITreeNode* aNode;
+ ResultBodyPtr aBody;
+ int i;
+ for (i = 0; i < aNb; i++) {
+ aBody = aCompRes->subResult(i, true);
+ if (i < myChildren.size()) {
+ aNode = myChildren.at(i);
+ if (aNode->object() != aBody) {
+ ((PartSet_ObjectNode*)aNode)->setObject(aBody);
+ aResult.append(aNode);
+ }
+ } else {
+ aNode = new PartSet_ObjectNode(aBody, this);
+ myChildren.append(aNode);
+ aResult.append(aNode);
+ }
+ }
+ foreach(ModuleBase_ITreeNode* aNode, myChildren) {
+ aResult.append(aNode->objectCreated(theObjects));
+ }
+ }
+ return aResult;
+}
+QTreeNodesList PartSet_ObjectNode::objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup)
+{
+ QTreeNodesList aResult;
+ ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myObject);
+ if (aCompRes.get()) {
+ int aNb = aCompRes->numberOfSubs(true);
+ ModuleBase_ITreeNode* aNode;
+ // Delete extra objects
+ bool isDeleted = false;
+ while (myChildren.size() > aNb) {
+ aNode = myChildren.takeLast();
+ delete aNode;
+ isDeleted = true;
+ }
+ if (isDeleted)
+ aResult.append(this);
+ int i = 0;
+ foreach(ModuleBase_ITreeNode* aNode, myChildren) {
+ ((PartSet_ObjectNode*)aNode)->setObject(aCompRes->subResult(i, true));
+ aResult.append(aNode->objectsDeleted(theDoc, theGroup));
+ i++;
+ }
+ }
+ return aResult;
+}
//////////////////////////////////////////////////////////////////////////////////
PartSet_FolderNode::PartSet_FolderNode(ModuleBase_ITreeNode* theParent,
FolderType theType)
ModuleBase_ITreeNode* PartSet_FolderNode::createNode(const ObjectPtr& theObj)
{
- ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theObj);
- if (aCompRes.get())
- return new PartSet_CompsolidNode(theObj, this);
+ //ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObj);
+ //if (aCompRes.get())
+ // return new PartSet_CompsolidNode(theObj, this);
return new PartSet_ObjectNode(theObj, this);
}
//////////////////////////////////////////////////////////////////////////////////
-PartSet_CompsolidNode::PartSet_CompsolidNode(const ObjectPtr& theObj,
- ModuleBase_ITreeNode* theParent) : PartSet_ObjectNode(theObj, theParent)
-{
- update();
-}
-
-void PartSet_CompsolidNode::update()
-{
- ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myObject);
- int aNb = aCompRes->numberOfSubs(true);
- ModuleBase_ITreeNode* aNode;
- ResultBodyPtr aBody;
- int i;
- for (i = 0; i < aNb; i++) {
- aBody = aCompRes->subResult(i, true);
- if (i < myChildren.size()) {
- aNode = myChildren.at(i);
- if (aNode->object() != aBody) {
- ((PartSet_ObjectNode*)aNode)->setObject(aBody);
- }
- } else {
- aNode = new PartSet_ObjectNode(aBody, this);
- myChildren.append(aNode);
- }
- }
- // Delete extra objects
- while (myChildren.size() > aNb) {
- aNode = myChildren.takeLast();
- delete aNode;
- }
-}
-
-QTreeNodesList PartSet_CompsolidNode::objectCreated(const QObjectPtrList& theObjects)
-{
- QTreeNodesList aResult;
-
- ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myObject);
- int aNb = aCompRes->numberOfSubs(true);
- ModuleBase_ITreeNode* aNode;
- ResultBodyPtr aBody;
- int i;
- for (i = 0; i < aNb; i++) {
- aBody = aCompRes->subResult(i, true);
- if (i < myChildren.size()) {
- aNode = myChildren.at(i);
- if (aNode->object() != aBody) {
- ((PartSet_ObjectNode*)aNode)->setObject(aBody);
- aResult.append(aNode);
- }
- } else {
- aNode = new PartSet_ObjectNode(aBody, this);
- myChildren.append(aNode);
- aResult.append(aNode);
- }
- }
- return aResult;
-}
-
-QTreeNodesList PartSet_CompsolidNode::objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup)
-{
- QTreeNodesList aResult;
- ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myObject);
- int aNb = aCompRes->numberOfSubs(true);
- ModuleBase_ITreeNode* aNode;
- // Delete extra objects
- bool isDeleted = false;
- while (myChildren.size() > aNb) {
- aNode = myChildren.takeLast();
- delete aNode;
- isDeleted = true;
- }
- if (isDeleted)
- aResult.append(this);
- return aResult;
-}
\ No newline at end of file
+//PartSet_CompsolidNode::PartSet_CompsolidNode(const ObjectPtr& theObj,
+// ModuleBase_ITreeNode* theParent) : PartSet_ObjectNode(theObj, theParent)
+//{
+// update();
+//}
+
+//void PartSet_CompsolidNode::update()
+//{
+// ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(myObject);
+// int aNb = aCompRes->numberOfSubs(true);
+// ModuleBase_ITreeNode* aNode;
+// ResultBodyPtr aBody;
+// int i;
+// for (i = 0; i < aNb; i++) {
+// aBody = aCompRes->subResult(i, true);
+// if (i < myChildren.size()) {
+// aNode = myChildren.at(i);
+// if (aNode->object() != aBody) {
+// ((PartSet_ObjectNode*)aNode)->setObject(aBody);
+// }
+// } else {
+// aNode = new PartSet_ObjectNode(aBody, this);
+// myChildren.append(aNode);
+// }
+// }
+// // Delete extra objects
+// while (myChildren.size() > aNb) {
+// aNode = myChildren.takeLast();
+// delete aNode;
+// }
+//}
+//
+//QTreeNodesList PartSet_CompsolidNode::objectCreated(const QObjectPtrList& theObjects)
+//{
+// QTreeNodesList aResult;
+//
+// ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(myObject);
+// int aNb = aCompRes->numberOfSubs(true);
+// ModuleBase_ITreeNode* aNode;
+// ResultBodyPtr aBody;
+// int i;
+// for (i = 0; i < aNb; i++) {
+// aBody = aCompRes->subResult(i, true);
+// if (i < myChildren.size()) {
+// aNode = myChildren.at(i);
+// if (aNode->object() != aBody) {
+// ((PartSet_ObjectNode*)aNode)->setObject(aBody);
+// aResult.append(aNode);
+// }
+// } else {
+// aNode = new PartSet_ObjectNode(aBody, this);
+// myChildren.append(aNode);
+// aResult.append(aNode);
+// }
+// }
+// return aResult;
+//}
+//
+//QTreeNodesList PartSet_CompsolidNode::objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup)
+//{
+// QTreeNodesList aResult;
+// ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(myObject);
+// int aNb = aCompRes->numberOfSubs(true);
+// ModuleBase_ITreeNode* aNode;
+// // Delete extra objects
+// bool isDeleted = false;
+// while (myChildren.size() > aNb) {
+// aNode = myChildren.takeLast();
+// delete aNode;
+// isDeleted = true;
+// }
+// if (isDeleted)
+// aResult.append(this);
+// return aResult;
+//}
\ No newline at end of file
assert(shape.isEdge())
assert(name != ""), "String empty"
+def lowerLevelSubResults(theResult, theList):
+ """ Collects in a list all lover level sub-results (without children).
+ Auxiliary method for context correct definition.
+ """
+ nbSubs = theResult.numberOfSubs()
+ if nbSubs == 0:
+ theList.append(theResult)
+ else:
+ for sub in range(0, nbSubs):
+ lowerLevelSubResults(theResult.subResult(sub), theList)
+
def testHaveNamingByType(theFeature, theModel, thePartDoc, theSubshapeType) :
""" Tests if all sub-shapes of result have a unique name
:param theFeature: feature to test.
if not theFeature.results():
return
aFirstRes = theFeature.results()[0]
- # Get number of sub-results
- hasSubs = True
- nbSubs = aFirstRes.numberOfSubs()
- if nbSubs == 0:
- # no sub-results => treat current result as a sub
- hasSubs = False
- nbSubs = 1
+ aResList = []
+ lowerLevelSubResults(aFirstRes, aResList)
selectionList = []
shapesList = [] # to append only unique shapes (not isSame)
- for sub in range(0, nbSubs):
+ for aR in aResList:
# Get feature result/sub-result
- if hasSubs:
- aResult = aFirstRes.subResult(sub).resultSubShapePair()[0]
- else:
- aResult = aFirstRes.resultSubShapePair()[0]
+ aResult = aR.resultSubShapePair()[0]
# Get result/sub-result shape
shape = aResult.shape()
# Create shape explorer with desired shape type
# Shells
Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")])
Shell_1.result().setName("Shell_1_1")
-Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")])
+model.addRecover(Part_1_doc, Shell_1, [Face_10.result()])
+model.addRecover(Part_1_doc, Shell_1, [Face_11.result()])
+Shell_2 = model.addShell(Part_1_doc, [model.selection("FACE", "Recover_1_1"), model.selection("FACE", "Recover_2_1")])
Shell_2.result().setName("Shell_2_1")
-Shell_3 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")])
+model.addRecover(Part_1_doc, Shell_1, [Face_10.result()])
+model.addRecover(Part_1_doc, Shell_1, [Face_11.result()])
+Shell_3 = model.addShell(Part_1_doc, [model.selection("FACE", "Recover_3_1"), model.selection("FACE", "Recover_4_1")])
Shell_3.result().setName("Shell_3_1")
-Shell_4 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")])
+model.addRecover(Part_1_doc, Shell_1, [Face_10.result()])
+model.addRecover(Part_1_doc, Shell_1, [Face_11.result()])
+Shell_4 = model.addShell(Part_1_doc, [model.selection("FACE", "Recover_5_1"), model.selection("FACE", "Recover_6_1")])
Shell_4.result().setName("Shell_4_1")
-Shell_5 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")])
+model.addRecover(Part_1_doc, Shell_1, [Face_10.result()])
+model.addRecover(Part_1_doc, Shell_1, [Face_11.result()])
+Shell_5 = model.addShell(Part_1_doc, [model.selection("FACE", "Recover_7_1"), model.selection("FACE", "Recover_8_1")])
Shell_5.result().setName("Shell_5_1")
Shell_6 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_12_1"), model.selection("FACE", "Face_13_1")])
Shell_6.result().setName("Shell_6_1")
-Shell_7 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_12_1"), model.selection("FACE", "Face_13_1")])
+model.addRecover(Part_1_doc, Shell_1, [Face_12.result()])
+model.addRecover(Part_1_doc, Shell_1, [Face_13.result()])
+Shell_7 = model.addShell(Part_1_doc, [model.selection("FACE", "Recover_9_1"), model.selection("FACE", "Recover_10_1")])
Shell_7.result().setName("Shell_7_1")
-Shell_8 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")])
+model.addRecover(Part_1_doc, Shell_1, [Face_10.result()])
+model.addRecover(Part_1_doc, Shell_1, [Face_11.result()])
+Shell_8 = model.addShell(Part_1_doc, [model.selection("FACE", "Recover_11_1"), model.selection("FACE", "Recover_12_1")])
Shell_8.result().setName("Shell_8_1")
-Shell_9 = model.addShell(Part_1_doc, [model.selection("FACE", "Face_10_1"), model.selection("FACE", "Face_11_1")])
+model.addRecover(Part_1_doc, Shell_1, [Face_10.result()])
+model.addRecover(Part_1_doc, Shell_1, [Face_11.result()])
+Shell_9 = model.addShell(Part_1_doc, [model.selection("FACE", "Recover_13_1"), model.selection("FACE", "Recover_14_1")])
Shell_9.result().setName("Shell_9_1")
# Parameters
model.testNbResults(Translation_48, 0)
-assert(Translation_48.feature().error() == 'Attribute "axis_object" is not initialized.')
+assert(Translation_48.feature().error() == 'Translation axis is not selected.')
model.testNbResults(Translation_57, 0)
-assert(Translation_57.feature().error() == 'Attribute "axis_object" is not initialized.')
+assert(Translation_57.feature().error() == 'Translation axis is not selected.')
model.testNbResults(Translation_66, 0)
-assert(Translation_66.feature().error() == 'Attribute "axis_object" is not initialized.')
+assert(Translation_66.feature().error() == 'Translation axis is not selected.')
model.testNbResults(Translation_75, 0)
-assert(Translation_75.feature().error() == 'Attribute "axis_object" is not initialized.')
+assert(Translation_75.feature().error() == 'Translation axis is not selected.')
model.testNbResults(Translation_84, 0)
-assert(Translation_84.feature().error() == 'Attribute "axis_object" is not initialized.')
\ No newline at end of file
+assert(Translation_84.feature().error() == 'Translation axis is not selected.')