The Fit Primitive tool is used to create new mesh elements based on an input selection. The tool supports a variety of mesh elements, from simple primitives like squares and cylinders (hence the name) to more complex computational-geometry items like convex hulls. Using this tool, you can even do quick reverse-engineering tasks, see below for examples.  An example of Fit Primitive is shown below. Three areas of the bunny are selected, so three squares are fit, one to each area.


The hotkey for the Fit Primitive tool is p.

The property panel is shown to the right. The Primitive Type field allows you to select what kind of geometric element you wish to select. See below for details. 

The Single Primitive checkbox determines whether one primitive is fit to each selection, or one primitive is fit to all the selected areas combined (example below).

By default, the generated mesh elements are appended to the input mesh. If the Create New Objects box is checked, then instead a new Mesh object is added to the scene for each generated element.

Note that each primitive will have a 3D widget associated with it. You can use this widget to manipulate the primitive, see the Transform page for more details on usage. For some Primitive Types, as you use the widget, the primitive will be automatically re-fit (see below for details).

Primitive Type

Several of the Primitive Type options are quite simple. 

Square mode simply finds a best-fit plane for each selection, and then finds the maximum extent of the selection projected onto that plane, and creates a square with those extents.

Rectangle mode fits the same plane as Square, but sizes the first and second extents separately. The Sphere from plane and Disc from plane modes are similar, using the best-fit plane and then setting the primitive dimensions based on projections onto this plane. 

Cylinder mode fits a cylinder to the selection. One (current) issue wit the Cylinder mode is that our fitting algorithm is often confused if the selection length and diameter are roughly similar. The images below show an example, where initially the cylinder has the incorrect orientation (middle). In this case you can use the 3D widget to rotate the cylinder, and it will in most cases snap to the orientation you intended. If not, you may need to modify your input selection.

The Sphere Best Fit mode tries to find a sphere center and radius that best-fits the input selection. The images below show an example. 


The Linear Sweep mode is more complex than a simple geometric primitive. In this mode, we first find the best-fit bounding box. This gives us an axis direction. We then project the selected vertices onto the plane perpendicular to this axis, and find the 2D Convex Hull of these on-plane points. This convex hull gives us a 2D polygon we can sweep along the axis, to the extents of the selection projected onto the axis. 

The image below shows usage of Linear Sweep mode, applied to the bunny ear. The first image is the default sweep. However as we use the 3D widget to rotate the primitive, we are actually rotating the projection axis, and then the 2D convex hull and extents are recomputed dynamically. So, in the next two images, we have re-oriented the axis (which is alined with the blue arrow in the 3D widget), to produce different linear sweeps.

The Convex Hull primitive type is similarly not a basic geometric primitive. The Convex Hull of a set of points is the smallest 3D convex polyhedral that contains the given set of input points. This is useful for creating coarse approximations to complex shapes. In addition, the Convex Hull of a shape can be quite useful to create things like boxes or jigs/fixtures for complex shapes.


Finding Convex Hulls can be quite computationally intensive, so in the Fit Primitive tool we limit the number of vertices we send into the convex hull. We randomly select a subset of the input vertices (currently at most 5000). So, it is possible that the convex hull we produce does not precisely contain all the input vertices.


Single Primitive

In the example below, we want to fit a cylinder to an area where portions of the cylinder are attached to other shapes. We have selected as much of the cylinder as possible, which has resulted in several disconnected selected regions. By default, the Fit Primitive tool will fit a cylinder to each separate region (middle). If the Single Primitive box is checked, then a single cylinder will be simultaneously fit to all the selected triangles. The result is shown in the right (overlapping with the initial shape).


Reverse Engineering

In the example below, we have used multiple Fit Primitive operations  (as well as a few Boolean operations) to construct a set of simple shapes and primitives that approximate the scan on the left. This kind of basic approximation can be combined with operations like Attract to Target to create structured approximations to scan models.