reinterpret transform, set up the actual stream. We can only reinterpret pipes
| 1272 | |
| 1273 | // reinterpret transform, set up the actual stream. We can only reinterpret pipes |
| 1274 | void init() |
| 1275 | { |
| 1276 | if (!transform) |
| 1277 | return; |
| 1278 | |
| 1279 | trainable = transform->trainable; |
| 1280 | |
| 1281 | basis = QSharedPointer<DirectStreamTransform>((DirectStreamTransform *) Transform::make("DirectStream",this)); |
| 1282 | basis->transforms.clear(); |
| 1283 | basis->activeFrames = this->activeFrames; |
| 1284 | basis->endPoint = this->endPoint; |
| 1285 | |
| 1286 | // We need at least a CompositeTransform * to acess transform's children. |
| 1287 | CompositeTransform *downcast = dynamic_cast<CompositeTransform *> (transform); |
| 1288 | |
| 1289 | // If this isn't even a composite transform, or it's not a pipe, just set up |
| 1290 | // basis with 1 stage. |
| 1291 | if (!downcast || QString(transform->metaObject()->className()) != "br::PipeTransform") |
| 1292 | { |
| 1293 | basis->transforms.append(transform); |
| 1294 | basis->init(); |
| 1295 | return; |
| 1296 | } |
| 1297 | if (downcast->transforms.empty()) |
| 1298 | { |
| 1299 | qWarning("Trying to set up empty stream"); |
| 1300 | basis->init(); |
| 1301 | return; |
| 1302 | } |
| 1303 | |
| 1304 | // OK now we will regroup downcast's children |
| 1305 | QList<QList<Transform *> > sets; |
| 1306 | sets.append(QList<Transform *> ()); |
| 1307 | sets.last().append(downcast->transforms[0]); |
| 1308 | if (downcast->transforms[0]->timeVarying()) |
| 1309 | sets.append(QList<Transform *> ()); |
| 1310 | |
| 1311 | for (int i=1;i < downcast->transforms.size(); i++) { |
| 1312 | // If this is time varying it becomse its own stage |
| 1313 | if (downcast->transforms[i]->timeVarying()) { |
| 1314 | // If a set was already active, we add another one |
| 1315 | if (!sets.last().empty()) { |
| 1316 | sets.append(QList<Transform *>()); |
| 1317 | } |
| 1318 | // add the item |
| 1319 | sets.last().append(downcast->transforms[i]); |
| 1320 | // Add another set to indicate separation. |
| 1321 | sets.append(QList<Transform *>()); |
| 1322 | } |
| 1323 | // otherwise, we can combine non time-varying stages |
| 1324 | else { |
| 1325 | sets.last().append(downcast->transforms[i]); |
| 1326 | } |
| 1327 | |
| 1328 | } |
| 1329 | if (sets.last().empty()) |
| 1330 | sets.removeLast(); |
| 1331 |
no test coverage detected