# Easy3DMatchMatch

| Support            | ![](assets/images/sample_programs/applies_to/cpp.svg) ![](assets/images/sample_programs/applies_to/cs.svg)   |
|--------------------|--------------------------------------------------------------------------------------------------------------|
| Required licenses  | **Easy3DMatch**                                                                                              |
| Recommended images | The images from the folder `Sample Images/3D/Easy3DMatch/Match`                                              |
| Location           | `3D Processing/Easy3DMatchMatch`                                                                             |

#### NOTE
In the **C#** sample, it is not possible to set all the parameters within the GUI.

## Purpose

The matching consists in aligning the sample on the reference and comparing both to find defects in the sample.

This sample program demonstrates how to:

- Match a sample (point cloud or ZMap) on a reference (3D mesh, point cloud or ZMap).

![](assets/images/sample_programs/3d_processing_easy3dmatchmatch.webp)

## Code highlights

Use the recommended images:

- Reference: `.stl` or `.ply` file with `goldenScan` in the name.
- Sample: `.ply` file with `goldenScan` in the name.
- Both reference and sample files should come from the same folder (`Object 1` or `Object 2`).
- In case of `.ply` reference, they should both contain `top` or both contain `bottom`.

This sample contains many options that are not detailed here. Only the main code path is described here.

1. Set the reference mesh with its viewpoint (azimuth and elevation angle).
   ```c++
   matcher_.SetReference(referenceMesh_, azimuthReference_, elevationReference_);
   ```
2. Perform the matching for the given sample point cloud with its viewpoint and retrieves the result.
   ```c++
   match_ = matcher_.Match(samplePointCloud_, azimuthSample_, elevationSample_);
   ```
3. Retrieve the result of the comparison as a point cloud containing the point-to-point distances between sample and reference.
   ```c++
   matcher_.GetComparisonPointCloud(resultPointCloud_, true, true, showComparisonResultOnReference_, showResultFullModel_);
   ```
4. Highlight the anomalies detected by the `E3DMatcher` in the viewer.
   ```c++
   viewer_.AddRenderSource("anomaly_" + i.ToString(), match_.Anomalies[i].BoundingBox, new EC24(255, 255, 255), 128);
   ```
