OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::TriangleSelector::HeightRange Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/TriangleSelector.hpp>

Inheritance diagram for Slic3r::TriangleSelector::HeightRange:
Collaboration diagram for Slic3r::TriangleSelector::HeightRange:

Public Member Functions

 HeightRange ()=delete
 HeightRange (float z_world_, const Vec3f &source_, float height_, const Transform3d &trafo_, const ClippingPlane &clipping_plane_)
 ~HeightRange () override=default
bool is_pointer_in_triangle (const Vec3f &p1, const Vec3f &p2, const Vec3f &p3) const override
bool is_mesh_point_inside (const Vec3f &point) const override
bool is_edge_inside_cursor (const Triangle &tr, const std::vector< Vertex > &vertices) const override
bool is_facet_visible (int facet_idx, const std::vector< Vec3f > &face_normals) const override
bool is_pointer_in_triangle (const Triangle &tr, const std::vector< Vertex > &vertices) const
virtual int vertices_inside (const Triangle &tr, const std::vector< Vertex > &vertices) const

Static Public Member Functions

static std::unique_ptr< Cursor > cursor_factory (const Vec3f &center, const Vec3f &camera_pos, const float cursor_radius, const CursorType cursor_type, const Transform3d &trafo_matrix, const ClippingPlane &clipping_plane)
static std::unique_ptr< Cursor > cursor_factory (float z_world, const Vec3f &camera_pos, const float height, const Transform3d &trafo_matrix, const ClippingPlane &clipping_plane)
static bool is_facet_visible (const Cursor &cursor, int facet_idx, const std::vector< Vec3f > &face_normals)

Protected Attributes

Vec3f center
Transform3f trafo
Vec3f source
bool uniform_scaling
Transform3f trafo_normal
float radius
float radius_sqr
Vec3f dir = Vec3f(0.f, 0.f, 0.f)
ClippingPlane clipping_plane
friend TriangleSelector

Private Attributes

float m_z_world
float m_height

Detailed Description

Constructor & Destructor Documentation

◆ HeightRange() [1/2]

Slic3r::TriangleSelector::HeightRange::HeightRange ( )
delete

◆ HeightRange() [2/2]

Slic3r::TriangleSelector::HeightRange::HeightRange ( float z_world_,
const Vec3f & source_,
float height_,
const Transform3d & trafo_,
const ClippingPlane & clipping_plane_ )
inlineexplicit
223 : SinglePointCursor(Vec3f(0.f, 0.f, 0.f), source_, 1.f, trafo_, clipping_plane_), m_z_world(z_world_), m_height(height_) {}
float m_height
Definition TriangleSelector.hpp:235
float m_z_world
Definition TriangleSelector.hpp:234
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65

References Slic3r::TriangleSelector::SinglePointCursor::SinglePointCursor(), m_height, and m_z_world.

Here is the call graph for this function:

◆ ~HeightRange()

Slic3r::TriangleSelector::HeightRange::~HeightRange ( )
overridedefault

Member Function Documentation

◆ cursor_factory() [1/2]

std::unique_ptr< Cursor > Slic3r::TriangleSelector::SinglePointCursor::cursor_factory ( const Vec3f & center,
const Vec3f & camera_pos,
const float cursor_radius,
const CursorType cursor_type,
const Transform3d & trafo_matrix,
const ClippingPlane & clipping_plane )
inlinestaticinherited
144 {
145 assert(cursor_type == TriangleSelector::CursorType::CIRCLE || cursor_type == TriangleSelector::CursorType::SPHERE);
146 if (cursor_type == TriangleSelector::CursorType::SPHERE)
147 return std::make_unique<TriangleSelector::Sphere>(center, camera_pos, cursor_radius, trafo_matrix, clipping_plane);
148 else
149 return std::make_unique<TriangleSelector::Circle>(center, camera_pos, cursor_radius, trafo_matrix, clipping_plane);
150 }
ClippingPlane clipping_plane
Definition TriangleSelector.hpp:130
Vec3f center
Definition TriangleSelector.hpp:160
@ SPHERE
Definition TriangleSelector.hpp:83
@ CIRCLE
Definition TriangleSelector.hpp:82

References center, Slic3r::TriangleSelector::CIRCLE, Slic3r::TriangleSelector::Cursor::clipping_plane, and Slic3r::TriangleSelector::SPHERE.

Referenced by Slic3r::GUI::GLGizmoPainterBase::gizmo_event().

Here is the caller graph for this function:

◆ cursor_factory() [2/2]

std::unique_ptr< Cursor > Slic3r::TriangleSelector::SinglePointCursor::cursor_factory ( float z_world,
const Vec3f & camera_pos,
const float height,
const Transform3d & trafo_matrix,
const ClippingPlane & clipping_plane )
inlinestaticinherited
153 {
154 return std::make_unique<TriangleSelector::HeightRange>(z_world, camera_pos, height, trafo_matrix, clipping_plane);
155 }

References Slic3r::TriangleSelector::Cursor::clipping_plane.

◆ is_edge_inside_cursor()

bool Slic3r::TriangleSelector::HeightRange::is_edge_inside_cursor ( const Triangle & tr,
const std::vector< Vertex > & vertices ) const
overridevirtual

Implements Slic3r::TriangleSelector::Cursor.

1184{
1185 float top_z = m_z_world + m_height + EPSILON;
1186 float bot_z = m_z_world - EPSILON;
1187 std::array<Vec3f, 3> pts;
1188 for (int i = 0; i < 3; ++i) {
1189 pts[i] = vertices[tr.verts_idxs[i]].v;
1190 pts[i] = this->trafo * pts[i];
1191 }
1192
1193 return !((pts[0].z() < bot_z && pts[1].z() < bot_z && pts[2].z() < bot_z) ||
1194 (pts[0].z() > top_z && pts[1].z() > top_z && pts[2].z() > top_z));
1195}
#define EPSILON
Definition ColorUtils.cpp:64
Transform3f trafo
Definition TriangleSelector.hpp:121

References EPSILON, m_height, m_z_world, Slic3r::TriangleSelector::Cursor::trafo, and Slic3r::TriangleSelector::Triangle::verts_idxs.

◆ is_facet_visible() [1/2]

bool Slic3r::TriangleSelector::Cursor::is_facet_visible ( const Cursor & cursor,
int facet_idx,
const std::vector< Vec3f > & face_normals )
staticinherited
1101{
1102 assert(facet_idx < int(face_normals.size()));
1103 Vec3f n = face_normals[facet_idx];
1104 if (!cursor.uniform_scaling)
1105 n = cursor.trafo_normal * n;
1106 return n.dot(cursor.dir) < 0.f;
1107}

References Cursor(), dir, trafo_normal, and uniform_scaling.

Here is the call graph for this function:

◆ is_facet_visible() [2/2]

bool Slic3r::TriangleSelector::HeightRange::is_facet_visible ( int facet_idx,
const std::vector< Vec3f > & face_normals ) const
inlineoverridevirtual

Implements Slic3r::TriangleSelector::Cursor.

230 {
231 return true;
232 }

◆ is_mesh_point_inside()

bool Slic3r::TriangleSelector::HeightRange::is_mesh_point_inside ( const Vec3f & point) const
overridevirtual

Implements Slic3r::TriangleSelector::Cursor.

1173{
1174 // just use 40% edge limit as tolerance
1175 const float tolerance = 0.02;
1176 const Vec3f transformed_point = trafo * point;
1177 float top_z = m_z_world + m_height + tolerance;
1178 float bot_z = m_z_world - tolerance;
1179
1180 return transformed_point.z() > bot_z && transformed_point.z() < top_z;
1181}

References m_height, m_z_world, and Slic3r::TriangleSelector::Cursor::trafo.

◆ is_pointer_in_triangle() [1/2]

bool Slic3r::TriangleSelector::Cursor::is_pointer_in_triangle ( const Triangle & tr,
const std::vector< Vertex > & vertices ) const
inherited
1092 {
1093 const Vec3f& p1 = vertices[tr.verts_idxs[0]].v;
1094 const Vec3f& p2 = vertices[tr.verts_idxs[1]].v;
1095 const Vec3f& p3 = vertices[tr.verts_idxs[2]].v;
1096 return this->is_pointer_in_triangle(p1, p2, p3);
1097}
bool is_pointer_in_triangle(const Triangle &tr, const std::vector< Vertex > &vertices) const
Definition TriangleSelector.cpp:1092

References is_pointer_in_triangle(), and Slic3r::TriangleSelector::Triangle::verts_idxs.

Referenced by is_pointer_in_triangle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_pointer_in_triangle() [2/2]

bool Slic3r::TriangleSelector::HeightRange::is_pointer_in_triangle ( const Vec3f & p1,
const Vec3f & p2,
const Vec3f & p3 ) const
overridevirtual

Implements Slic3r::TriangleSelector::Cursor.

1168{
1169 return false;
1170}

◆ vertices_inside()

int Slic3r::TriangleSelector::Cursor::vertices_inside ( const Triangle & tr,
const std::vector< Vertex > & vertices ) const
virtualinherited
1111{
1112 int inside = 0;
1113 for (size_t i = 0; i < 3; ++i)
1114 if (this->is_mesh_point_inside(vertices[tr.verts_idxs[i]].v))
1115 ++inside;
1116
1117 return inside;
1118}
virtual bool is_mesh_point_inside(const Vec3f &point) const =0
bool inside(const Polygons &polygons, const Point &p)
Definition TreeNode.cpp:160

References is_mesh_point_inside(), and Slic3r::TriangleSelector::Triangle::verts_idxs.

Here is the call graph for this function:

Member Data Documentation

◆ center

◆ clipping_plane

◆ dir

◆ m_height

float Slic3r::TriangleSelector::HeightRange::m_height
private

◆ m_z_world

float Slic3r::TriangleSelector::HeightRange::m_z_world
private

◆ radius

◆ radius_sqr

◆ source

◆ trafo

◆ trafo_normal

Transform3f Slic3r::TriangleSelector::Cursor::trafo_normal
protectedinherited

Referenced by Cursor(), and is_facet_visible().

◆ TriangleSelector

friend Slic3r::TriangleSelector::Cursor::TriangleSelector
protectedinherited

◆ uniform_scaling


The documentation for this class was generated from the following files: