1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkCPExodusIIElementBlockCellIterator.cxx
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14 =========================================================================*/
15
16 #include "vtkCPExodusIIElementBlockCellIterator.h"
17
18 #include "vtkCPExodusIIElementBlock.h"
19 #include "vtkCPExodusIIElementBlockPrivate.h"
20 #include "vtkObjectFactory.h"
21 #include "vtkPoints.h"
22
23 #include <algorithm>
24
25 vtkStandardNewMacro(vtkCPExodusIIElementBlockCellIterator);
26
27 //------------------------------------------------------------------------------
PrintSelf(ostream & os,vtkIndent indent)28 void vtkCPExodusIIElementBlockCellIterator::PrintSelf(ostream& os, vtkIndent indent)
29 {
30 this->Superclass::PrintSelf(os, indent);
31 os << indent << "Storage: " << this->Storage << endl;
32 os << indent << "DataSetPoints: " << this->DataSetPoints << endl;
33 os << indent << "CellId: " << this->CellId << endl;
34 }
35
36 //------------------------------------------------------------------------------
IsValid()37 bool vtkCPExodusIIElementBlockCellIterator::IsValid()
38 {
39 return this->Storage && this->CellId < this->Storage->NumberOfCells;
40 }
41
42 //------------------------------------------------------------------------------
GetCellId()43 vtkIdType vtkCPExodusIIElementBlockCellIterator::GetCellId()
44 {
45 return this->CellId;
46 }
47
48 //------------------------------------------------------------------------------
vtkCPExodusIIElementBlockCellIterator()49 vtkCPExodusIIElementBlockCellIterator::vtkCPExodusIIElementBlockCellIterator()
50 : Storage(nullptr)
51 , DataSetPoints(nullptr)
52 , CellId(0)
53 {
54 }
55
56 //------------------------------------------------------------------------------
~vtkCPExodusIIElementBlockCellIterator()57 vtkCPExodusIIElementBlockCellIterator::~vtkCPExodusIIElementBlockCellIterator() {}
58
59 //------------------------------------------------------------------------------
ResetToFirstCell()60 void vtkCPExodusIIElementBlockCellIterator::ResetToFirstCell()
61 {
62 this->CellId = 0;
63 }
64
65 //------------------------------------------------------------------------------
IncrementToNextCell()66 void vtkCPExodusIIElementBlockCellIterator::IncrementToNextCell()
67 {
68 ++this->CellId;
69 }
70
71 //------------------------------------------------------------------------------
FetchCellType()72 void vtkCPExodusIIElementBlockCellIterator::FetchCellType()
73 {
74 this->CellType = this->Storage->CellType;
75 }
76
77 //------------------------------------------------------------------------------
FetchPointIds()78 void vtkCPExodusIIElementBlockCellIterator::FetchPointIds()
79 {
80 this->PointIds->SetNumberOfIds(this->Storage->CellSize);
81
82 std::transform(this->Storage->GetElementStart(this->CellId),
83 this->Storage->GetElementEnd(this->CellId), this->PointIds->GetPointer(0),
84 StorageType::NodeToPoint);
85 }
86
87 //------------------------------------------------------------------------------
FetchPoints()88 void vtkCPExodusIIElementBlockCellIterator::FetchPoints()
89 {
90 this->DataSetPoints->GetPoints(this->GetPointIds(), this->Points);
91 }
92
93 //------------------------------------------------------------------------------
SetStorage(vtkCPExodusIIElementBlock * eb)94 void vtkCPExodusIIElementBlockCellIterator::SetStorage(vtkCPExodusIIElementBlock* eb)
95 {
96 if (eb != nullptr)
97 {
98 this->Storage = eb->GetInternals();
99 this->DataSetPoints = eb->GetPoints();
100 if (this->DataSetPoints)
101 {
102 this->Points->SetDataType(this->DataSetPoints->GetDataType());
103 }
104 }
105 else
106 {
107 this->Storage = nullptr;
108 this->DataSetPoints = nullptr;
109 }
110 this->CellId = 0;
111 }
112