Completely replaced the homebrew Pointf3 class with Eigen Vec3d.

Replaced the unscale macro with a template, implemented templates
for unscaling Eigen vectors.
This commit is contained in:
bubnikv 2018-08-21 17:43:05 +02:00
parent c5256bdd2c
commit cb138a20b8
46 changed files with 329 additions and 373 deletions

View file

@ -96,17 +96,17 @@ new_from_points(CLASS, points)
Clone<BoundingBoxf3> clone()
%code{% RETVAL = THIS; %};
void merge(BoundingBoxf3* bb) %code{% THIS->merge(*bb); %};
void merge_point(Pointf3* point) %code{% THIS->merge(*point); %};
void merge_point(Vec3d* point) %code{% THIS->merge(*point); %};
void scale(double factor);
void translate(double x, double y, double z);
void offset(double delta);
bool contains_point(Pointf3* point) %code{% RETVAL = THIS->contains(*point); %};
Clone<Pointf3> size();
Clone<Pointf3> center();
bool contains_point(Vec3d* point) %code{% RETVAL = THIS->contains(*point); %};
Clone<Vec3d> size();
Clone<Vec3d> center();
double radius();
bool empty() %code{% RETVAL = empty(*THIS); %};
Clone<Pointf3> min_point() %code{% RETVAL = THIS->min; %};
Clone<Pointf3> max_point() %code{% RETVAL = THIS->max; %};
Clone<Vec3d> min_point() %code{% RETVAL = THIS->min; %};
Clone<Vec3d> max_point() %code{% RETVAL = THIS->max; %};
double x_min() %code{% RETVAL = THIS->min(0); %};
double x_max() %code{% RETVAL = THIS->max(0); %};
double y_min() %code{% RETVAL = THIS->min(1); %};

View file

@ -55,10 +55,10 @@
int object_idx() const;
int volume_idx() const;
int instance_idx() const;
Clone<Pointf3> origin() const
Clone<Vec3d> origin() const
%code%{ RETVAL = THIS->get_origin(); %};
void translate(double x, double y, double z)
%code%{ THIS->set_origin(THIS->get_origin() + Pointf3(x, y, z)); %};
%code%{ THIS->set_origin(THIS->get_origin() + Vec3d(x, y, z)); %};
Clone<BoundingBoxf3> bounding_box() const
%code%{ RETVAL = THIS->bounding_box; %};
Clone<BoundingBoxf3> transformed_bounding_box() const;

View file

@ -78,15 +78,15 @@ Line::coincides_with(line_sv)
%name{Slic3r::Linef3} class Linef3 {
Linef3(Pointf3* a, Pointf3* b)
Linef3(Vec3d* a, Vec3d* b)
%code{% RETVAL = new Linef3(*a, *b); %};
~Linef3();
Clone<Linef3> clone()
%code{% RETVAL = THIS; %};
Ref<Pointf3> a()
Ref<Vec3d> a()
%code{% RETVAL = &THIS->a; %};
Ref<Pointf3> b()
Ref<Vec3d> b()
%code{% RETVAL = &THIS->b; %};
Clone<Pointf3> intersect_plane(double z);
Clone<Vec3d> intersect_plane(double z);
void scale(double factor);
};

View file

@ -289,9 +289,9 @@ ModelMaterial::attributes()
void set_layer_height_profile(std::vector<double> profile)
%code%{ THIS->layer_height_profile = profile; THIS->layer_height_profile_valid = true; %};
Ref<Pointf3> origin_translation()
Ref<Vec3d> origin_translation()
%code%{ RETVAL = &THIS->origin_translation; %};
void set_origin_translation(Pointf3* point)
void set_origin_translation(Vec3d* point)
%code%{ THIS->origin_translation = *point; %};
bool needed_repair() const;
@ -299,7 +299,7 @@ ModelMaterial::attributes()
int facets_count();
void center_around_origin();
void translate(double x, double y, double z);
void scale_xyz(Pointf3* versor)
void scale_xyz(Vec3d* versor)
%code{% THIS->scale(*versor); %};
void rotate(float angle, Axis axis);
void mirror(Axis axis);

View file

@ -121,10 +121,10 @@ Point::coincides_with(point_sv)
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf", (*THIS)(0), (*THIS)(1)); RETVAL = buf; %};
};
%name{Slic3r::Pointf3} class Pointf3 {
Pointf3(double _x = 0, double _y = 0, double _z = 0);
~Pointf3();
Clone<Pointf3> clone()
%name{Slic3r::Pointf3} class Vec3d {
Vec3d(double _x = 0, double _y = 0, double _z = 0);
~Vec3d();
Clone<Vec3d> clone()
%code{% RETVAL = THIS; %};
double x()
%code{% RETVAL = (*THIS)(0); %};
@ -139,14 +139,14 @@ Point::coincides_with(point_sv)
void set_z(double val)
%code{% (*THIS)(2) = val; %};
void translate(double x, double y, double z)
%code{% *THIS += Pointf3(x, y, z); %};
%code{% *THIS += Vec3d(x, y, z); %};
void scale(double factor)
%code{% *THIS *= factor; %};
double distance_to(Pointf3* point)
double distance_to(Vec3d* point)
%code{% RETVAL = (*point - *THIS).norm(); %};
Pointf3* negative()
%code{% RETVAL = new Pointf3(- *THIS); %};
Pointf3* vector_to(Pointf3* point)
%code{% RETVAL = new Pointf3(*point - *THIS); %};
Vec3d* negative()
%code{% RETVAL = new Vec3d(- *THIS); %};
Vec3d* vector_to(Vec3d* point)
%code{% RETVAL = new Vec3d(*point - *THIS); %};
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%lf,%lf,%lf", (*THIS)(0), (*THIS)(1), (*THIS)(2)); RETVAL = buf; %};
};

View file

@ -16,7 +16,7 @@
void repair();
void WriteOBJFile(char* output_file);
void scale(float factor);
void scale_xyz(Pointf3* versor)
void scale_xyz(Vec3d* versor)
%code{% THIS->scale(*versor); %};
void translate(float x, float y, float z);
void rotate_x(float angle);
@ -33,7 +33,7 @@
ExPolygons horizontal_projection();
Clone<Polygon> convex_hull();
Clone<BoundingBoxf3> bounding_box();
Clone<Pointf3> center()
Clone<Vec3d> center()
%code{% RETVAL = THIS->bounding_box().center(); %};
int facets_count();
void reset_repair_stats();

View file

@ -70,9 +70,9 @@ Pointf* O_OBJECT_SLIC3R
Ref<Pointf> O_OBJECT_SLIC3R_T
Clone<Pointf> O_OBJECT_SLIC3R_T
Pointf3* O_OBJECT_SLIC3R
Ref<Pointf3> O_OBJECT_SLIC3R_T
Clone<Pointf3> O_OBJECT_SLIC3R_T
Vec3d* O_OBJECT_SLIC3R
Ref<Vec3d> O_OBJECT_SLIC3R_T
Clone<Vec3d> O_OBJECT_SLIC3R_T
Line* O_OBJECT_SLIC3R
Ref<Line> O_OBJECT_SLIC3R_T

View file

@ -25,9 +25,9 @@
%typemap{Pointf*};
%typemap{Ref<Pointf>}{simple};
%typemap{Clone<Pointf>}{simple};
%typemap{Pointf3*};
%typemap{Ref<Pointf3>}{simple};
%typemap{Clone<Pointf3>}{simple};
%typemap{Vec3d*};
%typemap{Ref<Vec3d>}{simple};
%typemap{Clone<Vec3d>}{simple};
%typemap{BoundingBox*};
%typemap{Ref<BoundingBox>}{simple};
%typemap{Clone<BoundingBox>}{simple};