Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reproject barycenter to avoid boundary shrinking #7633

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ void tangential_relaxation(const VertexRange& vertices,
typedef std::tuple<vertex_descriptor, Vector_3, Point_3> VNP;
std::vector< VNP > barycenters;
auto gt_barycenter = gt.construct_barycenter_3_object();
auto gt_project = gt.construct_projected_point_3_object();

// at each vertex, compute vertex normal
std::unordered_map<vertex_descriptor, Vector_3> vnormals;
Expand Down Expand Up @@ -269,8 +270,19 @@ void tangential_relaxation(const VertexRange& vertices,
//check squared cosine is < 0.25 (~120 degrees)
if (0.25 < dot*dot / ( squared_distance(get(vpm,ph0), get(vpm, v)) *
squared_distance(get(vpm,ph1), get(vpm, v))) )
barycenters.emplace_back(v, vn,
gt_barycenter(get(vpm, ph0), 0.25, get(vpm, ph1), 0.25, get(vpm, v), 0.5));
{
typename GT::Point_3 bary = gt_barycenter(get(vpm, ph0), 0.25, get(vpm, ph1), 0.25, get(vpm, v), 0.5);
// to avoid shrinking of borders, we project back onto the incident segments
typename GT::Segment_3 s1(get(vpm, ph0), get(vpm,v)),
s2(get(vpm, ph1), get(vpm,v));

typename GT::Point_3 p1 = gt_project(s1, bary), p2 = gt_project(s2, bary);

bary = squared_distance(p1, bary)<squared_distance(p2,bary)? p1:p2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compare_squared_distance(p1, p2, bary) == CGAL::SMALLER?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but it is more expensive and I don't think it really matters here.

barycenters.emplace_back(v, vn, bary);
}


}
}
}
Expand Down