diff --git a/UTSR/simulNDT.cpp b/UTSR/simulNDT.cpp new file mode 100644 index 0000000..182a63a --- /dev/null +++ b/UTSR/simulNDT.cpp @@ -0,0 +1,120 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +struct ScanData { + std::vector timeScale; + struct CscanData { + int AscanPoints; + double TsGate; + double TendGate; + std::vector X; + int Rows; + double Cl; + double Cs; + double Density; + double Frequency; + double Bandwidth; + char WaveType; + double BeamAngle; + double ProbeDiameter; + std::string DefectType; + double PosX; + double PosY; + double DepthCentre; + double Diameter; + double Height; + double Tilt; + double MaxSignal; + double MaxSdtRef; + double Y; + int Cols; + std::vector> CscanValues; + double Wavelength; + double Nearfield; + double ProbeEllipX; + double ProbeEllipY; + double TrueAngle; + double CalValue; + } CscanData; + std::vector> AscanValues; +}; + +struct Setup { + // Define the setup structure here + // This is a placeholder and should be filled with actual fields +}; + +std::pair simulNDT(const std::map>& args) { + ScanData scanData; + Setup setup; + + // Parse input arguments + double TsGate = std::get(args.at("TsGate")); + double TendGate = std::get(args.at("TendGate")); + double deltaT = std::get(args.at("deltaT")); + // ... Parse other arguments similarly + + // Create timeScale element + for (double t = TsGate; t <= TendGate; t += deltaT) { + scanData.timeScale.push_back(t); + } + + // Define the time window for simulation + std::vector t; + for (double time = TsGate; time <= TendGate; time += deltaT) { + t.push_back(time); + } + int nt = t.size(); + int idxTsGate = std::lower_bound(t.begin(), t.end(), TsGate) - t.begin() - 1; + int idxTendGate = std::lower_bound(t.begin(), t.end(), TendGate) - t.begin(); + + // Update scanData with arguments values + scanData.CscanData.AscanPoints = scanData.timeScale.size(); + scanData.CscanData.TsGate = TsGate; + scanData.CscanData.TendGate = TendGate; + + // ... Update other fields of scanData.CscanData + + // Create AscanValues element + scanData.AscanValues.resize(scanData.CscanData.AscanPoints, std::vector(scanData.CscanData.Rows, 0.0)); + + // Create default simulation setup + setup = setup_maker(); // Assuming this function is defined elsewhere + + // Define the frequency window for simulation + std::vector f; + for (int i = -nt/2; i < nt/2; ++i) { + f.push_back(i / (deltaT * nt)); + } + setup.f = std::vector(f.begin() + nt/2 + 1, f.end()); + + // Adjust material parameters + // ... Adjust setup parameters + + // Perform the simulation + if (std::get(args.at("simul"))) { + // ... Perform simulation + } + + return {scanData, setup}; +} +/* + +This C++ code provides a basic structure for the `simulNDT` function. Note that some parts are left as placeholders or comments, as the full implementation would require additional context and supporting functions. The code uses C++ standard library containers and algorithms where appropriate. + +Key points: +1. The `ScanData` and `Setup` structures are defined to hold the data. +2. The function takes a map of string keys to variants (to allow different types of arguments) instead of using variable arguments. +3. Standard C++ containers (`vector`, `map`) are used instead of Matlab arrays. +4. C++ algorithms like `lower_bound` are used for operations like finding indices. +5. The simulation loop is not fully implemented as it depends on functions not provided in the original code. + +To complete this implementation, you would need to define the missing functions (like `setup_maker`, `SDH_PE_MM`, `TG_PE_MM`, `IFourierT`) and fill in the details of the simulation loop. + +*/