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
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Michael Migliore
VTK
Commits
6bedf4c2
Commit
6bedf4c2
authored
5 months ago
by
Jaswant Panchumarti (Kitware)
Browse files
Options
Downloads
Patches
Plain Diff
Validate ClassName and SuperClassName only when required in deserializer
parent
e07917ad
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Common/Core/vtkDeserializer.cxx
+22
-21
22 additions, 21 deletions
Common/Core/vtkDeserializer.cxx
Serialization/Manager/Testing/Python/TestUpdateObjectFromState.py
+25
-0
25 additions, 0 deletions
...ation/Manager/Testing/Python/TestUpdateObjectFromState.py
with
47 additions
and
21 deletions
Common/Core/vtkDeserializer.cxx
+
22
−
21
View file @
6bedf4c2
...
...
@@ -81,32 +81,33 @@ bool vtkDeserializer::DeserializeJSON(
}
std
::
string
className
;
std
::
vector
<
std
::
string
>
superClassNames
;
if
(
objectBase
==
nullptr
)
{
const
auto
iter
=
state
.
find
(
"ClassName"
);
if
(
iter
==
state
.
end
())
{
vtkErrorMacro
(
<<
"Failed to find 'ClassName' in state at id="
<<
identifier
);
return
false
;
}
else
{
className
=
iter
->
get
<
std
::
string
>
();
}
}
{
const
auto
iter
=
state
.
find
(
"SuperClassNames"
);
if
(
iter
==
state
.
end
())
// Only look for ClassName and SuperClassNames if we are going to construct the object.
{
vtkErrorMacro
(
<<
"Failed to find 'SuperClassNames' in state at id="
<<
identifier
);
return
false
;
const
auto
iter
=
state
.
find
(
"ClassName"
);
if
(
iter
==
state
.
end
())
{
vtkErrorMacro
(
<<
"Failed to find 'ClassName' in state at id="
<<
identifier
);
return
false
;
}
else
{
className
=
iter
->
get
<
std
::
string
>
();
}
}
else
{
superClassNames
=
iter
->
get
<
std
::
vector
<
std
::
string
>>
();
const
auto
iter
=
state
.
find
(
"SuperClassNames"
);
if
(
iter
==
state
.
end
())
{
vtkErrorMacro
(
<<
"Failed to find 'SuperClassNames' in state at id="
<<
identifier
);
return
false
;
}
else
{
superClassNames
=
iter
->
get
<
std
::
vector
<
std
::
string
>>
();
}
}
}
if
(
objectBase
==
nullptr
)
{
if
(
auto
ptr
=
this
->
ConstructObject
(
className
,
superClassNames
))
{
objectBase
=
vtk
::
TakeSmartPointer
(
ptr
);
...
...
This diff is collapsed.
Click to expand it.
Serialization/Manager/Testing/Python/TestUpdateObjectFromState.py
+
25
−
0
View file @
6bedf4c2
...
...
@@ -56,5 +56,30 @@ class TestUpdateObjectFromState(vtkTesting.vtkTest):
self
.
assertTupleEqual
(
camera
.
GetPosition
(),
(
0
,
0.2
,
1.3
))
self
.
assertEqual
(
camera
.
GetViewAngle
(),
60
)
def
test3
(
self
):
from
vtkmodules.vtkSerializationManager
import
vtkObjectManager
from
vtkmodules.vtkRenderingCore
import
vtkCamera
import
json
# Scenario 3:
# An object is registered and serialized. Later, a new state is created with modified properties.
# Unlike Scenario 2, this new state does not have keys that were originally part of the state like
# "ClassName", "SuperClassNames" and "vtk-object-manager-kept-alive"
# Call UpdateObjectFromState() with modified state. Verify the real object's properties match
# with the state's properties.
manager
=
vtkObjectManager
()
manager
.
Initialize
()
camera
=
vtkCamera
()
cid
=
manager
.
RegisterObject
(
camera
)
manager
.
UpdateStatesFromObjects
()
manager
.
UpdateObjectFromState
(
json
.
dumps
({
"
Id
"
:
cid
,
"
Position
"
:
(
0
,
0.2
,
1.3
)}))
self
.
assertTupleEqual
(
camera
.
GetPosition
(),
(
0
,
0.2
,
1.3
))
manager
.
UpdateObjectFromState
(
json
.
dumps
({
"
Id
"
:
cid
,
"
ViewAngle
"
:
60
}))
self
.
assertEqual
(
camera
.
GetViewAngle
(),
60
)
if
__name__
==
"
__main__
"
:
vtkTesting
.
main
([(
TestUpdateObjectFromState
,
'
test
'
)])
This diff is collapsed.
Click to expand it.
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