1 #include "MEDPresentationScalarMap.hxx"
2 #include "MEDFactoryClient.hxx"
7 MEDPresentationScalarMap::internalGeneratePipeline()
9 MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
11 MEDCALC::MeshHandler* meshHandler = dataManager->getMesh(_fieldHandler->meshid);
12 MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
14 std::string fileName(dataSHandler->uri);
15 std::string fieldName(_fieldHandler->fieldname);
16 std::string fieldType = getFieldTypeString();
18 std::cout << "Generating pipeline for SCALAR MAP:" <<std::endl;
19 std::cout << "\tfileName: " << fileName << std::endl;
20 std::cout << "\tfiedName: " << fieldName << std::endl;
21 if (fileName.substr(0, 7) != std::string("file://"))
23 std::cerr << "\tData source is not a file! Can not proceed." << std::endl;
27 fileName = fileName.substr(7, fileName.size());
28 std::cout << "\tfileName: " << fileName << std::endl;
30 PyGILState_STATE _gil_state = PyGILState_Ensure();
32 std::string cmd = std::string("import pvsimple as pvs;");
33 cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + fileName + std::string("');");
34 cmd += std::string("__disp1 = pvs.Show(__obj1);");
35 cmd += std::string("pvs.ColorBy(__disp1, ('") + fieldType + std::string("', '") + fieldName + std::string("'));");
36 cmd += std::string("pvs.GetActiveViewOrCreate('RenderView').ResetCamera();");
37 cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
39 //std::cerr << "Python command:" << std::endl;
40 //std::cerr << cmd << std::endl;
41 PyRun_SimpleString(cmd.c_str());
42 // Retrieve Python object for internal storage:
43 PyObject * obj = getPythonObjectFromMain("__obj1");
44 PyObject * disp = getPythonObjectFromMain("__disp1");
45 pushInternal(obj, disp);
47 PyGILState_Release(_gil_state);