> ## Documentation Index
> Fetch the complete documentation index at: https://support.lumafield.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Compare Tool

> Quantify and visualize deviations between a scan and a CAD model, or between two scans

## Summary

The Compare Tool is a versatile and powerful analysis capability in Voyager that can be used to assess overall dimensional deviations in a variety of applications. For example:

1. Comparing a scan of a part with the CAD model that was used to make it to understand both global and local dimensional deviations.
2. Comparing two scans of the same part to characterize wear over time or the impact of accelerated lifetime testing.
3. Comparing different instances of the same part to quantify differences between injection mold cavities or differences between different vendors.

## Preparing Your CAD (or Nominal) Mesh

The **Nominal Mesh** represents either design intent, in the case of comparing a scan to CAD, or the state that you want to compare the analysis Mesh to (before use in the case of wear testing, for example).

If creating a Nominal Mesh from a CAD tool:

<Steps>
  <Step title="Isolate Your Part">
    In your CAD tool, isolate the body that you would like to use for the analysis.
  </Step>

  <Step title="Export the body as an STL">
    Ensure that the mesh contains enough polygons to properly resolve curves.  CAD tools often default to a low polygon count when exporting CAD models (left) - the middle image illustrates a low polygon count while the right image illustrates a sufficiently high polygon count.  If you have access to the mesh generation parameters in your CAD tool, set the "surface deviation" to a value of 0.001 mm or lower.  This will reduce error from tessellating the CAD model.

    <img height="200" src="https://mintcdn.com/lumafield/iD2sgKuz7BoMpq7k/images/comparison-mesh-poly-count.png?fit=max&auto=format&n=iD2sgKuz7BoMpq7k&q=85&s=65a8dbe739c6bd5bb0fb216e3e711450" data-path="images/comparison-mesh-poly-count.png" />
  </Step>

  <Step title="Import the STL into your Voyager Project.">
    Use the [Import Tool](/voyager/voyager-import) to load your external Mesh into the Project. Be sure to set the units to the **same units** that were used in the CAD tool that you exported from.

    <Frame>
      <img src="https://mintcdn.com/lumafield/m5QGN5HaY0IKqsU9/images/Compare_Import_Icon.png?fit=max&auto=format&n=m5QGN5HaY0IKqsU9&q=85&s=e781f67330e7e0402f75a1e01fce444c" alt="Compare Icon" width="1610" height="366" data-path="images/Compare_Import_Icon.png" />
    </Frame>
  </Step>
</Steps>

## Preparing Your Analysis Mesh

The **Analysis Mesh** or **Mesh to Analyze** is the Mesh that you would like to characterize.  Typically this Mesh is generated in Voyager from CT scan data using Voyager's [Mesh Tool](/voyager/voyager-mesh-tool).  Meshes from third-party scanners (like structured light scanners) can also be imported and used as an Analysis Mesh.

## Running the Workflow

<Steps>
  <Step title="Select the Compare button in the Toolbar">
    <img height="200" className="hidden dark:block" src="https://mintcdn.com/lumafield/iD2sgKuz7BoMpq7k/images/comparison-click-compare.png?fit=max&auto=format&n=iD2sgKuz7BoMpq7k&q=85&s=97e16e742c3bddb9b148468249625dd3" data-path="images/comparison-click-compare.png" />

    <img height="200" className="dark:hidden" src="https://mintcdn.com/lumafield/m5QGN5HaY0IKqsU9/images/Compare_Compare_Icon.png?fit=max&auto=format&n=m5QGN5HaY0IKqsU9&q=85&s=36bac413fd767c4c6f7e5123cb724ae1" data-path="images/Compare_Compare_Icon.png" />
  </Step>

  <Step title="Select the Mesh you would like to analyze">
    <Frame>
      <img src="https://mintcdn.com/lumafield/m5QGN5HaY0IKqsU9/images/Compare_Mesh_To_Analyze.png?fit=max&auto=format&n=m5QGN5HaY0IKqsU9&q=85&s=0feb71fa848509c45c72a168eef40c02" alt="Compare Mesh To Analyze" title="Compare Mesh To Analyze" style={{ width:"40%" }} width="1008" height="1236" data-path="images/Compare_Mesh_To_Analyze.png" />
    </Frame>
  </Step>

  <Step title="Select your nominal Mesh">
    <Frame>
      <img src="https://mintcdn.com/lumafield/m5QGN5HaY0IKqsU9/images/Compare_Nominal_Mesh.png?fit=max&auto=format&n=m5QGN5HaY0IKqsU9&q=85&s=c7fdcf8da333963da1920dcf78ff7ab7" alt="Compare Nominal Mesh" style={{ width:"40%" }} width="1020" height="1234" data-path="images/Compare_Nominal_Mesh.png" />
    </Frame>
  </Step>

  <Step title="Coarsely align the Meshes">
    Using the rotation handles in the view ports, rotate the analysis Mesh until it is approximately aligned with the nominal Mesh.  This does not have to be perfect as we will next run a fine automatic alignment to more precisely align the two Meshes.

    <video src="https://mintcdn.com/lumafield/m5QGN5HaY0IKqsU9/images/Compare_Coarse_Align.mp4?fit=max&auto=format&n=m5QGN5HaY0IKqsU9&q=85&s=e9a19eaed3adc62adf293508e9dba08b" controls={true} data-path="images/Compare_Coarse_Align.mp4" />
  </Step>

  <Step title="Run auto-alignment">
    Auto alignment performs a global best fit alignment.  This works well when the deviations between parts are small, but may require some manual adjustments if there are large differences between parts or if it is important to align to a specific feature or datum.

    <video src="https://mintcdn.com/lumafield/m5QGN5HaY0IKqsU9/images/Compare_Auto_Align.mp4?fit=max&auto=format&n=m5QGN5HaY0IKqsU9&q=85&s=c5884a9a4ac80f8af4eca2d838d6bd54" controls={true} data-path="images/Compare_Auto_Align.mp4" />
  </Step>

  <Step title="Submit the comparison">
    Once you are satisfied with your alignment, click "Submit" to send the analysis to the Lumafield Cloud for computation. Results are typically available within 1-10 minutes.

    <Frame>
      <img src="https://mintcdn.com/lumafield/m5QGN5HaY0IKqsU9/images/Compare_Submit.gif?s=7bcb7747c6b7db4f63c53fa089d53236" alt="Compare Submit" width="3024" height="1650" data-path="images/Compare_Submit.gif" />
    </Frame>
  </Step>
</Steps>

## Visualizing and Interpreting Results

### 3D

The Compare Tool maps deviations between the Analysis and the Nominal meshes onto the Analysis Mesh and displays a heatmap visualization.  Red corresponds to positive deviations, meaning regions in which the analysis Mesh deviates away from the nominal Mesh. Blue corresponds to areas with negative deviation, ie, material is absent relative to the nominal Mesh.

<Frame>
  <img src="https://mintcdn.com/lumafield/m5QGN5HaY0IKqsU9/images/Compare_3D.png?fit=max&auto=format&n=m5QGN5HaY0IKqsU9&q=85&s=49bb17af51872e35ff12078b18bc3038" alt="Compare 3D" width="3024" height="1652" data-path="images/Compare_3D.png" />
</Frame>

### Probe Tool

Clicking anywhere on a Compare analysis result will activate the probe Tool, measuring the deviation at that location. The mean deviation and the number of polygons being sampled by the probe are displayed in the lower left hand corner, near the color bar.

<img height="200" src="https://mintcdn.com/lumafield/iD2sgKuz7BoMpq7k/images/comparison-probe-tool.gif?s=f24ef2e5c7a08094960c449150b81c32" data-path="images/comparison-probe-tool.gif" />

By adjusting the slider in the Attributes Panel, the size of the probe sphere can be changed to capture more or fewer polygons.

<img height="200" src="https://mintcdn.com/lumafield/iD2sgKuz7BoMpq7k/images/comparison-probe-tool-radius.gif?s=cb68d15da470e676761389fd7be6ed70" data-path="images/comparison-probe-tool-radius.gif" />

<Warning>
  Be aware that because the probe is spherical, it is possible to include features that might affect the mean deviation.
</Warning>

<img height="200" src="https://mintcdn.com/lumafield/iD2sgKuz7BoMpq7k/images/comparison-probe-tool-radius-caution.gif?s=1c771c7b5b56c9cd067409d71ef3f512" data-path="images/comparison-probe-tool-radius-caution.gif" />

### 2D

Comparative analysis results can also be reviewed in 2D.  To enter 2D mode, select "Source Meshes Aligned" from the "Visualize" dropdown menu in the Attributes Panel.

<Frame>
  <img src="https://mintcdn.com/lumafield/m5QGN5HaY0IKqsU9/images/Compare_Source_Meshes_Aligned.png?fit=max&auto=format&n=m5QGN5HaY0IKqsU9&q=85&s=cb8ac4f2fd9b1ba2b9f5a9675b4b6387" alt="Compare Source Meshes Aligned" width="2016" height="1580" data-path="images/Compare_Source_Meshes_Aligned.png" />
</Frame>

In 2D mode, you can adjust 3D visualization settings for the analysis and nominal meshes:

<Frame>
  <img src="https://mintcdn.com/lumafield/m5QGN5HaY0IKqsU9/images/Compare_Transparent.gif?s=ef21b828a36623579183c7da280921d6" alt="Compare Transparent" width="3024" height="1650" data-path="images/Compare_Transparent.gif" />
</Frame>

By selecting slices from the dropdown menu, you can inspect the comparison in 2D and use [Inspection Planes](/voyager/voyager-inspection-planes) to apply measurements

<img height="200" src="https://mintcdn.com/lumafield/iD2sgKuz7BoMpq7k/images/comparison-2d-select-slice.png?fit=max&auto=format&n=iD2sgKuz7BoMpq7k&q=85&s=91cfb6c6e83f8d560fe4d4dc23a54c8c" data-path="images/comparison-2d-select-slice.png" />

<img height="200" src="https://mintcdn.com/lumafield/iD2sgKuz7BoMpq7k/images/comparison-2d-inspection-plane.png?fit=max&auto=format&n=iD2sgKuz7BoMpq7k&q=85&s=7be8427be4a89ffd206168fb547ea5c8" data-path="images/comparison-2d-inspection-plane.png" />

## Troubleshooting and Common Problems

### Histogram just has one skinny spike

Every vertex in a Mesh is included in a comparison analysis, so if your analysis Mesh has extraneous pieces of Mesh or has voids (say in the case of a casting or injection molded component) or stray pieces of Mesh, distances will be computed between the nominal surface and these surfaces as well.

The impact of this effect can be reduced via two methods:

1. Use the rangemapper to exclude outliers.  This can be accomplished by switching the rangemapper to log mode (upper right hand button) and then specifying new limits that better fit the distribution of deviations.

<img height="200" src="https://mintcdn.com/lumafield/iD2sgKuz7BoMpq7k/images/comparison-rangemapper-range.png?fit=max&auto=format&n=iD2sgKuz7BoMpq7k&q=85&s=58ff3e38b932550c296febf9b49c9a0b" data-path="images/comparison-rangemapper-range.png" />

2. Export the analysis Mesh and clean it in a 3rd party Tool like Meshlab to remove disconnected bodies or to trim extraneous surfaces.  Re-Upload and re-compute your analysis.

### "Stripes" in the comparison results

"Stripes" in a comparative analysis result like the example below are due to too low a polygon count on the nominal mesh.  If using a CAD tool to export an STL of the nominal part, increase the number of polygons.  If using a scan mesh, re-export with a higher polygon count.

<img height="200" src="https://mintcdn.com/lumafield/iD2sgKuz7BoMpq7k/images/comparison-with-low-poly-mesh.png?fit=max&auto=format&n=iD2sgKuz7BoMpq7k&q=85&s=81eab26d00a51b5bc14fd2ed5974a10d" data-path="images/comparison-with-low-poly-mesh.png" />
