mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
Tweaks to GLGizmoFlatten
This commit is contained in:
parent
b9bb821392
commit
87565a0686
6 changed files with 77 additions and 52 deletions
|
@ -7,6 +7,18 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
Linef3 transform(const Linef3& line, const Transform3d& t)
|
||||
{
|
||||
typedef Eigen::Matrix<double, 3, 2> LineInMatrixForm;
|
||||
|
||||
LineInMatrixForm world_line;
|
||||
::memcpy((void*)world_line.col(0).data(), (const void*)line.a.data(), 3 * sizeof(double));
|
||||
::memcpy((void*)world_line.col(1).data(), (const void*)line.b.data(), 3 * sizeof(double));
|
||||
|
||||
LineInMatrixForm local_line = t * world_line.colwise().homogeneous();
|
||||
return Linef3(Vec3d(local_line(0, 0), local_line(1, 0), local_line(2, 0)), Vec3d(local_line(0, 1), local_line(1, 1), local_line(2, 1)));
|
||||
}
|
||||
|
||||
bool Line::intersection_infinite(const Line &other, Point* point) const
|
||||
{
|
||||
Vec2d a1 = this->a.cast<double>();
|
||||
|
|
|
@ -15,6 +15,8 @@ typedef std::vector<Line> Lines;
|
|||
typedef std::vector<Line3> Lines3;
|
||||
typedef std::vector<ThickLine> ThickLines;
|
||||
|
||||
Linef3 transform(const Linef3& line, const Transform3d& t);
|
||||
|
||||
class Line
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -6,6 +6,44 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
std::vector<Vec3f> transform(const std::vector<Vec3f>& points, const Transform3f& t)
|
||||
{
|
||||
unsigned int vertices_count = (unsigned int)points.size();
|
||||
if (vertices_count == 0)
|
||||
return std::vector<Vec3f>();
|
||||
|
||||
unsigned int data_size = 3 * vertices_count * sizeof(float);
|
||||
|
||||
Eigen::MatrixXf src(3, vertices_count);
|
||||
::memcpy((void*)src.data(), (const void*)points.data(), data_size);
|
||||
|
||||
Eigen::MatrixXf dst(3, vertices_count);
|
||||
dst = t * src.colwise().homogeneous();
|
||||
|
||||
std::vector<Vec3f> ret_points(vertices_count, Vec3f::Zero());
|
||||
::memcpy((void*)ret_points.data(), (const void*)dst.data(), data_size);
|
||||
return ret_points;
|
||||
}
|
||||
|
||||
Pointf3s transform(const Pointf3s& points, const Transform3d& t)
|
||||
{
|
||||
unsigned int vertices_count = (unsigned int)points.size();
|
||||
if (vertices_count == 0)
|
||||
return Pointf3s();
|
||||
|
||||
unsigned int data_size = 3 * vertices_count * sizeof(double);
|
||||
|
||||
Eigen::MatrixXd src(3, vertices_count);
|
||||
::memcpy((void*)src.data(), (const void*)points.data(), data_size);
|
||||
|
||||
Eigen::MatrixXd dst(3, vertices_count);
|
||||
dst = t * src.colwise().homogeneous();
|
||||
|
||||
Pointf3s ret_points(vertices_count, Vec3d::Zero());
|
||||
::memcpy((void*)ret_points.data(), (const void*)dst.data(), data_size);
|
||||
return ret_points;
|
||||
}
|
||||
|
||||
void Point::rotate(double angle)
|
||||
{
|
||||
double cur_x = (double)(*this)(0);
|
||||
|
|
|
@ -67,6 +67,9 @@ inline std::string to_string(const Vec2d &pt) { return std::string("[") + std:
|
|||
inline std::string to_string(const Vec3crd &pt) { return std::string("[") + std::to_string(pt(0)) + ", " + std::to_string(pt(1)) + ", " + std::to_string(pt(2)) + "]"; }
|
||||
inline std::string to_string(const Vec3d &pt) { return std::string("[") + std::to_string(pt(0)) + ", " + std::to_string(pt(1)) + ", " + std::to_string(pt(2)) + "]"; }
|
||||
|
||||
std::vector<Vec3f> transform(const std::vector<Vec3f>& points, const Transform3f& t);
|
||||
Pointf3s transform(const Pointf3s& points, const Transform3d& t);
|
||||
|
||||
class Point : public Vec2crd
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue