Standard_ConstructionError
Standard_ConstructionError is an exception thrown by Open CASCADE Technology (OCCT) when a geometric entity or topological shape cannot be built due to invalid input parameters or violated mathematical constraints.
In the Open CASCADE Technology (OCCT) geometry kernel, Standard_ConstructionError is a foundational exception type indicating that a mathematical, geometric, or topological construction operation has failed. This diagnostic signals that the requested entity is mathematically impossible to instantiate with the provided inputs, or that the operation fundamentally violates the preconditions of the modeling class being invoked. It acts as a strict guard against generating corrupt, non-manifold, or mathematically undefined geometries within an application's modeling environment.
This diagnostic is emitted when developers provide geometrically or mathematically invalid parameters to OCCT constructors and builder APIs. Common triggers include providing a zero or negative radius to circular, cylindrical, or spherical constructors (such as gp_Cylinder or gp_Circ), passing coincident points to line constructors where strictly distinct points are required, specifying incompatible knot vectors for B-Splines, or attempting to construct complex topologies with degenerate geometries without appropriate tolerance thresholds. The underlying algorithms validate these parameters before allocation and raise the exception to halt execution and prevent invalid state.
#include <gp_Cylinder.hxx>
#include <gp_Ax3.hxx>
#include <Standard_ConstructionError.hxx>
#include <iostream>
int main() {
try {
gp_Ax3 axis; // Default origin and axes
Standard_Real invalid_radius = -10.0;
// Throws Standard_ConstructionError because radius is negative
gp_Cylinder cylinder(axis, invalid_radius);
} catch (const Standard_ConstructionError& e) {
std::cerr << "Standard_ConstructionError caught." << std::endl;
return 1;
}
return 0;
}
Ensure that all inputs to OCCT constructors are mathematically valid by actively validating spatial parameters, distances, and radii before invoking geometry builders.
```C++
#include <gp_Cylinder.hxx>
#include <gp_Ax3.hxx>
#include <iostream>
#include <algorithm>
int main() {
gp_Ax3 axis;
Standard_Real requested_radius = -10.0;
// Fix: Validate and constrain the radius before construction
Standard_Real safe_radius = std::max(requested_radius, 0.001);
// Cylinder successfully constructed with valid parameters
gp_Cylinder cylinder(axis, safe_radius);
std::cout << "Cylinder created with radius: " << cylinder.Radius() << std::endl;
return 0;
}
```
Open CASCADE Technology OCCT 7.8.0 — Standard_ConstructionError.hxx — retrieved 2026-08-11