Commit 112f33d6 authored by Daniel Filbert's avatar Daniel Filbert

Added propagation anchor class: detection point. But still inculding bugs...

parent a64c1eaa
......@@ -94,6 +94,7 @@ namespace ITAGeo
DIFFRACTION_OUTER_APEX, //!< Diffraction occurrance point (at a boundary outer edge, e.g. house corner)
DIFFRACTION_INNER_APEX, //!< Diffraction occurrance point (at a boundary outer edge, e.g. room corner)
MIRROR_IMAGE, //!< (Virtual) Mirror image in medium
DETECTION_POINT, //!< Point of detection within detection volume (e.g. sphere) of receiver used in ray tracing
LAST_ELEMENT //!< Last element of EAnchorType to iterate over EAnchorType
} iAnchorType; //! Type of anchor
......@@ -329,6 +330,33 @@ namespace ITAGeo
std::shared_ptr< Material::IMaterial > pMaterial; //!< Acoustic material connection, i.e. absorption coefficient
};
//! Geometrical propagation anchor of the detection point inside the receiver's detection volume
/**
* A detection point
*/
class ITA_GEO_API CDetectionPoint : public CPropagationAnchor // public CPropagationAnchor
{
public:
inline CDetectionPoint()
{
iAnchorType = CPropagationAnchor::DETECTION_POINT;
};
inline CDetectionPoint(const VistaVector3D& v3DetectionPoint)
: CPropagationAnchor(v3DetectionPoint)
{
iAnchorType = CPropagationAnchor::DETECTION_POINT;
};
inline virtual ~CDetectionPoint() {};
//! Returns a string with the properties of the object
std::string ToString() const;
std::stringstream ToJSON(std::shared_ptr< const CResourceManager > pResourceManager = nullptr) const;
//! Load properties from JSON formatted string
void LoadFromJSONString(const std::string& sContent, std::shared_ptr< CResourceManager > pResourceManager = nullptr);
};
//! Propagation path list class
/**
* Container to hold a list of propagation anchors, that form a propagation path.
......
......@@ -540,6 +540,59 @@ std::stringstream ITAGeo::CSpecularReflection::ToJSON( std::shared_ptr< const CR
#endif
}
//---CDetectionPoint----------------------------------------------------------------------------------------------------------------------
void ITAGeo::CDetectionPoint::LoadFromJSONString(const std::string& sContent, std::shared_ptr< CResourceManager > pResourceManager)
{
#ifdef WITH_JSON_SUPPORT
JSONNode jnRoot = libjson::parse(sContent);
//Check for correct class of the content
if (jnRoot.at("class").as_string() != GetTypeStr())
{
ITA_EXCEPT_INVALID_PARAMETER("The json string doesn't contain properties of type ITAGeo::CSpecularReflection. It contains the properties of " + jnRoot.at("class").as_string() + ".");
}
//--Get the properties-------------------------
CPropagationAnchor::LoadFromJSONString(sContent, pResourceManager);
#endif
}
std::string ITAGeo::CDetectionPoint::ToString() const
{
std::stringstream ss;
ss << "[ " << std::setw(10) << GetAnchorTypeStr(iAnchorType) << " ] "
<< ", Interaction point : " << v3InteractionPoint;
return ss.str();
}
std::stringstream ITAGeo::CDetectionPoint::ToJSON(std::shared_ptr< const CResourceManager > pResourceManager) const
{
#ifdef WITH_JSON_SUPPORT
//Get the properties of the parent class
std::string sRoot = ITAGeo::CPropagationAnchor::ToJSON(pResourceManager).str();
JSONNode jnRoot = libjson::parse(sRoot);
//Set class node. First, search the node. If the node does not exist, push back new node.
if (sRoot.find("\"class\"") == std::string::npos)
{
JSONNode jnClassType("class", GetTypeStr());
jnRoot.push_back(jnClassType);
}
//Convert to stringstream and return value
std::stringstream ss;
ss << jnRoot.write_formatted();
return ss;
#else
ITA_EXCEPT_NOT_IMPLEMENTED;
#endif
}
//---CITADiffractionWedgeAperture---------------------------------------------------------------------------------------------------------
ITAGeo::CITADiffractionWedgeApertureBase::CITADiffractionWedgeApertureBase()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment