# filipeabperes/py3ode architecture

> Architecture diagram of the GitHub repository filipeabperes/py3ode, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/filipeabperes/py3ode
- Repository: https://github.com/filipeabperes/py3ode

## Overview

##### Main Components

a) Core Bridge Layer:
- Cython (.pyx) files in the src/ directory that serve as the bridge between Python and the C-based ODE
- Components into logical subsystems:
- Physics Core (body.pyx, mass.pyx, world.pyx)
- Geometry System (geoms.pyx, geomobject.pyx, trimesh.pyx)
- Collision Detection (contact.pyx, space.pyx)
- Joint System (joints.pyx)

b) XODE Parser Layer:
- XODE parser components from the xode/ directory
- Relationship between parser components (parser.py, node.py, transform.py)

**[Python Application Layer]**
- ↕
**[Py3ODE Python Interface]**
- ↕
**[Cython Bridge Layer]**
- ↕
**[ODE C Library]**

##### Component Relationships

Use the following conventions:
- Double lines for data transformation flows
- Blue: Python interface components
- Green: Cython bridge components
- Yellow: External ODE library
- Orange: XODE parser components

##### Detailed Component Breakdown

**[XODE Parser System]**
- ↓
**[Physics Components] ← → [Geometry System]**
- ↓
**[Collision Detection] ← → [Joint System]**
- ↓
**[World Simulation]**

##### Implementation Details

a) Core Physics Components:
- World (world.pyx)
- Body (body.pyx)
- Mass (mass.pyx)
- Joints (joints.pyx)

b) Geometry System:
- Basic Geometries (geoms.pyx)
- Trimesh Support (trimesh.pyx, trimeshdata.pyx)
- Height Fields (heightfielddata.pyx)

c) XODE Parser Components:
- Parser (parser.py)
- Node Handler (node.py)
- Transform Processor (transform.py)

##### Notes for Implementation

- The bridge nature of the project (Python ↔ C)
- The separation between physics simulation and geometry handling
- The role of the XODE parser in scene description
- The hierarchical nature of the physics world (World → Bodies → Joints/Geoms)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Python Application Layer"
        PythonApp["Python Application"]
    end

    subgraph "Py3ODE Interface Layer"
        MainBridge["Main Bridge Interface"]:::bridge
        XODESystem["XODE Parser System"]:::parser
    end

    subgraph "Core Physics Layer"
        PhysicsCore["Physics Core Components"]:::core
        GeometrySystem["Geometry System"]:::geometry
        CollisionSystem["Collision Detection"]:::collision
        JointSystem["Joint System"]:::joint
    end

    subgraph "ODE C Library Layer"
        ODELib["Open Dynamics Engine (ODE)"]:::external
    end

    %% XODE Parser Components
    subgraph XODESystem
        Parser["Parser"]:::parser
        NodeHandler["Node Handler"]:::parser
        TransformProc["Transform Processor"]:::parser
        BodyParser["Body Parser"]:::parser
        JointParser["Joint Parser"]:::parser
        GeomParser["Geometry Parser"]:::parser
    end

    %% Physics Core Components
    subgraph PhysicsCore
        World["World System"]:::core
        Body["Body System"]:::core
        Mass["Mass System"]:::core
    end

    %% Geometry System Components
    subgraph GeometrySystem
        GeomObject["Geometry Object Handler"]:::geometry
        GeomPrimitives["Geometry Primitives"]:::geometry
        Trimesh["Trimesh Support"]:::geometry
        HeightField["Height Field System"]:::geometry
    end

    %% Collision System Components
    subgraph CollisionSystem
        Contact["Contact Handler"]:::collision
        Space["Space Management"]:::collision
    end

    %% Relationships
    PythonApp --> MainBridge
    PythonApp --> XODESystem
    MainBridge --> PhysicsCore
    MainBridge --> GeometrySystem
    MainBridge --> CollisionSystem
    MainBridge --> JointSystem
    PhysicsCore --> ODELib
    GeometrySystem --> ODELib
    CollisionSystem --> ODELib
    JointSystem --> ODELib

    %% XODE Parser Relationships
    Parser --> NodeHandler
    Parser --> TransformProc
    Parser --> BodyParser
    Parser --> JointParser
    Parser --> GeomParser
    XODESystem --> PhysicsCore
    XODESystem --> GeometrySystem
    XODESystem --> JointSystem

    %% Component Interactions
    PhysicsCore <--> GeometrySystem
    PhysicsCore <--> CollisionSystem
    PhysicsCore <--> JointSystem
    GeometrySystem <--> CollisionSystem

    %% Styling
    classDef bridge fill:#9BB8ED
    classDef parser fill:#FFB366
    classDef core fill:#85E085
    classDef geometry fill:#85E085
    classDef collision fill:#85E085
    classDef joint fill:#85E085
    classDef external fill:#FFE5CC

    %% Click Events
    click MainBridge "https://github.com/filipeabperes/Py3ODE/blob/master/src/ode.pyx"
    click World "https://github.com/filipeabperes/Py3ODE/blob/master/src/world.pyx"
    click Body "https://github.com/filipeabperes/Py3ODE/blob/master/src/body.pyx"
    click Mass "https://github.com/filipeabperes/Py3ODE/blob/master/src/mass.pyx"
    click GeomObject "https://github.com/filipeabperes/Py3ODE/blob/master/src/geomobject.pyx"
    click GeomPrimitives "https://github.com/filipeabperes/Py3ODE/blob/master/src/geoms.pyx"
    click Trimesh "https://github.com/filipeabperes/Py3ODE/blob/master/src/trimesh.pyx"
    click HeightField "https://github.com/filipeabperes/Py3ODE/blob/master/src/heightfielddata.pyx"
    click Contact "https://github.com/filipeabperes/Py3ODE/blob/master/src/contact.pyx"
    click Space "https://github.com/filipeabperes/Py3ODE/blob/master/src/space.pyx"
    click JointSystem "https://github.com/filipeabperes/Py3ODE/blob/master/src/joints.pyx"
    click Parser "https://github.com/filipeabperes/Py3ODE/blob/master/xode/parser.py"
    click NodeHandler "https://github.com/filipeabperes/Py3ODE/blob/master/xode/node.py"
    click TransformProc "https://github.com/filipeabperes/Py3ODE/blob/master/xode/transform.py"
    click BodyParser "https://github.com/filipeabperes/Py3ODE/blob/master/xode/body.py"
    click JointParser "https://github.com/filipeabperes/Py3ODE/blob/master/xode/joint.py"
    click GeomParser "https://github.com/filipeabperes/Py3ODE/blob/master/xode/geom.py"
```
