+ // dump "setName" for the entity
+ if (aLastDumped.myUserName) {
+ EntityName& anEntityNames = myNames[aLastDumped.myEntity];
+ if (!anEntityNames.myIsDefault)
+ myDumpBuffer << anEntityNames.myCurrentName << ".setName(\""
+ << anEntityNames.myUserName << "\")" << std::endl;
+ // don't dump "setName" for the entity twice
+ anEntityNames.myUserName.clear();
+ anEntityNames.myIsDefault = true;
+ }
+ // dump "setName" for results
+ std::list<ResultPtr>::const_iterator aResIt = aLastDumped.myResults.begin();
+ std::list<ResultPtr>::const_iterator aResEnd = aLastDumped.myResults.end();
+ for (; aResIt != aResEnd; ++aResIt) {
+ // set result name
+ EntityName& anEntityNames = myNames[*aResIt];
+ if (!anEntityNames.myIsDefault) {
+ *this << *aResIt;
+ myDumpBuffer << ".setName(\"" << anEntityNames.myUserName << "\")" << std::endl;
+ // don't dump "setName" for the entity twice
+ anEntityNames.myUserName.clear();
+ anEntityNames.myIsDefault = true;
+ }
+ // set result color
+ if (!isDefaultColor(*aResIt)) {
+ AttributeIntArrayPtr aColor = (*aResIt)->data()->intArray(ModelAPI_Result::COLOR_ID());
+ if (aColor && aColor->isInitialized()) {
+ *this << *aResIt;
+ myDumpBuffer << ".setColor(" << aColor->value(0) << ", " << aColor->value(1)
+ << ", " << aColor->value(2) << ")" << std::endl;
+ }
+ }
+ // set result deflection
+ if (!isDefaultDeflection(*aResIt)) {
+ AttributeDoublePtr aDeflectionAttr =
+ (*aResIt)->data()->real(ModelAPI_Result::DEFLECTION_ID());
+ if(aDeflectionAttr.get() && aDeflectionAttr->isInitialized()) {
+ *this << *aResIt;
+ myDumpBuffer << ".setDeflection(" << aDeflectionAttr->value() << ")" << std::endl;
+ }
+ }
+ // set result transparency
+ if (!isDefaultTransparency(*aResIt)) {
+ AttributeDoublePtr aTransparencyAttr =
+ (*aResIt)->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
+ if(aTransparencyAttr.get() && aTransparencyAttr->isInitialized()) {
+ *this << *aResIt;
+ myDumpBuffer << ".setTransparency(" << aTransparencyAttr->value() << ")" << std::endl;
+ }
+ }
+ }
+
+ myNames[aLastDumped.myEntity].myIsDumped = true;
+ myEntitiesStack.pop();
+}
+
+bool ModelHighAPI_Dumper::isDumped(const EntityPtr& theEntity) const
+{
+ EntityNameMap::const_iterator aFound = myNames.find(theEntity);
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theEntity);
+ return (aFound != myNames.end() && aFound->second.myIsDumped) ||
+ myFeaturesToSkip.find(aFeature) != myFeaturesToSkip.end();
+}
+
+bool ModelHighAPI_Dumper::isDumped(const AttributeRefAttrPtr& theRefAttr) const
+{
+ FeaturePtr aFeature;
+ if (theRefAttr->isObject())
+ aFeature = ModelAPI_Feature::feature(theRefAttr->object());
+ else
+ aFeature = ModelAPI_Feature::feature(theRefAttr->attr()->owner());
+ return aFeature && isDumped(EntityPtr(aFeature));
+}
+
+bool ModelHighAPI_Dumper::isDumped(const AttributeRefListPtr& theRefList) const
+{
+ std::list<ObjectPtr> aRefs = theRefList->list();
+ std::list<ObjectPtr>::iterator anIt = aRefs.begin();
+ for (; anIt != aRefs.end(); ++anIt) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
+ if (aFeature && !isDumped(EntityPtr(aFeature)))
+ return false;
+ }
+ return true;
+}
+
+bool ModelHighAPI_Dumper::isDefaultColor(const ResultPtr& theResult) const
+{
+ AttributeIntArrayPtr aColor = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+ if (!aColor || !aColor->isInitialized())
+ return true;
+
+ std::string aSection, aName, aDefault;
+ theResult->colorConfigInfo(aSection, aName, aDefault);
+
+ // dump current color
+ std::ostringstream aColorInfo;
+ aColorInfo << aColor->value(0) << "," << aColor->value(1) << "," << aColor->value(2);
+
+ return aDefault == aColorInfo.str();
+}
+
+bool ModelHighAPI_Dumper::isDefaultDeflection(const ResultPtr& theResult) const
+{
+ AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
+ if(!aDeflectionAttr || !aDeflectionAttr->isInitialized()) {
+ return true;
+ }
+
+ double aCurrent = aDeflectionAttr->value();
+ double aDefault = -1;
+
+ bool isConstruction = false;
+ std::string aResultGroup = theResult->groupName();
+ if (aResultGroup == ModelAPI_ResultConstruction::group())
+ isConstruction = true;
+ else if (aResultGroup == ModelAPI_ResultBody::group()) {
+ GeomShapePtr aGeomShape = theResult->shape();
+ if (aGeomShape.get()) {
+ // if the shape could not be exploded on faces, it contains only wires, edges, and vertices
+ // correction of deviation for them should not influence to the application performance
+ GeomAPI_ShapeExplorer anExp(aGeomShape, GeomAPI_Shape::FACE);
+ isConstruction = !anExp.more();
+ }
+ }
+ if (isConstruction)
+ aDefault = Config_PropManager::real("Visualization", "construction_deflection");
+ else
+ aDefault = Config_PropManager::real("Visualization", "body_deflection");
+
+ return fabs(aCurrent - aDefault) < 1.e-12;
+}
+
+bool ModelHighAPI_Dumper::isDefaultTransparency(const ResultPtr& theResult) const
+{
+ AttributeDoublePtr anAttribute = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
+ if(!anAttribute || !anAttribute->isInitialized()) {
+ return true;
+ }
+ return fabs(anAttribute->value()) < 1.e-12;