MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadLayer

Method ReadLayer

IO/GDAL/vtkGDALVectorReader.cxx:115–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113 }
114
115 bool ReadLayer(OGRLayer* layer, vtkMultiBlockDataSet* mbds)
116 {
117 OGRFeature* feat;
118 vtkPolyData* pd = nullptr;
119 vtkIdType nTotPoly = 0;
120 vtkCellArray *lines = nullptr, *verts = nullptr;
121
122 OGRFeatureDefn* fdef = layer->GetLayerDefn();
123 int numFields = fdef->GetFieldCount();
124 std::vector<vtkAbstractArray*> fields;
125
126 if (this->AppendFeatures)
127 {
128 this->SetupPolyData(&pd, &lines, &verts, &fields, numFields, fdef);
129 }
130
131 while ((feat = layer->GetNextFeature()))
132 {
133 if (!this->AppendFeatures)
134 {
135 fields.clear();
136 this->SetupPolyData(&pd, &lines, &verts, &fields, numFields, fdef);
137 mbds->SetBlock(this->LayerIdx, pd);
138 ++this->LayerIdx;
139 pd->FastDelete();
140 nTotPoly = 0;
141 }
142
143 vtkPoints* pts = pd->GetPoints();
144 if (!pts)
145 {
146 pts = vtkPoints::New();
147 pts->SetDataTypeToDouble();
148 pd->SetPoints(pts);
149 pts->FastDelete();
150 }
151
152 // Insert points and lines to represent the geometry of each feature.
153 OGRGeometry* geom = feat->GetGeometryRef();
154 vtkIdType nPoly = this->insertGeometryRecursive(geom, pd, pts, lines, verts);
155 if (!nPoly)
156 {
157 continue;
158 }
159
160 nTotPoly += nPoly;
161
162 // Now insert the field values for this geometry once for each cell created
163 // (We have to copy the values when there are multiple polygons or polygons
164 // with inner rings.)
165 vtkIdType i;
166 int ival;
167 double rval;
168 const char* sval;
169 vtkIntArray* iarr;
170 vtkDoubleArray* rarr;
171 vtkStringArray* sarr;
172 for (int f = 0; f < numFields; ++f)

Callers 1

RequestDataMethod · 0.80

Calls 10

SetupPolyDataMethod · 0.95
SetBlockMethod · 0.80
FastDeleteMethod · 0.80
NewFunction · 0.50
clearMethod · 0.45
GetPointsMethod · 0.45
SetPointsMethod · 0.45
GetTypeMethod · 0.45
InsertNextValueMethod · 0.45

Tested by

no test coverage detected