-void Model_Document::updateResults(FeaturePtr theFeature)
-{
- // for not persistent is will be done by parametric updater automatically
- //if (!theFeature->isPersistentResult()) return;
- // check the existing results and remove them if there is nothing on the label
- std::list<ResultPtr>::const_iterator aResIter = theFeature->results().cbegin();
- while(aResIter != theFeature->results().cend()) {
- ResultPtr aBody = std::dynamic_pointer_cast<ModelAPI_Result>(*aResIter);
- if (aBody) {
- if (!aBody->data()->isValid()) {
- // found a disappeared result => remove it
- theFeature->removeResult(aBody);
- // start iterate from beginning because iterator is corrupted by removing
- aResIter = theFeature->results().cbegin();
- continue;
- }
- }
- aResIter++;
- }
- // it may be on undo
- if (!theFeature->data() || !theFeature->data()->isValid())
- return;
- // check that results are presented on all labels
- int aResSize = theFeature->results().size();
- TDF_ChildIterator aLabIter(resultLabel(theFeature->data(), 0).Father());
- for(; aLabIter.More(); aLabIter.Next()) {
- // here must be GUID of the feature
- int aResIndex = aLabIter.Value().Tag() - 1;
- ResultPtr aNewBody;
- if (aResSize <= aResIndex) {
- TDF_Label anArgLab = aLabIter.Value();
- Handle(TDataStd_Comment) aGroup;
- if (anArgLab.FindAttribute(TDataStd_Comment::GetID(), aGroup)) {
- if (aGroup->Get() == ModelAPI_ResultBody::group().c_str()) {
- aNewBody = createBody(theFeature->data(), aResIndex);
- } else if (aGroup->Get() == ModelAPI_ResultPart::group().c_str()) {
- aNewBody = createPart(theFeature->data(), aResIndex);
- } else if (aGroup->Get() == ModelAPI_ResultConstruction::group().c_str()) {
- theFeature->execute(); // construction shapes are needed for sketch solver
- break;
- } else if (aGroup->Get() == ModelAPI_ResultGroup::group().c_str()) {
- aNewBody = createGroup(theFeature->data(), aResIndex);
- } else {
- Events_Error::send(std::string("Unknown type of result is found in the document:") +
- TCollection_AsciiString(aGroup->Get()).ToCString());
- }
- }
- if (aNewBody) {
- theFeature->setResult(aNewBody, aResIndex);
- }
- }
- }
-}
-