Ejemplo n.º 1
0
    /**
     *  Set up the data object with empty UltrasoundPoint%s representing the points
     *  that need to be scanned.
     *
     *  This is analagous to setting up the view frustum in traditional 3D graphics.
     */
    private void EstablishScanningPlane(ref UltrasoundScanData data)
    {
        OnionLogger.globalLog.PushInfoLayer("Pre-populating data");

        UltrasoundProbeConfiguration config = data.GetProbeConfig();

        // nearZ and farZ represent near and far clipping "planes" (they're really arcs)
        float nearZ = config.GetMinScanDistance();
        float farZ  = config.GetMaxScanDistance();

        float arcSizeDegrees    = config.GetArcSizeInDegrees();
        int   scanlines         = config.GetNumberOfScanlines();
        int   pointsPerScanline = config.GetPointsPerScanline();

        for (int i = 0; i < scanlines; ++i)
        {
            UltrasoundScanline scanline = new UltrasoundScanline(config.GetPosition());
            float   angleInDegrees      = -(arcSizeDegrees / 2) + i * arcSizeDegrees / (scanlines - 1);
            float   angleInRadians      = Mathf.Deg2Rad * angleInDegrees;
            Vector2 trajectory          = new Vector2(Mathf.Sin(angleInRadians), Mathf.Cos(angleInRadians));

            for (int j = 0; j < pointsPerScanline; ++j)
            {
                float           d = nearZ + j * (farZ - nearZ) / (pointsPerScanline - 1);
                Vector2         positionOnPlane      = d * trajectory;
                Vector3         positionInWorldSpace = WorldSpaceFromProjectedPosition(positionOnPlane, config);
                UltrasoundPoint point = new UltrasoundPoint(positionInWorldSpace, positionOnPlane);
                scanline.AddUltrasoundPoint(point);
            }

            data.AddScanline(scanline);
        }

        OnionLogger.globalLog.PopInfoLayer();
    }
Ejemplo n.º 2
0
    /**
     *  Since the pulse will lose energy after interacting with tissue at a point, we will
     *  need to recalculate the pulse intensity after processing each UltrasoundPoint.
     *
     *  @param previousPulseIntensity The intensity of the pulse that hit this point.
     *  @param previousOrgan The properties of the organ at this point.
     *  @param config The probe configuration. (Used for normalizing energy loss for higher res display)
     *
     *  @return The new intensity to use for the next UltrasoundPoint.
     */
    private float PulseIntensityAfterPoint(float previousPulseIntensity,
                                           HorayMaterialProperties previousOrgan,
                                           UltrasoundProbeConfiguration config)
    {
        // When calculating energy lost, we need to normalize for the number of points in the display.
        float resolutionCoefficient = config.GetPointsPerScanline();
        float energyLost            = (previousOrgan.echogenicity + previousOrgan.attenuation) / resolutionCoefficient;
        float newIntensity          = previousPulseIntensity - energyLost;

        return(newIntensity);
    }
    /**
     *  Copy constructor to instantiate a new UltrasoundProbeConfiguration from another.
     *
     *  @param config The other UltrasoundProbeConfiguration object.
     *  @throw ArgumentNullException
     */
    public UltrasoundProbeConfiguration(UltrasoundProbeConfiguration config)
    {
        UltrasoundDebug.Assert(null != config,
                               "Null UltrasoundProbeConfiguration used for copy constructor.",
                               this);
        this.SetPosition(config.GetPosition());
        this.SetRotation(config.GetRotation());

        this.maxDistance       = config.GetMaxScanDistance();
        this.minDistance       = config.GetMinScanDistance();
        this.arcSizeInDegrees  = config.GetArcSizeInDegrees();
        this.pointsPerScanline = config.GetPointsPerScanline();
        this.numberOfScanlines = config.GetNumberOfScanlines();
        this.gain = config.GetGain();
    }