160 printMsg(
"Construct trees", debug::Priority::VERBOSE);
162 const int numInputs = inputTrees.size();
164 setDataVisualization(numInputs);
166 std::vector<MergeTree<dataType>> intermediateMTrees(numInputs);
167 constructTrees<dataType>(
168 inputTrees, intermediateMTrees, treesNodes, treesArcs, treesSegmentation);
172 auto images = preprocessSegmentation(treesSegmentation, DoResampleToImage);
173 fieldL2_ = std::vector<std::vector<double>>(images.size());
174 for(
size_t i = 0; i < images.size(); ++i) {
175 auto array = images[i]->GetPointData()->GetArray(
"Scalars");
176 for(vtkIdType j = 0; j < array->GetNumberOfTuples(); ++j)
177 fieldL2_[i].emplace_back(array->GetTuple1(j));
185 for(
size_t i = 0; i < inputTrees.size(); ++i) {
186 for(
int j = 0; j < 3; ++j) {
187 if(j != 2 or inputTrees[i]->GetNumberOfBlocks() > 2) {
188 auto array = inputTrees[i]->GetBlock(j)->GetFieldData()->GetArray(
189 TimeVariableName.c_str());
202 printMsg(
"Call base", debug::Priority::VERBOSE);
204 std::vector<MergeTree<dataType>> allMT_T;
206 removed = execute<dataType>(intermediateMTrees, emptyTreeDistances, allMT_T);
209 int indexRemoved = 0;
210 for(
size_t i = 0; i < intermediateMTrees.size(); ++i) {
211 if((
int)i != removed[indexRemoved]) {
213 mergeTreeTemplateToDouble<dataType>(intermediateMTrees[i], keyFrame);
214 keyFrames.emplace_back(keyFrame);
224 vtkInformationVector *outputVector,
226 bool const OutputSegmentation = (inputTrees[0]->GetNumberOfBlocks() == 3);
230 auto output_keyFrames = vtkMultiBlockDataSet::GetData(outputVector, 0);
231 auto output_table = vtkTable::GetData(outputVector, 1);
236 std::vector<int> keyFramesIndex;
237 int indexRemoved = 0;
238 for(
size_t i = 0; i < inputTrees.size(); ++i)
239 if((
int)i != removed[indexRemoved]) {
240 keyFramesIndex.emplace_back(i);
244 std::vector<vtkUnstructuredGrid *> treesNodesT;
245 std::vector<vtkUnstructuredGrid *> treesArcsT;
246 std::vector<vtkDataSet *> treesSegmentationT;
247 std::vector<std::vector<int>> treesNodeCorrMeshT;
248 std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> inputTreesT;
249 for(
size_t i = 0; i < keyFramesIndex.size(); ++i) {
250 treesNodesT.emplace_back(treesNodes[keyFramesIndex[i]]);
251 treesArcsT.emplace_back(treesArcs[keyFramesIndex[i]]);
252 treesSegmentationT.emplace_back(treesSegmentation[keyFramesIndex[i]]);
253 treesNodeCorrMeshT.emplace_back(treesNodeCorrMesh[keyFramesIndex[i]]);
254 inputTreesT.emplace_back(inputTrees[keyFramesIndex[i]]);
256 treesNodes.swap(treesNodesT);
257 treesArcs.swap(treesArcsT);
258 treesSegmentation.swap(treesSegmentationT);
259 treesNodeCorrMesh.swap(treesNodeCorrMeshT);
260 inputTrees.swap(inputTreesT);
262 std::vector<MergeTree<dataType>> keyFramesT;
263 mergeTreesDoubleToTemplate<dataType>(keyFrames, keyFramesT);
264 std::vector<FTMTree_MT *> keyFramesTree;
265 mergeTreeToFTMTree<dataType>(keyFramesT, keyFramesTree);
267 output_keyFrames->SetNumberOfBlocks((OutputSegmentation ? 3 : 2));
270 vtkBlockNodes->SetNumberOfBlocks(keyFramesT.size());
271 output_keyFrames->SetBlock(0, vtkBlockNodes);
274 vtkBlockArcs->SetNumberOfBlocks(keyFramesT.size());
275 output_keyFrames->SetBlock(1, vtkBlockArcs);
276 if(OutputSegmentation) {
279 vtkBlockSegs->SetNumberOfBlocks(keyFramesT.size());
280 output_keyFrames->SetBlock(2, vtkBlockSegs);
284 for(
size_t i = 0; i < keyFramesT.size(); ++i) {
299 visuMaker.
copyPointData(treesNodes[i], treesNodeCorrMesh[i]);
310 vtkOutputNode1->GetFieldData()->ShallowCopy(treesNodes[i]->GetFieldData());
311 vtkOutputArc1->GetFieldData()->ShallowCopy(treesArcs[i]->GetFieldData());
312 if(treesSegmentation[i] and OutputSegmentation)
313 vtkOutputSegmentation1->GetFieldData()->ShallowCopy(
314 treesSegmentation[i]->GetFieldData());
317 vtkMultiBlockDataSet::SafeDownCast(output_keyFrames->GetBlock(0))
318 ->SetBlock(i, vtkOutputNode1);
319 vtkMultiBlockDataSet::SafeDownCast(output_keyFrames->GetBlock(1))
320 ->SetBlock(i, vtkOutputArc1);
321 if(OutputSegmentation)
322 vtkMultiBlockDataSet::SafeDownCast(output_keyFrames->GetBlock(2))
323 ->SetBlock(i, vtkOutputSegmentation1);
326 vtkNew<vtkIntArray> vtkAssignmentSolver{};
327 vtkAssignmentSolver->SetName(
"AssignmentSolver");
329 output_keyFrames->GetFieldData()->AddArray(vtkAssignmentSolver);
334 vtkNew<vtkIntArray> treeIds{};
335 treeIds->SetName(
"treeID");
336 treeIds->SetNumberOfTuples(removed.size());
337 vtkNew<vtkDoubleArray> coef{};
338 coef->SetName(
"Alpha");
339 coef->SetNumberOfTuples(removed.size());
340 vtkNew<vtkIntArray> index1Id{};
341 index1Id->SetName(
"Index1");
342 index1Id->SetNumberOfTuples(removed.size());
343 vtkNew<vtkIntArray> index2Id{};
344 index2Id->SetName(
"Index2");
345 index2Id->SetNumberOfTuples(removed.size());
346 vtkNew<vtkIntArray> index1IdR{};
347 index1IdR->SetName(
"Index1_R");
348 index1IdR->SetNumberOfTuples(removed.size());
349 vtkNew<vtkIntArray> index2IdR{};
350 index2IdR->SetName(
"Index2_R");
351 index2IdR->SetNumberOfTuples(removed.size());
353 for(
size_t i = 0; i < removed.size(); ++i) {
354 while(removed[i] > keyFramesIndex[keyFrameCpt])
356 int const index1 = keyFramesIndex[keyFrameCpt - 1];
357 int const index2 = keyFramesIndex[keyFrameCpt];
358 double const alpha =
computeAlpha(index1, removed[i], index2);
359 coef->SetTuple1(i, alpha);
360 index1Id->SetTuple1(i, index1);
361 index2Id->SetTuple1(i, index2);
362 treeIds->SetTuple1(i, removed[i]);
363 index1IdR->SetTuple1(i, keyFrameCpt - 1);
364 index2IdR->SetTuple1(i, keyFrameCpt);
366 output_table->AddColumn(treeIds);
367 output_table->AddColumn(coef);
368 output_table->AddColumn(index1Id);
369 output_table->AddColumn(index2Id);
370 output_table->AddColumn(index1IdR);
371 output_table->AddColumn(index2IdR);
374 treesNodes.swap(treesNodesT);
375 treesArcs.swap(treesArcsT);
376 treesSegmentation.swap(treesSegmentationT);
377 treesNodeCorrMesh.swap(treesNodeCorrMeshT);
378 inputTrees.swap(inputTreesT);