diff --git a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVesselMeanderStrategy.cpp b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVesselMeanderStrategy.cpp index 9295a00387..f39053f1f8 100644 --- a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVesselMeanderStrategy.cpp +++ b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVesselMeanderStrategy.cpp @@ -1,53 +1,53 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPhotoacousticVesselMeanderStrategy.h" mitk::PhotoacousticVesselMeanderStrategy::PhotoacousticVesselMeanderStrategy() { } mitk::PhotoacousticVesselMeanderStrategy::~PhotoacousticVesselMeanderStrategy() { } void mitk::PhotoacousticVesselMeanderStrategy::CalculateNewPositionInStraightLine(mitk::PhotoacousticSmartVector::Pointer position, mitk::PhotoacousticSmartVector::Pointer direction, double /*bendingFactor*/, std::mt19937* rng) { if(direction->GetNorm() <= mitk::eps) { direction->Randomize(rng); } position->SetElement(0,position->GetElement(0) + direction->GetElement(0)); position->SetElement(1,position->GetElement(1) + direction->GetElement(1)); position->SetElement(2,position->GetElement(2) + direction->GetElement(2)); } void mitk::PhotoacousticVesselMeanderStrategy::CalculateRandomlyDivergingPosition(mitk::PhotoacousticSmartVector::Pointer position, mitk::PhotoacousticSmartVector::Pointer direction, double bendingFactor, std::mt19937* rng) { if(direction->GetNorm() <= mitk::eps) { direction->Randomize(rng); } - direction->RandomizeByPercentage(0.4, bendingFactor, rng); + direction->RandomizeByPercentage(RANDOMIZATION_PERCENTAGE, bendingFactor, rng); position->SetElement(0,position->GetElement(0) + direction->GetElement(0)); position->SetElement(1,position->GetElement(1) + direction->GetElement(1)); position->SetElement(2,position->GetElement(2) + direction->GetElement(2)); } diff --git a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVesselMeanderStrategy.h b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVesselMeanderStrategy.h index e78ef6f81c..2cefe90572 100644 --- a/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVesselMeanderStrategy.h +++ b/Modules/PhotoacousticSimulation/src/Algorithms/mitkPhotoacousticVesselMeanderStrategy.h @@ -1,62 +1,64 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKVESSELMEANDERSTRATEGY_H #define MITKVESSELMEANDERSTRATEGY_H #include "mitkVector.h" #include "mitkPhotoacousticSmartVector.h" #include //Includes for smart pointer usage #include "mitkCommon.h" #include "itkLightObject.h" namespace mitk { class MITKPHOTOACOUSTICSIMULATION_EXPORT PhotoacousticVesselMeanderStrategy : public itk::LightObject { public: mitkClassMacroItkParent(mitk::PhotoacousticVesselMeanderStrategy, itk::LightObject) itkFactorylessNewMacro(Self) /** * @brief CalculateNewPositionInStraightLine calculates the new position by just following the direction vector. * @param position * @param direction * @param bendingFactor */ void CalculateNewPositionInStraightLine(mitk::PhotoacousticSmartVector::Pointer position, mitk::PhotoacousticSmartVector::Pointer direction, double bendingFactor, std::mt19937* rng); /** * @brief CalculateRandomlyDivergingPosition calculates the new position by modifying the direction vector randomly, * proportional to the selected bendingFactor. This means, that the vessels will bend in each expansion step, * if bendingFactor > 0. * * @param position * @param direction * @param bendingFactor */ void CalculateRandomlyDivergingPosition(mitk::PhotoacousticSmartVector::Pointer position, mitk::PhotoacousticSmartVector::Pointer direction, double bendingFactor, std::mt19937* rng); protected: PhotoacousticVesselMeanderStrategy(); virtual ~PhotoacousticVesselMeanderStrategy(); + + const double RANDOMIZATION_PERCENTAGE = 0.4; }; } #endif // MITKVESSELMEANDERSTRATEGY_H diff --git a/Modules/PhotoacousticSimulation/src/ProbeDesign/mitkPhotoacousticLightSource.cpp b/Modules/PhotoacousticSimulation/src/ProbeDesign/mitkPhotoacousticLightSource.cpp index 13a32e32fb..70f140f805 100644 --- a/Modules/PhotoacousticSimulation/src/ProbeDesign/mitkPhotoacousticLightSource.cpp +++ b/Modules/PhotoacousticSimulation/src/ProbeDesign/mitkPhotoacousticLightSource.cpp @@ -1,416 +1,416 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkPhotoacousticLightSource.h" #include "math.h" mitk::PhotoacousticLightSource::PhotoacousticLightSource() : m_IsValid(false) { } mitk::PhotoacousticLightSource::PhotoacousticLightSource(TiXmlElement* element, bool verbose): m_IsValid(true), m_Verbose(verbose) { ParseEnergy(element); ParsePhotonSpawnArea(element); ParsePhotonDirection(element); if(m_IsValid) { if(m_Verbose) std::cout << "Successfully created LightSource" << std::endl; } else { if(m_Verbose) std::cout << "Failed creating LightSource." << std::endl; } } mitk::PhotoacousticLightSource::~PhotoacousticLightSource() { } mitk::PhotoacousticLightSource::TransformResult mitk::PhotoacousticLightSource::BoxMuellerTransform(double u1, double u2, double mu, double sigma) { TransformResult result; result.z0 = sqrt(-2.0 * log(u1)) * cos(TWO_PI * u2) * sigma + mu; result.z1 = sqrt(-2.0 * log(u1)) * sin(TWO_PI * u2) * sigma + mu; return result; } void mitk::PhotoacousticLightSource::ParsePhotonDirection(TiXmlElement* element) { - TiXmlElement* direction = element->FirstChildElement("PhotonDirection"); + TiXmlElement* direction = element->FirstChildElement(XML_TAG_PHOTON_DIRECTION); if(direction) { - ParseAngle(direction, "xAngle"); + ParseAngle(direction, XML_TAG_X_ANGLE); } else { if(m_Verbose) - std::cerr << "No \"xAngle\" field in xml. Setting to default (0, 0, UNIFORM)." << std::endl; + std::cerr << "No \"" << XML_TAG_X_ANGLE << "\" field in xml. Setting to default (0, 0, UNIFORM)." << std::endl; m_AngleXMinimum = 0; m_AngleXMaximum = 0; m_AngleXMode = DistributionMode::UNIFORM; } - direction = element->FirstChildElement("PhotonDirection"); + direction = element->FirstChildElement(XML_TAG_PHOTON_DIRECTION); if(direction) { - ParseAngle(direction, "yAngle"); + ParseAngle(direction, XML_TAG_Y_ANGLE); } else { if(m_Verbose) - std::cerr << "No \"yAngle\" field in xml. Setting to default (0, 0, UNIFORM)." << std::endl; + std::cerr << "No \"" << XML_TAG_Y_ANGLE << "\" field in xml. Setting to default (0, 0, UNIFORM)." << std::endl; m_AngleYMinimum = 0; m_AngleYMaximum = 0; m_AngleYMode = DistributionMode::UNIFORM; } } void mitk::PhotoacousticLightSource::ParseAngle(TiXmlElement* direction, std::string angle) { double minimum; double maximum; DistributionMode mode; if(m_Verbose) std::cout << "Parsing " << angle << std::endl; TiXmlElement* angleElement = direction->FirstChildElement(angle); if(angleElement) { - TiXmlElement* angleMin = angleElement->FirstChildElement("min"); + TiXmlElement* angleMin = angleElement->FirstChildElement(XML_TAG_MINIMUM); if(angleMin) { std::string angleMinText = angleMin->GetText(); minimum = std::stod(angleMinText); if(m_Verbose) std::cout << "Setting min=" << minimum << std::endl; } else { if(m_Verbose) - std::cerr << "No \"min\" tag in xml. Setting min=0" << std::endl; + std::cerr << "No \""<< XML_TAG_MINIMUM <<"\" tag in xml. Setting min=0" << std::endl; minimum = 0; } - TiXmlElement* angleMax = angleElement->FirstChildElement("max"); + TiXmlElement* angleMax = angleElement->FirstChildElement(XML_TAG_MAXIMUM); if(angleMax) { std::string angleMaxText = angleMax->GetText(); maximum = std::stod(angleMaxText); if(m_Verbose) std::cout << "Setting max=" << maximum << std::endl; } else { if(m_Verbose) - std::cerr << "No \"max\" tag in xml. Setting max=0" << std::endl; + std::cerr << "No \"" << XML_TAG_MAXIMUM << "\" tag in xml. Setting max=0" << std::endl; maximum = 0; } - TiXmlElement* angleMode = angleElement->FirstChildElement("mode"); + TiXmlElement* angleMode = angleElement->FirstChildElement(XML_TAG_MODE); if(angleMode) { std::string angleModeText = angleMode->GetText(); if(strcmp("UNIFORM", angleModeText.c_str()) == 0) { mode = DistributionMode::UNIFORM; if(m_Verbose) std::cout << "Setting mode=UNIFORM" << std::endl; } else if (strcmp("GAUSSIAN", angleModeText.c_str()) == 0) { mode = DistributionMode::GAUSSIAN; if(m_Verbose) std::cout << "Setting mode=GAUSSIAN" << std::endl; } } else { if(m_Verbose) - std::cerr << "No \"mode\" tag in xml. Setting mode=UNIFORM" << std::endl; + std::cerr << "No \"" << XML_TAG_MODE << "\" tag in xml. Setting mode=UNIFORM" << std::endl; mode = DistributionMode::UNIFORM; } } else { if(m_Verbose) - std::cerr << "No \"angleX\" field in xml. Setting to default (0, 0, UNIFORM)." << std::endl; + std::cerr << "No \"" << angle << "\" field in xml. Setting to default (0, 0, UNIFORM)." << std::endl; maximum = 0; minimum = 0; mode = DistributionMode::UNIFORM; } - if(strcmp("xAngle", angle.c_str()) == 0) + if(strcmp(XML_TAG_X_ANGLE.c_str(), angle.c_str()) == 0) { m_AngleXMinimum = minimum; m_AngleXMaximum = maximum; m_AngleXMode = mode; } - else if(strcmp("yAngle", angle.c_str()) == 0) + else if(strcmp(XML_TAG_Y_ANGLE.c_str(), angle.c_str()) == 0) { m_AngleYMinimum = minimum; m_AngleYMaximum = maximum; m_AngleYMode = mode; } } void mitk::PhotoacousticLightSource::ParseEnergy(TiXmlElement* element) { - TiXmlElement* energy = element->FirstChildElement("Energy"); + TiXmlElement* energy = element->FirstChildElement(XML_TAG_ENERGY); if(energy) { std::string energyText = energy->GetText(); m_Energy = std::stod(energyText); if(m_Verbose) std::cout << "Setting energy=" << m_Energy; } else { if(m_Verbose) - std::cerr << "No \"Energy\" field in xml. Setting Energy=1" << std::endl; + std::cerr << "No \"" << XML_TAG_ENERGY << "\" field in xml. Setting Energy=1" << std::endl; m_Energy = 1.0; } } void mitk::PhotoacousticLightSource::ParsePhotonSpawnArea(TiXmlElement* element) { TiXmlElement* spawnArea = element->FirstChildElement("PhotonSpawnArea"); if(spawnArea) { - TiXmlElement* spawnType = spawnArea->FirstChildElement("SpawnType"); + TiXmlElement* spawnType = spawnArea->FirstChildElement(XML_TAG_SPAWN_TYPE); if(spawnType) { std::string spawnTypeText = spawnType->GetText(); - if(strcmp("POINT", spawnTypeText.c_str())==0) + if(strcmp(XML_TAG_SPAWN_TYPE_POINT.c_str(), spawnTypeText.c_str())==0) { m_SpawnType = SpawnType::POINT; if(m_Verbose) - std::cout << "Setting SpawnType=POINT" << std::endl; + std::cout << "Setting " << XML_TAG_SPAWN_TYPE << " = " << XML_TAG_SPAWN_TYPE_POINT << std::endl; } - else if (strcmp("RECTANGLE", spawnTypeText.c_str())==0) + else if (strcmp(XML_TAG_SPAWN_TYPE_RECTANGLE.c_str(), spawnTypeText.c_str())==0) { m_SpawnType = SpawnType::RECTANGLE; if(m_Verbose) - std::cout << "Setting SpawnType=RECTANGLE" << std::endl; + std::cout << "Setting " << XML_TAG_SPAWN_TYPE << " = " << XML_TAG_SPAWN_TYPE_RECTANGLE << std::endl; } - else if (strcmp("CIRCLE", spawnTypeText.c_str())==0) + else if (strcmp(XML_TAG_SPAWN_TYPE_CIRCLE.c_str(), spawnTypeText.c_str())==0) { m_SpawnType = SpawnType::CIRCLE; if(m_Verbose) - std::cout << "Setting SpawnType=CIRCLE" << std::endl; + std::cout << "Setting " << XML_TAG_SPAWN_TYPE << " = " << XML_TAG_SPAWN_TYPE_CIRCLE << std::endl; } else { std::cerr << "The provided SpawnType (" << spawnTypeText << ") did not match any available spawn type. Light source is not valid." << std::endl; m_IsValid = false; } } else { - std::cerr << "The \"SpawnType\" element was not provided for this light source. Light source is not valid." << std::endl; + std::cerr << "The \"" << XML_TAG_SPAWN_TYPE << "\" element was not provided for this light source. Light source is not valid." << std::endl; m_IsValid = false; } - TiXmlElement* xLocation = spawnArea->FirstChildElement("x"); + TiXmlElement* xLocation = spawnArea->FirstChildElement(XML_TAG_X); if(xLocation) { std::string xLocationText = xLocation->GetText(); m_SpawnLocationX = std::stod(xLocationText); if(m_Verbose) - std::cout << "Setting x=" << m_SpawnLocationX; + std::cout << "Setting "<< XML_TAG_X << "=" << m_SpawnLocationX; } else { if(m_Verbose) - std::cerr << "No \"x\" field in xml. Setting x=0" << std::endl; + std::cerr << "No \"" << XML_TAG_X << "\" field in xml. Setting " << XML_TAG_X << "=0" << std::endl; m_SpawnLocationX = 0; } - TiXmlElement* yLocation = spawnArea->FirstChildElement("y"); + TiXmlElement* yLocation = spawnArea->FirstChildElement(XML_TAG_Y); if(yLocation) { std::string yLocationText = yLocation->GetText(); m_SpawnLocationY = std::stod(yLocationText); if(m_Verbose) - std::cout << "Setting y=" << m_SpawnLocationY; + std::cout << "Setting " << XML_TAG_Y << "=" << m_SpawnLocationY; } else { if(m_Verbose) - std::cerr << "No \"y\" field in xml. Setting y=0" << std::endl; + std::cerr << "No \"" << XML_TAG_Y << "\" field in xml. Setting " << XML_TAG_Y << "=0" << std::endl; m_SpawnLocationY = 0; } - TiXmlElement* zLocation = spawnArea->FirstChildElement("z"); + TiXmlElement* zLocation = spawnArea->FirstChildElement(XML_TAG_Z); if(zLocation) { std::string zLocationText = zLocation->GetText(); m_SpawnLocationZ = std::stod(zLocationText); if(m_Verbose) - std::cout << "Setting z=" << m_SpawnLocationZ; + std::cout << "Setting " << XML_TAG_Z << "=" << m_SpawnLocationZ; } else { if(m_Verbose) - std::cerr << "No \"z\" field in xml. Setting z=0.1" << std::endl; + std::cerr << "No \"" << XML_TAG_Z << "\" field in xml. Setting " << XML_TAG_Z << "=0.1" << std::endl; m_SpawnLocationZ = 0.1; } - TiXmlElement* rLocation = spawnArea->FirstChildElement("r"); + TiXmlElement* rLocation = spawnArea->FirstChildElement(XML_TAG_R); if(rLocation) { std::string rLocationText = rLocation->GetText(); m_SpawnLocationRadius = std::stod(rLocationText); if(m_Verbose) - std::cout << "Setting r=" << m_SpawnLocationRadius; + std::cout << "Setting " << XML_TAG_R << "=" << m_SpawnLocationRadius; } else { if(m_Verbose) - std::cerr << "No \"radius\" field in xml. Setting radius=0" << std::endl; + std::cerr << "No \"" << XML_TAG_R << "\" field in xml. Setting " << XML_TAG_R << "=0" << std::endl; m_SpawnLocationRadius = 0; } - TiXmlElement* xLength = spawnArea->FirstChildElement("xLength"); + TiXmlElement* xLength = spawnArea->FirstChildElement(XML_TAG_X_LENGTH); if(xLength) { std::string xLengthText = xLength->GetText(); m_SpawnLocationXLength = std::stod(xLengthText); if(m_Verbose) - std::cout << "Setting xLength=" << m_SpawnLocationXLength << std::endl; + std::cout << "Setting " << XML_TAG_X_LENGTH << "=" << m_SpawnLocationXLength << std::endl; } else { if(m_Verbose) - std::cerr << "No \"xLength\" field in xml. Setting xLength=0" << std::endl; + std::cerr << "No \"" << XML_TAG_X_LENGTH << "\" field in xml. Setting " << XML_TAG_X_LENGTH << "=0" << std::endl; m_SpawnLocationXLength = 0; } - TiXmlElement* yLength = spawnArea->FirstChildElement("yLength"); + TiXmlElement* yLength = spawnArea->FirstChildElement(XML_TAG_Y_LENGTH); if(yLength) { std::string yLengthText = yLength->GetText(); m_SpawnLocationYLength = std::stod(yLengthText); if(m_Verbose) - std::cout << "Setting yLength=" << m_SpawnLocationYLength << std::endl; + std::cout << "Setting " << XML_TAG_Y_LENGTH << "=" << m_SpawnLocationYLength << std::endl; } else { if(m_Verbose) - std::cerr << "No \"yLength\" field in xml. Setting ylength=0" << std::endl; + std::cerr << "No \"" << XML_TAG_Y_LENGTH << "\" field in xml. Setting " << XML_TAG_Y_LENGTH << "=0" << std::endl; m_SpawnLocationYLength = 0; } - TiXmlElement* zLength = spawnArea->FirstChildElement("zLength"); + TiXmlElement* zLength = spawnArea->FirstChildElement(XML_TAG_Z_LENGTH); if(zLength) { std::string zLengthText = zLength->GetText(); m_SpawnLocationZLength = std::stod(zLengthText); if(m_Verbose) - std::cout << "Setting zlength=" << m_SpawnLocationZLength << std::endl; + std::cout << "Setting " << XML_TAG_Z_LENGTH << "=" << m_SpawnLocationZLength << std::endl; } else { if(m_Verbose) - std::cerr << "No \"zLength\" field in xml. Setting zlength=0" << std::endl; + std::cerr << "No \"" << XML_TAG_Z_LENGTH << "\" field in xml. Setting " << XML_TAG_Z_LENGTH << "=0" << std::endl; m_SpawnLocationZLength = 0; } } else m_IsValid = false; } mitk::PhotoacousticLightSource::PhotonInformation mitk::PhotoacousticLightSource::GetNextPhoton(double rnd1, double rnd2, double rnd3, double rnd4, double rnd5, double gau1, double gau2) { PhotonInformation returnValue; switch(m_SpawnType) { case POINT: returnValue.xPosition = m_SpawnLocationX; returnValue.yPosition = m_SpawnLocationY; returnValue.zPosition = m_SpawnLocationZ; break; case RECTANGLE: returnValue.xPosition = m_SpawnLocationX + rnd3 * m_SpawnLocationXLength; returnValue.yPosition = m_SpawnLocationY + rnd4 * m_SpawnLocationYLength; returnValue.zPosition = m_SpawnLocationZ + rnd5 * m_SpawnLocationZLength; break; case CIRCLE: double radius = rnd3 * m_SpawnLocationRadius; double angle = rnd4 * TWO_PI; returnValue.xPosition = m_SpawnLocationX + radius * cos(angle); returnValue.yPosition = m_SpawnLocationY + radius * sin(angle); returnValue.zPosition = m_SpawnLocationZ; break; } switch(m_AngleXMode) { case UNIFORM: returnValue.xAngle = rnd1 * (m_AngleXMaximum - m_AngleXMinimum) + m_AngleXMinimum; break; case GAUSSIAN: TransformResult trans = BoxMuellerTransform(gau1, gau2, (m_AngleXMaximum - m_AngleXMinimum)/2 + m_AngleXMinimum, (m_AngleXMaximum - m_AngleXMinimum)/2.355); returnValue.xAngle = trans.z0; break; } switch(m_AngleYMode) { case UNIFORM: returnValue.yAngle = rnd2 * (m_AngleYMaximum - m_AngleYMinimum) + m_AngleYMinimum; break; case GAUSSIAN: TransformResult trans = BoxMuellerTransform(gau1, gau2, (m_AngleYMaximum - m_AngleYMinimum)/2 + m_AngleYMinimum, (m_AngleYMaximum - m_AngleYMinimum)/2.355 ); returnValue.yAngle = trans.z1; break; } if((returnValue.xAngle*returnValue.xAngle+returnValue.yAngle*returnValue.yAngle) > 1) { double unify = sqrt(returnValue.xAngle*returnValue.xAngle+returnValue.yAngle*returnValue.yAngle)*1.001; returnValue.xAngle = returnValue.xAngle / unify; returnValue.yAngle = returnValue.yAngle / unify; } returnValue.zAngle = sqrt(1 - returnValue.xAngle*returnValue.xAngle - returnValue.yAngle*returnValue.yAngle); if(m_Verbose) std::cout << "Created a new photon at (" << returnValue.xPosition << "|" << returnValue.yPosition << "|" << returnValue.zPosition << ") with angle (" << returnValue.xAngle << "|" << returnValue.yAngle << "|" << returnValue.zAngle << ")" << std::endl; return returnValue; } bool mitk::PhotoacousticLightSource::IsValid() { return m_IsValid; } diff --git a/Modules/PhotoacousticSimulation/src/ProbeDesign/mitkPhotoacousticLightSource.h b/Modules/PhotoacousticSimulation/src/ProbeDesign/mitkPhotoacousticLightSource.h index 2ba2c2e6f2..09eba012fc 100644 --- a/Modules/PhotoacousticSimulation/src/ProbeDesign/mitkPhotoacousticLightSource.h +++ b/Modules/PhotoacousticSimulation/src/ProbeDesign/mitkPhotoacousticLightSource.h @@ -1,166 +1,185 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKPHOTOACOUSTICLIGHTSOURCE_H #define MITKPHOTOACOUSTICLIGHTSOURCE_H #include #include "MitkPhotoacousticSimulationExports.h" //Includes for smart pointer usage #include "mitkCommon.h" #include "itkObject.h" #include "itkMacro.h" #include namespace mitk { /** * @brief The PhotoacousticProbe class * The representation of a PhotoacousticProbe */ class MITKPHOTOACOUSTICSIMULATION_EXPORT PhotoacousticLightSource : public itk::Object { public: mitkClassMacroItkParent(mitk::PhotoacousticLightSource, itk::Object) itkFactorylessNewMacro(Self) mitkNewMacro2Param(Self, TiXmlElement*, bool) + const std::string XML_TAG_X_ANGLE = "xAngle"; + const std::string XML_TAG_Y_ANGLE = "yAngle"; + const std::string XML_TAG_PHOTON_DIRECTION = "PhotonDirection"; + const std::string XML_TAG_MINIMUM = "min"; + const std::string XML_TAG_MAXIMUM = "max"; + const std::string XML_TAG_MODE = "mode"; + const std::string XML_TAG_ENERGY = "energy"; + const std::string XML_TAG_SPAWN_TYPE = "SpawnType"; + const std::string XML_TAG_SPAWN_TYPE_POINT = "POINT"; + const std::string XML_TAG_SPAWN_TYPE_RECTANGLE = "RECTANGLE"; + const std::string XML_TAG_SPAWN_TYPE_CIRCLE = "CIRCLE"; + const std::string XML_TAG_X = "x"; + const std::string XML_TAG_Y = "y"; + const std::string XML_TAG_Z = "z"; + const std::string XML_TAG_R = "r"; + const std::string XML_TAG_X_LENGTH = "xLength"; + const std::string XML_TAG_Y_LENGTH = "yLength"; + const std::string XML_TAG_Z_LENGTH = "zLength"; + enum SpawnType { POINT, RECTANGLE, CIRCLE }; enum DistributionMode { UNIFORM, GAUSSIAN }; struct PhotonInformation { double xPosition; double yPosition; double zPosition; double xAngle; double yAngle; double zAngle; }; PhotonInformation GetNextPhoton(double rnd1, double rnd2, double rnd3, double rnd4, double rnd5, double gau1, double gau2); bool IsValid(); PhotoacousticLightSource(TiXmlElement* element, bool verbose); PhotoacousticLightSource(); virtual ~PhotoacousticLightSource(); void ParseAngle(TiXmlElement* direction, std::string angle); itkGetMacro(SpawnType, SpawnType) itkSetMacro(SpawnType, SpawnType) itkGetMacro(SpawnLocationX, double) itkSetMacro(SpawnLocationX, double) itkGetMacro(SpawnLocationY, double) itkSetMacro(SpawnLocationY, double) itkGetMacro(SpawnLocationZ, double) itkSetMacro(SpawnLocationZ, double) itkGetMacro(SpawnLocationXLength, double) itkSetMacro(SpawnLocationXLength, double) itkGetMacro(SpawnLocationYLength, double) itkSetMacro(SpawnLocationYLength, double) itkGetMacro(SpawnLocationZLength, double) itkSetMacro(SpawnLocationZLength, double) itkGetMacro(SpawnLocationRadius, double) itkSetMacro(SpawnLocationRadius, double) itkGetMacro(Energy, double) itkSetMacro(Energy, double) itkGetMacro(AngleXMinimum, double) itkSetMacro(AngleXMinimum, double) itkGetMacro(AngleXMaximum, double) itkSetMacro(AngleXMaximum, double) itkGetMacro(AngleYMinimum, double) itkSetMacro(AngleYMinimum, double) itkGetMacro(AngleYMaximum, double) itkSetMacro(AngleYMaximum, double) itkGetMacro(AngleXMode, DistributionMode) itkSetMacro(AngleXMode, DistributionMode) itkGetMacro(AngleYMode, DistributionMode) itkSetMacro(AngleYMode, DistributionMode) itkGetMacro(Verbose, bool) itkSetMacro(Verbose, bool) protected: const double TWO_PI = 2.0*3.14159265358979323846; SpawnType m_SpawnType; double m_SpawnLocationX; double m_SpawnLocationY; double m_SpawnLocationZ; double m_SpawnLocationXLength; double m_SpawnLocationYLength; double m_SpawnLocationZLength; double m_SpawnLocationRadius; double m_Energy; double m_AngleXMinimum; double m_AngleXMaximum; double m_AngleYMinimum; double m_AngleYMaximum; DistributionMode m_AngleXMode; DistributionMode m_AngleYMode; bool m_IsValid; bool m_Verbose; struct TransformResult { double z0; double z1; }; void ParsePhotonDirection(TiXmlElement* element); void ParseEnergy(TiXmlElement* element); void ParsePhotonSpawnArea(TiXmlElement* element); TransformResult BoxMuellerTransform(double u1, double u2, double mu, double sigma); }; } #endif // MITKPHOTOACOUSTICLIGHTSOURCE_H