# Clip¶

## Description¶

Clip a grid (structured of unstructured) using a given clipping geometrical shape.

==>

Initial unstructured multi-element mesh on the left. Clipping with a plane on the right.

## Parameters¶

• base: antares.api.Base

The input base to be clipped.

• coordinates: list(str)

The variable names that define the set of coordinates.

• type: str, default= ‘plane’

The type of geometrical shape used to clip. The values are: - plane - cone - cylinder - sphere - revolution

If none of the above, you can also set a VTK functions as a value.

• origin: tuple(float),

The coordinates (tuple of 3 floats) of the origin used to define the clipping shape. Used for: - plane - cone - cylinder - sphere

• normal: tuple(float),

The coordinates (tuple of 3 floats) of the normal vector used to define a clipping plane.

• angle: float,

Angle (in radian) of the clipping cone.

Radius of a clipping cylinder or sphere.

• line: dict,

Definition of the line for the clipping of type ‘revolution’.

As an example, in a cylindrical coordinate system (x,r,t). Give the axial points as keys and radial points as values. The revolution will take place in the azimutal direction. The lowest and the greatest x-values will serve to set two x-constant clipping planes to only keep the domain in-between.

• axis: str,

The coordinate (name) that defines the clipping cone or cylinder.

• invert: bool, default= False

If True, invert the clipping domain.

• memory_mode: bool, default= False

If True, the initial base is deleted on the fly to limit memory usage.

• 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).

## Preconditions¶

Zones may be either structured or unstructured.

Zones may contain multiple instants.

## Postconditions¶

The output base is always unstructured. 3D bases only contain tetrahedral elements. 2D bases only contain triangle elements. If with_families is enabled, the output base contains the reconstructed families of base.

## Example¶

The following example shows a clipping with a plane defined with the point (0., 0., 0.) and the normal vector (1., 0., 0.).

import antares
myt = antares.Treatment('clip')
myt['base'] = base
myt['type'] = 'plane'
myt['origin'] = [0., 0., 0.]
myt['normal'] = [1., 0., 0.]
clipped = myt.execute()


Note

dependency on VTK

## Main functions¶

class antares.treatment.TreatmentClip.TreatmentClip
execute()

Clip the geometry.

Returns

the unstructured Base obtained by clipping with a geometrical shape.

Return type

antares.api.Base

## Example¶

"""
This example shows how to clip a base.

Note that even if the input base is structured, the output of the
clip treatment will be unstructured.
"""
import os

import antares

OUTPUT = 'OUTPUT'
if not os.path.isdir(OUTPUT):
os.makedirs(OUTPUT)

# ------------------
# Reading the files
# ------------------
reader['filename'] = os.path.join('..', 'data', 'ROTOR37', 'GENERIC', 'flow_<zone>_<instant>.dat')

# -----------------------
# Clipping of type plane
# -----------------------
# For this clipping the dataset is cut by a plane and only the
# cells under the plane are kept (under/over is defined by the
# normal orientation).
# Note that the output dataset present a smooth plane cut at the
# clipping position
treatment = antares.Treatment('clip')
treatment['base'] = ini_base
treatment['type'] = 'plane'
treatment['origin'] = [70., 0., 0.]
treatment['normal'] = [1., 0., 0.]
result = treatment.execute()

# -------------------
# Writing the result
# -------------------
writer = antares.Writer('bin_tp')
writer['filename'] = os.path.join(OUTPUT, 'ex_clip_plane.plt')
writer['base'] = result
writer.dump()