<a id="e3d-mesh"></a>

# Mesh

A Mesh is a geometric representation of a 3D surface, a set of connected 3D points.

In an [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html) object, 3 points are connected to define a triangle. This kind of 3D representation is also called a *triangle mesh*.

![image](assets/images/easy3d/basic_concepts_3.webp)![image](assets/images/easy3d/basic_concepts_4.webp)

An [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html) object contains a point cloud and the indexes of the vertices of all mesh triangles. It uses a metric space representation that can be generated from a depth map and that can be used to produce a ZMap.

<a id="e3d-mesh-from-depthmap"></a>

## Generation from a Depth Map

* An [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html) object is generated from a depth map using the class [`EDepthMapToMeshConverter`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EDepthMapToMeshConverter.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EDepthMapToMeshConverter.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EDepthMapToMeshConverter.html).
* Like [`EDepthMapToPointCloudConverter`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EDepthMapToPointCloudConverter.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EDepthMapToPointCloudConverter.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EDepthMapToPointCloudConverter.html), this class uses a calibration model to transform the depth map pixels to 3D world positions. In addition, the depth map pixel connectivity is used to build the triangle mesh. Adjacent pixels produce surface triangles.
* Use the method [`EDepthMapToMeshConverter::SetCalibrationModel`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EDepthMapToMeshConverter.html#a5f8fd90ff288f2e0afc9c13cf2ec4824) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EDepthMapToMeshConverter.html#a02276f00442ba0a5f370f15d827aa0ad) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EDepthMapToMeshConverter.html#a5b07a7a01f79bc4b5416c25886d5837d) to select a calibration model and the method [`EDepthMapToMeshConverter::Convert`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EDepthMapToMeshConverter.html#a5b1f452102fb244a02f7063f676a61fc) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EDepthMapToMeshConverter.html#a99edaa29324268ff34b9e719c7863e9f) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EDepthMapToMeshConverter.html#a11bdf54a2f05f0fe913e9ae1f5b4a2ee) to generate an [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html) from an 8 bits or 16 bits depth map.

<a id="e3d-mesh-from-zmap"></a>

## Generation from a ZMap

* An [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html) object is generated from a ZMap using the class [`EZMapToMeshConverter`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EZMapToMeshConverter.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EZMapToMeshConverter.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EZMapToMeshConverter.html).
* Use the method [`EZMapToMeshConverter::SetMaxEdgeLength`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EZMapToMeshConverter.html#a36a3c00c2c4003d3bc57dac9f7c0fb4a) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EZMapToMeshConverter.html#a726af3d4423290b9ffda82fe4658617b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EZMapToMeshConverter.html#a10ace90a5839d1eb069f225d63ce8d05) to filter out the large triangles from the mesh. These large triangles occur when the colors of two neighboring pixels are very far apart.

<a id="e3d-mesh-from-point-cloud"></a>

## Generation from a Point Cloud

* An [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html) object is generated from a point cloud using the class [`EPointCloudToMeshConverter`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html).
  * The [`EPointCloud`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EPointCloud.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EPointCloud.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EPointCloud.html) is first converted to a ZMap that is then converted to an [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html).
* Use the method [`EPointCloudToMeshConverter::SetProjectionPlane`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html#a3eea7ff440427ba650c2f0e7bd9b1106) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html#a1d2c7b909e8160f0455103f21171659e) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html#a13d6a44c9f685517750583e9e3f09895) to set the projection plane.
* Use the method [`EPointCloudToMeshConverter::SetResolution`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html#a3f91a9950a0a8edef420c9cff3df74ff) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html#a7601fa7a03ae87d55b2dd9c96b97c8fc) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html#ae5ac8c8d5310dc183cd51bf9c71f0b36) to specify the size of the triangles of the mesh.
* Use the method [`EPointCloudToMeshConverter::SetMaxEdgeLength`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html#a8d2370b44b8b1e7f16afb1168e8910e7) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html#a97e20b11a475a51d0e1c20a6d7359fd1) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EPointCloudToMeshConverter.html#af249760ffd7270044ae5fc19e7f022cb) to filter out the large triangles from the mesh.

#### SEE ALSO
[Sample appplication](../../../resources/sample_programs/3d_processing/easy3dpointcloudtomesh.html.md)

<a id="e3d-mesh-access"></a>

## Access and Usage

* In an [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html) object the 3D world positions are stored as an [`EPointCloud`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EPointCloud.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EPointCloud.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EPointCloud.html) (accessible through the method [`EMesh::GetPointCloud`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html#a39ea3f60ae08091be70983859ca54b7f) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html#a5545474941bcf789edb40a5ee2f5182b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html#adb495ec923fae1d6e6244925e7244a98)). The triangle mesh is stored as an array of point indexes, where 3 consecutive indexes define a triangle.
  * The method [`EMesh::GetTriangleIndexes`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html#ac292bdd629792c468a443ac322897d8c) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html#abb0102f82d31159f075c65ba194aedda) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html#ad30366dcbeccfbb0592f3fe72e1751e1) provides a read-only access to the triangle mesh.
  * The normals are stored as an array of [`E3DPoint`](../../../doxygen_cpp/structeVision_1_1Easy3D_1_1E3DPoint.html) [<sub>.NET</sub>](../../../doxygen_cs/structeVision_1_1Easy3D_1_1E3DPoint.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1E3DPoint.html) readable through the [`EMesh::GetNormals`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html#ab1b0cfcc626f142a82be210cf724346e) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html#a8e5f47f2616d6007fd7fa72ddfa4f4c4) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html#a80521cd392e1d6374f6bd04df7cf3af6) method.
* You can use either the proprietary format to save and load [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html) objects using the [`EMesh::Save`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html#a8abc367f757b9a73cedc70bd848958e6) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html#ad34fea1129bfaf2f9b71838b0230070d) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html#adfbee98a7d5caa362631683ee61639d0) and [`EMesh::Load`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html#aed72fc5d0a1ca4818761b4a2c0e57f73) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html#af7a66e2c02e386e2851b16d4e5c47e5c) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html#a040120b7939320deb2d8767a6469dfa6) methods, or use the [STL standard file format](https://en.wikipedia.org/wiki/STL_(file_format)) using the [`EMesh::SaveSTL`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html#a30066db934ce2dc9d50312edf28b6a25) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html#ad1bebdad5bc06b20e4ec63ca05d410b1) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html#a05d4140e35a83ad207942d74a3a1b379) and [`EMesh::LoadSTL`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html#a56e2c95adf3f5a443330222fe4871712) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html#a52c6f5f436efb3389e9f669d009638e2) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html#a926f9268d9be71c1c81889e4545861b5) methods which respectively write to and read from ASCII or binary STL files.
* You can use an [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html) to produce a ZMap (see [“Generating a ZMap”](zmap.html.md#e3d-generating-zmap)). Because an [`EMesh`](../../../doxygen_cpp/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy3D_1_1EMesh.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy3D_1_1EMesh.html) represents a surface, the generated ZMap can show better continuity and less undefined pixels.
