Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
08e8b206
Commit
08e8b206
authored
Mar 31, 2017
by
peastman
Committed by
GitHub
Mar 31, 2017
Browse files
Merge pull request #1769 from peastman/loops
Use C++11 style loops
parents
55ee0b9f
083bc501
Changes
96
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
113 additions
and
184 deletions
+113
-184
serialization/src/CustomIntegratorProxy.cpp
serialization/src/CustomIntegratorProxy.cpp
+24
-29
serialization/src/CustomManyParticleForceProxy.cpp
serialization/src/CustomManyParticleForceProxy.cpp
+11
-21
serialization/src/CustomNonbondedForceProxy.cpp
serialization/src/CustomNonbondedForceProxy.cpp
+19
-31
serialization/src/CustomTorsionForceProxy.cpp
serialization/src/CustomTorsionForceProxy.cpp
+4
-11
serialization/src/GBSAOBCForceProxy.cpp
serialization/src/GBSAOBCForceProxy.cpp
+1
-3
serialization/src/GayBerneForceProxy.cpp
serialization/src/GayBerneForceProxy.cpp
+2
-6
serialization/src/HarmonicAngleForceProxy.cpp
serialization/src/HarmonicAngleForceProxy.cpp
+1
-3
serialization/src/HarmonicBondForceProxy.cpp
serialization/src/HarmonicBondForceProxy.cpp
+1
-3
serialization/src/NonbondedForceProxy.cpp
serialization/src/NonbondedForceProxy.cpp
+2
-6
serialization/src/PeriodicTorsionForceProxy.cpp
serialization/src/PeriodicTorsionForceProxy.cpp
+1
-3
serialization/src/RBTorsionForceProxy.cpp
serialization/src/RBTorsionForceProxy.cpp
+1
-3
serialization/src/SerializationNode.cpp
serialization/src/SerializationNode.cpp
+6
-6
serialization/src/StateProxy.cpp
serialization/src/StateProxy.cpp
+8
-23
serialization/src/SystemProxy.cpp
serialization/src/SystemProxy.cpp
+3
-6
serialization/src/TabulatedFunctionProxies.cpp
serialization/src/TabulatedFunctionProxies.cpp
+24
-24
serialization/src/XmlSerializer.cpp
serialization/src/XmlSerializer.cpp
+5
-6
No files found.
serialization/src/CustomIntegratorProxy.cpp
View file @
08e8b206
...
...
@@ -74,45 +74,40 @@ void* CustomIntegratorProxy::deserialize(const SerializationNode& node) const {
throw
OpenMMException
(
"Unsupported version number"
);
CustomIntegrator
*
integrator
=
new
CustomIntegrator
(
node
.
getDoubleProperty
(
"stepSize"
));
const
SerializationNode
&
globalVariablesNode
=
node
.
getChildNode
(
"GlobalVariables"
);
const
map
<
string
,
string
>
&
globalVariableProp
=
globalVariablesNode
.
getProperties
();
for
(
map
<
string
,
string
>::
const_iterator
cit
=
globalVariableProp
.
begin
();
cit
!=
globalVariableProp
.
end
();
cit
++
)
{
integrator
->
addGlobalVariable
(
cit
->
first
,
globalVariablesNode
.
getDoubleProperty
(
cit
->
first
));
}
for
(
auto
&
prop
:
globalVariablesNode
.
getProperties
())
integrator
->
addGlobalVariable
(
prop
.
first
,
globalVariablesNode
.
getDoubleProperty
(
prop
.
first
));
const
SerializationNode
&
perDofVariablesNode
=
node
.
getChildNode
(
"PerDofVariables"
);
const
vector
<
SerializationNode
>&
perDofVariableList
=
perDofVariablesNode
.
getChildren
();
int
count
=
0
;
for
(
vector
<
SerializationNode
>::
const_iterator
cit
=
perDofVariableList
.
begin
();
cit
!=
perDofVariableList
.
end
();
cit
++
,
count
++
)
{
const
vector
<
SerializationNode
>&
perDofVariableVector
=
cit
->
getChildren
();
integrator
->
addPerDofVariable
(
cit
->
getName
(),
0
);
for
(
auto
&
var
:
perDofVariablesNode
.
getChildren
())
{
integrator
->
addPerDofVariable
(
var
.
getName
(),
0
);
vector
<
Vec3
>
perDofValues
;
for
(
vector
<
SerializationNode
>::
const_iterator
dit
=
perDofVariableVector
.
begin
();
dit
!=
perDofVariableVector
.
end
();
dit
++
)
{
perDofValues
.
push_back
(
Vec3
(
dit
->
getDoubleProperty
(
"x"
),
dit
->
getDoubleProperty
(
"y"
),
dit
->
getDoubleProperty
(
"z"
)));
}
for
(
auto
&
child
:
var
.
getChildren
())
perDofValues
.
push_back
(
Vec3
(
child
.
getDoubleProperty
(
"x"
),
child
.
getDoubleProperty
(
"y"
),
child
.
getDoubleProperty
(
"z"
)));
integrator
->
setPerDofVariable
(
count
,
perDofValues
);
count
++
;
}
const
SerializationNode
&
computationsNode
=
node
.
getChildNode
(
"Computations"
);
const
vector
<
SerializationNode
>&
computationsList
=
computationsNode
.
getChildren
();
for
(
vector
<
SerializationNode
>::
const_iterator
cit
=
computationsList
.
begin
();
cit
!=
computationsList
.
end
();
cit
++
)
{
CustomIntegrator
::
ComputationType
computationType
=
static_cast
<
CustomIntegrator
::
ComputationType
>
(
cit
->
getIntProperty
(
"computationType"
));
for
(
auto
&
comp
:
computationsNode
.
getChildren
())
{
CustomIntegrator
::
ComputationType
computationType
=
static_cast
<
CustomIntegrator
::
ComputationType
>
(
comp
.
getIntProperty
(
"computationType"
));
// make sure that the int casts to a valid enum
if
(
computationType
==
CustomIntegrator
::
ComputeGlobal
)
{
integrator
->
addComputeGlobal
(
c
it
->
getStringProperty
(
"computationVariable"
),
c
it
->
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
ComputePerDof
)
{
integrator
->
addComputePerDof
(
c
it
->
getStringProperty
(
"computationVariable"
),
c
it
->
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
ComputeSum
)
{
integrator
->
addComputeSum
(
c
it
->
getStringProperty
(
"computationVariable"
),
c
it
->
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
ConstrainPositions
)
{
if
(
computationType
==
CustomIntegrator
::
ComputeGlobal
)
{
integrator
->
addComputeGlobal
(
c
omp
.
getStringProperty
(
"computationVariable"
),
c
omp
.
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
ComputePerDof
)
{
integrator
->
addComputePerDof
(
c
omp
.
getStringProperty
(
"computationVariable"
),
c
omp
.
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
ComputeSum
)
{
integrator
->
addComputeSum
(
c
omp
.
getStringProperty
(
"computationVariable"
),
c
omp
.
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
ConstrainPositions
)
{
integrator
->
addConstrainPositions
();
}
else
if
(
computationType
==
CustomIntegrator
::
ConstrainVelocities
)
{
}
else
if
(
computationType
==
CustomIntegrator
::
ConstrainVelocities
)
{
integrator
->
addConstrainVelocities
();
}
else
if
(
computationType
==
CustomIntegrator
::
UpdateContextState
)
{
}
else
if
(
computationType
==
CustomIntegrator
::
UpdateContextState
)
{
integrator
->
addUpdateContextState
();
}
else
if
(
computationType
==
CustomIntegrator
::
IfBlockStart
)
{
integrator
->
beginIfBlock
(
c
it
->
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
WhileBlockStart
)
{
integrator
->
beginWhileBlock
(
c
it
->
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
BlockEnd
)
{
integrator
->
endBlock
();
}
else
if
(
computationType
==
CustomIntegrator
::
IfBlockStart
)
{
integrator
->
beginIfBlock
(
c
omp
.
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
WhileBlockStart
)
{
integrator
->
beginWhileBlock
(
c
omp
.
getStringProperty
(
"computationExpression"
));
}
else
if
(
computationType
==
CustomIntegrator
::
BlockEnd
)
{
integrator
->
endBlock
();
}
else
{
throw
(
OpenMMException
(
"Custom Integrator Deserialization: Unknown computation type"
));
}
...
...
serialization/src/CustomManyParticleForceProxy.cpp
View file @
08e8b206
...
...
@@ -84,10 +84,10 @@ void CustomManyParticleForceProxy::serialize(const void* object, SerializationNo
force
.
getTypeFilter
(
i
,
types
);
stringstream
list
;
bool
first
=
true
;
for
(
set
<
int
>::
const_iterator
iter
=
types
.
begin
();
iter
!=
types
.
end
();
++
iter
)
{
for
(
int
type
:
types
)
{
if
(
!
first
)
list
<<
","
;
list
<<
*
iter
;
list
<<
type
;
first
=
false
;
}
filters
.
createChildNode
(
"Filter"
).
setIntProperty
(
"index"
,
i
).
setStringProperty
(
"types"
,
list
.
str
());
...
...
@@ -108,19 +108,14 @@ void* CustomManyParticleForceProxy::deserialize(const SerializationNode& node) c
force
->
setPermutationMode
((
CustomManyParticleForce
::
PermutationMode
)
node
.
getIntProperty
(
"permutationMode"
));
force
->
setCutoffDistance
(
node
.
getDoubleProperty
(
"cutoff"
));
const
SerializationNode
&
perParticleParams
=
node
.
getChildNode
(
"PerParticleParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
perParticleParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
perParticleParams
.
getChildren
()[
i
];
for
(
auto
&
parameter
:
perParticleParams
.
getChildren
())
force
->
addPerParticleParameter
(
parameter
.
getStringProperty
(
"name"
));
}
const
SerializationNode
&
globalParams
=
node
.
getChildNode
(
"GlobalParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
globalParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
globalParams
.
getChildren
()[
i
];
for
(
auto
&
parameter
:
globalParams
.
getChildren
())
force
->
addGlobalParameter
(
parameter
.
getStringProperty
(
"name"
),
parameter
.
getDoubleProperty
(
"default"
));
}
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
vector
<
double
>
params
(
force
->
getNumPerParticleParameters
());
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
particles
.
getChildren
()[
i
];
for
(
auto
&
particle
:
particles
.
getChildren
())
{
for
(
int
j
=
0
;
j
<
(
int
)
params
.
size
();
j
++
)
{
stringstream
key
;
key
<<
"param"
;
...
...
@@ -130,13 +125,10 @@ void* CustomManyParticleForceProxy::deserialize(const SerializationNode& node) c
force
->
addParticle
(
params
,
particle
.
getIntProperty
(
"type"
));
}
const
SerializationNode
&
exclusions
=
node
.
getChildNode
(
"Exclusions"
);
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
exclusion
=
exclusions
.
getChildren
()[
i
];
for
(
auto
&
exclusion
:
exclusions
.
getChildren
())
force
->
addExclusion
(
exclusion
.
getIntProperty
(
"p1"
),
exclusion
.
getIntProperty
(
"p2"
));
}
const
SerializationNode
&
filters
=
node
.
getChildNode
(
"TypeFilters"
);
for
(
int
i
=
0
;
i
<
(
int
)
filters
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
filter
=
filters
.
getChildren
()[
i
];
for
(
auto
&
filter
:
filters
.
getChildren
())
{
string
typesString
=
filter
.
getStringProperty
(
"types"
);
vector
<
string
>
splitTypes
;
size_t
searchPos
=
0
,
nextPos
;
...
...
@@ -146,20 +138,18 @@ void* CustomManyParticleForceProxy::deserialize(const SerializationNode& node) c
}
splitTypes
.
push_back
(
typesString
.
substr
(
searchPos
));
set
<
int
>
types
;
for
(
int
j
=
0
;
j
<
(
int
)
splitTypes
.
size
();
j
++
)
{
if
(
splitTypes
[
j
]
.
size
()
>
0
)
{
for
(
auto
&
t
:
splitTypes
)
{
if
(
t
.
size
()
>
0
)
{
int
type
;
stringstream
(
splitTypes
[
j
]
)
>>
type
;
stringstream
(
t
)
>>
type
;
types
.
insert
(
type
);
}
}
force
->
setTypeFilter
(
filter
.
getIntProperty
(
"index"
),
types
);
}
const
SerializationNode
&
functions
=
node
.
getChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
function
=
functions
.
getChildren
()[
i
];
for
(
auto
&
function
:
functions
.
getChildren
())
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
function
.
decodeObject
<
TabulatedFunction
>
());
}
return
force
;
}
catch
(...)
{
...
...
serialization/src/CustomNonbondedForceProxy.cpp
View file @
08e8b206
...
...
@@ -92,11 +92,11 @@ void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode&
std
::
set
<
int
>
set2
;
force
.
getInteractionGroupParameters
(
i
,
set1
,
set2
);
SerializationNode
&
set1node
=
interactionGroup
.
createChildNode
(
"Set1"
);
for
(
std
::
set
<
int
>::
iterator
it
=
set1
.
begin
();
it
!=
set1
.
end
();
++
it
)
set1node
.
createChildNode
(
"Particle"
).
setIntProperty
(
"index"
,
*
it
);
for
(
int
p
:
set1
)
set1node
.
createChildNode
(
"Particle"
).
setIntProperty
(
"index"
,
p
);
SerializationNode
&
set2node
=
interactionGroup
.
createChildNode
(
"Set2"
);
for
(
std
::
set
<
int
>::
iterator
it
=
set2
.
begin
();
it
!=
set2
.
end
();
++
it
)
set2node
.
createChildNode
(
"Particle"
).
setIntProperty
(
"index"
,
*
it
);
for
(
int
p
:
set2
)
set2node
.
createChildNode
(
"Particle"
).
setIntProperty
(
"index"
,
p
);
}
}
...
...
@@ -114,26 +114,19 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
force
->
setSwitchingDistance
(
node
.
getDoubleProperty
(
"switchingDistance"
,
-
1.0
));
force
->
setUseLongRangeCorrection
(
node
.
getBoolProperty
(
"useLongRangeCorrection"
,
false
));
const
SerializationNode
&
perParticleParams
=
node
.
getChildNode
(
"PerParticleParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
perParticleParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
perParticleParams
.
getChildren
()[
i
];
for
(
auto
&
parameter
:
perParticleParams
.
getChildren
())
force
->
addPerParticleParameter
(
parameter
.
getStringProperty
(
"name"
));
}
const
SerializationNode
&
globalParams
=
node
.
getChildNode
(
"GlobalParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
globalParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
globalParams
.
getChildren
()[
i
];
for
(
auto
&
parameter
:
globalParams
.
getChildren
())
force
->
addGlobalParameter
(
parameter
.
getStringProperty
(
"name"
),
parameter
.
getDoubleProperty
(
"default"
));
}
if
(
version
>
1
)
{
const
SerializationNode
&
energyDerivs
=
node
.
getChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
(
int
)
energyDerivs
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
energyDerivs
.
getChildren
()[
i
];
for
(
auto
&
parameter
:
energyDerivs
.
getChildren
())
force
->
addEnergyParameterDerivative
(
parameter
.
getStringProperty
(
"name"
));
}
}
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
vector
<
double
>
params
(
force
->
getNumPerParticleParameters
());
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
particles
.
getChildren
()[
i
];
for
(
auto
&
particle
:
particles
.
getChildren
())
{
for
(
int
j
=
0
;
j
<
(
int
)
params
.
size
();
j
++
)
{
stringstream
key
;
key
<<
"param"
;
...
...
@@ -143,13 +136,10 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
force
->
addParticle
(
params
);
}
const
SerializationNode
&
exclusions
=
node
.
getChildNode
(
"Exclusions"
);
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
exclusion
=
exclusions
.
getChildren
()[
i
];
for
(
auto
&
exclusion
:
exclusions
.
getChildren
())
force
->
addExclusion
(
exclusion
.
getIntProperty
(
"p1"
),
exclusion
.
getIntProperty
(
"p2"
));
}
const
SerializationNode
&
functions
=
node
.
getChildNode
(
"Functions"
);
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
function
=
functions
.
getChildren
()[
i
];
for
(
auto
&
function
:
functions
.
getChildren
())
{
if
(
function
.
hasProperty
(
"type"
))
{
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
function
.
decodeObject
<
TabulatedFunction
>
());
}
...
...
@@ -158,30 +148,28 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
const
SerializationNode
&
valuesNode
=
function
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
()
.
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
]
.
getDoubleProperty
(
"v"
));
for
(
auto
&
child
:
valuesNode
.
getChildren
())
values
.
push_back
(
child
.
getDoubleProperty
(
"v"
));
force
->
addTabulatedFunction
(
function
.
getStringProperty
(
"name"
),
new
Continuous1DFunction
(
values
,
function
.
getDoubleProperty
(
"min"
),
function
.
getDoubleProperty
(
"max"
)));
}
}
bool
hasInteractionGroups
=
false
;
// Older files will be missing this block.
for
(
int
i
=
0
;
i
<
(
int
)
node
.
getChildren
()
.
size
();
i
++
)
{
if
(
node
.
getChildren
()[
i
]
.
getName
()
==
"InteractionGroups"
)
for
(
auto
&
child
:
node
.
getChildren
()
)
if
(
child
.
getName
()
==
"InteractionGroups"
)
hasInteractionGroups
=
true
;
}
if
(
hasInteractionGroups
)
{
const
SerializationNode
&
interactionGroups
=
node
.
getChildNode
(
"InteractionGroups"
);
for
(
int
i
=
0
;
i
<
(
int
)
interactionGroups
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
interactionGroup
=
interactionGroups
.
getChildren
()[
i
];
for
(
auto
&
interactionGroup
:
interactionGroups
.
getChildren
())
{
// Get set 1.
const
SerializationNode
&
set1node
=
interactionGroup
.
getChildNode
(
"Set1"
);
std
::
set
<
int
>
set1
;
for
(
int
j
=
0
;
j
<
(
int
)
set1node
.
getChildren
()
.
size
();
j
++
)
set1
.
insert
(
set1node
.
getChildren
()[
j
]
.
getIntProperty
(
"index"
));
for
(
auto
&
child
:
set1node
.
getChildren
())
set1
.
insert
(
child
.
getIntProperty
(
"index"
));
// Get set 2.
const
SerializationNode
&
set2node
=
interactionGroup
.
getChildNode
(
"Set2"
);
std
::
set
<
int
>
set2
;
for
(
int
j
=
0
;
j
<
(
int
)
set2node
.
getChildren
()
.
size
();
j
++
)
set2
.
insert
(
set2node
.
getChildren
()[
j
]
.
getIntProperty
(
"index"
));
for
(
auto
&
child
:
set2node
.
getChildren
())
set2
.
insert
(
child
.
getIntProperty
(
"index"
));
force
->
addInteractionGroup
(
set1
,
set2
);
}
}
...
...
serialization/src/CustomTorsionForceProxy.cpp
View file @
08e8b206
...
...
@@ -85,26 +85,19 @@ void* CustomTorsionForceProxy::deserialize(const SerializationNode& node) const
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
perTorsionParams
=
node
.
getChildNode
(
"PerTorsionParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
perTorsionParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
perTorsionParams
.
getChildren
()[
i
];
for
(
auto
&
parameter
:
perTorsionParams
.
getChildren
())
force
->
addPerTorsionParameter
(
parameter
.
getStringProperty
(
"name"
));
}
const
SerializationNode
&
globalParams
=
node
.
getChildNode
(
"GlobalParameters"
);
for
(
int
i
=
0
;
i
<
(
int
)
globalParams
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
globalParams
.
getChildren
()[
i
];
for
(
auto
&
parameter
:
globalParams
.
getChildren
())
force
->
addGlobalParameter
(
parameter
.
getStringProperty
(
"name"
),
parameter
.
getDoubleProperty
(
"default"
));
}
if
(
version
>
2
)
{
const
SerializationNode
&
energyDerivs
=
node
.
getChildNode
(
"EnergyParameterDerivatives"
);
for
(
int
i
=
0
;
i
<
(
int
)
energyDerivs
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
parameter
=
energyDerivs
.
getChildren
()[
i
];
for
(
auto
&
parameter
:
energyDerivs
.
getChildren
())
force
->
addEnergyParameterDerivative
(
parameter
.
getStringProperty
(
"name"
));
}
}
const
SerializationNode
&
torsions
=
node
.
getChildNode
(
"Torsions"
);
vector
<
double
>
params
(
force
->
getNumPerTorsionParameters
());
for
(
int
i
=
0
;
i
<
(
int
)
torsions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
torsion
=
torsions
.
getChildren
()[
i
];
for
(
auto
&
torsion
:
torsions
.
getChildren
())
{
for
(
int
j
=
0
;
j
<
(
int
)
params
.
size
();
j
++
)
{
stringstream
key
;
key
<<
"param"
;
...
...
serialization/src/GBSAOBCForceProxy.cpp
View file @
08e8b206
...
...
@@ -72,10 +72,8 @@ void* GBSAOBCForceProxy::deserialize(const SerializationNode& node) const {
if
(
version
>
1
)
force
->
setSurfaceAreaEnergy
(
node
.
getDoubleProperty
(
"surfaceAreaEnergy"
));
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
particles
.
getChildren
()[
i
];
for
(
auto
&
particle
:
particles
.
getChildren
())
force
->
addParticle
(
particle
.
getDoubleProperty
(
"q"
),
particle
.
getDoubleProperty
(
"r"
),
particle
.
getDoubleProperty
(
"scale"
));
}
}
catch
(...)
{
delete
force
;
...
...
serialization/src/GayBerneForceProxy.cpp
View file @
08e8b206
...
...
@@ -78,17 +78,13 @@ void* GayBerneForceProxy::deserialize(const SerializationNode& node) const {
force
->
setUseSwitchingFunction
(
node
.
getBoolProperty
(
"useSwitchingFunction"
,
false
));
force
->
setSwitchingDistance
(
node
.
getDoubleProperty
(
"switchingDistance"
,
-
1.0
));
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
particles
.
getChildren
()[
i
];
for
(
auto
&
particle
:
particles
.
getChildren
())
force
->
addParticle
(
particle
.
getDoubleProperty
(
"sig"
),
particle
.
getDoubleProperty
(
"eps"
),
particle
.
getIntProperty
(
"xparticle"
),
particle
.
getIntProperty
(
"yparticle"
),
particle
.
getDoubleProperty
(
"sx"
),
particle
.
getDoubleProperty
(
"sy"
),
particle
.
getDoubleProperty
(
"sz"
),
particle
.
getDoubleProperty
(
"ex"
),
particle
.
getDoubleProperty
(
"ey"
),
particle
.
getDoubleProperty
(
"ez"
));
}
const
SerializationNode
&
exceptions
=
node
.
getChildNode
(
"Exceptions"
);
for
(
int
i
=
0
;
i
<
(
int
)
exceptions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
exception
=
exceptions
.
getChildren
()[
i
];
for
(
auto
&
exception
:
exceptions
.
getChildren
())
force
->
addException
(
exception
.
getIntProperty
(
"p1"
),
exception
.
getIntProperty
(
"p2"
),
exception
.
getDoubleProperty
(
"sig"
),
exception
.
getDoubleProperty
(
"eps"
));
}
}
catch
(...)
{
delete
force
;
...
...
serialization/src/HarmonicAngleForceProxy.cpp
View file @
08e8b206
...
...
@@ -65,10 +65,8 @@ void* HarmonicAngleForceProxy::deserialize(const SerializationNode& node) const
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
angles
=
node
.
getChildNode
(
"Angles"
);
for
(
int
i
=
0
;
i
<
(
int
)
angles
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
angle
=
angles
.
getChildren
()[
i
];
for
(
auto
&
angle
:
angles
.
getChildren
())
force
->
addAngle
(
angle
.
getIntProperty
(
"p1"
),
angle
.
getIntProperty
(
"p2"
),
angle
.
getIntProperty
(
"p3"
),
angle
.
getDoubleProperty
(
"a"
),
angle
.
getDoubleProperty
(
"k"
));
}
}
catch
(...)
{
delete
force
;
...
...
serialization/src/HarmonicBondForceProxy.cpp
View file @
08e8b206
...
...
@@ -65,10 +65,8 @@ void* HarmonicBondForceProxy::deserialize(const SerializationNode& node) const {
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
bonds
=
node
.
getChildNode
(
"Bonds"
);
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
bond
=
bonds
.
getChildren
()[
i
];
for
(
auto
&
bond
:
bonds
.
getChildren
())
force
->
addBond
(
bond
.
getIntProperty
(
"p1"
),
bond
.
getIntProperty
(
"p2"
),
bond
.
getDoubleProperty
(
"d"
),
bond
.
getDoubleProperty
(
"k"
));
}
}
catch
(...)
{
delete
force
;
...
...
serialization/src/NonbondedForceProxy.cpp
View file @
08e8b206
...
...
@@ -108,15 +108,11 @@ void* NonbondedForceProxy::deserialize(const SerializationNode& node) const {
}
force
->
setReciprocalSpaceForceGroup
(
node
.
getIntProperty
(
"recipForceGroup"
,
-
1
));
const
SerializationNode
&
particles
=
node
.
getChildNode
(
"Particles"
);
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
particles
.
getChildren
()[
i
];
for
(
auto
&
particle
:
particles
.
getChildren
())
force
->
addParticle
(
particle
.
getDoubleProperty
(
"q"
),
particle
.
getDoubleProperty
(
"sig"
),
particle
.
getDoubleProperty
(
"eps"
));
}
const
SerializationNode
&
exceptions
=
node
.
getChildNode
(
"Exceptions"
);
for
(
int
i
=
0
;
i
<
(
int
)
exceptions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
exception
=
exceptions
.
getChildren
()[
i
];
for
(
auto
&
exception
:
exceptions
.
getChildren
())
force
->
addException
(
exception
.
getIntProperty
(
"p1"
),
exception
.
getIntProperty
(
"p2"
),
exception
.
getDoubleProperty
(
"q"
),
exception
.
getDoubleProperty
(
"sig"
),
exception
.
getDoubleProperty
(
"eps"
));
}
}
catch
(...)
{
delete
force
;
...
...
serialization/src/PeriodicTorsionForceProxy.cpp
View file @
08e8b206
...
...
@@ -65,11 +65,9 @@ void* PeriodicTorsionForceProxy::deserialize(const SerializationNode& node) cons
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
torsions
=
node
.
getChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
(
int
)
torsions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
torsion
=
torsions
.
getChildren
()[
i
];
for
(
auto
&
torsion
:
torsions
.
getChildren
())
force
->
addTorsion
(
torsion
.
getIntProperty
(
"p1"
),
torsion
.
getIntProperty
(
"p2"
),
torsion
.
getIntProperty
(
"p3"
),
torsion
.
getIntProperty
(
"p4"
),
torsion
.
getIntProperty
(
"periodicity"
),
torsion
.
getDoubleProperty
(
"phase"
),
torsion
.
getDoubleProperty
(
"k"
));
}
}
catch
(...)
{
delete
force
;
...
...
serialization/src/RBTorsionForceProxy.cpp
View file @
08e8b206
...
...
@@ -65,12 +65,10 @@ void* RBTorsionForceProxy::deserialize(const SerializationNode& node) const {
if
(
version
>
1
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
torsions
=
node
.
getChildNode
(
"Torsions"
);
for
(
int
i
=
0
;
i
<
(
int
)
torsions
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
torsion
=
torsions
.
getChildren
()[
i
];
for
(
auto
&
torsion
:
torsions
.
getChildren
())
force
->
addTorsion
(
torsion
.
getIntProperty
(
"p1"
),
torsion
.
getIntProperty
(
"p2"
),
torsion
.
getIntProperty
(
"p3"
),
torsion
.
getIntProperty
(
"p4"
),
torsion
.
getDoubleProperty
(
"c0"
),
torsion
.
getDoubleProperty
(
"c1"
),
torsion
.
getDoubleProperty
(
"c2"
),
torsion
.
getDoubleProperty
(
"c3"
),
torsion
.
getDoubleProperty
(
"c4"
),
torsion
.
getDoubleProperty
(
"c5"
));
}
}
catch
(...)
{
delete
force
;
...
...
serialization/src/SerializationNode.cpp
View file @
08e8b206
...
...
@@ -56,16 +56,16 @@ vector<SerializationNode>& SerializationNode::getChildren() {
}
const
SerializationNode
&
SerializationNode
::
getChildNode
(
const
std
::
string
&
name
)
const
{
for
(
int
i
=
0
;
i
<
(
int
)
children
.
size
();
i
++
)
if
(
child
ren
[
i
]
.
name
==
name
)
return
child
ren
[
i
]
;
for
(
auto
&
child
:
children
)
if
(
child
.
name
==
name
)
return
child
;
throw
OpenMMException
(
"Unknown child '"
+
name
+
"' for node '"
+
getName
()
+
"'"
);
}
SerializationNode
&
SerializationNode
::
getChildNode
(
const
std
::
string
&
name
)
{
for
(
int
i
=
0
;
i
<
(
int
)
children
.
size
();
i
++
)
if
(
child
ren
[
i
]
.
name
==
name
)
return
child
ren
[
i
]
;
for
(
auto
&
child
:
children
)
if
(
child
.
name
==
name
)
return
child
;
throw
OpenMMException
(
"Unknown child '"
+
name
+
"' for node '"
+
getName
()
+
"'"
);
}
...
...
serialization/src/StateProxy.cpp
View file @
08e8b206
...
...
@@ -56,11 +56,8 @@ void StateProxy::serialize(const void* object, SerializationNode& node) const {
if
((
s
.
getDataTypes
()
&
State
::
Parameters
)
!=
0
)
{
s
.
getParameters
();
SerializationNode
&
parametersNode
=
node
.
createChildNode
(
"Parameters"
);
map
<
string
,
double
>
stateParams
=
s
.
getParameters
();
map
<
string
,
double
>::
const_iterator
it
;
for
(
it
=
stateParams
.
begin
();
it
!=
stateParams
.
end
();
it
++
)
{
parametersNode
.
setDoubleProperty
(
it
->
first
,
it
->
second
);
}
for
(
auto
&
param
:
s
.
getParameters
())
parametersNode
.
setDoubleProperty
(
param
.
first
,
param
.
second
);
}
if
((
s
.
getDataTypes
()
&
State
::
Energy
)
!=
0
)
{
s
.
getPotentialEnergy
();
...
...
@@ -108,17 +105,11 @@ void* StateProxy::deserialize(const SerializationNode& node) const {
int
types
=
0
;
vector
<
int
>
arraySizes
;
State
::
StateBuilder
builder
(
outTime
);
const
vector
<
SerializationNode
>&
children
=
node
.
getChildren
();
for
(
int
j
=
0
;
j
<
(
int
)
children
.
size
();
j
++
)
{
const
SerializationNode
&
child
=
children
[
j
];
for
(
auto
&
child
:
node
.
getChildren
())
{
if
(
child
.
getName
()
==
"Parameters"
)
{
map
<
string
,
double
>
outStateParams
;
// inStateParams is really a <string,double> pair, where string is the name and double is the value
// but we want to avoid casting a string to a double and instead use the built in routines,
map
<
string
,
string
>
inStateParams
=
child
.
getProperties
();
for
(
map
<
string
,
string
>::
const_iterator
pit
=
inStateParams
.
begin
();
pit
!=
inStateParams
.
end
();
pit
++
)
{
outStateParams
[
pit
->
first
]
=
child
.
getDoubleProperty
(
pit
->
first
);
}
for
(
auto
&
param
:
child
.
getProperties
())
outStateParams
[
param
.
first
]
=
child
.
getDoubleProperty
(
param
.
first
);
builder
.
setParameters
(
outStateParams
);
}
else
if
(
child
.
getName
()
==
"Energies"
)
{
...
...
@@ -128,28 +119,22 @@ void* StateProxy::deserialize(const SerializationNode& node) const {
}
else
if
(
child
.
getName
()
==
"Positions"
)
{
vector
<
Vec3
>
outPositions
;
for
(
int
i
=
0
;
i
<
(
int
)
child
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
child
.
getChildren
()[
i
];
for
(
auto
&
particle
:
child
.
getChildren
())
outPositions
.
push_back
(
Vec3
(
particle
.
getDoubleProperty
(
"x"
),
particle
.
getDoubleProperty
(
"y"
),
particle
.
getDoubleProperty
(
"z"
)));
}
builder
.
setPositions
(
outPositions
);
arraySizes
.
push_back
(
outPositions
.
size
());
}
else
if
(
child
.
getName
()
==
"Velocities"
)
{
vector
<
Vec3
>
outVelocities
;
for
(
int
i
=
0
;
i
<
(
int
)
child
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
child
.
getChildren
()[
i
];
for
(
auto
&
particle
:
child
.
getChildren
())
outVelocities
.
push_back
(
Vec3
(
particle
.
getDoubleProperty
(
"x"
),
particle
.
getDoubleProperty
(
"y"
),
particle
.
getDoubleProperty
(
"z"
)));
}
builder
.
setVelocities
(
outVelocities
);
arraySizes
.
push_back
(
outVelocities
.
size
());
}
else
if
(
child
.
getName
()
==
"Forces"
)
{
vector
<
Vec3
>
outForces
;
for
(
int
i
=
0
;
i
<
(
int
)
child
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
particle
=
child
.
getChildren
()[
i
];
for
(
auto
&
particle
:
child
.
getChildren
())
outForces
.
push_back
(
Vec3
(
particle
.
getDoubleProperty
(
"x"
),
particle
.
getDoubleProperty
(
"y"
),
particle
.
getDoubleProperty
(
"z"
)));
}
builder
.
setForces
(
outForces
);
arraySizes
.
push_back
(
outForces
.
size
());
}
...
...
serialization/src/SystemProxy.cpp
View file @
08e8b206
...
...
@@ -129,14 +129,11 @@ void* SystemProxy::deserialize(const SerializationNode& node) const {
}
}
const
SerializationNode
&
constraints
=
node
.
getChildNode
(
"Constraints"
);
for
(
int
i
=
0
;
i
<
(
int
)
constraints
.
getChildren
().
size
();
i
++
)
{
const
SerializationNode
&
constraint
=
constraints
.
getChildren
()[
i
];
for
(
auto
&
constraint
:
constraints
.
getChildren
())
system
->
addConstraint
(
constraint
.
getIntProperty
(
"p1"
),
constraint
.
getIntProperty
(
"p2"
),
constraint
.
getDoubleProperty
(
"d"
));
}
const
SerializationNode
&
forces
=
node
.
getChildNode
(
"Forces"
);
for
(
int
i
=
0
;
i
<
(
int
)
forces
.
getChildren
().
size
();
i
++
)
{
system
->
addForce
(
forces
.
getChildren
()[
i
].
decodeObject
<
Force
>
());
}
for
(
auto
&
force
:
forces
.
getChildren
())
system
->
addForce
(
force
.
decodeObject
<
Force
>
());
}
catch
(...)
{
delete
system
;
...
...
serialization/src/TabulatedFunctionProxies.cpp
View file @
08e8b206
...
...
@@ -49,8 +49,8 @@ void Continuous1DFunctionProxy::serialize(const void* object, SerializationNode&
node
.
setDoubleProperty
(
"min"
,
min
);
node
.
setDoubleProperty
(
"max"
,
max
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
alues
[
j
]
);
for
(
auto
v
:
values
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
);
}
void
*
Continuous1DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -58,8 +58,8 @@ void* Continuous1DFunctionProxy::deserialize(const SerializationNode& node) cons
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
()
.
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
]
.
getDoubleProperty
(
"v"
));
for
(
auto
&
child
:
valuesNode
.
getChildren
())
values
.
push_back
(
child
.
getDoubleProperty
(
"v"
));
return
new
Continuous1DFunction
(
values
,
node
.
getDoubleProperty
(
"min"
),
node
.
getDoubleProperty
(
"max"
));
}
...
...
@@ -80,8 +80,8 @@ void Continuous2DFunctionProxy::serialize(const void* object, SerializationNode&
node
.
setDoubleProperty
(
"ymin"
,
ymin
);
node
.
setDoubleProperty
(
"ymax"
,
ymax
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
alues
[
j
]
);
for
(
auto
v
:
values
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
);
}
void
*
Continuous2DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -89,8 +89,8 @@ void* Continuous2DFunctionProxy::deserialize(const SerializationNode& node) cons
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
()
.
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
]
.
getDoubleProperty
(
"v"
));
for
(
auto
&
child
:
valuesNode
.
getChildren
())
values
.
push_back
(
child
.
getDoubleProperty
(
"v"
));
return
new
Continuous2DFunction
(
node
.
getIntProperty
(
"xsize"
),
node
.
getIntProperty
(
"ysize"
),
values
,
node
.
getDoubleProperty
(
"xmin"
),
node
.
getDoubleProperty
(
"xmax"
),
node
.
getDoubleProperty
(
"ymin"
),
node
.
getDoubleProperty
(
"ymax"
));
}
...
...
@@ -115,8 +115,8 @@ void Continuous3DFunctionProxy::serialize(const void* object, SerializationNode&
node
.
setDoubleProperty
(
"zmin"
,
zmin
);
node
.
setDoubleProperty
(
"zmax"
,
zmax
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
alues
[
j
]
);
for
(
auto
v
:
values
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
);
}
void
*
Continuous3DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -124,8 +124,8 @@ void* Continuous3DFunctionProxy::deserialize(const SerializationNode& node) cons
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
()
.
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
]
.
getDoubleProperty
(
"v"
));
for
(
auto
&
child
:
valuesNode
.
getChildren
())
values
.
push_back
(
child
.
getDoubleProperty
(
"v"
));
return
new
Continuous3DFunction
(
node
.
getIntProperty
(
"xsize"
),
node
.
getIntProperty
(
"ysize"
),
node
.
getIntProperty
(
"zsize"
),
values
,
node
.
getDoubleProperty
(
"xmin"
),
node
.
getDoubleProperty
(
"xmax"
),
node
.
getDoubleProperty
(
"ymin"
),
node
.
getDoubleProperty
(
"ymax"
),
node
.
getDoubleProperty
(
"zmin"
),
node
.
getDoubleProperty
(
"zmax"
));
...
...
@@ -140,8 +140,8 @@ void Discrete1DFunctionProxy::serialize(const void* object, SerializationNode& n
vector
<
double
>
values
;
function
.
getFunctionParameters
(
values
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
alues
[
j
]
);
for
(
auto
v
:
values
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
);
}
void
*
Discrete1DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -149,8 +149,8 @@ void* Discrete1DFunctionProxy::deserialize(const SerializationNode& node) const
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
()
.
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
]
.
getDoubleProperty
(
"v"
));
for
(
auto
&
child
:
valuesNode
.
getChildren
())
values
.
push_back
(
child
.
getDoubleProperty
(
"v"
));
return
new
Discrete1DFunction
(
values
);
}
...
...
@@ -166,8 +166,8 @@ void Discrete2DFunctionProxy::serialize(const void* object, SerializationNode& n
node
.
setDoubleProperty
(
"xsize"
,
xsize
);
node
.
setDoubleProperty
(
"ysize"
,
ysize
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
alues
[
j
]
);
for
(
auto
v
:
values
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
);
}
void
*
Discrete2DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -175,8 +175,8 @@ void* Discrete2DFunctionProxy::deserialize(const SerializationNode& node) const
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
()
.
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
]
.
getDoubleProperty
(
"v"
));
for
(
auto
&
child
:
valuesNode
.
getChildren
())
values
.
push_back
(
child
.
getDoubleProperty
(
"v"
));
return
new
Discrete2DFunction
(
node
.
getIntProperty
(
"xsize"
),
node
.
getIntProperty
(
"ysize"
),
values
);
}
...
...
@@ -193,8 +193,8 @@ void Discrete3DFunctionProxy::serialize(const void* object, SerializationNode& n
node
.
setDoubleProperty
(
"ysize"
,
ysize
);
node
.
setDoubleProperty
(
"zsize"
,
zsize
);
SerializationNode
&
valuesNode
=
node
.
createChildNode
(
"Values"
);
for
(
int
j
=
0
;
j
<
(
int
)
values
.
size
();
j
++
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
alues
[
j
]
);
for
(
auto
v
:
values
)
valuesNode
.
createChildNode
(
"Value"
).
setDoubleProperty
(
"v"
,
v
);
}
void
*
Discrete3DFunctionProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
...
...
@@ -202,7 +202,7 @@ void* Discrete3DFunctionProxy::deserialize(const SerializationNode& node) const
throw
OpenMMException
(
"Unsupported version number"
);
const
SerializationNode
&
valuesNode
=
node
.
getChildNode
(
"Values"
);
vector
<
double
>
values
;
for
(
int
j
=
0
;
j
<
(
int
)
valuesNode
.
getChildren
()
.
size
();
j
++
)
values
.
push_back
(
valuesNode
.
getChildren
()[
j
]
.
getDoubleProperty
(
"v"
));
for
(
auto
&
child
:
valuesNode
.
getChildren
())
values
.
push_back
(
child
.
getDoubleProperty
(
"v"
));
return
new
Discrete3DFunction
(
node
.
getIntProperty
(
"xsize"
),
node
.
getIntProperty
(
"ysize"
),
node
.
getIntProperty
(
"zsize"
),
values
);
}
serialization/src/XmlSerializer.cpp
View file @
08e8b206
...
...
@@ -115,11 +115,10 @@ void XmlSerializer::encodeNode(const SerializationNode& node, std::ostream& stre
for
(
int
i
=
0
;
i
<
depth
;
i
++
)
stream
<<
'\t'
;
stream
<<
'<'
<<
node
.
getName
();
const
map
<
string
,
string
>&
properties
=
node
.
getProperties
();
for
(
map
<
string
,
string
>::
const_iterator
iter
=
properties
.
begin
();
iter
!=
properties
.
end
();
++
iter
)
{
for
(
auto
&
prop
:
node
.
getProperties
())
{
string
name
,
value
;
encodeString
(
iter
->
first
,
&
name
);
encodeString
(
iter
->
second
,
&
value
);
encodeString
(
prop
.
first
,
&
name
);
encodeString
(
prop
.
second
,
&
value
);
stream
<<
' '
<<
name
<<
"=
\"
"
<<
value
<<
'\"'
;
}
const
vector
<
SerializationNode
>&
children
=
node
.
getChildren
();
...
...
@@ -127,8 +126,8 @@ void XmlSerializer::encodeNode(const SerializationNode& node, std::ostream& stre
stream
<<
"/>
\n
"
;
else
{
stream
<<
">
\n
"
;
for
(
int
i
=
0
;
i
<
(
int
)
children
.
size
();
i
++
)
encodeNode
(
child
ren
[
i
]
,
stream
,
depth
+
1
);
for
(
auto
&
child
:
children
)
encodeNode
(
child
,
stream
,
depth
+
1
);
for
(
int
i
=
0
;
i
<
depth
;
i
++
)
stream
<<
'\t'
;
stream
<<
"</"
<<
node
.
getName
()
<<
">
\n
"
;
...
...
Prev
1
2
3
4
5
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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