ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkGeometricalQuadEdge.h
Go to the documentation of this file.
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 __itkGeometricalQuadEdge_h
00019 #define __itkGeometricalQuadEdge_h
00020 
00021 #include "itkQuadEdge.h"
00022 
00023 namespace itk
00024 {
00059 template< typename TVRef,  typename TFRef,
00060           typename TPrimalData, typename TDualData,
00061           bool PrimalDual = true >
00062 class GeometricalQuadEdge:public QuadEdge
00063 {
00064 public:
00066   typedef GeometricalQuadEdge Self;
00067   typedef QuadEdge            Superclass;
00068   typedef Self *              RawPointer;
00069 
00075   typedef GeometricalQuadEdge< TFRef, TVRef,
00076                                TDualData, TPrimalData, !PrimalDual >         DualType;
00077 
00079   typedef TVRef       OriginRefType;
00080   typedef TFRef       DualOriginRefType;
00081   typedef TPrimalData PrimalDataType;
00082   typedef TDualData   DualDataType;
00083   // Line Cell Id in Mesh Cell Container
00084   // used to go up to LineCell level
00085   typedef TFRef LineCellIdentifier;
00086 public:
00087 
00089   typedef QuadEdgeMeshIteratorGeom< Self >      IteratorGeom;
00090   typedef QuadEdgeMeshConstIteratorGeom< Self > ConstIteratorGeom;
00091 
00093   inline itkQEDefineIteratorGeomMethodsMacro(Onext);
00094   inline itkQEDefineIteratorGeomMethodsMacro(Sym);
00095   inline itkQEDefineIteratorGeomMethodsMacro(Lnext);
00096   inline itkQEDefineIteratorGeomMethodsMacro(Rnext);
00097   inline itkQEDefineIteratorGeomMethodsMacro(Dnext);
00098   inline itkQEDefineIteratorGeomMethodsMacro(Oprev);
00099   inline itkQEDefineIteratorGeomMethodsMacro(Lprev);
00100   inline itkQEDefineIteratorGeomMethodsMacro(Rprev);
00101   inline itkQEDefineIteratorGeomMethodsMacro(Dprev);
00102   inline itkQEDefineIteratorGeomMethodsMacro(InvOnext);
00103   inline itkQEDefineIteratorGeomMethodsMacro(InvLnext);
00104   inline itkQEDefineIteratorGeomMethodsMacro(InvRnext);
00105   inline itkQEDefineIteratorGeomMethodsMacro(InvDnext);
00107 
00109   itkQEAccessorsMacro(Superclass, Self, DualType);
00110 public:
00111 
00113   GeometricalQuadEdge();
00114   virtual ~GeometricalQuadEdge() {}
00115 
00117   inline void SetOrigin(const OriginRefType v)
00118   { m_Origin = v; }
00119 
00120   inline void SetDestination(const OriginRefType v)
00121   { this->GetSym()->SetOrigin(v); }
00122 
00123   inline void SetRight(const DualOriginRefType v)
00124   { this->GetRot()->SetOrigin(v); }
00125 
00126   inline void SetLeft(const DualOriginRefType v)
00127   { this->GetInvRot()->SetOrigin(v); }
00128 
00136   bool SetLnextRingWithSameLeftFace(const DualOriginRefType faceGeom,
00137                                     int maxSize = 100);
00138 
00139   inline void UnsetOrigin()   { m_Origin = m_NoPoint; }
00140   inline void UnsetDestination()  { this->GetSym()->UnsetOrigin(); }
00141   inline void UnsetRight() { this->GetRot()->UnsetOrigin(); }
00142   inline void UnsetLeft()  { this->GetInvRot()->UnsetOrigin(); }
00143 
00145   //ORIENTATION_NOTE: this definition of GetLeft (or GetRight)
00146   // implicitely assumes that the Onext order is counter-clockwise !
00147   inline const OriginRefType GetOrigin() const { return ( m_Origin ); }
00148   inline const OriginRefType GetDestination()  const { return ( GetSym()->GetOrigin() ); }
00149   inline const DualOriginRefType GetRight() const { return ( GetRot()->GetOrigin() ); }
00150   inline const DualOriginRefType GetLeft() const { return ( GetInvRot()->GetOrigin() ); }
00152 
00154   bool IsOriginSet() const;
00155 
00156   bool IsDestinationSet() const;
00157 
00158   bool IsRightSet() const;
00159 
00160   bool IsLeftSet() const;
00161 
00163   inline void SetPrimalData(const PrimalDataType data)
00164   { m_Data = data; this->SetPrimalData(); }
00165   inline void SetDualData(const DualDataType data)
00166   { this->GetRot()->SetPrimalData(data); }
00168 
00169   inline void SetPrimalData() { m_DataSet = true; }
00170   inline void SetDualData()   { this->GetRot()->SetPrimalData(); }
00171 
00172   inline void UnsetPrimalData() { m_Data = false; }
00173   inline void UnsetDualData()   { this->GetRot()->UnsetPrimalData(); }
00174 
00176   inline PrimalDataType GetPrimalData() { return ( m_Data ); }
00177   inline DualDataType   GetDualData()
00178   { return ( this->GetRot()->GetPrimalData() ); }
00180 
00182   inline bool IsPrimalDataSet() { return ( m_DataSet ); }
00183   inline bool IsDualDataSet()
00184   { return ( this->GetRot()->IsPrimalDataSet() ); }
00186 
00191   inline bool IsWire()
00192   { return ( !( this->IsLeftSet() ) && !( this->IsRightSet() ) ); }
00193 
00199   inline bool IsAtBorder()
00200   {
00201     return ( ( this->IsLeftSet() && !this->IsRightSet() )
00202              || ( !this->IsLeftSet() && this->IsRightSet() ) );
00203   }
00204 
00209   inline bool IsInternal() const
00210   { return ( this->IsLeftSet() && this->IsRightSet() ); }
00211 
00212   bool IsOriginInternal() const;
00213 
00214   bool IsLnextSharingSameFace(int maxSize = 100);
00215 
00216   bool IsLnextOfTriangle();
00217 
00218   bool IsInOnextRing(Self *);
00219 
00220   bool IsInLnextRing(Self *);
00221 
00222   Self * GetNextBorderEdgeWithUnsetLeft(Self *edgeTest = 0);
00223 
00224   bool InsertAfterNextBorderEdgeWithUnsetLeft(Self *isol,
00225                                               Self *hint = 0);
00226 
00227   bool ReorderOnextRingBeforeAddFace(Self *second);
00228 
00230   inline bool IsOriginDisconnected()
00231   { return ( this == this->GetOnext() ); }
00232   inline bool IsDestinationDisconnected()
00233   { return ( this->GetSym()->IsOriginDisconnected() ); }
00234   inline bool IsDisconnected()
00235   {
00236     return ( this->IsOriginDisconnected()
00237              && this->IsDestinationDisconnected() );
00238   }
00240 
00241   void Disconnect();
00242 
00243   inline void SetIdent(const LineCellIdentifier & User_Value) { this->m_LineCellIdent = User_Value; }
00244   inline LineCellIdentifier GetIdent() { return ( this->m_LineCellIdent ); }
00245 public:
00246   // Reserved OriginRefType designated to represent the absence of Origin
00247   static const OriginRefType m_NoPoint;
00248 protected:
00249   OriginRefType      m_Origin;    // Geometrical information
00250   PrimalDataType     m_Data;      // User data associated to this edge.
00251   bool               m_DataSet;   // Indicates if the data is set.
00252   LineCellIdentifier m_LineCellIdent;
00253 };
00254 }
00255 
00256 #ifndef ITK_MANUAL_INSTANTIATION
00257 #include "itkGeometricalQuadEdge.hxx"
00258 #endif
00259 
00260 #endif
00261