Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VTK
VTK
Commits
7ba10901
Commit
7ba10901
authored
1 year ago
by
Mathieu Westphal (Kitware)
Committed by
Lucas Givord
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
vtkERFReader: Fix incorrect reserver and isspace usages
parent
b20e932f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!11541
Branch for the v9.4.0 release
,
!11236
Branch for the vupdate-for-v5.13.0-RC1 release
,
!10681
Fix multiple issues in the ERF Reader
Pipeline
#373826
passed
1 year ago
Stage: build
Stage: test
Stage: test-ext
Stage: external
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
IO/ERF/vtkERFReader.cxx
+22
-47
22 additions, 47 deletions
IO/ERF/vtkERFReader.cxx
IO/ERF/vtkERFReader.h
+23
-31
23 additions, 31 deletions
IO/ERF/vtkERFReader.h
with
45 additions
and
78 deletions
IO/ERF/vtkERFReader.cxx
+
22
−
47
View file @
7ba10901
...
...
@@ -409,29 +409,17 @@ void vtkERFReader::AppendSystemBlock(
continue
;
}
vtkHDF
::
ScopedH5AHandle
attributeHandler
=
H5Aopen
(
systemHandle
,
attribute
,
H5P_DEFAULT
);
vtkHDF
::
ScopedH5THandle
rawType
=
H5Aget_type
(
attributeHandler
);
vtkHDF
::
ScopedH5THandle
dataType
=
H5Tget_native_type
(
rawType
,
H5T_DIR_ASCEND
);
if
(
H5Tget_class
(
dataType
)
!=
H5T_STRING
)
std
::
string
value
=
this
->
GetAttributeValueAsStr
(
systemHandle
,
attribute
);
if
(
value
.
empty
())
{
continue
;
}
hsize_t
stringLength
=
H5Aget_storage_size
(
attributeHandler
);
std
::
vector
<
char
>
value
;
value
.
reserve
(
stringLength
);
if
(
H5Aread
(
attributeHandler
,
dataType
,
value
.
data
())
>=
0
)
{
std
::
string
content
(
value
.
data
());
content
.
erase
(
std
::
remove_if
(
content
.
begin
(),
content
.
end
(),
isspace
),
content
.
end
());
vtkNew
<
vtkStringArray
>
stringArr
;
stringArr
->
SetName
(
attribute
);
stringArr
->
SetNumberOfValues
(
1
);
stringArr
->
SetValue
(
0
,
content
);
output
->
GetFieldData
()
->
AddArray
(
stringArr
);
}
vtkNew
<
vtkStringArray
>
stringArr
;
stringArr
->
SetName
(
attribute
);
stringArr
->
SetNumberOfValues
(
1
);
stringArr
->
SetValue
(
0
,
value
);
output
->
GetFieldData
()
->
AddArray
(
stringArr
);
}
// Check Datasets
...
...
@@ -677,7 +665,7 @@ void vtkERFReader::AppendPoints(
if
(
H5Tequal
(
nodeDataType
,
H5T_NATIVE_DOUBLE
))
{
std
::
vector
<
double
>
resData
;
resData
.
res
erv
e
(
numberOfPoints
*
3
);
resData
.
res
iz
e
(
numberOfPoints
*
3
);
H5Dread
(
arrayId
,
nodeDataType
,
H5S_ALL
,
H5S_ALL
,
H5P_DEFAULT
,
resData
.
data
());
for
(
int
i
=
0
;
i
<
numberOfPoints
;
i
++
)
{
...
...
@@ -718,21 +706,6 @@ void vtkERFReader::AppendCells(
return
;
}
// Retrieve attributes information about number of points
vtkHDF
::
ScopedH5AHandle
etypHandler
=
H5Aopen
(
fileId
,
"etyp"
,
H5P_DEFAULT
);
vtkHDF
::
ScopedH5THandle
rawType
=
H5Aget_type
(
etypHandler
);
vtkHDF
::
ScopedH5THandle
dataType
=
H5Tget_native_type
(
rawType
,
H5T_DIR_ASCEND
);
hsize_t
stringLength
=
H5Aget_storage_size
(
etypHandler
);
std
::
vector
<
char
>
value
;
value
.
reserve
(
stringLength
+
1
);
if
(
H5Aread
(
etypHandler
,
dataType
,
value
.
data
())
>=
0
)
{
value
[
stringLength
]
=
'\0'
;
std
::
string
content
(
value
.
data
());
content
.
erase
(
std
::
remove_if
(
content
.
begin
(),
content
.
end
(),
isspace
),
content
.
end
());
}
int
numberOfDimensions
=
this
->
GetAttributeValueAsInt
(
fileId
,
"ndim"
);
if
(
numberOfDimensions
==
VTK_INT_MIN
)
{
...
...
@@ -791,7 +764,7 @@ void vtkERFReader::FillCellsByType(vtkCellArray* cellArray, vtkUnsignedCharArray
int
numberOfIndicePerCell
,
int
numberOfCell
)
{
std
::
vector
<
int
>
resData
;
resData
.
res
erv
e
(
numberOfCell
*
numberOfIndicePerCell
);
resData
.
res
iz
e
(
numberOfCell
*
numberOfIndicePerCell
);
H5Dread
(
arrayId
,
shellDataType
,
H5S_ALL
,
H5S_ALL
,
H5P_DEFAULT
,
resData
.
data
());
switch
(
numberOfDimensions
)
...
...
@@ -829,9 +802,9 @@ void vtkERFReader::Fill0DCellType(vtkCellArray* cellArray, vtkUnsignedCharArray*
for
(
int
i
=
0
;
i
<
numberOfCell
;
i
++
)
{
int
pointId1
=
entid
->
LookupValue
(
resData
[
i
]);
vtkIdType
pointId1
=
static_cast
<
vtkIdType
>
(
entid
->
LookupValue
(
resData
[
i
])
)
;
cellArray
->
InsertNextCell
(
{
pointId1
}
);
cellArray
->
InsertNextCell
(
1
,
&
pointId1
);
cellTypes
->
InsertNextValue
(
VTK_VERTEX
);
}
}
...
...
@@ -940,28 +913,30 @@ void vtkERFReader::Fill3DCellType(vtkCellArray* cellArray, vtkUnsignedCharArray*
std
::
string
vtkERFReader
::
GetAttributeValueAsStr
(
const
hid_t
&
erfIdx
,
const
std
::
string
&
attributeName
)
const
{
std
::
string
etypnode
;
vtkHDF
::
ScopedH5AHandle
attributeHandler
=
H5Aopen
(
erfIdx
,
attributeName
.
c_str
(),
H5P_DEFAULT
);
vtkHDF
::
ScopedH5THandle
rawType
=
H5Aget_type
(
attributeHandler
);
vtkHDF
::
ScopedH5THandle
dataType
=
H5Tget_native_type
(
rawType
,
H5T_DIR_ASCEND
);
if
(
H5Tget_class
(
dataType
)
!=
H5T_STRING
)
{
return
etypnode
;
return
""
;
}
hsize_t
stringLength
=
H5Aget_storage_size
(
attributeHandler
);
std
::
vector
<
char
>
value
;
std
::
string
value
;
value
.
resize
(
stringLength
+
1
);
if
(
H5Aread
(
attributeHandler
,
dataType
,
value
.
data
()
)
>=
0
)
if
(
H5Aread
(
attributeHandler
,
dataType
,
&
value
[
0
]
)
>=
0
)
{
etypnode
=
std
::
string
(
value
.
data
());
etypnode
.
erase
(
std
::
remove_if
(
etypnode
.
begin
(),
etypnode
.
end
(),
[](
char
c
)
{
return
std
::
isspace
(
c
)
||
!
std
::
isalpha
(
c
);
}),
etypnode
.
end
());
value
.
erase
(
std
::
remove_if
(
value
.
begin
(),
value
.
end
(),
[](
char
c
)
{
// convert it to avoid potential issue wit negative char
unsigned
char
uc
=
static_cast
<
unsigned
char
>
(
c
);
return
std
::
isspace
(
uc
)
||
!
std
::
isalpha
(
uc
);
}),
value
.
end
());
}
return
etypnod
e
;
return
valu
e
;
}
//----------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
IO/ERF/vtkERFReader.h
+
23
−
31
View file @
7ba10901
...
...
@@ -225,29 +225,6 @@ private:
void
AppendFieldDataByName
(
vtkPartitionedDataSetCollection
*
pdc
,
const
hid_t
&
id
,
const
std
::
string
&
name
);
///@{
/**
* Return true if the cell type is supported depending of the number of dimensions and the number
* of nodes.
*
* Supported cell type:
* - Vertex
* - Line
* - Triangle
* - Tetra
* - Pyramid
* - Penta
* - Hexa
*
* @note High order cells aren't supported.
*/
bool
IsCellSupported
(
int
ndim
,
int
npelem
);
bool
Is0DCellSupported
(
int
npelem
);
bool
Is1DCellSupported
(
int
npelem
);
bool
Is2DCellSupported
(
int
npelem
);
bool
Is3DCellSupported
(
int
npelem
);
///@}
///@{
/**
* Recreate the mesh.
...
...
@@ -265,14 +242,6 @@ private:
void
AppendMeshs
(
vtkPartitionedDataSetCollection
*
pdc
,
vtkDataAssembly
*
hierarchy
,
int
&
streamNodeId
,
int
&
meshNodeId
,
int
&
meshStartId
);
/**
* Return true if the group name will be equal to 'erfblock'.
*
* In the standard, all possible path leads at the end to a 'erfblock' which will then contents
* attributes and dataset.
*/
bool
IsLastGroup
(
const
std
::
string
&
groupname
)
const
;
/**
* Get the index of the current time values selected by the user in the TimeValues.
*/
...
...
@@ -286,6 +255,29 @@ private:
int
GetAttributeValueAsInt
(
const
hid_t
&
erfIdx
,
const
std
::
string
&
attributeName
)
const
;
///@}
///@{
/**
* Return true if the cell type is supported depending of the number of dimensions and the number
* of nodes.
*
* Supported cell type:
* - Vertex
* - Line
* - Triangle
* - Tetra
* - Pyramid
* - Penta
* - Hexa
*
* @note High order cells aren't supported.
*/
bool
IsCellSupported
(
int
ndim
,
int
npelem
);
bool
Is0DCellSupported
(
int
npelem
);
bool
Is1DCellSupported
(
int
npelem
);
bool
Is2DCellSupported
(
int
npelem
);
bool
Is3DCellSupported
(
int
npelem
);
///@}
/**
* Fill the cell array to the right cell type based on the dimension.
*/
...
...
This diff is collapsed.
Click to expand it.
Lucas Givord
@lucas.givord
mentioned in commit
d3b2629e
·
1 year ago
mentioned in commit
d3b2629e
mentioned in commit d3b2629e30874131bdb530e68327f24eb1aa5679
Toggle commit list
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment