# FreeCAD Entegrasyonu - FikoYT

## 🏗️ Mimari

**Python Flask API** (Port 8090)
- **FreeCAD Library:** Direct integration
- **Headless Rendering:** Xvfb virtual display
- **GPU Support:** NVIDIA CUDA 12.2.0
- **Workers:** Gunicorn (4 workers)

## 🔄 İş Akışı

### 1. STEP Import
```python
# free.py - STEP parser
def parse_step_file(filepath):
    doc = FreeCAD.openDocument(filepath)
    objects = doc.Objects

    # Extract geometry
    for obj in objects:
        if hasattr(obj, 'Shape'):
            volume = obj.Shape.Volume
            area = obj.Shape.Area
```

### 2. Frontend Integration
```typescript
// Dual processing: OCCT-WASM + FreeCAD API
const importer = new FikoImporterSTP(sahne);
const cizim = await importer.stpDosyasiniYukle(file);
sahne.ekle(cizim);
```

## 📊 Analiz Özellikleri

**StepAnalyzer Component:**
- **Volume:** Hacim hesaplama
- **Weight:** Yoğunluk bazlı
- **Dimensions:** XYZ boyutları
- **Product Tree:** Hiyerarşik yapı
- **3D Preview:** Real-time render

## 🎬 Animasyon

**Python Scripts:**
- `freesim-yatay-dikey.py` - Motion simulation
- `freesim-spiral.py` - Path simulation
- `headless_render.py` - Batch render

## 🔗 Backend Endpoints

```
POST /uyar/api/freecad/analyze
→ Output: { file_id, objects, cache_expires_in }

POST /uyar/api-raw/freecad/render-cached
→ Input: { file_id, render_params }
→ Output: glTF/GIF blob
```

## ⚡ Cache Sistemi

- **File ID:** Analiz sonrası cache
- **Expires:** 1 saat otomatik
- **Fast Render:** Tekrar upload yok
- **Memory:** Optimize edilmiş

## ⚠️ Kritik

- **Docker:** Container zorunlu
- **Port:** 8090 açık
- **GPU:** CUDA 12.2.0
- **Format:** .stp/.step max 500MB

---
2025-11-06
