ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkQuadEdge_h 00019 #define __itkQuadEdge_h 00020 00021 #include "itkQuadEdgeMeshBaseIterator.h" 00022 00023 #include "itkMacro.h" 00024 00025 // Debugging macros for classes that do not derive from the itkObject. 00026 // FIXME: Maybe variations of these macros should be moved into 00027 // itkMacro.h 00028 // 00029 #define itkQEDebugMacro(x) \ 00030 { \ 00031 std::ostringstream itkmsg; \ 00032 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \ 00033 << " (" << this << "): " x \ 00034 << "\n\n"; \ 00035 OutputWindowDisplayDebugText( itkmsg.str().c_str() ); \ 00036 } 00037 #define itkQEWarningMacro(x) \ 00038 { \ 00039 std::ostringstream itkmsg; \ 00040 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \ 00041 << " (" << this << "): " x \ 00042 << "\n\n"; \ 00043 OutputWindowDisplayWarningText( itkmsg.str().c_str() ); \ 00044 } 00045 00046 // ------------------------------------------------------------------------- 00056 #define itkQEAccessorsMacro(st, pt, dt) \ 00057 pt * GetOnext() \ 00058 { \ 00059 return ( dynamic_cast< pt * >( this->st::GetOnext() ) ); \ 00060 } \ 00061 \ 00062 dt *GetRot() \ 00063 { \ 00064 return ( dynamic_cast< dt * >( this->st::GetRot() ) ); \ 00065 } \ 00066 \ 00067 pt *GetSym() \ 00068 { \ 00069 return ( dynamic_cast< pt * >( this->st::GetSym() ) ); \ 00070 } \ 00071 \ 00072 pt *GetLnext() \ 00073 { \ 00074 return ( dynamic_cast< pt * >( this->st::GetLnext() ) ); \ 00075 } \ 00076 \ 00077 pt *GetRnext() \ 00078 { \ 00079 return ( dynamic_cast< pt * >( this->st::GetRnext() ) ); \ 00080 } \ 00081 \ 00082 pt *GetDnext() \ 00083 { \ 00084 return ( dynamic_cast< pt * >( this->st::GetDnext() ) ); \ 00085 } \ 00086 \ 00087 pt *GetOprev() \ 00088 { \ 00089 return ( dynamic_cast< pt * >( this->st::GetOprev() ) ); \ 00090 } \ 00091 \ 00092 pt *GetLprev() \ 00093 { \ 00094 return ( dynamic_cast< pt * >( this->st::GetLprev() ) ); \ 00095 } \ 00096 \ 00097 pt *GetRprev() \ 00098 { \ 00099 return ( dynamic_cast< pt * >( this->st::GetRprev() ) ); \ 00100 } \ 00101 \ 00102 pt *GetDprev() \ 00103 { \ 00104 return ( dynamic_cast< pt * >( this->st::GetDprev() ) ); \ 00105 } \ 00106 \ 00107 dt *GetInvRot() \ 00108 { \ 00109 return ( dynamic_cast< dt * >( this->st::GetInvRot() ) ); \ 00110 } \ 00111 \ 00112 pt *GetInvOnext() \ 00113 { \ 00114 return ( dynamic_cast< pt * >( this->st::GetInvOnext() ) ); \ 00115 } \ 00116 \ 00117 pt *GetInvLnext() \ 00118 { \ 00119 return ( dynamic_cast< pt * >( this->st::GetInvLnext() ) ); \ 00120 } \ 00121 \ 00122 pt *GetInvRnext() \ 00123 { \ 00124 return ( dynamic_cast< pt * >( this->st::GetInvRnext() ) ); \ 00125 } \ 00126 \ 00127 pt *GetInvDnext() \ 00128 { \ 00129 return ( dynamic_cast< pt * >( this->st::GetInvDnext() ) ); \ 00130 } \ 00131 const pt *GetOnext() const \ 00132 { \ 00133 return ( dynamic_cast< const pt * >( this->st::GetOnext() ) ); \ 00134 } \ 00135 \ 00136 const dt *GetRot() const \ 00137 { \ 00138 return ( dynamic_cast< const dt * >( this->st::GetRot() ) ); \ 00139 } \ 00140 \ 00141 const pt *GetSym() const \ 00142 { \ 00143 return ( dynamic_cast< const pt * >( this->st::GetSym() ) ); \ 00144 } \ 00145 \ 00146 const pt *GetLnext() const \ 00147 { \ 00148 return ( dynamic_cast< const pt * >( this->st::GetLnext() ) ); \ 00149 } \ 00150 \ 00151 const pt *GetRnext() const \ 00152 { \ 00153 return ( dynamic_cast< const pt * >( this->st::GetRnext() ) ); \ 00154 } \ 00155 \ 00156 const pt *GetDnext() const \ 00157 { \ 00158 return ( dynamic_cast< const pt * >( this->st::GetDnext() ) ); \ 00159 } \ 00160 \ 00161 const pt *GetOprev() const \ 00162 { \ 00163 return ( dynamic_cast< const pt * >( this->st::GetOprev() ) ); \ 00164 } \ 00165 \ 00166 const pt *GetLprev() const \ 00167 { \ 00168 return ( dynamic_cast< const pt * >( this->st::GetLprev() ) ); \ 00169 } \ 00170 \ 00171 const pt *GetRprev() const \ 00172 { \ 00173 return ( dynamic_cast< const pt * >( this->st::GetRprev() ) ); \ 00174 } \ 00175 \ 00176 const pt *GetDprev() const \ 00177 { \ 00178 return ( dynamic_cast< const pt * >( this->st::GetDprev() ) ); \ 00179 } \ 00180 \ 00181 const dt *GetInvRot() const \ 00182 { \ 00183 return ( dynamic_cast< const dt * >( this->st::GetInvRot() ) ); \ 00184 } \ 00185 \ 00186 const pt *GetInvOnext() const \ 00187 { \ 00188 return ( dynamic_cast< const pt * >( this->st::GetInvOnext() ) ); \ 00189 } \ 00190 \ 00191 const pt *GetInvLnext() const \ 00192 { \ 00193 return ( dynamic_cast< const pt * >( this->st::GetInvLnext() ) ); \ 00194 } \ 00195 \ 00196 const pt *GetInvRnext() const \ 00197 { \ 00198 return ( dynamic_cast< const pt * >( this->st::GetInvRnext() ) ); \ 00199 } \ 00200 \ 00201 const pt *GetInvDnext() const \ 00202 { \ 00203 return ( dynamic_cast< const pt * >( this->st::GetInvDnext() ) ); \ 00204 } 00205 00206 00207 namespace itk 00208 { 00223 class ITK_EXPORT QuadEdge 00224 { 00225 public: 00227 typedef QuadEdge Self; 00228 00230 typedef QuadEdgeMeshIterator< Self > Iterator; 00231 typedef QuadEdgeMeshConstIterator< Self > ConstIterator; 00232 00234 inline itkQEDefineIteratorMethodsMacro(Onext); 00235 // itkQEDefineIteratorMethodsMacro( Sym ); 00236 // itkQEDefineIteratorMethodsMacro( Lnext ); 00237 // itkQEDefineIteratorMethodsMacro( Rnext ); 00238 // itkQEDefineIteratorMethodsMacro( Dnext ); 00239 // itkQEDefineIteratorMethodsMacro( Oprev ); 00240 // itkQEDefineIteratorMethodsMacro( Lprev ); 00241 // itkQEDefineIteratorMethodsMacro( Rprev ); 00242 // itkQEDefineIteratorMethodsMacro( Dprev ); 00243 // itkQEDefineIteratorMethodsMacro( InvOnext ); 00244 // itkQEDefineIteratorMethodsMacro( InvLnext ); 00245 // itkQEDefineIteratorMethodsMacro( InvRnext ); 00246 // itkQEDefineIteratorMethodsMacro( InvDnext ); 00248 00250 QuadEdge(); 00251 virtual ~QuadEdge(); 00253 00255 inline void SetOnext(Self *onext) { this->m_Onext = onext; } 00256 inline void SetRot(Self *rot) { this->m_Rot = rot; } 00258 00262 inline Self * GetOnext() { return this->m_Onext; } 00263 inline Self * GetRot() { return this->m_Rot; } 00264 inline const Self * GetOnext() const { return this->m_Onext; } 00265 inline const Self * GetRot() const { return this->m_Rot; } 00267 00284 // TODO fix this ref 00285 // * \sa \ref DoxySurgeryConnectivity 00286 inline void Splice(Self *b) 00287 { 00288 Self *aNext = this->GetOnext(); 00289 Self *bNext = b->GetOnext(); 00290 Self *alpha = aNext->GetRot(); 00291 Self *beta = bNext->GetRot(); 00292 Self *alphaNext = alpha->GetOnext(); 00293 Self *betaNext = beta->GetOnext(); 00295 00296 this->SetOnext(bNext); 00297 b->SetOnext(aNext); 00298 alpha->SetOnext(betaNext); 00299 beta->SetOnext(alphaNext); 00300 } 00301 00302 // Second order accessors. 00303 00306 inline Self * GetSym() 00307 { 00308 if ( this->m_Rot ) 00309 { 00310 return ( this->m_Rot->m_Rot ); 00311 } 00312 return ( this->m_Rot ); 00313 } 00315 00316 inline const Self * GetSym() const 00317 { 00318 if ( this->m_Rot ) 00319 { 00320 return ( this->m_Rot->m_Rot ); 00321 } 00322 return ( this->m_Rot ); 00323 } 00324 00327 Self * GetLnext(); 00328 00329 const Self * GetLnext() const; 00330 00334 Self * GetRnext(); 00335 00336 const Self * GetRnext() const; 00337 00341 Self * GetDnext(); 00342 00343 const Self * GetDnext() const; 00344 00347 Self * GetOprev(); 00348 00349 const Self * GetOprev() const; 00350 00354 Self * GetLprev(); 00355 00356 const Self * GetLprev() const; 00357 00361 Self * GetRprev(); 00362 00363 const Self * GetRprev() const; 00364 00368 Self * GetDprev(); 00369 00370 const Self * GetDprev() const; 00371 00373 inline Self * GetInvRot() 00374 { 00375 #ifdef NDEBUG 00376 return ( this->GetRot()->GetRot()->GetRot() ); 00377 #else 00378 Self *p1 = this->GetRot(); 00379 if ( !p1 ) { return NULL; } 00380 Self *p2 = p1->GetRot(); 00381 if ( !p2 ) { return NULL; } 00382 Self *p3 = p2->GetRot(); 00383 if ( !p3 ) { return NULL; } 00384 return p3; 00385 #endif 00386 } 00388 00389 inline Self * GetInvOnext() { return this->GetOprev(); } 00390 inline Self * GetInvLnext() { return this->GetLprev(); } 00391 inline Self * GetInvRnext() { return this->GetRprev(); } 00392 inline Self * GetInvDnext() { return this->GetDprev(); } 00393 inline const Self * GetInvRot() const 00394 { 00395 #ifdef NDEBUG 00396 return ( this->GetRot()->GetRot()->GetRot() ); 00397 #else 00398 const Self *p1 = this->GetRot(); 00399 if ( !p1 ) { return NULL; } 00400 const Self *p2 = p1->GetRot(); 00401 if ( !p2 ) { return NULL; } 00402 const Self *p3 = p2->GetRot(); 00403 if ( !p3 ) { return NULL; } 00404 return p3; 00405 #endif 00406 } 00407 00408 inline const Self * GetInvOnext() const { return this->GetOprev(); } 00409 inline const Self * GetInvLnext() const { return this->GetLprev(); } 00410 inline const Self * GetInvRnext() const { return this->GetRprev(); } 00411 inline const Self * GetInvDnext() const { return this->GetDprev(); } 00412 00414 inline bool IsHalfEdge() const { return ( ( m_Onext == this ) || ( m_Rot == NULL ) ); } 00415 inline bool IsIsolated() const { return ( this == this->GetOnext() ); } 00416 bool IsEdgeInOnextRing(Self *testEdge) const; 00418 00419 bool IsLnextGivenSizeCyclic(const int size) const; 00420 00421 unsigned int GetOrder() const; 00422 00423 private: 00427 }; 00428 } 00429 00430 #endif 00431