mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-05 00:10:36 +08:00
remove mesh manipulation functions
This commit is contained in:
parent
a8cda979d8
commit
f607f5d28a
@ -280,123 +280,28 @@ TriangleMesh::WriteOBJFile(const std::string &output_file) const {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriangleMesh::scale(float factor)
|
TriangleMesh TriangleMesh::get_transformed_mesh(TransformationMatrix const & trafo) const
|
||||||
{
|
{
|
||||||
stl_scale(&(this->stl), factor);
|
TriangleMesh mesh;
|
||||||
|
std::vector<float> trafo_arr = trafo.matrix3x4f();
|
||||||
|
stl_transform(&(this->stl), &(mesh.stl), trafo_arr.data());
|
||||||
|
stl_invalidate_shared_vertices(&(mesh.stl));
|
||||||
|
return mesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriangleMesh::transform(TransformationMatrix const & trafo)
|
||||||
|
{
|
||||||
|
std::vector<float> trafo_arr = trafo.matrix3x4f();
|
||||||
|
stl_transform(&(this->stl), trafo_arr.data());
|
||||||
|
stl_invalidate_shared_vertices(&(this->stl));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriangleMesh::align_to_bed()
|
||||||
|
{
|
||||||
|
stl_translate_relative(&(this->stl), 0.0f, 0.0f, -this->stl.stats.min.z);
|
||||||
stl_invalidate_shared_vertices(&this->stl);
|
stl_invalidate_shared_vertices(&this->stl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriangleMesh::scale(const Pointf3 &versor)
|
|
||||||
{
|
|
||||||
float fversor[3];
|
|
||||||
fversor[0] = versor.x;
|
|
||||||
fversor[1] = versor.y;
|
|
||||||
fversor[2] = versor.z;
|
|
||||||
stl_scale_versor(&this->stl, fversor);
|
|
||||||
stl_invalidate_shared_vertices(&this->stl);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::translate(float x, float y, float z)
|
|
||||||
{
|
|
||||||
stl_translate_relative(&(this->stl), x, y, z);
|
|
||||||
stl_invalidate_shared_vertices(&this->stl);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::translate(Pointf3 vec) {
|
|
||||||
this->translate(
|
|
||||||
static_cast<float>(vec.x),
|
|
||||||
static_cast<float>(vec.y),
|
|
||||||
static_cast<float>(vec.z)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::rotate(float angle, const Axis &axis)
|
|
||||||
{
|
|
||||||
// admesh uses degrees
|
|
||||||
angle = Slic3r::Geometry::rad2deg(angle);
|
|
||||||
|
|
||||||
if (axis == X) {
|
|
||||||
stl_rotate_x(&(this->stl), angle);
|
|
||||||
} else if (axis == Y) {
|
|
||||||
stl_rotate_y(&(this->stl), angle);
|
|
||||||
} else if (axis == Z) {
|
|
||||||
stl_rotate_z(&(this->stl), angle);
|
|
||||||
}
|
|
||||||
stl_invalidate_shared_vertices(&this->stl);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::rotate_x(float angle)
|
|
||||||
{
|
|
||||||
this->rotate(angle, X);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::rotate_y(float angle)
|
|
||||||
{
|
|
||||||
this->rotate(angle, Y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::rotate_z(float angle)
|
|
||||||
{
|
|
||||||
this->rotate(angle, Z);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::mirror(const Axis &axis)
|
|
||||||
{
|
|
||||||
if (axis == X) {
|
|
||||||
stl_mirror_yz(&this->stl);
|
|
||||||
} else if (axis == Y) {
|
|
||||||
stl_mirror_xz(&this->stl);
|
|
||||||
} else if (axis == Z) {
|
|
||||||
stl_mirror_xy(&this->stl);
|
|
||||||
}
|
|
||||||
stl_invalidate_shared_vertices(&this->stl);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::mirror_x()
|
|
||||||
{
|
|
||||||
this->mirror(X);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::mirror_y()
|
|
||||||
{
|
|
||||||
this->mirror(Y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::mirror_z()
|
|
||||||
{
|
|
||||||
this->mirror(Z);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::align_to_origin()
|
|
||||||
{
|
|
||||||
this->translate(
|
|
||||||
-(this->stl.stats.min.x),
|
|
||||||
-(this->stl.stats.min.y),
|
|
||||||
-(this->stl.stats.min.z)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::center_around_origin()
|
|
||||||
{
|
|
||||||
this->align_to_origin();
|
|
||||||
this->translate(
|
|
||||||
-(this->stl.stats.size.x/2),
|
|
||||||
-(this->stl.stats.size.y/2),
|
|
||||||
-(this->stl.stats.size.z/2)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TriangleMesh::rotate(double angle, Point* center)
|
|
||||||
{
|
|
||||||
this->rotate(angle, *center);
|
|
||||||
}
|
|
||||||
void TriangleMesh::rotate(double angle, const Point& center)
|
|
||||||
{
|
|
||||||
this->translate(-center.x, -center.y, 0);
|
|
||||||
stl_rotate_z(&(this->stl), (float)angle);
|
|
||||||
this->translate(+center.x, +center.y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Pointf3s TriangleMesh::vertices()
|
Pointf3s TriangleMesh::vertices()
|
||||||
{
|
{
|
||||||
Pointf3s tmp {};
|
Pointf3s tmp {};
|
||||||
|
@ -63,30 +63,11 @@ class TriangleMesh
|
|||||||
bool is_manifold() const;
|
bool is_manifold() const;
|
||||||
void WriteOBJFile(const std::string &output_file) const;
|
void WriteOBJFile(const std::string &output_file) const;
|
||||||
|
|
||||||
void scale(float factor);
|
TriangleMesh get_transformed_mesh(TransformationMatrix const & trafo) const;
|
||||||
void scale(const Pointf3 &versor);
|
|
||||||
|
|
||||||
/// Translate the mesh to a new location.
|
void transform(TransformationMatrix const & trafo);
|
||||||
void translate(float x, float y, float z);
|
|
||||||
|
|
||||||
/// Translate the mesh to a new location.
|
void align_to_bed();
|
||||||
void translate(Pointf3 vec);
|
|
||||||
|
|
||||||
|
|
||||||
void rotate(float angle, const Axis &axis);
|
|
||||||
void rotate_x(float angle);
|
|
||||||
void rotate_y(float angle);
|
|
||||||
void rotate_z(float angle);
|
|
||||||
void mirror(const Axis &axis);
|
|
||||||
void mirror_x();
|
|
||||||
void mirror_y();
|
|
||||||
void mirror_z();
|
|
||||||
void align_to_origin();
|
|
||||||
void center_around_origin();
|
|
||||||
|
|
||||||
/// Rotate angle around a specified point.
|
|
||||||
void rotate(double angle, const Point& center);
|
|
||||||
void rotate(double angle, Point* center);
|
|
||||||
|
|
||||||
TriangleMeshPtrs split() const;
|
TriangleMeshPtrs split() const;
|
||||||
TriangleMeshPtrs cut_by_grid(const Pointf &grid) const;
|
TriangleMeshPtrs cut_by_grid(const Pointf &grid) const;
|
||||||
|
@ -17,18 +17,7 @@
|
|||||||
void repair();
|
void repair();
|
||||||
float volume();
|
float volume();
|
||||||
void WriteOBJFile(std::string output_file);
|
void WriteOBJFile(std::string output_file);
|
||||||
void scale(float factor);
|
void align_to_bed();
|
||||||
void scale_xyz(Pointf3* versor)
|
|
||||||
%code{% THIS->scale(*versor); %};
|
|
||||||
void translate(float x, float y, float z);
|
|
||||||
void rotate_x(float angle);
|
|
||||||
void rotate_y(float angle);
|
|
||||||
void rotate_z(float angle);
|
|
||||||
void mirror_x();
|
|
||||||
void mirror_y();
|
|
||||||
void mirror_z();
|
|
||||||
void align_to_origin();
|
|
||||||
void rotate(double angle, Point* center);
|
|
||||||
TriangleMeshPtrs split();
|
TriangleMeshPtrs split();
|
||||||
TriangleMeshPtrs cut_by_grid(Pointf* grid)
|
TriangleMeshPtrs cut_by_grid(Pointf* grid)
|
||||||
%code{% RETVAL = THIS->cut_by_grid(*grid); %};
|
%code{% RETVAL = THIS->cut_by_grid(*grid); %};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user