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

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

Inheritance diagram for Slic3r::TriangleSelector::Capsule3D:
Collaboration diagram for Slic3r::TriangleSelector::Capsule3D:

Public Member Functions

 Capsule3D ()=delete
 Capsule3D (const Vec3f &first_center_, const Vec3f &second_center_, const Vec3f &source_, float radius_world, const Transform3d &trafo_, const ClippingPlane &clipping_plane_)
 ~Capsule3D () override=default
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 Vec3f &p1, const Vec3f &p2, const Vec3f &p3) 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 &first_center, const Vec3f &second_center, const Vec3f &camera_pos, const float cursor_radius, const CursorType cursor_type, 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 first_center
Vec3f second_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

Detailed Description

Constructor & Destructor Documentation

◆ Capsule3D() [1/2]

Slic3r::TriangleSelector::Capsule3D::Capsule3D ( )
delete

◆ Capsule3D() [2/2]

Slic3r::TriangleSelector::Capsule3D::Capsule3D ( const Vec3f & first_center_,
const Vec3f & second_center_,
const Vec3f & source_,
float radius_world,
const Transform3d & trafo_,
const ClippingPlane & clipping_plane_ )
inlineexplicit
243 : TriangleSelector::DoublePointCursor(first_center_, second_center_, source_, radius_world, trafo_, clipping_plane_)
244 {}

References Slic3r::TriangleSelector::DoublePointCursor::DoublePointCursor(), and Slic3r::TriangleSelector::Cursor::TriangleSelector.

Here is the call graph for this function:

◆ ~Capsule3D()

Slic3r::TriangleSelector::Capsule3D::~Capsule3D ( )
overridedefault

Member Function Documentation

◆ cursor_factory()

std::unique_ptr< Cursor > Slic3r::TriangleSelector::DoublePointCursor::cursor_factory ( const Vec3f & first_center,
const Vec3f & second_center,
const Vec3f & camera_pos,
const float cursor_radius,
const CursorType cursor_type,
const Transform3d & trafo_matrix,
const ClippingPlane & clipping_plane )
inlinestaticinherited
172 {
173 assert(cursor_type == TriangleSelector::CursorType::CIRCLE || cursor_type == TriangleSelector::CursorType::SPHERE);
174 if (cursor_type == TriangleSelector::CursorType::SPHERE)
175 return std::make_unique<TriangleSelector::Capsule3D>(first_center, second_center, camera_pos, cursor_radius, trafo_matrix, clipping_plane);
176 else
177 return std::make_unique<TriangleSelector::Capsule2D>(first_center, second_center, camera_pos, cursor_radius, trafo_matrix, clipping_plane);
178 }
ClippingPlane clipping_plane
Definition TriangleSelector.hpp:130
Vec3f second_center
Definition TriangleSelector.hpp:184
Vec3f first_center
Definition TriangleSelector.hpp:183
@ SPHERE
Definition TriangleSelector.hpp:83
@ CIRCLE
Definition TriangleSelector.hpp:82

References Slic3r::TriangleSelector::CIRCLE, Slic3r::TriangleSelector::Cursor::clipping_plane, first_center, second_center, and Slic3r::TriangleSelector::SPHERE.

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

Here is the caller graph for this function:

◆ is_edge_inside_cursor()

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

Implements Slic3r::TriangleSelector::Cursor.

2266{
2267 std::array<Vec3f, 3> pts;
2268 for (int i = 0; i < 3; ++i) {
2269 pts[i] = vertices[tr.verts_idxs[i]].v;
2270 if (!this->uniform_scaling)
2271 pts[i] = this->trafo * pts[i];
2272 }
2273
2274 for (int side = 0; side < 3; ++side) {
2275 const Vec3f &edge_a = pts[side];
2276 const Vec3f &edge_b = pts[side < 2 ? side + 1 : 0];
2277 if (test_line_inside_capsule(edge_a, edge_b, this->first_center, this->second_center, this->radius))
2278 return true;
2279 }
2280
2281 return false;
2282}
Transform3f trafo
Definition TriangleSelector.hpp:121
bool uniform_scaling
Definition TriangleSelector.hpp:124
float radius
Definition TriangleSelector.hpp:126
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65
static bool test_line_inside_capsule(const Vec3f &line_a, const Vec3f &line_b, const Vec3f &capsule_p, const Vec3f &capsule_q, const float capsule_radius)
Definition TriangleSelector.cpp:130

References Slic3r::TriangleSelector::DoublePointCursor::first_center, Slic3r::TriangleSelector::Cursor::radius, Slic3r::TriangleSelector::DoublePointCursor::second_center, Slic3r::test_line_inside_capsule(), Slic3r::TriangleSelector::Cursor::trafo, Slic3r::TriangleSelector::Cursor::uniform_scaling, and Slic3r::TriangleSelector::Triangle::verts_idxs.

Here is the call graph for this function:

◆ is_facet_visible() [1/2]

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

Implements Slic3r::TriangleSelector::Cursor.

249{ return true; }

◆ is_facet_visible() [2/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_mesh_point_inside()

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

Implements Slic3r::TriangleSelector::Cursor.

2164{
2165 const Vec3f transformed_point = uniform_scaling ? point : Vec3f(trafo * point);
2166 const Vec3f first_center_diff = this->first_center - transformed_point;
2167 const Vec3f second_center_diff = this->second_center - transformed_point;
2168 if (first_center_diff.squaredNorm() < this->radius_sqr || second_center_diff.squaredNorm() < this->radius_sqr)
2170
2171 // First, check if the point pt is laying between planes defined by first_center and second_center.
2172 // Then check if it is inside the cylinder between first_center and second_center.
2173 const Vec3f centers_diff = this->second_center - this->first_center;
2174 if (first_center_diff.dot(centers_diff) <= 0.f && second_center_diff.dot(centers_diff) >= 0.f && (first_center_diff.cross(centers_diff).norm() / centers_diff.norm()) <= this->radius)
2176
2177 return false;
2178}
static bool is_mesh_point_not_clipped(const Vec3f &point, const TriangleSelector::ClippingPlane &clipping_plane)
Definition TriangleSelector.cpp:2135

References Slic3r::TriangleSelector::Cursor::clipping_plane, Slic3r::TriangleSelector::DoublePointCursor::first_center, Slic3r::is_mesh_point_not_clipped(), Slic3r::TriangleSelector::DoublePointCursor::second_center, Slic3r::TriangleSelector::Cursor::trafo, and Slic3r::TriangleSelector::Cursor::uniform_scaling.

Here is the call graph for this function:

◆ 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::DoublePointCursor::is_pointer_in_triangle ( const Vec3f & p1,
const Vec3f & p2,
const Vec3f & p3 ) const
overridevirtualinherited

Implements Slic3r::TriangleSelector::Cursor.

2243{
2246}
Vec3f dir
Definition TriangleSelector.hpp:128
static bool is_circle_pointer_inside_triangle(const Vec3f &p1_, const Vec3f &p2_, const Vec3f &p3_, const Vec3f &center, const Vec3f &dir, const bool uniform_scaling, const Transform3f &trafo)
Definition TriangleSelector.cpp:2214

References Slic3r::TriangleSelector::Cursor::dir, first_center, Slic3r::is_circle_pointer_inside_triangle(), second_center, Slic3r::TriangleSelector::Cursor::trafo, and Slic3r::TriangleSelector::Cursor::uniform_scaling.

Here is the call graph for this function:

◆ 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

◆ clipping_plane

◆ dir

◆ first_center

◆ radius

◆ radius_sqr

◆ second_center

◆ 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: