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 itkQuadrilateralCell_h 19 #define itkQuadrilateralCell_h 20 21 #include "itkLineCell.h" 22 #include "itkQuadrilateralCellTopology.h" 23 24 namespace itk 25 { 26 /** \class QuadrilateralCell 27 * \brief Represents a quadrilateral for a Mesh. 28 * 29 * \tparam TPixelType The type associated with a point, cell, or boundary 30 * for use in storing its data. 31 * 32 * \tparam TCellTraits Type information of mesh containing cell. 33 * 34 * \ingroup MeshObjects 35 * \ingroup ITKCommon 36 */ 37 38 template< typename TCellInterface > 39 class ITK_TEMPLATE_EXPORT QuadrilateralCell:public TCellInterface, private QuadrilateralCellTopology 40 { 41 public: 42 ITK_DISALLOW_COPY_AND_ASSIGN(QuadrilateralCell); 43 44 /** Standard class type aliases. */ 45 itkCellCommonTypedefs(QuadrilateralCell); 46 itkCellInheritedTypedefs(TCellInterface); 47 48 /** Standard part of every itk Object. */ 49 itkTypeMacro(QuadrilateralCell, CellInterface); 50 51 /** The type of boundary for this triangle's vertices. */ 52 using VertexType = VertexCell< TCellInterface >; 53 using VertexAutoPointer = typename VertexType::SelfAutoPointer; 54 55 /** The type of boundary for this triangle's edges. */ 56 using EdgeType = LineCell< TCellInterface >; 57 using EdgeAutoPointer = typename EdgeType::SelfAutoPointer; 58 59 /** Quadrilateral-specific topology numbers. */ 60 static constexpr unsigned int NumberOfPoints = 4; 61 static constexpr unsigned int NumberOfVertices = 4; 62 static constexpr unsigned int NumberOfEdges = 4; 63 static constexpr unsigned int CellDimension = 2; 64 static constexpr unsigned int NumberOfDerivatives = 8; 65 66 /** Implement the standard CellInterface. */ GetType()67 CellGeometry GetType() const override 68 { return Superclass::QUADRILATERAL_CELL; } 69 void MakeCopy(CellAutoPointer &) const override; 70 71 unsigned int GetDimension() const override; 72 73 unsigned int GetNumberOfPoints() const override; 74 75 CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const override; 76 77 bool GetBoundaryFeature(int dimension, CellFeatureIdentifier, CellAutoPointer &) override; 78 void SetPointIds(PointIdConstIterator first) override; 79 80 void SetPointIds(PointIdConstIterator first, 81 PointIdConstIterator last) override; 82 83 void SetPointId(int localId, PointIdentifier) override; 84 PointIdIterator PointIdsBegin() override; 85 86 PointIdConstIterator PointIdsBegin() const override; 87 88 PointIdIterator PointIdsEnd() override; 89 90 PointIdConstIterator PointIdsEnd() const override; 91 92 /** Quadrilateral-specific interface. */ 93 virtual CellFeatureCount GetNumberOfVertices() const; 94 95 virtual CellFeatureCount GetNumberOfEdges() const; 96 97 virtual bool GetVertex(CellFeatureIdentifier, VertexAutoPointer &); 98 virtual bool GetEdge(CellFeatureIdentifier, EdgeAutoPointer &); 99 100 /** Evaluate the position inside the cell */ 101 bool EvaluatePosition(CoordRepType * position, 102 PointsContainer * points, 103 CoordRepType * closestPoint, 104 CoordRepType[CellDimension], 105 double * dist2, 106 InterpolationWeightType * weight) override; 107 108 /** Visitor interface */ 109 itkCellVisitMacro(Superclass::QUADRILATERAL_CELL); 110 111 /** Constructor and destructor */ QuadrilateralCell()112 QuadrilateralCell() 113 { 114 for ( PointIdentifier i = 0; i < Self::NumberOfPoints; i++ ) 115 { 116 m_PointIds[i] = NumericTraits< PointIdentifier >::max(); 117 } 118 } 119 120 #if defined(__GNUC__) && (__GNUC__ > 5) 121 ~QuadrilateralCell() override = default; 122 #else ~QuadrilateralCell()123 ~QuadrilateralCell() override {}; 124 #endif 125 126 protected: 127 /** Store the number of points needed for a quadrilateral. */ 128 PointIdentifier m_PointIds[NumberOfPoints]; 129 130 void InterpolationDerivs(const CoordRepType pointCoords[CellDimension], CoordRepType derivs[NumberOfDerivatives]); 131 void InterpolationFunctions(const CoordRepType pointCoords[CellDimension], InterpolationWeightType weights[NumberOfPoints]); 132 void EvaluateLocation(int &itkNotUsed(subId), const PointsContainer * points, const CoordRepType pointCoords[PointDimension], 133 CoordRepType x[PointDimension], InterpolationWeightType * weights); 134 }; 135 } // end namespace itk 136 137 #ifndef ITK_MANUAL_INSTANTIATION 138 #include "itkQuadrilateralCell.hxx" 139 #endif 140 141 #endif 142