コード例 #1
0
def adjustCamera(view, renderView1, metrichash):
    camera = GetActiveCamera()
    if view.startswith("iso"):
        camera.SetFocalPoint(0, 0, 0)
        if (view == "iso-flipped"):
            camera.SetPosition(0, 1, 0)
        else:
            camera.SetPosition(0, -1, 0)
        renderView1.ResetCamera()
        # adjust for scale margin
        camera.SetFocalPoint(camera.GetFocalPoint()[0],
                             camera.GetFocalPoint()[1],
                             camera.GetFocalPoint()[2] - 0.25)
        camera.SetPosition(camera.GetPosition()[0],
                           camera.GetPosition()[1],
                           camera.GetPosition()[2] - 1)
        camera.Elevation(45)
        camera.Azimuth(45)
    elif view == "+X" or view == "+x" or view == "back":
        camera.SetFocalPoint(0, 0, 0)
        camera.SetPosition(1, 0, 0)
        renderView1.ResetCamera()
    elif view == "-X" or view == "-x" or view == "front":
        camera.SetFocalPoint(0, 0, 0)
        camera.SetPosition(-1, 0, 0)
        renderView1.ResetCamera()
    elif view == "+Y" or view == "+y" or view == "right":
        camera.SetFocalPoint(0, 0, 0)
        camera.SetPosition(0, 1, 0)
        renderView1.ResetCamera()
    elif view == "-Y" or view == "-y" or view == "left":
        camera.SetFocalPoint(0, 0, 0)
        camera.SetPosition(0, -1, 0)
        renderView1.ResetCamera()
    elif view == "+Z" or view == "+z" or view == "top":
        camera.SetFocalPoint(0, 0, 0)
        camera.SetPosition(0, 0, 1)
        renderView1.ResetCamera()
        #        camera.Roll(90)
    elif view == "-Z" or view == "-z" or view == "bottom":
        camera.SetFocalPoint(0, 0, 0)
        camera.SetPosition(0, 0, -1)
        renderView1.ResetCamera()
        #       camera.Roll(-90)
    elif view == "customize":
        renderView1.InteractionMode = '3D'
        renderView1.CameraPosition = data_IO.read_floats_from_string(
            metrichash["CameraPosition"])
        renderView1.CameraFocalPoint = data_IO.read_floats_from_string(
            metrichash["CameraFocalPoint"])
        renderView1.CameraViewUp = data_IO.read_floats_from_string(
            metrichash["CameraViewUp"])
        renderView1.CameraParallelScale = float(
            metrichash["CameraParallelScale"])
        renderView1.CameraParallelProjection = int(
            metrichash["CameraParallelProjection"])
コード例 #2
0
def read_uncoupled_step_time_from_inp(inp_file_path):
    """Read time period of UNCOUPLED TEMPERATURE-DISPLACEMENT steps from ccx input file"""

    finp = data_IO.open_file(inp_file_path)
    lines = finp.readlines()
    finp.close()

    line_num = 0
    times = []
    while line_num is not None:
        line_num = data_IO.get_index_in_str_list(
            lines, 'UNCOUPLED TEMPERATURE-DISPLACEMENT', start_from=line_num)
        if line_num is not None:
            times.append(
                data_IO.read_floats_from_string(lines[line_num + 1], ',')[1])
            line_num = line_num + 1

    return times
コード例 #3
0
def colorMetric(d, metrichash):
    display = GetDisplayProperties(d)
    kpifld = metrichash['field']
    kpifldcomp = metrichash['fieldComponent']
    ColorBy(display, ('POINTS', kpifld, kpifldcomp))

    Render()
    UpdateScalarBars()
    ctf = GetColorTransferFunction(kpifld)
    try:
        ctf.ApplyPreset(metrichash["colorscale"], True)
    except:
        pass
    try:
        if data_IO.str2bool(metrichash["invertcolor"]):
            ctf.InvertTransferFunction()
    except:
        pass

    try:
        datarange = getdatarange(d, kpifld, kpifldcomp)
        min = datarange[0]
        max = datarange[1]
        if metrichash["min"] != "auto":
            min = float(metrichash["min"])
        if metrichash["max"] != "auto":
            max = float(metrichash["max"])
        ctf.RescaleTransferFunction(min, max)
        if int(metrichash["discretecolors"]) > 0:
            ctf.Discretize = 1
            ctf.NumberOfTableValues = int(metrichash["discretecolors"])
        else:
            ctf.Discretize = 0
    except:
        pass

    renderView1 = GetActiveViewOrCreate('RenderView')
    ctfColorBar = GetScalarBar(ctf, renderView1)

    ctfColorBar.Orientation = "Horizontal"

    # Properties modified on uLUTColorBar
    if 'barTitle' in metrichash:
        ctfColorBar.Title = metrichash["barTitle"]
    if 'ComponentTitle' in metrichash:
        ctfColorBar.ComponentTitle = metrichash["ComponentTitle"]
    if 'FontColor' in metrichash:
        ctfColorBar.TitleColor = data_IO.read_floats_from_string(
            metrichash["FontColor"])
        ctfColorBar.LabelColor = data_IO.read_floats_from_string(
            metrichash["FontColor"])
    else:
        ctfColorBar.TitleColor = [0, 0, 0]
        ctfColorBar.LabelColor = [0, 0, 0]
    if 'FontSize' in metrichash:
        ctfColorBar.TitleFontSize = int(metrichash["FontSize"])
        ctfColorBar.LabelFontSize = int(metrichash["FontSize"])
    if 'LabelFormat' in metrichash:
        ctfColorBar.LabelFormat = metrichash["LabelFormat"]
        ctfColorBar.RangeLabelFormat = metrichash["LabelFormat"]

    imgtype = metrichash['image'].split("_")[0]
    PVversion = getParaviewVersion()
    if (imgtype != "iso"):
        # center
        if PVversion < 5.04:
            ctfColorBar.Position = [0.25, 0.05]
            ctfColorBar.Position2 = [0.5, 0]  # no such property in PV 5.04
        else:
            ctfColorBar.WindowLocation = 'LowerCenter'
    else:
        # left
        if PVversion < 5.04:
            ctfColorBar.Position = [0.05, 0.025]
            ctfColorBar.Position2 = [0.4, 0]  # no such property in PV 5.04
        else:
            ctfColorBar.WindowLocation = 'LowerLeftCorner'