Fix for normal averaging and hidden parameter for max normal Z angle.
This commit is contained in:
parent
a7d8146198
commit
760b1cd9bc
3 changed files with 15 additions and 2 deletions
|
@ -1085,7 +1085,8 @@ bool SLASupportTree::generate(const PointSet &points,
|
||||||
double polar = std::acos(z / r);
|
double polar = std::acos(z / r);
|
||||||
double azimuth = std::atan2(n(1), n(0));
|
double azimuth = std::atan2(n(1), n(0));
|
||||||
|
|
||||||
if(polar >= PI / 2) { // skip if the tilt is not sane
|
// skip if the tilt is not sane
|
||||||
|
if(polar >= PI - cfg.normal_cutoff_angle) {
|
||||||
|
|
||||||
// We saturate the polar angle to 3pi/4
|
// We saturate the polar angle to 3pi/4
|
||||||
polar = std::max(polar, 3*PI / 4);
|
polar = std::max(polar, 3*PI / 4);
|
||||||
|
|
|
@ -67,6 +67,10 @@ struct SupportConfig {
|
||||||
// The elevation in Z direction upwards. This is the space between the pad
|
// The elevation in Z direction upwards. This is the space between the pad
|
||||||
// and the model object's bounding box bottom.
|
// and the model object's bounding box bottom.
|
||||||
double object_elevation_mm = 10;
|
double object_elevation_mm = 10;
|
||||||
|
|
||||||
|
// The max Z angle for a normal at which it will get completely ignored.
|
||||||
|
double normal_cutoff_angle = 110.0 * M_PI / 180.0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PoolConfig;
|
struct PoolConfig;
|
||||||
|
|
|
@ -188,7 +188,15 @@ PointSet normals(const PointSet& points, const EigenMesh3D& emesh,
|
||||||
neighnorms.emplace_back(U.cross(V).normalized());
|
neighnorms.emplace_back(U.cross(V).normalized());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Throw out duplicates. They would case trouble with summing.
|
// Throw out duplicates. They would cause trouble with summing. We will
|
||||||
|
// use std::unique which works on sorted ranges. We will sort by the
|
||||||
|
// coefficient-wise sum of the normals. It should force the same
|
||||||
|
// elements to be consecutive.
|
||||||
|
std::sort(neighnorms.begin(), neighnorms.end(),
|
||||||
|
[](const Vec3d& v1, const Vec3d& v2){
|
||||||
|
return v1.sum() < v2.sum();
|
||||||
|
});
|
||||||
|
|
||||||
auto lend = std::unique(neighnorms.begin(), neighnorms.end(),
|
auto lend = std::unique(neighnorms.begin(), neighnorms.end(),
|
||||||
[](const Vec3d& n1, const Vec3d& n2) {
|
[](const Vec3d& n1, const Vec3d& n2) {
|
||||||
// Compare normals for equivalence. This is controvers stuff.
|
// Compare normals for equivalence. This is controvers stuff.
|
||||||
|
|
Loading…
Reference in a new issue