| 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) |
no test coverage detected