Summary
The orthographic reorder path (ReorderUnorganizedTexture::create_texture_) estimates the mesh's oriented bounding box with vtkOBBTree::ComputeOBB and derives the output image dimensions from the realigned bounds. For degenerate or very small meshes — e.g. a perfectly planar (zero-thickness) sheet, or a mesh with only a handful of vertices — vtkOBBTree returns ill-conditioned/garbage axes. The huge OBB axis then propagates through the realignment transform, so the transformed bounds blow up to ~±DOUBLE_MAX and the computed size overflows:
Output size: 2147483647x2147483647 (Sample rate: 0.05) xLen=2e+38 yLen=2e+38 pts=6 cells=4
which makes cv::Mat::zeros(rows, cols, CV_8UC3) throw OutOfMemoryError (attempts a ~1.4e19-byte allocation).
Repro
Build a tiny flat quad-pair mesh (6 vertices, 4 triangles, all z=0), a valid UV map, and run compute() in the default ProjectionMode::Orthographic. It crashes in the allocation. The ProjectionMode::Camera path with explicit ProjectionParams is unaffected (it does not use vtkOBBTree).
Impact
Real photogrammetry meshes are dense and only "roughly planar," so this hasn't been hit in production — but it makes the orthographic path impossible to exercise with a small synthetic fixture. The multi-texture unit tests added in the #2 fix (ReorderMultiTexture.*) therefore drive the shared sampler via the camera path instead.
Possible fixes
- Validate the computed OBB extents / output dimensions and fail with a clear error (or fall back) when they are non-finite or exceed a sane bound.
- Replace/augment
vtkOBBTree with a more robust OBB (e.g. PCA over vertices with a guard for rank-deficient covariance), so a genuinely planar mesh yields a well-defined in-plane basis + normal.
- Guard
create_texture_ so a degenerate OBB doesn't propagate an infinite transform.
Discovered while implementing #2.
Summary
The orthographic reorder path (
ReorderUnorganizedTexture::create_texture_) estimates the mesh's oriented bounding box withvtkOBBTree::ComputeOBBand derives the output image dimensions from the realigned bounds. For degenerate or very small meshes — e.g. a perfectly planar (zero-thickness) sheet, or a mesh with only a handful of vertices —vtkOBBTreereturns ill-conditioned/garbage axes. The huge OBB axis then propagates through the realignment transform, so the transformed bounds blow up to ~±DOUBLE_MAXand the computed size overflows:which makes
cv::Mat::zeros(rows, cols, CV_8UC3)throwOutOfMemoryError(attempts a ~1.4e19-byte allocation).Repro
Build a tiny flat quad-pair mesh (6 vertices, 4 triangles, all z=0), a valid UV map, and run
compute()in the defaultProjectionMode::Orthographic. It crashes in the allocation. TheProjectionMode::Camerapath with explicitProjectionParamsis unaffected (it does not usevtkOBBTree).Impact
Real photogrammetry meshes are dense and only "roughly planar," so this hasn't been hit in production — but it makes the orthographic path impossible to exercise with a small synthetic fixture. The multi-texture unit tests added in the #2 fix (
ReorderMultiTexture.*) therefore drive the shared sampler via the camera path instead.Possible fixes
vtkOBBTreewith a more robust OBB (e.g. PCA over vertices with a guard for rank-deficient covariance), so a genuinely planar mesh yields a well-defined in-plane basis + normal.create_texture_so a degenerate OBB doesn't propagate an infinite transform.Discovered while implementing #2.