ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkGeometricalQuadEdge.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkGeometricalQuadEdge_h
19 #define __itkGeometricalQuadEdge_h
20 
21 #include "itkQuadEdge.h"
22 
23 namespace itk
24 {
59 template< typename TVRef, typename TFRef,
60  typename TPrimalData, typename TDualData,
61  bool PrimalDual = true >
63 {
64 public:
68  typedef Self * RawPointer;
69 
75  typedef GeometricalQuadEdge< TFRef, TVRef,
76  TDualData, TPrimalData, !PrimalDual > DualType;
77 
79  typedef TVRef OriginRefType;
80  typedef TFRef DualOriginRefType;
81  typedef TPrimalData PrimalDataType;
82  typedef TDualData DualDataType;
83  // Line Cell Id in Mesh Cell Container
84  // used to go up to LineCell level
85  typedef TFRef LineCellIdentifier;
86 
87 public:
88 
92 
103  inline itkQEDefineIteratorGeomMethodsMacro(InvOnext);
104  inline itkQEDefineIteratorGeomMethodsMacro(InvLnext);
105  inline itkQEDefineIteratorGeomMethodsMacro(InvRnext);
106  inline itkQEDefineIteratorGeomMethodsMacro(InvDnext);
108 
111 
112 public:
115  virtual ~GeometricalQuadEdge() {}
116 
118  inline void SetOrigin(const OriginRefType v)
119  { m_Origin = v; }
120 
121  inline void SetDestination(const OriginRefType v)
122  { this->GetSym()->SetOrigin(v); }
123 
124  inline void SetRight(const DualOriginRefType v)
125  { this->GetRot()->SetOrigin(v); }
126 
127  inline void SetLeft(const DualOriginRefType v)
128  { this->GetInvRot()->SetOrigin(v); }
129 
138  int maxSize = 100);
139 
140  inline void UnsetOrigin() { m_Origin = m_NoPoint; }
141  inline void UnsetDestination() { this->GetSym()->UnsetOrigin(); }
142  inline void UnsetRight() { this->GetRot()->UnsetOrigin(); }
143  inline void UnsetLeft() { this->GetInvRot()->UnsetOrigin(); }
144 
146  //ORIENTATION_NOTE: this definition of GetLeft (or GetRight)
147  // implicitely assumes that the Onext order is counter-clockwise !
148  inline const OriginRefType GetOrigin() const { return ( m_Origin ); }
149  inline const OriginRefType GetDestination() const { return ( GetSym()->GetOrigin() ); }
150  inline const DualOriginRefType GetRight() const { return ( GetRot()->GetOrigin() ); }
151  inline const DualOriginRefType GetLeft() const { return ( GetInvRot()->GetOrigin() ); }
153 
155  bool IsOriginSet() const;
156 
157  bool IsDestinationSet() const;
158 
159  bool IsRightSet() const;
160 
161  bool IsLeftSet() const;
162 
164  inline void SetPrimalData(const PrimalDataType data)
165  { m_Data = data; this->SetPrimalData(); }
166  inline void SetDualData(const DualDataType data)
167  { this->GetRot()->SetPrimalData(data); }
169 
170  inline void SetPrimalData() { m_DataSet = true; }
171  inline void SetDualData() { this->GetRot()->SetPrimalData(); }
172 
173  inline void UnsetPrimalData() { m_Data = false; }
174  inline void UnsetDualData() { this->GetRot()->UnsetPrimalData(); }
175 
177  inline PrimalDataType GetPrimalData() { return ( m_Data ); }
179  { return ( this->GetRot()->GetPrimalData() ); }
181 
183  inline bool IsPrimalDataSet() { return ( m_DataSet ); }
184  inline bool IsDualDataSet()
185  { return ( this->GetRot()->IsPrimalDataSet() ); }
187 
192  inline bool IsWire()
193  { return ( !( this->IsLeftSet() ) && !( this->IsRightSet() ) ); }
194 
200  inline bool IsAtBorder()
201  {
202  return ( ( this->IsLeftSet() && !this->IsRightSet() )
203  || ( !this->IsLeftSet() && this->IsRightSet() ) );
204  }
205 
210  inline bool IsInternal() const
211  { return ( this->IsLeftSet() && this->IsRightSet() ); }
212 
213  bool IsOriginInternal() const;
214 
215  bool IsLnextSharingSameFace(int maxSize = 100);
216 
217  bool IsLnextOfTriangle();
218 
219  bool IsInOnextRing(Self *);
220 
221  bool IsInLnextRing(Self *);
222 
223  Self * GetNextBorderEdgeWithUnsetLeft(Self *edgeTest = 0);
224 
226  Self *hint = 0);
227 
228  bool ReorderOnextRingBeforeAddFace(Self *second);
229 
231  inline bool IsOriginDisconnected()
232  { return ( this == this->GetOnext() ); }
234  { return ( this->GetSym()->IsOriginDisconnected() ); }
235  inline bool IsDisconnected()
236  {
237  return ( this->IsOriginDisconnected()
238  && this->IsDestinationDisconnected() );
239  }
241 
242  void Disconnect();
243 
244  inline void SetIdent(const LineCellIdentifier & User_Value) { this->m_LineCellIdent = User_Value; }
245  inline LineCellIdentifier GetIdent() { return ( this->m_LineCellIdent ); }
246 
247 public:
248  // Reserved OriginRefType designated to represent the absence of Origin
249  static const OriginRefType m_NoPoint;
250 
251 protected:
252  OriginRefType m_Origin; // Geometrical information
253  PrimalDataType m_Data; // User data associated to this edge.
254  bool m_DataSet; // Indicates if the data is set.
256 };
257 }
258 
259 #ifndef ITK_MANUAL_INSTANTIATION
260 #include "itkGeometricalQuadEdge.hxx"
261 #endif
262 
263 #endif
264