/*========================================================================= * * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #ifndef itkQuadEdgeMeshLineCell_hxx #define itkQuadEdgeMeshLineCell_hxx #include "itkCellInterfaceVisitor.h" namespace itk { // --------------------------------------------------------------------- template QuadEdgeMeshLineCell::QuadEdgeMeshLineCell() { m_Identifier = 0; m_QuadEdgeGeom = new QEType; auto * e2 = new QEType; auto * e1 = new QEDual; auto * e3 = new QEDual; this->m_QuadEdgeGeom->SetRot(e1); e1->SetRot(e2); e2->SetRot(e3); e3->SetRot(this->m_QuadEdgeGeom); this->m_QuadEdgeGeom->SetOnext(this->m_QuadEdgeGeom); e1->SetOnext(e3); e2->SetOnext(e2); e3->SetOnext(e1); } // --------------------------------------------------------------------- template QuadEdgeMeshLineCell::~QuadEdgeMeshLineCell() { // ALEX: for performance issues, // we will assume the user calls Disconnect beforehand // or else it is the mesh destructor, and we can proceed. // if( !m_QuadEdgeGeom->IsDisconnected( ) ) // { // m_QuadEdgeGeom->Disconnect( ); // } bool FoundNullPointer = false; if (m_QuadEdgeGeom) { if (m_QuadEdgeGeom->GetRot()) { if (m_QuadEdgeGeom->GetRot()->GetRot()) { if (m_QuadEdgeGeom->GetRot()->GetRot()->GetRot()) { delete m_QuadEdgeGeom->GetRot()->GetRot()->GetRot(); // e3 delete m_QuadEdgeGeom->GetRot()->GetRot(); // e2 delete m_QuadEdgeGeom->GetRot(); // e1 delete m_QuadEdgeGeom; } else { FoundNullPointer = true; delete m_QuadEdgeGeom->GetRot()->GetRot(); // e2 delete m_QuadEdgeGeom->GetRot(); // e1 delete m_QuadEdgeGeom; } } else { FoundNullPointer = true; delete m_QuadEdgeGeom->GetRot(); // e1 delete m_QuadEdgeGeom; } } else { FoundNullPointer = true; delete m_QuadEdgeGeom; } } else { FoundNullPointer = true; } if (FoundNullPointer) { // Throw exception here } } // --------------------------------------------------------------------- template void QuadEdgeMeshLineCell::Accept(CellIdentifier cellId, MultiVisitor * mv) { using IntVis = CellInterfaceVisitor; typename IntVis::Pointer v = mv->GetVisitor(this->GetType()); if (v) { v->VisitFromCell(cellId, this); } } // --------------------------------------------------------------------- template auto QuadEdgeMeshLineCell::GetNumberOfBoundaryFeatures(int dimension) const -> CellFeatureCount { if (dimension == 0) { return 2; } if (dimension == 1) { return 1; } return 0; } // --------------------------------------------------------------------- template bool QuadEdgeMeshLineCell::GetBoundaryFeature(int dimension, CellFeatureIdentifier cellId, CellAutoPointer & cell) { // TODO : FIXME (void)dimension; (void)cellId; (void)cell; return (false); } // --------------------------------------------------------------------- template void QuadEdgeMeshLineCell::SetPointIds(PointIdConstIterator first) { PointIdConstIterator i = first; this->GetQEGeom()->SetOrigin(*i); ++i; this->GetQEGeom()->SetDestination(*i); } // --------------------------------------------------------------------- template void QuadEdgeMeshLineCell::InternalSetPointIds(PointIdInternalConstIterator first) { PointIdInternalConstIterator i = first; this->GetQEGeom()->SetOrigin(*i); ++i; this->GetQEGeom()->SetDestination(*i); } // --------------------------------------------------------------------- template void QuadEdgeMeshLineCell::SetPointIds(PointIdConstIterator first, PointIdConstIterator last) { (void)last; this->GetQEGeom()->SetOrigin(*first); ++first; this->GetQEGeom()->SetDestination(*first); } // --------------------------------------------------------------------- template void QuadEdgeMeshLineCell::InternalSetPointIds(PointIdInternalConstIterator first, PointIdInternalConstIterator last) { (void)last; this->GetQEGeom()->SetOrigin(*first); ++first; this->GetQEGeom()->SetDestination(*first); } // --------------------------------------------------------------------- template void QuadEdgeMeshLineCell::SetPointId(int localId, PointIdentifier pId) { if (localId == 0) { this->GetQEGeom()->SetOrigin(pId); } else if (localId == 1) { this->GetQEGeom()->SetDestination(pId); } } // --------------------------------------------------------------------- template auto QuadEdgeMeshLineCell::InternalPointIdsBegin() -> PointIdInternalIterator { return (PointIdInternalIterator(this->m_QuadEdgeGeom, PointIdInternalIterator::OperatorSym, true)); } // --------------------------------------------------------------------- template auto QuadEdgeMeshLineCell::InternalPointIdsEnd() -> PointIdInternalIterator { return (PointIdInternalIterator(this->m_QuadEdgeGeom, PointIdInternalIterator::OperatorSym, false)); } // --------------------------------------------------------------------- template auto QuadEdgeMeshLineCell::InternalGetPointIds() const -> PointIdInternalConstIterator { return (PointIdInternalConstIterator(this->m_QuadEdgeGeom, PointIdInternalConstIterator::OperatorSym, true)); } // --------------------------------------------------------------------- template auto QuadEdgeMeshLineCell::InternalPointIdsBegin() const -> PointIdInternalConstIterator { return (PointIdInternalConstIterator(this->m_QuadEdgeGeom, PointIdInternalConstIterator::OperatorSym, true)); } // --------------------------------------------------------------------- template auto QuadEdgeMeshLineCell::InternalPointIdsEnd() const -> PointIdInternalConstIterator { return (PointIdInternalConstIterator(this->m_QuadEdgeGeom, PointIdInternalConstIterator::OperatorSym, false)); } // --------------------------------------------------------------------- template void QuadEdgeMeshLineCell::SetIdent(CellIdentifier cid) { this->m_Identifier = cid; this->m_QuadEdgeGeom->SetIdent(cid); this->m_QuadEdgeGeom->GetSym()->SetIdent(cid); } // --------------------------------------------------------------------- template auto QuadEdgeMeshLineCell::GetIdent() -> CellIdentifier { return this->m_Identifier; } // --------------------------------------------------------------------- template CellGeometryEnum QuadEdgeMeshLineCell::GetType() const { return CellGeometryEnum::LINE_CELL; } // --------------------------------------------------------------------- template unsigned int QuadEdgeMeshLineCell::GetDimension() const { return static_cast(Self::CellDimension); } // --------------------------------------------------------------------- template unsigned int QuadEdgeMeshLineCell::GetNumberOfPoints() const { return 2; } } // end namespace itk #endif