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 itkBorderQuadEdgeMeshFilter_h 19 #define itkBorderQuadEdgeMeshFilter_h 20 21 #include "itkAutoPointer.h" 22 #include "itkQuadEdgeMesh.h" 23 #include "itkQuadEdgeMeshToQuadEdgeMeshFilter.h" 24 #include "itkQuadEdgeMeshBoundaryEdgesMeshFunction.h" 25 26 namespace itk 27 { 28 /** 29 * \class BorderQuadEdgeMeshFilter 30 * \brief Transform one border of a QuadEdgeMesh into either a circle 31 * (conformal) or a square (arclength-wise). 32 * 33 * This class is one important step when computing a planar parameterization 34 * of one mesh. 35 * 36 * If the input mesh has several boundaries, one can choose 37 * the one which would be transformed via the variable m_BorderPick. 38 * 39 * \li <tt>m_BorderPick == Self::LONGEST</tt> refers to the boundary 40 * \f$ b \f$ which satisfies: 41 * \f[ b = \arg \max_{b^k} \sum_{i=1}^{N^k} \left\| x_{i}^k - x_{i+1}^k \right\| \f] 42 * 43 * \li <tt>m_BorderPick == Self::LARGEST</tt> refers to the boundary 44 * \f$ b \f$ which satisfies: 45 * \f[ b = \arg \max_{b^k} N^k \f] 46 * 47 * \sa ParameterizationQuadEdgeMeshFilter 48 * \ingroup ITKQuadEdgeMeshFiltering 49 */ 50 template< typename TInputMesh, typename TOutputMesh=TInputMesh > 51 class ITK_TEMPLATE_EXPORT BorderQuadEdgeMeshFilter: 52 public QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh > 53 { 54 public: 55 ITK_DISALLOW_COPY_AND_ASSIGN(BorderQuadEdgeMeshFilter); 56 57 /** Basic types. */ 58 using Self = BorderQuadEdgeMeshFilter; 59 using Superclass = QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, 60 TOutputMesh >; 61 using Pointer = SmartPointer< Self >; 62 using ConstPointer = SmartPointer< const Self >; 63 64 using InputMeshType = TInputMesh; 65 using InputMeshConstPointer = typename InputMeshType::ConstPointer; 66 using InputCoordRepType = typename InputMeshType::CoordRepType; 67 using InputPointType = typename InputMeshType::PointType; 68 using InputTraits = typename InputMeshType::Traits; 69 using InputPointIdentifier = typename InputMeshType::PointIdentifier; 70 using InputQEType = typename InputMeshType::QEType; 71 using InputIteratorGeom = typename InputQEType::IteratorGeom; 72 using InputVectorType = typename InputMeshType::VectorType; 73 using InputEdgeListType = typename InputMeshType::EdgeListType; 74 using InputEdgeListPointerType = AutoPointer< InputEdgeListType >; 75 using InputEdgeListIterator = typename InputEdgeListType::iterator; 76 using InputEdgeCellType = typename InputMeshType::EdgeCellType; 77 using InputPolygonCellType = typename InputMeshType::PolygonCellType; 78 using InputPointIdList = typename InputMeshType::PointIdList; 79 using InputPointsContainer = typename InputMeshType::PointsContainer; 80 using InputPointsContainerConstIterator = typename InputMeshType::PointsContainerConstIterator; 81 using InputCellsContainerConstIterator = typename InputMeshType::CellsContainerConstIterator; 82 83 using OutputMeshType = TOutputMesh; 84 using OutputMeshPointer = typename OutputMeshType::Pointer; 85 using OutputCoordRepType = typename OutputMeshType::CoordRepType; 86 using OutputPointType = typename OutputMeshType::PointType; 87 using OutputTraits = typename OutputMeshType::Traits; 88 using OutputPointIdentifier = typename OutputMeshType::PointIdentifier; 89 using OutputQEType = typename OutputMeshType::QEType; 90 using OutputVectorType = typename OutputMeshType::VectorType; 91 using OutputEdgeListType = typename OutputMeshType::EdgeListType; 92 using OutputEdgeCellType = typename OutputMeshType::EdgeCellType; 93 using OutputPolygonCellType = typename OutputMeshType::PolygonCellType; 94 using OutputPointIdList = typename OutputMeshType::PointIdList; 95 using OutputPointsContainer = typename OutputMeshType::PointsContainer; 96 using OutputPointsContainerConstIterator = typename OutputMeshType::PointsContainerConstIterator; 97 using OutputCellsContainerConstIterator = typename OutputMeshType::CellsContainerConstIterator; 98 99 itkNewMacro(Self); 100 itkTypeMacro(BorderQuadEdgeMeshFilter, QuadEdgeMeshToQuadEdgeMeshFilter); 101 static constexpr unsigned int PointDimension = InputTraits::PointDimension; 102 103 using InputVectorPointType = std::vector< InputPointType >; 104 using MapPointIdentifier = std::map< InputPointIdentifier, OutputPointIdentifier >; 105 using MapPointIdentifierIterator = typename MapPointIdentifier::iterator; 106 107 using BoundaryRepresentativeEdgesType = QuadEdgeMeshBoundaryEdgesMeshFunction< InputMeshType >; 108 using BoundaryRepresentativeEdgesPointer = typename BoundaryRepresentativeEdgesType::Pointer; 109 110 enum BorderTransformType { 111 SQUARE_BORDER_TRANSFORM = 0, 112 DISK_BORDER_TRANSFORM 113 }; 114 115 enum BorderPickType { 116 LONGEST = 0, 117 LARGEST 118 }; 119 120 itkSetMacro(TransformType, BorderTransformType); 121 itkGetConstMacro(TransformType, BorderTransformType); 122 123 itkSetMacro( BorderPick, BorderPickType ); 124 itkGetConstMacro( BorderPick, BorderPickType ); 125 126 itkSetMacro(Radius, InputCoordRepType); 127 itkGetConstMacro(Radius, InputCoordRepType); 128 129 void ComputeTransform(); 130 131 MapPointIdentifier GetBoundaryPtMap(); 132 133 InputVectorPointType GetBorder(); 134 135 protected: 136 BorderQuadEdgeMeshFilter(); 137 138 ~BorderQuadEdgeMeshFilter() override = default; 139 140 void PrintSelf(std::ostream & os, Indent indent) const override; 141 142 BorderTransformType m_TransformType; 143 BorderPickType m_BorderPick; 144 145 InputCoordRepType m_Radius; 146 147 InputVectorPointType m_Border; 148 149 MapPointIdentifier m_BoundaryPtMap; 150 151 void GenerateData() override; 152 153 void ComputeBoundary(); 154 155 InputQEType* ComputeLongestBorder(); 156 157 InputQEType* ComputeLargestBorder(); 158 159 void DiskTransform(); 160 161 InputPointType GetMeshBarycentre(); 162 163 InputCoordRepType RadiusMaxSquare(); 164 165 void ArcLengthSquareTransform(); 166 }; 167 } // end namespace itk 168 169 #ifndef ITK_MANUAL_INSTANTIATION 170 #include "itkBorderQuadEdgeMeshFilter.hxx" 171 #endif 172 173 #endif 174