Metadata-Version: 2.4
Name: cgal_pycad
Version: 0.1.0
Summary: A Python library for exact 3D geometric modeling using CGAL
Home-page: https://github.com/ctrichet/cgal_pycad
Author: Antigravity
Author-email: example@example.com
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: C++
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

# CGAL PyCAD

![Build Status](https://img.shields.io/badge/pypi-v0.1.0-blue)
![License](https://img.shields.io/badge/license-MIT-green)
![Python](https://img.shields.io/badge/python-3.8%2B-blue)

**CGAL PyCAD** is a Python library for exact 3D geometric modeling, built on top of the powerful [CGAL](https://www.cgal.org/) library. It provides a simple, OpenSCAD-like Domain Specific Language (DSL) for creating constructively solid geometry (CSG) without the floating-point errors common in other CAD tools.

## Features

- **Exact Arithmetic**: All coordinates are handled as exact rational numbers (`CGAL::Gmpq`), ensuring zero precision loss during booleans and transformations.
- **Robust Backend**: Powered by CGAL's `Nef_polyhedron_3`, guaranteeing valid, closed 3D solids.
- **Pythonic wrappers**: Simple, functional API inspired by OpenSCAD.
- **No Floating Point**: The API strictly accepts integers, `fractions.Fraction`, or rational strings/tuples. Floats are explicitly forbidden to prevent accidental precision loss.
- **Export**: Generates standard STL and OFF files for 3D printing and visualization.

## Installation

### Prerequisites

You must have CGAL and a C++ compiler installed on your system.

**Ubuntu/Debian:**
```bash
sudo apt update
sudo apt install libcgal-dev g++ cmake
```

### From PyPI (Coming soon)
```bash
pip install cgal_pycad
```

### From Source
```bash
git clone https://github.com/ctrichet/cgal_pycad.git
cd cgal_pycad
pip install .
```

## Usage

```python
from cgal_pycad import cube, translate, scale
from fractions import Fraction

# Create a base block (100 x 200 x 2)
base = cube([100, 200, 2])

# Create a slot
slot = cube([10, 3, 4])

# Subtract slot from base multiple times
for i in range(5):
    # exact translation
    t_vec = [20*i, -1, -1]
    base = base - translate(t_vec)(slot)

# Scale (anisotropic)
result = base.scale([1, 1, Fraction(1, 2)])

# Export
result.to_stl("output.stl")
```

## Contributing

Contributions are welcome!

1. Fork the repository.
2. Create your feature branch (`git checkout -b feature/amazing-feature`).
3. Commit your changes.
4. Push to the branch.
5. Open a Pull Request.

### Development Setup

```bash
# Create venv
python3 -m venv venv
source venv/bin/activate

# Install build deps
pip install scikit-build cmake ninja pybind11

# Build and install in editable mode
pip install -e .
```

## License

Distributed under the MIT License. See `LICENSE` for more information.
