mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-14 08:18:10 +08:00
Changed the Slic3r coordinate type from long to int32 to match
the point type on Windows / Linux / OSX to achieve the same behavior on all the 32 / 64bit systems. (Windows always treats the long as 32bit int, while Linux treats long as a 64bit int).
This commit is contained in:
parent
adc9e749c4
commit
47d904a628
@ -171,12 +171,11 @@ stl_scale(stl_file *stl, float factor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void calculate_normals(stl_file *stl) {
|
static void calculate_normals(stl_file *stl) {
|
||||||
long i;
|
|
||||||
float normal[3];
|
float normal[3];
|
||||||
|
|
||||||
if (stl->error) return;
|
if (stl->error) return;
|
||||||
|
|
||||||
for(i = 0; i < stl->stats.number_of_facets; i++) {
|
for(uint32_t i = 0; i < stl->stats.number_of_facets; i++) {
|
||||||
stl_calculate_normal(normal, &stl->facet_start[i]);
|
stl_calculate_normal(normal, &stl->facet_start[i]);
|
||||||
stl_normalize_vector(normal);
|
stl_normalize_vector(normal);
|
||||||
stl->facet_start[i].normal.x = normal[0];
|
stl->facet_start[i].normal.x = normal[0];
|
||||||
@ -381,7 +380,6 @@ stl_mirror_xz(stl_file *stl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static float get_volume(stl_file *stl) {
|
static float get_volume(stl_file *stl) {
|
||||||
long i;
|
|
||||||
stl_vertex p0;
|
stl_vertex p0;
|
||||||
stl_vertex p;
|
stl_vertex p;
|
||||||
stl_normal n;
|
stl_normal n;
|
||||||
@ -396,7 +394,7 @@ static float get_volume(stl_file *stl) {
|
|||||||
p0.y = stl->facet_start[0].vertex[0].y;
|
p0.y = stl->facet_start[0].vertex[0].y;
|
||||||
p0.z = stl->facet_start[0].vertex[0].z;
|
p0.z = stl->facet_start[0].vertex[0].z;
|
||||||
|
|
||||||
for(i = 0; i < stl->stats.number_of_facets; i++) {
|
for(uint32_t i = 0; i < stl->stats.number_of_facets; i++) {
|
||||||
p.x = stl->facet_start[i].vertex[0].x - p0.x;
|
p.x = stl->facet_start[i].vertex[0].x - p0.x;
|
||||||
p.y = stl->facet_start[i].vertex[0].y - p0.y;
|
p.y = stl->facet_start[i].vertex[0].y - p0.y;
|
||||||
p.z = stl->facet_start[i].vertex[0].z - p0.z;
|
p.z = stl->facet_start[i].vertex[0].z - p0.z;
|
||||||
|
@ -32,8 +32,7 @@ public:
|
|||||||
coord_t x;
|
coord_t x;
|
||||||
coord_t y;
|
coord_t y;
|
||||||
Point(coord_t _x = 0, coord_t _y = 0): x(_x), y(_y) {};
|
Point(coord_t _x = 0, coord_t _y = 0): x(_x), y(_y) {};
|
||||||
Point(int _x, int _y): x(_x), y(_y) {};
|
Point(int64_t _x, int64_t _y): x(coord_t(_x)), y(coord_t(_y)) {}; // for Clipper
|
||||||
Point(long long _x, long long _y): x(coord_t(_x)), y(coord_t(_y)) {}; // for Clipper
|
|
||||||
Point(double x, double y);
|
Point(double x, double y);
|
||||||
static Point new_scale(coordf_t x, coordf_t y) { return Point(coord_t(scale_(x)), coord_t(scale_(y))); }
|
static Point new_scale(coordf_t x, coordf_t y) { return Point(coord_t(scale_(x)), coord_t(scale_(y))); }
|
||||||
|
|
||||||
@ -271,23 +270,6 @@ template<typename TO> inline TO convert_to(const Pointf3 &src) { return TO(typen
|
|||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#include <boost/polygon/polygon.hpp>
|
#include <boost/polygon/polygon.hpp>
|
||||||
namespace boost { namespace polygon {
|
namespace boost { namespace polygon {
|
||||||
template <>
|
|
||||||
struct geometry_concept<coord_t> { typedef coordinate_concept type; };
|
|
||||||
|
|
||||||
/* Boost.Polygon already defines a specialization for coordinate_traits<long> as of 1.60:
|
|
||||||
https://github.com/boostorg/polygon/commit/0ac7230dd1f8f34cb12b86c8bb121ae86d3d9b97 */
|
|
||||||
#if BOOST_VERSION < 106000
|
|
||||||
template <>
|
|
||||||
struct coordinate_traits<coord_t> {
|
|
||||||
typedef coord_t coordinate_type;
|
|
||||||
typedef long double area_type;
|
|
||||||
typedef long long manhattan_area_type;
|
|
||||||
typedef unsigned long long unsigned_area_type;
|
|
||||||
typedef long long coordinate_difference;
|
|
||||||
typedef long double coordinate_distance;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct geometry_concept<Slic3r::Point> { typedef point_concept type; };
|
struct geometry_concept<Slic3r::Point> { typedef point_concept type; };
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
#define SLIC3R_VERSION "1.39.0"
|
#define SLIC3R_VERSION "1.39.0"
|
||||||
#define SLIC3R_BUILD "UNKNOWN"
|
#define SLIC3R_BUILD "UNKNOWN"
|
||||||
|
|
||||||
typedef long coord_t;
|
typedef int32_t coord_t;
|
||||||
typedef double coordf_t;
|
typedef double coordf_t;
|
||||||
|
|
||||||
//FIXME This epsilon value is used for many non-related purposes:
|
//FIXME This epsilon value is used for many non-related purposes:
|
||||||
// For a threshold of a squared Euclidean distance,
|
// For a threshold of a squared Euclidean distance,
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
double radius();
|
double radius();
|
||||||
Clone<Point> min_point() %code{% RETVAL = THIS->min; %};
|
Clone<Point> min_point() %code{% RETVAL = THIS->min; %};
|
||||||
Clone<Point> max_point() %code{% RETVAL = THIS->max; %};
|
Clone<Point> max_point() %code{% RETVAL = THIS->max; %};
|
||||||
long x_min() %code{% RETVAL = THIS->min.x; %};
|
int x_min() %code{% RETVAL = THIS->min.x; %};
|
||||||
long x_max() %code{% RETVAL = THIS->max.x; %};
|
int x_max() %code{% RETVAL = THIS->max.x; %};
|
||||||
long y_min() %code{% RETVAL = THIS->min.y; %};
|
int y_min() %code{% RETVAL = THIS->min.y; %};
|
||||||
long y_max() %code{% RETVAL = THIS->max.y; %};
|
int y_max() %code{% RETVAL = THIS->max.y; %};
|
||||||
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min.x, THIS->min.y, THIS->max.x, THIS->max.y); RETVAL = buf; %};
|
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld;%ld,%ld", THIS->min.x, THIS->min.y, THIS->max.x, THIS->max.y); RETVAL = buf; %};
|
||||||
bool defined() %code{% RETVAL = THIS->defined; %};
|
bool defined() %code{% RETVAL = THIS->defined; %};
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ BridgeDetector*
|
|||||||
BridgeDetector::new(expolygon, lower_slices, extrusion_width)
|
BridgeDetector::new(expolygon, lower_slices, extrusion_width)
|
||||||
ExPolygon* expolygon;
|
ExPolygon* expolygon;
|
||||||
ExPolygonCollection* lower_slices;
|
ExPolygonCollection* lower_slices;
|
||||||
long extrusion_width;
|
int extrusion_width;
|
||||||
CODE:
|
CODE:
|
||||||
RETVAL = new BridgeDetector(*expolygon, *lower_slices, extrusion_width);
|
RETVAL = new BridgeDetector(*expolygon, *lower_slices, extrusion_width);
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
@ -33,7 +33,7 @@ BridgeDetector*
|
|||||||
BridgeDetector::new_expolygons(expolygons, lower_slices, extrusion_width)
|
BridgeDetector::new_expolygons(expolygons, lower_slices, extrusion_width)
|
||||||
ExPolygonCollection* expolygons;
|
ExPolygonCollection* expolygons;
|
||||||
ExPolygonCollection* lower_slices;
|
ExPolygonCollection* lower_slices;
|
||||||
long extrusion_width;
|
int extrusion_width;
|
||||||
CODE:
|
CODE:
|
||||||
RETVAL = new BridgeDetector(expolygons->expolygons, *lower_slices, extrusion_width);
|
RETVAL = new BridgeDetector(expolygons->expolygons, *lower_slices, extrusion_width);
|
||||||
OUTPUT:
|
OUTPUT:
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
float spacing();
|
float spacing();
|
||||||
float spacing_to(Flow* other)
|
float spacing_to(Flow* other)
|
||||||
%code{% RETVAL = THIS->spacing(*other); %};
|
%code{% RETVAL = THIS->spacing(*other); %};
|
||||||
long scaled_width();
|
int scaled_width();
|
||||||
long scaled_spacing();
|
int scaled_spacing();
|
||||||
double mm3_per_mm();
|
double mm3_per_mm();
|
||||||
%{
|
%{
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
%}
|
%}
|
||||||
|
|
||||||
%name{Slic3r::Point} class Point {
|
%name{Slic3r::Point} class Point {
|
||||||
Point(long _x = 0, long _y = 0);
|
Point(int _x = 0, int _y = 0);
|
||||||
~Point();
|
~Point();
|
||||||
Clone<Point> clone()
|
Clone<Point> clone()
|
||||||
%code{% RETVAL=THIS; %};
|
%code{% RETVAL=THIS; %};
|
||||||
@ -18,13 +18,13 @@
|
|||||||
%code{% RETVAL = to_SV_pureperl(THIS); %};
|
%code{% RETVAL = to_SV_pureperl(THIS); %};
|
||||||
SV* pp()
|
SV* pp()
|
||||||
%code{% RETVAL = to_SV_pureperl(THIS); %};
|
%code{% RETVAL = to_SV_pureperl(THIS); %};
|
||||||
long x()
|
int x()
|
||||||
%code{% RETVAL = THIS->x; %};
|
%code{% RETVAL = THIS->x; %};
|
||||||
long y()
|
int y()
|
||||||
%code{% RETVAL = THIS->y; %};
|
%code{% RETVAL = THIS->y; %};
|
||||||
void set_x(long val)
|
void set_x(int val)
|
||||||
%code{% THIS->x = val; %};
|
%code{% THIS->x = val; %};
|
||||||
void set_y(long val)
|
void set_y(int val)
|
||||||
%code{% THIS->y = val; %};
|
%code{% THIS->y = val; %};
|
||||||
int nearest_point_index(Points points);
|
int nearest_point_index(Points points);
|
||||||
Clone<Point> nearest_point(Points points)
|
Clone<Point> nearest_point(Points points)
|
||||||
@ -77,15 +77,15 @@ Point::coincides_with(point_sv)
|
|||||||
};
|
};
|
||||||
|
|
||||||
%name{Slic3r::Point3} class Point3 {
|
%name{Slic3r::Point3} class Point3 {
|
||||||
Point3(long _x = 0, long _y = 0, long _z = 0);
|
Point3(int _x = 0, int _y = 0, int _z = 0);
|
||||||
~Point3();
|
~Point3();
|
||||||
Clone<Point3> clone()
|
Clone<Point3> clone()
|
||||||
%code{% RETVAL = THIS; %};
|
%code{% RETVAL = THIS; %};
|
||||||
long x()
|
int x()
|
||||||
%code{% RETVAL = THIS->x; %};
|
%code{% RETVAL = THIS->x; %};
|
||||||
long y()
|
int y()
|
||||||
%code{% RETVAL = THIS->y; %};
|
%code{% RETVAL = THIS->y; %};
|
||||||
long z()
|
int z()
|
||||||
%code{% RETVAL = THIS->z; %};
|
%code{% RETVAL = THIS->z; %};
|
||||||
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld,%ld", THIS->x, THIS->y, THIS->z); RETVAL = buf; %};
|
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld,%ld", THIS->x, THIS->y, THIS->z); RETVAL = buf; %};
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user