refactor: use BRep topological entity instead of gp_Pnt for Rust

encapsulation
This commit is contained in:
2025-11-08 19:00:33 +01:00
parent 192cd6d8ae
commit 34bde0b847
2 changed files with 16 additions and 20 deletions
+2 -9
View File
@@ -3,13 +3,6 @@
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
extern "C" { extern "C" {
struct Point { TopoDS_Shape make_point(double x, double y, double z);
double x; void coord_point(const TopoDS_Shape& shape, double* x, double* y, double* z);
double y;
double z;
};
Point* make_point(double x, double y, double z);
void free_point(Point* p);
void coord_point(const Point* p, double* x, double* y, double* z);
} }
+14 -11
View File
@@ -1,17 +1,20 @@
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
Point* make_point(double x, double y, double z) { TopoDS_Shape make_point(double x, double y, double z) {
gp_Pnt* p = new gp_Pnt(x, y, z); gp_Pnt point(x, y, z);
return reinterpret_cast<Point*>(p); return BRepBuilderAPI_MakeVertex(point).Vertex();
} }
void free_point(Point* p) { void coord_point(const TopoDS_Shape& shape, double* x, double* y, double* z) {
delete reinterpret_cast<gp_Pnt*>(p); TopoDS_Vertex vertex = TopoDS::Vertex(shape);
} gp_Pnt point = BRep_Tool::Pnt(vertex);
void coord_point(const Point* p, double* x, double* y, double* z) { *x = point.X();
const gp_Pnt* gp = reinterpret_cast<const gp_Pnt*>(p); *y = point.Y();
*x = gp->X(); *z = point.Z();
*y = gp->Y();
*z = gp->Z();
} }