Cut (with VTK)¶
Description¶
Cut a grid (structured or unstructured) using a given geometrical shape. Cut using the VTK library.
Parameters¶
- base:
Base
The input base to be cut.
- base:
- coordinates: list(str)
The variable names that define the set of coordinates. If no value is given, the default coordinate system of the base is used (see
Base.coordinate_names
).
- nb_cuts: int, default= 1
The desired number of cuts of the same kind. It defines the length of the list of the varying arguments. Performing multiple cuts at once, ‘origin’, ‘normal’, ‘axis’, ‘angle’, ‘radius’ become lists of parameters.
- type: str, default= ‘plane’
The type of geometrical shape used to cut. The values are: - plane - cone - cylinder - sphere - revolution - spline - polyline - vtk user-defined function The cone is a right circular cone.
- origin: tuple(float) or list(tuple(float))
The coordinates of the origin used to define the cutting shape. Used for:
plane
cone
cylinder
sphere
They must be coherent with coordinates. Tuple of 3 floats for a single cut, or list of tuples of 3 floats for a multiple cut. The origin must be inside the domain.
- normal: tuple(float) or list(tuple(float))
The coordinates of the normal vector used to define a cutting plane (type=’plane’). Tuple of 3 floats for a single cut, or list of tuples of 3 floats for a multiple cut.
- angle: float or list(float)
Angle (in radian) of the cone at the apex for a cutting cone (type=’cone’). Float for a single cut, or list of floats for a multiple cut.
- radius: float or list(float)
Radius of the cutting cylinder or sphere (type=’cylinder’ or type=’sphere’). Float for a single cut, or list of floats for a multiple cut.
- axis: tuple(3*floats) or list(tuple(3*floats))
The axis of rotation for type=’cylinder’ or type=’cone’. Tuple of 3 floats for a single cut, or list of tuples of 3 floats for a multiple cut.
example: axis =[0., 0., 1.] to set ‘z’ as the axis in 3D with the cartesian coordinates [‘x’, ‘y’, ‘z’]
- line_points: list(tuple(float))
List of point coordinates for type=’polyline’ or type=’spline’. Definition points must be given in the same frame of reference as the base. The points must defined a line in the space made by the coordinates except the extrusion axis. These points form a line that is extruded in the third dimension with respect to coordinates. List of tuples of two/three floats for a single cut, or list of lists of tuples of two/three floats for a multiple cut. If two floats are given, the third coordinate is set to zero.
example: line_points =[(-4., 2.), (1., 2.)]. List of (x,r) points with ‘theta’ the extrusion axis with coordinates [‘x’, ‘r’, ‘theta’].
- example:
[(x,y),…] for a single cut.
[[(x1,y1),…], [(x2,y2),…],…] for a multiple cut.
- resolution: int, default= 50
The desired number of points used to discretize the cutter line from the point list defined with line_points. Note that it is only used for type=’spline’.
- line: list(tuple(float))
List of point coordinates for type=’revolution’. The frame of reference must be the cylindrical coordinate system. No checking is made on this point. The points of the ‘line’ must be given in order. List of tuples of two floats for a single cut, or list of lists of tuples of two floats for a multiple cut.
- expert: str
Options dedicated to expert users. Values are [‘tri_and_qua’]. ‘tri_and_qua’: do not triangulate the cut surface. Keep original elements (only segments, triangles, and quadrilaterals). Other elements are triangulated.
- memory_mode: bool, default= False
If True, the initial base is deleted on the fly to limit memory usage.
- with_boundaries: bool, default= False
Whether or not to use data from the boundaries.
- with_families: bool, default= False
If True, the output of the treatment contains rebuilt families based on the input base. All the families and all the levels of sub-families are rebuilt, but only attributes and Zone are transfered (not yet implemented for Boundary and Window).
- merging_point_tolerance: float, default= 1e-15
Below this value, 2 points are merged, to avoid degenerated elements
Preconditions¶
If shared coordinates, ALL coordinates must be in the shared instant.
The Base must contain at least one non shared Instant.
Requirements for cut type:
cone: ‘angle’, ‘axis’, ‘origin’
cylinder: ‘axis’, ‘origin’, ‘radius’
plane: ‘origin’, ‘normal’
sphere: ‘origin’, ‘radius’
polyline: ‘line_points’
revolution: ‘line’
spline: ‘line_points’
For multiple cuts, the value of atomic keys can be replaced with a list of values. The length of this list must be equal to ‘nb_cuts’.
Postconditions¶
If with_families is enabled, the output base contains the reconstructed families of base.
Example¶
The following example shows a cutting with a plane defined with the point (0., 0., 0.) and the normal vector (1., 0., 0.).
import antares
myt = antares.Treatment('cut')
myt['base'] = base
myt['type'] = 'plane'
myt['origin'] = [0., 0., 0.]
myt['normal'] = [1., 0., 0.]
cutbase = myt.execute()
Main functions¶
Examples¶
Look at examples in antares/examples/treatment:
cut.py
cut_sector.py
multicut_cylinder.py
multicut_plane.py
multicut_revolution.py
multicut_spline.py
spline.py
decimate.py
turboglobalperfo.py
unwrapline.py