bool ON_Brep::IsValidForV2( const ON_BrepEdge& edge ) const { int ei = edge.m_edge_index; if ( ei < 0 || ei >= m_E.Count() ) return false; if ( &edge != &m_E[ei] ) return false; if ( edge.ProxyCurveIsReversed() ) return false; if ( edge.Domain() != edge.ProxyCurveDomain() ) return false; const ON_Curve * curve = edge.EdgeCurveOf(); if ( curve != edge.ProxyCurve() ) return false; const ON_NurbsCurve* nurbs_curve = ON_NurbsCurve::Cast(curve); if ( 0 == nurbs_curve ) return false; if ( !nurbs_curve->IsClamped(2) ) return false; if ( nurbs_curve->m_dim != 3 ) return false; if ( nurbs_curve->m_is_rat ) { // 2 June 2003 Dale Lear - RR 8809 fix // V2 likes end weights to be 1.0 if ( nurbs_curve->m_cv[3] != 1.0 || nurbs_curve->CV(nurbs_curve->m_cv_count-1)[3] != 1.0 ) { return false; } } if ( curve->Domain() != edge.Domain() ) return false; // 14 April 2003 Dale Lear // RR 8808 - V2 requires edges to be strictly closed/open if ( nurbs_curve->m_cv_count >= 4 && 0 == ON_ComparePoint( nurbs_curve->m_dim, nurbs_curve->m_is_rat, nurbs_curve->m_cv, nurbs_curve->CV(nurbs_curve->m_cv_count-1) ) ) { if ( edge.m_vi[0] != edge.m_vi[1] ) return false; } else if (edge.m_vi[0] == edge.m_vi[1] ) { return false; } return true; }
int brep_edge_check(int reason, const SubsurfaceBBNode* sbv, const ON_BrepFace* face, const ON_Surface* surf, const ON_Ray& r, HitList& hits) { // if the intersection was not found for any reason, we need to // check and see if we are close to any topological edges; we may // have hit a crack... // the proper way to do this is to only look at edges // interesecting with the subsurface bounding box... but for // now, we'll look at the edges associated with the face for the bounding box... // XXX - optimize this set<ON_BrepEdge*> edges; ON_3dPoint pt; for (int i = 0; i < face->LoopCount(); i++) { ON_BrepLoop* loop = face->Loop(i); for (int j = 0; j < loop->TrimCount(); j++) { ON_BrepTrim* trim = loop->Trim(j); ON_BrepEdge* edge = trim->Edge(); pair<set<ON_BrepEdge*>::iterator, bool> res = edges.insert(edge); // if (res.second) { // only check if its the first time we've seen this // edge const ON_Curve* curve = edge->EdgeCurveOf(); Sample s; if (curve->CloseTo(ON_3dPoint(hits.back().point), BREP_EDGE_MISS_TOLERANCE, s)) { TRACE1("CLOSE TO EDGE"); hits.back().closeToEdge = true; return BREP_INTERSECT_FOUND; } } } return BREP_INTERSECT_TRIMMED; }