---
title: Geometry
source: https://infrared.city/docs/sdk/1.0/python/geometry/
---

# Geometry

Mesh utilities for bring-your-own geometry.

`clean_mesh` repairs one mesh: it joins duplicate vertices, drops degenerate and duplicate triangles, and makes the triangle winding consistent and outward-facing.

Notes

You do not need it for correct results: the SDK already cleans every building before it grids facades and roofs (unless a payload sets `mesh_cleaning="off"`). Use it to see what the cleaning does to your mesh, or to make an upload smaller (an unwelded export carries every shared corner once per triangle).

## MeshCleanReport  `dataclass`

What `clean_mesh` did to one mesh.

Attributes:

| Name | Type | Description |
| --- | --- | --- |
| `vertices_welded` | `int` | Input vertices joined into an earlier vertex at the same position. |
| `degenerate_faces_removed` | `int` | Triangles removed because they repeat a vertex or have zero area. |
| `duplicate_faces_removed` | `int` | Triangles removed because they exactly repeat an earlier triangle. |
| `faces_flipped` | `int` | Kept triangles whose winding is the reverse of the input winding. |
| `closed_components` | `int` | Connected parts that form a closed surface (turned outward). |
| `open_components` | `int` | Connected parts with open edges; they keep their authored direction. |
| `non_manifold_edges` | `int` | Edges shared by three or more triangles. |

## CleanedMesh

Bases: `NamedTuple`

The result of `clean_mesh`: flat arrays and the report.

Attributes:

| Name | Type | Description |
| --- | --- | --- |
| `coordinates` | `ndarray` | Flat vertex positions `[x, y, z, ...]`, `float32` or `float64`. |
| `indices` | `ndarray` | Flat triangle vertex indices, little-endian `uint32`. |
| `report` | `[MeshCleanReport](#infrared_sdk.geometry.MeshCleanReport)` | What the cleaning changed. |

## clean_mesh

```python
clean_mesh(coordinates, indices) -> CleanedMesh
```

Clean one mesh the way the SDK cleans each building.

The steps: join vertices at bit-identical positions (`-0.0` equals `+0.0`, no tolerance), drop degenerate and exact duplicate triangles, make the winding consistent (the authored majority wins), and turn closed parts outward. An open part keeps its authored direction.

Warnings

Clean each building on its own: two objects that touch must stay apart.

Parameters:

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `coordinates` | `array_like` | Vertex positions, flat `[x, y, z, ...]` or an `(n, 3)` array. `float64` input stays `float64`; anything else becomes `float32` (the wire precision). | *required* |
| `indices` | `array_like` | Triangle vertex indices, flat or `(m, 3)`. | *required* |

Returns:

| Type | Description |
| --- | --- |
| `[CleanedMesh](#infrared_sdk.geometry.CleanedMesh)` | Flat `coordinates` and `indices` arrays and a `MeshCleanReport`. When nothing changed, the arrays hold the input values. |

Raises:

| Type | Description |
| --- | --- |
| `ValueError` | If a coordinate is not finite, an index is out of range, or an index is not a whole number in `0..2**32-1`. |
