import React, { useMemo } from 'react'; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'; import { Slider } from '@/components/ui/slider'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Badge } from '@/components/ui/badge'; import { Separator } from '@/components/ui/separator'; import { useWindStore } from '@/store/appStore'; import { calculateCylinder, type CylinderEndType } from '@/lib/modules/cylinder'; import Cylinder3DViewer from '@/components/three/Cylinder3D'; import SceneCapturePanel from '../components/SceneCapturePanel'; import ExportMenu from '../components/ExportMenu'; import { exportGenericToPDF, type GenericPDFSection } from '../lib/export-generic-pdf'; const CylinderModule: React.FC = () => { const { v0, terrainCategory, structureClass, s2, vk, q, cpi: globalCpi } = useWindStore(); const [diameter, setDiameter] = React.useState(8); const [height, setHeight] = React.useState(20); const [surface, setSurface] = React.useState<'rough' | 'smooth'>('rough'); const [endType, setEndType] = React.useState('closed'); const result = useMemo(() => { return calculateCylinder({ d: diameter, h: height, vk, surface, endType, baseCpi: globalCpi, }); }, [diameter, height, vk, surface, endType, globalCpi]); const handleExportPDF = () => { const sections: GenericPDFSection[] = [ { title: 'Geometria do Cilindro', type: 'grid', gridItems: [ { label: 'Diâmetro (d)', value: `${diameter} m` }, { label: 'Altura (h)', value: `${height} m` }, { label: 'h/d', value: result.hOverD.toFixed(2) }, { label: 'Tipo de Superfície', value: surface === 'rough' ? 'Rugosa' : 'Lisa' }, { label: 'Extremidades', value: endType }, { label: 'Reynolds (Re)', value: result.re.toExponential(2) }, { label: 'Regime', value: result.supercritical ? 'Supercrítico' : 'Subcrítico' }, ], }, { title: 'Pressões na Superfície', type: 'table', tableHeaders: ['Ângulo', 'Cpe', 'p (kN/m²)'], tableRows: result.profile.map((p) => [ `${p.angle}°`, p.cpe.toFixed(2), p.pressureKN_m2.toFixed(3), ]), }, { title: 'Força Resultante', type: 'grid', gridItems: [ { label: 'Força horizontal por unidade de altura', value: `${result.forcePerHeightKN_m.toFixed(2)} kN/m`, }, { label: 'Nota Cpi', value: result.cpiNote }, ], }, ]; exportGenericToPDF('Cilindros', sections); }; return (
{/* Coluna Esquerda: Controles */}
Cilindro Vertical Sec. 6.2.1 — silos, reservatórios, chaminés.
{diameter} m
setDiameter(v[0])} />
{height} m
setHeight(v[0])} />
V₀:{v0} m/s
S₂ (cat. {terrainCategory}, cl. {structureClass}):{s2.toFixed(3)}
Vₖ:{vk.toFixed(2)} m/s
q:{q.toFixed(4)} kN/m²
Reynolds Re:{result.re.toLocaleString('pt-BR')}
h/d:{result.hOverD.toFixed(2)}
Regime:{result.supercritical ? 'supercrítico' : 'subcrítico'}
{/* Coluna Central: 3D */}
h/d = {result.hOverD.toFixed(2)} Re = {result.re.toExponential(2)}
{/* Coluna Direita: Resultados */}
Pressões na Superfície {result.cpiNote}
{result.profile.map((p) => ( ))}
Ângulo Cpe p (kN/m²)
{p.angle}° {p.cpe.toFixed(2)} {p.pressureKN_m2.toFixed(3)}
Força horizontal por unidade de altura: {result.forcePerHeightKN_m.toFixed(2)} kN/m
); }; export default CylinderModule;