## Using *OpenCascadeLink*

This section shows some of the ways that *OpenCascadeLink* can be applied. To use *OpenCascadeLink,* it must first be loaded.

Since many of the OpenCascade examples interact with the finite element mesh functionality the finite element package is also loaded.

### Solid 3D Primitives

Various Wolfram Language Graphics3D primitives can be represented in *OpenCascade*. These primitives are represented as solids.

#### Ball

#### CapsuleShape

#### Cone

#### Cuboid

#### Cylinder

#### Ellipsoid

#### Hexahedron

#### Parallelepiped

#### Prism

#### Polyhedron

#### Pyramid

#### SphericalShell

#### Tetrahedron

### Extended Solid 3D Primitives

*OpenCascade* provides some primitives that do not have a direct correspondence in the Wolfram language.

#### Torus

Here the arguments are an axis around which the torus is located, a radius from the axis to the interior of the torus and a second radius specifying the the radius of the interior of the torus.

### Surfaces Primitives

It is also possible to create instances of surface graphics primitives embedded in 3D.

#### BSplineSurface

A fully meshed ElementMesh can not be created from a non closed surface.

#### Polygon

A fully meshed ElementMesh can not be created from a non closed surface.

#### Triangle

A fully meshed ElementMesh can not be created from a non closed surface.

### Surfaces Meshes

#### ElementMesh

The conversion is computationally expensive since every surface element is mapped into an *OpenCascade* object and then sewed together.

Both, open and closed surfaces can be converted.

### Edge Primitives

It is also possible to create instances of edge graphics primitives embedded in 3D.

#### Line

A boundary ElementMesh can not be created from an *OpenCascade* shape of type wire. Wire objects can, however, be used for rotational or linear sweeps.

### Operations on OpenCascade objects

#### SurfaceMesh

Surfaces of *OpenCascade* objects can be meshed.

"AngularDeflection" and "LinearDeflection" specify the maximum amount a segment may deviate from the true surface. The concepts are best explained with the following illustration.

"AngularDeflection" specifies the maximum deflection angle α at the end nodes of a segment while "LinearDeflection" specifies the maximum deflection to the true curve within a segment. The Automatic default for the "AngularDeflection" is set to 0.5 and the Automatic default for the "LinearDeflection" is set to 0.01. For more information please consult the OpenCascade Documentation.

"ComputeInParallel" specifies if the surface discretization should be performed on multiple CPU cores. The Automatic default is set to False.

"RelativeDeflection" specifies if the deflection is relative or absolute to the size of the geometry. The Automatic default is set to True.

To make working with *OpenCascade* and the finite element method easier a function to mesh the surface and return a boundary ElementMesh is provided.

All options that are relevant for the ElementMesh generation can be specified via "ElementMeshOptions" and options relevant for OpenCascadeShapeSurfaceMesh can be specified via "ShapeSurfaceMeshOptions".

The "MarkerMethod" option allows to specify if markers should be added and if where they should be computed. The default is to use "OpenCascade". Other options are "ElementMesh" and None to switch off markers entirely. Using "ElementMesh" as a "MarkerMethod" option can be useful if the generated surface consists of many single surface elements. In that case the "OpenCascade" method would attribute each element a unique marker which may be undesirable. With the method "ElementMesh", however, the markers are added based on their face normals and if those deviate by a certain amount. The ToBoundaryMesh reference page has more information on this topic.

#### Extracting parts

#### Translations, rotations and other transformations

As an alternative, the TransformationFunction can directly be applied during the creation of the *OpenCascade* shape by making use of a TransformedRegion.

#### Sewing

Surfaces that share edges can be sewn together.

Sewing of B-Spline surfaces with other objects is possible. However, nodes need to match.

As a further example an Ellipsoid is created from 8 BSplineSurface patches.

Note, here the ordering of the control points is important as explained further down.

A possible issue is that *OpenCascade* is sensitive to the ordering of the surfaces given for sewing. This may be tricky to note as a displayed surface might look good but when, for example, Boolean operations are performed on the object unexpected results may happen.

#### RotationalSweeps

*OpenCascade* can perform rotational sweeps. For this a surface is rotated around an axis. The rotation can be less than a full rotation.

*OpenCascade* can also perform rotational sweeps on wire objects.

Rotational sweeps can not be performed on Solid or CompundSolid OpenCascade shape types.

#### LinearSweeps

For a linear sweep of a surface a starting point on the surface and destination point are given and the surface is swept to the destination point.

*OpenCascade* can also perform linear sweeps on wire objects.

Linear sweeps can not be performed on Solid or CompundSolid OpenCascade shape types.

### Boolean Operations

Some restrictions in computing Boolean operations are detailed in the Boolean possible issues section and the Boolean operations on solids section.

#### Difference

Compute geometric differences of shapes.

#### Union

Compute geometric unions of shapes.

#### Intersection

Compute geometric intersection of shapes.

Intersections can also be generated from lower dimensional region objects.

#### BooleanRegion

The *OpenCascadeLink* provides functionality to directly work with BooleanRegion objects.

As a convenience it is also possible to use OpenCascadeShape for BooleanRegion objects directly.

#### Boolean operations on solids

*OpenCascade* handles Boolean operations in a slightly different manner than the Wolfram Language Boolean operators RegionUnion, RegionIntersection and RegionDifference. It's illustrative to walk through several examples.

##### Solids overlapping

##### Solids touching at a face

The lowest dimensional object that can be returned from an *OpenCascase* Boolean operation is that of the minimal dimension of any argument given to the Boolean operation. For example, a Boolean operation of two *OpenCascade* solids can not return an *OpenCascade* face object.

Since there are not solids and no faces the conversion to a boundary element mesh will fail.

Note that the resulting full mesh will be open at the touching faces.

Note that the resulting solid has it's surface split according to the shape of the touching object.

Note that the resulting solid has it's surface split according to the shape of the touching object.

##### Solids touching at an edge

The lowest dimensional object that can be returned from an *OpenCascase* Boolean operation is that of the minimal dimension of any argument given to the Boolean operation. For example, a Boolean operation of two *OpenCascade* solids can not return an *OpenCascade* face object.

Note that the edge of resulting full mesh will be split at the touching edges.

Note that the edge of resulting boundary mesh will be split at the touching edges.

Note that the edge of resulting boundary mesh will be split at the touching edges.

### Internal boundaries

*OpenCascade* offers several ways to include internal boundaries.

#### Internal boundaries by union of faces

Forming the union of solids will leave the position of the over lap open.

Note that at the overlap where the two cuboids touched the union is not closed. This may be undesirable if one is working with a multiple material region. One option to close the face at the overlap is to compute the union of all faces of the solids.

Note that now an interface exists between the two solids.

#### Internal boundaries by sewing

Shape sewing can also be used to generate shapes that have internal boundaries.

Note that computing the intersection returns a closed shape.

Since the intersection of the two shapes is closed by sewing that closed shape into the union of the shapes we have three internal regions. One in the cylinder on top of the cuboid, one in the cylinder that is inside the cuboid and one in the remaining cuboid.

### Fillets

*OpenCascade* provides functionality to fillet shapes.

It is also possible to fillet only selected edges.

In *OpenCasacde* every face has access to all the edges the face is comprised of. In the case of the cube each face is connected to 4 edges. Since there are 6 faces this makes a total of 24 edges that can be addressed of which 12 are duplicated.

If the requested fillet radius is too large then the filleting will fail.

### Chamfers

Chamfers are similar to fillets. The difference is that chamfers are not rounded but planes.

### Shelling

*OpenCascade* provides functionality to shell shapes.

### De-featuring

*OpenCascade* provides functionality to de-feature shapes.

### Import/Export

*OpenCascade* can read and write various computer aided design relevant file formats. Import and Export of the these file formats is partially implemented.

#### STL Export

*OpenCascade* can export STL files.* *

#### STL Import

*OpenCascade* can import STL files.* *

Note that an import of an STL file with OpenCascadeShapeImport will result in a boundary mesh that has a unique marker assigned to each surface element.

This may not be wanted. To avoid that the options "MarkerMethod""ElementMesh" or "MarkerMethod"None may be specified.

#### Step Export

*OpenCascade* can export STEP files.* *

#### Step Import

*OpenCascade* can import STEP files.* *

#### BRep Export

*OpenCascade* can export BRep files.* *

#### BRep Import

*OpenCascade* can import BRep files.* *

### Possible issues

#### Boolean operation issues

The lowest dimensional object that can be returned from an *OpenCascase* Boolean operation is that of the minimal dimension of any argument given to the Boolean operation. For example, a Boolean operation of two *OpenCascade* solids can not return an *OpenCascade* face object.

A boundary mesh can not be generated because the resulting *OpenCascade* shape intersection does not contain information on the lower dimensional face object.

Consider the case of a face and a cuboid touching.

The lowest dimensional argument to the OpenCascade Boolean intersection operation was the face object. Since the resulting operation is also a face object the object information is present in the resulting shape object and can be meshed.