Used in creation of mesh/submesh presentation.
"""
- ### Old API all_cell_types = proxy.CellTypes.Available
- all_cell_types = proxy.Entity.Available
- ### Old API proxy.CellTypes = all_cell_types
- proxy.Entity = all_cell_types
- proxy.UpdatePipeline()
+ extractCT = pv.ExtractCellType()
+ extractCT.AllGeoTypes = extractCT.GetProperty("GeoTypesInfo")[::2]
def select_cells_with_data(proxy, on_points=None, on_cells=None):
print "Import " + file_name.split(os.sep)[-1] + "..."
try:
- paravis_instance.ImportFile(file_name)
- proxy = pv.GetActiveSource()
+ proxy = pv.MEDReader(FileName=file_name)
if proxy is None:
print "FAILED"
else:
CreatePrsForProxy(proxy, view, prs_types,
picture_dir, picture_ext)
+def GetFieldsInfo(proxy):
+ """Extracts names of fields from tree info.
+ """
+ fields_info = proxy.GetProperty("FieldsTreeInfo")
+ print fields_info
+ keys = [fields_info[::2][i] for i in range(len(fields_info[::2])) if fields_info[1::2][i]!='0']
+ print keys
+ # list all the names of arrays that can be seen (including their spatial discretization)
+ arr_names_with_dis = [elt.split("/")[-1] for elt in keys]
+ # split items by spatial discretization (point or cell)
+ # and put (field_name, field_path) pairs into corresponding dictionaries
+ points_dict = dict(); cells_dict = dict()
+ for (i, elt) in enumerate(arr_names_with_dis):
+ arr_item = elt.split(proxy.GetProperty("Separator").GetData())
+ if arr_item[1] == 'P0':
+ cells_dict[arr_item[0]] = keys[i]
+ elif arr_item[1] == 'P1':
+ points_dict[arr_item[0]] = keys[i]
+ return points_dict, cells_dict
def CreatePrsForProxy(proxy, view, prs_types, picture_dir, picture_ext):
"""Build presentations of the given types for all fields of the proxy.
"""
# List of the field names
- field_names = list(proxy.PointArrays.GetData())
+ point_fields, cell_fields = GetFieldsInfo(proxy)
+ print 'point_fields: ', point_fields
+ print 'cell_fields: ', cell_fields
+ field_names = list(point_fields.keys())
nb_on_nodes = len(field_names)
- field_names.extend(proxy.CellArrays.GetData())
+ field_names.extend(cell_fields.keys())
+ print 'field_names: ', field_names
+ field_paths = list(point_fields.values())
+ field_paths.extend(cell_fields.values())
+ print 'field_paths: ', field_paths
# Add path separator to the end of picture path if necessery
if not picture_dir.endswith(os.sep):
if PrsTypeEnum.MESH in prs_types:
# Create Mesh presentation. Build all possible submeshes.
+ extGrp=pv.ExtractGroup()
+
# Remember the current state
- groups = list(proxy.Groups)
+ groups = filter(lambda x:x[:4]=="GRP_",list(extGrp.GetProperty("GroupsFlagsInfo")[::2]))
# Iterate on meshes
mesh_names = get_mesh_names(proxy)
process_prs_for_test(prs, view, pic_name, False)
# Restore the state
- proxy.Groups = groups
- proxy.UpdatePipeline()
+ extGrp.AllGroups = groups
+ extGrp.UpdatePipelineInformation()
# Presentations on fields
for (i, field_name) in enumerate(field_names):
# Select only the current field:
# necessary for getting the right timestamps
- cell_arrays = proxy.CellArrays.GetData()
- point_arrays = proxy.PointArrays.GetData()
field_entity = None
if (i >= nb_on_nodes):
field_entity = EntityType.CELL
- proxy.PointArrays.DeselectAll()
- proxy.CellArrays = [field_name]
+ proxy.AllArrays = [cell_fields[field_name]]
else:
field_entity = EntityType.NODE
- proxy.CellArrays.DeselectAll()
- proxy.PointArrays = [field_name]
+ proxy.AllArrays = [point_fields[field_name]]
# Get timestamps
proxy.UpdatePipelineInformation()
timestamps = proxy.TimestepValues.GetData()
+ print timestamps
# Restore fields selection state
- proxy.CellArrays = cell_arrays
- proxy.PointArrays = point_arrays
+ proxy.AllArrays = field_paths
proxy.UpdatePipelineInformation()
for prs_type in prs_types:
# Show and dump the presentation into a graphics file
process_prs_for_test(prs, view, pic_name)
+ return
INCLUDE(SalomeMEDConfig)
FIND_PACKAGE(SalomePython REQUIRED)
FIND_PACKAGE(SalomeHDF5 REQUIRED)
+FIND_PACKAGE(SalomeMED REQUIRED)
FIND_PACKAGE(SalomeMEDFile REQUIRED)
+# Accumulate environment variables for PARAVIS module
+SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
+ ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
+SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
+
#
# process all vtk-modules defined in this plugin. This generates the necessary
# wrappings for all these modules as well.
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
ADD_TEST(testMEDReader0 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader0.py)
+SET_TESTS_PROPERTIES(testMEDReader0 PROPERTIES ENVIRONMENT "${tests_env}")
ADD_TEST(testMEDReader1 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader1.py)
+SET_TESTS_PROPERTIES(testMEDReader1 PROPERTIES ENVIRONMENT "${tests_env}")
ADD_TEST(testMEDReader2 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader2.py)
+SET_TESTS_PROPERTIES(testMEDReader2 PROPERTIES ENVIRONMENT "${tests_env}")
ADD_TEST(testMEDReader3 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader3.py)
+SET_TESTS_PROPERTIES(testMEDReader3 PROPERTIES ENVIRONMENT "${tests_env}")
ADD_TEST(testMEDReader4 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader4.py)
+SET_TESTS_PROPERTIES(testMEDReader4 PROPERTIES ENVIRONMENT "${tests_env}")
ADD_TEST(testMEDReader5 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader5.py)
+SET_TESTS_PROPERTIES(testMEDReader5 PROPERTIES ENVIRONMENT "${tests_env}")
ADD_TEST(testMEDReader6 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader6.py)
+SET_TESTS_PROPERTIES(testMEDReader6 PROPERTIES ENVIRONMENT "${tests_env}")
ADD_TEST(testMEDReader7 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader7.py)
+SET_TESTS_PROPERTIES(testMEDReader7 PROPERTIES ENVIRONMENT "${tests_env}")
ADD_TEST(testMEDReader8 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/testMEDReader8.py)
+SET_TESTS_PROPERTIES(testMEDReader8 PROPERTIES ENVIRONMENT "${tests_env}")
print "Chart title for xyplot ...", aXYPlot.ChartTitle
error = 0
-try:
- aXYPlot.ShowAxis = [1, 1, 0, 0]
-except:
- print "Error: ShowAxis property is not avaliable for XYPlotView"
- error = error + 1
aXYPlot.AxisUseCustomRange = [1, 1, 0, 0]
error = error + test_values(Ranges, Etvalue[0:2])
Ranges=aXYPlot.BottomAxisRange
error = error + test_values(Ranges, Etvalue[2:4])
-
-try:
- aXYPlot.ShowAxis = [1, 1, 1, 1]
-except:
- print "Error: ShowAxis property is not avaliable for XYPlotView"
- error = error + 1
-
aXYPlot.AxisUseCustomRange = [1, 1, 1, 1]
# Left, bottom, right and top axis range
aXYPlot.LeftAxisRange = [0, 200]
my_view = GetRenderView()
print "\nCreating plot3d.......",
-plot3d = Plot3DOnField(proxy, EntityType.CELL, field_name, 1)
+plot3d = Plot3DOnField(proxy, EntityType.NODE, field_name, 1)
if plot3d is None:
raise RuntimeError("Error!!! Presentation wasn't created...")
field_name = 'VITESSE'
print "\nCreating scalar map.......",
-scalar_map = ScalarMapOnField(proxy, EntityType.CELL, field_name, 1)
+scalar_map = ScalarMapOnField(proxy, EntityType.NODE, field_name, 1)
if scalar_map is None:
raise RuntimeError("Error!!! Presentation wasn't created...")
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/A0")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/A0")
# 1. Import MED file
print 'Importing "hydro_sea_alv.med"...',
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/A1")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/A1")
med_file_path = datadir + "fra1.med"
pic_path = os.path.join(picturedir, "A1." + pictureext)
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/A2")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/A2")
med_file_path = datadir + "carre_MIXTE_0000_v3.0.6.med"
pic_path = os.path.join(picturedir, "A2." + pictureext)
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/A6")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/A6")
med_file_path = datadir + "fra.med"
import paravis
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/A7")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/A7")
med_file_path = datadir + "hexa_28320_ELEM.med"
CreatePrsForFile(my_paravis, med_file_path, [PrsTypeEnum.MESH], picturedir, pictureext)
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/A9")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/A9")
# 1. Step1: Import MED file
print "**** Step1: Importing MED file"
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/B1")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/B1")
# 1. Import MED file
med_file_path = datadir + "resultat.01.med"
med_reader = pvsimple.GetActiveSource()
if med_reader is None:
- print "FAILED"
+ raise RuntimeError, "MEDfileForStructuredMesh.med was not imported!"
else:
print "OK"
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/C4")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/C4")
# 1. Import MED file
med_file_path = datadir + "forma01f.resu.med"
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/C6")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/C6")
# 1. Import MED file
med_file_path = datadir + "relachement_brutal_sans_dudg_gauss.med"
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/C7")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/C7")
# 1. Import MED file
med_file_path = datadir + "Bug583-Quadratique.resu.med"
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/D0")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/D0")
# Aux method
def get_group_full_name(source, group_name):
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "bugs/D1")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("bugs/D1")
# 1. Import of the "Bug829_resu_mode.med" file at first time
med_file_path = datadir + "Bug829_resu_mode.med"
import pvsimple
my_paravis = paravis.myParavis
-picturedir = get_picture_dir(sys.argv[1], "imps/A1")
+os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
+picturedir = get_picture_dir("imps/A1")
def set_prs_colored(prs, proxy, entity, field_name, vector_mode, timestamp_nb):