23 const int meshDimensions = 3;
24 const int dataDimensions = 1;
25 const int nValues = 4;
26 const int nTimeSteps = 3;
29 dummyMesh->setVertexOffsets(vertexOffsets);
34 Eigen::VectorXd insert0(nValues);
35 insert0 << 1.0, 2.0, 3.0, 4.0;
36 Eigen::VectorXd insert05(nValues);
37 insert05 << 10.0, 20.0, 30.0, 40.0;
38 Eigen::VectorXd insert1(nValues);
39 insert1 << 100.0, 200.0, 300.0, 400.0;
44 fromDataPtr->setSampleAtTime(0,
time::Sample{dataDimensions, insert0});
45 fromDataPtr->setSampleAtTime(0.5,
time::Sample{dataDimensions, insert05});
46 fromDataPtr->setSampleAtTime(1,
time::Sample{dataDimensions, insert1});
50 Eigen::VectorXd expectedSerialized(nTimeSteps * nValues);
51 expectedSerialized << 1.0, 10.0, 100.0, 2.0, 20.0, 200.0, 3.0, 30.0, 300.0, 4.0, 40.0, 400.0;
53 for (
int i = 0; i < nTimeSteps * nValues; i++) {
54 BOOST_TEST(
testing::equals(serialized.values()(i), expectedSerialized(i)));
62 const int meshDimensions = 3;
63 const int nValues = 4;
64 const int nTimeSteps = 3;
66 Eigen::VectorXd serializedValues(nTimeSteps * nValues);
67 serializedValues << 1.0, 10.0, 100.0, 2.0, 20.0, 200.0, 3.0, 30.0, 300.0, 4.0, 40.0, 400.0;
70 dummyMesh->setVertexOffsets(vertexOffsets);
74 toDataPtr->sample().values = Eigen::VectorXd(nValues);
75 toDataPtr->sample().setZero();
77 toDataPtr->setSampleAtTime(0, toDataPtr->sample());
79 Eigen::VectorXd timeStamps(nTimeSteps);
80 timeStamps << 0, 0.5, 1;
84 serialized.values() = serializedValues;
86 serialized.deserializeInto(timeStamps, toDataPtr);
90 Eigen::VectorXd insert0(nValues);
91 insert0 << 1.0, 2.0, 3.0, 4.0;
92 Eigen::VectorXd insert05(nValues);
93 insert05 << 10.0, 20.0, 30.0, 40.0;
94 Eigen::VectorXd insert1(nValues);
95 insert1 << 100.0, 200.0, 300.0, 400.0;
101 BOOST_TEST(toDataPtr->timeStepsStorage().stamples().size() == nTimeSteps);
102 for (
int t = 0; t < nTimeSteps; t++) {
103 BOOST_TEST(
testing::equals(toDataPtr->timeStepsStorage().stamples()[t].timestamp, timeStamps[t]));
104 for (
int i = 0; i < nValues; i++) {
105 BOOST_TEST(
testing::equals(toDataPtr->timeStepsStorage().stamples()[t].sample.values(i), expectedValues[t](i)));
114 const int meshDimensions = 3;
115 const int dataDimensions = 1;
116 const int nValues = 4;
117 const int nTimeSteps = 3;
120 dummyMesh->setVertexOffsets(vertexOffsets);
123 fromData->requireDataGradient();
125 Eigen::VectorXd insert0(nValues);
126 insert0 << 1.0, 2.0, 3.0, 4.0;
127 Eigen::VectorXd insert05(nValues);
128 insert05 << 10.0, 20.0, 30.0, 40.0;
129 Eigen::VectorXd insert1(nValues);
130 insert1 << 100.0, 200.0, 300.0, 400.0;
131 Eigen::MatrixXd insertGradients0(nValues, meshDimensions);
132 insertGradients0 << 1.0, 2.0, 3.0,
136 Eigen::MatrixXd insertGradients05(nValues, meshDimensions);
137 insertGradients05 << 11.0, 21.0, 31.0,
141 Eigen::MatrixXd insertGradients1(nValues, meshDimensions);
142 insertGradients1 << 111.0, 211.0, 311.0,
149 fromDataPtr->setSampleAtTime(0,
time::Sample{dataDimensions, insert0, insertGradients0});
150 fromDataPtr->setSampleAtTime(0.5,
time::Sample{dataDimensions, insert05, insertGradients05});
151 fromDataPtr->setSampleAtTime(1,
time::Sample{dataDimensions, insert1, insertGradients1});
155 Eigen::VectorXd expectedSerializedValues(nTimeSteps * nValues);
156 expectedSerializedValues << 1.0, 10.0, 100.0, 2.0, 20.0, 200.0, 3.0, 30.0, 300.0, 4.0, 40.0, 400.0;
158 Eigen::VectorXd expectedSerializedGradients(nTimeSteps * nValues * meshDimensions);
159 expectedSerializedGradients << 1.0, 11.0, 111.0, 4.0, 41.0, 411.0, 3.0, 31.0, 311.0, 2.0, 21.0, 211.0, 2.0, 21.0, 211.0, 1.0, 11.0, 111.0, 4.0, 41.0, 411.0, 3.0, 31.0, 311.0, 3.0, 31.0, 311.0, 2.0, 21.0, 211.0, 1.0, 11.0, 111.0, 4.0, 41.0, 411.0;
161 for (
int i = 0; i < nTimeSteps * nValues; i++) {
162 BOOST_TEST(
testing::equals(serialized.values()(i), expectedSerializedValues(i)));
165 for (
int i = 0; i < nTimeSteps * meshDimensions * nValues; i++) {
166 BOOST_TEST(
testing::equals(serialized.gradients()(i), expectedSerializedGradients(i)));
174 const int meshDimensions = 3;
175 const int nValues = 4;
176 const int nTimeSteps = 3;
178 Eigen::VectorXd serializedValues(nTimeSteps * nValues);
179 serializedValues << 1.0, 10.0, 100.0, 2.0, 20.0, 200.0, 3.0, 30.0, 300.0, 4.0, 40.0, 400.0;
181 Eigen::VectorXd serializedGradients(nTimeSteps * nValues * meshDimensions);
182 serializedGradients << 1.0, 11.0, 111.0, 4.0, 41.0, 411.0, 3.0, 31.0, 311.0, 2.0, 21.0, 211.0, 2.0, 21.0, 211.0, 1.0, 11.0, 111.0, 4.0, 41.0, 411.0, 3.0, 31.0, 311.0, 3.0, 31.0, 311.0, 2.0, 21.0, 211.0, 1.0, 11.0, 111.0, 4.0, 41.0, 411.0;
185 dummyMesh->setVertexOffsets(vertexOffsets);
188 toData->requireDataGradient();
191 toDataPtr->sample().values = Eigen::VectorXd(nValues);
192 toDataPtr->sample().gradients = Eigen::MatrixXd(nValues, meshDimensions);
193 toDataPtr->sample().setZero();
195 toDataPtr->setSampleAtTime(0, toDataPtr->sample());
197 Eigen::VectorXd timeStamps(nTimeSteps);
198 timeStamps << 0, 0.5, 1;
202 serialized.values() = serializedValues;
203 serialized.gradients() = serializedGradients;
205 serialized.deserializeInto(timeStamps, toDataPtr);
209 Eigen::VectorXd insert0(nValues);
210 insert0 << 1.0, 2.0, 3.0, 4.0;
211 Eigen::VectorXd insert05(nValues);
212 insert05 << 10.0, 20.0, 30.0, 40.0;
213 Eigen::VectorXd insert1(nValues);
214 insert1 << 100.0, 200.0, 300.0, 400.0;
222 Eigen::MatrixXd insertGradients0(nValues, meshDimensions);
223 insertGradients0 << 1.0, 2.0, 3.0,
227 Eigen::MatrixXd insertGradients05(nValues, meshDimensions);
228 insertGradients05 << 11.0, 21.0, 31.0,
232 Eigen::MatrixXd insertGradients1(nValues, meshDimensions);
233 insertGradients1 << 111.0, 211.0, 311.0,
238 expectedGradients.
push_back(insertGradients0);
239 expectedGradients.
push_back(insertGradients05);
240 expectedGradients.
push_back(insertGradients1);
242 BOOST_TEST(toDataPtr->timeStepsStorage().stamples().size() == nTimeSteps);
243 for (
int t = 0; t < nTimeSteps; t++) {
244 BOOST_TEST(
testing::equals(toDataPtr->timeStepsStorage().stamples()[t].timestamp, timeStamps[t]));
245 for (
int i = 0; i < nValues; i++) {
246 BOOST_TEST(
testing::equals(toDataPtr->timeStepsStorage().stamples()[t].sample.values(i), expectedValues[t](i)));
248 for (
int i = 0; i < meshDimensions * nValues; i++) {
249 BOOST_TEST(
testing::equals(toDataPtr->timeStepsStorage().stamples()[t].sample.gradients(i), expectedGradients[t](i)));