OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::SketchPlane Struct Reference

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

Public Member Functions

Vec2d project (const Vec3d &ray_origin, const Vec3d &ray_dir) const
Vec3d to_world (const Vec2d &pt) const
template<class Archive>
void serialize (Archive &ar)

Static Public Member Functions

static SketchPlane from_face (const TopoDS_Face &face)
static SketchPlane XY ()
static SketchPlane XZ ()
static SketchPlane YZ ()

Public Attributes

Vec3d origin {0,0,0}
Vec3d normal {0,0,1}
Vec3d x_axis {1,0,0}
Vec3d y_axis {0,1,0}

Detailed Description

Member Function Documentation

◆ from_face()

SketchPlane Slic3r::SketchPlane::from_face ( const TopoDS_Face & face)
static
86{
87 SketchPlane sp;
88 // Use the first triangulation vertex + face normal
89 TopLoc_Location loc;
90 Handle(Poly_Triangulation) tri = BRep_Tool::Triangulation(face, loc);
91 if (!tri.IsNull() && tri->NbNodes() > 0) {
92 gp_Pnt p = tri->Node(1).Transformed(loc.Transformation());
93 sp.origin = Vec3d(p.X(), p.Y(), p.Z());
94 }
95 // Compute normal from BRep face
96 BRepAdaptor_Surface surf(face);
97 if (surf.GetType() != GeomAbs_Plane) {
98 // Fallback: try to use the first uv point
99 double u1 = surf.FirstUParameter(), v1 = surf.FirstVParameter();
100 gp_Pnt pt; gp_Vec du, dv;
101 surf.D1(u1, v1, pt, du, dv);
102 gp_Dir n = gp_Dir(du.Crossed(dv));
103 sp.normal = Vec3d(n.X(), n.Y(), n.Z());
104 sp.x_axis = Vec3d(du.X(), du.Y(), du.Z()).normalized();
105 sp.y_axis = sp.normal.cross(sp.x_axis).normalized();
106 return sp;
107 }
108 // Plane face — use the plane directly
109 gp_Pln pln = surf.Plane();
110 sp.origin = Vec3d(pln.Location().X(), pln.Location().Y(), pln.Location().Z());
111 gp_Dir n = pln.Axis().Direction();
112 sp.normal = Vec3d(n.X(), n.Y(), n.Z());
113 gp_Dir xd = pln.XAxis().Direction();
114 sp.x_axis = Vec3d(xd.X(), xd.Y(), xd.Z());
115 sp.y_axis = sp.normal.cross(sp.x_axis).normalized();
116 return sp;
117}
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68

References normal, origin, x_axis, and y_axis.

Referenced by Slic3r::GUI::DesignPanel::add_imported_sketch(), Slic3r::CadDocument::apply_cut(), Slic3r::CadDocument::apply_feature(), Slic3r::GUI::DesignPanel::open_text_dialog(), and Slic3r::GUI::DesignPanel::update_extrude_gizmo().

Here is the caller graph for this function:

◆ project()

Vec2d Slic3r::SketchPlane::project ( const Vec3d & ray_origin,
const Vec3d & ray_dir ) const
120{
121 double denom = ray_dir.dot(normal);
122 if (std::abs(denom) < 1e-12)
123 return {0, 0}; // ray parallel to plane
124 double t = (origin - ray_origin).dot(normal) / denom;
125 if (t < 0)
126 return {0, 0}; // behind camera
127 Vec3d hit = ray_origin + t * ray_dir;
128 Vec3d local = hit - origin;
129 return {local.dot(x_axis), local.dot(y_axis)};
130}
@ local
Definition Time.hpp:13
T dot(const boost::geometry::model::d2::point_xy< T > &v1, const boost::geometry::model::d2::point_xy< T > &v2)
Definition ExtrusionSimulator.cpp:154
Vec3d y_axis
Definition SketchEngine.hpp:54
Vec3d x_axis
Definition SketchEngine.hpp:53
Vec3d normal
Definition SketchEngine.hpp:52
Vec3d origin
Definition SketchEngine.hpp:51

References Slic3r::dot(), normal, origin, x_axis, and y_axis.

Referenced by Slic3r::GUI::DesignSketchTool::drag_helix_handle().

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

◆ serialize()

template<class Archive>
void Slic3r::SketchPlane::serialize ( Archive & ar)
inline
68{ ar(origin, normal, x_axis, y_axis); }

References normal, origin, x_axis, and y_axis.

◆ to_world()

Vec3d Slic3r::SketchPlane::to_world ( const Vec2d & pt) const

◆ XY()

◆ XZ()

SketchPlane Slic3r::SketchPlane::XZ ( )
inlinestatic
61{ return {{0,0,0}, {0,1,0}, {1,0,0}, {0,0,1}}; }

Referenced by Slic3r::GUI::anonymous_namespace{McpControl.cpp}::action_sketch_begin(), Slic3r::GUI::anonymous_namespace{McpControl.cpp}::plane_from(), Slic3r::GUI::plane_from_index(), Slic3r::CadDocument::resolve_datum_axes(), Slic3r::CadDocument::resolve_datum_planes(), and Slic3r::GUI::DesignPanel::update_reference_planes().

Here is the caller graph for this function:

◆ YZ()

SketchPlane Slic3r::SketchPlane::YZ ( )
inlinestatic
62{ return {{0,0,0}, {1,0,0}, {0,1,0}, {0,0,1}}; }

Referenced by Slic3r::GUI::anonymous_namespace{McpControl.cpp}::action_sketch_begin(), Slic3r::GUI::anonymous_namespace{McpControl.cpp}::plane_from(), Slic3r::GUI::plane_from_index(), Slic3r::CadDocument::resolve_datum_axes(), Slic3r::CadDocument::resolve_datum_planes(), and Slic3r::GUI::DesignPanel::update_reference_planes().

Here is the caller graph for this function:

Member Data Documentation

◆ normal

Vec3d Slic3r::SketchPlane::normal {0,0,1}
52{0,0,1};

Referenced by Slic3r::GUI::DesignPanel::DesignPanel(), Slic3r::CadDocument::apply_cut(), Slic3r::CadDocument::apply_feature(), Slic3r::CadDocument::build_sketch_wire(), Slic3r::GUI::DesignSketchTool::drag_helix_handle(), Slic3r::SketchEngine::entities_to_wires(), Slic3r::GUI::face_plane_inward(), Slic3r::frame_from(), from_face(), Slic3r::GUI::index_from_plane(), Slic3r::GUI::is_base_plane(), Slic3r::SketchEngine::make_extrude(), Slic3r::SketchEngine::make_extrude_face(), Slic3r::SketchEngine::make_extrude_regions(), Slic3r::SketchEngine::make_extrude_taper(), Slic3r::SketchEngine::make_extrude_two_sided(), Slic3r::SketchEngine::make_pocket(), Slic3r::offset_angle_plane(), project(), Slic3r::project_edges_to_entities(), Slic3r::GUI::DesignSketchTool::render_cut_gizmo(), Slic3r::GUI::DesignSketchTool::render_draft_gizmo(), Slic3r::GUI::DesignSketchTool::render_extrude_gizmo(), Slic3r::GUI::DesignSketchTool::render_fillet_gizmo(), Slic3r::GUI::DesignSketchTool::render_hole_gizmo(), Slic3r::GUI::DesignSketchTool::render_mate_connectors(), Slic3r::GUI::DesignSketchTool::render_mate_face(), Slic3r::GUI::DesignSketchTool::render_move_gizmo(), Slic3r::GUI::DesignSketchTool::render_pattern_gizmo(), Slic3r::GUI::DesignSketchTool::render_revolve_gizmo(), Slic3r::GUI::DesignSketchTool::render_shell_gizmo(), Slic3r::GUI::DesignSketchTool::render_thread_gizmo(), Slic3r::GUI::DesignSketchTool::render_view_helpers(), Slic3r::CadDocument::resolve_datum_axes(), Slic3r::CadDocument::resolve_datum_planes(), serialize(), Slic3r::GUI::DesignPanel::update_datum_gizmo(), Slic3r::GUI::DesignPanel::update_extrude_gizmo(), Slic3r::GUI::DesignCanvas::view_normal_to_sketch(), and Slic3r::SketchEngine::wires_to_face().

◆ origin

Vec3d Slic3r::SketchPlane::origin {0,0,0}
51{0,0,0};

Referenced by Slic3r::GUI::DesignPanel::DesignPanel(), Slic3r::CadDocument::apply_cut(), Slic3r::CadDocument::apply_feature(), Slic3r::CadDocument::build_sketch_wire(), Slic3r::GUI::DesignSketchTool::drag_helix_handle(), Slic3r::GUI::face_plane_inward(), Slic3r::frame_from(), from_face(), Slic3r::GUI::DesignPanel::hole_plane(), Slic3r::GUI::is_base_plane(), Slic3r::SketchEngine::make_extrude_regions(), Slic3r::offset_angle_plane(), Slic3r::GUI::pick_reference_square(), Slic3r::GUI::anonymous_namespace{McpControl.cpp}::plane_from(), Slic3r::GUI::DesignPanel::plane_from_choice(), project(), Slic3r::project_edges_to_entities(), Slic3r::GUI::reference_square(), Slic3r::GUI::DesignSketchTool::render_cut_gizmo(), Slic3r::GUI::DesignSketchTool::render_draft_gizmo(), Slic3r::GUI::DesignSketchTool::render_extrude_gizmo(), Slic3r::GUI::DesignSketchTool::render_fillet_gizmo(), Slic3r::GUI::DesignSketchTool::render_hole_gizmo(), Slic3r::GUI::DesignSketchTool::render_mate_connectors(), Slic3r::GUI::DesignSketchTool::render_mate_face(), Slic3r::GUI::DesignSketchTool::render_move_gizmo(), Slic3r::GUI::DesignSketchTool::render_pattern_gizmo(), Slic3r::GUI::DesignSketchTool::render_revolve_gizmo(), Slic3r::GUI::DesignSketchTool::render_shell_gizmo(), Slic3r::GUI::DesignSketchTool::render_thread_gizmo(), Slic3r::GUI::DesignSketchTool::render_view_helpers(), Slic3r::CadDocument::resolve_datum_axes(), Slic3r::CadDocument::resolve_datum_planes(), Slic3r::revolve_axis_of(), serialize(), Slic3r::GUI::DesignPanel::thread_plane(), to_world(), Slic3r::GUI::DesignPanel::update_datum_gizmo(), Slic3r::GUI::DesignPanel::update_extrude_gizmo(), Slic3r::GUI::DesignPanel::update_pattern_gizmo(), Slic3r::GUI::DesignPanel::update_reference_planes(), Slic3r::GUI::DesignPanel::update_revolve_gizmo(), Slic3r::GUI::DesignCanvas::view_normal_to_sketch(), and Slic3r::SketchEngine::wires_to_face().

◆ x_axis

◆ y_axis


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