bool ON_HatchLoop::SetCurve( const ON_Curve& curve) { ON_Curve* pC = curve.DuplicateCurve(); if( pC) { if(pC->Dimension() == 3 && !pC->ChangeDimension(2)) return false; if( m_p2dCurve) delete m_p2dCurve; m_p2dCurve = pC; } return true; }
ON_Surface::ISO ON_Surface::IsIsoparametric( const ON_Curve& curve, const ON_Interval* subdomain ) const { ISO iso = not_iso; if ( subdomain ) { ON_Interval cdom = curve.Domain(); double t0 = cdom.NormalizedParameterAt(subdomain->Min()); double t1 = cdom.NormalizedParameterAt(subdomain->Max()); if ( t0 < t1-ON_SQRT_EPSILON ) { if ( (t0 > ON_SQRT_EPSILON && t0 < 1.0-ON_SQRT_EPSILON) || (t1 > ON_SQRT_EPSILON && t1 < 1.0-ON_SQRT_EPSILON) ) { cdom.Intersection(*subdomain); if ( cdom.IsIncreasing() ) { ON_NurbsCurve nurbs_curve; if ( curve.GetNurbForm( nurbs_curve, 0.0,&cdom) ) { return IsIsoparametric( nurbs_curve, 0 ); } } } } } ON_BoundingBox bbox; double tolerance = 0.0; const int dim = curve.Dimension(); if ( (dim == 2 || dim==3) && curve.GetBoundingBox(bbox) ) { iso = IsIsoparametric( bbox ); switch (iso) { case x_iso: case W_iso: case E_iso: // make sure curve is a (nearly) vertical line // and weed out vertical scribbles tolerance = bbox.m_max.x - bbox.m_min.x; if ( tolerance < ON_ZERO_TOLERANCE && ON_ZERO_TOLERANCE*1024.0 <= (bbox.m_max.y-bbox.m_min.y) ) { // 26 March 2007 Dale Lear // If tolerance is tiny, then use ON_ZERO_TOLERANCE // This fixes cases where iso curves where not getting // the correct flag because tol=1e-16 and the closest // point to line had calculation errors of 1e-15. tolerance = ON_ZERO_TOLERANCE; } if ( !curve.IsLinear( tolerance ) ) iso = not_iso; break; case y_iso: case S_iso: case N_iso: // make sure curve is a (nearly) horizontal line // and weed out horizontal scribbles tolerance = bbox.m_max.y - bbox.m_min.y; if ( tolerance < ON_ZERO_TOLERANCE && ON_ZERO_TOLERANCE*1024.0 <= (bbox.m_max.x-bbox.m_min.x) ) { // 26 March 2007 Dale Lear // If tolerance is tiny, then use ON_ZERO_TOLERANCE // This fixes cases where iso curves where not getting // the correct flag because tol=1e-16 and the closest // point to line had calculation errors of 1e-15. tolerance = ON_ZERO_TOLERANCE; } if ( !curve.IsLinear( tolerance ) ) iso = not_iso; break; default: // nothing here break; } } return iso; }