# Helical Bevel Gear

The purpose of this tutorial is to illustrate the usage of the OpenCascadeLink to greate a helical bevel gear. The shape and the procedure of the creation are based on a computer aided design (CAD) tutorial [1].

The creation of the gear will be done in several stages. First, the shaft is created. As a second step the gear will be made. Both the shaft and the gear will be combined. Following that the bosses are added and lastly the gear will be perforated.

### Shaft

The shaft will be created by specifying a cross section in the X-Z plane. This cross section will then serve as a basis for a solid created from a revolution around the X-axis.

The cross section will consist of three parts, two line segments and a half circle.

Specify a cross section of the shaft:

Note that the orientation of the segments is important. Should the orientation of the segments in the opposite direction the revolution will result in a solid that specifies the region outside of the shaft. If the orientation of a set of segments be in the opposite direction to what is wanted a trick is to revert the axis of revolution in the exact opposite direction. That will avoid respecifying the segments too.

Specify the cross section:
Visualize the cross section of the shaft:
Create OpenCascade objects from the cross section:
Combine the segments into a single wire object

While OpenCascadeShapeUnion could have been used to combine the segments into a single object, OpenCascadeShapeUnion will return a compound and its harder to see what is in a compound.

Next, the cross section will be revolved around a rotation axis along the X-axis.

Create a rotation axis:
Create the rotational sweep of the cross section around the rotation axis:
Inspect the type of the shape object created:

Now that the cross section is rotated the resulting shape is a shell. That is because the input to the rotation was a wire. However, we would like to have a solid.

Create a solid from the shell and inspect the type:

As an alternative, one could have used Polygon for the creation of the cross section. These are face type OpenCascade objects and after a revolution would have returned an OpenCascade solid.

Extract a boundary element mesh:
Visualize the boundary element mesh of the shaft:

To verify that the boundary mesh construction worked as intended, a full element mesh is generated.

Create a full element mesh:

The warning message will disappear if the boundary element mesh is created with a smaller "LinearDeflection" value than the default.

### Gears

The creation of the gear itself will be done in two steps. First half a gear tooth is modeled in the YZ-plane. The half tooth is constructed by combining three sections of circles. This half tooth is then mirrored at an axis to give a complete tooth. The the single tooth is rotated to make a set of gear teeth in the YZ-plane. Once that is done the gear in the YZ-pane is translated, rotated and scaled in a second plane parallel to the YZ-plane. This procedure is repeated one more time to give a third set of teeth in a third plane again parallel to YZ-plane. The actual gear is then created by extruding through the planes. This created a loft.

#### Gear teeth

The gear tooth will be created by intersecting three circles and taking parts of their boundaries.

We start by sketching the procedure of the gear tooth generation in 2D.

Specify the intersection points:
Find the coordinate of the third circle such that is passes through the specified intersection points and has the given radius r3:
Visualize the three circles and the relevant intersections.
Compute the arc angles for the circles from p3:
Visualize the circle arcs that make half a gear tooth:
Mirror the half tooth and rotate the tooth for a full set of gears:

Next, we proceed to put the above insight into 3D. Since the Wolfram language does not have a Circle primitive that can be used in 3D OpenCascadeLink provides one. The primitive allows one to specify coordinates through which the circle should pass.

Compute the end point of the third arc.
Setup the OpenCascade 3D Circle primitives:
Make a single wire from the arc segments:
Inspect the resulting type:

Next, the half tooth is mirrored along the Z-axis.

Set up a rotation transform in the Z-axis direction:
Create the full gear tooth by combining the half tooth and the mirrored half tooth:
Set up a rotation transforms in steps of of 2π/8 in the X-axis direction
Create the gear profile wire in the YZ-axis by multiple rotations of the single tooth around the X-axis:

To visualize the created gear profile in 3D we use a trick to give the flat profile an extension in the X-direction. This is purely for visualization and is not needed for the gear constriction.

Visualize the gear profile in 3D together with the shaft:

#### Make planes

Now, the the gear profile is created that profile can be scaled, rotated and translated to create the gear profiles parallel to each other in the YZ-plane.

Create the second gear profile:
Create the third gear profile:
Visualize the gear profiles:
Construct the full 3D gear by creating surfaces through the gear profiles in the YZ-panes:
Extract a boundary element mesh:
Visualize the boundary element mesh of the gear:

To verify that the boundary mesh construction worked as intended, a full element mesh is generated.

Create a full element mesh:

### Combine

The shaft and the gear are now combined.

Create the union of the shaft and the gear.
Extract a boundary element mesh:
Visualize the boundary element mesh of the union of the shaft and the gear:

To verify that the boundary mesh construction worked as intended, a full element mesh is generated.

Create a full element mesh:

#### Boss

Create a Cuboid that will be used to make the bosses:
Visualize the beveled gear and a single boss:
Verify the the boss does indeed intersect the surface of the shaft properly:
Create 13 bosses:
Form the union of the bosses with the beveled gear:
Extract a boundary element mesh:
Visualize the boundary element mesh of the union of the shaft and the gear:

To verify that the boundary mesh construction worked as intended, a full element mesh is generated.

Create a full element mesh:

#### Hollow shaft

Create a Cylinder to use to perforate the object:
Visualize the beveled gear and the cylinder that is to create the perforation:
Create the difference of the beveled gear and the cylinder:
Extract a boundary element mesh:
Visualize the boundary element mesh of the union of the shaft and the gear:

To verify that the boundary mesh construction worked as intended, a full element mesh is generated.

Create a full element mesh:
Extract a boundary element mesh with a refined surface approximation:
Create a full mesh and visualize the beveled gear:

#### Initialization

The following helper function is to visualize circles in 3D space.