Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Christian Butz
VTK
Commits
c343d16a
Commit
c343d16a
authored
Jul 26, 2013
by
Aashish Chaudhary
Committed by
Code Review
Jul 26, 2013
Browse files
Merge topic 'gdal-active-layer' into master
8e5b524b
Shapefiles: If active layer specified, load only it.
parents
723a4691
8e5b524b
Changes
3
Hide whitespace changes
Inline
Side-by-side
IO/GDAL/Testing/Cxx/TestGDALVectorReader.cxx
View file @
c343d16a
...
...
@@ -46,6 +46,20 @@ int TestGDALVectorReader(int argc, char** argv)
vtkNew
<
vtkGDALVectorReader
>
reader
;
reader
->
SetFileName
(
vectorFileName
);
delete
[]
vectorFileName
;
// Test layer information helpers
reader
->
UpdateInformation
();
int
nl
=
reader
->
GetNumberOfLayers
();
for
(
int
i
=
0
;
i
<
nl
;
++
i
)
{
reader
->
SetActiveLayer
(
i
);
cout
<<
"Layer "
<<
i
<<
" Type "
<<
reader
->
GetActiveLayerType
()
<<
" FeatureCount "
<<
reader
->
GetActiveLayerFeatureCount
()
<<
"
\n
"
;
}
reader
->
SetActiveLayer
(
0
);
// Read only layer 0, which is the only layer.
reader
->
Update
();
// We need a renderer
...
...
IO/GDAL/vtkGDALVectorReader.cxx
View file @
c343d16a
...
...
@@ -298,6 +298,7 @@ vtkGDALVectorReader::vtkGDALVectorReader()
{
this
->
FileName
=
0
;
this
->
Implementation
=
0
;
this
->
ActiveLayer
=
-
1
;
this
->
SetNumberOfInputPorts
(
0
);
...
...
@@ -408,13 +409,17 @@ int vtkGDALVectorReader::GetFeatureCount(int layerIndex)
// -----------------------------------------------------------------------------
int
vtkGDALVectorReader
::
GetActiveLayerType
()
{
return
this
->
GetLayerType
(
ActiveLayer
);
return
this
->
ActiveLayer
<
0
||
this
->
ActiveLayer
>=
this
->
GetNumberOfLayers
()
?
-
1
:
this
->
GetLayerType
(
this
->
ActiveLayer
);
}
// -----------------------------------------------------------------------------
int
vtkGDALVectorReader
::
GetActiveLayerFeatureCount
()
{
return
this
->
GetFeatureCount
(
ActiveLayer
);
return
this
->
ActiveLayer
<
0
||
this
->
ActiveLayer
>=
this
->
GetNumberOfLayers
()
?
0
:
this
->
GetFeatureCount
(
this
->
ActiveLayer
);
}
// -----------------------------------------------------------------------------
...
...
@@ -492,7 +497,13 @@ int vtkGDALVectorReader::RequestData( vtkInformation* request,
vtkGDALVectorReader
::
Internal
*
p
=
this
->
Implementation
;
for
(
int
layerIdx
=
0
;
layerIdx
<
p
->
Source
->
GetLayerCount
();
++
layerIdx
)
int
lastLayer
=
p
->
Source
->
GetLayerCount
()
-
1
;
int
startLayer
=
this
->
ActiveLayer
<
0
||
this
->
ActiveLayer
>=
lastLayer
?
0
:
this
->
ActiveLayer
;
int
endLayer
=
this
->
ActiveLayer
<
0
||
this
->
ActiveLayer
>=
lastLayer
?
lastLayer
:
this
->
ActiveLayer
;
for
(
int
layerIdx
=
startLayer
;
layerIdx
<=
endLayer
;
++
layerIdx
)
{
OGRLayer
*
layer
=
p
->
Source
->
GetLayer
(
layerIdx
);
if
(
!
layer
)
...
...
IO/GDAL/vtkGDALVectorReader.h
View file @
c343d16a
...
...
@@ -17,7 +17,10 @@
// vtkGDALVectorReader is a source object that reads vector files and uses
// GDAL as the underlying library for the task. GDAL is required for this
// reader. The output of the reader is a vtkMultiBlockDataSet
//
// This filter uses the ActiveLayer member to only load entries from the
// specified layer (when ActiveLayer >= 0).
//
// .SECTION See Also
// vtkMultiBlockDataSet
...
...
@@ -60,7 +63,9 @@ public:
int
GetActiveLayerFeatureCount
();
// Description:
// Set and Get the active layer
// Set and Get the active layer.
// If ActiveLayer is less than 0 (the default is -1), then all
// layers are read. Otherwise, only the specified layer is read.
vtkSetMacro
(
ActiveLayer
,
int
);
vtkGetMacro
(
ActiveLayer
,
int
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment