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>
extern "C" {
struct Point {
double x;
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);
TopoDS_Shape make_point(double x, double y, double z);
void coord_point(const TopoDS_Shape& shape, 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>
Point* make_point(double x, double y, double z) {
gp_Pnt* p = new gp_Pnt(x, y, z);
return reinterpret_cast<Point*>(p);
TopoDS_Shape make_point(double x, double y, double z) {
gp_Pnt point(x, y, z);
return BRepBuilderAPI_MakeVertex(point).Vertex();
}
void free_point(Point* p) {
delete reinterpret_cast<gp_Pnt*>(p);
}
void coord_point(const TopoDS_Shape& shape, double* x, double* y, double* z) {
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) {
const gp_Pnt* gp = reinterpret_cast<const gp_Pnt*>(p);
*x = gp->X();
*y = gp->Y();
*z = gp->Z();
*x = point.X();
*y = point.Y();
*z = point.Z();
}