Manifold::Error::InvalidConstruction

Diagnostic signature

InvalidConstruction

The Manifold geometry kernel emits InvalidConstruction when attempting a Boolean operation (such as union, intersection, or difference) where one or more input operands are in an error state. This occurs to prevent evaluating broken geometry and producing inconsistent states.

What it means

When performing Constructive Solid Geometry (CSG) operations like Add, Subtract, Intersect, or SplitByPlane, the Manifold kernel verifies that all input geometries are completely valid. If an operand passed to these operations is fundamentally broken (e.g., initialized with invalid mesh data, producing NotManifold, NonFiniteVertex, or MissingPositionProperties), the kernel safely aborts the operation. Rather than generating broken internal representations or crashing during the Boolean calculation, the kernel returns a new empty Manifold object tagged with the InvalidConstruction error status.

Why it happens

This error status is triggered within the Boolean processing pipeline (such as Boolean3::Result) when propagating failures from underlying geometry evaluation. A common root cause is constructing a Manifold from invalid source data (like an uninitialized or malformed MeshGL). If this construction failure is silently ignored and the resulting invalid object is subsequently used as an operand in an operation like `a + b`, the operation will not proceed. Instead, the kernel intercepts the invalid operand state and sets InvalidConstruction on the resultant geometry. To resolve this, you must trace the failure back to the creation of the specific operand that originally failed.

Minimal reproduction

#include <manifold.h>

using namespace manifold_cad;

int main() {
    // 1. Create an invalid manifold from uninitialized/empty mesh data
    // This operand will have an error status (e.g., MissingPositionProperties).
    MeshGL bad_mesh;
    Manifold bad_operand(bad_mesh);

    // 2. Create a valid standard primitive
    Manifold valid_operand = Manifold::Cube();

    // 3. Attempt a Boolean operation combining the valid and invalid operands.
    // The operation aborts and flags the result as InvalidConstruction.
    Manifold result = bad_operand + valid_operand;

    if (result.Status() == Manifold::Error::InvalidConstruction) {
        return 0; // Reproduction successful
    }
    return 1;
}

How to fix it

Always inspect the .Status() of created or imported geometries before feeding them into Boolean operations. If an operand fails to construct, correct its underlying source data or generation parameters rather than letting the failure propagate.

```C++
#include <manifold.h>
#include <iostream>

using namespace manifold_cad;

int main() {
    // Generate valid meshes for both operands
    Manifold operand_a = Manifold::Cube();
    Manifold operand_b = Manifold::Sphere(1.0);

    // Verify both operands are valid before performing Boolean operations
    if (operand_a.Status() != Manifold::Error::NoError || 
        operand_b.Status() != Manifold::Error::NoError) {
        std::cerr << "Error: Invalid operand geometry detected." << std::endl;
        return 1;
    }

    // The boolean operation will now proceed successfully
    Manifold result = operand_a + operand_b;

    if (result.Status() == Manifold::Error::NoError) {
        std::cout << "Boolean operation successful." << std::endl;
    } else {
        std::cerr << "Unexpected error during operation." << std::endl;
        return 1;
    }

    return 0;
}
```

Step 1

Step 2

Step 3

Upstream references

better error handling · Issue #744 · elalish/manifold

SplitByPlane() doesn't handle empty Manifold objects · Issue #1515 · elalish/manifold