Exemple #1
0
def Extract_MED_data_over_line_to_csv_file(inputFileName, outputFileName,
                                           point1, point2, resolution):
    pvs._DisableFirstRenderCameraReset()
    data_vtu = MEDReader.Reader(FileName=[inputFileName])
    PlotOverLine1 = pvs.PlotOverLine(Source="High Resolution Line Source")
    PlotOverLine1.Source.Point1 = point1
    PlotOverLine1.Source.Point2 = point2
    PlotOverLine1.Source.Resolution = resolution
    writer = pvs.CreateWriter(outputFileName, PlotOverLine1)
    writer.FieldAssociation = "Cells"  # or "Points" (default in cdmath is finite volumes)
    writer.UpdatePipeline()
Exemple #2
0
def Slice_MED_data_over_line_to_csv_file(inputFileName, outputFileName, point,
                                         normal):
    pvs._DisableFirstRenderCameraReset()
    data_vtu = MEDReader.Reader(FileName=[inputFileName])
    Slice1 = pvs.Slice(SliceType="Plane")
    Slice1.SliceOffsetValues = [0.0]
    Slice1.SliceType.Origin = point
    Slice1.SliceType.Normal = normal
    CellCenters1 = pvs.CellCenters()
    writer = pvs.CreateWriter(outputFileName, CellCenters1)
    writer.Precision = 30
    writer.FieldAssociation = "Cells"  # or "Points" (default in cdmath is finite volumes)
    writer.UpdatePipeline()
Exemple #3
0
def Slice_MED_data_over_line_to_numpyArray(inputFileName, point, normal):
    pvs._DisableFirstRenderCameraReset()
    data_vtu = MEDReader.Reader(FileName=[inputFileName])
    Slice1 = pvs.Slice(SliceType="Plane")
    Slice1.SliceOffsetValues = [0.0]
    Slice1.SliceType.Origin = point
    Slice1.SliceType.Normal = normal
    CellCenters1 = pvs.CellCenters()

    vtkarray = Slice1.GetCellData(
    )  # or PlotOverLine1.GetCellData() # or Clip1.GetCellData()
    numpy_array = npvtk.vtk_to_numpy(vtkarray)

    return numpy_array
Exemple #4
0
def Extract_MED_data_over_line_to_numpyArray(inputFileName, point1, point2,
                                             resolution):
    pvs._DisableFirstRenderCameraReset()
    data_vtu = MEDReader.Reader(FileName=[inputFileName])
    PlotOverLine1 = pvs.PlotOverLine(Source="High Resolution Line Source")
    PlotOverLine1.Source.Point1 = point1
    PlotOverLine1.Source.Point2 = point2
    PlotOverLine1.Source.Resolution = resolution

    vtkarray = PlotOverLine1.GetCellData(
    )  # or Slice1.GetCellData() # or Clip1.GetCellData()
    numpy_array = npvtk.vtk_to_numpy(vtkarray)

    return numpy_array
# fill list ParaView_1
ipar.append("ParaView_1", "ParaView scene:7 - viewer:1")
ipar.append("ParaView_1", "empty")
# fill list AP_MODULES_LIST
ipar.append("AP_MODULES_LIST", "ParaViS")

###
### PARAVIS component
###

import pvsimple
pvsimple.ShowParaviewView()
#### import the simple module from the paraview
from pvsimple import *
#### disable automatic camera reset on 'Show'
pvsimple._DisableFirstRenderCameraReset()

# create a new 'MED Reader'
mesh1med = MEDReader(FileName=medfile)

# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [897, 531]

# show data in view
mesh1medDisplay = Show(mesh1med, renderView1)

# reset view to fit data
renderView1.ResetCamera()
Exemple #6
0
try: pvsimple
except:
  import pvsimple
  from pvsimple import *
pvsimple._DisableFirstRenderCameraReset()

dir='/home/fred/asteretude/kenyatta/resultat/resultatcubepoutre/vmis/'
i=1
filein=dir+'CHRCUM%D.med'%i
fileout=dir+'CHRCUM%D.png'%i
CHRCURM1_med = MEDReader( FileName=file)

AnimationScene1 = GetAnimationScene()
CHRCURM1_med.Frequencies = ['[0] -1', '[1] 4.94066e-324']
CHRCURM1_med.Groups = ['GROUP/MAIL/OnCell/base', 'GROUP/MAIL/OnCell/toutface', 'GROUP/MAIL/OnCell/tout', 'GROUP/MAIL/OnCell/forc', 'GROUP/MAIL/OnCell/No_Group']
CHRCURM1_med.PointArrays = ['CHRATIO']

AnimationScene1.EndTime = 4.9406564584124654e-324
AnimationScene1.PlayMode = 'Snap To TimeSteps'
AnimationScene1.StartTime = -1.0

CHRCURM1_med.Entity = ['CELL_TYPE/MED_CELL/MED_HEXA8']

RenderView1 = GetRenderView()
a1_CHRATIO_PVLookupTable = GetLookupTableForArray( "CHRATIO", 1, NanColor=[0.25, 0.0, 0.0], RGBPoints=[1.0, 0.23000000000000001, 0.29899999999999999, 0.754, 1.0, 0.70599999999999996, 0.016, 0.14999999999999999], VectorMode='Magnitude', ColorSpace='Diverging', ScalarRangeInitialized=1.0 )

a1_CHRATIO_PiecewiseFunction = CreatePiecewiseFunction()

DataRepresentation1 = Show()
DataRepresentation1.ConstantRadius = 0.44785425863863337
DataRepresentation1.EdgeColor = [0.0, 0.0, 0.50000762951094835]
def make_a_screenshot(path_to_insert):
    import pvsimple
    pvsimple.ShowParaviewView()
    #### import the simple module from the paraview
    from pvsimple import *
    #### disable automatic camera reset on 'Show'
    pvsimple._DisableFirstRenderCameraReset()

    # create a new 'MED Reader'
    home_dir = os.path.expanduser("~")
    mesh_unrefmed = MEDReader(FileName=home_dir + path_to_insert +
                              '/Meshes/Mesh_unref.med')

    # get active view
    renderView1 = GetActiveViewOrCreate('RenderView')
    # uncomment following to set a specific view size
    # renderView1.ViewSize = [1470, 639]

    # show data in view
    mesh_unrefmedDisplay = Show(mesh_unrefmed, renderView1)

    # reset view to fit data
    renderView1.ResetCamera()

    # create a new 'CSV Reader'
    vert_of_Neural_model_NEURONcsv = CSVReader(FileName=[
        home_dir + path_to_insert +
        '/Neuron_model_arrays/Vert_of_Neural_model_NEURON.csv'
    ])

    # Properties modified on vert_of_Neural_model_NEURONcsv
    vert_of_Neural_model_NEURONcsv.HaveHeaders = 0
    vert_of_Neural_model_NEURONcsv.FieldDelimiterCharacters = ' '

    # Create a new 'SpreadSheet View'
    spreadSheetView1 = CreateView('SpreadSheetView')
    spreadSheetView1.ColumnToSort = ''
    spreadSheetView1.BlockSize = 1024
    # uncomment following to set a specific view size
    # spreadSheetView1.ViewSize = [400, 400]

    # get layout
    layout1 = GetLayout()

    # place view in the layout
    layout1.AssignView(2, spreadSheetView1)

    # show data in view
    vert_of_Neural_model_NEURONcsvDisplay = Show(
        vert_of_Neural_model_NEURONcsv, spreadSheetView1)

    # create a new 'Table To Points'
    tableToPoints1 = TableToPoints(Input=vert_of_Neural_model_NEURONcsv)

    # Properties modified on tableToPoints1
    tableToPoints1.YColumn = 'Field 1'
    tableToPoints1.ZColumn = 'Field 2'

    # show data in view
    tableToPoints1Display = Show(tableToPoints1, spreadSheetView1)

    # hide data in view
    Hide(vert_of_Neural_model_NEURONcsv, spreadSheetView1)

    # set active view
    SetActiveView(renderView1)

    # set active source
    SetActiveSource(tableToPoints1)

    # show data in view
    tableToPoints1Display_1 = Show(tableToPoints1, renderView1)

    # hide data in view
    Hide(mesh_unrefmed, renderView1)

    # set active source
    SetActiveSource(mesh_unrefmed)

    # show data in view
    mesh_unrefmedDisplay = Show(mesh_unrefmed, renderView1)

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.98

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.8

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.78

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.75

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.64

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.63

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.48

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.36

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.35

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.25

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.23

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.22

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.21

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.22

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.24

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.25

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.26

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.27

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.26

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.25

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.24

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.23

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.22

    # Properties modified on mesh_unrefmedDisplay
    mesh_unrefmedDisplay.Opacity = 0.21

    # set active source
    SetActiveSource(tableToPoints1)

    # change solid color
    tableToPoints1Display_1.DiffuseColor = [
        0.00392156862745098, 1.0, 0.00392156862745098
    ]

    #### saving camera placements for all active views

    # current camera placement for renderView1
    renderView1.CameraPosition = [
        -11.97298107774897, 3.0091410210384057, 9.63659807262625
    ]
    renderView1.CameraFocalPoint = [
        1.024347367682281, 1.1129612638758126, 1.0326026334725262
    ]
    renderView1.CameraViewUp = [
        0.5421585701688229, -0.07947879959151795, 0.8365089391082374
    ]
    renderView1.CameraParallelScale = 7.199611409666049

    renderView1.ResetCamera()
    # save screenshot
    renderView1.ViewSize = [1600, 1000]
    renderView1.ResetCamera()
    SaveScreenshot(home_dir + path_to_insert +
                   '/Images/InitMesh_and_Neurons.png',
                   magnification=1,
                   quality=100,
                   view=renderView1)

    #if salome.sg.hasDesktop():
    #  salome.sg.updateObjBrowser(True)

    import killSalome
    killSalome.killAllPorts()