Skip to content

Commit cb2951f

Browse files
authored
Merge pull request #16550 from Mugen87/dev33
VTKLoader: Handle invalid DATASET types.
2 parents 8d26c72 + 1dd2601 commit cb2951f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

examples/js/loaders/VTKLoader.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
9999

100100
var line = lines[ i ];
101101

102-
if ( inPointsSection ) {
102+
if ( line.indexOf( 'DATASET' ) === 0 ) {
103+
104+
var dataset = line.split( ' ' )[ 1 ];
105+
106+
if ( dataset !== 'POLYDATA' ) throw new Error( 'Unsupported DATASET type: ' + dataset );
107+
108+
} else if ( inPointsSection ) {
103109

104110
// get the vertices
105111
while ( ( result = pat3Floats.exec( line ) ) !== null ) {
@@ -354,7 +360,13 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
354360
state = findString( buffer, index );
355361
line = state.parsedString;
356362

357-
if ( line.indexOf( 'POINTS' ) === 0 ) {
363+
if ( line.indexOf( 'DATASET' ) === 0 ) {
364+
365+
var dataset = line.split( ' ' )[ 1 ];
366+
367+
if ( dataset !== 'POLYDATA' ) throw new Error( 'Unsupported DATASET type: ' + dataset );
368+
369+
} else if ( line.indexOf( 'POINTS' ) === 0 ) {
358370

359371
vtk.push( line );
360372
// Add the points
@@ -1117,7 +1129,7 @@ Object.assign( THREE.VTKLoader.prototype, THREE.EventDispatcher.prototype, {
11171129

11181130
} else {
11191131

1120-
// TODO for vtu,vti,and other xml formats
1132+
throw new Error( 'Unsupported DATASET type' );
11211133

11221134
}
11231135

0 commit comments

Comments
 (0)