Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00015
00016
00017 #include "pcl/surface/3rdparty/opennurbs/opennurbs.h"
00018
00019 bool ON_Brep::IsValidForV2( const ON_BrepTrim& trim ) const
00020 {
00021 int ti = trim.m_trim_index;
00022 if ( ti < 0 || ti >= m_T.Count() )
00023 return false;
00024 if ( &trim != &m_T[ti] )
00025 return false;
00026 if ( trim.ProxyCurveIsReversed() )
00027 return false;
00028 if ( trim.Domain() != trim.ProxyCurveDomain() )
00029 return false;
00030 const ON_Curve * curve = trim.TrimCurveOf();
00031 if ( curve != trim.ProxyCurve() )
00032 return false;
00033 const ON_NurbsCurve* nurbs_curve = ON_NurbsCurve::Cast(curve);
00034 if ( 0 == nurbs_curve )
00035 return false;
00036 if ( !nurbs_curve->IsClamped(2) )
00037 return false;
00038 if ( nurbs_curve->m_dim != 2 )
00039 return false;
00040 if ( nurbs_curve->m_is_rat )
00041 {
00042
00043
00044 if ( nurbs_curve->m_cv[2] != 1.0 || nurbs_curve->CV(nurbs_curve->m_cv_count-1)[2] != 1.0 )
00045 {
00046 return false;
00047 }
00048 }
00049
00050 if ( nurbs_curve->m_cv_count >= 4
00051 && 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) )
00052 )
00053 {
00054
00055
00056 if ( trim.m_vi[0] != trim.m_vi[1] )
00057 {
00058 const ON_BrepLoop* loop = Loop(trim.m_li);
00059 if ( 0 != loop && loop->m_ti.Count() > 1 )
00060 return false;
00061 }
00062 }
00063
00064 if ( curve->Domain() != trim.Domain() )
00065 return false;
00066
00067 return true;
00068 }
00069
00070 bool ON_Brep::IsValidForV2( const ON_BrepEdge& edge ) const
00071 {
00072 int ei = edge.m_edge_index;
00073 if ( ei < 0 || ei >= m_E.Count() )
00074 return false;
00075 if ( &edge != &m_E[ei] )
00076 return false;
00077 if ( edge.ProxyCurveIsReversed() )
00078 return false;
00079 if ( edge.Domain() != edge.ProxyCurveDomain() )
00080 return false;
00081 const ON_Curve * curve = edge.EdgeCurveOf();
00082 if ( curve != edge.ProxyCurve() )
00083 return false;
00084 const ON_NurbsCurve* nurbs_curve = ON_NurbsCurve::Cast(curve);
00085 if ( 0 == nurbs_curve )
00086 return false;
00087 if ( !nurbs_curve->IsClamped(2) )
00088 return false;
00089 if ( nurbs_curve->m_dim != 3 )
00090 return false;
00091 if ( nurbs_curve->m_is_rat )
00092 {
00093
00094
00095 if ( nurbs_curve->m_cv[3] != 1.0 || nurbs_curve->CV(nurbs_curve->m_cv_count-1)[3] != 1.0 )
00096 {
00097 return false;
00098 }
00099 }
00100
00101 if ( curve->Domain() != edge.Domain() )
00102 return false;
00103
00104
00105
00106 if ( nurbs_curve->m_cv_count >= 4
00107 && 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) )
00108 )
00109 {
00110 if ( edge.m_vi[0] != edge.m_vi[1] )
00111 return false;
00112 }
00113 else if (edge.m_vi[0] == edge.m_vi[1] )
00114 {
00115 return false;
00116 }
00117
00118 return true;
00119 }
00120
00121 bool ON_Brep::IsValidForV2() const
00122 {
00123 bool rc = IsValidTopology()?true:false;
00124 if ( rc )
00125 {
00126 int c2i, c3i, si, ti, li, ei, vi, fi, next_ti, lti, next_lti, loop_trim_count;
00127 ON_3dPoint P0, P1;
00128
00129 const int c2_count = m_C2.Count();
00130 const int c3_count = m_C3.Count();
00131 const int s_count = m_S.Count();
00132 const int vertex_count = m_V.Count();
00133 const int edge_count = m_E.Count();
00134 const int face_count = m_F.Count();
00135 const int loop_count = m_L.Count();
00136 const int trim_count = m_T.Count();
00137
00138 for ( c2i = 0; c2i < c2_count; c2i++ )
00139 {
00140
00141 if ( !ON_NurbsCurve::Cast(m_C2[c2i]) )
00142 return false;
00143 }
00144
00145 for ( c3i = 0; c3i < c3_count; c3i++ )
00146 {
00147
00148 if ( !ON_NurbsCurve::Cast(m_C3[c3i]) )
00149 return false;
00150 }
00151
00152 for ( si = 0; si < s_count; si++ )
00153 {
00154
00155 if ( !ON_NurbsSurface::Cast(m_S[si]) )
00156 return false;
00157 }
00158
00159 for ( vi = 0; vi < vertex_count; vi++ )
00160 {
00161 const ON_BrepVertex& vertex = m_V[vi];
00162 if ( vertex.m_vertex_index != vi )
00163 return false;
00164 }
00165
00166 for ( fi = 0; fi < face_count; fi++ )
00167 {
00168 const ON_BrepFace& face = m_F[fi];
00169 if ( face.m_face_index != fi )
00170 return false;
00171 }
00172
00173 for ( ti = 0; ti < trim_count; ti++ )
00174 {
00175 if ( !IsValidForV2( m_T[ti] ) )
00176 return false;
00177 }
00178
00179 for ( ei = 0; ei < edge_count; ei++ )
00180 {
00181 if ( !IsValidForV2(m_E[ei]) )
00182 return false;
00183 }
00184
00185 for ( li = 0; li < loop_count; li++ )
00186 {
00187 const ON_BrepLoop& loop = m_L[li];
00188 if ( loop.m_loop_index == -1 )
00189 return false;
00190 loop_trim_count = loop.m_ti.Count();
00191 for ( lti = 0; lti < loop_trim_count; lti++ )
00192 {
00193 next_lti = (lti+1)%loop_trim_count;
00194 ti = loop.m_ti[lti];
00195 next_ti = loop.m_ti[next_lti];
00196 if ( ti < 0 || ti >= trim_count )
00197 return false;
00198 if ( next_ti < 0 || next_ti >= trim_count )
00199 return false;
00200 P0 = m_T[ti].PointAtEnd();
00201 P1 = m_T[next_ti].PointAtStart();
00202 if ( P0.DistanceTo(P1) > ON_ZERO_TOLERANCE )
00203 return false;
00204 }
00205 }
00206 }
00207
00208 return rc;
00209 }
00210