Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:CARLA simulator Carla Triangulation

From Leeroopedia
Revision as of 12:15, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/CARLA_simulator_Carla_Triangulation.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Geometry, Mesh Generation
Last Updated 2026-02-15 05:00 GMT

Overview

Triangulation.h provides the triangulation lookup table and function used by the Marching Cubes mesh reconstruction algorithm to convert cube intersection data into triangle meshes.

Description

This header defines the Triangulate function within the MeshReconstruction namespace and contains a large static lookup table (signConfigToTriangles) that maps each of the 256 possible sign configurations of a marching cube's 8 vertices to a list of triangle indices. Each entry in the 256x16 array encodes up to 5 triangles (3 indices each), with -1 indicating unused slots. The triangulation function takes intersection information from a cube, a gradient function, and appends the resulting triangles to a mesh.

Usage

This file is used internally by the Marching Cubes mesh reconstruction pipeline. It should not be included directly by client code; instead, include MeshReconstruction.h which orchestrates the full reconstruction process including triangulation.

Code Reference

Source Location

  • Repository: CARLA
  • File: LibCarla/source/third-party/marchingcube/Triangulation.h

Signature

namespace MeshReconstruction
{
  void Triangulate(
      IntersectInfo const &intersect,
      Fun3v const &grad,
      Mesh &mesh);
}

// Lookup table: 256 sign configurations -> triangle indices
const int signConfigToTriangles[256][16];

Import

#include "third-party/marchingcube/Triangulation.h"

I/O Contract

Parameter Type Direction Description
intersect IntersectInfo const & In Sign configuration and edge-vertex intersection data from a cube
grad Fun3v const & In Gradient function for computing vertex normals
mesh Mesh & In/Out Output mesh to which triangles, vertices, and normals are appended

Usage Examples

// Typically called from the MarchCube pipeline:
MeshReconstruction::Cube cube({min, cubeSize}, sdf);
auto intersect = cube.Intersect(isoLevel);
MeshReconstruction::Triangulate(intersect, sdfGrad, mesh);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment