Exemple #1
0
ReconstructionAlgorithm* Framework::instantiateReconstructionAlgorithm()
{
    getParameterSet()->get<OutputParameterSet>()->testValidityOfOutputOptions(getVolumeSerializer());

    auto algorithm = getParameterSet()->get<AlgorithmParameterSet>()->getAlgorithm();
    std::transform(algorithm.begin(), algorithm.end(), algorithm.begin(), tolower);

    ReconstructionAlgorithm* reconstructionAlgorithm = nullptr;
    if(algorithm == "sart" || algorithm == "sirt" || algorithm == "blockiterative")
    {
        reconstructionAlgorithm = new BlockIterativeReconstructionOperator(this);
    } else {
        reconstructionAlgorithm = pluginManager->instantiateReconstructionAlgorithm(algorithm, this);
    }

    auto isDiscrete = getParameterSet()->get<AlgorithmParameterSet>()->isReconstructionDiscrete();
    if( isDiscrete )
    {
        ReconstructionAlgorithmUsingMask *maskedReconstructionAlgorithm = dynamic_cast<ReconstructionAlgorithmUsingMask *>(reconstructionAlgorithm);
        if( !maskedReconstructionAlgorithm )
        {
            throw Exception((boost::format("Discrete reconstruction cannot be done using %1% algorithm, because it does NOT support prior knowledge mask.") % algorithm).str());
        }
        auto discreteReconstructionAlgorithm = new DiscreteReconstructionAlgorithm(this, maskedReconstructionAlgorithm);
        discreteReconstructionAlgorithm->takeOwnershipOfMethod();
        reconstructionAlgorithm = discreteReconstructionAlgorithm;
    }

    auto meshExportPath = getParameterSet()->get<DebugParameterSet>()->getMeshExportPath();
    if(meshExportPath)
    {
        Visualizer* visualizer = new Visualizer(meshExportPath->string(), "ettention");
        reconstructionAlgorithm->exportGeometryTo(visualizer);
        visualizer->writeMesh();
        delete visualizer;
    }

    return reconstructionAlgorithm;
}