feat: Replace SDF kernel with OpenCASCADE, VTK with pygfx
Major architecture migration: - Remove SDF-based geometry kernel (sdf/) - Remove VTK renderer (drawing_modules/) - Remove old mesh modules (mesh_modules/) New components: - geometry/base.py: Abstract geometry kernel interface - geometry_occ/kernel.py: OpenCASCADE implementation via CadQuery/OCP - geometry_occ/sketch.py: 2D sketching with constraint solving - rendering/base.py: Abstract renderer interface - rendering/pygfx_renderer.py: WebGPU-based renderer - models/data_model.py: Project, Component, Sketch, Body classes - main.py: New Qt-based application Features: - STEP/IGES import/export - Exact BRep geometry (vs approximate SDF mesh) - Parametric sketching with constraints - Boolean operations (union, difference, intersection) - Fillet and chamfer operations - Modern pygfx renderer (~30MB vs VTK ~200MB) Dependencies: - cadquery >= 2.4 - ocp >= 7.9.3 - pygfx >= 0.7.0 - wgpu >= 0.19.0 - PySide6 >= 6.9.0
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
# Fluency CAD 2.0
|
||||
|
||||
A parametric CAD application built on OpenCASCADE Technology (OCCT) with a modern pygfx-based 3D renderer.
|
||||
|
||||
## Features
|
||||
|
||||
- **OpenCASCADE Geometry Kernel**: Industry-standard BRep geometry with exact precision
|
||||
- **STEP/IGES Import/Export**: Full support for industry-standard CAD file formats
|
||||
- **Parametric Sketching**: 2D sketching with constraint solving using CadQuery
|
||||
- **Boolean Operations**: Union, difference, and intersection
|
||||
- **Fillet & Chamfer**: Apply edge treatments to solid bodies
|
||||
- **Modern Renderer**: WebGPU-based rendering with pygfx (smaller footprint than VTK)
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
fluency/
|
||||
├── src/fluency/
|
||||
│ ├── geometry/ # Geometry abstraction layer
|
||||
│ │ └── base.py # Abstract interfaces
|
||||
│ ├── geometry_occ/ # OpenCASCADE implementation
|
||||
│ │ ├── kernel.py # OCGeometryKernel
|
||||
│ │ └── sketch.py # OCCSketch with constraints
|
||||
│ ├── rendering/ # Rendering abstraction
|
||||
│ │ ├── base.py # Abstract renderer
|
||||
│ │ └── pygfx_renderer.py
|
||||
│ ├── models/ # Data models
|
||||
│ │ └── data_model.py # Project, Component, Sketch, Body
|
||||
│ └── main.py # Application entry point
|
||||
├── tests/
|
||||
│ └── test_geometry.py
|
||||
└── pyproject.toml
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# Create virtual environment
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
||||
|
||||
# Install dependencies
|
||||
pip install -e ".[dev]"
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
| Package | Purpose |
|
||||
|---------|---------|
|
||||
| cadquery | High-level OpenCASCADE Python bindings |
|
||||
| ocp | Low-level OpenCASCADE Python bindings |
|
||||
| pygfx | WebGPU-based 3D renderer |
|
||||
| wgpu | WebGPU Python bindings |
|
||||
| PySide6 | Qt GUI framework |
|
||||
| numpy | Numerical computing |
|
||||
| scipy | Scientific computing |
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
# Run the application
|
||||
fluency-cad
|
||||
|
||||
# Or directly
|
||||
python -m fluency.main
|
||||
```
|
||||
|
||||
## API Example
|
||||
|
||||
```python
|
||||
from fluency.geometry_occ.kernel import OCGeometryKernel
|
||||
from fluency.geometry.base import Point2D
|
||||
|
||||
# Create kernel
|
||||
kernel = OCGeometryKernel()
|
||||
|
||||
# Create a sketch
|
||||
points = [
|
||||
Point2D(0, 0),
|
||||
Point2D(10, 0),
|
||||
Point2D(10, 10),
|
||||
Point2D(0, 10),
|
||||
]
|
||||
polygon = kernel.create_polygon(points)
|
||||
|
||||
# Extrude to 3D
|
||||
body = kernel.extrude(polygon, height=20.0)
|
||||
|
||||
# Apply fillet
|
||||
body = kernel.fillet(body, radius=2.0)
|
||||
|
||||
# Export to STEP
|
||||
kernel.export_step(body, "part.step")
|
||||
|
||||
# Export to STL
|
||||
kernel.export_stl(body, "part.stl")
|
||||
```
|
||||
|
||||
## Comparison: Before vs After
|
||||
|
||||
| Aspect | Before (SDF + VTK) | After (OCC + pygfx) |
|
||||
|--------|-------------------|---------------------|
|
||||
| Geometry Precision | Approximate (mesh) | Exact (BRep) |
|
||||
| Export Formats | STL only | STEP, IGES, STL, BREP |
|
||||
| File Size | Large (mesh) | Small (BRep) |
|
||||
| Fillet/Chamfer | Approximate | Exact |
|
||||
| Dependency Size | ~200MB (VTK) | ~30MB (pygfx) |
|
||||
| Constraint Solver | SolveSpace (separate) | CadQuery (integrated) |
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
||||
Reference in New Issue
Block a user