mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-05 21:01:56 +00:00
Every connector hole was moved 0.05 mm toward the cut face so it would open the face instead of leaving a coplanar skin. Moving the whole volume also moved its far end, so a plug hole was 0.05 mm shallower than depth plus tolerance, and each dowel hole 0.05 mm shallower than depth plus half the tolerance. Grow the plug and snap hole by the overlap at the face instead of moving it, and cut each dowel half just past the plane so the holes keep their depth and still overlap the face. The connector tests now measure each hole from the cut face, which is what shows the missing 0.05 mm, and also run on a tilted, shifted cut plane.
77 lines
2.8 KiB
C++
77 lines
2.8 KiB
C++
#ifndef slic3r_CutUtils_hpp_
|
|
#define slic3r_CutUtils_hpp_
|
|
|
|
#include "enum_bitmask.hpp"
|
|
#include "Point.hpp"
|
|
#include "Model.hpp"
|
|
|
|
#include <optional>
|
|
#include <vector>
|
|
|
|
namespace Slic3r {
|
|
|
|
using ModelObjectPtrs = std::vector<ModelObject*>;
|
|
|
|
// A connector hole reaches this far out of the cut face, so the face is open instead of covered by a coplanar skin.
|
|
inline constexpr double CONNECTOR_HOLE_OVERLAP = 0.05;
|
|
|
|
enum class ModelObjectCutAttribute : int { KeepUpper, KeepLower, KeepAsParts, FlipUpper, FlipLower, PlaceOnCutUpper, PlaceOnCutLower, CreateDowels, InvalidateCutInfo, KeepPaint };
|
|
using ModelObjectCutAttributes = enum_bitmask<ModelObjectCutAttribute>;
|
|
ENABLE_ENUM_BITMASK_OPERATORS(ModelObjectCutAttribute);
|
|
|
|
|
|
class Cut {
|
|
|
|
Model m_model;
|
|
int m_instance;
|
|
const Transform3d m_cut_matrix;
|
|
ModelObjectCutAttributes m_attributes;
|
|
|
|
void post_process(ModelObject* object, ModelObjectPtrs& objects, bool keep, bool place_on_cut, bool flip);
|
|
void post_process(ModelObject* upper_object, ModelObject* lower_object, ModelObjectPtrs& objects);
|
|
void finalize(const ModelObjectPtrs& objects, const std::vector<std::optional<TriangleSelector::SavedPainting>>& saved_paintings);
|
|
|
|
public:
|
|
|
|
Cut(const ModelObject* object, int instance, const Transform3d& cut_matrix,
|
|
ModelObjectCutAttributes attributes = ModelObjectCutAttribute::KeepUpper |
|
|
ModelObjectCutAttribute::KeepLower |
|
|
ModelObjectCutAttribute::KeepAsParts );
|
|
~Cut() { m_model.clear_objects(); }
|
|
|
|
struct Groove
|
|
{
|
|
float depth{ 0.f };
|
|
float width{ 0.f };
|
|
float flaps_angle{ 0.f };
|
|
float angle{ 0.f };
|
|
float depth_init{ 0.f };
|
|
float width_init{ 0.f };
|
|
float flaps_angle_init{ 0.f };
|
|
float angle_init{ 0.f };
|
|
float depth_tolerance{ 0.1f };
|
|
float width_tolerance{ 0.1f };
|
|
};
|
|
|
|
struct Part
|
|
{
|
|
bool selected;
|
|
bool is_modifier;
|
|
};
|
|
|
|
const ModelObjectPtrs& perform_with_plane();
|
|
const ModelObjectPtrs& perform_by_contour(const ModelObject* src_object, std::vector<Part> parts, int dowels_count);
|
|
const ModelObjectPtrs& perform_with_groove(const Groove& groove,
|
|
const Transform3d& rotation_m,
|
|
const int groove_count,
|
|
const float groove_gap,
|
|
const float m_radius,
|
|
bool keep_as_parts = false);
|
|
|
|
static float calculate_groove_width(const Cut::Groove& groove, const float m_radius);
|
|
}; // namespace Cut
|
|
|
|
} // namespace Slic3r
|
|
|
|
#endif /* slic3r_CutUtils_hpp_ */
|