vtk_openCARP_methods_ibt.vtk_methods package
Submodules
vtk_openCARP_methods_ibt.vtk_methods.converters module
vtk_openCARP_methods_ibt.vtk_methods.dat_to_vtk_conversion module
- add_dat_to_openCARP_mesh(dat_file, openCARP_mesh_file, array_name, output_file)[source]
Adds data from a .dat file as PointData to a openCARP .pts, .elem mesh.
- Parameters:
dat_file – Path to the .dat file containing data to add.
openCARP_mesh_file – Path to the input openCARP file e.g Test-> Test.pts and Test.elem has to exist.
array_name – Name of the array which is represented in the .dat file.
output_file – Path to save the updated VTK mesh.
- add_dat_to_vtk_mesh(dat_file, mesh, array_name, output_file, offset=0)[source]
Adds data from a .dat file as PointData to a VTK mesh. :type dat_file: :param dat_file: Path to the .dat file containing data to add. :type mesh: :param mesh: A VTKMesh in the .vtk format :type array_name: :param array_name: Name of the array which is represented in the .dat file. :type output_file: :param output_file: Path to save the updated VTK mesh. :type offset: :param offset: Offset which is added to the data array. :return:
vtk_openCARP_methods_ibt.vtk_methods.exporting module
- vtk_polydata_writer(filename, data, store_binary=False, store_xml=False)[source]
Writes a vtk polydata grid to specified filename this has to include the full path
- write_to_vtx(filename, data, try_append=False)[source]
Writes the data to a .vtx file :type filename: :param filename: Filename to write the data to with .vtx extension :type data: :param data: The data to write. Can be a list/array or single values :type try_append: :param try_append: Set to true if you like to append to existing .vtx file :return:
vtk_openCARP_methods_ibt.vtk_methods.filters module
- apply_extract_cell_filter(input, id_list, input_is_connection=False)[source]
Extract cells from mesh based on the id_list :type input_is_connection: :param input_is_connection: Set to true if the input is an output port :type input: :param input: Input mesh or connection :type id_list: :param id_list: :return:
- clean_polydata(input, input_is_connection=False)[source]
Encapsulates the vtkCleanPolyData function :type input: :param input: Either the input mesh or a vtk input connection port :type input_is_connection: :param input_is_connection: True if the input is an output port :return: applied clean polydata filter
- get_elements_above_plane(input, plane, extract_boundary_cells_on=False, input_is_connection=False)[source]
Encapsulates the vtkExtractGeometry filter and returns elements which lay above the specified plane. :type input_is_connection: :param input_is_connection: Set to true if the input is an output port :type input: :param input: Input data or connection. Set input_is_connection to true if the input is an output port :type plane: :param plane: vtkPlane :type extract_boundary_cells_on: :param extract_boundary_cells_on: True if the option to extract boundary cells should be turned on :return:
- get_equidistant_points(mesh, tolerance=1.0, point_merging_on=True, tolerance_on=True)[source]
Returns equidistant points with elements for given interpoint distance :type tolerance_on: :param tolerance_on: Set to true, if a specific tolerance is to be applied :type mesh: :param mesh: Mesh on which the filter is to be applied :type tolerance: :param tolerance: Tolerance given in mm :type point_merging_on: :param point_merging_on: Enable point merging of vtk clean filter :return:
- get_feature_edges(input_data, boundary_edges_on, feature_edges_on, manifold_edges_on, non_manifold_edges_on)[source]
- get_vtk_geom_filter_port(geom, input_is_connection=False)[source]
Initializes an vtkGeometryFilter and returns the filter and the output port. Filter has to be returned otherwise it will be destroyed by the garbage collector :type geom: :param geom: Input data or connection :type input_is_connection: :param input_is_connection: True is the input is also an output port :return: the output port of the geometry filter and the geometry filter itself
- scale_poly_data(mesh, scale_factor)[source]
Scales a polydata based on a scale factor :type mesh: :param mesh: VTK polydata mesh :type scale_factor: :param scale_factor: Factor which scales the mesh
- Returns:
- translate_poly_data(mesh, translation)[source]
Translates a polydata based on a three-dimensional translation vector :type mesh: :param mesh: VTK polydata mesh :type translation: :param translation: Array with three indices for translation in x,y and z. :return:
- vtk_append(geometries, merge_points=False)[source]
Appends the geometries to one mesh :type geometries: :param geometries: List of at least 1 vtk meshes. Supports vtkPolyData and vtkUnstructuredGrid. Hast to be the same type for all the geometries. Has to be a list. :type merge_points: :param merge_points: Set merge points flag of the append filter on or off. :return:
vtk_openCARP_methods_ibt.vtk_methods.finder module
vtk_openCARP_methods_ibt.vtk_methods.helper_methods module
- add_vectors_to_vtk(mesh, vectors, name, is_cell_array=True)[source]
Adds a set of vectors to a vtk object as a cell array with a given name. :type mesh: :param mesh: A vtk object. :type vectors: :param vectors: A numpy based array of vectors. :type name: :param name: The name of the resulting cell array :type is_cell_array: :param is_cell_array: If True, the resulting array is added to cell data otherwise to point data. :return:
- find_points_within_radius(mesh, center_point, radius)[source]
Gets points within a radius around the center_point. :type mesh: :param mesh: Has to be a vtk mesh :type center_point: :param center_point: point in coordinates (x,y,z) :type radius: :param radius: Radius in units of the mesh :return:
- get_maximum_distance_of_points(points, point_center)[source]
Returns the maximum distance to the point_center. :type points: :param points: Has to be a vtk object on which GetPoints() can be executed :type point_center: :param point_center: :return: the maximum distance between the point_center and the points
vtk_openCARP_methods_ibt.vtk_methods.init_objects module
- class ExtractionModes(value)[source]
Bases:
EnumAn enumeration.
- ALL_REGIONS = 'all_regions'
- CLOSEST_POINT = 'closest_point'
- CLOSEST_POINT_REGION = 'closest_point_region'
- LARGEST_REGION = 'largest_region'
- SPECIFIED_REGIONS = 'specified_regions'
- init_connectivity_filter(input, extraction_mode, color_regions=False, closest_point=None)[source]
Returns an initialized connectivity filter with update applied :type closest_point: :param closest_point: Set closest point if the extraction mode is set to the closest point :type input: :param input: The inout data :type extraction_mode:
ExtractionModes:param extraction_mode: One of the implemented connectivity modes. See class ConnectivityModes :type color_regions: :param color_regions: :return:
- initialize_plane_with_points(norm_center_point, point_a, point_b, plane_origin, invert_norm=False)[source]
Creates a plane for given vectors. Plane is defined by a perpendicular vector n and a center point (plane_origin) The perpendicular vector is the cross product between the norm_center_point and point_a and point_b. :type norm_center_point: :param norm_center_point: Center for building the perpendicular vector :type point_a: :param point_a: :type point_b: :param point_b: :type plane_origin: :param plane_origin: :type invert_norm: :param invert_norm: Inverts the perpendicular vector of the plane :return:
vtk_openCARP_methods_ibt.vtk_methods.mapper module
- cell_array_mapper(mesh1, mesh2, mesh2_name, idat)[source]
- Parameters:
mesh1 – Vtk mesh object
mesh2 – Vtk mesh object
mesh2_name
idat – Set to “all” to mapp all arrays, else choose a specific array
- Returns:
Returns mesh and also stores it to disk with subfix “_with_data”
- ids_to_pts(ids, mesh)[source]
Converts ids to pts which can be exported to a pts file :type ids: :param ids: The point ids for the mesh :type mesh: :param mesh: :return:
- mapp_ids_for_folder(source_folder, dest_folder, source_mesh, dest_mesh, debug=False)[source]
Maps all vtx files from one folder to another folder with two different meshes as a base. vtx files in source folder has to be originated from the source mesh. All the vtx files in the dest_folder will be in correspondence to the dest_mesh :type debug: :param debug: If true all the vtx files will also be stored as .pts file for better inspection :type source_folder: :param source_folder:Path to a folder with vtx files :type dest_folder: :param dest_folder: Path to a folder where the results are stored :type source_mesh: :param source_mesh: original vtk mesh :type dest_mesh: :param dest_mesh: mesh for the reference of the newly generated points :return:
- point_array_mapper(mesh1, mesh2, idat)[source]
- Parameters:
mesh1
mesh2
idat – Set to “all” to mapp all arrays, else choose a specific array
- Returns:
Mapped mesh
- remap_ids(source_mesh, dest_mesh, source_point_ids)[source]
Maps source point_id_s coming from the source_mesh to ids from the dest_mesh. :type source_mesh: :param source_mesh: vtk mesh :type dest_mesh: :param dest_mesh: vtk mesh :type source_point_ids: :param source_point_ids: array :return: Array with the new ids
vtk_openCARP_methods_ibt.vtk_methods.normal_orientation module
- are_normals_outside(mesh)[source]
Determine if the normals of the mesh point outside the center of the mesh. Based on stochastic evaluation of 100 points to be able to process large meshes fast. :type mesh: :param mesh: A vtk mesh object :return: True if the normals of the mesh point outside, false otherwise
- generate_normals(mesh)[source]
Generates the normals for a given vtk polydata mesh :type mesh: :param mesh: Polydata mesh with normals as array :return:
- get_sampled_points_and_normals(normals, points, number_of_samples=1000)[source]
Get a random subset of points and normals. :type normals: :param normals: Array of all normals as n-dimensional array :type points: :param points: Array of all points as n-dimensional array :type number_of_samples: :param number_of_samples: How many points/normals should be sampled :return:
vtk_openCARP_methods_ibt.vtk_methods.reader module
vtk_openCARP_methods_ibt.vtk_methods.thresholding module
- get_lower_threshold(input_source, lower_bound, field_association, field_name, idx=0, port=0, connection=0, source_is_input_connection=0)[source]
Encapsulates vtk lower threshold
- Parameters:
input_source – Input data to threshold. Can be either an input connection or input data format.
Set source_is_input_connection to 1 if it’s an input connection :type lower_bound: :param lower_bound: lower bound for filtering the input source :type field_association: :param field_association: Type of field :type field_name: :param field_name: :type idx: :param idx: further details see vtk.vtkThreshold.SetInputArrayToProcess() :type port: :param port:further details see vtk.vtkThreshold.SetInputArrayToProcess() :type connection: :param connection:further details see vtk.vtkThreshold.SetInputArrayToProcess() :type source_is_input_connection: :param source_is_input_connection: 1 if it’s an input connection, 0 if it’s an input data format :return: initialized and updated threshold object
- get_threshold_between(input_source, lower_bound, upper_bound, field_association, field_name, idx=0, port=0, connection=0, source_is_input_connection=0, invert=False)[source]
- Parameters:
input_source – Input data to threshold. Can be either an input connection or input data format.
Set source_is_input_connection to 1 if it’s an input connection. Automatically swaps variables if lower_bound > upper_bound. :type lower_bound: :param lower_bound: :type upper_bound: :param upper_bound: :type field_association: :param field_association: Type of field :type field_name: :param field_name: :type idx: :param idx: further details see vtk.vtkThreshold.SetInputArrayToProcess() :type port: :param port:further details see vtk.vtkThreshold.SetInputArrayToProcess() :type connection: :param connection:further details see vtk.vtkThreshold.SetInputArrayToProcess() :type source_is_input_connection: :param source_is_input_connection: 1 if it’s an input connection, 0 if it’s an input data format :type invert: :param invert: True if selection should be inverted :return: initialized and updated threshold object :return:
- get_upper_threshold(input_source, upper_bound, field_association, field_name, idx=0, port=0, connection=0, source_is_input_connection=0)[source]
Encapsulates vtk lower threshold
- Parameters:
input_source – Input data to threshold. Can be either an input connection or input data format.
Set source_is_input_connection to 1 if it’s an input connection :type upper_bound: :param upper_bound: lower bound for filtering the input source :type field_association: :param field_association: Type of field :type field_name: :param field_name: :type idx: :param idx: further details see vtk.vtkThreshold.SetInputArrayToProcess() :type port: :param port:further details see vtk.vtkThreshold.SetInputArrayToProcess() :type connection: :param connection:further details see vtk.vtkThreshold.SetInputArrayToProcess() :type source_is_input_connection: :param source_is_input_connection: 1 if it’s an input connection, 0 if it’s an input data format :return: initialized and updated threshold object