43 : _pane(acc.get_pane(h)), _ne(count_edges(h))
65 : _pane(acc.get_pane(h)), _ne(3)
100 intersect( pbs, pgs, ngs, c1, c2, is_b_border);
102 if ( std::fabs( *c1) < 1/eps_e && std::fabs( *c2) < 1/eps_e) {
105 double prod1 = v1 * v2;
108 double prod2 = v1 * v2;
112 { prod1 = -prod1; prod2 = -prod2; }
114 *normal_match =
std::max(prod1, prod2);
117 if ( std::fabs(*c1-1) <= eps_e) *c1 = 1.;
118 else if ( std::fabs(*c1) <= eps_e) *c1 = 0.;
120 if ( std::fabs(*c2-1) <= eps_e) *c2 = 1.;
121 else if ( std::fabs(*c2) <= eps_e) *c2 = 0.;
129 std::sqrt( (J[0]*J[0]) * (J[1]*J[1]) * (J[2]*J[2]));
131 if (is_b_border) *orien_match = -*orien_match;
135 if ( is_b_border) { *c1 = 1-*c1; }
137 return *c1 >= 0. && *c1 <= 1. && *c2 >= 0. && *c2 <= 1.;
157 Real *c2,
bool reversed)
const {
159 Vector_3 vb = pbs[1]-pbs[0], vg=pgs[1]-pgs[0], vn=ngs[1]-ngs[0];
170 { a /= max_abc; b /= max_abc; c /= max_abc; d /= max_abc; }
173 Real eps = 0.1, tol_fea = 1;
178 { *c1 = *c2 = HUGE_VAL;
return; }
182 if ( t >= -tol_fea && t <= 1+tol_fea) {
187 s = nominator / denominator;
190 { *c1 = *c2 = HUGE_VAL;
return; }
195 { *c1 = *c2 = HUGE_VAL;
return; }
201 Real temp = -b - sqrt_d;
206 Real temp = -b + sqrt_d;
211 if ( std::fabs(t1 -1.) < eps || std::fabs(t2 -1.) < eps ) {
213 Real b = -(c - d - a);
216 { *c1 = *c2 = HUGE_VAL;
return; }
218 Real temp = -b - sqrt_d;
219 if (std::fabs(t1 - 1.) < eps) t1 = 1 + 2*d / temp;
220 if (std::fabs(t2 - 1.) < eps) t2 = 1 + temp / 2 / a;
223 Real temp = -b + sqrt_d;
224 if (std::fabs(t1 - 1.) < eps) t1 = 1 + temp / 2 / a;
225 if (std::fabs(t2 - 1.) < eps) t2 = 1 + 2*d / temp;
229 if ( t1 >= -tol_fea && t1 <= 1+tol_fea) {
234 s1 = numerator / denominator;
237 s1 = reversed ? HUGE_VAL : -HUGE_VAL;
239 if ( t2 >= -tol_fea && t2 <= 1+tol_fea) {
244 s2 = numerator / denominator;
247 s2 = reversed ? HUGE_VAL : -HUGE_VAL;
249 double start = *c1-eps;
252 if ( s1 < start && s2 < start)
253 { *c1 = *c2 = HUGE_VAL;
return; }
254 else if ( s2 < start || s1 >= start && s1 <= s2)
260 if ( 1-s1 < start && 1-s2 < start)
261 { *c1 = *c2 = -HUGE_VAL;
return; }
262 else if ( 1-s2 < start || 1-s1 >= start && 1-s1 <= 1-s2)
272 Vector_3 v2 = e.interpolate( ngs, t);
273 Vector_3 v3 = e.interpolate( pbs, s)-e.interpolate( pgs, t);
277 std::cerr <<
"WARNING: Rejecting intersection due to too large error "
278 << error <<
". Solution was " << s <<
"," << t << std::endl;
280 *c1 = *c2 = HUGE_VAL;
283 { *c1 =
s; *c2 = t; }
299 if ( eps_np < 0) eps_np = eps_p;
309 const bool comp_dir = ( dir ==
Vector_3(0,0,0));
317 if ( comp_dir) e.interpolate( ns, nc, &dir);
320 Vector_3 f = e.interpolate( ps, nc) - p + t*dir;
321 double et = f*f / e.Jacobian_det( ps,nc);
322 if ( et <= eps_c2 || et >= err)
break;
326 e.Jacobian( ps, nc, J);
329 e.Jacobian( ns, nc, J2);
330 J[0] = J[0] + t*J2[0];
331 J[1] = J[1] + t*J2[1];
337 CGAL::solve( J[0][0], J[0][1], J[0][2], J[1][0], J[1][1], J[1][2],
338 J[2][0], J[2][1], J[2][2], f[0], f[1], f[2],
341 nc =
Point_2( nc[0] - u[0], nc[1] - u[1]); t -= u[2];
343 if ( std::fabs( nc[0]) > 2 || std::fabs( nc[1]) > 2 ) {
350 nc =
Point_2( ( nc[0] <= eps_p && nc[0] >= -eps_np)
351 ? 0. : ( ( nc[0]>=1.-eps_p && nc[0]<=1.+eps_np) ? 1 : nc[0]),
352 ( nc[1] <= eps_p && nc[1] >= -eps_np)
353 ? 0. : ( ( nc[1]>=1.-eps_p && nc[1]<=1.+eps_np) ? 1 : nc[1]));
357 if ( nc[0] < 0.) { nc[0] = nc[1] = 0; }
358 else if ( nc[0] > 1.) { nc[0] = nc[1] = 0; *g = (*g)->
next(); }
362 if ( nc_out) *nc_out = nc;
370 if ( (nc[0] + nc[1]) >= 1-eps_p && (nc[0] + nc[1]) <= 1+eps_np) {
372 if ( nc[0] < eps_p) {
380 else if ( nc[0] == 0.) {
387 else if ( nc[1] == 0.)
392 if ( nc_out) *nc_out = nc;
394 return ( nc[0] >= 0. && nc[1] >= 0. && nc[0]+nc[1] <= 1.);
406 else if ( nc[0] == 1.) {
415 else if ( nc[1] == 0.)
418 else if ( nc[1] == 1.)
424 if ( nc_out) *nc_out = nc;
426 return ( nc[0] >= 0. && nc[0] <= 1. && nc[1] >= 0. && nc[1] <= 1.);
444 const Real eps_e)
const
451 CGAL::solve( c1[0], c1[1], c1[2], n[0], n[1], n[2],
452 b[0], b[1], b[2], f[0], f[1], f[2], s, u, v);
453 if ( std::fabs(s) <= eps_e)
455 else if ( std::fabs(1.-s) <= eps_e)
469 const Real eps_e)
const {
474 Vector_3 qdiff=q2-
q1, bdiff=b2-b1, ndiff=n2-n1;
483 Vector_3 f = ((q1-p) += s*qdiff += u*c2 +=
v*c3);
484 double et = f*f / (qdiff*qdiff);
486 if ( et <= eps_c2 || et >= err)
break;
490 Vector_3 c1 = (u*ndiff +=
v*bdiff += qdiff);
492 CGAL::solve( c1[0], c1[1], c1[2], c2[0], c2[1], c2[2],
493 c3[0], c3[1], c3[2], f[0], f[1], f[2], x[0], x[1], x[2]);
495 s -= x[0]; u -= x[1];
v -= x[2];
498 if ( std::fabs(s) <= eps_e)
500 else if ( std::fabs(1.-s) <= eps_e)
518 if ( pn->
is_feature_1(g) && !is_border && *cg != 0 && *cg!=1)
return;
528 else if ( *cg >= 1-tol){
556 double meas[3] = { nc[0], nc[1], 1-nc[0]-nc[1]};
565 for (
int k=0;
k<3; ++
k) {
567 if ( meas[
k] <= tol && is_feas[
k] &&
568 (meas[
k] <= meas[(
k+1)%3] || !is_feas[(
k+1)%3]) &&
569 (meas[
k] <= meas[(
k+2)%3] || !is_feas[(
k+2)%3])) {
572 if (
k==0) nc[0] = 1-nc[1];
else if (
k==2) nc[0] = nc[1];
575 if ( nc[0]>=1) nc[0] = 1.;
else if ( nc[0]<=0) nc[0] = 0.;
584 for (
int k=0;
k<3; ++
k) {
586 if ( 1-meas[(
k+1)%3] <= tol &&
599 double meas[4] = { nc[0], nc[1], 1-nc[0], 1-nc[1]};
608 for (
int k=0;
k<4; ++
k) {
610 if ( meas[
k] <= tol && is_feas[
k] &&
611 (meas[
k] <= meas[(
k+1)%4] || !is_feas[(
k+1)%4]) &&
612 (meas[
k] <= meas[(
k+2)%4] || !is_feas[(
k+2)%4]) &&
613 (meas[
k] <= meas[(
k+3)%4] || !is_feas[(
k+3)%4]) ) {
616 nc[0] = meas[(
k+3)%4];
619 if ( nc[0]>=1) nc[0] = 1.;
else if ( nc[0]<=0) nc[0] = 0.;
628 for (
int k=0;
k<4; ++
k) {
630 if ( meas[ (
k+3)%4] <= tol && meas[
k] <= tol &&
659 Real match[4] = { nrm_b*nrm_g, nrm_bopp*nrm_g,
660 nrm_b*nrm_gopp, nrm_bopp*nrm_gopp};
663 Real best_match=-1;
int m=0;
664 for (
int i=0;
i<4; ++
i) {
665 if ( match[
i]>best_match) { best_match = match[m=
i]; }
Vector_3 get_tangent(const Halfedge *b, Real a) const
Vertex * get_origin(Halfedge *h) const
bool intersect(const Halfedge *b, const Halfedge *g, Real start, Real *c1, Real *c2, Real *dir, Real *dir_match, bool is_opposite, Real eps_e) const
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
An adaptor for enumerating node IDs of an element.
Real project_green_feature(const Vector_3 &n, const Vector_3 &t, const Point_3 &p1, const Point_3 &p2, const Point_3 &q, const Real eps_p) const
Halfedge * get_opposite(Halfedge *h) const
Vertex_overlay * destination()
RFC_Pane_overlay * get_pane(Vertex *v) const
Base * base()
The id of its base COM::Pane object.
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Halfedge_overlay * opposite()
bool is_feature_1(const Halfedge *h) const
const Vector_3 & get_normal(const Halfedge *h) const
Vector_3 get_projdir(const Halfedge *b, Real a) const
SURF::Vector_3< Real > Vector_3
SURF::Generic_element_2 Generic_element
Real normalmatch(const Halfedge *b, const Halfedge *g) const
RFC_BEGIN_NAME_SPACE HDS_accessor< Tag_true > acc
int get_lid(const Vertex *v) const
Size size_of_edges() const
Vertex_overlay * origin()
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
bool is_on_feature(const Vertex *v) const
void snap_blue_ridge_edge(const Halfedge *b, const Halfedge *g, Real *cb, Real *cg, Parent_type *t, Real tol=0.1) const
#define RFC_END_NAME_SPACE
Halfedge_overlay * prev()
Vertex_overlay * vertex()
Real project_blue_feature(const Vector_3 &n1, const Vector_3 &n2, const Vector_3 &t1, const Vector_3 &t2, const Point_3 &q1, const Point_3 &q2, const Point_3 &p, const Real eps_p) const
#define RFC_BEGIN_NAME_SPACE
int size_of_nodes() const
Number of nodes per element.
static Vector_3 cross_product(const Vector_3 &v, const Vector_3 &w)
void snap_blue_ridge_vertex(const Vertex *v, Halfedge **g, Parent_type *t, Point_2 *nc, Real tol=0.1) const
bool project_onto_element(const Point_3 &p, Halfedge **g, Parent_type *pt, Vector_3 dir, Point_2 *nc_out, const Real eps_p, Real eps_np=-1.) const
double det(const Matrix3D &A)
Halfedge_overlay * next()
Real squared_norm(const Vector_3 &v) const
#define RFC_assertion_code
Size size_of_edges() const
const RFC_Pane_overlay * _pane
Vertex * get_destination(Halfedge *h) const
Some basic geometric data types.
bool is_border(const Halfedge *h) const
std::vector< int > _nodes
bool is_feature_1(const Halfedge *h) const
SURF::Vector_2< Real > Point_2
CGAL_BEGIN_NAMESPACE void solve(const FT &a1, const FT &a2, const FT &a3, const FT &b1, const FT &b2, const FT &b3, const FT &c1, const FT &c2, const FT &c3, const FT &d1, const FT &d2, const FT &d3, FT &x, FT &y, FT &z)