Standard_DimensionError
Standard_DimensionError is an exception in Open CASCADE Technology (OCCT) indicating an operation was attempted on operands, such as matrices, vectors, or arrays, that have incompatible dimensions.
Standard_DimensionError is an exception type in the Open CASCADE Technology (OCCT) C++ framework, specifically inheriting from Standard_DomainError. It serves as a programmatic safeguard to indicate that an operation was invoked on mathematical or geometric entities—such as arrays, matrices, or vectors—whose sizes or spatial dimensions do not meet the mathematical requirements of that operation. In OCCT, encountering this exception means the running process has halted an operation that would otherwise result in undefined behavior or mathematically invalid results.
The OCCT framework explicitly emits this exception during runtime boundary checks when operands have incompatible sizes for a requested operation. Typical triggers include attempting to assign a math_Vector of one length to another of a different length, performing matrix multiplication via math_Matrix::Multiply where inner row-column counts do not match, or supplying mismatched knot and pole arrays when defining B-spline curves and surfaces. The underlying OCCT classes enforce these checks dynamically, comparing the calculated length or bounds of the data structures involved before proceeding with data manipulation.
#include <math_Vector.hxx>
#include <Standard_DimensionError.hxx>
#include <iostream>
int main() {
// Initialize vectors with different lengths
math_Vector vectorA(1, 3);
math_Vector vectorB(1, 2);
try {
// Attempting to assign vectors of different dimensions
vectorA = vectorB;
}
catch (const Standard_DimensionError& e) {
// Standard_DimensionError is raised
std::cerr << "Caught exception: " << e.DynamicType()->Name() << std::endl;
return 1;
}
return 0;
}
Ensure that all vectors, matrices, and arrays involved in the operation have compatible dimensions before execution.
```C++
#include <math_Vector.hxx>
#include <Standard_DimensionError.hxx>
#include <iostream>
int main() {
// Initialize vectors with matching total lengths
math_Vector vectorA(1, 3); // 3 elements
math_Vector vectorB(0, 2); // 3 elements
try {
// Dimensions are compatible (both hold 3 items),
// assignment succeeds despite differing index offsets.
vectorA = vectorB;
std::cout << "Assignment successful." << std::endl;
}
catch (const Standard_DimensionError& e) {
std::cerr << "Caught exception: " << e.DynamicType()->Name() << std::endl;
return 1;
}
return 0;
}
```
Open CASCADE Technology OCCT 7.8.0 — Standard_DimensionError.hxx — retrieved 2026-08-11