aerocaps.geom.geometry_container.GeometryContainer#
- class GeometryContainer[source]#
Bases:
objectStorage container for geometric objects that adds convenience methods for plotting and export
- __init__()[source]#
Storage container for geometric objects that adds convenience methods for plotting and export. The example code below shows how to add a curve and a surface to a new container, plots them in an interactive scene, exports them to IGES, and then removes both of them by varying identifiers:
# Create the geometric objects curve = BezierCurve3D(np.array([ [0.0, 0.0, 0.0], [0.3, 0.2, 0.1], [0.6, 0.1, 0.3], [1.0, -0.1, 0.2] ]), name='MyCurve') surf = BezierSurface(np.array([ [ [0.0, 0.0, 0.0], [0.3, 0.2, 0.1], [0.6, 0.1, 0.3], [1.0, -0.1, 0.2] ], [ [0.0, 0.0, 1.0], [0.3, 0.4, 1.1], [0.6, 0.2, 1.3], [1.0, -0.3, 1.2] ] ])) # Instantiate a container container = GeometryContainer() # Add the geometries to the container container.add_geometry(point) container.add_geometry(curve) # List the geometries inside the container geom_names = container.geometry_name_list() print(f'{geom_names = }') # Plot the geometries in an interactive scene container.plot() # Export the geometries to an IGES file container.export_iges('curve_and_surf.igs', units='meters') # Remove the curve and surface by different methods container.remove_geometry('MyCurve') container.remove_geometry(surf) # Show that the container is now empty geom_names = container.geometry_name_list() print(f'{geom_names = }')
Methods
add_geometry(geom)Adds a geometric object to the container, renaming the object with a higher index if necessary
export_iges(file_name[, units])Exports all the exportable objects in the container to an IGES file
export_stl(file_name[, Nu, Nv])Exports all the exportable objects in the container to an STL file
geometry_by_name(name)Searches for a geometry in the container by name
geometry_name_list([geom_type])Gets the list of geometries (by name) that have been added to the container
plot([show, Nu, Nv, Nt, surface_selection, ...])Plots all the plottable objects in the container onto a
pyvista.Plotterscene.remove_geometry(geom)Removes a geometric object from the container
- add_geometry(geom: Geometry)[source]#
Adds a geometric object to the container, renaming the object with a higher index if necessary
- Parameters:
geom (Geometry) – Geometric object to add
- export_iges(file_name: str, units: str = 'meters')[source]#
Exports all the exportable objects in the container to an IGES file
- Parameters:
file_name (str) – Path to the IGES file
units (str) – Physical length units used to export the geometries. See
aerocaps.iges.iges_generator.IGESGenerator.__init__for more details. Default:"meters"
- export_stl(file_name: str, Nu: int = 50, Nv: int = 50)[source]#
Exports all the exportable objects in the container to an STL file
- geometry_name_list(geom_type: type = None) List[str][source]#
Gets the list of geometries (by name) that have been added to the container
- plot(show: bool = True, Nu: int = 50, Nv: int = 50, Nt: int = 50, surface_selection: bool = True, random_colors: bool = False, color_seed: int = 42)[source]#
Plots all the plottable objects in the container onto a
pyvista.Plotterscene. Also adds a surface picker to dynamically show surface information on right-click.- Parameters:
show (bool) – Whether to show the plot. Default:
TrueNu (int) – The number of points in the \(u\)-direction of each surface to evaluate. Default:
50Nv (int) – The number of points in the \(u\)-direction of each surface to evaluate. Default:
50Nt (int) – The number of points to evaluate along each curve for a trimmed surface evaluation. Default:
50surface_selection (bool) – Whether to allow interactive selection of surfaces. Default:
Truerandom_colors (bool) – Whether to paint each surface with a random color. Default:
Falsecolor_seed (int) – The random number seed used to generate the random colors. Ignored if
random_colors==False. Default:42