Files
medicallib/include/MedicalLib/Heart.h
T
google-labs-jules[bot] 86488cec48 This commit performs a comprehensive documentation pass on the MedicalLib library, implementing a full documentation generation pipeline using Doxygen, Sphinx, and Breathe for Read the Docs.
Key changes include:

- **Added Comprehensive Doxygen Comments:**
  - Reviewed all header files in `include/MedicalLib/`.
  - Added Doxygen comments for public methods, structs, and their member variables to ensure full API coverage as per the project's coding standards.
  - Addressed all Doxygen warnings related to undocumented public members.

- **Restructured Sphinx Documentation:**
  - Created a new `docs/api/` directory to house detailed documentation for each component.
  - Replaced the single `api.rst` file with a well-organized structure using a `toctree`.
  - Created individual `.rst` pages for each organ, class, and major component.

- **Enabled Graph Generation:**
  - Configured Doxygen to generate class hierarchy and collaboration graphs.
  - Ensured the build process includes these graphs in the final documentation, providing visual context for the library's structure.

- **Verified Build Process:**
  - Installed all necessary dependencies (`doxygen`, `graphviz`, python packages).
  - Successfully ran the Doxygen and Sphinx build process to generate the final HTML documentation, ensuring all changes are correctly integrated.

This work results in a professional, navigable, and maintainable documentation site for the MedicalLib library.
2025-08-20 09:14:51 +00:00

118 lines
4.0 KiB
C++

#pragma once
#include "Organ.h"
#include <vector>
#include <string>
#include <map>
#include <deque>
/**
* @brief Represents the state of a heart valve.
*/
enum class ValveStatus { OPEN, CLOSED };
/**
* @brief Represents a single heart valve and its potential pathologies.
*/
struct Valve {
std::string name; ///< The name of the valve (e.g., "Mitral").
ValveStatus status = ValveStatus::CLOSED; ///< The current status of the valve (OPEN or CLOSED).
double stenosis = 0.0; ///< Degree of narrowing, normalized [0, 1].
double regurgitation = 0.0; ///< Degree of leakage, normalized [0, 1].
};
/**
* @brief Represents the state of a heart chamber.
*/
enum class ChamberState { SYSTOLE, DIASTOLE };
/**
* @brief Represents a single chamber of the heart.
*/
struct Chamber {
std::string name; ///< The name of the chamber (e.g., "Left Ventricle").
ChamberState state = ChamberState::DIASTOLE;///< The current state of the chamber (SYSTOLE or DIASTOLE).
double volume_mL = 0.0; ///< The current volume of blood in the chamber in mL.
double pressure_mmHg = 0.0; ///< The current pressure in the chamber in mmHg.
double endDiastolicVolume_mL = 120.0; ///< The volume of blood at the end of diastole (filling).
double endSystolicVolume_mL = 50.0; ///< The volume of blood at the end of systole (contraction).
};
/**
* @brief Represents the Heart organ, with detailed mechanical and electrical simulation.
*/
class MEDICAL_LIB_API Heart : public Organ {
public:
/**
* @brief Constructor for the Heart class.
* @param id The ID of the organ.
* @param numLeads The number of EKG leads to simulate (e.g., 3, 5, or 12).
*/
Heart(int id, int numLeads = 12);
/**
* @brief Updates the heart's state over time, simulating the cardiac cycle.
* @param patient A reference to the patient object.
* @param deltaTime_s The time elapsed in seconds.
*/
void update(Patient& patient, double deltaTime_s) override;
/**
* @brief Gets a string summary of the heart's vitals, including EKG and mechanical data.
* @return A string containing the heart's vital signs.
*/
std::string getSummary() const override;
// --- Electrical Properties ---
/**
* @brief Sets the baseline heart rate.
* @param newRate_bpm The new heart rate in beats per minute.
*/
void setHeartRate(double newRate_bpm);
/**
* @brief Gets the current measured heart rate.
* @return The heart rate in beats per minute.
*/
double getHeartRate() const;
/**
* @brief Gets the simulated EKG data for all leads.
* @return A constant reference to the map of EKG data.
*/
const std::map<std::string, std::deque<double>>& getEkgData() const;
// --- Mechanical Properties ---
/**
* @brief Calculates and returns the left ventricular ejection fraction.
* @return The ejection fraction as a percentage [0, 100].
*/
double getEjectionFraction() const;
/**
* @brief Gets the simulated aortic pressure, representing systemic blood pressure.
* @return The aortic pressure in mmHg.
*/
double getAorticPressure() const; // Represents systemic blood pressure
private:
// --- Electrical Simulation ---
double simulateEkgWaveform(double timeInCycle);
double heartRate; // Underlying target heart rate (bpm)
double measuredHeartRate;
int numLeads;
std::vector<std::string> leadNames;
std::map<std::string, std::deque<double>> ekgData;
size_t ekgHistorySize;
// Cycle timing
double totalTime_s;
double cardiacCyclePosition_s;
double lastRPeakTime_s;
bool rPeakDetectedInCycle;
// --- Mechanical Simulation ---
Chamber leftAtrium, rightAtrium, leftVentricle, rightVentricle;
Valve mitralValve, tricuspidValve, aorticValve, pulmonaryValve;
double ejectionFraction; // Percentage
};