]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/ModelHighAPI/ModelHighAPI_Dumper.cpp
Salome HOME
Draft of transparency
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Dumper.cpp
index c005e37f024c72b879ab113212078447dcae4955..ba329d412e4b3783596f73ed44c772cf372cff4c 100644 (file)
@@ -474,6 +474,15 @@ void ModelHighAPI_Dumper::dumpEntitySetName()
         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;
@@ -534,6 +543,15 @@ bool ModelHighAPI_Dumper::isDefaultDeflection(const ResultPtr& theResult) const
   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;
+}
+
 ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const char theChar)
 {
   myDumpBuffer << theChar;
@@ -674,7 +692,7 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const FeaturePtr& theEntity
     std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
     for (; aResIt != aResults.end(); ++aResIt) {
       if (!myNames[*aResIt].myIsDefault || !isDefaultColor(*aResIt) ||
-          !isDefaultDeflection(*aResIt))
+          !isDefaultDeflection(*aResIt) || !isDefaultTransparency(*aResIt))
         aResultsWithNameOrColor.push_back(*aResIt);
 
       ResultCompSolidPtr aCompSolid =
@@ -684,7 +702,7 @@ ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(const FeaturePtr& theEntity
         for (int i = 0; i < aNbSubs; ++i) {
           ResultPtr aCurRes = aCompSolid->subResult(i);
           if (!myNames[aCurRes].myIsDefault || !isDefaultColor(aCurRes) ||
-              !isDefaultDeflection(aCurRes))
+              !isDefaultDeflection(aCurRes) || !isDefaultTransparency(aCurRes))
             aResultsWithNameOrColor.push_back(aCurRes);
         }
       }