{
  "title": "TriangleMesh",
  "public_path": "flex_rf.tidy3d.TriangleMesh",
  "lookup_path": "tidy3d.TriangleMesh",
  "slug": "flex_rf/tidy3d/TriangleMesh",
  "public_url": "/rf/latest/autogenerated/flex_rf/tidy3d/trianglemesh/",
  "object_kind": "class",
  "introduction": "Custom surface geometry given by a triangle mesh, as in the STL file format.",
  "notes": "",
  "examples": "```python\nvertices = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]])\nfaces = np.array([[1, 2, 3], [0, 3, 2], [0, 1, 3], [0, 2, 1]])\nstl_geom = TriangleMesh.from_vertices_faces(vertices, faces)\n```",
  "references": "",
  "signature": "class TriangleMesh(Geometry, ABC)",
  "source": {
    "path": "flex/public/tidy3d/tidy3d/components/geometry/mesh.py",
    "url": "",
    "lineno": 41,
    "endlineno": 1300
  },
  "bases": [
    "base.Geometry",
    "ABC"
  ],
  "parameter_rows": [
    {
      "name": "mesh_dataset",
      "annotation": "TriangleMeshDataset | None",
      "default": "None",
      "description": "Surface mesh data.",
      "origin": "declared"
    },
    {
      "name": "attrs",
      "annotation": "dict",
      "default": "factory: dict",
      "description": "Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields, `attrs` are mutable. For example, the following is allowed for setting an `attr` `obj.attrs['foo'] = bar`. Also note that Tidy3D will raise a `TypeError` if `attrs` contain objects that can not be serialized. One can check if `attrs` are serializable by calling `obj.model_dump_json()`.",
      "origin": "inherited"
    }
  ],
  "members": [
    {
      "name": "bounds",
      "kind": "function",
      "signature": "bounds()",
      "description": "Returns bounding box min and max coordinates."
    },
    {
      "name": "fill_holes",
      "kind": "function",
      "signature": "fill_holes()",
      "description": "Try to fill holes in the mesh. Can be used to repair non-watertight meshes."
    },
    {
      "name": "fix_normals",
      "kind": "function",
      "signature": "fix_normals()",
      "description": "Try to fix normals to be consistent and outward-facing."
    },
    {
      "name": "fix_winding",
      "kind": "function",
      "signature": "fix_winding()",
      "description": "Try to fix winding in the mesh."
    },
    {
      "name": "from_height_function",
      "kind": "function",
      "signature": "from_height_function(axis: Ax, direction: Literal['-', '+'], base: float, center: tuple[float, float], size: tuple[float, float], grid_size: tuple[int, int], height_func: Callable[[np.ndarray, np.ndarray], np.ndarray])",
      "description": "Construct a TriangleMesh object from analytical expression of height function. The height function should be vectorized to accept 2D meshgrid arrays."
    },
    {
      "name": "from_height_grid",
      "kind": "function",
      "signature": "from_height_grid(axis: Ax, direction: Literal['-', '+'], base: float, grid: tuple[np.ndarray, np.ndarray], height: NDArray)",
      "description": "Construct a TriangleMesh object from grid based height information."
    },
    {
      "name": "from_stl",
      "kind": "function",
      "signature": "from_stl(filename: str, scale: float = 1.0, origin: tuple[float, float, float] = (0, 0, 0), solid_index: int | None = None, **kwargs: Any)",
      "description": "Load a `TriangleMesh` directly from an STL file. The `solid_index` parameter can be used to select a single solid from the file. Otherwise, if the file contains a single solid, it will be loaded as a `TriangleMesh`; if the file contains multiple solids, they will all be loaded as a `GeometryGroup`."
    },
    {
      "name": "from_triangles",
      "kind": "function",
      "signature": "from_triangles(triangles: NDArray)",
      "description": "Create a `TriangleMesh` from a numpy array containing the triangles of a surface mesh."
    },
    {
      "name": "from_trimesh",
      "kind": "function",
      "signature": "from_trimesh(mesh: Trimesh)",
      "description": "Create a `TriangleMesh` from a `trimesh.Trimesh` object."
    },
    {
      "name": "from_vertices_faces",
      "kind": "function",
      "signature": "from_vertices_faces(vertices: NDArray, faces: NDArray)",
      "description": "Create a `TriangleMesh` from numpy arrays containing the data of a surface mesh. The first array contains the vertices, and the second array contains faces formed from triples of the vertices."
    },
    {
      "name": "inside",
      "kind": "function",
      "signature": "inside(x: NDArray, y: NDArray, z: NDArray)",
      "description": "For input arrays `x`, `y`, `z` of arbitrary but identical shape, return an array with the same shape which is `True` for every point in zip(x, y, z) that is inside the volume of the `Geometry`, and `False` otherwise."
    },
    {
      "name": "intersections_plane",
      "kind": "function",
      "signature": "intersections_plane(x: float | None = None, y: float | None = None, z: float | None = None, cleanup: bool = True, quad_segs: int | None = None, section_tolerance_2d: bool = False)",
      "description": "Returns list of shapely geometries at plane specified by one non-None value of x,y,z."
    },
    {
      "name": "intersections_tilted_plane",
      "kind": "function",
      "signature": "intersections_tilted_plane(normal: Coordinate, origin: Coordinate, to_2D: MatrixReal4x4, cleanup: bool = True, quad_segs: int | None = None, section_tolerance_2d: bool = False)",
      "description": "Return a list of shapely geometries at the plane specified by normal and origin."
    },
    {
      "name": "plot",
      "kind": "function",
      "signature": "plot(x: float | None = None, y: float | None = None, z: float | None = None, ax: Ax = None, **patch_kwargs: Any)",
      "description": "Plot geometry cross section at single (x,y,z) coordinate."
    },
    {
      "name": "subdivide_faces",
      "kind": "function",
      "signature": "subdivide_faces(vertices: NDArray, faces: NDArray)",
      "description": "Uniformly subdivide each triangular face by inserting edge midpoints."
    },
    {
      "name": "to_stl",
      "kind": "function",
      "signature": "to_stl(filename: PathLike, *, binary: bool = True)",
      "description": "Export this TriangleMesh to an STL file."
    },
    {
      "name": "triangles",
      "kind": "function",
      "signature": "triangles()",
      "description": "The triangles of the surface mesh as an `np.ndarray`."
    },
    {
      "name": "trimesh",
      "kind": "function",
      "signature": "trimesh()",
      "description": "A `trimesh.Trimesh` object representing the custom surface mesh geometry."
    }
  ],
  "group": "flex_rf.tidy3d"
}
