Removed ResultCompSolid class. Instead ResultBody may have any number of subs, or not.
#include <ModelAPI_Document.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeInteger.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Session.h>
return;
}
ResultPtr aContext = anObjectAttr->context();
- ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
+ ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext);
if(aResCompSolidPtr.get()
&& aResCompSolidPtr->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) {
std::shared_ptr<GeomAPI_Shape> aContextShape = aResCompSolidPtr->shape();
#include "FeaturesPlugin_CompositeBoolean.h"
#include <ModelAPI_AttributeSelectionList.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
#include <GeomAlgoAPI_Boolean.h>
return false;
}
ResultPtr aContext = anObjectAttr->context();
- ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
+ ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext);
if(aResCompSolidPtr.get()) {
GeomShapePtr aContextShape = aResCompSolidPtr->shape();
std::map<GeomShapePtr, ListOfShape>::iterator anIt = aCompSolidsObjects.begin();
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Validator.h>
return;
ResultPtr aContext = anObjectAttr->context();
- ResultCompSolidPtr aCtxOwner = ModelAPI_Tools::compSolidOwner(aContext);
+ ResultBodyPtr aCtxOwner = ModelAPI_Tools::bodyOwner(aContext);
GeomShapePtr aParent = aCtxOwner ? aCtxOwner->shape() : aContext->shape();
if (!aParent)
return;
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
}
ResultPtr aContext = aShapeAttrSelection->context();
- ResultCompSolidPtr aResultCompSolid =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aContext);
- if(!aResultCompSolid.get()) {
+ ResultBodyPtr aResultBody =
+ std::dynamic_pointer_cast<ModelAPI_ResultBody>(aContext);
+ if (!aResultBody.get()) {
aSubShapesToKeepAttrList->clear();
aSubShapesToRemoveAttrList->clear();
return;
}
- const int aNumOfSubs = aResultCompSolid->numberOfSubs();
+ const int aNumOfSubs = aResultBody->numberOfSubs();
GeomShapePtr aBaseShape = aShapeAttrSelection->value();
if(!aBaseShape.get()) {
if(aNumOfSubs == 0) {
aSubShapesToKeepAttrList->append(aContext, aSubShape);
} else {
- for(int anIndex = 0; anIndex < aResultCompSolid->numberOfSubs(); ++anIndex) {
- ResultBodyPtr aSubResult = aResultCompSolid->subResult(anIndex);
+ for (int anIndex = 0; anIndex < aResultBody->numberOfSubs(); ++anIndex) {
+ ResultBodyPtr aSubResult = aResultBody->subResult(anIndex);
if(aSubResult->shape()->isEqual(aSubShape)) {
aSubShapesToKeepAttrList->append(aSubResult, aSubShape);
break;
if(aNumOfSubs == 0) {
aSubShapesToRemoveAttrList->append(aContext, aSubShape);
} else {
- for(int anIndex = 0; anIndex < aResultCompSolid->numberOfSubs(); ++anIndex) {
- ResultBodyPtr aSubResult = aResultCompSolid->subResult(anIndex);
+ for (int anIndex = 0; anIndex < aResultBody->numberOfSubs(); ++anIndex) {
+ ResultBodyPtr aSubResult = aResultBody->subResult(anIndex);
if(aSubResult->shape()->isEqual(aSubShape)) {
aSubShapesToRemoveAttrList->append(aSubResult, aSubShape);
break;
if(aNumOfSubs == 0) {
aSubShapesToKeepAttrList->append(aContext, aSubShape);
} else {
- for(int anIndex = 0; anIndex < aResultCompSolid->numberOfSubs(); ++anIndex) {
- ResultBodyPtr aSubResult = aResultCompSolid->subResult(anIndex);
+ for (int anIndex = 0; anIndex < aResultBody->numberOfSubs(); ++anIndex) {
+ ResultBodyPtr aSubResult = aResultBody->subResult(anIndex);
if(aSubResult->shape()->isEqual(aSubShape)) {
aSubShapesToKeepAttrList->append(aSubResult, aSubShape);
break;
#include <GeomAPI_ShapeIterator.h>
#include <ModelAPI_AttributeSelectionList.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.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();
std::map<std::shared_ptr<GeomAPI_Shape>, ListOfShape>::iterator
#include "ModelAPI_AttributeSelectionList.h"
#include "ModelAPI_ResultPart.h"
#include "ModelAPI_ResultBody.h"
-#include "ModelAPI_ResultCompSolid.h"
#include "ModelAPI_Session.h"
bool FeaturesPlugin_ValidatorTransform::isValid(const AttributePtr& theAttribute,
else { // Part document: Result CompSolid is valid
aValid = aResult->groupName() == ModelAPI_ResultBody::group();
if (aValid) {
- ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
+ ResultBodyPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
aValid = aComp.get() != NULL;
}
}
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_Feature.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Tools.h>
return false;
}
- ResultCompSolidPtr aContextOwner = ModelAPI_Tools::compSolidOwner(aContext);
+ ResultBodyPtr aContextOwner = ModelAPI_Tools::bodyOwner(aContext);
GeomShapePtr anOwner = aContextOwner.get() ? aContextOwner->shape() : aContext->shape();
if (anOwner->shapeType() != GeomAPI_Shape::SOLID &&
return false;
}
- ResultCompSolidPtr aResultCompsolid =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aContext);
- if(aResultCompsolid.get()) {
+ ResultBodyPtr aResultBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aContext);
+ if(aResultBody.get()) {
continue;
}
return false;
}
- ResultCompSolidPtr aResult =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aContext);
+ ResultBodyPtr aResult =
+ std::dynamic_pointer_cast<ModelAPI_ResultBody>(aContext);
if(!aResult.get()) {
continue;
}
std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
bool isAllInSameCompSolid = true;
- ResultCompSolidPtr aCompSolid;
+ ResultBodyPtr aCompSolid;
AttributeSelectionListPtr anAttrSelList = theFeature->selectionList(*anIt);
if (anAttrSelList)
{
AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex);
ResultPtr aContext = anAttr->context();
- ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
+ ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext);
if (aResCompSolidPtr.get())
{
if (aCompSolid.get())
{
AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex);
ResultPtr aContext = anAttr->context();
- ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext);
+ ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext);
if (aResCompSolidPtr.get())
{
if (aCompSolid.get())
}
// additional check that the selected object is top-level result
if (theArguments.size() > 0 && *(theArguments.rbegin()) == "toplevel") {
- if (ModelAPI_Tools::compSolidOwner(aContext).get()) {
+ if (ModelAPI_Tools::bodyOwner(aContext).get()) {
theError = "Error: Only higher level shape allowed.";
return false;
}
Model_Update.h
Model_Validator.h
Model_ResultBody.h
- Model_ResultCompSolid.h
Model_ResultConstruction.h
Model_ResultPart.h
Model_ResultField.h
Model_Update.cpp
Model_Validator.cpp
Model_ResultBody.cpp
- Model_ResultCompSolid.cpp
Model_ResultConstruction.cpp
Model_ResultPart.cpp
Model_ResultField.cpp
#include <Model_ResultConstruction.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_CompositeFeature.h>
}
ResultPtr Model_AttributeSelection::context() {
- /*
if (!ModelAPI_AttributeSelection::isInitialized() && !myTmpContext.get() && !myTmpSubShape.get())
return ResultPtr();
- */
if (myTmpContext.get() || myTmpSubShape.get()) {
return myTmpContext;
}
if (!isFound) { // sub-shape is not found in the up-to-date instance of the context shape
// if context is sub-result of compound/compsolid, selection of sub-shape better propagate to
- // the main result (which is may be modified), case is in 1799
- ResultCompSolidPtr aMain = ModelAPI_Tools::compSolidOwner(theContext);
+ // the main result (which is may be modified); the case is in 1799
+ ResultBodyPtr aMain = ModelAPI_Tools::bodyOwner(theContext);
+ while(ModelAPI_Tools::bodyOwner(aMain).get())
+ aMain = ModelAPI_Tools::bodyOwner(theContext);
if (aMain.get()) {
selectBody(aMain, theSubShape);
return;
}
// if compsolid is context, try to take sub-solid as context: like in GUI and scripts
if (aCont.get() && aShapeToBeSelected.get()) {
- ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aCont);
+ ResultBodyPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aCont);
if (aComp && aComp->numberOfSubs()) {
- for(int aSubNum = 0; aSubNum < aComp->numberOfSubs(); aSubNum++) {
- ResultPtr aSub = aComp->subResult(aSubNum);
+ 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)) {
aCont = aSub;
break;
while(aFindNewContext && aCont.get()) {
aFindNewContext = false;
// take references to all results: root one, any sub
- ResultCompSolidPtr aCompContext = ModelAPI_Tools::compSolidOwner(aCont);
- int aSubsSize = (aCompContext.get() ? aCompContext->numberOfSubs() : 0) + 1;
- for(int aResultNum = 0; aResultNum < aSubsSize; aResultNum++) {
- ResultPtr aResCont = aCont;
- if (aCompContext.get())
- if (aResultNum == aSubsSize - 1)
- aResCont = aCompContext;
- else aResCont = aCompContext->subResult(aResultNum);
+ ResultBodyPtr aCompContext = ModelAPI_Tools::bodyOwner(aCont);
+ std::list<ResultPtr> allRes;
+ if (aCompContext.get())
+ ModelAPI_Tools::allSubs(aCompContext, allRes);
+ allRes.push_back(aCont);
+ for(std::list<ResultPtr>::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) {
+ ResultPtr aResCont = *aSub;
const std::set<AttributePtr>& aRefs = aResCont->data()->refsToMe();
std::set<AttributePtr>::const_iterator aRef = aRefs.begin();
for(; !aFindNewContext && aRef != aRefs.end(); aRef++) {
std::list<std::shared_ptr<ModelAPI_Result> > aResults;
// take all sub-results or one result
- const std::list<std::shared_ptr<ModelAPI_Result> >& aFResults = aRefFeat->results();
- std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aFResults.begin();
- for (; aRIter != aFResults.cend(); aRIter++) {
- // iterate sub-bodies of compsolid
- ResultCompSolidPtr aComp =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aRIter);
- if (aComp.get() && aComp->numberOfSubs() > 0) {
- int aNumSub = aComp->numberOfSubs();
- for(int a = 0; a < aNumSub; a++) {
- aResults.push_back(aComp->subResult(a));
- }
- } else {
- aResults.push_back(*aRIter);
- }
+ std::list<ResultPtr> aRefFeatResults;
+ ModelAPI_Tools::allResults(aRefFeat, aRefFeatResults);
+ std::list<ResultPtr>::iterator aRefResIter = aRefFeatResults.begin();
+ for(; aRefResIter != aRefFeatResults.end(); aRefResIter++) {
+ ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aRefResIter);
+ if (aBody.get() && aBody->numberOfSubs() == 0) // add only lower level subs
+ aResults.push_back(aBody);
}
std::list<std::shared_ptr<ModelAPI_Result> >::iterator aResIter = aResults.begin();
for(; aResIter != aResults.end(); aResIter++) {
aShapeToBeSelected.get() ? aShapeToBeSelected : aCont->shape();
if (aShape.get() && aShape->isSubShape(aSelectedShape, false)) {
aCont = *aResIter; // found new context (produced from this) with same subshape
- //if (!aShape->isSubShape(aShapeToBeSelected, true)) // take context orientation
- // aShapeToBeSelected->setOrientation();
aFindNewContext = true; // continue searching futher
break;
}
{
int anID = 0;
std::shared_ptr<GeomAPI_Shape> aSelection = value();
- std::shared_ptr<GeomAPI_Shape> aContext = context()->shape();
+ ResultPtr aContextRes = context();
// support for compsolids:
- if (context().get() && ModelAPI_Tools::compSolidOwner(context()).get())
- aContext = ModelAPI_Tools::compSolidOwner(context())->shape();
+ while(ModelAPI_Tools::bodyOwner(aContextRes).get()) {
+ aContextRes = ModelAPI_Tools::bodyOwner(aContextRes);
+ }
+ std::shared_ptr<GeomAPI_Shape> aContext = aContextRes->shape();
TopoDS_Shape aMainShape = aContext->impl<TopoDS_Shape>();
const TopoDS_Shape& aSubShape = aSelection->impl<TopoDS_Shape>();
// searching for the latest main shape
- if (aSelection && !aSelection->isNull() &&
- aContext && !aContext->isNull())
+ if (aSelection && !aSelection->isNull() && aContext && !aContext->isNull())
{
std::shared_ptr<Model_Document> aDoc =
std::dynamic_pointer_cast<Model_Document>(context()->document());
void Model_AttributeSelection::setId(int theID)
{
- const ResultPtr& aContext = context();
std::shared_ptr<GeomAPI_Shape> aSelection;
- std::shared_ptr<GeomAPI_Shape> aContextShape = aContext->shape();
+ ResultPtr aContextRes = context();
// support for compsolids:
- if (aContext.get() && ModelAPI_Tools::compSolidOwner(aContext).get())
- aContextShape = ModelAPI_Tools::compSolidOwner(aContext)->shape();
+ while(ModelAPI_Tools::bodyOwner(aContextRes).get()) {
+ aContextRes = ModelAPI_Tools::bodyOwner(aContextRes);
+ }
+ std::shared_ptr<GeomAPI_Shape> aContext = aContextRes->shape();
- TopoDS_Shape aMainShape = aContextShape->impl<TopoDS_Shape>();
+ TopoDS_Shape aMainShape = aContext->impl<TopoDS_Shape>();
// searching for the latest main shape
- if (theID > 0 &&
- aContextShape && !aContextShape->isNull())
+ if (theID > 0 && aContext && !aContext->isNull())
{
std::shared_ptr<Model_Document> aDoc =
- std::dynamic_pointer_cast<Model_Document>(aContext->document());
+ std::dynamic_pointer_cast<Model_Document>(aContextRes->document());
if (aDoc.get()) {
Handle(TNaming_NamedShape) aNS = TNaming_Tool::NamedShape(aMainShape, aDoc->generalLabel());
if (!aNS.IsNull()) {
aSelection = aResult;
}
- setValue(aContext, aSelection);
+ setValue(aContextRes, aSelection);
}
std::string Model_AttributeSelection::contextName(const ResultPtr& theContext) const
// if new context becomes compsolid, the resulting sub may be in sub-solids
std::list<ResultPtr> aNewToIterate;
aNewToIterate.push_back(theNewContext);
- ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theNewContext);
+ ResultBodyPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theNewContext);
if (aComp.get()) {
- for(int a = 0; a < aComp->numberOfSubs(); a++)
- aNewToIterate.push_back(aComp->subResult(a, false));
+ std::list<ResultPtr> allNewContextSubs;
+ ModelAPI_Tools::allSubs(aComp, allNewContextSubs);
+ std::list<ResultPtr>::iterator aSub = allNewContextSubs.begin();
+ for(; aSub != allNewContextSubs.end(); aSub++) {
+ ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSub);
+ if (aBody.get() && aBody->numberOfSubs() == 0) // add only lower level subs
+ aNewToIterate.push_back(aBody);
+ }
}
// first iteration: searching for the whole shape appearance (like face of the box)
TopTools_ListOfShape aContextList;
aContextList.Append(theContShape);
if (theContext.get()) {
- ResultPtr aComposite = ModelAPI_Tools::compSolidOwner(theContext);
+ ResultPtr aComposite = ModelAPI_Tools::bodyOwner(theContext);
if (aComposite.get() && aComposite->shape().get() && !aComposite->shape()->isNull())
aContextList.Append(aComposite->shape()->impl<TopoDS_Shape>());
}
#include <ModelAPI_Validator.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_ResultPart.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
#include <Model_Validator.h>
bool isUserDefined = true;
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
if (aResult) {
- std::string aDefaultName = ModelAPI_Tools::getDefaultName(aResult);
+ std::string aDefaultName = ModelAPI_Tools::getDefaultName(aResult).first;
isUserDefined = aDefaultName != theName;
}
if (isUserDefined) {
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <Events_Loop.h>
#include <Events_InfoMessage.h>
return myObjs->size(theGroupID, theAllowFolder);
}
+std::shared_ptr<ModelAPI_Object> Model_Document::parent(
+ const std::shared_ptr<ModelAPI_Object> theChild)
+{
+ if(myObjs == 0) // may be on close
+ return ObjectPtr();
+ return myObjs->parent(theChild);
+}
+
std::shared_ptr<ModelAPI_Feature> Model_Document::currentFeature(const bool theVisible)
{
if (!myObjs) // on close document feature destruction it may call this method
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(
object(ModelAPI_Feature::group(), a));
if (aFeature.get() && aFeature->data()->isValid()) {
- const std::list<std::shared_ptr<ModelAPI_Result> >& aResList = aFeature->results();
- std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRes = aResList.begin();
- for(; aRes != aResList.end(); aRes++) {
+ std::list<ResultPtr> aResults;
+ ModelAPI_Tools::allResults(aFeature, aResults);
+ for (std::list<ResultPtr>::iterator aRes = aResults.begin();
+ aRes != aResults.end(); aRes++) {
ModelAPI_EventCreator::get()->sendUpdated(*aRes, aRedispEvent);
- // #issue 1048: sub-compsolids also
- ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aRes);
- if (aCompRes.get()) {
- int aNumSubs = aCompRes->numberOfSubs();
- for(int a = 0; a < aNumSubs; a++) {
- ResultPtr aSub = aCompRes->subResult(a);
- if (aSub.get()) {
- ModelAPI_EventCreator::get()->sendUpdated(aSub, aRedispEvent);
- }
- }
- }
}
}
}
if (aShape.IsNull())
return FeaturePtr();
- // for comsolids and compounds all the naming is located in the main object, so, try to use
+ // for compsolids and compounds all the naming is located in the main object, so, try to use
// it first
- ResultCompSolidPtr aMain = ModelAPI_Tools::compSolidOwner(theResult);
+ ResultBodyPtr aMain = ModelAPI_Tools::bodyOwner(theResult);
+ while (aMain.get()) { // get the top-most main
+ ResultBodyPtr aNextMain = ModelAPI_Tools::bodyOwner(aMain);
+ if (aNextMain.get())
+ aMain = aNextMain;
+ else break;
+ }
if (aMain.get()) {
FeaturePtr aMainRes = producedByFeature(aMain, theShape);
if (aMainRes)
//! \param theAllowFolder take into account grouping feature by folders
MODEL_EXPORT virtual int size(const std::string& theGroupID, const bool theAllowFolder = false);
+ //! Returns the parent object of this child. This may be result or feature, parent of a
+ //! top result. Fast method, that uses internal data structure specifics.
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Object> parent(
+ const std::shared_ptr<ModelAPI_Object> theChild);
+
//! Returns the feature that is currently edited in this document, normally
//! this is the latest created feature
//! \param theVisible use visible features only: flag is true for Object Browser functionality
friend class Model_AttributeRefAttrList;
friend class Model_AttributeSelection;
friend class Model_ResultPart;
- friend class Model_ResultCompSolid;
+ friend class Model_ResultBody;
friend class Model_ResultConstruction;
friend class Model_SelectionNaming;
friend class DFBrowser;
#include <Model_ResultPart.h>
#include <Model_ResultConstruction.h>
#include <Model_ResultBody.h>
-#include <Model_ResultCompSolid.h>
#include <Model_ResultGroup.h>
#include <Model_ResultField.h>
#include <Model_ResultParameter.h>
FeaturePtr aFeature = feature(theLabel);
if (aFeature.get())
return feature(theLabel);
- TDF_Label aFeatureLabel = theLabel.Father().Father(); // let's suppose it is result
- aFeature = feature(aFeatureLabel);
- bool isSubResult = false;
- if (!aFeature.get() && aFeatureLabel.Depth() > 1) { // let's suppose this is sub-result of result
+ TDF_Label aFeatureLabel = theLabel; // let's suppose it is result of this feature
+ TDF_LabelList aSubLabs; // sub - labels from higher level to lower level of result
+ while(!aFeature.get() && aFeatureLabel.Depth() > 1) {
+ aSubLabs.Prepend(aFeatureLabel);
aFeatureLabel = aFeatureLabel.Father().Father();
aFeature = feature(aFeatureLabel);
- isSubResult = true;
}
if (aFeature.get()) {
- const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
- std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.cbegin();
- for (; aRIter != aResults.cend(); aRIter++) {
- if (isSubResult) {
- ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aRIter);
- if (aCompRes.get()) {
- int aNumSubs = aCompRes->numberOfSubs();
- for(int a = 0; a < aNumSubs; a++) {
- ResultPtr aSub = aCompRes->subResult(a);
- if (aSub.get()) {
- std::shared_ptr<Model_Data> aSubData = std::dynamic_pointer_cast<Model_Data>(
- aSub->data());
- if (aSubData->label().Father().IsEqual(theLabel))
- return aSub;
+ ResultPtr aCurrentResult;
+ // searching for results then sub-results label by label
+ for(TDF_ListIteratorOfLabelList aSubLab(aSubLabs); aSubLab.More(); aSubLab.Next()) {
+ if (aCurrentResult.get()) { // iterate sub-results of result
+ ResultBodyPtr anOwner = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aCurrentResult);
+ if (!anOwner)
+ return ObjectPtr(); // only Body can have sub-results
+ int a, aNumSubs = anOwner->numberOfSubs();
+ for(a = 0; a < aNumSubs; a++) {
+ ResultPtr aSub = anOwner->subResult(a);
+ if (aSub.get()) {
+ std::shared_ptr<Model_Data> aSubData = std::dynamic_pointer_cast<Model_Data>(
+ aSub->data());
+ if (aSubData->label().Father().IsEqual(aSubLab.ChangeValue())) {
+ aCurrentResult = aSub;
+ break;
}
}
}
- } else {
- std::shared_ptr<Model_Data> aResData = std::dynamic_pointer_cast<Model_Data>(
- (*aRIter)->data());
- if (aResData->label().Father().IsEqual(theLabel))
- return *aRIter;
+ if (a == aNumSubs) // not found an appropriate sub-result of result
+ return ObjectPtr();
+ } else { // iterate results of feature
+ const std::list<ResultPtr>& aResults = aFeature->results();
+ std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.cbegin();
+ for(; aRIter != aResults.cend(); aRIter++) {
+ std::shared_ptr<Model_Data> aResData = std::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
+ if (aResData->label().Father().IsEqual(aSubLab.ChangeValue())) {
+ aCurrentResult = *aRIter;
+ break;
+ }
+ }
+ if (aRIter == aResults.cend()) // not found an appropriate result of feature
+ return ObjectPtr();
}
}
+ return aCurrentResult;
}
- return FeaturePtr(); // not found
+ return ObjectPtr(); // not found
}
ObjectPtr Model_Objects::object(const std::string& theGroupID,
std::list<std::shared_ptr<ModelAPI_Feature> > allObjs = allFeatures();
std::list<std::shared_ptr<ModelAPI_Feature> >::iterator anObjIter = allObjs.begin();
for(; anObjIter != allObjs.end(); anObjIter++) {
- const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = (*anObjIter)->results();
- std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.cbegin();
- for (; aRIter != aResults.cend(); aRIter++) {
- if (aRIter->get() && (*aRIter)->groupName() == theGroupID) {
- if ((*aRIter)->data()->name() == theName)
- return *aRIter;
- ResultCompSolidPtr aCompRes =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aRIter);
- if (aCompRes.get()) {
- int aNumSubs = aCompRes->numberOfSubs();
- for(int a = 0; a < aNumSubs; a++) {
- ResultPtr aSub = aCompRes->subResult(a);
- if (aSub.get() && aSub->groupName() == theGroupID) {
- if (aSub->data()->name() == theName)
- return aSub;
- }
- }
- }
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allResults(*anObjIter, allRes);
+ for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+ if (aRes->get() && (*aRes)->groupName() == theGroupID) {
+ if ((*aRes)->data()->name() == theName)
+ return *aRes;
}
}
}
return aGroupID.empty() ? int(myHistory[theGroupID].size()) : int(myHistory[aGroupID].size());
}
+std::shared_ptr<ModelAPI_Object> Model_Objects::parent(
+ const std::shared_ptr<ModelAPI_Object> theChild)
+{
+ if (theChild.get()) {
+ std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(theChild->data());
+ TDF_Label aLab = aData->label();
+ if (!aLab.IsNull() && aLab.Depth() > 1) {
+ ObjectPtr anObj = object(aLab.Father().Father());
+ return anObj;
+ }
+ }
+ return ObjectPtr();
+}
+
+
void Model_Objects::allResults(const std::string& theGroupID, std::list<ResultPtr>& theResults)
{
// iterate the array of references and get feature by feature from the array
int theResultIndex,
std::string& theParentName) const
{
- ResultCompSolidPtr aCompSolidRes =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theFeatureData->owner());
- if (aCompSolidRes) {
- FeaturePtr anOwner = ModelAPI_Feature::feature(theResult->data()->owner());
+ ResultBodyPtr aBodyRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theFeatureData->owner());
+ if(aBodyRes) {
+ FeaturePtr anOwner = ModelAPI_Feature::feature(theResult);
// names of sub-solids in CompSolid should be default (for example,
// result of boolean operation 'Boolean_1' is a CompSolid which is renamed to 'MyBOOL',
std::ostringstream aDefaultName;
aDefaultName << anOwner->name();
// compute default name of CompSolid (name of feature + index of CompSolid's result)
- int aCompSolidResultIndex = 0;
+ int aBodyResultIndex = 0;
const std::list<ResultPtr>& aResults = anOwner->results();
- for (std::list<ResultPtr>::const_iterator anIt = aResults.begin();
- anIt != aResults.end(); ++anIt, ++aCompSolidResultIndex)
- if (aCompSolidRes == *anIt)
+ std::list<ResultPtr>::const_iterator anIt = aResults.begin();
+ for(; anIt != aResults.end(); ++anIt, ++aBodyResultIndex)
+ if(aBodyRes == *anIt)
break;
- aDefaultName << "_" << (aCompSolidResultIndex + 1);
+ aDefaultName << "_" << (aBodyResultIndex + 1);
theParentName = aDefaultName.str();
return false;
}
- std::pair<std::string, bool> aName = ModelAPI_Tools::getDefaultName(theResult, theResultIndex);
+ std::pair<std::string, bool> aName = ModelAPI_Tools::getDefaultName(theResult);
if (aName.second)
theParentName = aName.first;
return aName.second;
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
{
TDF_Label aLab = resultLabel(theFeatureData, theIndex);
- // for feature create compsolid, but for result sub create body:
- // only one level of recursion is supported now
- ResultPtr aResultOwner = std::dynamic_pointer_cast<ModelAPI_Result>(theFeatureData->owner());
- ObjectPtr anOldObject;
- if (aResultOwner.get()) {
- TDataStd_Comment::Set(aLab, ModelAPI_ResultBody::group().c_str());
- } else { // in compsolid (higher level result) old object probably may be found
- TDataStd_Comment::Set(aLab, ModelAPI_ResultCompSolid::group().c_str());
- anOldObject = object(aLab);
- }
+ TDataStd_Comment::Set(aLab, ModelAPI_ResultBody::group().c_str());
+ ObjectPtr anOldObject = object(aLab);
std::shared_ptr<ModelAPI_ResultBody> aResult;
if (anOldObject.get()) {
aResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anOldObject);
}
if (!aResult.get()) {
- // create compsolid anyway; if it is compsolid, it will create sub-bodies internally
- if (aResultOwner.get()) {
- aResult = std::shared_ptr<ModelAPI_ResultBody>(new Model_ResultBody);
- } else {
- aResult = std::shared_ptr<ModelAPI_ResultBody>(new Model_ResultCompSolid);
- }
+ aResult = std::shared_ptr<ModelAPI_ResultBody>(new Model_ResultBody);
storeResult(theFeatureData, aResult, theIndex);
}
return aResult;
if (aData.get()) {
TDF_Label aFeatureLab = aData->label().Father().Father().Father();
FeaturePtr aFeature = feature(aFeatureLab);
- if (!aFeature.get() && aFeatureLab.Depth() > 1) { // this may be sub-result of result
+ while(!aFeature.get() && aFeatureLab.Depth() > 1) { // this may be sub-result of result
aFeatureLab = aFeatureLab.Father().Father();
aFeature = feature(aFeatureLab);
}
TDF_Label anArgLab = aLabIter.Value();
Handle(TDataStd_Comment) aGroup;
if (anArgLab.FindAttribute(TDataStd_Comment::GetID(), aGroup)) {
- if (aGroup->Get() == ModelAPI_ResultBody::group().c_str() ||
- aGroup->Get() == ModelAPI_ResultCompSolid::group().c_str()) {
+ if (aGroup->Get() == ModelAPI_ResultBody::group().c_str()) {
aNewBody = createBody(theFeature->data(), aResIndex);
} else if (aGroup->Get() == ModelAPI_ResultPart::group().c_str()) {
std::shared_ptr<ModelAPI_ResultPart> aNewP = createPart(theFeature->data(), aResIndex);
//! \param theAllowFolder take into account grouping feature by folders
int size(const std::string& theGroupID, const bool theAllowFolder = false);
+ //! Returns the parent object of this child. This may be result or feature, parent of a
+ //! top result. Fast method, that uses internal data structure specifics.
+ std::shared_ptr<ModelAPI_Object> parent(const std::shared_ptr<ModelAPI_Object> theChild);
+
//! Returns all (and disabled) results of the given type.
//! Not fast method (iterates all features).
void allResults(const std::string& theGroupID, std::list<ResultPtr>& theResults);
//
#include <Model_ResultBody.h>
+
+#include <Model_Document.h>
+#include <Model_Objects.h>
#include <Model_BodyBuilder.h>
-#include <ModelAPI_ResultCompSolid.h>
-#include <ModelAPI_Tools.h>
-#include <Config_PropManager.h>
+#include <Model_Document.h>
+#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
-// DEB
-//#include <TCollection_AsciiString.hxx>
-//#include <TDF_Tool.hxx>
-//#define DEB_IMPORT 1
+#include <ModelAPI_Tools.h>
+#include <Events_Loop.h>
+
+#include <TopoDS_Shape.hxx>
+#include <TopExp_Explorer.hxx>
-Model_ResultBody::Model_ResultBody()
+
+Model_ResultBody::Model_ResultBody() : ModelAPI_ResultBody()
{
myBuilder = new Model_BodyBuilder(this);
- myWasConcealed = false;
- myConnect = ConnectionNotComputed;
+ myLastConcealed = false;
+ updateSubs(shape()); // in case of open, etc.
+}
+
+Model_ResultBody::~Model_ResultBody()
+{
+ updateSubs(std::shared_ptr<GeomAPI_Shape>()); // erase sub-results
+ delete myBuilder;
+}
+
+void Model_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
+ std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
+ const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
+ const bool theIsStoreSeparate,
+ const bool theIsStoreAsGenerated,
+ const bool theSplitInSubs)
+{
+ if (theSplitInSubs && mySubs.size()) { // consists of subs
+ std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
+ for(; aSubIter != mySubs.cend(); aSubIter++) {
+ // check that sub-shape was also created as modification of ShapeIn
+ /* to find when it is needed later to enable: to store modification of sub-bodies not only as primitives
+ GeomShapePtr aSubGeomShape = (*aSubIter)->shape();
+ if (!theIsStoreAsGenerated && aSubGeomShape.get() && !aSubGeomShape->isNull()) {
+ TopoDS_Shape aSubShape = aSubGeomShape->impl<TopoDS_Shape>();
+ TopoDS_Shape aWholeIn = theShapeIn->impl<TopoDS_Shape>();
+ for(TopExp_Explorer anExp(aWholeIn, aSubShape.ShapeType()); anExp.More(); anExp.Next()) {
+ ListOfShape aHistory;
+ std::shared_ptr<GeomAPI_Shape> aSubIn(new GeomAPI_Shape());
+ aSubIn->setImpl((new TopoDS_Shape(anExp.Current())));
+ theMS->modified(aSubIn, aHistory);
+ std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aHistory.begin();
+ for (; anIt != aHistory.end(); anIt++) {
+ if ((*anIt)->isSame(aSubGeomShape)) {
+ (*aSubIter)->storeModified(aSubIn, aSubGeomShape, -2); // -2 is to avoid clearing
+ }
+ }
+ }
+ }*/
+ (*aSubIter)->loadAndOrientModifiedShapes(
+ theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
+ theIsStoreAsGenerated);
+ }
+ } else { // do for this directly
+ myBuilder->loadAndOrientGeneratedShapes(
+ theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
+ }
+}
+
+int Model_ResultBody::numberOfSubs(bool forTree) const
+{
+ return int(mySubs.size());
+}
+
+ResultBodyPtr Model_ResultBody::subResult(const int theIndex, bool forTree) const
+{
+ return mySubs.at(theIndex);
+}
+
+bool Model_ResultBody::isSub(ObjectPtr theObject, int& theIndex) const
+{
+ std::map<ObjectPtr, int>::const_iterator aFound = mySubsMap.find(theObject);
+ if (aFound != mySubsMap.end()) {
+ theIndex = aFound->second;
+ return true;
+ }
+ return false;
}
void Model_ResultBody::colorConfigInfo(std::string& theSection, std::string& theName,
bool Model_ResultBody::setDisabled(std::shared_ptr<ModelAPI_Result> theThis, const bool theFlag)
{
bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag);
- if (aChanged && data()->isValid()) { // state is changed, so modifications are needed
+ if (aChanged) { // state is changed, so modifications are needed
myBuilder->evolutionToSelection(theFlag);
+ updateSubs(shape()); // to set disabled/enabled
}
return aChanged;
}
-bool Model_ResultBody::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
+bool Model_ResultBody::isConcealed()
{
- return myBuilder->isLatestEqual(theShape);
+ return myLastConcealed;
}
-bool Model_ResultBody::isConcealed()
+void Model_ResultBody::setIsConcealed(const bool theValue)
{
- bool aResult = false;
- if (ModelAPI_ResultBody::isConcealed()) {
- aResult = true;
- } else {
- ResultPtr aThis = std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner());
- if (aThis.get()) {
- ResultCompSolidPtr aParent = ModelAPI_Tools::compSolidOwner(aThis);
- if (aParent.get()) {
- if (aParent->isConcealed())
- aResult = true;
- }
- }
+ if (ModelAPI_ResultBody::isConcealed() != theValue) {
+ ModelAPI_ResultBody::setIsConcealed(theValue);
+ updateConcealment();
}
- if (myWasConcealed != aResult) {
- myWasConcealed = aResult;
- if (aResult) { // hidden unit must be redisplayed (hidden)
- ModelAPI_EventCreator::get()->sendDeleted(document(), this->groupName());
- // redisplay for the viewer (it must be disappeared also)
+}
+
+void Model_ResultBody::updateConcealment()
+{
+ if (myLastConcealed != ModelAPI_ResultBody::isConcealed()) {
+ ResultPtr anOwner = std::dynamic_pointer_cast<ModelAPI_Result>(data()->owner());
+ std::shared_ptr<Model_ResultBody> aParent = std::dynamic_pointer_cast<Model_ResultBody>(
+ ModelAPI_Tools::bodyOwner(anOwner));
+
+ myLastConcealed = ModelAPI_ResultBody::isConcealed(); // set new value and check parent
+ if (myLastConcealed) { // this becomes concealed, so, update all: parent and children
+ if (aParent.get())
+ aParent->updateConcealment();
static Events_ID EVENT_DISP =
Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ ModelAPI_EventCreator::get()->sendDeleted(document(), groupName());
ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), EVENT_DISP);
- } else { // was not concealed become concealed => delete event
- static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
- ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
+ std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
+ for (; aSubIter != mySubs.cend(); aSubIter++) {
+ std::dynamic_pointer_cast<Model_ResultBody>(*aSubIter)->updateConcealment();
+ }
+ } else {
+ // ask parent: if it is still concealed, nothing is changed
+ if (aParent.get()) {
+ aParent->updateConcealment();
+ if (aParent->isConcealed()) {
+ myLastConcealed = true;
+ return;
+ }
+ }
+ // iterate children: if they are concealed, nothing is changed
+ bool aChildConcealed = false;
+ std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
+ for (; aSubIter != mySubs.cend(); aSubIter++) {
+ std::dynamic_pointer_cast<Model_ResultBody>(*aSubIter)->updateConcealment();
+ if ((*aSubIter)->isConcealed()) {
+ aChildConcealed = true;
+ break;
+ }
+ }
+ if (aChildConcealed) { // some child is concealed, so, update back
+ myLastConcealed = true;
+ if (aParent.get())
+ aParent->updateConcealment();
+ std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
+ for (; aSubIter != mySubs.cend(); aSubIter++) {
+ std::dynamic_pointer_cast<Model_ResultBody>(*aSubIter)->updateConcealment();
+ }
+ } else { // so, it becomes unconcealed
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
+ ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent);
+ static Events_ID EVENT_DISP =
+ Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), EVENT_DISP);
+ }
+ }
+ }
+}
+
+void Model_ResultBody::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape)
+{
+ static Events_Loop* aLoop = Events_Loop::loop();
+ static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static Events_ID EVENT_UPD = aLoop->eventByName(EVENT_OBJECT_UPDATED);
+ static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
+ // iterate all sub-solids of compsolid to make sub-results synchronized with them
+ TopoDS_Shape aThisShape;
+ if (theThisShape.get()) aThisShape = theThisShape->impl<TopoDS_Shape>();
+ if (!aThisShape.IsNull() && (aThisShape.ShapeType() == TopAbs_COMPSOLID ||
+ aThisShape.ShapeType() == TopAbs_COMPOUND)) {
+ bool aWasEmpty = mySubs.empty();
+ Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(document())->objects();
+ unsigned int aSubIndex = 0;
+ TopoDS_Iterator aShapesIter(aThisShape);
+ for(; aShapesIter.More(); aShapesIter.Next(), aSubIndex++) {
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
+ aShape->setImpl(new TopoDS_Shape(aShapesIter.Value()));
+ ResultBodyPtr aSub;
+ if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result
+ aSub = anObjects->createBody(this->data(), aSubIndex);
+ mySubs.push_back(aSub);
+ mySubsMap[aSub] = int(mySubs.size() - 1);
+ } else { // just update shape of this result
+ aSub = mySubs[aSubIndex];
+ }
+ if (!aShape->isEqual(aSub->shape())) {
+ aSub->store(aShape, false);
+ aECreator->sendUpdated(aSub, EVENT_DISP);
+ aECreator->sendUpdated(aSub, EVENT_UPD);
+ }
+ aSub->setDisabled(aSub, isDisabled());
+ }
+ // erase left, unused results
+ while(mySubs.size() > aSubIndex) {
+ ResultBodyPtr anErased = *(mySubs.rbegin());
+ if (anErased->ModelAPI_ResultBody::isConcealed())
+ std::dynamic_pointer_cast<Model_ResultBody>(anErased)->updateConcealment();
+ anErased->setDisabled(anErased, true);
+ mySubsMap.erase(anErased);
+ mySubs.pop_back();
+ }
+ if (aWasEmpty) { // erase all subs
+ // redisplay this because result with and without subs are displayed differently
+ aECreator->sendUpdated(data()->owner(), EVENT_DISP);
}
+ } else if (!mySubs.empty()) { // erase all subs
+ while(!mySubs.empty()) {
+ ResultBodyPtr anErased = *(mySubs.rbegin());
+ if (anErased->ModelAPI_ResultBody::isConcealed())
+ std::dynamic_pointer_cast<Model_ResultBody>(anErased)->updateConcealment();
+ anErased->setDisabled(anErased, true); // even if it is invalid (to erase subs on abort/undo)
+ mySubs.pop_back();
+ }
+ mySubsMap.clear();
+ // redisplay this because result with and without subs are displayed differently
+ aECreator->sendUpdated(data()->owner(), EVENT_DISP);
}
+}
- return aResult;
+bool Model_ResultBody::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+ if (myBuilder->isLatestEqual(theShape))
+ return true;
+ // also check that it is asked for sub-elements
+ std::vector<ResultBodyPtr>::const_iterator aSubIter = mySubs.cbegin();
+ for(; aSubIter != mySubs.cend(); aSubIter++) {
+ if (aSubIter->get() && (*aSubIter)->isLatestEqual(theShape)) {
+ return true;
+ }
+ }
+ return false;
}
#include "Model.h"
#include <ModelAPI_ResultBody.h>
-//#include <GeomAlgoAPI_MakeShape.h>
-//#include <GeomAPI_DataMapOfShapeShape.h>
-//#include <vector>
-
-//class TNaming_Builder;
+#include <vector>
+#include <map>
/**\class Model_ResultBody
- * \ingroup DataModel
- * \brief The body (shape) result of a feature.
- *
- * Provides a shape that may be displayed in the viewer.
- * May provide really huge results, so, working with this kind
- * of result must be optimized.
- */
+* \ingroup DataModel
+* \brief The body (shape) result of a feature.
+*
+* Provides a shape that may be displayed in the viewer.
+* May provide really huge results, so, working with this kind
+* of result must be optimized.
+* Also provides a conainer of sub-body result in case it is compound or compsolid.
+*/
class Model_ResultBody : public ModelAPI_ResultBody
{
- /// builders that tores the naming history: one per label to allow store several shapes to one
- /// label; index in vector corresponds to the label tag
- //std::vector<TNaming_Builder*> myBuilders;
-
- /// Flag that stores the previous state of "concealed": if it is changed,
- /// The event is used to redisplay the body.
- bool myWasConcealed;
+ /// Sub-bodies if this is compsolid or compound: zero-based index to subs
+ std::vector<ResultBodyPtr> mySubs;
+ /// Also keep map of result to index in mySubs to facilitate speed of access from OB
+ std::map<ObjectPtr, int> mySubsMap;
+ /// Keeps the last state of the concealment flag in order to update it when needed.
+ bool myLastConcealed;
public:
+
+ /// Removes the stored builders
+ MODEL_EXPORT virtual ~Model_ResultBody();
+
+ /// load and orient modified shapes for sub-objects
+ MODEL_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
+ std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
+ const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
+ const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false,
+ const bool theSplitInSubs = false);
+
+
+ /// Returns the number of sub-elements
+ MODEL_EXPORT virtual int numberOfSubs(bool forTree = false) const;
+
+ /// Returns the sub-result by zero-base index
+ MODEL_EXPORT virtual ResultBodyPtr subResult(const int theIndex,
+ bool forTree = false) const;
+
+ /// Returns true if feature or reuslt belong to this composite feature as subs
+ /// Returns theIndex - zero based index of sub if found
+ MODEL_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const;
+
/// Returns the parameters of color definition in the resources config manager
MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
std::string& theDefault);
/// Disables the result body: keeps the resulting shape as selection, but erases the underlaying
- /// naming data structure if theFlag if false. Or restores everything on theFlag is true.
+ /// naming data structure if theFlag if false. Or restores every thing on theFlag is true.
MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
const bool theFlag);
- /// The compsolid is concealed if at least one of the sub is concealed,
- /// so, sub is Concealed if at least one sub is concealed
+ /// The compsolid is concealed if at least one of the sub is concealed
MODEL_EXPORT virtual bool isConcealed();
+ /// Sets all subs as concealed in the data tree (referenced by other objects)
+ MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
+
/// Returns true if the latest modification of this body in the naming history
// is equal to the given shape
MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
- /// Removes the stored builders
- MODEL_EXPORT virtual ~Model_ResultBody() {};
-
protected:
/// Makes a body on the given feature
Model_ResultBody();
+ /// Updates the sub-bodies if shape of this object is composite-solid
+ void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape);
+
+ // Checks the state of children and partents to send events of creation/erase when needed
+ void updateConcealment();
+
friend class Model_Objects;
};
+++ /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 <Model_ResultCompSolid.h>
-
-#include <Model_Document.h>
-#include <Model_Objects.h>
-#include <Model_BodyBuilder.h>
-#include <Model_Document.h>
-#include <ModelAPI_Object.h>
-#include <ModelAPI_Events.h>
-#include <Events_Loop.h>
-
-#include <TopoDS_Shape.hxx>
-#include <TopExp_Explorer.hxx>
-
-
-Model_ResultCompSolid::Model_ResultCompSolid()
-{
- myBuilder = new Model_BodyBuilder(this);
- myLastConcealed = false;
- updateSubs(shape()); // in case of open, etc.
-}
-
-Model_ResultCompSolid::~Model_ResultCompSolid()
-{
- updateSubs(std::shared_ptr<GeomAPI_Shape>()); // erase sub-results
-}
-
-void Model_ResultCompSolid::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
- const bool theIsStoreSameShapes)
-{
- ModelAPI_ResultCompSolid::store(theShape, theIsStoreSameShapes);
- updateSubs(theShape);
-}
-
-void Model_ResultCompSolid::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
- const std::shared_ptr<GeomAPI_Shape>& theToShape)
-{
- ModelAPI_ResultCompSolid::storeGenerated(theFromShape, theToShape);
- updateSubs(theToShape);
-}
-
-void Model_ResultCompSolid::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag)
-{
- ModelAPI_ResultCompSolid::storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
- updateSubs(theNewShape);
-}
-
-void Model_ResultCompSolid::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
- const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate,
- const bool theIsStoreAsGenerated,
- const bool theSplitInSubs)
-{
- if (theSplitInSubs && mySubs.size()) { // consists of subs
- std::vector<std::shared_ptr<ModelAPI_ResultBody> >::const_iterator aSubIter = mySubs.cbegin();
- for(; aSubIter != mySubs.cend(); aSubIter++) {
- // check that sub-shape was also created as modification of ShapeIn
- /* to find when it is needed later to enable: to store modification of sub-bodies not only as primitives
- GeomShapePtr aSubGeomShape = (*aSubIter)->shape();
- if (!theIsStoreAsGenerated && aSubGeomShape.get() && !aSubGeomShape->isNull()) {
- TopoDS_Shape aSubShape = aSubGeomShape->impl<TopoDS_Shape>();
- TopoDS_Shape aWholeIn = theShapeIn->impl<TopoDS_Shape>();
- for(TopExp_Explorer anExp(aWholeIn, aSubShape.ShapeType()); anExp.More(); anExp.Next()) {
- ListOfShape aHistory;
- std::shared_ptr<GeomAPI_Shape> aSubIn(new GeomAPI_Shape());
- aSubIn->setImpl((new TopoDS_Shape(anExp.Current())));
- theMS->modified(aSubIn, aHistory);
- std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = aHistory.begin();
- for (; anIt != aHistory.end(); anIt++) {
- if ((*anIt)->isSame(aSubGeomShape)) {
- (*aSubIter)->storeModified(aSubIn, aSubGeomShape, -2); // -2 is to avoid clearing
- }
- }
- }
- }*/
- (*aSubIter)->loadAndOrientModifiedShapes(
- theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
- theIsStoreAsGenerated);
- }
- } else { // do for this directly
- ModelAPI_ResultCompSolid::loadAndOrientModifiedShapes(
- theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
- theIsStoreAsGenerated);
- }
-}
-
-int Model_ResultCompSolid::numberOfSubs(bool forTree) const
-{
- return int(mySubs.size());
-}
-
-std::shared_ptr<ModelAPI_ResultBody> Model_ResultCompSolid::subResult(const int theIndex,
- bool forTree) const
-{
- return mySubs.at(theIndex);
-}
-
-bool Model_ResultCompSolid::isSub(ObjectPtr theObject, int& theIndex) const
-{
- std::map<ObjectPtr, int>::const_iterator aFound = mySubsMap.find(theObject);
- if (aFound != mySubsMap.end()) {
- theIndex = aFound->second;
- return true;
- }
- return false;
-}
-
-void Model_ResultCompSolid::colorConfigInfo(std::string& theSection, std::string& theName,
- std::string& theDefault)
-{
- theSection = "Visualization";
- theName = "result_body_color";
- theDefault = DEFAULT_COLOR();
-}
-
-bool Model_ResultCompSolid::setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
- const bool theFlag)
-{
- bool aChanged = ModelAPI_ResultBody::setDisabled(theThis, theFlag);
- if (aChanged) { // state is changed, so modifications are needed
- myBuilder->evolutionToSelection(theFlag);
- updateSubs(shape()); // to set disabled/enabled
- }
- return aChanged;
-}
-
-bool Model_ResultCompSolid::isConcealed()
-{
- bool aResult = false;;
- if (ModelAPI_ResultCompSolid::isConcealed()) {
- aResult = true;
- } else {
- std::vector<std::shared_ptr<ModelAPI_ResultBody> >::const_iterator aSubIter = mySubs.cbegin();
- for(; aSubIter != mySubs.cend(); aSubIter++) {
- if ((*aSubIter)->ModelAPI_ResultBody::isConcealed()) {
- aResult = true;
- break;
- }
- }
- }
- if (myLastConcealed != aResult) {
- myLastConcealed = aResult;
- //setIsConcealed(aResult); // set for all subs the same result
- std::vector<std::shared_ptr<ModelAPI_ResultBody> >::const_iterator aSubIter = mySubs.cbegin();
- for(; aSubIter != mySubs.cend(); aSubIter++) { // update the visualization status of each sub
- if ((*aSubIter)->ModelAPI_ResultBody::isConcealed() != aResult) {
- if (aResult) { // hidden unit must be redisplayed (hidden)
- ModelAPI_EventCreator::get()->sendDeleted(document(), (*aSubIter)->groupName());
- // redisplay for the viewer (it must be disappeared also)
- static Events_ID EVENT_DISP =
- Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- ModelAPI_EventCreator::get()->sendUpdated(*aSubIter, EVENT_DISP);
- } else { // was not concealed become concealed => delete event
- static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
- ModelAPI_EventCreator::get()->sendUpdated(*aSubIter, anEvent);
- }
- }
- }
- // update the display state of the subs: explicitly call Model_ResultBody::isConcealed
- for(aSubIter = mySubs.cbegin(); aSubIter != mySubs.cend(); aSubIter++) {
- (*aSubIter)->isConcealed();
- }
- }
- return aResult;
-}
-
-void Model_ResultCompSolid::setIsConcealed(const bool theValue)
-{
- if (theValue != ModelAPI_ResultCompSolid::isConcealed()) {
- std::vector<std::shared_ptr<ModelAPI_ResultBody> >::const_iterator aSubIter = mySubs.cbegin();
- for(; aSubIter != mySubs.cend(); aSubIter++) {
- if ((*aSubIter)->ModelAPI_ResultBody::isConcealed() != theValue) {
- if (theValue) { // hidden unit must be redisplayed (hidden)
- ModelAPI_EventCreator::get()->sendDeleted(document(), (*aSubIter)->groupName());
- // redisplay for the viewer (it must be disappeared also)
- static Events_ID EVENT_DISP =
- Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- ModelAPI_EventCreator::get()->sendUpdated(*aSubIter, EVENT_DISP);
- } else { // was not concealed become concealed => delete event
- static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
- ModelAPI_EventCreator::get()->sendUpdated(*aSubIter, anEvent);
- }
- }
- }
- ModelAPI_ResultCompSolid::setIsConcealed(theValue);
- // to set correct myLastConcealed
- isConcealed();
- }
- //myLastConcealed = theValue;
-}
-
-void Model_ResultCompSolid::updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape)
-{
- static Events_Loop* aLoop = Events_Loop::loop();
- static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
- static Events_ID EVENT_UPD = aLoop->eventByName(EVENT_OBJECT_UPDATED);
- static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
- // iterate all sub-solids of compsolid to make sub-results synchronized with them
- TopoDS_Shape aThisShape;
- if (theThisShape.get()) aThisShape = theThisShape->impl<TopoDS_Shape>();
- if (!aThisShape.IsNull() && (aThisShape.ShapeType() == TopAbs_COMPSOLID ||
- aThisShape.ShapeType() == TopAbs_COMPOUND)) {
- bool aWasEmpty = mySubs.empty();
- Model_Objects* anObjects = std::dynamic_pointer_cast<Model_Document>(document())->objects();
- unsigned int aSubIndex = 0;
- TopoDS_Iterator aShapesIter(aThisShape);
- for(; aShapesIter.More(); aShapesIter.Next(), aSubIndex++) {
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
- aShape->setImpl(new TopoDS_Shape(aShapesIter.Value()));
- ResultBodyPtr aSub;
- if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result
- aSub = anObjects->createBody(this->data(), aSubIndex);
- mySubs.push_back(aSub);
- mySubsMap[aSub] = int(mySubs.size() - 1);
- } else { // just update shape of this result
- aSub = mySubs[aSubIndex];
- }
- if (!aShape->isEqual(aSub->shape())) {
- aSub->store(aShape, false);
- aECreator->sendUpdated(aSub, EVENT_DISP);
- aECreator->sendUpdated(aSub, EVENT_UPD);
- }
- aSub->setDisabled(aSub, isDisabled());
- aSub->setIsConcealed(myLastConcealed);
- }
- // erase left, unused results
- while(mySubs.size() > aSubIndex) {
- ResultBodyPtr anErased = *(mySubs.rbegin());
- anErased->setDisabled(anErased, true);
- mySubsMap.erase(anErased);
- mySubs.pop_back();
- }
- if (aWasEmpty) { // erase all subs
- // redisplay this because result with and without subs are displayed differently
- aECreator->sendUpdated(data()->owner(), EVENT_DISP);
- }
- } else if (!mySubs.empty()) { // erase all subs
- while(!mySubs.empty()) {
- ResultBodyPtr anErased = *(mySubs.rbegin());
- anErased->setDisabled(anErased, true); // even if it is invalid (to erase subs on abort/undo)
- mySubs.pop_back();
- }
- mySubsMap.clear();
- // redisplay this because result with and without subs are displayed differently
- aECreator->sendUpdated(data()->owner(), EVENT_DISP);
- }
-}
-
-bool Model_ResultCompSolid::isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape)
-{
- if (myBuilder->isLatestEqual(theShape))
- return true;
- // also check that it is asked for sub-elements
- std::vector<std::shared_ptr<ModelAPI_ResultBody> >::const_iterator aSubIter = mySubs.cbegin();
- for(; aSubIter != mySubs.cend(); aSubIter++) {
- if (aSubIter->get() && (*aSubIter)->isLatestEqual(theShape)) {
- return true;
- }
- }
- return false;
-}
+++ /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>
-//
-
-#ifndef Model_ResultCompSolid_H_
-#define Model_ResultCompSolid_H_
-
-#include "Model.h"
-#include <ModelAPI_ResultCompSolid.h>
-#include <vector>
-#include <map>
-
-/**\class Model_ResultCompSolid
-* \ingroup DataModel
-* \brief The compsolid (container of body results) result of a feature.
-*
-* Provides a container of shapes that may be displayed in the viewer.
-*/
-class Model_ResultCompSolid : public ModelAPI_ResultCompSolid
-{
- /// Sub-bodies if this is compsolid: zero base index to subs
- std::vector<std::shared_ptr<ModelAPI_ResultBody> > mySubs;
- /// Also keep map of result to index in mySubs to facilitate speed of access from OB
- std::map<ObjectPtr, int> mySubsMap;
- /// Flag that stores the previous state of "concealed": if it is changed,
- /// The event must be generated to redisplay this and all subs.
- bool myLastConcealed;
-
-
-public:
-
- /// Removes the stored builders
- MODEL_EXPORT virtual ~Model_ResultCompSolid();
-
- /// Stores the shape (called by the execution method). Creates sub-results for compsolid.
- MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
- const bool theIsStoreSameShapes = true);
-
- /// Stores the generated shape. Creates sub-results for compsolid.
- MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
- const std::shared_ptr<GeomAPI_Shape>& theToShape);
-
- /// Stores the modified shape. Creates sub-results for compsolid.
- MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
-
- /// load and orient modified shapes for sub-objects
- MODEL_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
- const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate = false,
- const bool theIsStoreAsGenerated = false,
- const bool theSplitInSubs = false);
-
-
- /// Returns the number of sub-elements
- MODEL_EXPORT virtual int numberOfSubs(bool forTree = false) const;
-
- /// Returns the sub-result by zero-base index
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultBody> subResult(const int theIndex,
- bool forTree = false) const;
-
- /// Returns true if feature or reuslt belong to this composite feature as subs
- /// Returns theIndex - zero based index of sub if found
- MODEL_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const;
-
- /// Returns the parameters of color definition in the resources config manager
- MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
- std::string& theDefault);
-
- /// Disables the result body: keeps the resulting shape as selection, but erases the underlaying
- /// naming data structure if theFlag if false. Or restores everything on theFlag is true.
- MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
- const bool theFlag);
-
- /// The compsolid is concealed if at least one of the sub is concealed
- MODEL_EXPORT virtual bool isConcealed();
-
- /// Sets all subs as concealed in the data tree (referenced by other objects)
- MODEL_EXPORT virtual void setIsConcealed(const bool theValue);
-
- /// Returns true if the latest modification of this body in the naming history
- // is equal to the given shape
- MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
-
-protected:
- /// Makes a body on the given feature
- Model_ResultCompSolid();
-
- /// Updates the sub-bodies if shape of this object is composite-solid
- void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape);
-
- friend class Model_Objects;
-};
-
-#endif
ModelAPI_Plugin.h
ModelAPI_Result.h
ModelAPI_ResultBody.h
- ModelAPI_ResultCompSolid.h
ModelAPI_ResultConstruction.h
ModelAPI_ResultField.h
ModelAPI_ResultGroup.h
ModelAPI_Plugin.cpp
ModelAPI_Result.cpp
ModelAPI_ResultBody.cpp
- ModelAPI_ResultCompSolid.cpp
ModelAPI_ResultConstruction.cpp
ModelAPI_ResultField.cpp
ModelAPI_ResultGroup.cpp
%include "ModelAPI_ResultField.h"
%include "ModelAPI_ResultParameter.h"
%include "ModelAPI_Tools.h"
-%include "ModelAPI_ResultCompSolid.h"
%include "ModelAPI_Folder.h"
// std::list -> []
%template(modelAPI_ResultParameter) shared_ptr_cast<ModelAPI_ResultParameter, ModelAPI_Result>;
%template(modelAPI_ResultGroup) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_ResultGroup>;
%template(modelAPI_ResultField) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_ResultField>;
-%template(modelAPI_ResultCompSolid) shared_ptr_cast<ModelAPI_ResultCompSolid, ModelAPI_ResultBody>;
// Attribute casts
%template(modelAPI_AttributeDocRef) shared_ptr_cast<ModelAPI_AttributeDocRef, ModelAPI_Attribute>;
//! \param theAllowFolder take into account grouping feature by folders
virtual int size(const std::string& theGroupID, const bool theAllowFolder = false) = 0;
+ //! Returns the parent object of this child. This may be result or feature, parent of a
+ //! top result. Fast method, that uses internal data structure specifics.
+ virtual std::shared_ptr<ModelAPI_Object> parent(
+ const std::shared_ptr<ModelAPI_Object> theChild) = 0;
+
//! Returns the feature that is currently edited in this document, normally
//! this is the latest created feature
//! \param theVisible use visible features only: flag is true for Object Browser functionality
//
#include "ModelAPI_ResultBody.h"
+
#include <ModelAPI_BodyBuilder.h>
#include <Events_Loop.h>
#include <ModelAPI_Events.h>
ModelAPI_ResultBody::ModelAPI_ResultBody()
-: myBuilder(0)
+ : myBuilder(0)
{
myConnect = ConnectionNotComputed;
}
ModelAPI_ResultBody::~ModelAPI_ResultBody()
{
if (myBuilder)
- delete myBuilder;
+ delete myBuilder;
}
std::string ModelAPI_ResultBody::groupName()
}
void ModelAPI_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape,
- const bool theIsStoreSameShapes)
+ const bool theIsStoreSameShapes)
{
myBuilder->store(theShape, theIsStoreSameShapes);
myConnect = ConnectionNotComputed;
static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
aECreator->sendUpdated(data()->owner(), aRedispEvent);
+
+ updateSubs(theShape);
}
void ModelAPI_ResultBody::storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
- const std::shared_ptr<GeomAPI_Shape>& theToShape)
+ const std::shared_ptr<GeomAPI_Shape>& theToShape)
{
myBuilder->storeGenerated(theFromShape, theToShape);
myConnect = ConnectionNotComputed;
static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
aECreator->sendUpdated(data()->owner(), aRedispEvent);
+
+ updateSubs(theToShape);
}
void ModelAPI_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const int theDecomposeSolidsTag)
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape,
+ const int theDecomposeSolidsTag)
{
myBuilder->storeModified(theOldShape, theNewShape, theDecomposeSolidsTag);
myConnect = ConnectionNotComputed;
static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
aECreator->sendUpdated(data()->owner(), aRedispEvent);
+
+ updateSubs(theNewShape);
}
void ModelAPI_ResultBody::storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape)
}
void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
- const std::string& theName, const int theTag)
+ const std::string& theName, const int theTag)
{
myBuilder->generated(theNewShape, theName, theTag);
}
void ModelAPI_ResultBody::generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
- const int theTag)
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
+ const int theTag)
{
myBuilder->generated(theOldShape, theNewShape, theName, theTag);
}
void ModelAPI_ResultBody::modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
- const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
- const int theTag)
+ const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
+ const int theTag)
{
myBuilder->modified(theOldShape, theNewShape, theName, theTag);
}
void ModelAPI_ResultBody::deleted(
- const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag)
+ const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag)
{
myBuilder->deleted(theOldShape, theTag);
}
-void ModelAPI_ResultBody::loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag)
+void ModelAPI_ResultBody::loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS,
+ std::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag)
{
myBuilder->loadDeletedShapes(theMS, theShapeIn, theKindOfShape, theTag);
}
-void ModelAPI_ResultBody::loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
- const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate,
- const bool theIsStoreAsGenerated,
- const bool /*theSplitInSubs*/)
+void ModelAPI_ResultBody::loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
+ std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
+ const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
+ const bool theIsStoreSeparate,
+ const bool theIsStoreAsGenerated,
+ const bool /*theSplitInSubs*/)
{
myBuilder->loadAndOrientModifiedShapes(
theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes, theIsStoreSeparate,
theIsStoreAsGenerated);
}
-void ModelAPI_ResultBody::loadAndOrientGeneratedShapes (GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape,
- const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes)
+void ModelAPI_ResultBody::loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
+ std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape,
+ const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes)
{
myBuilder->loadAndOrientGeneratedShapes(
theMS, theShapeIn, theKindOfShape, theTag, theName, theSubShapes);
}
void ModelAPI_ResultBody::loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag)
+ const std::string& theName, int& theTag)
{
myBuilder->loadFirstLevel(theShape, theName, theTag);
}
void ModelAPI_ResultBody::loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName, int& theTag)
+ const std::string& theName, int& theTag)
{
myBuilder->loadDisconnectedEdges(theShape, theName, theTag);
}
void ModelAPI_ResultBody::loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName,int& theTag)
+ const std::string& theName, int& theTag)
{
myBuilder->loadDisconnectedVertexes(theShape, theName, theTag);
}
}
return myConnect == IsConnected;
}
+
+void ModelAPI_ResultBody::setDisplayed(const bool theDisplay)
+{
+ ModelAPI_Result::setDisplayed(theDisplay);
+ for (int i = 0; i < numberOfSubs(); i++)
+ subResult(i)->setDisplayed(theDisplay);
+}
* Provides a shape that may be displayed in the viewer.
* May provide really huge results, so, working with this kind
* of result must be optimized.
+* Also provides a conainer of sub-body result in case it is compound or compsolid.
*/
class ModelAPI_ResultBody : public ModelAPI_Result
{
+public:
+ /// Iternal enumeration for storage the information of connected topology flag
+ enum ConnectedTopologyFlag {
+ ConnectionNotComputed, ///< not yet computed
+ IsConnected, ///< the topology is connected
+ IsNotConnected ///< the topology is connected
+ };
+
+protected:
+ /// Keeps (not persistently) the connected topology flag
+ ConnectedTopologyFlag myConnect;
+
+ ModelAPI_BodyBuilder* myBuilder; ///< provides the body processing in naming shape
+
public:
MODELAPI_EXPORT virtual ~ModelAPI_ResultBody();
+
/// Returns the group identifier of this result
MODELAPI_EXPORT virtual std::string groupName();
return "0.0001";
}
- /// Iternal enumeration for storage the information of connected topology flag
- enum ConnectedTopologyFlag {
- ConnectionNotComputed, ///< not yet computed
- IsConnected, ///< the topology is connected
- IsNotConnected ///< the topology is connected
- };
- /// Keeps (not persistently) the connected topology flag
- ConnectedTopologyFlag myConnect;
+ /// Returns the number of sub-elements
+ MODELAPI_EXPORT virtual int numberOfSubs(bool forTree = false) const = 0;
+
+ /// Returns the sub-result by zero-base index
+ MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_ResultBody> subResult(
+ const int theIndex, bool forTree = false) const = 0;
+
+ /// Returns true if feature or reuslt belong to this composite feature as subs
+ /// Returns theIndex - zero based index of sub if found
+ MODELAPI_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const = 0;
/// \brief Stores the shape (called by the execution method).
/// param[in] theShape shape to store.
/// param[in] theIsStoreSameShapes if false stores reference to the same shape
/// if it is already in document.
MODELAPI_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
- const bool theIsStoreSameShapes = true);
+ const bool theIsStoreSameShapes = true);
/// Stores the generated shape (called by the execution method).
MODELAPI_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1);
/// load deleted shapes
- MODELAPI_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
- std::shared_ptr<GeomAPI_Shape> theShapeIn,
- const int theKindOfShape,
- const int theTag);
+ MODELAPI_EXPORT virtual void loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS,
+ std::shared_ptr<GeomAPI_Shape> theShapeIn,
+ const int theKindOfShape,
+ const int theTag);
+
/// load and orient modified shapes
- MODELAPI_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
+ MODELAPI_EXPORT virtual void loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
- const bool theIsStoreSeparate = false,
- const bool theIsStoreAsGenerated = false,
+ const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false,
const bool theSplitInSubs = false);
+
/// load and orient generated shapes
- MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes (GeomAlgoAPI_MakeShape* theMS,
+ MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape,
const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes);
/// load disconnected vetexes
MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
- const std::string& theName,int& theTag);
+ const std::string& theName, int& theTag);
/// Returns true if the latest modification of this body in the naming history
// is equal to the given shape
/// so it is more effective to use this method than directly GeomAPI_Shape.
MODELAPI_EXPORT virtual bool isConnectedTopology();
+ /// Set displayed flag to the result and all sub results
+ /// \param theDisplay a boolean value
+ MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
+
protected:
/// Default constructor accessible only from Model_Objects
MODELAPI_EXPORT ModelAPI_ResultBody();
- ModelAPI_BodyBuilder* myBuilder; ///< provides the body processing in naming shape
+ /// Updates the sub-bodies if shape of this object is compsolid or compound
+ virtual void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape) = 0;
};
//! Pointer on feature object
+++ /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 "ModelAPI_ResultCompSolid.h"
-
-ModelAPI_ResultCompSolid::~ModelAPI_ResultCompSolid()
-{
-}
-
-void ModelAPI_ResultCompSolid::setDisplayed(const bool theDisplay)
-{
- ModelAPI_ResultBody::setDisplayed(theDisplay);
- for (int i = 0; i < numberOfSubs(); i++)
- subResult(i)->setDisplayed(theDisplay);
-}
+++ /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>
-//
-
-#ifndef ModelAPI_ResultCompSolid_H_
-#define ModelAPI_ResultCompSolid_H_
-
-#include "ModelAPI_Result.h"
-#include "ModelAPI_ResultBody.h"
-#include <string>
-
-/**\class ModelAPI_ResultCompSolid
-* \ingroup DataModel
-* \brief The comp solid (container of results) result of a feature.
-*
-* Provides a conainer of body result that may be displayed in the viewer.
-*/
-class ModelAPI_ResultCompSolid : public ModelAPI_ResultBody
-{
-public:
- MODELAPI_EXPORT virtual ~ModelAPI_ResultCompSolid();
- /// Returns the group identifier of this result
-
- /// Returns the number of sub-elements
- virtual int numberOfSubs(bool forTree = false) const = 0;
-
- /// Returns the sub-result by zero-base index
- virtual std::shared_ptr<ModelAPI_ResultBody> subResult(const int theIndex,
- bool forTree = false) const = 0;
-
- /// Returns true if feature or reuslt belong to this composite feature as subs
- /// Returns theIndex - zero based index of sub if found
- virtual bool isSub(ObjectPtr theObject, int& theIndex) const = 0;
-
- /// Set displayed flag to the result and all sub results
- /// \param theDisplay a boolean value
- MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
-
-protected:
-};
-
-//! Pointer on feature object
-typedef std::shared_ptr<ModelAPI_ResultCompSolid> ResultCompSolidPtr;
-
-#endif
#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_AttributeDocRef.h>
return CompositeFeaturePtr(); // not found
}
-ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub)
+ResultBodyPtr bodyOwner(const ResultPtr& theSub)
{
- int anIndex;
- ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theSub);
- if (aBody.get()) {
- FeaturePtr aFeatureOwner = aBody->document()->feature(aBody);
- if (aFeatureOwner.get()) {
- std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter =
- aFeatureOwner->results().cbegin();
- for(; aResIter != aFeatureOwner->results().cend(); aResIter++) {
- ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aResIter);
- if (aComp && aComp->isSub(aBody, anIndex))
- return aComp;
- }
+ if (theSub.get()) {
+ ObjectPtr aParent = theSub->document()->parent(theSub);
+ if (aParent.get()) {
+ return std::dynamic_pointer_cast<ModelAPI_ResultBody>(aParent);
}
}
- return ResultCompSolidPtr(); // not found
+ return ResultBodyPtr(); // not found
}
-int compSolidIndex(const ResultPtr& theSub)
+int bodyIndex(const ResultPtr& theSub)
{
int anIndex = -1;
- ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theSub);
- if (aBody.get()) {
- FeaturePtr aFeatureOwner = aBody->document()->feature(aBody);
- if (aFeatureOwner.get()) {
- std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter =
- aFeatureOwner->results().cbegin();
- for(; aResIter != aFeatureOwner->results().cend(); aResIter++) {
- ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aResIter);
- if (aComp && aComp->isSub(aBody, anIndex))
- return anIndex;
- }
- }
+ ResultBodyPtr aParent = bodyOwner(theSub);
+ if (aParent.get()) {
+ ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theSub);
+ if (aBody.get() && aParent->isSub(aBody, anIndex))
+ return anIndex;
}
return anIndex; // not found
}
bool hasSubResults(const ResultPtr& theResult)
{
- ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theResult);
+ ResultBodyPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
return aCompSolid.get() && aCompSolid->numberOfSubs() > 0;
}
+void allSubs(const ResultBodyPtr& theResult, std::list<ResultPtr>& theResults) {
+ // iterate sub-bodies of compsolid
+ ResultBodyPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
+ if (aComp.get()) {
+ int aNumSub = aComp->numberOfSubs();
+ for (int a = 0; a < aNumSub; a++) {
+ ResultBodyPtr aSub = aComp->subResult(a);
+ theResults.push_back(aSub);
+ allSubs(aSub, theResults);
+ }
+ }
+}
+
void allResults(const FeaturePtr& theFeature, std::list<ResultPtr>& theResults)
{
if (!theFeature.get()) // safety: for empty feature no results
return;
const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
- std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
+ std::list<ResultPtr>::const_iterator aRIter = aResults.begin();
for (; aRIter != aResults.cend(); aRIter++) {
theResults.push_back(*aRIter);
- // iterate sub-bodies of compsolid
- ResultCompSolidPtr aComp = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aRIter);
- if (aComp.get()) {
- int aNumSub = aComp->numberOfSubs();
- for(int a = 0; a < aNumSub; a++) {
- theResults.push_back(aComp->subResult(a));
- }
- }
+ ResultBodyPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aRIter);
+ allSubs(aResult, theResults);
}
}
}
}
-std::pair<std::string, bool> getDefaultName(
- const std::shared_ptr<ModelAPI_Result>& theResult,
- const int theResultIndex)
+std::pair<std::string, bool> getDefaultName(const std::shared_ptr<ModelAPI_Result>& theResult)
{
typedef std::list< std::pair < std::string, std::list<ObjectPtr> > > ListOfReferences;
SessionPtr aSession = ModelAPI_Session::get();
- FeaturePtr anOwner = ModelAPI_Feature::feature(theResult->data()->owner());
- ResultCompSolidPtr aCompSolidRes = compSolidOwner(theResult);
- if (aCompSolidRes) {
+ ResultBodyPtr anOwnerRes = bodyOwner(theResult);
+ if (anOwnerRes) {
// names of sub-solids in CompSolid should be default (for example,
// result of boolean operation 'Boolean_1_1' is a CompSolid which is renamed to 'MyBOOL',
// however, sub-elements of 'MyBOOL' should be named 'Boolean_1_1_1', 'Boolean_1_1_2' etc.)
std::ostringstream aDefaultName;
- aDefaultName << anOwner->name();
- // compute default name of CompSolid (name of feature + index of CompSolid's result)
- int aCompSolidResultIndex = 0;
- const std::list<ResultPtr>& aResults = anOwner->results();
- for (std::list<ResultPtr>::const_iterator anIt = aResults.begin();
- anIt != aResults.end(); ++anIt, ++aCompSolidResultIndex)
- if (aCompSolidRes == *anIt)
- break;
- aDefaultName << "_" << (aCompSolidResultIndex + 1) << "_" << (theResultIndex + 1);
+ aDefaultName << getDefaultName(anOwnerRes).first;
+ aDefaultName << "_" << (bodyIndex(theResult) + 1);
return std::pair<std::string, bool>(aDefaultName.str(), false);
}
+ FeaturePtr anOwner = ModelAPI_Feature::feature(theResult->data()->owner());
DataPtr aData = anOwner->data();
ListOfReferences aReferences;
break;
}
}
+ // get the result number in the feature
+ int anIndexInOwner = 0;
+ const std::list<ResultPtr>& anOwnerResults = anOwner->results();
+ std::list<ResultPtr>::const_iterator aResIt = anOwnerResults.cbegin();
+ for(; aResIt != anOwnerResults.cend(); aResIt++) {
+ if(*aResIt == theResult)
+ break;
+ anIndexInOwner++;
+ }
// find an object which is concealed by theResult
if (aFoundRef != aReferences.end() && !aFoundRef->second.empty()) {
std::map<ResultPtr, int> aNbRefToObject;
// search the object by result index
std::list<ObjectPtr>::const_iterator anObjIt = aFoundRef->second.begin();
- int aResultIndex = theResultIndex;
+ int aResultIndex = anIndexInOwner;
while (--aResultIndex >= 0) {
ResultPtr aCurRes = std::dynamic_pointer_cast<ModelAPI_Result>(*anObjIt);
- ResultCompSolidPtr aParentCompSolid = ModelAPI_Tools::compSolidOwner(aCurRes);
- if (aParentCompSolid)
- aCurRes = aParentCompSolid;
+ ResultBodyPtr aParentBody = ModelAPI_Tools::bodyOwner(aCurRes);
+ if (aParentBody)
+ aCurRes = aParentBody;
if (aNbRefToObject.find(aCurRes) == aNbRefToObject.end())
aNbRefToObject[aCurRes] = 1;
else
if ((*anObjIt)->groupName() == ModelAPI_ResultBody::group()) {
// check the result is part of CompSolid
ResultPtr anObjRes = std::dynamic_pointer_cast<ModelAPI_Result>(*anObjIt);
- ResultCompSolidPtr aParentCompSolid = ModelAPI_Tools::compSolidOwner(anObjRes);
- if (aParentCompSolid)
- anObjRes = aParentCompSolid;
+ ResultBodyPtr aParentBody = ModelAPI_Tools::bodyOwner(anObjRes);
+ if (aParentBody)
+ anObjRes = aParentBody;
// return name of reference result only if it has been renamed by the user,
// in other case compose a default name
aDefaultName << anOwner->name();
// if there are several results (issue #899: any number of result),
// add unique prefix starting from second
- if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group())
- aDefaultName << "_" << theResultIndex + 1;
+ if (anIndexInOwner > 0 || theResult->groupName() == ModelAPI_ResultBody::group())
+ aDefaultName << "_" << anIndexInOwner + 1;
return std::pair<std::string, bool>(aDefaultName.str(), false);
}
-std::string getDefaultName(const ResultPtr& theResult)
-{
- FeaturePtr anOwner = ModelAPI_Feature::feature(theResult->data()->owner());
-
- // names of sub-solids in CompSolid should be default (for example,
- // result of boolean operation 'Boolean_1_1' is a CompSolid which is renamed to 'MyBOOL',
- // however, sub-elements of 'MyBOOL' should be named 'Boolean_1_1_1', 'Boolean_1_1_2' etc.)
- std::ostringstream aDefaultName;
- aDefaultName << anOwner->name();
-
- ResultPtr aResToSearch = theResult;
- ResultCompSolidPtr aCompSolidRes = compSolidOwner(theResult);
- if (aCompSolidRes)
- aResToSearch = aCompSolidRes;
-
- // obtain index of result
- int aResIndex = 1;
- const std::list<ResultPtr>& aResults = anOwner->results();
- for (std::list<ResultPtr>::const_iterator anIt = aResults.begin();
- anIt != aResults.end(); ++anIt, ++aResIndex)
- if (aResToSearch == *anIt)
- break;
-
- // compute default name of CompSolid (name of feature + index of CompSolid's result)
- aDefaultName << "_" << aResIndex;
-
- if (aCompSolidRes) {
- // obtain index of result in compsolid and compose a default name
- int aNbSubs = aCompSolidRes->numberOfSubs();
- for (int anIndex = 0; anIndex < aNbSubs; ++anIndex)
- if (aCompSolidRes->subResult(anIndex) == theResult) {
- aDefaultName << "_" << (anIndex + 1);
- break;
- }
- }
-
- return aDefaultName.str();
-}
-
} // namespace ModelAPI_Tools
class ModelAPI_Feature;
class ModelAPI_Result;
class ModelAPI_ResultParameter;
-class ModelAPI_ResultCompSolid;
+class ModelAPI_ResultBody;
class GeomAPI_Shape;
const std::shared_ptr<ModelAPI_Feature>& theFeature);
/*!
- * Returns the compsolid result - parent of this result.
- * \param theSub the sub-element of comp-solid
+ * Returns the result - parent of this result.
+ * \param theSub the sub-element of composit result
* \returns null if it is not sub-element of composite
*/
-MODELAPI_EXPORT std::shared_ptr<ModelAPI_ResultCompSolid> compSolidOwner(
- const std::shared_ptr<ModelAPI_Result>& theSub);
+MODELAPI_EXPORT std::shared_ptr<ModelAPI_ResultBody>
+ bodyOwner(const std::shared_ptr<ModelAPI_Result>& theSub);
/*!
- * Returns index of this result in parent (if parent exists, returned by compSolidOwner)
+ * Returns index of this result in parent (if parent exists, returned by bodyOwner)
* \returns zero-base index, or -1 if not found
*/
-MODELAPI_EXPORT int compSolidIndex(const std::shared_ptr<ModelAPI_Result>& theSub);
+MODELAPI_EXPORT int bodyIndex(const std::shared_ptr<ModelAPI_Result>& theSub);
/*!
* Returns true if the result contains a not empty list of sub results.
*/
MODELAPI_EXPORT bool hasSubResults(const std::shared_ptr<ModelAPI_Result>& theResult);
+/*!
+* collects recursively all subs of the given result
+*/
+MODELAPI_EXPORT void allSubs(const std::shared_ptr<ModelAPI_ResultBody>& theResult,
+ std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
+
/*!
* Adds the results of the given feature to theResults list: including disabled and sub-results
*/
MODELAPI_EXPORT void getConcealedResults(const std::shared_ptr<ModelAPI_Feature>& theFeature,
std::list<std::shared_ptr<ModelAPI_Result> >& theResults);
-/*! Return the default name of the result according the features it depends.
+/*! Return the default name of the result according the features it depends or name of the feature.
* Return also whether the name is get from the concealing result of parent object
* (means that concealing result has user-defined name).
*/
MODELAPI_EXPORT std::pair<std::string, bool> getDefaultName(
- const std::shared_ptr<ModelAPI_Result>& theResult,
- const int theResultIndex);
-
-/*! Return the default name of the result according to name of the feature.
- */
-MODELAPI_EXPORT std::string getDefaultName(const std::shared_ptr<ModelAPI_Result>& theResult);
+ const std::shared_ptr<ModelAPI_Result>& theResult);
}
#endif
#include "ModelAPI_ResultGroup.h"
#include "ModelAPI_ResultField.h"
#include "ModelAPI_Tools.h"
- #include "ModelAPI_ResultCompSolid.h"
#include "ModelAPI_Folder.h"
#include <memory>
#include <ModelAPI_Folder.h>
#include <ModelAPI_Result.h>
#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_Tools.h>
// Save only names of results which is not correspond to default feature name
const std::list<ResultPtr>& aResults = theFeature->results();
- std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
- for (int i = 0; aResIt != aResults.end(); ++aResIt, ++i) {
- std::pair<std::string, bool> aName = ModelAPI_Tools::getDefaultName(*aResIt, i);
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allResults(theFeature, allRes);
+ for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+ std::pair<std::string, bool> aName = ModelAPI_Tools::getDefaultName(*aRes);
std::string aDefaultName = aName.first;
- std::string aResName = (*aResIt)->data()->name();
-
+ std::string aResName = (*aRes)->data()->name();
bool isUserDefined = !(isFeatureDefaultName && aDefaultName == aResName);
-
- myNames[*aResIt] = EntityName(aResName,
- (isUserDefined ? aResName : std::string()), !isUserDefined);
-
- // check names of sub-results for CompSolid
- ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aResIt);
- if (aCompSolid) {
- int aNbSubs = aCompSolid->numberOfSubs();
- for (int j = 0; j < aNbSubs; ++j) {
- ResultPtr aSub = aCompSolid->subResult(j);
- std::string aSubName = aSub->data()->name();
- aName = ModelAPI_Tools::getDefaultName(aSub, j);
- aDefaultName = aName.first;
-
- bool isUserDefinedSubName = isUserDefined || aDefaultName != aSubName;
- myNames[aSub] = EntityName(aSubName,
- (isUserDefinedSubName ? aSubName : std::string()), !isUserDefinedSubName);
- }
- }
+ myNames[*aRes] =
+ EntityName(aResName, (isUserDefined ? aResName : std::string()), !isUserDefined);
}
}
bool isUserDefinedName = !myNames[theEntity].myIsDefault;
// store results if they have user-defined names or colors
std::list<ResultPtr> aResultsWithNameOrColor;
- const std::list<ResultPtr>& aResults = theEntity->results();
- std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
- for (; aResIt != aResults.end(); ++aResIt) {
- if (!myNames[*aResIt].myIsDefault || !isDefaultColor(*aResIt) ||
- !isDefaultDeflection(*aResIt) || !isDefaultTransparency(*aResIt))
- aResultsWithNameOrColor.push_back(*aResIt);
-
- ResultCompSolidPtr aCompSolid =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*aResIt);
- if (aCompSolid) {
- int aNbSubs = aCompSolid->numberOfSubs();
- for (int i = 0; i < aNbSubs; ++i) {
- ResultPtr aCurRes = aCompSolid->subResult(i);
- if (!myNames[aCurRes].myIsDefault || !isDefaultColor(aCurRes) ||
- !isDefaultDeflection(aCurRes) || !isDefaultTransparency(aCurRes))
- aResultsWithNameOrColor.push_back(aCurRes);
- }
- }
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allResults(theEntity, allRes);
+ for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+ if(!myNames[*aRes].myIsDefault || !isDefaultColor(*aRes) ||
+ !isDefaultDeflection(*aRes) || !isDefaultTransparency(*aRes))
+ aResultsWithNameOrColor.push_back(*aRes);
}
// store just dumped entity to stack
if (myEntitiesStack.empty() || myEntitiesStack.top().myEntity != theEntity)
ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const ResultPtr& theResult)
{
- FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
- int anIndex = 0;
- int aSubIndex = -1;
- std::list<ResultPtr> aResults = aFeature->results();
- for(std::list<ResultPtr>::const_iterator
- anIt = aResults.cbegin(); anIt != aResults.cend(); ++anIt, ++anIndex) {
- if(theResult->isSame(*anIt)) {
- break;
- }
-
- ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(*anIt);
- if (aCompSolid) {
- int aNbSubs = aCompSolid->numberOfSubs();
- for (aSubIndex = 0; aSubIndex < aNbSubs; ++aSubIndex)
- if (theResult->isSame(aCompSolid->subResult(aSubIndex)))
- break;
- if (aSubIndex < aNbSubs)
- break;
- aSubIndex = -1;
+ // iterate in the structure of sub-results to the parent
+ ResultPtr aCurRes = theResult;
+ std::list<int> anIndices; // indexes of results in the parent result, starting from topmost
+ while(aCurRes.get()) {
+ ResultBodyPtr aParent = ModelAPI_Tools::bodyOwner(aCurRes);
+ if (aParent) {
+ anIndices.push_front(ModelAPI_Tools::bodyIndex(aCurRes));
}
+ aCurRes = aParent;
}
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
myDumpBuffer << name(aFeature);
- if(anIndex == 0) {
- myDumpBuffer << ".result()";
- } else {
- myDumpBuffer << ".results()[" << anIndex << "]";
- }
- if (aSubIndex >= 0) {
- myDumpBuffer << ".subResult(" << aSubIndex << ")";
+ for (std::list<int>::iterator anI = anIndices.begin(); anI != anIndices.end(); anI++) {
+ if (anI == anIndices.begin()) {
+ if(*anI == 0) {
+ myDumpBuffer << ".result()";
+ }
+ else {
+ myDumpBuffer << ".results()[" << *anI << "]";
+ }
+ } else {
+ myDumpBuffer << ".subResult(" << *anI << ")";
+ }
}
+
return *this;
}
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Feature.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
+
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
if (myVariantType != VT_ResultSubShapePair)
return 0;
- ResultCompSolidPtr aCompSolid =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(myResultSubShapePair.first);
- if (!aCompSolid)
+ ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myResultSubShapePair.first);
+ if (!aBody.get())
return 0;
- return aCompSolid->numberOfSubs();
+ return aBody->numberOfSubs();
}
ModelHighAPI_Selection ModelHighAPI_Selection::subResult(int theIndex) const
if (myVariantType != VT_ResultSubShapePair)
return ModelHighAPI_Selection();
- ResultCompSolidPtr aCompSolid =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(myResultSubShapePair.first);
- if (!aCompSolid)
+ ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myResultSubShapePair.first);
+ if (!aBody)
return ModelHighAPI_Selection();
- if (theIndex >= aCompSolid->numberOfSubs())
+ if (theIndex >= aBody->numberOfSubs())
return ModelHighAPI_Selection();
- ResultBodyPtr aResult = aCompSolid->subResult(theIndex);
+ ResultBodyPtr aResult = aBody->subResult(theIndex);
return ModelHighAPI_Selection(aResult, aResult->shape());
}
#include <ModelAPI_Events.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeIntArray.h>
#include "ModuleBase_Tools.h"
aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.));
// Activate individual repaintng if this is a part of compsolid
- ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult);
- SetAutoHilight(aCompSolid.get() == NULL);
+ ResultBodyPtr aResOwner = ModelAPI_Tools::bodyOwner(myResult);
+ SetAutoHilight(aResOwner.get() == NULL);
myHiddenSubShapesDrawer = new AIS_ColoredDrawer (myDrawer);
Handle(Prs3d_ShadingAspect) aShadingAspect = new Prs3d_ShadingAspect();
#include <ModelAPI_Data.h>
#include <ModelAPI_Result.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultParameter.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_AttributeValidator.h>
#include <ModelAPI_Events.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Tools.h>
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
//********************************************************************
void ModuleBase_WidgetValidated::filterCompSolids(QList<ModuleBase_ViewerPrsPtr>& theValues)
{
- std::set<ResultCompSolidPtr> aCompSolids;
+ std::set<ResultBodyPtr> aCompSolids;
QList<ModuleBase_ViewerPrsPtr> aValidatedValues;
// Collect compsolids.
for (; anIt != aLast; anIt++) {
const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt;
ObjectPtr anObject = aViewerPrs->object();
- ResultCompSolidPtr aResultCompSolid =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anObject);
- if(aResultCompSolid.get()) {
+ ResultBodyPtr aResultCompSolid =
+ std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObject);
+ if(aResultCompSolid.get() && aResultCompSolid->numberOfSubs() > 0) {
aCompSolids.insert(aResultCompSolid);
}
}
const ModuleBase_ViewerPrsPtr& aViewerPrs = *anIt;
ObjectPtr anObject = aViewerPrs->object();
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
- ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aResult);
+ ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aResult);
if(aResCompSolidPtr.get() && (aCompSolids.find(aResCompSolidPtr) != aCompSolids.end())) {
// Skip sub-solid of compsolid.
continue;
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_Session.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Tools.h>
#include <Events_InfoMessage.h>
if (theObject.get()) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
if (aResult.get()) {
- ResultCompSolidPtr aCompsolidResult =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObject);
- if (aCompsolidResult.get()) {
- if (aCompsolidResult->numberOfSubs() > 0) {
- for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
- ResultPtr aSubResult = aCompsolidResult->subResult(i);
+ ResultBodyPtr aBodyResult =
+ std::dynamic_pointer_cast<ModelAPI_ResultBody>(theObject);
+ if (aBodyResult.get()) {
+ if (aBodyResult->numberOfSubs() > 0) {
+ for(int i = 0; i < aBodyResult->numberOfSubs(); i++) {
+ ResultPtr aSubResult = aBodyResult->subResult(i);
if (aSubResult.get()) {
GeomShapePtr aShape;
addValue(aSubResult, aShape, theFeature, theWorkshop, theObjectShapes);
#include <ModelAPI_Events.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <GeomAPI_PlanarEdges.h>
#include <Events_InfoMessage.h>
aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.));
// Activate individual repaintng if this is a part of compsolid
- ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult);
- SetAutoHilight(aCompSolid.get() == NULL);
+ ResultBodyPtr anOwner = ModelAPI_Tools::bodyOwner(myResult);
+ SetAutoHilight(anOwner.get() == NULL);
ModuleBase_Tools::setPointBallHighlighting(this);
}
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Tools.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Folder.h>
ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(myObject);
if (aResObj.get()) {
ModuleBase_IWorkshop* aWork = workshop();
- ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResObj);
+ ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResObj);
if (aCompRes.get()) {
VisibilityState aState = aCompRes->numberOfSubs(true) == 0 ?
(aWork->isVisible(aCompRes) ? Visible : Hidden) : NoneState;
ModuleBase_ITreeNode* PartSet_FolderNode::createNode(const ObjectPtr& theObj)
{
- ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObj);
+ ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theObj);
if (aCompRes.get())
return new PartSet_CompsolidNode(theObj, this);
return new PartSet_ObjectNode(theObj, this);
void PartSet_CompsolidNode::update()
{
- ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(myObject);
+ ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myObject);
int aNb = aCompRes->numberOfSubs(true);
ModuleBase_ITreeNode* aNode;
ResultBodyPtr aBody;
{
QTreeNodesList aResult;
- ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(myObject);
+ ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myObject);
int aNb = aCompRes->numberOfSubs(true);
ModuleBase_ITreeNode* aNode;
ResultBodyPtr aBody;
QTreeNodesList PartSet_CompsolidNode::objectsDeleted(const DocumentPtr& theDoc, const QString& theGroup)
{
QTreeNodesList aResult;
- ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(myObject);
+ ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(myObject);
int aNb = aCompRes->numberOfSubs(true);
ModuleBase_ITreeNode* aNode;
// Delete extra objects
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_Object.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
for(int i = 0; i < aCurSelList->size(); i++) {
std::shared_ptr<ModelAPI_AttributeSelection> aCurSel = aCurSelList->value(i);
ResultPtr aCurSelContext = aCurSel->context();
- ResultCompSolidPtr aCurSelCompSolidPtr = ModelAPI_Tools::compSolidOwner(aCurSelContext);
+ ResultBodyPtr aCurSelCompSolidPtr = ModelAPI_Tools::bodyOwner(aCurSelContext);
std::shared_ptr<GeomAPI_Shape> aCurSelCompSolid;
if(aCurSelCompSolidPtr.get()) {
aCurSelCompSolid = aCurSelCompSolidPtr->shape();
for(int j = 0; j < aRefSelList->size(); j++) {
std::shared_ptr<ModelAPI_AttributeSelection> aRefSel = aRefSelList->value(j);
ResultPtr aRefSelContext = aRefSel->context();
- ResultCompSolidPtr aRefSelCompSolidPtr =
- ModelAPI_Tools::compSolidOwner(aRefSelContext);
+ ResultBodyPtr aRefSelCompSolidPtr =
+ ModelAPI_Tools::bodyOwner(aRefSelContext);
std::shared_ptr<GeomAPI_Shape> aRefSelCompSolid;
if(aRefSelCompSolidPtr.get()) {
aRefSelCompSolid = aRefSelCompSolidPtr->shape();
#include <ModelAPI_Object.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_AttributeIntArray.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModuleBase_BRepOwner.h>
#include <ModuleBase_IModule.h>
// compsolid is not visualized in the viewer,
// but should have presentation when all sub solids are
// visible. It is useful for highlight presentation where compsolid shape is selectable
- if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultCompSolid::group()) {
- ResultCompSolidPtr aCompsolidResult =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
+ if (!aVisible && aResult.get() && aResult->groupName() == ModelAPI_ResultBody::group()) {
+ ResultBodyPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
bool anAllSubsVisible = aCompsolidResult->numberOfSubs() > 0;
for(int i = 0; i < aCompsolidResult->numberOfSubs() && anAllSubsVisible; i++) {
if (aAISObj.get() == NULL) {
// if result is a result of a composite feature, it is visualized by visualization of
// composite children, so we should get one of this presentations
- ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
+ ResultBodyPtr aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
if (aCompSolid.get() && aCompSolid->numberOfSubs() > 0) {
aAISObj = getAISObject(aCompSolid->subResult(0));
}
#include <ModelAPI_Data.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
#include <ModuleBase_Tools.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_Session.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
#include <AIS_InteractiveContext.hxx>
// is On and we have to use parent result which corresponds to the CompSolid shape
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aFeature);
if (aResult.get()) {
- ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(aResult);
+ ResultBodyPtr aCompSolid = ModelAPI_Tools::bodyOwner(aResult);
if (aCompSolid.get()) {
GeomShapePtr aShape = aCompSolid->shape();
if (aShape.get() && aShape->isEqual(thePrs->shape())) {
#include <ModelAPI_Data.h>
#include <ModelAPI_Result.h>
#include <ModelAPI_Object.h>
-#include <ModelAPI_ResultCompSolid.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_Tools.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Tools.h>
if (aObject.get()) {
aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
if (aFeature.get()) {
- const std::list<std::shared_ptr<ModelAPI_Result>> aResList = aFeature->results();
- ResultPtr aResult;
- ResultCompSolidPtr aCompSolid;
- std::list<ResultPtr>::const_iterator aIt;
- for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
- aResult = (*aIt);
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allResults(aFeature, allRes);
+ for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
aSelectedPrs.append(std::shared_ptr<ModuleBase_ViewerPrs>(
- new ModuleBase_ViewerPrs(aResult, GeomShapePtr(), NULL)));
- aCompSolid = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
- if (aCompSolid.get()) {
- for (int i = 0; i < aCompSolid->numberOfSubs(); i++) {
- ResultBodyPtr aResult = aCompSolid->subResult(i);
- aSelectedPrs.append(std::shared_ptr<ModuleBase_ViewerPrs>(
- new ModuleBase_ViewerPrs(aResult, aResult->shape(), NULL)));
- }
- }
+ new ModuleBase_ViewerPrs(*aRes, GeomShapePtr(), NULL)));
}
}
}
#include <ModelAPI_Feature.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_ResultParameter.h>
for (std::set<ObjectPtr>::const_iterator anObjectsIt = theObjects.begin();
anObjectsIt != theObjects.end(); anObjectsIt++) {
ObjectPtr anObject = *anObjectsIt;
- ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anObject);
+ ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObject);
if (aCompRes.get()) {
- if (aCompRes->numberOfSubs(true) == 0)
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allSubs(aCompRes, allRes);
+ if (allRes.empty()) {
anAllProcessedObjects.insert(anObject);
- else {
- for (int i = 0; i < aCompRes->numberOfSubs(true); i++) {
- ResultPtr aSubRes = aCompRes->subResult(i, true);
- anAllProcessedObjects.insert(aCompRes->subResult(i, true));
+ } else {
+ for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+ ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aRes);
+ if (aBody.get() && aBody->numberOfSubs() == 0)
+ anAllProcessedObjects.insert(aBody);
}
}
- }
- else
+ } else
anAllProcessedObjects.insert(anObject);
}
{
bool aCanBeShaded = myDisplayer->canBeShaded(theObject);
if (!aCanBeShaded) {
- ResultCompSolidPtr aCompsolidResult =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(theObject);
- if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
- for(int i = 0; i < aCompsolidResult->numberOfSubs() && !aCanBeShaded; i++)
- aCanBeShaded = myDisplayer->canBeShaded(aCompsolidResult->subResult(i));
+ ResultBodyPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultBody>(theObject);
+ if (aCompRes.get() != NULL) { // change colors for all sub-solids
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allSubs(aCompRes, allRes);
+ std::list<ResultPtr>::iterator aRes = allRes.begin();
+ for(; aRes != allRes.end() && !aCanBeShaded; aRes++) {
+ aCanBeShaded = myDisplayer->canBeShaded(*aRes);
+ }
}
}
return aCanBeShaded;
foreach(ObjectPtr anObj, theObjects) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
if (aResult.get() != NULL) {
- ResultCompSolidPtr aCompsolidResult =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
- if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
- for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
- setColor(aCompsolidResult->subResult(i), !isRandomColor ? aColorResult :
- aDlg->getRandomColor());
+ ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
+ if (aBodyResult.get() != NULL) { // change colors for all sub-solids
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allSubs(aBodyResult, allRes);
+ for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+ setColor(*aRes, !isRandomColor ? aColorResult : aDlg->getRandomColor());
}
}
setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor());
foreach(ObjectPtr anObj, theObjects) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
if (aResult.get() != NULL) {
- ResultCompSolidPtr aCompsolidResult =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
- if (aCompsolidResult.get() != NULL) { // change property for all sub-solids
- for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
- setTransparency(aCompsolidResult->subResult(i), theTransparency);
+ ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
+ if (aBodyResult.get() != NULL) { // change property for all sub-solids
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allSubs(aBodyResult, allRes);
+ for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+ setTransparency(*aRes, theTransparency);
}
}
setTransparency(aResult, theTransparency);
foreach(ObjectPtr anObj, theObjects) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
if (aResult.get() != NULL) {
- ResultCompSolidPtr aCompsolidResult =
- std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
- if (aCompsolidResult.get() != NULL) { // change property for all sub-solids
- for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
- setDeflection(aCompsolidResult->subResult(i), aDeflection);
+ ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
+ if (aBodyResult.get() != NULL) { // change property for all sub-solids
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allSubs(aBodyResult, allRes);
+ for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+ setDeflection(*aRes, aDeflection);
}
}
setDeflection(aResult, aDeflection);
//**************************************************************
void XGUI_Workshop::setDisplayMode(const QObjectPtrList& theList, int theMode)
{
- foreach(ObjectPtr aObj, theList) {
- myDisplayer->setDisplayMode(aObj, (XGUI_Displayer::DisplayMode)theMode, false);
+ foreach(ObjectPtr anObj, theList) {
+ myDisplayer->setDisplayMode(anObj, (XGUI_Displayer::DisplayMode)theMode, false);
- ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aObj);
- if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
- for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
- myDisplayer->setDisplayMode(aCompsolidResult->subResult(i),
- (XGUI_Displayer::DisplayMode)theMode, false);
+ ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anObj);
+ if (aBodyResult.get() != NULL) { // change display mode for all sub-solids
+ std::list<ResultPtr> allRes;
+ ModelAPI_Tools::allSubs(aBodyResult, allRes);
+ for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
+ myDisplayer->setDisplayMode(*aRes, (XGUI_Displayer::DisplayMode)theMode, false);
}
}
}
#include <ModelAPI_Result.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
-#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_Tools.h>
#include <ModuleBase_Events.h>