Automatic PartDetection
Intelligent hole detection and parent assignment
Our advanced containment algorithms automatically identify closed shapes and correctly associate holes with their parent parts. No manual preprocessing required—Sheet2Nest handles complex nested geometries with precision and speed.
DetectionPipeline
From raw contours to structured parts with assigned holes
Normalize Contours
Standardize orientation and winding order
All contours are normalized to counter-clockwise (CCW) orientation with positive signed area. This ensures consistent geometric analysis and prevents misclassification of outer shapes and holes.
Sort by Area
Order contours from largest to smallest
Contours are sorted by absolute area in descending order. Larger shapes are processed first as potential outer contours, while smaller shapes are evaluated as potential holes.
AABB Pre-Check
Fast bounding box containment test
Before expensive point-in-polygon calculations, we perform a quick axis-aligned bounding box (AABB) check. If the inner shape's bounding box isn't contained within the outer shape's bounding box, containment is impossible.
Point-in-Polygon Test
Precise geometric containment verification
Using ray-casting algorithm, we test if the inner contour's centroid or key points are contained within the outer contour. This provides accurate containment detection even for complex concave shapes.
Layer Matching
Ensure shapes belong to same layer
Holes must be on the same layer as their parent parts. This prevents incorrect assignments when multiple layers contain overlapping geometries.
Closest Parent Assignment
Assign holes to nearest parent
When multiple outer contours could contain a hole, we assign it to the parent with the minimum area difference (closest fit). This ensures holes are correctly associated with their intended parent parts.
Normalize Contours
Standardize orientation and winding order
All contours are normalized to counter-clockwise (CCW) orientation with positive signed area. This ensures consistent geometric analysis and prevents misclassification of outer shapes and holes.
AABB Pre-Check
Fast bounding box containment test
Before expensive point-in-polygon calculations, we perform a quick axis-aligned bounding box (AABB) check. If the inner shape's bounding box isn't contained within the outer shape's bounding box, containment is impossible.
Layer Matching
Ensure shapes belong to same layer
Holes must be on the same layer as their parent parts. This prevents incorrect assignments when multiple layers contain overlapping geometries.
Sort by Area
Order contours from largest to smallest
Contours are sorted by absolute area in descending order. Larger shapes are processed first as potential outer contours, while smaller shapes are evaluated as potential holes.
Point-in-Polygon Test
Precise geometric containment verification
Using ray-casting algorithm, we test if the inner contour's centroid or key points are contained within the outer contour. This provides accurate containment detection even for complex concave shapes.
Closest Parent Assignment
Assign holes to nearest parent
When multiple outer contours could contain a hole, we assign it to the parent with the minimum area difference (closest fit). This ensures holes are correctly associated with their intended parent parts.
ContainmentAlgorithms
Multi-stage containment testing for accuracy and performance
AABB Pre-Check
Fast bounding box containment
Checks if inner bounding box is fully contained within outer bounding box with tolerance. O(1) complexity.
Ray Casting
Point-in-polygon algorithm
Casts a ray from test point to infinity and counts intersections with polygon edges. O(n) complexity where n is vertex count.
Winding Number
Sum of angles method
Calculates winding number by summing angles around test point. Handles complex concave shapes accurately.
DetectionFeatures
Multi-Hole Support
Detects and assigns multiple holes to a single part
Nested Geometries
Handles complex nested hole structures
Layer Awareness
Respects DXF layer boundaries
Area-Based Sorting
Intelligent parent selection
Tolerance Handling
Robust to floating-point precision issues
Performance Optimized
Fast containment checks with early exits
Before & After Detection
See how automatic part detection transforms raw contours into structured parts
Before Detection
Unorganized contours
After Detection
Structured parts with holes
Ready to Experience Automatic Detection?
Upload your DXF files and watch as Sheet2Nest automatically detects parts and assigns holes—no manual work required.
Start Nesting Now