CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxReconstructThreads.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #include "cxReconstructThreads.h"
13 
14 #include "cxImage.h"
16 #include "cxReconstructCore.h"
17 #include "cxPatientModelService.h"
18 #include "cxViewService.h"
19 
20 //Windows fix
21 #ifndef M_PI
22 #define M_PI 3.14159265358979323846
23 #endif
24 
25 namespace cx
26 {
27 
28 
30  cx::ThreadedTimedAlgorithm<void> ("US PreReconstruction", 30),
31  mPatientModelService(patientModelService)
32 {
33  mInput = input;
34  mUseDefaultMessages = false;
35  mCores = cores;
36 }
37 
39 {
40 }
41 
42 void ThreadedTimedReconstructPreprocessor::preProcessingSlot()
43 {
44 }
45 
46 void ThreadedTimedReconstructPreprocessor::calculate()
47 {
48  std::vector<bool> angio;
49  for (unsigned i=0; i<mCores.size(); ++i)
50  angio.push_back(mCores[i]->getInputParams().mAngio);
51 
52  std::vector<cx::ProcessedUSInputDataPtr> processedInput = mInput->createProcessedInput(angio);
53 
54  for (unsigned i=0; i<mCores.size(); ++i)
55  {
56  mCores[i]->initialize(processedInput[i], mInput->getOutputVolumeParams());
57  }
58 }
59 
60 void ThreadedTimedReconstructPreprocessor::postProcessingSlot()
61 {
62 }
63 
64 //---------------------------------------------------------
65 //---------------------------------------------------------
66 //---------------------------------------------------------
67 
68 
70  cx::ThreadedTimedAlgorithm<void> ("US Reconstruction", 30),
71  mPatientModelService(patientModelService),
72  mViewService(viewService)
73 {
74  mUseDefaultMessages = false;
75  mReconstructer = reconstructer;
76 }
77 
79 {
80 }
81 
82 void ThreadedTimedReconstructCore::preProcessingSlot()
83 {
84  mReconstructer->threadedPreReconstruct();
85 }
86 
87 void ThreadedTimedReconstructCore::calculate()
88 {
89  mReconstructer->threadedReconstruct();
90 }
91 
92 void ThreadedTimedReconstructCore::postProcessingSlot()
93 {
94  mReconstructer->threadedPostReconstruct();
95 
96  mPatientModelService->autoSave();
97  mViewService->autoShowData(mReconstructer->getOutput());
98 }
99 
100 }
101 
ThreadedTimedReconstructCore(PatientModelServicePtr patientModelService, ViewServicePtr viewService, ReconstructCorePtr reconstructer)
Base class for algorithms that wants to thread and time their execution. T is the return type of the ...
boost::shared_ptr< class ViewService > ViewServicePtr
ThreadedTimedReconstructPreprocessor(PatientModelServicePtr patientModelService, ReconstructPreprocessorPtr input, std::vector< ReconstructCorePtr > cores)
boost::shared_ptr< class ReconstructPreprocessor > ReconstructPreprocessorPtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class ReconstructCore > ReconstructCorePtr
Namespace for all CustusX production code.