Commit: fe641570636bc842f30b0cbf718020ded3764c72
Author: Sebastián Barschkis
Date:   Tue Oct 6 00:51:00 2015 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBfe641570636bc842f30b0cbf718020ded3764c72

improving manta export script

===================================================================

M       intern/smoke/intern/MANTA.cpp
M       intern/smoke/intern/MANTA.h
M       intern/smoke/intern/scenarios/smoke.h

===================================================================

diff --git a/intern/smoke/intern/MANTA.cpp b/intern/smoke/intern/MANTA.cpp
index 1cd5b2e..572d58d 100644
--- a/intern/smoke/intern/MANTA.cpp
+++ b/intern/smoke/intern/MANTA.cpp
@@ -381,7 +381,7 @@ void Manta_API::export_obstacles(float *data, int x, int y, 
int z, bool is2D = f
 
 void Manta_API::run_manta_sim_highRes(WTURBULENCE *wt)
 {
-       if (wt == NULL){                
+       if (wt == NULL) {
                cout << "ERROR: cannot run wt step, wt object is NULL " <<endl; 
 return;
        }
        PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -396,16 +396,25 @@ void Manta_API::run_manta_sim_highRes(WTURBULENCE *wt)
        updateHighResPointers(wt/*,false*/);
 }
 
-void Manta_API::run_manta_sim_file_lowRes(SmokeModifierData *smd)
+std::string get_manta_smoke_script(bool highRes, SmokeModifierData *smd)
 {
-       // Get either liquid or smoke setup string
-       string smoke_script = "";
-       if (smd->domain->flags & MOD_SMOKE_MANTA_USE_LIQUID)
-               smoke_script = smoke_setup_low  + liquid_step_low;
-       else
-               smoke_script = smoke_setup_low  + smoke_step_low;
+       std::string smoke_script = "";
+       if (highRes) {
+               smoke_script = smoke_setup_high + smoke_step_high;
+       } else {
+               if (smd->domain->flags & MOD_SMOKE_MANTA_USE_LIQUID)
+                       smoke_script = smoke_setup_low  + liquid_step_low;
+               else
+                       smoke_script = smoke_setup_low  + smoke_step_low;
+       }
+       return smoke_script;
+}
 
+void Manta_API::run_manta_sim_file_lowRes(SmokeModifierData *smd)
+{
+       std::string smoke_script = get_manta_smoke_script(false, smd);
        std::string final_script = parseScript(smoke_script, smd);
+       
        PyGILState_STATE gilstate = PyGILState_Ensure();
        PyRun_SimpleString(final_script.c_str());
        PyGILState_Release(gilstate);
@@ -413,8 +422,9 @@ void Manta_API::run_manta_sim_file_lowRes(SmokeModifierData 
*smd)
 
 void Manta_API::run_manta_sim_file_highRes(SmokeModifierData *smd)
 {
-       string smoke_script = smoke_setup_high + smoke_step_high;               
+       std::string smoke_script = get_manta_smoke_script(true, smd);
        std::string final_script = parseScript(smoke_script, smd);
+       
        PyGILState_STATE gilstate = PyGILState_Ensure();
        PyRun_SimpleString(final_script.c_str());
        PyGILState_Release(gilstate);
@@ -539,7 +549,7 @@ std::string Manta_API::parseLine(const string& line, 
SmokeModifierData *smd)
        bool readingVar = false;
        const char delimiter = '$';
        while (currPos < line.size()){
-               if(line[currPos] == delimiter && ! readingVar){
+               if(line[currPos] == delimiter && ! readingVar) {
                        readingVar      = true;
                        start_del       = currPos + 1;
                        res             += line.substr(end_del + 1, currPos - 
end_del -1);
@@ -555,24 +565,22 @@ std::string Manta_API::parseLine(const string& line, 
SmokeModifierData *smd)
        return res;
 }
 
-std::string Manta_API::parseScript(const string & setup_string, 
SmokeModifierData *smd)
+std::string Manta_API::parseScript(const string& setup_string, 
SmokeModifierData *smd)
 {
        std::istringstream f(setup_string);
        ostringstream res;
-       string line="";
-       while(getline(f,line)){
-               res << parseLine(line,smd) << "\n"; 
+       string line = "";
+       while(getline(f, line)) {
+               res << parseLine(line, smd) << "\n";
        }
        return res.str();
 }
 
-void Manta_API::manta_export_grids(SmokeModifierData *smd){
-       std::string smoke_script;
-       if (smd->domain->flags & MOD_SMOKE_MANTA_USE_LIQUID)
-               smoke_script = smoke_setup_low  + liquid_step_low;
-       else
-               smoke_script = smoke_setup_low  + smoke_step_low;
+void Manta_API::manta_export_grids(SmokeModifierData *smd)
+{
+       std::string smoke_script = get_manta_smoke_script(false, smd);
        std::string final_script = Manta_API::parseScript(smoke_script, smd) + 
standalone;
+       
        ofstream myfile;
        myfile.open (smd->domain->_manta_filepath);
        myfile << final_script;
@@ -585,7 +593,7 @@ void Manta_API::manta_export_grids(SmokeModifierData *smd){
 
 string Manta_API::getGridPointer(std::string gridName, std::string solverName)
 {
-       if ((gridName == "") && (solverName == "")){
+       if ((gridName == "") && (solverName == "")) {
                return "";
        }
        cout << "getting grid pointer " << gridName<< " , " << solverName 
<<endl;
diff --git a/intern/smoke/intern/MANTA.h b/intern/smoke/intern/MANTA.h
index 54cb40d..c7c5bc6 100644
--- a/intern/smoke/intern/MANTA.h
+++ b/intern/smoke/intern/MANTA.h
@@ -130,6 +130,7 @@ public:
        static void updatePointers(FLUID_3D *fluid);
        static void updateHighResPointers(WTURBULENCE *wt);
        static void manta_export_grids(SmokeModifierData *smd);
+       static std::string get_manta_smoke_script(bool highRes, 
SmokeModifierData *smd);
 };
 
 
diff --git a/intern/smoke/intern/scenarios/smoke.h 
b/intern/smoke/intern/scenarios/smoke.h
index 1c71673..20d434a 100644
--- a/intern/smoke/intern/scenarios/smoke.h
+++ b/intern/smoke/intern/scenarios/smoke.h
@@ -159,6 +159,16 @@ 
density.save(os.path.join('$MANTA_EXPORT_PATH$','density.uni'))\n\
 flags.save(os.path.join('$MANTA_EXPORT_PATH$','flags.uni'))\n\
 inflow_grid.save(os.path.join('$MANTA_EXPORT_PATH$','inflow.uni'))\n\
 forces.save(os.path.join('$MANTA_EXPORT_PATH$','forces.uni'))\n\
+if manta_using_colors:\n\
+  color_r_low.save(os.path.join('$MANTA_EXPORT_PATH$','color_r.uni'))\n\
+  color_g_low.save(os.path.join('$MANTA_EXPORT_PATH$','color_g.uni'))\n\
+  color_b_low.save(os.path.join('$MANTA_EXPORT_PATH$','color_b.uni'))\n\
+if manta_using_heat:\n\
+  heat_low.save(os.path.join('$MANTA_EXPORT_PATH$','heat.uni'))\n\
+if manta_using_fire:\n\
+  flame_low.save(os.path.join('$MANTA_EXPORT_PATH$','flame.uni'))\n\
+  fuel_low.save(os.path.join('$MANTA_EXPORT_PATH$','fuel.uni'))\n\
+  react_low.save(os.path.join('$MANTA_EXPORT_PATH$','react.uni'))\n\
 print('Grids exported')";
 
 const string fire_process_burn_low = "\n\

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to