pyg4ometry.visualisation.VtkExporter¶
Attributes¶
Classes¶
Module Contents¶
- pyg4ometry.visualisation.VtkExporter._WITH_PARAVIEW = True¶
- pyg4ometry.visualisation.VtkExporter._WITH_PARAVIEW = False¶
- class pyg4ometry.visualisation.VtkExporter.VtkExporter(path='.')¶
- path¶
- localmeshes¶
- elements = []¶
- mbdico¶
- mbindexdico¶
- materialVisualisationOptions¶
- export_to_Paraview(reg, fileName='Paraview_model.pvsm', model=True, df_model=None, df_color=None)¶
Method that exports the visible logical volumes of the registry reg into Paraview VTK files (.vtm) and creates a Paraview State file (.pvsm) for the Paraview Model.
df_model and df_color are optional: if they are not given, the Paraview model will take the materials colors
- Parameters:
reg – Registry
fileName – Name of the Paraview State file (.pvsm)
model – Boolean informing whether we work with a “model” GDML or a “simple” GDML
True: it will consider that each daughter volume of the GDML world volume will need a .vtm file False: it will create one .vtm file for the whole GDML :param df_model: (optional) pandas.DataFrame linking the NAME of the element and their TYPE :param df_color: (optional) pandas.DataFrame linking the TYPE with its specific R G B color
- export_to_VTK(reg, model=True, df_model=None, df_color=None)¶
Method that exports the visible logical volumes of the registry reg into Paraview VTK files (.vtm).
- Parameters:
reg – Registry
model – Boolean informing whether we work with a “model” GDML or a “simple” GDML
True: it will consider that each daughter volume of the GDML world volume will need a .vtm file False: it will create one .vtm file for the whole GDML :param df_model: (optional) pandas.DataFrame linking the NAME of the element and their TYPE :param df_color: (optional) pandas.DataFrame linking the TYPE with its specific R G B color
- fill_color_dico(df_gdml, df_model, df_color)¶
Method that fills a dictionary linking the logical volumes names and their respective color based on the pandas.DataFrame df_color linking the TYPE of the elements and their respective RGB color values.
- Parameters:
df_gdml – pandas.DataFrame that represents the GDML Structure
df_model – pandas.DataFrame linking the NAME of the element and their TYPE
df_color – pandas.DataFrame linking the TYPE with its specific R G B color
Returns: A dictionary with the keys R, G and B whose item is a dictionary with as keys the logical volumes names and as item the respective RGB value
- add_logical_world_volume(lv, model, color_dico={'R': {}, 'G': {}, 'B': {}}, rotation=_np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]), translation=_np.array([0, 0, 0]))¶
Method that receives the logical world volume and calls the necessary methods to write the .vtm file(s).
- Parameters:
lv – Logical world volume
model – Boolean informing whether we work with a “model” GDML or a “simple” GDML
True: it will consider that each daughter volume of the GDML world volume will need a .vtm file False: it will create one .vtm file for the whole GDML :param color_dico: A dictionary with the keys R, G and B whose item is a dictionary with as keys the logical volumes names and as item the respective RGB value :param rotation: (optional) numpy.matrix :param translation: (optional) numpy.array
- add_logical_volume_recursive(lv, rotation, translation, color_dico, first_level=True)¶
Method that receives a logical volume and add calls addMesh() on its mesh. The method is recursive and will be called on all the daughter logical volumes of the logical volume.
- Parameters:
lv – Logical volume
rotation – numpy.matrix
ranslation – numpy.array
color_dico – A dictionary with the keys R, G and B whose item is a dictionary
with as keys the logical volumes names and as item the respective RGB value :param first_level: Boolean indicating if we are at the first level of recursivity
- addMesh(solid_name, mesh, rotation, translation, visOptions=None)¶
Method that converts the mesh into VtkPolyData (.vtp file) and gives it the correct rotation, translation and color.
- Parameters:
solid_name – Name of the logical volume solid
mesh – Mesh of the logical volume
rotation – numpy.matrix
translation – numpy.array
visOptions – VisualisationOptions instance
- getMaterialVisOptions(name)¶
Method that “cleans” the logical volume material string.
- Parameters:
name (str) – raw name of the logical volume material
Returns: clean name of the logical volume material
- getElementName(logicalVolumeName)¶
Method that “cleans” the logical volume name string.
- Parameters:
logicalVolumeName (str) – raw name of the logical volume
Returns: clean name of the logical volume
- countVisibleDaughters(lv, element_name, n=0)¶
Method that counts the number of “visible” daughter logical volumes of the mother logical volume lv.
- Parameters:
lv (pyg4ometry.geant4.LogicalVolume) – logical volume
element_name (str) – name of the element
n (int) – number of “visible” daughter volumes
Returns: n