return LONG_UNDEFINED;
}
+/**
+ * Get the timestep associated to a field
+ */
+double MEDDataManager_i::getFieldTimeStep(CORBA::Long fieldHandlerId)
+{
+ int iteration, order;
+ // WARN: note that the variables "iteration" and "order" are passed
+ // by reference to the function getTime (see documentation of
+ // MEDCouplingField). As a consequence, the values of these
+ // variables are updated by this function call. This is the means to
+ // retrieve the iteration and order of the field.
+ MEDCALC::FieldHandler * fieldHandler = getFieldHandler(fieldHandlerId);
+ MEDCouplingFieldDouble* fieldDouble = getFieldDouble(fieldHandler);
+ double timestamp = fieldDouble->getTime(iteration, order);
+ return timestamp;
+}
+
/*!
* This method returns the physical data of the specified field,
* i.e. the MEDCoupling field associated to the specified field
MEDCALC::MeshHandler* meshHandler = dataManager->getMeshHandler(fieldHandler->meshid);
MEDCALC::DatasourceHandler* dataSHandler = dataManager->getDatasourceHandlerFromID(meshHandler->sourceid);
- extractFileName(std::string(dataSHandler->uri));
+ // get the file name of the field (or its memory information)
+ extractFileName(std::string(fieldHandler->source));
_fieldName = fieldHandler->fieldname;
_mcFieldType = (MEDCoupling::TypeOfField) fieldHandler->type;
void
MEDPresentation::extractFileName(const std::string& name)
{
+ STDLOG("MEDPresentation::extractFileName('" << name << "')");
_fileName = name;
if (_fileName.substr(0, 7) != std::string("file://")) {
- const char* msg = "MEDPresentation(): Data source is not a file! Can not proceed.";
+ const char* msg = "MEDPresentation(): Data source is in memory! Saving it in tmp file.";
STDLOG(msg);
- throw MEDPresentationException(msg);
+ // export a med file with this field
+ // we could instead use CORBA to transfer the field to PARAVIS like in MEDCalculatorDBFieldReal::display()
+ _fileName = std::tmpnam(NULL);
+ MEDCALC::FieldIdList fieldIdList;
+ fieldIdList.length(1);
+ fieldIdList[0] = _handlerId;
+ MEDFactoryClient::getDataManager()->saveFields(_fileName.c_str(), fieldIdList);
}
- _fileName = _fileName.substr(7, _fileName.size());
+ else
+ // removing "file://"
+ _fileName = _fileName.substr(7, _fileName.size());
+ STDLOG("MEDPresentation::extractFileName _fileName=" << _fileName);
}
MEDPresentation::~MEDPresentation()
}
}
+/*
+ * Set the timestep of the animation to the timestep of the field.
+ * Especially useful when working on a field's iteration:
+ * in the workspace, in the python console, or using changeUnderlyingMesh.
+ */
+void
+MEDPresentation::setTimestep()
+{
+ // get the timestep of the field
+ double timestep = MEDFactoryClient::getDataManager()->getFieldTimeStep(_handlerId);
+
+ std::ostringstream oss;
+
+ // go to the right timestep in animation (view and VCR toolbar)
+ pushAndExecPyLine("pvs.GetAnimationScene().UpdateAnimationUsingDataTimeSteps()");
+ oss << "pvs.GetAnimationScene().AnimationTime = " << timestep << ";";
+ pushAndExecPyLine(oss.str()); oss.str("");
+}
+
void
MEDPresentation::setOrCreateRenderView()
{
commands += "";
commands += "from medcalc.medconsole import saveWorkspace, cleanWorkspace";
commands += "from medcalc.medconsole import putInWorkspace, removeFromWorkspace";
- commands += "from medcalc.medconsole import accessField";
+ commands += "from medcalc.medconsole import accessField, view";
commands += "from medcalc.medconsole import getEnvironment, ls, la";
commands += "";
this->exec(commands);