#pragma once
#include <BRepBuilderAPI_GTransform.hxx>
#include <TopoDS_Shape.hxx>
#include <gp_GTrsf.hxx>
#include <memory>
#include "rust/cxx.h"
inline std::unique_ptr<TopoDS_Shape> fc_gtransform(const TopoDS_Shape& shape,
rust::Slice<const double> matrix)
{
if (shape.IsNull() || matrix.size() < 16) {
return nullptr;
}
try {
gp_GTrsf trsf;
for (int row = 1; row <= 3; ++row) {
for (int column = 1; column <= 4; ++column) {
trsf.SetValue(row, column, matrix[(row - 1) * 4 + (column - 1)]);
}
}
BRepBuilderAPI_GTransform op(shape, trsf, Standard_True);
if (!op.IsDone()) {
return nullptr;
}
const TopoDS_Shape& result = op.Shape();
if (result.IsNull()) {
return nullptr;
}
return std::unique_ptr<TopoDS_Shape>(new TopoDS_Shape(result));
}
catch (...) {
return nullptr;
}
}