NEW: add snap connector

Jira:STUDIO-4227

most of the codes are referenced from PrusaSlicer,thanks YuSanka for the original submits

commit 7cd99d98f537198b78158feced2aa8977bfcbe08
Author: YuSanka <yusanka@gmail.com>
Date:   Wed Jul 12 18:06:51 2023 +0200
    WIP: Cut with Rivets
    * Code refactoring: get_connector_mesh() and apply_cut_connectors() moved from ModelObject to CutGizmo.
    * Allow to change values of space and bulges for snaps
7cd99d98f5
...

Change-Id: Id4c7991a0ed5bf9608823601775920a81a3dd1c4
This commit is contained in:
zhou.xu
2023-08-25 15:36:04 +08:00
committed by Lane.Wei
parent 5658d32633
commit 7e51bf41a1
6 changed files with 234 additions and 26 deletions

View File

@@ -237,6 +237,7 @@ private:
enum class CutConnectorType : int {
Plug,
Dowel,
Snap,
Undef
};
@@ -255,6 +256,11 @@ enum class CutConnectorShape : int {
Undef
//,D-shape
};
struct CutConnectorParas
{
float snap_space_proportion{0.3};
float snap_bulge_proportion{0.15};
};
struct CutConnectorAttributes
{
@@ -290,7 +296,7 @@ struct CutConnector
float radius_tolerance; // [0.f : 1.f]
float height_tolerance; // [0.f : 1.f]
CutConnectorAttributes attribs;
CutConnectorParas paras;
CutConnector() : pos(Vec3d::Zero()), rotation_m(Transform3d::Identity()), radius(5.f), height(10.f), radius_tolerance(0.f), height_tolerance(0.1f) {}
CutConnector(Vec3d p, Transform3d rot, float r, float h, float rt, float ht, CutConnectorAttributes attributes)
@@ -468,7 +474,7 @@ public:
bool is_cut() const { return cut_id.id().valid(); }
bool has_connectors() const;
static indexed_triangle_set get_connector_mesh(CutConnectorAttributes connector_attributes);
static indexed_triangle_set get_connector_mesh(CutConnectorAttributes connector_attributes, CutConnectorParas para);
void apply_cut_connectors(const std::string &name);
// invalidate cut state for this object and its connectors/volumes
void invalidate_cut();