X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FModelAPI_Tools.cpp;h=413f52c4ce616edd2c2e4cb49f84f0621dde2737;hb=befbd47554122bdbc74789ee76975167292d58be;hp=c6b8a6f7257df6ba4933747cb038402399502a87;hpb=631375bfe684e0eb11834499c88e835da7ff9d13;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index c6b8a6f72..413f52c4c 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -784,4 +785,84 @@ void removeResults(const std::list& theResults) } } +// used by GUI only +// LCOV_EXCL_START +double getDeflection(const std::shared_ptr& theResult) +{ + double aDeflection = -1; + // get deflection from the attribute of the result + if (theResult.get() != NULL && + theResult->data()->attribute(ModelAPI_Result::DEFLECTION_ID()).get() != NULL) { + AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID()); + if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) { + double aValue = aDoubleAttr->value(); + if (aValue > 0) /// zero value should not be used as a deflection(previous studies) + aDeflection = aDoubleAttr->value(); + } + } + return aDeflection; +} + + +void getColor(const std::shared_ptr& theResult, std::vector& theColor) +{ + theColor.clear(); + // get color from the attribute of the result + if (theResult.get() != NULL && + theResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) { + AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID()); + if (aColorAttr.get() && aColorAttr->size()) { + theColor.push_back(aColorAttr->value(0)); + theColor.push_back(aColorAttr->value(1)); + theColor.push_back(aColorAttr->value(2)); + } + } +} + +double getTransparency(const std::shared_ptr& theResult) +{ + double aTransparency = -1; + // get transparency from the attribute of the result + if (theResult.get() != NULL && + theResult->data()->attribute(ModelAPI_Result::TRANSPARENCY_ID()).get() != NULL) { + AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID()); + if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) { + aTransparency = aDoubleAttr->value(); + } + } + return aTransparency; +} +// LCOV_EXCL_STOP + +void copyVisualizationAttrs( + std::shared_ptr theSource, std::shared_ptr theDest) +{ + // color + AttributeIntArrayPtr aSourceColor = theSource->data()->intArray(ModelAPI_Result::COLOR_ID()); + if (aSourceColor.get() && aSourceColor->isInitialized() && aSourceColor->size()) { + AttributeIntArrayPtr aDestColor = theDest->data()->intArray(ModelAPI_Result::COLOR_ID()); + if (aDestColor.get()) { + aDestColor->setSize(aSourceColor->size()); + for(int a = 0; a < aSourceColor->size(); a++) + aDestColor->setValue(a, aSourceColor->value(a)); + } + } + // deflection + AttributeDoublePtr aSourceDefl = theSource->data()->real(ModelAPI_Result::DEFLECTION_ID()); + if (aSourceDefl.get() && aSourceDefl->isInitialized()) { + AttributeDoublePtr aDestDefl = theDest->data()->real(ModelAPI_Result::DEFLECTION_ID()); + if (aDestDefl.get()) { + aDestDefl->setValue(aSourceDefl->value()); + } + } + // transparency + AttributeDoublePtr aSourceTransp = theSource->data()->real(ModelAPI_Result::TRANSPARENCY_ID()); + if (aSourceTransp.get() && aSourceTransp->isInitialized()) { + AttributeDoublePtr aDestTransp = theDest->data()->real(ModelAPI_Result::TRANSPARENCY_ID()); + if (aDestTransp.get()) { + aDestTransp->setValue(aSourceTransp->value()); + } + } +} + } // namespace ModelAPI_Tools