115aa6885f
Type handling is mainly done using templates. Template Slic3r::ClassTraits is used to store info about exported types (perl class name). Currently only perl class name and refference name is used. Template values are initialized by REGISTER_CLASS macro. This macro is used in .cpp file of class ( it needs to be used exactly for each type). Ref<type> class is used to return value as perl reference. Operator overloading is used to make c++ and XSpp happy, only pointer value should be possible to return. Clone<type> class is used to return copy of value ( using new and copy constructor). Copy is created on assigment, this should be probably improved (memory leak on multiple assignments). It is overloaded to be able to return type, type* and type&. Typechecking in ExtrusionEntityCollection updated to check all passed types.
59 lines
1.7 KiB
Plaintext
59 lines
1.7 KiB
Plaintext
%module{Slic3r::XS};
|
|
|
|
%{
|
|
#include <myinit.h>
|
|
#include "BoundingBox.hpp"
|
|
#include "Point.hpp"
|
|
#include "perlglue.hpp"
|
|
%}
|
|
|
|
%name{Slic3r::Geometry::BoundingBox} class BoundingBox {
|
|
~BoundingBox();
|
|
Clone<BoundingBox> clone()
|
|
%code{% RETVAL = THIS; %};
|
|
void merge(BoundingBox* bb) %code{% THIS->merge(*bb); %};
|
|
void merge_point(Point* point) %code{% THIS->merge(*point); %};
|
|
void scale(double factor);
|
|
void translate(double x, double y);
|
|
Polygon* polygon()
|
|
%code{% RETVAL = new Polygon(); THIS->polygon(RETVAL); %};
|
|
Clone<Point> size();
|
|
Clone<Point> center();
|
|
Clone<Point> min_point() %code{% RETVAL = THIS->min; %};
|
|
Clone<Point> max_point() %code{% RETVAL = THIS->max; %};
|
|
double x_min() %code{% RETVAL = THIS->min.x; %};
|
|
double x_max() %code{% RETVAL = THIS->max.x; %};
|
|
double y_min() %code{% RETVAL = THIS->min.y; %};
|
|
double y_max() %code{% RETVAL = THIS->max.y; %};
|
|
|
|
%{
|
|
|
|
BoundingBox*
|
|
new_from_points(CLASS, points)
|
|
char* CLASS
|
|
Points points
|
|
CODE:
|
|
RETVAL = new BoundingBox(points);
|
|
OUTPUT:
|
|
RETVAL
|
|
|
|
%}
|
|
};
|
|
|
|
%name{Slic3r::Geometry::BoundingBoxf3} class BoundingBoxf3 {
|
|
~BoundingBoxf3();
|
|
Clone<BoundingBoxf3> clone()
|
|
%code{% RETVAL = THIS; %};
|
|
void merge(BoundingBoxf3* bb) %code{% THIS->merge(*bb); %};
|
|
void scale(double factor);
|
|
void translate(double x, double y, double z);
|
|
Clone<Pointf3> size();
|
|
Clone<Pointf3> center();
|
|
double x_min() %code{% RETVAL = THIS->min.x; %};
|
|
double x_max() %code{% RETVAL = THIS->max.x; %};
|
|
double y_min() %code{% RETVAL = THIS->min.y; %};
|
|
double y_max() %code{% RETVAL = THIS->max.y; %};
|
|
double z_min() %code{% RETVAL = THIS->min.z; %};
|
|
double z_max() %code{% RETVAL = THIS->max.z; %};
|
|
};
|