mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
Renamed MeshClipper.cpp/.hpp to MeshUtils.cpp/.hpp
More helper classes like the MeshClipper could live here Moved ClippingPlane class in here to start
This commit is contained in:
parent
9782701dd4
commit
70c0c87598
8 changed files with 116 additions and 94 deletions
|
@ -12,6 +12,7 @@
|
|||
#include "Selection.hpp"
|
||||
#include "Gizmos/GLGizmosManager.hpp"
|
||||
#include "GUI_ObjectLayers.hpp"
|
||||
#include "MeshUtils.hpp"
|
||||
|
||||
#include <float.h>
|
||||
|
||||
|
@ -67,54 +68,6 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class ClippingPlane
|
||||
{
|
||||
double m_data[4];
|
||||
|
||||
public:
|
||||
ClippingPlane()
|
||||
{
|
||||
m_data[0] = 0.0;
|
||||
m_data[1] = 0.0;
|
||||
m_data[2] = 1.0;
|
||||
m_data[3] = 0.0;
|
||||
}
|
||||
|
||||
ClippingPlane(const Vec3d& direction, double offset)
|
||||
{
|
||||
Vec3d norm_dir = direction.normalized();
|
||||
m_data[0] = norm_dir(0);
|
||||
m_data[1] = norm_dir(1);
|
||||
m_data[2] = norm_dir(2);
|
||||
m_data[3] = offset;
|
||||
}
|
||||
|
||||
bool operator==(const ClippingPlane& cp) const {
|
||||
return m_data[0]==cp.m_data[0] && m_data[1]==cp.m_data[1] && m_data[2]==cp.m_data[2] && m_data[3]==cp.m_data[3];
|
||||
}
|
||||
bool operator!=(const ClippingPlane& cp) const { return ! (*this==cp); }
|
||||
|
||||
double distance(const Vec3d& pt) const {
|
||||
assert(is_approx(get_normal().norm(), 1.));
|
||||
return (-get_normal().dot(pt) + m_data[3]);
|
||||
}
|
||||
|
||||
void set_normal(const Vec3d& normal) { for (size_t i=0; i<3; ++i) m_data[i] = normal(i); }
|
||||
void set_offset(double offset) { m_data[3] = offset; }
|
||||
Vec3d get_normal() const { return Vec3d(m_data[0], m_data[1], m_data[2]); }
|
||||
bool is_active() const { return m_data[3] != DBL_MAX; }
|
||||
static ClippingPlane ClipsNothing() { return ClippingPlane(Vec3d(0., 0., 1.), DBL_MAX); }
|
||||
const double* get_data() const { return m_data; }
|
||||
|
||||
// Serialization through cereal library
|
||||
template <class Archive>
|
||||
void serialize( Archive & ar )
|
||||
{
|
||||
ar( m_data[0], m_data[1], m_data[2], m_data[3] );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
wxDECLARE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, SimpleEvent);
|
||||
|
||||
using Vec2dEvent = Event<Vec2d>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue