mirror of https://github.com/CGAL/cgal
handle degenerate chords
This commit is contained in:
parent
2df0fc716d
commit
d03b529d88
|
|
@ -1550,21 +1550,36 @@ private:
|
||||||
const_cast<Boundary_cycle &>(bcycle).num_anchors = count;
|
const_cast<Boundary_cycle &>(bcycle).num_anchors = count;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
std::cout << "#anchors: " << count << std::endl;
|
||||||
|
|
||||||
FT dist_max(0.0);
|
halfedge_descriptor he_max = bcycle.he_head;
|
||||||
halfedge_descriptor he_max;
|
|
||||||
Vector_3 chord_vec = vector_functor(pt_begin, pt_end);
|
Vector_3 chord_vec = vector_functor(pt_begin, pt_end);
|
||||||
chord_vec = scale_functor(chord_vec,
|
const FT inv_len = FT(1.0) / CGAL::sqrt(chord_vec.squared_length());
|
||||||
FT(1.0 / std::sqrt(CGAL::to_double(chord_vec.squared_length()))));
|
if ((boost::math::isnormal)(inv_len)) {
|
||||||
BOOST_FOREACH(const halfedge_descriptor &he, chord) {
|
FT dist_max(0.0);
|
||||||
Vector_3 vec = vector_functor(pt_begin, m_vpoint_map[target(he, *m_ptm)]);
|
chord_vec = scale_functor(chord_vec, inv_len);
|
||||||
vec = CGAL::cross_product(chord_vec, vec);
|
BOOST_FOREACH(const halfedge_descriptor &he, chord) {
|
||||||
FT dist(std::sqrt(CGAL::to_double(vec.squared_length())));
|
Vector_3 vec = vector_functor(pt_begin, m_vpoint_map[target(he, *m_ptm)]);
|
||||||
if (dist > dist_max) {
|
vec = CGAL::cross_product(chord_vec, vec);
|
||||||
dist_max = dist;
|
FT dist(std::sqrt(CGAL::to_double(vec.squared_length())));
|
||||||
he_max = he;
|
if (dist > dist_max) {
|
||||||
|
dist_max = dist;
|
||||||
|
he_max = he;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
FT dist_max(0.0);
|
||||||
|
BOOST_FOREACH(const halfedge_descriptor &he, chord) {
|
||||||
|
const FT dist = CGAL::sqrt(CGAL::squared_distance(
|
||||||
|
pt_begin, m_vpoint_map[target(he, *m_ptm)]));
|
||||||
|
if (dist > dist_max) {
|
||||||
|
dist_max = dist;
|
||||||
|
he_max = he;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add one anchors to this boundary cycle
|
// add one anchors to this boundary cycle
|
||||||
attach_anchor(he_max);
|
attach_anchor(he_max);
|
||||||
const_cast<Boundary_cycle &>(bcycle).num_anchors++;
|
const_cast<Boundary_cycle &>(bcycle).num_anchors++;
|
||||||
|
|
@ -1784,7 +1799,7 @@ private:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
bool if_subdivide = false;
|
bool if_subdivide = false;
|
||||||
Boundary_chord_iterator chord_max;
|
Boundary_chord_iterator chord_max = chord_begin;
|
||||||
const Point_3 &pt_begin = m_vpoint_map[source(he_first, *m_ptm)];
|
const Point_3 &pt_begin = m_vpoint_map[source(he_first, *m_ptm)];
|
||||||
const Point_3 &pt_end = m_vpoint_map[target(he_last, *m_ptm)];
|
const Point_3 &pt_end = m_vpoint_map[target(he_last, *m_ptm)];
|
||||||
if (anchor_first == anchor_last) {
|
if (anchor_first == anchor_last) {
|
||||||
|
|
@ -1807,20 +1822,34 @@ private:
|
||||||
FT dist_max(0.0);
|
FT dist_max(0.0);
|
||||||
Vector_3 chord_vec = vector_functor(pt_begin, pt_end);
|
Vector_3 chord_vec = vector_functor(pt_begin, pt_end);
|
||||||
FT chord_len(std::sqrt(CGAL::to_double(chord_vec.squared_length())));
|
FT chord_len(std::sqrt(CGAL::to_double(chord_vec.squared_length())));
|
||||||
chord_vec = scale_functor(chord_vec, FT(1.0) / chord_len);
|
const FT inv_len = FT(1.0) / chord_len;
|
||||||
|
bool degenerate_chord = false;
|
||||||
for (Boundary_chord_iterator citr = chord_begin; citr != chord_end; ++citr) {
|
if ((boost::math::isnormal)(inv_len)) {
|
||||||
Vector_3 vec = vector_functor(pt_begin, m_vpoint_map[target(*citr, *m_ptm)]);
|
chord_vec = scale_functor(chord_vec, inv_len);
|
||||||
vec = CGAL::cross_product(chord_vec, vec);
|
for (Boundary_chord_iterator citr = chord_begin; citr != chord_end; ++citr) {
|
||||||
FT dist(std::sqrt(CGAL::to_double(vec.squared_length())));
|
Vector_3 vec = vector_functor(pt_begin, m_vpoint_map[target(*citr, *m_ptm)]);
|
||||||
if (dist > dist_max) {
|
vec = CGAL::cross_product(chord_vec, vec);
|
||||||
chord_max = citr;
|
const FT dist(std::sqrt(CGAL::to_double(vec.squared_length())));
|
||||||
dist_max = dist;
|
if (dist > dist_max) {
|
||||||
|
chord_max = citr;
|
||||||
|
dist_max = dist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
degenerate_chord = true;
|
||||||
|
for (Boundary_chord_iterator citr = chord_begin; citr != chord_end; ++citr) {
|
||||||
|
const FT dist = CGAL::sqrt(CGAL::squared_distance(
|
||||||
|
pt_begin, m_vpoint_map[target(*citr, *m_ptm)]));
|
||||||
|
if (dist > dist_max) {
|
||||||
|
chord_max = citr;
|
||||||
|
dist_max = dist;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FT criterion = dist_max;
|
FT criterion = dist_max;
|
||||||
if (relative_to_chord)
|
if (relative_to_chord && !degenerate_chord)
|
||||||
criterion /= chord_len;
|
criterion /= chord_len;
|
||||||
else
|
else
|
||||||
criterion /= m_average_edge_length;
|
criterion /= m_average_edge_length;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue