From d1ac3b9ff10b1fbdf3428e48cb11c803c0f03ceb Mon Sep 17 00:00:00 2001 From: Sven Erdem Date: Mon, 7 Oct 2024 18:34:02 +0200 Subject: [PATCH] add enum EventType --- .../src/Beamline/Objects/CircleSource.cpp | 2 +- .../src/Beamline/Objects/DipoleSource.cpp | 2 +- .../src/Beamline/Objects/MatrixSource.cpp | 2 +- .../src/Beamline/Objects/PixelSource.cpp | 2 +- .../src/Beamline/Objects/PointSource.cpp | 2 +- .../Objects/SimpleUndulatorSource.cpp | 2 +- Intern/rayx-core/src/Debug/Debug.h | 3 +- Intern/rayx-core/src/Shader/Behave.cpp | 2 +- Intern/rayx-core/src/Shader/Behave.h | 2 +- .../rayx-core/src/Shader/DynamicElements.cpp | 2 +- Intern/rayx-core/src/Shader/EventType.h | 64 +++++++++---------- Intern/rayx-core/src/Shader/Helper.cpp | 14 ++-- Intern/rayx-core/src/Shader/Helper.h | 4 +- Intern/rayx-core/src/Shader/Ray.h | 4 +- Intern/rayx-core/src/Shader/Refrac.cpp | 4 +- Intern/rayx-core/src/Shader/Refrac.h | 2 +- Intern/rayx-core/src/Shader/Throw.h | 2 +- Intern/rayx-core/src/Writer/CSVWriter.cpp | 23 ++++--- Intern/rayx-core/src/Writer/H5Writer.cpp | 34 ++++++---- Intern/rayx-core/src/Writer/Writer.h | 2 +- Intern/rayx-core/tests/setupTests.cpp | 10 +-- Intern/rayx-core/tests/setupTests.h | 2 +- Intern/rayx-ui/src/RayProcessing.cpp | 6 +- Intern/rayx-ui/src/Simulator.cpp | 2 +- .../src/Triangulation/TraceTriangulation.cpp | 2 +- Intern/rayx/src/TerminalApp.cpp | 2 +- docs/src/Tools/How-to-use-Doxygen.md | 4 +- 27 files changed, 108 insertions(+), 94 deletions(-) diff --git a/Intern/rayx-core/src/Beamline/Objects/CircleSource.cpp b/Intern/rayx-core/src/Beamline/Objects/CircleSource.cpp index 9431ab8b5..42aaad9bb 100644 --- a/Intern/rayx-core/src/Beamline/Objects/CircleSource.cpp +++ b/Intern/rayx-core/src/Beamline/Objects/CircleSource.cpp @@ -59,7 +59,7 @@ std::vector CircleSource::getRays([[maybe_unused]] int thread_count) const const auto field = stokesToElectricField(m_stokes, direction); - Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0}; + Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0}; rayList.push_back(r); } diff --git a/Intern/rayx-core/src/Beamline/Objects/DipoleSource.cpp b/Intern/rayx-core/src/Beamline/Objects/DipoleSource.cpp index 3265c8a7f..37ff1e41c 100644 --- a/Intern/rayx-core/src/Beamline/Objects/DipoleSource.cpp +++ b/Intern/rayx-core/src/Beamline/Objects/DipoleSource.cpp @@ -133,7 +133,7 @@ std::vector DipoleSource::getRays(int thread_count) const { const auto field = stokesToElectricField(psiandstokes.stokes, direction); - Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0}; + Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0}; #if defined(DIPOLE_OMP) #pragma omp critical // thread-safety for writing rayList { rayList.push_back(r); } diff --git a/Intern/rayx-core/src/Beamline/Objects/MatrixSource.cpp b/Intern/rayx-core/src/Beamline/Objects/MatrixSource.cpp index 226575b2f..aeef73b04 100644 --- a/Intern/rayx-core/src/Beamline/Objects/MatrixSource.cpp +++ b/Intern/rayx-core/src/Beamline/Objects/MatrixSource.cpp @@ -61,7 +61,7 @@ std::vector MatrixSource::getRays([[maybe_unused]] int thread_count) const const auto field = stokesToElectricField(m_pol, direction); - Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0}; + Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0}; returnList.push_back(r); } diff --git a/Intern/rayx-core/src/Beamline/Objects/PixelSource.cpp b/Intern/rayx-core/src/Beamline/Objects/PixelSource.cpp index cbf394bd4..c581973de 100644 --- a/Intern/rayx-core/src/Beamline/Objects/PixelSource.cpp +++ b/Intern/rayx-core/src/Beamline/Objects/PixelSource.cpp @@ -76,7 +76,7 @@ std::vector PixelSource::getRays([[maybe_unused]] int thread_count) const { const auto rotation = glm::dmat3(m_orientation); const auto field = stokesToElectricField(m_pol, rotation); - Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0}; + Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0}; rayList.push_back(r); } diff --git a/Intern/rayx-core/src/Beamline/Objects/PointSource.cpp b/Intern/rayx-core/src/Beamline/Objects/PointSource.cpp index 1a1569a85..c1340eb19 100644 --- a/Intern/rayx-core/src/Beamline/Objects/PointSource.cpp +++ b/Intern/rayx-core/src/Beamline/Objects/PointSource.cpp @@ -94,7 +94,7 @@ std::vector PointSource::getRays(int thread_count) const { const auto field = stokesToElectricField(m_pol, direction); - Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0}; + Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0}; #if defined(DIPOLE_OMP) #pragma omp critical { rayList.push_back(r); } diff --git a/Intern/rayx-core/src/Beamline/Objects/SimpleUndulatorSource.cpp b/Intern/rayx-core/src/Beamline/Objects/SimpleUndulatorSource.cpp index 34a6db23c..39f3941fc 100644 --- a/Intern/rayx-core/src/Beamline/Objects/SimpleUndulatorSource.cpp +++ b/Intern/rayx-core/src/Beamline/Objects/SimpleUndulatorSource.cpp @@ -74,7 +74,7 @@ std::vector SimpleUndulatorSource::getRays([[maybe_unused]] int thread_coun const auto field = stokesToElectricField(m_pol, direction); - Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0}; + Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0}; rayList.push_back(r); } diff --git a/Intern/rayx-core/src/Debug/Debug.h b/Intern/rayx-core/src/Debug/Debug.h index bdfd61890..6f9f777d6 100644 --- a/Intern/rayx-core/src/Debug/Debug.h +++ b/Intern/rayx-core/src/Debug/Debug.h @@ -166,8 +166,9 @@ inline std::vector formatAsVec(double arg) { return {arg}; } inline std::vector formatAsVec(complex::Complex comp) { return {comp.real(), comp.imag()}; } inline std::vector formatAsVec(const Ray arg) { + const auto eventType = static_cast(arg.m_eventType); return { - arg.m_position.x, arg.m_position.y, arg.m_position.z, arg.m_eventType, arg.m_direction.x, arg.m_direction.y, + arg.m_position.x, arg.m_position.y, arg.m_position.z, eventType, arg.m_direction.x, arg.m_direction.y, arg.m_direction.z, arg.m_energy, arg.m_field.x.real(), arg.m_field.x.imag(), arg.m_field.y.real(), arg.m_field.y.imag(), arg.m_field.z.real(), arg.m_field.z.imag(), arg.m_pathLength, arg.m_order, arg.m_lastElement, arg.m_sourceID, }; diff --git a/Intern/rayx-core/src/Shader/Behave.cpp b/Intern/rayx-core/src/Shader/Behave.cpp index 3b35e0b8a..3086a197e 100644 --- a/Intern/rayx-core/src/Shader/Behave.cpp +++ b/Intern/rayx-core/src/Shader/Behave.cpp @@ -27,7 +27,7 @@ Ray behaveSlit(Ray r, int id, [[maybe_unused]] Collision col, InvState& inv) { bool withinBeamstop = inCutout(beamstopCutout, r.m_position.x, r.m_position.z); if (!withinOpening || withinBeamstop) { - recordFinalEvent(r, ETYPE_ABSORBED, inv); + recordFinalEvent(r, EventType::Absorbed, inv); return r; } diff --git a/Intern/rayx-core/src/Shader/Behave.h b/Intern/rayx-core/src/Shader/Behave.h index f69d2de97..f546ab5e4 100644 --- a/Intern/rayx-core/src/Shader/Behave.h +++ b/Intern/rayx-core/src/Shader/Behave.h @@ -15,7 +15,7 @@ namespace RAYX { /// The `behave*` functions, will /// - change the rays direction, typically by reflecting using the normal /// - change the rays stokes vector -/// - potentially absorb the ray (by calling `recordFinalEvent(_, ETYPE_ABSORBED)`) +/// - potentially absorb the ray (by calling `recordFinalEvent(_, EventType::Absorbed)`) RAYX_FN_ACC Ray behaveSlit(Ray r, int id, Collision col, InvState& inv); RAYX_FN_ACC Ray behaveRZP(Ray r, int id, Collision col, InvState& inv); diff --git a/Intern/rayx-core/src/Shader/DynamicElements.cpp b/Intern/rayx-core/src/Shader/DynamicElements.cpp index fc4e82745..d5400742c 100644 --- a/Intern/rayx-core/src/Shader/DynamicElements.cpp +++ b/Intern/rayx-core/src/Shader/DynamicElements.cpp @@ -64,7 +64,7 @@ void dynamicElements(int gid, InvState& inv) { break; } - recordEvent(ray, ETYPE_JUST_HIT_ELEM, inv); + recordEvent(ray, EventType::HitElement, inv); // transform back to WORLD coordinates ray = rayMatrixMult(ray, nextElement.m_outTrans); diff --git a/Intern/rayx-core/src/Shader/EventType.h b/Intern/rayx-core/src/Shader/EventType.h index cc2b2bdfc..76db53075 100644 --- a/Intern/rayx-core/src/Shader/EventType.h +++ b/Intern/rayx-core/src/Shader/EventType.h @@ -4,37 +4,37 @@ namespace RAYX { -// The meaning of the `m_eventType` field of a `Ray`: -//////////////////////////////////////////////////// - -// This Ray has just hit `m_lastElement`. -// And will continue tracing afterwards. -// Ray is in element coordinates of the hit element. -constexpr double ETYPE_JUST_HIT_ELEM = 1; - -// If the storage space for the events is insufficient for the amount of events that were recorded in a shader call. -constexpr double ETYPE_TOO_MANY_EVENTS = 2; - -// This Ray was absorbed by `m_lastElement`. -// Ray is in element coordinates, relative to `m_lastElement`. -constexpr double ETYPE_ABSORBED = 3; - -// This is a yet uninitialized ray from outputData. -// This is the initial weight within outputData, and if less events than `maxEvents` are taken, -// the remaining weights in outputData will stay ETYPE_UNINIT even when returned to the CPU. -constexpr double ETYPE_UNINIT = 4; - -// This is an error code. -// Functions like refrac2D can error due to "ray beyond horizon", see Utils.h. -// In that case this is returned as final event. -constexpr double ETYPE_BEYOND_HORIZON = 5; - -// This is a general error code that means some assertion failed in the shader. -// This error code is typically generated using `_throw`. -constexpr double ETYPE_FATAL_ERROR = 6; - -// These rays have just been emitted and not had any other events -// If there are no other elements the ray has this eventtype -constexpr double ETYPE_EMITTED = 7; +// The meaning of the `m_eventType` field of a `Ray` +enum class EventType { + // This is a yet uninitialized ray from outputData. + // This is the initial weight within outputData, and if less events than `maxEvents` are taken, + // the remaining weights in outputData will stay EventType::Uninit even when returned to the CPU. + Uninit = 0, + + // This Ray has just hit `m_lastElement`. + // And will continue tracing afterwards. + // Ray is in element coordinates of the hit element. + HitElement = 1, + + // If the storage space for the events is insufficient for the amount of events that were recorded in a shader call. + TooManyEvents = 2, + + // This Ray was absorbed by `m_lastElement`. + // Ray is in element coordinates, relative to `m_lastElement`. + Absorbed = 3, + + // This is an error code. + // Functions like refrac2D can error due to "ray beyond horizon", see Utils.h. + // In that case this is returned as final event. + BeyondHorizon = 5, + + // This is a general error code that means some assertion failed in the shader. + // This error code is typically generated using `_throw`. + FatalError = 6, + + // These rays have just been emitted and not had any other events + // If there are no other elements the ray has this eventtype + Emitted = 7, +}; } // namespace RAYX diff --git a/Intern/rayx-core/src/Shader/Helper.cpp b/Intern/rayx-core/src/Shader/Helper.cpp index 2367419d1..a84bb8fa8 100644 --- a/Intern/rayx-core/src/Shader/Helper.cpp +++ b/Intern/rayx-core/src/Shader/Helper.cpp @@ -10,9 +10,9 @@ void init(InvState& inv) { inv.finalized = false; // TODO(Sven): dont waste time with initializing - // sets all output rays controlled by this shader call to ETYPE_UNINIT. + // sets all output rays controlled by this shader call to EventType::Uninit. for (uint32_t i = uint32_t(0); i < inv.pushConstants.maxEvents; i++) { - inv.outputRays[output_index(i, inv)].m_eventType = ETYPE_UNINIT; + inv.outputRays[output_index(i, inv)].m_eventType = EventType::Uninit; } inv.nextEventIndex = 0; @@ -38,13 +38,13 @@ uint32_t output_index(uint32_t i, InvState& inv) { // record an event and store it in the next free spot in outputRays. // `r` will typically be ray, or some related ray. RAYX_FN_ACC -void recordEvent(Ray r, double w, InvState& inv) { +void recordEvent(Ray r, EventType w, InvState& inv) { if (inv.finalized) { return; } // recording of event type ETYPE_UINIT is forbidden. - if (w == ETYPE_UNINIT) { + if (w == EventType::Uninit) { _throw("recordEvent failed: weight UNINIT is invalid in recordEvent"); return; @@ -54,9 +54,9 @@ void recordEvent(Ray r, double w, InvState& inv) { if (inv.nextEventIndex >= inv.pushConstants.maxEvents) { inv.finalized = true; - // change the last event to "ETYPE_TOO_MANY_EVENTS". + // change the last event to "EventType::TooManyEvents". uint32_t idx = output_index(uint32_t(inv.pushConstants.maxEvents - 1), inv); - inv.outputRays[idx].m_eventType = ETYPE_TOO_MANY_EVENTS; + inv.outputRays[idx].m_eventType = EventType::TooManyEvents; _throw("recordEvent failed: too many events!"); @@ -74,7 +74,7 @@ void recordEvent(Ray r, double w, InvState& inv) { // Like `recordEvent` above, but it will prevent recording more events after this. // Is used for events terminating the path of the ray. RAYX_FN_ACC -void recordFinalEvent(Ray r, double w, InvState& inv) { +void recordFinalEvent(Ray r, EventType w, InvState& inv) { recordEvent(r, w, inv); inv.finalized = true; } diff --git a/Intern/rayx-core/src/Shader/Helper.h b/Intern/rayx-core/src/Shader/Helper.h index ec1f56286..580e28770 100644 --- a/Intern/rayx-core/src/Shader/Helper.h +++ b/Intern/rayx-core/src/Shader/Helper.h @@ -9,7 +9,7 @@ namespace RAYX { RAYX_FN_ACC void init(InvState& inv); RAYX_FN_ACC uint64_t rayId(InvState& inv); RAYX_FN_ACC uint32_t output_index(uint32_t i, InvState& inv); -RAYX_FN_ACC void recordEvent(Ray r, double w, InvState& inv); -RAYX_FN_ACC void recordFinalEvent(Ray r, double w, InvState& inv); +RAYX_FN_ACC void recordEvent(Ray r, EventType w, InvState& inv); +RAYX_FN_ACC void recordFinalEvent(Ray r, EventType w, InvState& inv); } // namespace RAYX diff --git a/Intern/rayx-core/src/Shader/Ray.h b/Intern/rayx-core/src/Shader/Ray.h index 56ae937fd..c8a796620 100644 --- a/Intern/rayx-core/src/Shader/Ray.h +++ b/Intern/rayx-core/src/Shader/Ray.h @@ -19,10 +19,10 @@ struct RAYX_API Ray { glm::dvec3 m_position; /// The m_eventType expresses what is currently happening to the ray. - /// During tracing the eventType will be uninitialized (ETYPE_UNINIT). + /// During tracing the eventType will be uninitialized (EventType::Uninit). /// Only when an event will be recorded, the m_eventType will be set accordingly. /// See the potential values of `m_eventType` in `EventType.h`. - double m_eventType; + EventType m_eventType; /// The direction of the ray. /// The direction is normalized, so its L2 norm (aka length) is one. diff --git a/Intern/rayx-core/src/Shader/Refrac.cpp b/Intern/rayx-core/src/Shader/Refrac.cpp index 93d0cfc55..7ca238799 100644 --- a/Intern/rayx-core/src/Shader/Refrac.cpp +++ b/Intern/rayx-core/src/Shader/Refrac.cpp @@ -11,7 +11,7 @@ calculates refracted ray normal: normal at intersection point of ray and element az: linedensity in z direction varied spacing for different collision angles is already considered ax: linedensity in x direction -@returns: refracted ray (position unchanged, direction changed), weight = ETYPE_BEYOND_HORIZON if +@returns: refracted ray (position unchanged, direction changed), weight = EventType::BeyondHorizon if "ray beyond horizon" */ RAYX_FN_ACC @@ -41,7 +41,7 @@ Ray refrac2D(Ray r, glm::dvec3 normal, double density_z, double density_x, InvSt r.m_direction.z = z1; r.m_direction = inv_rot * r.m_direction; } else { // beyond horizon - when divergence too large - recordFinalEvent(r, ETYPE_BEYOND_HORIZON, inv); + recordFinalEvent(r, EventType::BeyondHorizon, inv); } return r; } diff --git a/Intern/rayx-core/src/Shader/Refrac.h b/Intern/rayx-core/src/Shader/Refrac.h index 499553cce..61d108434 100644 --- a/Intern/rayx-core/src/Shader/Refrac.h +++ b/Intern/rayx-core/src/Shader/Refrac.h @@ -10,7 +10,7 @@ calculates refracted ray @params: r: ray normal: normal at intersection point of ray and element -> for planes normal is always the same (0,1,0) -> no need to rotate but we do anyways. az: linedensity in z direction ax: linedensity in x direction -@returns: refracted ray (position unchanged, direction changed), weight = ETYPE_BEYOND_HORIZON if +@returns: refracted ray (position unchanged, direction changed), weight = EventType::BeyondHorizon if "ray beyond horizon" */ RAYX_FN_ACC Ray refrac2D(Ray r, glm::dvec3 normal, double az, double ax, InvState& inv); diff --git a/Intern/rayx-core/src/Shader/Throw.h b/Intern/rayx-core/src/Shader/Throw.h index be4a98cb6..d4e0b6338 100644 --- a/Intern/rayx-core/src/Shader/Throw.h +++ b/Intern/rayx-core/src/Shader/Throw.h @@ -4,7 +4,7 @@ // throws an error, and termiantes the program // TODO(Sven): rethink error handling. just instantly terminate with RAYX_EXIT or use recordFinalEvent? -// #define _throw(string) recordFinalEvent(_ray, ETYPE_FATAL_ERROR) +// #define _throw(string) recordFinalEvent(_ray, EventType::FatalError) // #define _throw(string) RAYX_ERR << string #define _throw(string) \ printf("Error occurred while executing shader: %s\n", string); \ diff --git a/Intern/rayx-core/src/Writer/CSVWriter.cpp b/Intern/rayx-core/src/Writer/CSVWriter.cpp index 7dd0874c7..4d6716392 100644 --- a/Intern/rayx-core/src/Writer/CSVWriter.cpp +++ b/Intern/rayx-core/src/Writer/CSVWriter.cpp @@ -118,19 +118,26 @@ RAYX::BundleHistory loadCSV(const std::string& filename) { RAYX_EXIT << "CSV line has incorrect length: " << d.size(); } - const auto direction = glm::dvec3(d[4], d[5], d[6]); + const auto position = glm::dvec3{d[0], d[1], d[2]}; + const auto eventType = static_cast(d[3]); + const auto direction = glm::dvec3(d[4], d[5], d[6]); + const auto energy = d[7]; const auto field = RAYX::ElectricField({d[8], d[9]}, {d[10], d[11]}, {d[12], d[13]}); + const auto pathLength = d[14]; + const auto order = d[15]; + const auto lastElement = d[16]; + const auto sourceID = d[17]; // create the Ray from the loaded doubles from this line. - RAYX::Ray ray = {.m_position = {d[0], d[1], d[2]}, - .m_eventType = d[3], + RAYX::Ray ray = {.m_position = position, + .m_eventType = eventType, .m_direction = direction, - .m_energy = d[7], + .m_energy = energy, .m_field = field, - .m_pathLength = d[14], - .m_order = d[15], - .m_lastElement = d[16], - .m_sourceID = d[17]}; + .m_pathLength = pathLength, + .m_order = order, + .m_lastElement = lastElement, + .m_sourceID = sourceID}; // This checks whether `ray_id` is from a "new ray" that didn't yet come up in the BundleHistory. // If so, we need to make place for it. if (out.size() <= ray_id) { diff --git a/Intern/rayx-core/src/Writer/H5Writer.cpp b/Intern/rayx-core/src/Writer/H5Writer.cpp index 3fc002643..4de18e717 100644 --- a/Intern/rayx-core/src/Writer/H5Writer.cpp +++ b/Intern/rayx-core/src/Writer/H5Writer.cpp @@ -97,21 +97,27 @@ RAYX::BundleHistory fromDoubles(const std::vector& doubles, const Format currentRayID = rayID; } + const auto* d = rayData + 2; + const auto position = glm::dvec3{d[0], d[1], d[2]}; + const auto eventType = static_cast(d[3]); + const auto direction = glm::dvec3(d[4], d[5], d[6]); + const auto energy = d[7]; + const auto field = RAYX::ElectricField({d[8], d[9]}, {d[10], d[11]}, {d[12], d[13]}); + const auto pathLength = d[14]; + const auto order = d[15]; + const auto lastElement = d[16]; + const auto sourceID = d[17]; + const auto ray = RAYX::Ray{ - .m_position = {rayData[2], rayData[3], rayData[4]}, // origin - .m_eventType = rayData[5], // eventType - .m_direction = {rayData[6], rayData[7], rayData[8]}, // direction - .m_energy = rayData[9], // energy - .m_field = - { - {rayData[10], rayData[11]}, - {rayData[12], rayData[13]}, - {rayData[14], rayData[15]}, - }, - .m_pathLength = rayData[16], // pathLength - .m_order = rayData[17], // order - .m_lastElement = rayData[18], // lastElement - .m_sourceID = rayData[19] // sourceID + .m_position = position, + .m_eventType = eventType, + .m_direction = direction, + .m_energy = energy, + .m_field = field, + .m_pathLength = pathLength, + .m_order = order, + .m_lastElement = lastElement, + .m_sourceID = sourceID, }; rayHist.push_back(ray); diff --git a/Intern/rayx-core/src/Writer/Writer.h b/Intern/rayx-core/src/Writer/Writer.h index ef0f94278..526f852b2 100644 --- a/Intern/rayx-core/src/Writer/Writer.h +++ b/Intern/rayx-core/src/Writer/Writer.h @@ -49,7 +49,7 @@ static Format FULL_FORMAT = { }, FormatComponent{ .name = "Event-type", - .get_double = [](uint32_t, uint32_t, RAYX::Ray ray) { return ray.m_eventType; }, + .get_double = [](uint32_t, uint32_t, RAYX::Ray ray) { return static_cast(ray.m_eventType); }, }, FormatComponent{ .name = "X-direction", diff --git a/Intern/rayx-core/tests/setupTests.cpp b/Intern/rayx-core/tests/setupTests.cpp index c8cd53a4f..4ac5e045e 100644 --- a/Intern/rayx-core/tests/setupTests.cpp +++ b/Intern/rayx-core/tests/setupTests.cpp @@ -55,7 +55,7 @@ RAYX::Ray parseCSVline(std::string line) { // otherwise uninitialized: ray.m_sourceID = -1; - ray.m_eventType = -1; + ray.m_eventType = EventType::Uninit; ray.m_lastElement = -1; ray.m_order = -1; @@ -84,13 +84,13 @@ std::vector extractLastHit(const RAYX::BundleHistory& hist) { std::vector outs; for (auto rr : hist) { Ray out; - out.m_eventType = ETYPE_UNINIT; + out.m_eventType = EventType::Uninit; for (auto r : rr) { - if (r.m_eventType == ETYPE_JUST_HIT_ELEM) { + if (r.m_eventType == EventType::HitElement) { out = r; } } - if (out.m_eventType != ETYPE_UNINIT) { + if (out.m_eventType != EventType::Uninit) { outs.push_back(out); } } @@ -168,7 +168,7 @@ std::optional lastSequentialHit(RayHistory ray_hist, uint32_t beamlin if (ray_hist[i].m_lastElement != i) { return {}; } - if (ray_hist[i].m_eventType != ETYPE_JUST_HIT_ELEM) { + if (ray_hist[i].m_eventType != EventType::HitElement) { return {}; } } diff --git a/Intern/rayx-core/tests/setupTests.h b/Intern/rayx-core/tests/setupTests.h index 35d284774..62d1c7687 100644 --- a/Intern/rayx-core/tests/setupTests.h +++ b/Intern/rayx-core/tests/setupTests.h @@ -185,7 +185,7 @@ void writeToOutputCSV(const RAYX::BundleHistory& hist, std::string filename); /// Returns all traced rays RAYX::BundleHistory traceRML(std::string filename); -// extracts the last ETYPE_JUST_HIT_ELEM for each ray. +// extracts the last EventType::HitElement for each ray. std::vector extractLastHit(const RAYX::BundleHistory&); /// will look at Tests/input/.csv diff --git a/Intern/rayx-ui/src/RayProcessing.cpp b/Intern/rayx-ui/src/RayProcessing.cpp index 5d3367aa0..5a7b948f7 100644 --- a/Intern/rayx-ui/src/RayProcessing.cpp +++ b/Intern/rayx-ui/src/RayProcessing.cpp @@ -96,9 +96,9 @@ std::vector getRays(const RAYX::BundleHistory& rayCache, const RAYX::Beaml RAYX_EXIT << "Trying to access out-of-bounds index with element ID: " << event.m_lastElement; } glm::vec4 worldPos = compiledElements[static_cast(event.m_lastElement)].m_outTrans * glm::vec4(event.m_position, 1.0f); - glm::vec4 originColor = (event.m_eventType == RAYX::ETYPE_JUST_HIT_ELEM) ? YELLOW : WHITE; - glm::vec4 pointColor = (event.m_eventType == RAYX::ETYPE_JUST_HIT_ELEM) ? ORANGE - : (event.m_eventType == RAYX::ETYPE_ABSORBED) ? RED + glm::vec4 originColor = (event.m_eventType == RAYX::EventType::HitElement) ? YELLOW : WHITE; + glm::vec4 pointColor = (event.m_eventType == RAYX::EventType::HitElement) ? ORANGE + : (event.m_eventType == RAYX::EventType::Absorbed) ? RED : WHITE; ColorVertex origin = {rayLastPos, originColor}; diff --git a/Intern/rayx-ui/src/Simulator.cpp b/Intern/rayx-ui/src/Simulator.cpp index bcc967750..7cfa8de06 100644 --- a/Intern/rayx-ui/src/Simulator.cpp +++ b/Intern/rayx-ui/src/Simulator.cpp @@ -24,7 +24,7 @@ void Simulator::runSimulation() { for (auto& ray : rays) { for (auto& event : ray) { - if (event.m_eventType == RAYX::ETYPE_TOO_MANY_EVENTS) { + if (event.m_eventType == RAYX::EventType::TooManyEvents) { notEnoughEvents = true; } } diff --git a/Intern/rayx-ui/src/Triangulation/TraceTriangulation.cpp b/Intern/rayx-ui/src/Triangulation/TraceTriangulation.cpp index 0bea36ea3..77a369b1f 100644 --- a/Intern/rayx-ui/src/Triangulation/TraceTriangulation.cpp +++ b/Intern/rayx-ui/src/Triangulation/TraceTriangulation.cpp @@ -29,7 +29,7 @@ std::vector> createRayGrid(size_t size, double width, dou RAYX::Ray ray = { .m_position = pos, - .m_eventType = RAYX::ETYPE_UNINIT, + .m_eventType = RAYX::EventType::Uninit, .m_direction = dir, .m_energy = 1.0f, .m_field = field, diff --git a/Intern/rayx/src/TerminalApp.cpp b/Intern/rayx/src/TerminalApp.cpp index 0cfeb1e21..e087cc1c4 100644 --- a/Intern/rayx/src/TerminalApp.cpp +++ b/Intern/rayx/src/TerminalApp.cpp @@ -80,7 +80,7 @@ void TerminalApp::tracePath(const std::filesystem::path& path) { } for (auto& event : ray) { - if (event.m_eventType == RAYX::ETYPE_TOO_MANY_EVENTS) { + if (event.m_eventType == RAYX::EventType::TooManyEvents) { notEnoughEvents = true; } } diff --git a/docs/src/Tools/How-to-use-Doxygen.md b/docs/src/Tools/How-to-use-Doxygen.md index 95e95cafe..f176092ae 100644 --- a/docs/src/Tools/How-to-use-Doxygen.md +++ b/docs/src/Tools/How-to-use-Doxygen.md @@ -62,13 +62,13 @@ std::vector getRays(const RAYX::BundleHistory& bundleHist, const std::vect for (const auto& rayHist : bundleHist) { glm::vec3 rayLastPos = {0.0f, 0.0f, 0.0f}; for (const auto& event : rayHist) { - if (event.m_eventType == ETYPE_JUST_HIT_ELEM || event.m_eventType == ETYPE_ABSORBED) { + if (event.m_eventType == EventType::HitElement || event.m_eventType == EventType::Absorbed) { // Events where rays hit objects are in element coordinates // We need to convert them to world coordinates glm::vec4 worldPos = elements[(size_t)event.m_lastElement].m_element.m_outTrans * glm::vec4(event.m_position, 1.0f); Vertex origin = {{rayLastPos.x, rayLastPos.y, rayLastPos.z, 1.0f}, YELLOW}; - Vertex point = (event.m_eventType == ETYPE_JUST_HIT_ELEM) ? Vertex(worldPos, ORANGE) : Vertex(worldPos, RED); + Vertex point = (event.m_eventType == EventType::HitElement) ? Vertex(worldPos, ORANGE) : Vertex(worldPos, RED); rays.push_back(Line(origin, point)); rayLastPos = point.pos;