Replaced Point3 with Eigen Vec3crd, removed Point3 from the Perl binding.
This commit is contained in:
parent
0b5b02e002
commit
ac72cd779f
@ -33,16 +33,6 @@ use overload
|
|||||||
'@{}' => sub { $_[0]->arrayref },
|
'@{}' => sub { $_[0]->arrayref },
|
||||||
'fallback' => 1;
|
'fallback' => 1;
|
||||||
|
|
||||||
package Slic3r::Point3;
|
|
||||||
use overload
|
|
||||||
'@{}' => sub { [ $_[0]->x, $_[0]->y, $_[0]->z ] }, #,
|
|
||||||
'fallback' => 1;
|
|
||||||
|
|
||||||
sub pp {
|
|
||||||
my ($self) = @_;
|
|
||||||
return [ @$self ];
|
|
||||||
}
|
|
||||||
|
|
||||||
package Slic3r::Pointf;
|
package Slic3r::Pointf;
|
||||||
use overload
|
use overload
|
||||||
'@{}' => sub { $_[0]->arrayref },
|
'@{}' => sub { $_[0]->arrayref },
|
||||||
|
@ -120,12 +120,12 @@ public:
|
|||||||
friend BoundingBox get_extents_rotated(const Points &points, double angle);
|
friend BoundingBox get_extents_rotated(const Points &points, double angle);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BoundingBox3 : public BoundingBox3Base<Point3>
|
class BoundingBox3 : public BoundingBox3Base<Vec3crd>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoundingBox3() : BoundingBox3Base<Point3>() {};
|
BoundingBox3() : BoundingBox3Base<Vec3crd>() {};
|
||||||
BoundingBox3(const Point3 &pmin, const Point3 &pmax) : BoundingBox3Base<Point3>(pmin, pmax) {};
|
BoundingBox3(const Vec3crd &pmin, const Vec3crd &pmax) : BoundingBox3Base<Vec3crd>(pmin, pmax) {};
|
||||||
BoundingBox3(const Points3& points) : BoundingBox3Base<Point3>(points) {};
|
BoundingBox3(const Points3& points) : BoundingBox3Base<Vec3crd>(points) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
class BoundingBoxf : public BoundingBoxBase<Vec2d>
|
class BoundingBoxf : public BoundingBoxBase<Vec2d>
|
||||||
|
@ -768,12 +768,12 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data)
|
|||||||
polyline = Polyline3();
|
polyline = Polyline3();
|
||||||
|
|
||||||
// add both vertices of the move
|
// add both vertices of the move
|
||||||
polyline.append(Point3(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z())));
|
polyline.append(Vec3crd(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z())));
|
||||||
polyline.append(Point3(scale_(move.end_position.x()), scale_(move.end_position.y()), scale_(move.end_position.z())));
|
polyline.append(Vec3crd(scale_(move.end_position.x()), scale_(move.end_position.y()), scale_(move.end_position.z())));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// append end vertex of the move to current polyline
|
// append end vertex of the move to current polyline
|
||||||
polyline.append(Point3(scale_(move.end_position.x()), scale_(move.end_position.y()), scale_(move.end_position.z())));
|
polyline.append(Vec3crd(scale_(move.end_position.x()), scale_(move.end_position.y()), scale_(move.end_position.z())));
|
||||||
|
|
||||||
// update current values
|
// update current values
|
||||||
position = move.end_position;
|
position = move.end_position;
|
||||||
@ -804,7 +804,7 @@ void GCodeAnalyzer::_calc_gcode_preview_retractions(GCodePreviewData& preview_da
|
|||||||
for (const GCodeMove& move : retraction_moves->second)
|
for (const GCodeMove& move : retraction_moves->second)
|
||||||
{
|
{
|
||||||
// store position
|
// store position
|
||||||
Point3 position(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z()));
|
Vec3crd position(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z()));
|
||||||
preview_data.retraction.positions.emplace_back(position, move.data.width, move.data.height);
|
preview_data.retraction.positions.emplace_back(position, move.data.width, move.data.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -818,7 +818,7 @@ void GCodeAnalyzer::_calc_gcode_preview_unretractions(GCodePreviewData& preview_
|
|||||||
for (const GCodeMove& move : unretraction_moves->second)
|
for (const GCodeMove& move : unretraction_moves->second)
|
||||||
{
|
{
|
||||||
// store position
|
// store position
|
||||||
Point3 position(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z()));
|
Vec3crd position(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z()));
|
||||||
preview_data.unretraction.positions.emplace_back(position, move.data.width, move.data.height);
|
preview_data.unretraction.positions.emplace_back(position, move.data.width, move.data.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ void GCodePreviewData::Travel::set_default()
|
|||||||
|
|
||||||
const GCodePreviewData::Color GCodePreviewData::Retraction::Default_Color = GCodePreviewData::Color(1.0f, 1.0f, 1.0f, 1.0f);
|
const GCodePreviewData::Color GCodePreviewData::Retraction::Default_Color = GCodePreviewData::Color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
GCodePreviewData::Retraction::Position::Position(const Point3& position, float width, float height)
|
GCodePreviewData::Retraction::Position::Position(const Vec3crd& position, float width, float height)
|
||||||
: position(position)
|
: position(position)
|
||||||
, width(width)
|
, width(width)
|
||||||
, height(height)
|
, height(height)
|
||||||
|
@ -151,11 +151,11 @@ public:
|
|||||||
|
|
||||||
struct Position
|
struct Position
|
||||||
{
|
{
|
||||||
Point3 position;
|
Vec3crd position;
|
||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
|
|
||||||
Position(const Point3& position, float width, float height);
|
Position(const Vec3crd& position, float width, float height);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<Position> PositionsList;
|
typedef std::vector<Position> PositionsList;
|
||||||
|
@ -58,14 +58,14 @@ public:
|
|||||||
class Line3
|
class Line3
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Line3() {}
|
Line3() : a(Vec3crd::Zero()), b(Vec3crd::Zero()) {}
|
||||||
Line3(const Point3& _a, const Point3& _b) : a(_a), b(_b) {}
|
Line3(const Vec3crd& _a, const Vec3crd& _b) : a(_a), b(_b) {}
|
||||||
|
|
||||||
double length() const { return (this->a - this->b).cast<double>().norm(); }
|
double length() const { return (this->a - this->b).cast<double>().norm(); }
|
||||||
Vector3 vector() const { return this->b - this->a; }
|
Vec3crd vector() const { return this->b - this->a; }
|
||||||
|
|
||||||
Point3 a;
|
Vec3crd a;
|
||||||
Point3 b;
|
Vec3crd b;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Linef
|
class Linef
|
||||||
|
@ -196,7 +196,7 @@ MultiPoint::_douglas_peucker(const Points &points, const double tolerance)
|
|||||||
|
|
||||||
void MultiPoint3::translate(double x, double y)
|
void MultiPoint3::translate(double x, double y)
|
||||||
{
|
{
|
||||||
for (Point3 &p : points) {
|
for (Vec3crd &p : points) {
|
||||||
p(0) += x;
|
p(0) += x;
|
||||||
p(1) += y;
|
p(1) += y;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ class MultiPoint3
|
|||||||
public:
|
public:
|
||||||
Points3 points;
|
Points3 points;
|
||||||
|
|
||||||
void append(const Point3& point) { this->points.push_back(point); }
|
void append(const Vec3crd& point) { this->points.push_back(point); }
|
||||||
|
|
||||||
void translate(double x, double y);
|
void translate(double x, double y);
|
||||||
void translate(const Point& vector);
|
void translate(const Point& vector);
|
||||||
|
@ -16,9 +16,7 @@ namespace Slic3r {
|
|||||||
class Line;
|
class Line;
|
||||||
class MultiPoint;
|
class MultiPoint;
|
||||||
class Point;
|
class Point;
|
||||||
class Point3;
|
typedef Point Vector;
|
||||||
typedef Point Vector;
|
|
||||||
typedef Point3 Vector3;
|
|
||||||
|
|
||||||
// Eigen types, to replace the Slic3r's own types in the future.
|
// Eigen types, to replace the Slic3r's own types in the future.
|
||||||
// Vector types with a fixed point coordinate base type.
|
// Vector types with a fixed point coordinate base type.
|
||||||
@ -36,7 +34,7 @@ typedef Eigen::Matrix<double, 3, 1, Eigen::DontAlign> Vec3d;
|
|||||||
typedef std::vector<Point> Points;
|
typedef std::vector<Point> Points;
|
||||||
typedef std::vector<Point*> PointPtrs;
|
typedef std::vector<Point*> PointPtrs;
|
||||||
typedef std::vector<const Point*> PointConstPtrs;
|
typedef std::vector<const Point*> PointConstPtrs;
|
||||||
typedef std::vector<Point3> Points3;
|
typedef std::vector<Vec3crd> Points3;
|
||||||
typedef std::vector<Vec2d> Pointfs;
|
typedef std::vector<Vec2d> Pointfs;
|
||||||
typedef std::vector<Vec3d> Pointf3s;
|
typedef std::vector<Vec3d> Pointf3s;
|
||||||
|
|
||||||
@ -221,27 +219,6 @@ private:
|
|||||||
coord_t m_grid_log2;
|
coord_t m_grid_log2;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Point3 : public Vec3crd
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef coord_t coord_type;
|
|
||||||
|
|
||||||
explicit Point3() { (*this)(0) = (*this)(1) = (*this)(2) = 0; }
|
|
||||||
explicit Point3(coord_t x, coord_t y, coord_t z) { (*this)(0) = x; (*this)(1) = y; (*this)(2) = z; }
|
|
||||||
// This constructor allows you to construct Point3 from Eigen expressions
|
|
||||||
template<typename OtherDerived>
|
|
||||||
Point3(const Eigen::MatrixBase<OtherDerived> &other) : Vec3crd(other) {}
|
|
||||||
static Point3 new_scale(coordf_t x, coordf_t y, coordf_t z) { return Point3(coord_t(scale_(x)), coord_t(scale_(y)), coord_t(scale_(z))); }
|
|
||||||
|
|
||||||
// This method allows you to assign Eigen expressions to MyVectorType
|
|
||||||
template<typename OtherDerived>
|
|
||||||
Point3& operator=(const Eigen::MatrixBase<OtherDerived> &other)
|
|
||||||
{
|
|
||||||
this->Vec3crd::operator=(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream &stm, const Vec2d &pointf);
|
std::ostream& operator<<(std::ostream &stm, const Vec2d &pointf);
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
@ -118,7 +118,7 @@ public:
|
|||||||
// so that next call to make_perimeters() performs a union() before computing loops
|
// so that next call to make_perimeters() performs a union() before computing loops
|
||||||
bool typed_slices;
|
bool typed_slices;
|
||||||
|
|
||||||
Point3 size; // XYZ in scaled coordinates
|
Vec3crd size; // XYZ in scaled coordinates
|
||||||
|
|
||||||
// scaled coordinates to add to copies (to compensate for the alignment
|
// scaled coordinates to add to copies (to compensate for the alignment
|
||||||
// operated when creating the object but still preserving a coherent API
|
// operated when creating the object but still preserving a coherent API
|
||||||
|
@ -38,6 +38,7 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Bounding
|
|||||||
typed_slices(false),
|
typed_slices(false),
|
||||||
_print(print),
|
_print(print),
|
||||||
_model_object(model_object),
|
_model_object(model_object),
|
||||||
|
size(Vec3crd::Zero()),
|
||||||
layer_height_profile_valid(false)
|
layer_height_profile_valid(false)
|
||||||
{
|
{
|
||||||
// Compute the translation to be applied to our meshes so that we work with smaller coordinates
|
// Compute the translation to be applied to our meshes so that we work with smaller coordinates
|
||||||
@ -50,8 +51,7 @@ PrintObject::PrintObject(Print* print, ModelObject* model_object, const Bounding
|
|||||||
// (copies are expressed in G-code coordinates and this translation is not publicly exposed).
|
// (copies are expressed in G-code coordinates and this translation is not publicly exposed).
|
||||||
this->_copies_shift = Point::new_scale(modobj_bbox.min(0), modobj_bbox.min(1));
|
this->_copies_shift = Point::new_scale(modobj_bbox.min(0), modobj_bbox.min(1));
|
||||||
// Scale the object size and store it
|
// Scale the object size and store it
|
||||||
Vec3d size = modobj_bbox.size();
|
this->size = (modobj_bbox.size() * (1. / SCALING_FACTOR)).cast<coord_t>();
|
||||||
this->size = Point3::new_scale(size(0), size(1), size(2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->reload_model_instances();
|
this->reload_model_instances();
|
||||||
|
@ -561,15 +561,15 @@ int generate_layer_height_texture(
|
|||||||
void *data, int rows, int cols, bool level_of_detail_2nd_level)
|
void *data, int rows, int cols, bool level_of_detail_2nd_level)
|
||||||
{
|
{
|
||||||
// https://github.com/aschn/gnuplot-colorbrewer
|
// https://github.com/aschn/gnuplot-colorbrewer
|
||||||
std::vector<Point3> palette_raw;
|
std::vector<Vec3crd> palette_raw;
|
||||||
palette_raw.push_back(Point3(0x01A, 0x098, 0x050));
|
palette_raw.push_back(Vec3crd(0x01A, 0x098, 0x050));
|
||||||
palette_raw.push_back(Point3(0x066, 0x0BD, 0x063));
|
palette_raw.push_back(Vec3crd(0x066, 0x0BD, 0x063));
|
||||||
palette_raw.push_back(Point3(0x0A6, 0x0D9, 0x06A));
|
palette_raw.push_back(Vec3crd(0x0A6, 0x0D9, 0x06A));
|
||||||
palette_raw.push_back(Point3(0x0D9, 0x0F1, 0x0EB));
|
palette_raw.push_back(Vec3crd(0x0D9, 0x0F1, 0x0EB));
|
||||||
palette_raw.push_back(Point3(0x0FE, 0x0E6, 0x0EB));
|
palette_raw.push_back(Vec3crd(0x0FE, 0x0E6, 0x0EB));
|
||||||
palette_raw.push_back(Point3(0x0FD, 0x0AE, 0x061));
|
palette_raw.push_back(Vec3crd(0x0FD, 0x0AE, 0x061));
|
||||||
palette_raw.push_back(Point3(0x0F4, 0x06D, 0x043));
|
palette_raw.push_back(Vec3crd(0x0F4, 0x06D, 0x043));
|
||||||
palette_raw.push_back(Point3(0x0D7, 0x030, 0x027));
|
palette_raw.push_back(Vec3crd(0x0D7, 0x030, 0x027));
|
||||||
|
|
||||||
// Clear the main texture and the 2nd LOD level.
|
// Clear the main texture and the 2nd LOD level.
|
||||||
// memset(data, 0, rows * cols * (level_of_detail_2nd_level ? 5 : 4));
|
// memset(data, 0, rows * cols * (level_of_detail_2nd_level ? 5 : 4));
|
||||||
@ -600,8 +600,8 @@ int generate_layer_height_texture(
|
|||||||
int idx1 = clamp(0, int(palette_raw.size() - 1), int(floor(idxf)));
|
int idx1 = clamp(0, int(palette_raw.size() - 1), int(floor(idxf)));
|
||||||
int idx2 = std::min(int(palette_raw.size() - 1), idx1 + 1);
|
int idx2 = std::min(int(palette_raw.size() - 1), idx1 + 1);
|
||||||
coordf_t t = idxf - coordf_t(idx1);
|
coordf_t t = idxf - coordf_t(idx1);
|
||||||
const Point3 &color1 = palette_raw[idx1];
|
const Vec3crd &color1 = palette_raw[idx1];
|
||||||
const Point3 &color2 = palette_raw[idx2];
|
const Vec3crd &color2 = palette_raw[idx2];
|
||||||
coordf_t z = cell_to_z * coordf_t(cell);
|
coordf_t z = cell_to_z * coordf_t(cell);
|
||||||
assert(z >= lo && z <= hi);
|
assert(z >= lo && z <= hi);
|
||||||
// Intensity profile to visualize the layers.
|
// Intensity profile to visualize the layers.
|
||||||
@ -636,8 +636,8 @@ int generate_layer_height_texture(
|
|||||||
int idx1 = clamp(0, int(palette_raw.size() - 1), int(floor(idxf)));
|
int idx1 = clamp(0, int(palette_raw.size() - 1), int(floor(idxf)));
|
||||||
int idx2 = std::min(int(palette_raw.size() - 1), idx1 + 1);
|
int idx2 = std::min(int(palette_raw.size() - 1), idx1 + 1);
|
||||||
coordf_t t = idxf - coordf_t(idx1);
|
coordf_t t = idxf - coordf_t(idx1);
|
||||||
const Point3 &color1 = palette_raw[idx1];
|
const Vec3crd &color1 = palette_raw[idx1];
|
||||||
const Point3 &color2 = palette_raw[idx2];
|
const Vec3crd &color2 = palette_raw[idx2];
|
||||||
// Color mapping from layer height to RGB.
|
// Color mapping from layer height to RGB.
|
||||||
Vec3d color(
|
Vec3d color(
|
||||||
lerp(coordf_t(color1(0)), coordf_t(color2(0)), t),
|
lerp(coordf_t(color1(0)), coordf_t(color2(0)), t),
|
||||||
|
@ -36,7 +36,7 @@ TriangleMesh::TriangleMesh()
|
|||||||
stl_initialize(&this->stl);
|
stl_initialize(&this->stl);
|
||||||
}
|
}
|
||||||
|
|
||||||
TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Point3>& facets )
|
TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Vec3crd>& facets )
|
||||||
: repaired(false)
|
: repaired(false)
|
||||||
{
|
{
|
||||||
stl_initialize(&this->stl);
|
stl_initialize(&this->stl);
|
||||||
@ -1539,14 +1539,14 @@ TriangleMesh make_cube(double x, double y, double z) {
|
|||||||
Vec3d(0, y, 0), Vec3d(x, y, z), Vec3d(0, y, z),
|
Vec3d(0, y, 0), Vec3d(x, y, z), Vec3d(0, y, z),
|
||||||
Vec3d(0, 0, z), Vec3d(x, 0, z)
|
Vec3d(0, 0, z), Vec3d(x, 0, z)
|
||||||
};
|
};
|
||||||
Point3 fv[12] = {
|
Vec3crd fv[12] = {
|
||||||
Point3(0, 1, 2), Point3(0, 2, 3), Point3(4, 5, 6),
|
Vec3crd(0, 1, 2), Vec3crd(0, 2, 3), Vec3crd(4, 5, 6),
|
||||||
Point3(4, 6, 7), Point3(0, 4, 7), Point3(0, 7, 1),
|
Vec3crd(4, 6, 7), Vec3crd(0, 4, 7), Vec3crd(0, 7, 1),
|
||||||
Point3(1, 7, 6), Point3(1, 6, 2), Point3(2, 6, 5),
|
Vec3crd(1, 7, 6), Vec3crd(1, 6, 2), Vec3crd(2, 6, 5),
|
||||||
Point3(2, 5, 3), Point3(4, 0, 3), Point3(4, 3, 5)
|
Vec3crd(2, 5, 3), Vec3crd(4, 0, 3), Vec3crd(4, 3, 5)
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Point3> facets(&fv[0], &fv[0]+12);
|
std::vector<Vec3crd> facets(&fv[0], &fv[0]+12);
|
||||||
Pointf3s vertices(&pv[0], &pv[0]+8);
|
Pointf3s vertices(&pv[0], &pv[0]+8);
|
||||||
|
|
||||||
TriangleMesh mesh(vertices ,facets);
|
TriangleMesh mesh(vertices ,facets);
|
||||||
@ -1558,7 +1558,7 @@ TriangleMesh make_cube(double x, double y, double z) {
|
|||||||
// Default is 360 sides, angle fa is in radians.
|
// Default is 360 sides, angle fa is in radians.
|
||||||
TriangleMesh make_cylinder(double r, double h, double fa) {
|
TriangleMesh make_cylinder(double r, double h, double fa) {
|
||||||
Pointf3s vertices;
|
Pointf3s vertices;
|
||||||
std::vector<Point3> facets;
|
std::vector<Vec3crd> facets;
|
||||||
|
|
||||||
// 2 special vertices, top and bottom center, rest are relative to this
|
// 2 special vertices, top and bottom center, rest are relative to this
|
||||||
vertices.emplace_back(Vec3d(0.0, 0.0, 0.0));
|
vertices.emplace_back(Vec3d(0.0, 0.0, 0.0));
|
||||||
@ -1579,16 +1579,16 @@ TriangleMesh make_cylinder(double r, double h, double fa) {
|
|||||||
vertices.emplace_back(Vec3d(p(0), p(1), 0.));
|
vertices.emplace_back(Vec3d(p(0), p(1), 0.));
|
||||||
vertices.emplace_back(Vec3d(p(0), p(1), h));
|
vertices.emplace_back(Vec3d(p(0), p(1), h));
|
||||||
id = vertices.size() - 1;
|
id = vertices.size() - 1;
|
||||||
facets.emplace_back(Point3( 0, id - 1, id - 3)); // top
|
facets.emplace_back(Vec3crd( 0, id - 1, id - 3)); // top
|
||||||
facets.emplace_back(Point3(id, 1, id - 2)); // bottom
|
facets.emplace_back(Vec3crd(id, 1, id - 2)); // bottom
|
||||||
facets.emplace_back(Point3(id, id - 2, id - 3)); // upper-right of side
|
facets.emplace_back(Vec3crd(id, id - 2, id - 3)); // upper-right of side
|
||||||
facets.emplace_back(Point3(id, id - 3, id - 1)); // bottom-left of side
|
facets.emplace_back(Vec3crd(id, id - 3, id - 1)); // bottom-left of side
|
||||||
}
|
}
|
||||||
// Connect the last set of vertices with the first.
|
// Connect the last set of vertices with the first.
|
||||||
facets.emplace_back(Point3( 2, 0, id - 1));
|
facets.emplace_back(Vec3crd( 2, 0, id - 1));
|
||||||
facets.emplace_back(Point3( 1, 3, id));
|
facets.emplace_back(Vec3crd( 1, 3, id));
|
||||||
facets.emplace_back(Point3(id, 3, 2));
|
facets.emplace_back(Vec3crd(id, 3, 2));
|
||||||
facets.emplace_back(Point3(id, 2, id - 1));
|
facets.emplace_back(Vec3crd(id, 2, id - 1));
|
||||||
|
|
||||||
TriangleMesh mesh(vertices, facets);
|
TriangleMesh mesh(vertices, facets);
|
||||||
return mesh;
|
return mesh;
|
||||||
@ -1599,7 +1599,7 @@ TriangleMesh make_cylinder(double r, double h, double fa) {
|
|||||||
// Default angle is 1 degree.
|
// Default angle is 1 degree.
|
||||||
TriangleMesh make_sphere(double rho, double fa) {
|
TriangleMesh make_sphere(double rho, double fa) {
|
||||||
Pointf3s vertices;
|
Pointf3s vertices;
|
||||||
std::vector<Point3> facets;
|
std::vector<Vec3crd> facets;
|
||||||
|
|
||||||
// Algorithm:
|
// Algorithm:
|
||||||
// Add points one-by-one to the sphere grid and form facets using relative coordinates.
|
// Add points one-by-one to the sphere grid and form facets using relative coordinates.
|
||||||
@ -1627,7 +1627,7 @@ TriangleMesh make_sphere(double rho, double fa) {
|
|||||||
const double r = sqrt(abs(rho*rho - z*z));
|
const double r = sqrt(abs(rho*rho - z*z));
|
||||||
Vec2d b = Eigen::Rotation2Dd(ring[i]) * Eigen::Vector2d(0, r);
|
Vec2d b = Eigen::Rotation2Dd(ring[i]) * Eigen::Vector2d(0, r);
|
||||||
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
||||||
facets.emplace_back((i == 0) ? Point3(1, 0, ring.size()) : Point3(id, 0, id - 1));
|
facets.emplace_back((i == 0) ? Vec3crd(1, 0, ring.size()) : Vec3crd(id, 0, id - 1));
|
||||||
++ id;
|
++ id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1641,11 +1641,11 @@ TriangleMesh make_sphere(double rho, double fa) {
|
|||||||
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
vertices.emplace_back(Vec3d(b(0), b(1), z));
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// wrap around
|
// wrap around
|
||||||
facets.emplace_back(Point3(id + ring.size() - 1 , id, id - 1));
|
facets.emplace_back(Vec3crd(id + ring.size() - 1 , id, id - 1));
|
||||||
facets.emplace_back(Point3(id, id - ring.size(), id - 1));
|
facets.emplace_back(Vec3crd(id, id - ring.size(), id - 1));
|
||||||
} else {
|
} else {
|
||||||
facets.emplace_back(Point3(id , id - ring.size(), (id - 1) - ring.size()));
|
facets.emplace_back(Vec3crd(id , id - ring.size(), (id - 1) - ring.size()));
|
||||||
facets.emplace_back(Point3(id, id - 1 - ring.size() , id - 1));
|
facets.emplace_back(Vec3crd(id, id - 1 - ring.size() , id - 1));
|
||||||
}
|
}
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
@ -1658,9 +1658,9 @@ TriangleMesh make_sphere(double rho, double fa) {
|
|||||||
for (size_t i = 0; i < ring.size(); i++) {
|
for (size_t i = 0; i < ring.size(); i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// third vertex is on the other side of the ring.
|
// third vertex is on the other side of the ring.
|
||||||
facets.emplace_back(Point3(id, id - ring.size(), id - 1));
|
facets.emplace_back(Vec3crd(id, id - ring.size(), id - 1));
|
||||||
} else {
|
} else {
|
||||||
facets.emplace_back(Point3(id, id - ring.size() + i, id - ring.size() + (i - 1)));
|
facets.emplace_back(Vec3crd(id, id - ring.size() + i, id - ring.size() + (i - 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
id++;
|
id++;
|
||||||
|
@ -21,7 +21,7 @@ class TriangleMesh
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TriangleMesh();
|
TriangleMesh();
|
||||||
TriangleMesh(const Pointf3s &points, const std::vector<Point3> &facets);
|
TriangleMesh(const Pointf3s &points, const std::vector<Vec3crd> &facets);
|
||||||
TriangleMesh(const TriangleMesh &other);
|
TriangleMesh(const TriangleMesh &other);
|
||||||
TriangleMesh(TriangleMesh &&other);
|
TriangleMesh(TriangleMesh &&other);
|
||||||
TriangleMesh& operator=(const TriangleMesh &other);
|
TriangleMesh& operator=(const TriangleMesh &other);
|
||||||
|
@ -41,7 +41,6 @@ REGISTER_CLASS(BoundingBoxf, "Geometry::BoundingBoxf");
|
|||||||
REGISTER_CLASS(BoundingBoxf3, "Geometry::BoundingBoxf3");
|
REGISTER_CLASS(BoundingBoxf3, "Geometry::BoundingBoxf3");
|
||||||
REGISTER_CLASS(BridgeDetector, "BridgeDetector");
|
REGISTER_CLASS(BridgeDetector, "BridgeDetector");
|
||||||
REGISTER_CLASS(Point, "Point");
|
REGISTER_CLASS(Point, "Point");
|
||||||
REGISTER_CLASS(Point3, "Point3");
|
|
||||||
__REGISTER_CLASS(Vec2d, "Pointf");
|
__REGISTER_CLASS(Vec2d, "Pointf");
|
||||||
__REGISTER_CLASS(Vec3d, "Pointf3");
|
__REGISTER_CLASS(Vec3d, "Pointf3");
|
||||||
REGISTER_CLASS(DynamicPrintConfig, "Config");
|
REGISTER_CLASS(DynamicPrintConfig, "Config");
|
||||||
|
@ -661,7 +661,7 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
|||||||
// We'll now create the box with jagged edge. y-coordinates of the pre-generated model are shifted so that the front
|
// We'll now create the box with jagged edge. y-coordinates of the pre-generated model are shifted so that the front
|
||||||
// edge has y=0 and centerline of the back edge has y=depth:
|
// edge has y=0 and centerline of the back edge has y=depth:
|
||||||
Pointf3s points;
|
Pointf3s points;
|
||||||
std::vector<Point3> facets;
|
std::vector<Vec3crd> facets;
|
||||||
float out_points_idx[][3] = {{0, -depth, 0}, {0, 0, 0}, {38.453, 0, 0}, {61.547, 0, 0}, {100, 0, 0}, {100, -depth, 0}, {55.7735, -10, 0}, {44.2265, 10, 0},
|
float out_points_idx[][3] = {{0, -depth, 0}, {0, 0, 0}, {38.453, 0, 0}, {61.547, 0, 0}, {100, 0, 0}, {100, -depth, 0}, {55.7735, -10, 0}, {44.2265, 10, 0},
|
||||||
{38.453, 0, 1}, {0, 0, 1}, {0, -depth, 1}, {100, -depth, 1}, {100, 0, 1}, {61.547, 0, 1}, {55.7735, -10, 1}, {44.2265, 10, 1}};
|
{38.453, 0, 1}, {0, 0, 1}, {0, -depth, 1}, {100, -depth, 1}, {100, 0, 1}, {61.547, 0, 1}, {55.7735, -10, 1}, {44.2265, 10, 1}};
|
||||||
int out_facets_idx[][3] = {{0, 1, 2}, {3, 4, 5}, {6, 5, 0}, {3, 5, 6}, {6, 2, 7}, {6, 0, 2}, {8, 9, 10}, {11, 12, 13}, {10, 11, 14}, {14, 11, 13}, {15, 8, 14},
|
int out_facets_idx[][3] = {{0, 1, 2}, {3, 4, 5}, {6, 5, 0}, {3, 5, 6}, {6, 2, 7}, {6, 0, 2}, {8, 9, 10}, {11, 12, 13}, {10, 11, 14}, {14, 11, 13}, {15, 8, 14},
|
||||||
@ -670,7 +670,7 @@ int GLVolumeCollection::load_wipe_tower_preview(
|
|||||||
for (int i=0;i<16;++i)
|
for (int i=0;i<16;++i)
|
||||||
points.push_back(Vec3d(out_points_idx[i][0] / (100.f/min_width), out_points_idx[i][1] + depth, out_points_idx[i][2]));
|
points.push_back(Vec3d(out_points_idx[i][0] / (100.f/min_width), out_points_idx[i][1] + depth, out_points_idx[i][2]));
|
||||||
for (int i=0;i<28;++i)
|
for (int i=0;i<28;++i)
|
||||||
facets.push_back(Point3(out_facets_idx[i][0], out_facets_idx[i][1], out_facets_idx[i][2]));
|
facets.push_back(Vec3crd(out_facets_idx[i][0], out_facets_idx[i][1], out_facets_idx[i][2]));
|
||||||
TriangleMesh tooth_mesh(points, facets);
|
TriangleMesh tooth_mesh(points, facets);
|
||||||
|
|
||||||
// We have the mesh ready. It has one tooth and width of min_width. We will now append several of these together until we are close to
|
// We have the mesh ready. It has one tooth and width of min_width. We will now append several of these together until we are close to
|
||||||
@ -1442,7 +1442,7 @@ static void thick_lines_to_indexed_vertex_array(const Lines3& lines,
|
|||||||
#undef BOTTOM
|
#undef BOTTOM
|
||||||
}
|
}
|
||||||
|
|
||||||
static void point_to_indexed_vertex_array(const Point3& point,
|
static void point_to_indexed_vertex_array(const Vec3crd& point,
|
||||||
double width,
|
double width,
|
||||||
double height,
|
double height,
|
||||||
GLIndexedVertexArray& volume)
|
GLIndexedVertexArray& volume)
|
||||||
@ -1512,7 +1512,7 @@ void _3DScene::thick_lines_to_verts(const Lines3& lines,
|
|||||||
thick_lines_to_indexed_vertex_array(lines, widths, heights, closed, volume.indexed_vertex_array);
|
thick_lines_to_indexed_vertex_array(lines, widths, heights, closed, volume.indexed_vertex_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void thick_point_to_verts(const Point3& point,
|
static void thick_point_to_verts(const Vec3crd& point,
|
||||||
double width,
|
double width,
|
||||||
double height,
|
double height,
|
||||||
GLVolume& volume)
|
GLVolume& volume)
|
||||||
@ -1618,7 +1618,7 @@ void _3DScene::polyline3_to_verts(const Polyline3& polyline, double width, doubl
|
|||||||
thick_lines_to_verts(lines, widths, heights, false, volume);
|
thick_lines_to_verts(lines, widths, heights, false, volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _3DScene::point3_to_verts(const Point3& point, double width, double height, GLVolume& volume)
|
void _3DScene::point3_to_verts(const Vec3crd& point, double width, double height, GLVolume& volume)
|
||||||
{
|
{
|
||||||
thick_point_to_verts(point, width, height, volume);
|
thick_point_to_verts(point, width, height, volume);
|
||||||
}
|
}
|
||||||
|
@ -553,7 +553,7 @@ public:
|
|||||||
static void extrusionentity_to_verts(const ExtrusionEntityCollection& extrusion_entity_collection, float print_z, const Point& copy, GLVolume& volume);
|
static void extrusionentity_to_verts(const ExtrusionEntityCollection& extrusion_entity_collection, float print_z, const Point& copy, GLVolume& volume);
|
||||||
static void extrusionentity_to_verts(const ExtrusionEntity* extrusion_entity, float print_z, const Point& copy, GLVolume& volume);
|
static void extrusionentity_to_verts(const ExtrusionEntity* extrusion_entity, float print_z, const Point& copy, GLVolume& volume);
|
||||||
static void polyline3_to_verts(const Polyline3& polyline, double width, double height, GLVolume& volume);
|
static void polyline3_to_verts(const Polyline3& polyline, double width, double height, GLVolume& volume);
|
||||||
static void point3_to_verts(const Point3& point, double width, double height, GLVolume& volume);
|
static void point3_to_verts(const Vec3crd& point, double width, double height, GLVolume& volume);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,20 +77,6 @@ Point::coincides_with(point_sv)
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
%name{Slic3r::Point3} class Point3 {
|
|
||||||
Point3(int _x = 0, int _y = 0, int _z = 0);
|
|
||||||
~Point3();
|
|
||||||
Clone<Point3> clone()
|
|
||||||
%code{% RETVAL = THIS; %};
|
|
||||||
int x()
|
|
||||||
%code{% RETVAL = (*THIS)(0); %};
|
|
||||||
int y()
|
|
||||||
%code{% RETVAL = (*THIS)(1); %};
|
|
||||||
int z()
|
|
||||||
%code{% RETVAL = (*THIS)(2); %};
|
|
||||||
std::string serialize() %code{% char buf[2048]; sprintf(buf, "%ld,%ld,%ld", (*THIS)(0), (*THIS)(1), (*THIS)(2)); RETVAL = buf; %};
|
|
||||||
};
|
|
||||||
|
|
||||||
%name{Slic3r::Pointf} class Vec2d {
|
%name{Slic3r::Pointf} class Vec2d {
|
||||||
Vec2d(double _x = 0, double _y = 0);
|
Vec2d(double _x = 0, double _y = 0);
|
||||||
~Vec2d();
|
~Vec2d();
|
||||||
|
@ -63,8 +63,6 @@ _constant()
|
|||||||
%code%{ RETVAL = THIS->layer_height_ranges; %};
|
%code%{ RETVAL = THIS->layer_height_ranges; %};
|
||||||
std::vector<double> layer_height_profile()
|
std::vector<double> layer_height_profile()
|
||||||
%code%{ RETVAL = THIS->layer_height_profile; %};
|
%code%{ RETVAL = THIS->layer_height_profile; %};
|
||||||
Ref<Point3> size()
|
|
||||||
%code%{ RETVAL = &THIS->size; %};
|
|
||||||
Clone<BoundingBox> bounding_box();
|
Clone<BoundingBox> bounding_box();
|
||||||
|
|
||||||
Points _shifted_copies()
|
Points _shifted_copies()
|
||||||
|
Loading…
Reference in New Issue
Block a user