FastGeoMesh 1.4.0
See the version list below for details.
dotnet add package FastGeoMesh --version 1.4.0
NuGet\Install-Package FastGeoMesh -Version 1.4.0
<PackageReference Include="FastGeoMesh" Version="1.4.0" />
<PackageVersion Include="FastGeoMesh" Version="1.4.0" />
<PackageReference Include="FastGeoMesh" />
paket add FastGeoMesh --version 1.4.0
#r "nuget: FastGeoMesh, 1.4.0"
#:package FastGeoMesh@1.4.0
#addin nuget:?package=FastGeoMesh&version=1.4.0
#tool nuget:?package=FastGeoMesh&version=1.4.0
FastGeoMesh
🇬🇧 English | 🇫🇷 Français
English
Fast quad meshing for prismatic volumes from 2D footprints and Z elevations.
FastGeoMesh is a high-performance .NET 8 library for generating quad-dominant meshes from 2.5D prismatic structures. Perfect for CAD, GIS, and real-time applications requiring sub-millisecond meshing performance.
⚡ Performance
Sub-millisecond meshing with .NET 8 optimizations + v1.4.0 async improvements:
- Trivial Structures (Async): ~311 μs (78% faster than sync!)
- Simple Structures (Async): ~202 μs (42% faster than sync!)
- Complex Geometry: ~340 μs, 87 KB
- Batch Processing (32 items): 3.3ms parallel vs 7.4ms sequential (2.2x speedup)
- Performance Monitoring: 639ns overhead (negligible)
- Geometry Operations: < 10 μs, zero allocations
Benchmarked on .NET 8.0.20, X64 RyuJIT AVX2, FastGeoMesh v1.4.0-rc1
🚀 Features
- 🏗️ Prism Mesher: Generate side faces and caps from 2D footprints
- ⚡ Async/Parallel Processing: Complete async interface with 2.2x parallel speedup
- 📊 Real-time Monitoring: Performance statistics and complexity estimation
- 🎯 Progress Reporting: Detailed operation tracking with ETA
- 📐 Smart Fast-Paths: Rectangle optimization + generic tessellation fallback
- 🎯 Quality Control: Quad quality scoring & configurable thresholds
- 📑 Triangle Fallback: Optional explicit cap triangles for low-quality quads
- ⚙️ Constraint System: Z-level segments & integrated auxiliary geometry
- 📤 Multi-Format Export: OBJ (quads+triangles), glTF (triangulated), SVG (top view)
- 🔧 Performance Presets: Fast vs High-Quality configurations
- 🧵 Thread-Safe: Immutable structures, stateless meshers
- 🔄 100% Backward Compatible: Existing v1.3.2 code works unchanged
🚀 Quick Start
using FastGeoMesh.Geometry;
using FastGeoMesh.Meshing;
using FastGeoMesh.Structures;
using FastGeoMesh.Meshing.Exporters;
// Define geometry
var poly = Polygon2D.FromPoints(new[]{
new Vec2(0,0), new Vec2(20,0), new Vec2(20,5), new Vec2(0,5)
});
var structure = new PrismStructureDefinition(poly, -10, 10);
// Add constraint at Z = 2.5
structure = structure.AddConstraintSegment(
new Segment2D(new Vec2(0,0), new Vec2(20,0)), 2.5);
// Configure options with preset
var options = MesherOptions.CreateBuilder()
.WithFastPreset() // ~311μs performance (async)
.WithTargetEdgeLengthXY(0.5)
.WithTargetEdgeLengthZ(1.0)
.WithRejectedCapTriangles(true) // Include triangle fallbacks
.Build();
// 🔥 NEW v1.4.0: Ultra-fast async meshing (often faster than sync!)
var mesher = new PrismMesher();
var asyncMesher = (IAsyncMesher)mesher;
var mesh = await asyncMesher.MeshAsync(structure, options);
// 🔥 NEW v1.4.0: Progress reporting
var progress = new Progress<MeshingProgress>(p =>
Console.WriteLine($"{p.Operation}: {p.Percentage:P1}"));
var mesh = await asyncMesher.MeshWithProgressAsync(structure, options, progress);
// 🔥 NEW v1.4.0: Batch processing with 2.2x speedup
var structures = CreateManyStructures();
var meshes = await asyncMesher.MeshBatchAsync(structures, options, maxDegreeOfParallelism: 4);
// Traditional sync approach (still works!)
var syncMesh = mesher.Mesh(structure, options);
var indexed = IndexedMesh.FromMesh(syncMesh, options.Epsilon);
// Export to multiple formats
ObjExporter.Write(indexed, "mesh.obj"); // Quads + triangles
GltfExporter.Write(indexed, "mesh.gltf"); // Triangulated
SvgExporter.Write(indexed, "mesh.svg"); // Top view
🎚️ Performance Presets
// Fast: ~305μs, 87KB - Real-time applications
var fast = MesherOptions.CreateBuilder().WithFastPreset().Build();
// High-Quality: ~1.3ms, 17MB - CAD precision
var quality = MesherOptions.CreateBuilder().WithHighQualityPreset().Build();
🏗️ Advanced Features
Basic Geometry Creation
// Rectangle from corner points
var rect = Polygon2D.FromPoints(new[]{
new Vec2(0,0), new Vec2(10,0), new Vec2(10,5), new Vec2(0,5)
});
// Square helper
var square = Polygon2D.FromPoints(new[]{
new Vec2(0,0), new Vec2(5,0), new Vec2(5,5), new Vec2(0,5)
});
// L-shaped polygon
var lShape = Polygon2D.FromPoints(new[]{
new Vec2(0,0), new Vec2(6,0), new Vec2(6,3),
new Vec2(3,3), new Vec2(3,6), new Vec2(0,6)
});
Complex Structures with Holes
var outer = Polygon2D.FromPoints(new[]{
new Vec2(0,0), new Vec2(10,0), new Vec2(10,6), new Vec2(0,6)
});
var hole = Polygon2D.FromPoints(new[]{
new Vec2(2,2), new Vec2(4,2), new Vec2(4,4), new Vec2(2,4)
});
var structure = new PrismStructureDefinition(outer, 0, 2)
.AddHole(hole);
var options = MesherOptions.CreateBuilder()
.WithHoleRefinement(0.75, 1.0) // Refine near holes
.Build();
// Generate mesh with hole handling
var mesh = new PrismMesher().Mesh(structure, options);
Multiple Z-Level Constraints
var structure = new PrismStructureDefinition(polygon, -5, 5)
.AddConstraintSegment(new Segment2D(new Vec2(0,0), new Vec2(10,0)), -2.5)
.AddConstraintSegment(new Segment2D(new Vec2(0,5), new Vec2(10,5)), 2.5)
.AddConstraintSegment(new Segment2D(new Vec2(5,0), new Vec2(5,5)), 0.0);
// This creates horizontal divisions at specified Z levels
var mesh = new PrismMesher().Mesh(structure, options);
Internal Surfaces (Slabs)
// Add horizontal slab at Z = -2.5 with hole
var slabOutline = Polygon2D.FromPoints(new[]{
new Vec2(1,1), new Vec2(9,1), new Vec2(9,5), new Vec2(1,5)
});
var slabHole = Polygon2D.FromPoints(new[]{
new Vec2(4,2), new Vec2(6,2), new Vec2(6,4), new Vec2(4,4)
});
structure = structure.AddInternalSurface(slabOutline, -2.5, slabHole);
// The slab creates a horizontal platform with its own hole
var mesh = new PrismMesher().Mesh(structure, options);
Quality Control and Triangle Fallback
var options = MesherOptions.CreateBuilder()
.WithTargetEdgeLengthXY(0.5)
.WithMinCapQuadQuality(0.8) // High quality threshold
.WithRejectedCapTriangles(true) // Output triangles for low-quality quads
.Build();
var mesh = new PrismMesher().Mesh(structure, options);
// Check generated content
Console.WriteLine($"Generated {mesh.Quads.Count} quads and {mesh.Triangles.Count} triangles");
Auxiliary Geometry
// Add points and line segments for additional detail
structure.Geometry
.AddPoint(new Vec3(5, 2.5, 0)) // Point at center
.AddPoint(new Vec3(0, 4, 2)) // Elevated point
.AddSegment(new Segment3D(new Vec3(0, 4, 2), new Vec3(20, 4, 2))) // Horizontal beam
.AddSegment(new Segment3D(new Vec3(10, 0, -5), new Vec3(10, 5, 5))); // Vertical support
// Auxiliary geometry affects meshing density around those features
Export with Custom Settings
var indexed = IndexedMesh.FromMesh(mesh, 1e-9); // Custom epsilon for vertex merging
// OBJ export with quads and triangles
ObjExporter.Write(indexed, "output.obj");
// glTF export (always triangulated)
GltfExporter.Write(indexed, "output.gltf");
// SVG export for 2D top view
SvgExporter.Write(indexed, "output.svg");
// Access mesh statistics
Console.WriteLine($"Vertices: {indexed.Vertices.Count}");
Console.WriteLine($"Edges: {indexed.Edges.Count}");
Console.WriteLine($"Quads: {indexed.Quads.Count}");
Console.WriteLine($"Triangles: {indexed.Triangles.Count}");
Error Handling and Validation
try
{
var mesh = new PrismMesher().Mesh(structure, options);
// Validate mesh quality
var adjacency = indexed.BuildAdjacency();
if (adjacency.NonManifoldEdges.Count > 0)
{
Console.WriteLine($"Warning: {adjacency.NonManifoldEdges.Count} non-manifold edges found");
}
}
catch (ArgumentException ex)
{
Console.WriteLine($"Invalid geometry: {ex.Message}");
}
catch (InvalidOperationException ex)
{
Console.WriteLine($"Meshing failed: {ex.Message}");
}
📖 Full Documentation: https://github.com/MabinogiCode/FastGeoMesh
📋 API Reference: https://github.com/MabinogiCode/FastGeoMesh/blob/main/docs/api-reference.md
⚡ Performance Guide: https://github.com/MabinogiCode/FastGeoMesh/blob/main/docs/performance-guide.md
License: MIT
Français
Maillage rapide de quads pour volumes prismatiques à partir d'empreintes 2D et d'élévations Z.
FastGeoMesh est une bibliothèque .NET 8 haute performance pour générer des maillages à dominante quadrilatérale à partir de structures prismatiques 2.5D. Parfaite pour les applications CAO, SIG et temps réel nécessitant des performances de maillage inférieures à la milliseconde.
⚡ Performance
Maillage sous-milliseconde avec optimisations .NET 8 :
- Prisme Simple : ~305 μs, 87 Ko
- Géométrie Complexe : ~340 μs, 87 Ko
- Avec Trous : ~907 μs, 1,3 Mo
- Opérations Géométriques : < 10 μs, zéro allocation
Testé sur .NET 8.0.20, X64 RyuJIT AVX2
🚀 Fonctionnalités
- 🏗️ Mailleur de Prismes : Génère faces latérales et chapeaux depuis empreintes 2D
- ⚡ Async/Parallel Processing: Interface async complète avec 2.2x d'accélération en parallèle
- 📊 Suivi en temps réel : Statistiques de performance et estimation de la complexité
- 🎯 Suivi de Progression : Suivi détaillé des opérations avec ETA
- 📐 Chemins Rapides Intelligents : Optimisation rectangle + tessellation générique
- 🎯 Contrôle Qualité : Scoring qualité des quads & seuils configurables
- 📑 Triangles de Secours : Triangles explicites optionnels pour quads de faible qualité
- ⚙️ Système de Contraintes : Segments de niveau Z & géométrie auxiliaire intégrée
- 📤 Export Multi-Format : OBJ (quads+triangles), glTF (triangulé), SVG (vue de dessus)
- 🔧 Préréglages Performance : Configurations Rapide vs Haute-Qualité
- 🧵 Thread-Safe : Structures immutables, mailleurs sans état
- 🔄 100% Rétro-compatibilité : Le code existant v1.3.2 fonctionne sans changement
🚀 Démarrage Rapide
using FastGeoMesh.Geometry;
using FastGeoMesh.Meshing;
using FastGeoMesh.Structures;
using FastGeoMesh.Meshing.Exporters;
// Définir la géométrie
var poly = Polygon2D.FromPoints(new[]{
new Vec2(0,0), new Vec2(20,0), new Vec2(20,5), new Vec2(0,5)
});
var structure = new PrismStructureDefinition(poly, -10, 10);
// Ajouter contrainte à Z = 2.5
structure = structure.AddConstraintSegment(
new Segment2D(new Vec2(0,0), new Vec2(20,0)), 2.5);
// Configurer options avec préréglage
var options = MesherOptions.CreateBuilder()
.WithFastPreset() // Performance ~311μs
.WithTargetEdgeLengthXY(0.5)
.WithTargetEdgeLengthZ(1.0)
.WithRejectedCapTriangles(true) // Inclure triangles de secours
.Build();
// 🔥 NOUVEAU v1.4.0: Maillage asynchrone ultra-rapide (souvent plus rapide que le sync!)
var mesher = new PrismMesher();
var asyncMesher = (IAsyncMesher)mesher;
var mesh = await asyncMesher.MeshAsync(structure, options);
// 🔥 NOUVEAU v1.4.0: Rapport de progression
var progress = new Progress<MeshingProgress>(p =>
Console.WriteLine($"{p.Operation}: {p.Percentage:P1}"));
var mesh = await asyncMesher.MeshWithProgressAsync(structure, options, progress);
// 🔥 NOUVEAU v1.4.0: Traitement par lots avec 2.2x d'accélération
var structures = CreateManyStructures();
var meshes = await asyncMesher.MeshBatchAsync(structures, options, maxDegreeOfParallelism: 4);
// Approche sync traditionnelle (fonctionne toujours!)
var syncMesh = mesher.Mesh(structure, options);
var indexed = IndexedMesh.FromMesh(syncMesh, options.Epsilon);
// Export vers formats multiples
ObjExporter.Write(indexed, "mesh.obj"); // Quads + triangles
GltfExporter.Write(indexed, "mesh.gltf"); // Triangulé
SvgExporter.Write(indexed, "mesh.svg"); // Vue de dessus
🎚️ Préréglages Performance
// Rapide : ~305μs, 87Ko - Applications temps réel
var rapide = MesherOptions.CreateBuilder().WithFastPreset().Build();
// Haute-Qualité : ~1,3ms, 17Mo - Précision CAO
var qualite = MesherOptions.CreateBuilder().WithHighQualityPreset().Build();
🏗️ Fonctionnalités Avancées
Création de Géométrie de Base
// Rectangle à partir des points de coin
var rect = Polygon2D.FromPoints(new[]{
new Vec2(0,0), new Vec2(10,0), new Vec2(10,5), new Vec2(0,5)
});
// Aide-mémoire pour carré
var square = Polygon2D.FromPoints(new[]{
new Vec2(0,0), new Vec2(5,0), new Vec2(5,5), new Vec2(0,5)
});
// Polygone en forme de L
var lShape = Polygon2D.FromPoints(new[]{
new Vec2(0,0), new Vec2(6,0), new Vec2(6,3),
new Vec2(3,3), new Vec2(3,6), new Vec2(0,6)
});
Structures Complexes avec Trous
var outer = Polygon2D.FromPoints(new[]{
new Vec2(0,0), new Vec2(10,0), new Vec2(10,6), new Vec2(0,6)
});
var hole = Polygon2D.FromPoints(new[]{
new Vec2(2,2), new Vec2(4,2), new Vec2(4,4), new Vec2(2,4)
});
var structure = new PrismStructureDefinition(outer, 0, 2)
.AddHole(hole);
var options = MesherOptions.CreateBuilder()
.WithHoleRefinement(0.75, 1.0) // Affiner près des trous
.Build();
// Générer le maillage avec gestion des trous
var mesh = new PrismMesher().Mesh(structure, options);
Contraintes à Plusieurs Niveaux Z
var structure = new PrismStructureDefinition(polygon, -5, 5)
.AddConstraintSegment(new Segment2D(new Vec2(0,0), new Vec2(10,0)), -2.5)
.AddConstraintSegment(new Segment2D(new Vec2(0,5), new Vec2(10,5)), 2.5)
.AddConstraintSegment(new Segment2D(new Vec2(5,0), new Vec2(5,5)), 0.0);
// Ceci crée des divisions horizontales aux niveaux Z spécifiés
var mesh = new PrismMesher().Mesh(structure, options);
Surfaces Internes (Dalles)
// Ajouter une dalle horizontale à Z = -2.5 avec trou
var slabOutline = Polygon2D.FromPoints(new[]{
new Vec2(1,1), new Vec2(9,1), new Vec2(9,5), new Vec2(1,5)
});
var slabHole = Polygon2D.FromPoints(new[]{
new Vec2(4,2), new Vec2(6,2), new Vec2(6,4), new Vec2(4,4)
});
structure = structure.AddInternalSurface(slabOutline, -2.5, slabHole);
// La dalle crée une plateforme horizontale avec son propre trou
var mesh = new PrismMesher().Mesh(structure, options);
Contrôle de Qualité et Triangle de Secours
var options = MesherOptions.CreateBuilder()
.WithTargetEdgeLengthXY(0.5)
.WithMinCapQuadQuality(0.8) // Seuil de haute qualité
.WithRejectedCapTriangles(true) // Sortir des triangles pour les quads de basse qualité
.Build();
var mesh = new PrismMesher().Mesh(structure, options);
// Vérifier le contenu généré
Console.WriteLine($"Généré {mesh.Quads.Count} quads et {mesh.Triangles.Count} triangles");
Géométrie Auxiliaire
// Ajouter des points et des segments de ligne pour plus de détails
structure.Geometry
.AddPoint(new Vec3(5, 2.5, 0)) // Point au centre
.AddPoint(new Vec3(0, 4, 2)) // Point en surélévation
.AddSegment(new Segment3D(new Vec3(0, 4, 2), new Vec3(20, 4, 2))) // Poutre horizontale
.AddSegment(new Segment3D(new Vec3(10, 0, -5), new Vec3(10, 5, 5))); // Support vertical
// La géométrie auxiliaire affecte la densité de maillage autour de ces caractéristiques
Exportation avec Paramètres Personnalisés
var indexed = IndexedMesh.FromMesh(mesh, 1e-9); // Epsilon personnalisé pour la fusion des sommets
// Export OBJ avec quads et triangles
ObjExporter.Write(indexed, "output.obj");
// Export glTF (toujours triangulé)
GltfExporter.Write(indexed, "output.gltf");
// Export SVG pour vue 2D de dessus
SvgExporter.Write(indexed, "output.svg");
// Accéder aux statistiques du maillage
Console.WriteLine($"Sommets: {indexed.Vertices.Count}");
Console.WriteLine($"Arêtes: {indexed.Edges.Count}");
Console.WriteLine($"Quads: {indexed.Quads.Count}");
Console.WriteLine($"Triangles: {indexed.Triangles.Count}");
Gestion des Erreurs et Validation
try
{
var mesh = new PrismMesher().Mesh(structure, options);
// Valider la qualité du maillage
var adjacency = indexed.BuildAdjacency();
if (adjacency.NonManifoldEdges.Count > 0)
{
Console.WriteLine($"Avertissement: {adjacency.NonManifoldEdges.Count} arêtes non-manifold détectées");
}
}
catch (ArgumentException ex)
{
Console.WriteLine($"Géométrie invalide: {ex.Message}");
}
catch (InvalidOperationException ex)
{
Console.WriteLine($"Échec du maillage: {ex.Message}");
}
📖 Documentation Complète : https://github.com/MabinogiCode/FastGeoMesh
📋 Référence API : https://github.com/MabinogiCode/FastGeoMesh/blob/main/docs/api-reference-fr.md
⚡ Guide Performance : https://github.com/MabinogiCode/FastGeoMesh/blob/main/docs/performance-guide-fr.md
Licence : MIT
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- LibTessDotNet (>= 1.1.15)
- Microsoft.Extensions.ObjectPool (>= 8.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.4.0-rc1: Production-ready async/parallel meshing with 2.4x speedup, real-time monitoring (560ns overhead), progress reporting, complexity estimation, and full cancellation support. 100% backward compatible with v1.3.2. Benchmarks validated: trivial structures 13% faster async, batch processing 2.2x parallel speedup. New IAsyncMesher interface with ValueTask for optimal library performance.