ITK  5.0.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 >
62 class ITK_TEMPLATE_EXPORT GeometricalQuadEdge:public QuadEdge
63 {
64 public:
68  using RawPointer = Self *;
69 
75  using DualType = GeometricalQuadEdge< TFRef, TVRef,
76  TDualData, TPrimalData, !PrimalDual >;
77 
79  using OriginRefType = TVRef;
80  using DualOriginRefType = TFRef;
81  using PrimalDataType = TPrimalData;
82  using DualDataType = TDualData;
83  // Line Cell Id in Mesh Cell Container
84  // used to go up to LineCell level
85  using LineCellIdentifier = TFRef;
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:
114  GeometricalQuadEdge(const GeometricalQuadEdge &) = default;
116  GeometricalQuadEdge & operator=(const GeometricalQuadEdge &) = default;
117  GeometricalQuadEdge & operator=(GeometricalQuadEdge &&) = default;
118  virtual ~GeometricalQuadEdge() override = default;
119 
121  inline void SetOrigin(const OriginRefType v)
122  { m_Origin = v; }
123 
124  inline void SetDestination(const OriginRefType v)
125  { this->GetSym()->SetOrigin(v); }
126 
127  inline void SetRight(const DualOriginRefType v)
128  { this->GetRot()->SetOrigin(v); }
129 
130  inline void SetLeft(const DualOriginRefType v)
131  { this->GetInvRot()->SetOrigin(v); }
132 
140  bool SetLnextRingWithSameLeftFace(const DualOriginRefType faceGeom,
141  int maxSize = 100);
142 
143  inline void UnsetOrigin() { m_Origin = m_NoPoint; }
144  inline void UnsetDestination() { this->GetSym()->UnsetOrigin(); }
145  inline void UnsetRight() { this->GetRot()->UnsetOrigin(); }
146  inline void UnsetLeft() { this->GetInvRot()->UnsetOrigin(); }
147 
149  //ORIENTATION_NOTE: this definition of GetLeft (or GetRight)
150  // implicitely assumes that the Onext order is counter-clockwise !
151  inline const OriginRefType GetOrigin() const { return ( m_Origin ); }
152  inline const OriginRefType GetDestination() const { return ( GetSym()->GetOrigin() ); }
153  inline const DualOriginRefType GetRight() const { return ( GetRot()->GetOrigin() ); }
154  inline const DualOriginRefType GetLeft() const { return ( GetInvRot()->GetOrigin() ); }
156 
158  bool IsOriginSet() const;
159 
160  bool IsDestinationSet() const;
161 
162  bool IsRightSet() const;
163 
164  bool IsLeftSet() const;
165 
167  inline void SetPrimalData(const PrimalDataType data)
168  { m_Data = data; this->SetPrimalData(); }
169  inline void SetDualData(const DualDataType data)
170  { this->GetRot()->SetPrimalData(data); }
172 
173  inline void SetPrimalData() { m_DataSet = true; }
174  inline void SetDualData() { this->GetRot()->SetPrimalData(); }
175 
176  inline void UnsetPrimalData() { m_Data = false; }
177  inline void UnsetDualData() { this->GetRot()->UnsetPrimalData(); }
178 
180  inline PrimalDataType GetPrimalData() { return ( m_Data ); }
182  { return ( this->GetRot()->GetPrimalData() ); }
184 
186  inline bool IsPrimalDataSet() { return ( m_DataSet ); }
187  inline bool IsDualDataSet()
188  { return ( this->GetRot()->IsPrimalDataSet() ); }
190 
195  inline bool IsWire()
196  { return ( !( this->IsLeftSet() ) && !( this->IsRightSet() ) ); }
197 
203  inline bool IsAtBorder()
204  {
205  return ( ( this->IsLeftSet() && !this->IsRightSet() )
206  || ( !this->IsLeftSet() && this->IsRightSet() ) );
207  }
208 
213  inline bool IsInternal() const
214  { return ( this->IsLeftSet() && this->IsRightSet() ); }
215 
216  bool IsOriginInternal() const;
217 
218  bool IsLnextSharingSameFace(int maxSize = 100);
219 
220  bool IsLnextOfTriangle();
221 
222  bool IsInOnextRing(Self *);
223 
224  bool IsInLnextRing(Self *);
225 
226  Self * GetNextBorderEdgeWithUnsetLeft(Self *edgeTest = nullptr);
227 
228  bool InsertAfterNextBorderEdgeWithUnsetLeft(Self *isol,
229  Self *hint = nullptr);
230 
231  bool ReorderOnextRingBeforeAddFace(Self *second);
232 
234  inline bool IsOriginDisconnected()
235  { return ( this == this->GetOnext() ); }
237  { return ( this->GetSym()->IsOriginDisconnected() ); }
238  inline bool IsDisconnected()
239  {
240  return ( this->IsOriginDisconnected()
241  && this->IsDestinationDisconnected() );
242  }
244 
245  void Disconnect();
246 
247  inline void SetIdent(const LineCellIdentifier & User_Value) { this->m_LineCellIdent = User_Value; }
248  inline LineCellIdentifier GetIdent() { return ( this->m_LineCellIdent ); }
249 
250 public:
251  // Reserved OriginRefType designated to represent the absence of Origin
252  static const OriginRefType m_NoPoint;
253 
254 protected:
255  OriginRefType m_Origin; // Geometrical information
256  PrimalDataType m_Data; // User data associated to this edge.
257  bool m_DataSet{false}; // Indicates if the data is set.
259 };
260 }
261 
262 #ifndef ITK_MANUAL_INSTANTIATION
263 #include "itkGeometricalQuadEdge.hxx"
264 #endif
265 
266 #endif
void SetOrigin(const OriginRefType v)
const OriginRefType GetOrigin() const
void SetLeft(const DualOriginRefType v)
void SetPrimalData(const PrimalDataType data)
Base class for the implementation of a quad-edge data structure as proposed in &quot;Guibas and Stolfi 198...
Definition: itkQuadEdge.h:225
const DualOriginRefType GetLeft() const
const DualOriginRefType GetRight() const
LineCellIdentifier m_LineCellIdent
This class extends the QuadEdge by adding a reference to the Origin.
void SetIdent(const LineCellIdentifier &User_Value)
const OriginRefType GetDestination() const
void SetRight(const DualOriginRefType v)
#define itkQEDefineIteratorGeomMethodsMacro(Op)
void SetDualData(const DualDataType data)
static const OriginRefType m_NoPoint
#define itkQEAccessorsMacro(st, pt, dt)
Definition: itkQuadEdge.h:57
void SetDestination(const OriginRefType v)
Non const geometrical iterator.