X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCalc%2Ftui%2Fmedimages.py;h=00efb0e73cfa5be5244fdad245e0b0a4ebeadd89;hb=c933321e259af4968b2469c1d4f6b7ac5178e294;hp=49be53a5e7263a3d9b77090a2bf4208e6b0fff2a;hpb=682bfb07cec46a60ed230d40826088957500a22b;p=modules%2Fmed.git diff --git a/src/MEDCalc/tui/medimages.py b/src/MEDCalc/tui/medimages.py index 49be53a5e..00efb0e73 100644 --- a/src/MEDCalc/tui/medimages.py +++ b/src/MEDCalc/tui/medimages.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2016 CEA/DEN, EDF R&D +# Copyright (C) 2007-2024 CEA, EDF # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -20,7 +20,12 @@ # Author : Guillaume Boulant (EDF) -import MEDCoupling as MC +import sys +if sys.platform == "win32": + import MEDCouplingCompat as MC +else: + import medcoupling as MC + import MEDLoader as ML from PIL import Image @@ -34,7 +39,7 @@ class FieldBuilder: # 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 @@ -48,12 +53,12 @@ class FieldBuilder: # just have to specify the field and the MEDLoader will save the # underlying mesh. createFromScratch=True - ML.MEDLoader.WriteField(medFilepath,field,createFromScratch) + ML.WriteField(medFilepath,field,createFromScratch) 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. """ # >>> @@ -83,10 +88,10 @@ class FieldBuilder: coordsY.setValues(arrY,nbNodesY,1) cmesh.setCoords(coordsX,coordsY) - print "Imagem mesh dimension: %d"%cmesh.getSpaceDimension() + print("Imagem mesh dimension: %d"%cmesh.getSpaceDimension()) # WARN: In the current state of development of MEDLoader, only - # unstructured meshes are supported for writting function in med + # unstructured meshes are supported for writing function in med # files. We just have to convert the cartesian mesh in an unstructured # mesh before creating the field. umesh=cmesh.buildUnstructured(); @@ -125,8 +130,8 @@ class FieldBuilder: def getTestImagePath(): import os - MED_ROOT_DIR=os.environ["MED_ROOT_DIR"] - RESDIR=os.path.join(MED_ROOT_DIR, "share", "salome", "resources", "med", "medcalc_testfiles") + FIELDS_ROOT_DIR=os.environ["FIELDS_ROOT_DIR"] + RESDIR=os.path.join(FIELDS_ROOT_DIR, "share", "salome", "resources", "fields", "medcalc_testfiles") imgFileName="irm_test1.png" imgFilePath=os.path.join(RESDIR,imgFileName) return imgFilePath