-// PyGILState_STATE _gil_state = PyGILState_Ensure();
-//
-// std::string cmd = std::string("import pvsimple as pvs;");
-// cmd += getRenderViewCommand(_params.viewMode); // define __view1
-//
-// cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
-// cmd += std::string("__isovolume1 = pvs.IsoVolume(Input=__obj1);");
-// cmd += std::string("__disp1 = pvs.Show(__isovolume1, __view1);");
-// cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
-// cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
-// cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
-// cmd += std::string("pvs.Render();");
-//
-// cmd += getResetCameraCommand();
-//
-// //std::cerr << "Python command:" << std::endl;
-// //std::cerr << cmd << std::endl;
-// PyRun_SimpleString(cmd.c_str());
-// // Retrieve Python object for internal storage:
-// PyObject* obj = getPythonObjectFromMain("__isovolume1");
-// PyObject* disp = getPythonObjectFromMain("__disp1");
-// pushInternal(obj, disp);
-//
-// PyGILState_Release(_gil_state);
+ MEDPresentation::internalGeneratePipeline();
+
+ MEDPyLockWrapper lock;
+
+ createSource();
+ setTimestamp();
+
+ // Populate internal array of available components:
+ fillAvailableFieldComponents();
+ if (getIntProperty(MEDPresentation::PROP_NB_COMPONENTS) > 1)
+ {
+ const char * msg = "Contour presentation only works for scalar field!"; // this message will appear in GUI too
+ STDLOG(msg);
+ throw KERNEL::createSalomeException(msg);
+ }
+ if (_params.nbContours < 1)
+ {
+ const char * mes = "Invalid number of contours!";
+ STDLOG(mes);
+ throw KERNEL::createSalomeException(mes);
+ }
+
+ setOrCreateRenderView(); // instantiate __viewXXX, needs to be after the exception above otherwise previous elements in the view will be hidden.
+
+ // Contour needs point data:
+ applyCellToPointIfNeeded();
+
+ std::ostringstream oss;
+ oss << _objVar << " = pvs.Contour(Input=" << _srcObjVar << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ showObject();
+
+ oss << _objVar << ".ContourBy = ['POINTS', '" << _fieldName << "'];";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ // Colorize contour
+ oss << _objVar << ".ComputeScalars = 1;";
+ pushAndExecPyLine(oss.str()); oss.str("");
+
+ // Set number of contours
+ setNumberContours();
+
+ colorBy(); // see initFieldInfo() - necessarily POINTS because of the conversion above
+ showScalarBar();
+ selectColorMap();
+ rescaleTransferFunction();
+ resetCameraAndRender();