STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
SET(${PROJECT_NAME_UC}_MAJOR_VERSION 8)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 1)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
ENDIF()
LIST(APPEND _${PROJECT_NAME}_exposed_targets
- medcouplingcorba medcouplingclient medcalculator MEDFactoryEngine)
+ medcouplingcorba medcouplingclient medcalculator MEDEngineCommon MEDFactoryEngine MEDEngine)
IF(SALOME_MED_ENABLE_PYTHON)
LIST(APPEND _${PROJECT_NAME}_exposed_targets medcalculatorspython)
ENDIF()
SET(MED_medcouplingclient medcouplingclient)
SET(MED_medcalculator medcalculator)
SET(MED_medcalculatorspython medcalculatorspython)
+SET(MED_MEDEngineCommon MEDEngineCommon)
SET(MED_MEDFactoryEngine MEDFactoryEngine)
+SET(MED_MEDEngine MEDEngine)
SET(MED_MEDCALCGUI_dialogs MEDCALCGUI_dialogs)
SET(MED_MEDCALCGUI MEDCALCGUI)
test "x$ac_cv_sizeof_int" = "x4" || AC_MSG_ERROR([Size of C type int expected to be four bytes])
DEFINED_F77INT64=""
else
- AC_MSG_ERROR([Size of Fortran type integer is neither four nor eigth bytes])
+ AC_MSG_ERROR([Size of Fortran type integer is neither four nor eight bytes])
fi
AC_SUBST(DEFINED_F77INT64)
])
\ No newline at end of file
+@import url("default.css");
@import url("classic.css");
body {
# General information about the project.
project = 'MED, Manipulation de champs dans SALOME'
-copyright = '2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE, G. Boulant, A. Geay'
+copyright = '2010-2017 CEA/DEN, EDF R&D, OPEN CASCADE, G. Boulant, A. Geay'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
SALOME MED module. Keep in mind that the MEDMEM library is designed to
be a self-consistent library with very few third party softwares (only
med-file, glibc and mpi typically). In particular, it is strictly
-independant from the SALOME framework even if it distributed with
+independent from the SALOME framework even if it distributed with
SALOME for convenience reasons.
Components of the MEDMEM library
We suggest to work with a simple list concept to store the metadata
for each mesh entry and each field entry. Note that a mesh entry is
characterized by the mesh name only, while a field entry is
-charaterized by the following attributes:
+characterized by the following attributes:
* :tt:`fieldName`: the name of the field
* :tt:`meshName`: the name of the mesh that supports the field
* :tt:`iteration`: a couple of integers :tt:`(iter,order)` that
characterizes the step in a serie (timeseries or spectrum).
-By default, we suggest to work with a simple map concept (dictionnary in a
+By default, we suggest to work with a simple map concept (dictionary in a
python context, map in a C++ context) to register the meshes and
fields loaded from the med file for each metadata entry.
case, for performance reasons. For example, the following code
illustrates how to dispatch the metadata in a tree data structure
where leaves are the physical data (field objects). We first have to
-define a tree structure (basic definition in htis simple case, but it
+define a tree structure (basic definition in this simple case, but it
works fine):
.. include:: ../../tut/medloader/manage.py
class FuncCosinus(Function):
def __init__(self,nbPeriods):
- # The pulsation w must be choosen so that w*xmax=n*2pi where
+ # The pulsation w must be chosen so that w*xmax=n*2pi where
# xmax=1 and n is an integer that corresponds to the number of
# oscilations on the xrange [0,xmax].
w=nbPeriods*2*pi
def createMesh(meshname, sizeX, sizeY):
"""
Creating a cartesian mesh with a grid of the size of the image.
- sizeX and sizeY should be respectively the width and heigth of the
+ sizeX and sizeY should be respectively the width and height of the
image.
"""
# >>>
img=Image.open("images/avatar.png")
#img=Image.open("images/irm.png")
imgbw=ImageOps.grayscale(img)
- # We keep only the grayscale. Maybe, it could be usefull to get
+ # We keep only the grayscale. Maybe, it could be useful to get
# the RGB scales each on one component of the field.
width,height=imgbw.size
# MEDCoupling field? Or a tree that you cross using attribute and
# whose leaves are the MEDCoupling fields?
# R: I think that the default structure should be a simple list that
-# store objects whith properties that corresponds to the metadata (and
+# store objects with properties that corresponds to the metadata (and
# if loaded the MEDCouplingField or Mesh). Then for specific request,
# a BTree could be create to organize the search (for example if we
# request all the fields for a given iteration step, then we should
};
typedef sequence<FieldseriesHandler> FieldseriesHandlerList;
- // The FieldHandler structure is a lightweigth data structure that
+ // The FieldHandler structure is a lightweight data structure that
// represents a single field (as understood in MEDCoupling model).
struct FieldHandler {
long id;
FieldHandler getFieldHandler(in long fieldHandlerId);
FieldHandlerList getFieldHandlerList();
- // __GBO__ Maybe it could be usefull to define a getFieldHandlerList with a datasourceId in argument
+ // __GBO__ Maybe it could be useful to define a getFieldHandlerList with a datasourceId in argument
string getFieldRepresentation(in long fieldHandlerId);
// Persistency management
EVENT_ADD_PRESENTATION,
EVENT_REMOVE_PRESENTATION,
EVENT_MODIFY_PRESENTATION,
+ EVENT_CHANGE_UNDERLYING_MESH,
+ EVENT_INTERPOLATE_FIELD,
EVENT_PLAY_TEST,
EVENT_QUIT_SALOME,
EVENT_ERROR,
MEDPresentationDeflectionShape.cxx
)
-SET(MEDFactoryEngine_SOURCES
+SET(MEDEngineCommon_SOURCES
${COMMON_SOURCES}
+)
+
+SET(MEDFactoryEngine_SOURCES
MEDFactory_i.cxx
)
SET(MEDEngine_SOURCES
- ${COMMON_SOURCES}
MED.cxx
)
SET(COMMON_FLAGS "${COMMON_FLAGS} -DNOMINMAX")
ENDIF(WIN32)
+ADD_LIBRARY(MEDEngineCommon SHARED ${MEDEngineCommon_SOURCES})
+SET_TARGET_PROPERTIES(MEDEngineCommon PROPERTIES COMPILE_FLAGS "${COMMON_FLAGS}")
+TARGET_LINK_LIBRARIES(MEDEngineCommon ${COMMON_LIBS})
+
ADD_LIBRARY(MEDFactoryEngine SHARED ${MEDFactoryEngine_SOURCES})
SET_TARGET_PROPERTIES(MEDFactoryEngine PROPERTIES COMPILE_FLAGS "${COMMON_FLAGS}")
-TARGET_LINK_LIBRARIES(MEDFactoryEngine ${COMMON_LIBS})
+TARGET_LINK_LIBRARIES(MEDFactoryEngine ${COMMON_LIBS} MEDEngineCommon)
ADD_LIBRARY(MEDEngine SHARED ${MEDEngine_SOURCES})
SET_TARGET_PROPERTIES(MEDEngine PROPERTIES COMPILE_FLAGS "${COMMON_FLAGS}")
-TARGET_LINK_LIBRARIES(MEDEngine ${COMMON_LIBS})
+TARGET_LINK_LIBRARIES(MEDEngine ${COMMON_LIBS} MEDEngineCommon)
#INSTALL(TARGETS MEDFactoryEngine DESTINATION ${SALOME_INSTALL_LIBS})
+INSTALL(TARGETS MEDEngineCommon EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
INSTALL(TARGETS MEDFactoryEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
INSTALL(TARGETS MEDEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
#ifndef _MED_HXX_
#define _MED_HXX_
-#ifdef WIN32
-# if defined MEDENGINE_EXPORTS || defined MEDEngine_EXPORTS
-# define MEDENGINE_EXPORT __declspec( dllexport )
-# else
-# define MEDENGINE_EXPORT __declspec( dllimport )
-# endif
-#else
-# define MEDENGINE_EXPORT
-#endif
-
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(MED_Gen)
#include CORBA_SERVER_HEADER(MEDDataManager)
#include <map>
#include <string>
-class MEDENGINE_EXPORT MED :
+#include "MEDCALC.hxx"
+
+class MEDCALC_EXPORT MED :
public POA_MED_ORB::MED_Gen,
public Engines_Component_i
{
};
extern "C"
-MEDENGINE_EXPORT
+MEDCALC_EXPORT
PortableServer::ObjectId* MEDEngine_factory( CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId,
#define __MEDCALC_HXX__
#ifdef WIN32
-# if defined MEDFactoryEngine_EXPORTS || defined MEDEngine_EXPORTS
+# if defined MEDFactoryEngine_EXPORTS || defined MEDEngine_EXPORTS || defined MEDEngineCommon_EXPORTS
# define MEDCALC_EXPORT __declspec( dllexport )
# else
# define MEDCALC_EXPORT __declspec( dllimport )
// Other public functions (non available via CORBA)
// ===========================================================
//
- static MEDCalculator_i * getInstance();
+ MEDCALC_EXPORT static MEDCalculator_i * getInstance();
private:
MEDCalculator_i();
public SALOME::GenericObj_i
{
public:
- static MEDCommandsHistoryManager_i* getInstance();
+ MEDCALC_EXPORT static MEDCommandsHistoryManager_i* getInstance();
MEDCALC_EXPORT void addCommand(const char* command);
MEDCALC_EXPORT MEDCALC::CommandsList* getCommandsHistory();
* function savePersistentFields is called.
*/
void MEDDataManager_i::markAsPersistent(CORBA::Long fieldHandlerId, bool persistent) {
- LOG("mark as persistant : id="<<fieldHandlerId);
+ LOG("mark as persistent : id="<<fieldHandlerId);
_fieldPersistencyMap[fieldHandlerId] = persistent;
}
LOG("getFieldDouble: field "<<fieldHandler->fieldname<<" loaded from file "<<filepath);
TypeOfField type = (TypeOfField)fieldHandler->type;
int meshDimRelToMax = 0;
- MEDCouplingFieldDouble * myField = ReadField(type,
+ MCAuto<MEDCouplingFieldDouble> myField = ReadField(type,
filepath,
meshName,
meshDimRelToMax,
fieldHandler->iteration,
fieldHandler->order);
myField->setMesh(myMesh);
- _fieldDoubleMap[fieldHandler->id] = myField;
+ _fieldDoubleMap[fieldHandler->id] = myField.retn();
return myField;
}
// ===========================================================
//
static long LONG_UNDEFINED;
- static MEDDataManager_i * getInstance();
- MEDCouplingFieldDouble * getFieldDouble(const MEDCALC::FieldHandler * fieldHandler);
- MEDCALC::FieldHandler * addField(MEDCouplingFieldDouble * fieldDouble,
- long meshHandlerId=LONG_UNDEFINED);
+ MEDCALC_EXPORT static MEDDataManager_i * getInstance();
+ MEDCALC_EXPORT MEDCouplingFieldDouble * getFieldDouble(const MEDCALC::FieldHandler * fieldHandler);
+ MEDCALC_EXPORT MEDCALC::FieldHandler * addField(MEDCouplingFieldDouble * fieldDouble,
+ long meshHandlerId=LONG_UNDEFINED);
private:
MEDDataManager_i();
_fieldName = fieldHandler->fieldname;
_mcFieldType = (MEDCoupling::TypeOfField) fieldHandler->type;
_pvFieldType = getPVFieldTypeString(_mcFieldType);
- _colorByType = _pvFieldType; // by default the same; overriden in DeflectionShape, VectorField, PointSprite and Contour
+ _colorByType = _pvFieldType; // by default the same; overridden in DeflectionShape, VectorField, PointSprite and Contour
_meshName = meshHandler->name;
}
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();
{
public:
- static MEDPresentationManager_i* getInstance();
+ MEDCALC_EXPORT static MEDPresentationManager_i* getInstance();
MEDCALC_EXPORT MEDPresentation::TypeID makeMeshView(const MEDCALC::MeshViewParameters&, const MEDCALC::ViewModeType);
MEDCALC_EXPORT MEDPresentation::TypeID makeScalarMap(const MEDCALC::ScalarMapParameters&, const MEDCALC::ViewModeType);
selectColorMap();
rescaleTransferFunction();
resetCameraAndRender();
+ pushAndExecPyLine(_dispVar+".SetRepresentationType('Surface')");
}
void
#
# This file is a set of basic use case to test (from the python
-# context) the functions developped in the MEDCALC engine and the
+# context) the functions developed in the MEDCALC engine and the
# associated MEDCALC CORBA interface (MEDDataManager and
# MEDCalaculator).
#
# This is not the main CORBA component of the SALOME module MED
# (i.e. the engine associated to the study), but the CORBA
# entry point for MED fields operations (i.e. a CORBA component
-# reachable throught the LifeCycleCORBA). This entry point is used to
+# reachable throughout the LifeCycleCORBA). This entry point is used to
# get the other SALOME CORBA components required for MED field
# operations, in particular the dataManager and the calculator
//{
// return _eventLoopStarted;
//}
+
+int
+MEDModule::getIntParamFromStudyEditor(SALOMEDS::SObject_var obj, const char* name)
+{
+ if (obj->_is_nil())
+ return -1;
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeParameter_var aParam;
+ if ( obj->FindAttribute(anAttr,"AttributeParameter") ) {
+ aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
+ if (aParam->IsSet(name, PT_INTEGER))
+ return aParam->GetInt(name);
+ }
+ return -1;
+}
inline SALOME_AppStudyEditor* getStudyEditor() { return _studyEditor; }
void requestSALOMETermination() const;
- bool itemClickGeneric(std::string & name, std::string & type, int & presId) const;
+ bool itemClickGeneric(std::string& name, std::string& type, int& presId) const;
+
+ int getIntParamFromStudyEditor(SALOMEDS::SObject_var obj, const char* name);
signals:
void presentationSelected(int presId, const QString& presType, const QString& presName);
delete((*it).second);
}
-int
-PresentationController::getIntParamFromStudyEditor(SALOMEDS::SObject_var obj, const char * name)
-{
- if (obj->_is_nil())
- return -1;
-
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeParameter_var aParam;
- if ( obj->FindAttribute(anAttr,"AttributeParameter") ) {
- aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- if (aParam->IsSet(name, PT_INTEGER))
- return aParam->GetInt(name);
- }
- return -1;
-}
-
std::string
PresentationController::_getIconName(const std::string& name)
{
if (soObj->_is_nil() || name == "MEDCalc")
return;
- int fieldId = getIntParamFromStudyEditor(soObj, FIELD_ID);
- int meshId = getIntParamFromStudyEditor(soObj, MESH_ID);
+ int fieldId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_ID);
+ int meshId = _salomeModule->getIntParamFromStudyEditor(soObj, MESH_ID);
MEDCALC::FieldHandler* fieldHandler = 0;
MEDCALC::MeshHandler* meshHandler = 0;
}
else
{
- if (fieldId < 0) // is it a field serie ?
+ if (fieldId < 0) // is it a field series?
{
- int fieldSeriesId = getIntParamFromStudyEditor(soObj, FIELD_SERIES_ID);
+ int fieldSeriesId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_SERIES_ID);
// If fieldId and fieldSeriesId equals -1, then it means that it is not a field
// managed by the MED module, and we stop this function process.
if ( fieldSeriesId < 0)
std::string name(_studyEditor->getName(soPres));
if (soPres->_is_nil() || name == "MEDCalc")
return;
- int presId = getIntParamFromStudyEditor(soPres,PRESENTATION_ID);
+ int presId = _salomeModule->getIntParamFromStudyEditor(soPres,PRESENTATION_ID);
// If fieldId equals -1, then it means that it is not a field
// managed by the MED module, and we stop this function process.
if ( presId < 0 )
std::string name(_studyEditor->getName(soPres));
if (soPres->_is_nil() || name == "MEDCalc")
return;
- int presId = getIntParamFromStudyEditor(soPres,PRESENTATION_ID);
+ int presId = _salomeModule->getIntParamFromStudyEditor(soPres,PRESENTATION_ID);
// If fieldId equals -1, then it means that it is not a field
// managed by the MED module, and we stop this function process.
if ( presId < 0 )
MEDWidgetHelper * findOrCreateWidgetHelper(MEDCALC::MEDPresentationManager_ptr presManager,
int presId, const std::string& type, const std::string& name);
- int getIntParamFromStudyEditor(SALOMEDS::SObject_var obj, const char * name);
-
QString getViewModePython() const;
QString getColorMapPython() const;
QString getScalarBarRangePython() const;
// item must be selected.
SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
if ( listOfSObject->size() > 0 ) {
- SALOMEDS::SObject_var soField = listOfSObject->at(0);
- std::string name(_studyEditor->getName(soField));
- if (soField->_is_nil() || name == "MEDCalc")
+ SALOMEDS::SObject_var soObj = listOfSObject->at(0);
+ std::string name(_studyEditor->getName(soObj));
+ if (soObj->_is_nil() || name == "MEDCalc")
return;
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeParameter_var aParam;
- if ( soField->FindAttribute(anAttr,"AttributeParameter") ) {
- aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- if (! aParam->IsSet(FIELD_SERIES_ID, PT_INTEGER))
+
+ int fieldId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_ID);
+ if (fieldId < 0) { // is it a field series?
+ int fieldSeriesId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_SERIES_ID);
+ // If fieldId and fieldSeriesId equals -1, then it means that it is not a field
+ // managed by the MED module, and we stop this function process.
+ if ( fieldSeriesId < 0)
+ return;
+ MEDCALC::FieldHandlerList* fieldHandlerList = MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldSeriesId);
+ if (fieldHandlerList->length() < 0)
+ return;
+ // For a field series, get the first real field entry:
+ MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[0];
+ fieldId = fieldHandler.id;
+ if (fieldId < 0)
return;
}
- int fieldId = aParam->GetInt(FIELD_SERIES_ID);
+
// _GBO_ : the dialog should not be modal, so that we can choose a
// mesh in the browser. Then we have to emit a signal from the
// dialog.accept, connected to a slot of the DatasourceControler
void
ProcessingController::OnChangeUnderlyingMeshInputValidated()
{
+ STDLOG("Change Underlying Mesh");
int meshId = _dlgChangeUnderlyingMesh->getMeshId();
STDLOG("meshId = " << ToString(meshId));
int fieldId = _dlgChangeUnderlyingMesh->getFieldId();
- MEDCALC::FieldHandler* fieldHandler =
- MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
- // We don't modify the original field but create first a duplicate
- MEDCALC::FieldHandler* duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler);
- MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId);
-
- // Request once more the duplicate to update the meta-data on this
- // client side
- duplicate = MEDFactoryClient::getDataManager()->getFieldHandler(duplicate->id);
-
- // >>>
- // WARN: the following is a temporary code for test purpose
- // Automatically add in ws
ProcessingEvent* event = new ProcessingEvent();
- event->eventtype = ProcessingEvent::EVENT_IMPORT_OBJECT;
- XmedDataObject* dataObject = new XmedDataObject();
- dataObject->setFieldHandler(*duplicate);
- event->objectdata = dataObject;
- emit processingSignal(event);
- // Note that this signal is processed by the WorkspaceController
+ event->eventtype = ProcessingEvent::EVENT_CHANGE_UNDERLYING_MESH;
+ event->fieldId = fieldId;
+ event->meshId = meshId;
+ emit processingSignal(event); // --> WorkspaceController::processProcessingEvent()
// Tag the item to prevent double import
//_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
// item must be selected.
SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
if ( listOfSObject->size() > 0 ) {
- SALOMEDS::SObject_var soField = listOfSObject->at(0);
- std::string name(_studyEditor->getName(soField));
- if (soField->_is_nil() || name == "MEDCalc")
+ SALOMEDS::SObject_var soObj = listOfSObject->at(0);
+ std::string name(_studyEditor->getName(soObj));
+ if (soObj->_is_nil() || name == "MEDCalc")
return;
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeParameter_var aParam;
- if ( soField->FindAttribute(anAttr,"AttributeParameter") ) {
- aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- if (! aParam->IsSet(FIELD_SERIES_ID, PT_INTEGER))
+
+ int fieldId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_ID);
+ if (fieldId < 0) { // is it a field series?
+ int fieldSeriesId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_SERIES_ID);
+ // If fieldId and fieldSeriesId equals -1, then it means that it is not a field
+ // managed by the MED module, and we stop this function process.
+ if ( fieldSeriesId < 0)
+ return;
+ MEDCALC::FieldHandlerList* fieldHandlerList = MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldSeriesId);
+ if (fieldHandlerList->length() < 0)
+ return;
+ // For a field series, get the first real field entry:
+ MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[0];
+ fieldId = fieldHandler.id;
+ if (fieldId < 0)
return;
}
- int fieldId = aParam->GetInt(FIELD_SERIES_ID);
+
// _GBO_ : the dialog should not be modal, so that we can choose a
// mesh in the browser. Then we have to emit a signal from the
// dialog.accept, connected to a slot of the DatasourceControler
void
ProcessingController::OnInterpolateFieldInputValidated()
{
+ STDLOG("Interpolate Field");
MEDCALC::InterpolationParameters params;
params.precision = _dlgInterpolateField->getPrecision();
STDLOG("precision = " << params.precision);
int meshId = _dlgInterpolateField->getMeshId();
STDLOG("meshId = " << ToString(meshId));
int fieldId = _dlgInterpolateField->getFieldId();
- MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
-
- // We don't modify the original field but create first a duplicate
- // MEDCALC::FieldHandler* duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler);
- //MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId);
- MEDCALC::FieldHandler* result = NULL;
- try {
- result = MEDFactoryClient::getDataManager()->interpolateField(fieldId, meshId, params);
- }
- catch(...) {
- STDLOG("Unable to process field interpolation; please check interpolation parameters");
- QMessageBox::critical(_salomeModule->getApp()->desktop(),
- tr("Operation failed"),
- tr("Unable to process field interpolation; please check interpolation parameters"));
- return;
- }
-
- // Request once more the duplicate to update the meta-data on this
- // client side
- // duplicate = MEDFactoryClient::getDataManager()->getFieldHandler(duplicate->id);
- // >>>
- // WARN: the following is a temporary code for test purpose
- // Automatically add in ws
ProcessingEvent* event = new ProcessingEvent();
- event->eventtype = ProcessingEvent::EVENT_IMPORT_OBJECT;
- XmedDataObject* dataObject = new XmedDataObject();
- dataObject->setFieldHandler(*result);
- event->objectdata = dataObject;
- emit processingSignal(event);
- // Note that this signal is processed by the WorkspaceController
+ event->eventtype = ProcessingEvent::EVENT_INTERPOLATE_FIELD;
+ event->fieldId = fieldId;
+ event->meshId = meshId;
+ event->interpParams = params;
+ emit processingSignal(event); // --> WorkspaceController::processProcessingEvent()
// // Tag the item to prevent double import
// //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
typedef struct {
enum EventType {
EVENT_IMPORT_OBJECT,
- EVENT_PROCESS_INTERPOLATE_FIELD,
- EVENT_PROCESS_CHANGE_UNDERLYING_MESH
+ EVENT_INTERPOLATE_FIELD,
+ EVENT_CHANGE_UNDERLYING_MESH
};
int eventtype;
- XmedDataObject* objectdata;
+ int fieldId;
+ int meshId;
+ MEDCALC::InterpolationParameters interpParams;
} ProcessingEvent;
class MEDModule;
#include <QTimer>
#include <QMessageBox>
+#include "MEDLoader.hxx"
+using namespace MEDCoupling;
+#include "MEDDataManager_i.hxx"
+
/*!
* This class defines a DockWidget plugged in the SALOME application,
* and containing a tree view for rendering a hierarchical data
else if ( event->type == MEDCALC::EVENT_MODIFY_PRESENTATION ) {
emit workspaceSignal(event); // forward to PresentationController
}
+ else if ( event->type == MEDCALC::EVENT_CHANGE_UNDERLYING_MESH
+ || event->type == MEDCALC::EVENT_INTERPOLATE_FIELD ) {
+ int fieldId = event->dataId;
+ MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
+ XmedDataObject* dataObject = new XmedDataObject();
+ dataObject->setFieldHandler(*fieldHandler);
+ std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
+ STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
+ // _GBO_ QUESTION: tag automatically the object as a peristant object ??
+ // We first add the data object to the internal data model
+ dataModel->addDataObject(dataObject);
+ // Then we request the tree view to consider this new object
+ this->getDataTreeModel()->addData(dataObject);
+
+ // Workaround to visualize the result
+ MEDCouplingFieldDouble* fieldDouble = MEDDataManager_i::getInstance()->getFieldDouble(fieldHandler);
+ std::string filename = std::tmpnam(NULL);
+ WriteField(filename.c_str(), fieldDouble, true);
+
+ QStringList commands;
+ commands += QString("source_id = medcalc.LoadDataSource('%1')").arg(filename.c_str());
+ commands += QString("source_id");
+ commands += QString("mesh_id = medcalc.GetFirstMeshFromDataSource(source_id)");
+ commands += QString("mesh_id");
+ commands += QString("field_id = medcalc.GetFirstFieldFromMesh(mesh_id)");
+ commands += QString("field_id");
+ commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(field_id), viewMode=MEDCALC.VIEW_MODE_NEW_LAYOUT)");
+ commands += QString("presentation_id");
+ _consoleDriver->exec(commands);
+ }
else if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
emit workspaceSignal(event); // forward to TestController
}
return;
}
- // >>>
- // __GBO__ To know what to do we should test the type, because the
- // object could be a mesh, a timeseries or a single field. We test
- // here the case of a single field. Moreover, there could have
- // options such that "change the underlying mesh".
- // <<<
+ int fieldId = event->fieldId;
+ int meshId = event->meshId;
- XmedDataObject* dataObject = event->objectdata;
+ if ( event->eventtype == ProcessingEvent::EVENT_CHANGE_UNDERLYING_MESH ) {
+ QStringList commands;
+ commands += QString("result_id = medcalc.ChangeUnderlyingMesh(fieldId=%1,meshId=%2)").arg(fieldId).arg(meshId);
+ commands += QString("result_id");
+ _consoleDriver->exec(commands);
+ }
+ else if ( event->eventtype == ProcessingEvent::EVENT_INTERPOLATE_FIELD ) {
+ MEDCALC::InterpolationParameters params = event->interpParams;
+ QString method = QString(params.method);
+ QString nature = QString(params.nature);
+ QString intersectionType = QString(params.intersectionType);
- if ( event->eventtype == ProcessingEvent::EVENT_IMPORT_OBJECT ) {
- std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
- STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
- // _GBO_ QUESTION: tag automatically the object as a peristant object ??
- // We first add the data object to the internal data model
- dataModel->addDataObject(dataObject);
- // Then we request the tree view to consider this new object
- this->getDataTreeModel()->addData(dataObject);
+ QStringList commands;
+ commands += QString("result_id = medcalc.InterpolateField(fieldId=%1,meshId=%2,precision=%3,defaultValue=%4,reverse=%5,method='%6',nature='%7',intersectionType='%8')").arg(fieldId).arg(meshId).arg(params.precision).arg(params.defaultValue).arg(params.reverse).arg(method).arg(nature).arg(intersectionType);
+ commands += QString("result_id");
+ _consoleDriver->exec(commands);
}
}
#include "MEDFactoryClient.hxx"
#include CORBA_CLIENT_HEADER(MED_Gen)
#include CORBA_CLIENT_HEADER(MEDCommandsHistoryManager)
+#include <iostream>
XmedConsoleDriver::XmedConsoleDriver(MEDModule* salomeModule)
{
else
{
_ui.widgetDynamic->show();
- // It is the WidgetHelper responsability to re-show the widgets it needs
+ // It is the WidgetHelper responsibility to re-show the widgets it needs
_ui.labelCompo->hide();
_ui.comboBoxCompo->hide();
_ui.labelMeshMode->hide();
medimages.py
medio.py
medpresentation.py
+ medprocessing.py
medtest.py
)
from fieldproxy import newFieldProxy, FieldProxy
# Input/Output
-from medio import LoadDataSource, LoadImageAsDataSource, GetFirstMeshFromDataSource
+from medio import LoadDataSource
+from medio import LoadImageAsDataSource
+from medio import GetFirstMeshFromDataSource
+from medio import GetFirstFieldFromMesh
# Presentations
from medpresentation import MakeMeshView
from medpresentation import ComputeCellAverageSize, GetDomainCenter, GetSliceOrigins, SelectSourceField
+# Processing
+from medprocessing import ChangeUnderlyingMesh
+from medprocessing import InterpolateField
+
# Console commands
import medconsole
dataManager = medcalc.medcorba.factory.getDataManager()
# IMPORTANT NOTE:
-# the pyConsoleGlobals variable should hold the globals() dictionnary of
+# the pyConsoleGlobals variable should hold the globals() dictionary of
# the python console context
pyConsoleGlobals = None
#-----
# This function is to be called from the working python console to
-# specify the globals() dictionnary (used in fieldtools for stat analysis)
+# specify the globals() dictionary (used in fieldtools for stat analysis)
#
# >>> medcalc.setConsoleGlobals(globals())
#
# Try to define the event listener
connectEventListener()
if __eventListener is None:
- # it definitly does not work
+ # it definitely does not work
medcalc.wrn("the GUI is not loaded yet and will not be notified of the modification")
return False
def notifyGui_removePresentation(presId):
__notifyGui(MEDCALC.EVENT_REMOVE_PRESENTATION, presentationId=presId)
#
+def notifyGui_modifyPresentation(presId):
+ __notifyGui(MEDCALC.EVENT_MODIFY_PRESENTATION, presentationId=presId)
+
def notifyGui_playQtTestingScenario(filename):
__notifyGui(MEDCALC.EVENT_PLAY_TEST, filename=filename)
#
def notifyGui_termination():
__notifyGui(MEDCALC.EVENT_QUIT_SALOME)
-
+
def notifyGui_error(msg):
__notifyGui(MEDCALC.EVENT_ERROR, msg=msg)
-
-def notifyGui_modifyPresentation(presId):
- __notifyGui(MEDCALC.EVENT_MODIFY_PRESENTATION, presentationId=presId)
+
+def notifyGui_changeUnderlyingMesh(fieldId):
+ __notifyGui(MEDCALC.EVENT_CHANGE_UNDERLYING_MESH, dataId=fieldId)
+
+def notifyGui_interpolateField(fieldId):
+ __notifyGui(MEDCALC.EVENT_INTERPOLATE_FIELD, dataId=fieldId)
# Load the image file in a numpy array using PIL.
img=Image.open(imageFilepath)
imgbw=ImageOps.grayscale(img)
- # WARN: We keep only the grayscale. Maybe, it could be usefull
+ # WARN: We keep only the grayscale. Maybe, it could be useful
# to get the RGB scales each on one component of the field.
# Creating a cartesian mesh with a grid of the size of the image
def createMesh(self, meshname, sizeX, sizeY):
"""
Creating a cartesian mesh with a grid of the size of the image.
- sizeX and sizeY should be respectively the width and heigth of the
+ sizeX and sizeY should be respectively the width and height of the
image.
"""
# >>>
if not len(handlerLst):
return -1
return handlerLst[0].id
+#
+
+def GetFirstFieldFromMesh(mesh_id):
+ dataManager = medcalc.medcorba.factory.getDataManager()
+ series = dataManager.getFieldseriesListOnMesh(mesh_id)
+ if not len(series):
+ return -1
+ fields = dataManager.getFieldListInFieldseries(series[0].id)
+ if not len(fields):
+ return -1
+ return fields[0].id
+#
notifyGui_addPresentation(meshID, presentation_id)
return presentation_id
except SALOME.SALOME_Exception as e:
- notifyGui_error("An error occured while creating the mesh view:\n" + e.details.text)
+ notifyGui_error("An error occurred while creating the mesh view:\n" + e.details.text)
raise Exception(e.details.text)
notifyGui_addPresentation(proxy.id, presentation_id)
return presentation_id
except SALOME.SALOME_Exception as e:
- notifyGui_error("An error occured while creating the scalar map:\n" + e.details.text)
+ notifyGui_error("An error occurred while creating the scalar map:\n" + e.details.text)
raise Exception(e.details.text)
def MakeContour(proxy,
notifyGui_addPresentation(proxy.id, presentation_id)
return presentation_id
except SALOME.SALOME_Exception as e:
- notifyGui_error("An error occured while creating the contour:\n" + e.details.text)
+ notifyGui_error("An error occurred while creating the contour:\n" + e.details.text)
raise Exception(e.details.text)
#
notifyGui_addPresentation(proxy.id, presentation_id)
return presentation_id
except SALOME.SALOME_Exception as e:
- notifyGui_error("An error occured while creating the vector field:\n" + e.details.text)
+ notifyGui_error("An error occurred while creating the vector field:\n" + e.details.text)
raise Exception(e.details.text)
def MakeSlices(proxy,
notifyGui_addPresentation(proxy.id, presentation_id)
return presentation_id
except SALOME.SALOME_Exception as e:
- notifyGui_error("An error occured while creating the slices:\n" + e.details.text)
+ notifyGui_error("An error occurred while creating the slices:\n" + e.details.text)
raise Exception(e.details.text)
notifyGui_addPresentation(proxy.id, presentation_id)
return presentation_id
except SALOME.SALOME_Exception as e:
- notifyGui_error("An error occured while creating the deflection shape:\n" + e.details.text)
+ notifyGui_error("An error occurred while creating the deflection shape:\n" + e.details.text)
raise Exception(e.details.text)
notifyGui_addPresentation(proxy.id, presentation_id)
return presentation_id
except SALOME.SALOME_Exception as e:
- notifyGui_error("An error occured while creating the point sprite:\n" + e.details.text)
+ notifyGui_error("An error occurred while creating the point sprite:\n" + e.details.text)
raise Exception(e.details.text)
def RemovePresentation(presentation_id):
--- /dev/null
+# Copyright (C) 2011-2016 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import medcalc
+import MEDCALC
+import SALOME
+from medcalc.medevents import notifyGui_error
+
+
+def ChangeUnderlyingMesh(fieldId, meshId):
+ try:
+ dataManager = medcalc.medcorba.factory.getDataManager()
+ fieldHandler = dataManager.getFieldHandler(fieldId)
+
+ # We don't modify the original field but create first a duplicate
+ duplicate = medcalc.medcorba.factory.getCalculator().dup(fieldHandler)
+ dataManager.changeUnderlyingMesh(duplicate.id, meshId)
+
+ from medcalc.medevents import notifyGui_changeUnderlyingMesh
+ notifyGui_changeUnderlyingMesh(duplicate.id)
+ return duplicate.id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occurred while changing underlying mesh:\n" + e.details.text)
+ raise Exception(e.details.text)
+#
+
+def InterpolateField(fieldId,
+ meshId,
+ precision,
+ defaultValue,
+ reverse,
+ method,
+ nature,
+ intersectionType
+ ):
+ params = MEDCALC.InterpolationParameters(precision, defaultValue, reverse, method, nature, intersectionType)
+ try:
+ dataManager = medcalc.medcorba.factory.getDataManager()
+ fieldHandler = dataManager.interpolateField(fieldId, meshId, params)
+ from medcalc.medevents import notifyGui_interpolateField
+ notifyGui_interpolateField(fieldHandler.id)
+ return fieldHandler.id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occurred while interpolating field:\n" + e.details.text)
+ raise Exception(e.details.text)
+#
if(types.empty())
throw INTERP_KERNEL::Exception("MEDCalculatorBrowserField::MEDCalculatorBrowserField : the file is not loadable using MED File 3 API ! Problably presence of field on edges faces...");
_type=types[0];//To improve
- MEDCouplingFieldDouble *tmpf=0;
+ MCAuto<MEDCouplingFieldDouble> tmpf;
try
{
tmpf=ReadField(_type,fname,meshNames[0].c_str(),0,fieldName,dtits[0].first.first,dtits[0].first.second);
c="-noname-";
_components.push_back(c);
}
- tmpf->decrRef();
_corresponding_meshes=GetMeshNamesOnField(fname,fieldName);
}
return _name;
}
-// Return if the mesh name is equal to input or not, usefull for std::find for example
+// Return if the mesh name is equal to input or not, useful for std::find for example
bool MEDCalculatorBrowserMesh::operator==(const std::string& nm)
{
return _name==nm;
// str method
// Construct a std::string to print this time step, using std::cout for example
// Put x or o for selected or not
-// Add time step id value ( tiem value )
+// Add time step id value ( time value )
// Return a std::string
std::string MEDCalculatorBrowserStep::str()
{
return ret;
}
else
- throw INTERP_KERNEL::Exception("FieldReal::operator+ : unrecognized type of parameter recieved !");
+ throw INTERP_KERNEL::Exception("FieldReal::operator+ : unrecognized type of parameter received !");
}
}
return ret;
}
else
- throw INTERP_KERNEL::Exception("FieldReal::isEqual : unrecognized type of parameter recieved !");
+ throw INTERP_KERNEL::Exception("FieldReal::isEqual : unrecognized type of parameter received !");
}
}
return ret;
}
else
- throw INTERP_KERNEL::Exception("FieldReal::operator- : unrecognized type of parameter recieved !");
+ throw INTERP_KERNEL::Exception("FieldReal::operator- : unrecognized type of parameter received !");
}
}
return ret;
}
else
- throw INTERP_KERNEL::Exception("FieldReal::operator* : unrecognized type of parameter recieved !");
+ throw INTERP_KERNEL::Exception("FieldReal::operator* : unrecognized type of parameter received !");
}
}
return ret;
}
else
- throw INTERP_KERNEL::Exception("FieldReal::operator/ : unrecognized type of parameter recieved !");
+ throw INTERP_KERNEL::Exception("FieldReal::operator/ : unrecognized type of parameter received !");
}
}
return ret;
}
else
- throw INTERP_KERNEL::Exception("FieldCst::operator+ : unrecognized type of parameter recieved !");
+ throw INTERP_KERNEL::Exception("FieldCst::operator+ : unrecognized type of parameter received !");
}
}
return ret;
}
else
- throw INTERP_KERNEL::Exception("FieldCst::operator- : unrecognized type of parameter recieved !");
+ throw INTERP_KERNEL::Exception("FieldCst::operator- : unrecognized type of parameter received !");
}
}
return ret;
}
else
- throw INTERP_KERNEL::Exception("FieldCst::operator* : unrecognized type of parameter recieved !");
+ throw INTERP_KERNEL::Exception("FieldCst::operator* : unrecognized type of parameter received !");
}
}
return ret;
}
else
- throw INTERP_KERNEL::Exception("FieldCst::operator/ : unrecognized type of parameter recieved !");
+ throw INTERP_KERNEL::Exception("FieldCst::operator/ : unrecognized type of parameter received !");
}
}
return ret;
}
else
- throw INTERP_KERNEL::Exception("FieldCst::isEqual : unrecognized type of parameter recieved !");
+ throw INTERP_KERNEL::Exception("FieldCst::isEqual : unrecognized type of parameter received !");
}
}
MEDCouplingFieldDouble *MEDCalculatorDBSliceField::getField(TypeOfField type, const std::string& fname, const std::string& mname, const std::string& fieldName) const
{
if(!_field)
- _field=ReadField(type,fname.c_str(),mname.c_str(),0,fieldName.c_str(),_iteration,_order);
+ {
+ MCAuto<MEDCouplingFieldDouble> tmp(ReadField(type,fname.c_str(),mname.c_str(),0,fieldName.c_str(),_iteration,_order));
+ _field=tmp.retn();
+ }
return _field;
}
#define __MEDCALCULATORDBSLICEFIELD_HXX__
#include "MedCalculatorDefines.hxx"
+#include "MCType.hxx"
#include "MEDCouplingRefCountObject.hxx"
#include "InterpKernelException.hxx"
def MEDCouplingFieldDoubleIpow(self,*args):
import _MEDCalculator
return _MEDCalculator.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def MEDCouplingDataArrayBytenew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.DataArrayByte____new___(cls,args)
def MEDCouplingDataArrayIntnew(cls,*args):
import _MEDCalculator
return _MEDCalculator.DataArrayInt____new___(cls,args)
return true;
}
std::size_t pos5=s.find_first_not_of(NUMBERS,pos4,10);
- if(pos5==pos4)//an another caracter found after : !
+ if(pos5==pos4)//an another character found after : !
return false;
std::string elt2;
if(pos5==std::string::npos)
ret << elt2;
result=ret.str();
std::size_t pos6=s.find_first_not_of(' ',pos5);
- if(pos6==pos5)//an another caracter found after 2nd elt !
+ if(pos6==pos5)//an another character found after 2nd elt !
return false;
return pos6==std::string::npos;
}
#endif
#include CORBA_SERVER_HEADER(MEDCouplingCorbaServant)
#include "MEDCouplingClient.hxx"
+#include "MCType.hxx"
namespace MEDCoupling
{
{
meshPtr->Register();
//1st call to getTinyInfo to get tiny array of key integers value
- //to corectly resize local copy of distant instance adressed by 'meshPtr'
+ //to corectly resize local copy of distant instance addressed by 'meshPtr'
//1st value of returned array is the type of instance. Thanks to
//CORBA and its type-check no use of this value is necessary.
SALOME_TYPES::ListOfDouble *tinyD;
#include CORBA_SERVER_HEADER(MEDCouplingCorbaServant)
#include "MEDCouplingCorba.hxx"
#include "DataArrayServant.hxx"
+#include "MCType.hxx"
namespace MEDCoupling
{
#ifndef __MEDCOUPLINGCORBAFIELDFACTORYCOMPONENT_HXX__
#define __MEDCOUPLINGCORBAFIELDFACTORYCOMPONENT_HXX__
+#include "MCType.hxx"
+
#include <string>
namespace MEDCoupling
def MEDCouplingDataArrayIntIpow(self,*args):
import _MEDCouplingClient
return _MEDCouplingClient.DataArrayInt____ipow___(self, self, *args)
+def MEDCouplingDataArrayBytenew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.DataArrayByte____new___(cls,args)
def MEDCouplingDataArrayDoubleTupleIadd(self,*args):
import _MEDCouplingClient
return _MEDCouplingClient.DataArrayDoubleTuple____iadd___(self, self, *args)
def MEDCouplingDataArrayIntIpow(self,*args):
import _MEDCouplingCorba
return _MEDCouplingCorba.DataArrayInt____ipow___(self, self, *args)
+def MEDCouplingDataArrayBytenew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.DataArrayByte____new___(cls,args)
def MEDCouplingDataArrayDoubleTupleIadd(self,*args):
import _MEDCouplingCorba
return _MEDCouplingCorba.DataArrayDoubleTuple____iadd___(self, self, *args)
public slots:
void openFile();// Create a new MedGUI_LiteStruct from a file and add content to QTreeWidgets
void meshesStateChange(QTreeWidgetItem*, int);// Change the select statement of one or more meshes, the item represents a mesh or a file
- void fieldsStateChange(QTreeWidgetItem*, int);// Change tje select statement of one or more fields, the item represents a mesh or a field or a step
+ void fieldsStateChange(QTreeWidgetItem*, int);// Change the select statement of one or more fields, the item represents a mesh or a field or a step
void fieldsStateChanges();
void sendSelectionToDB();
void unselectAll();// Unselec all fields and meshes