Mercurial > hg > orthanc-stone
diff Framework/Volumes/DicomVolumeImageMPRSlicer.cpp @ 949:32eaf4929b08 toa2019081301
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 13 Aug 2019 16:01:05 +0200 |
parents | 401808e7ff2e |
children | a7351ad54960 |
line wrap: on
line diff
--- a/Framework/Volumes/DicomVolumeImageMPRSlicer.cpp Sat Aug 10 13:13:11 2019 +0200 +++ b/Framework/Volumes/DicomVolumeImageMPRSlicer.cpp Tue Aug 13 16:01:05 2019 +0200 @@ -21,7 +21,11 @@ #include "DicomVolumeImageMPRSlicer.h" +#include "../StoneException.h" + #include <Core/OrthancException.h> +//#include <Core/Images/PngWriter.h> +#include <Core/Images/JpegWriter.h> namespace OrthancStone { @@ -76,14 +80,76 @@ ImageBuffer3D::SliceReader reader(volume_.GetPixelData(), projection_, sliceIndex_); texture.reset(dynamic_cast<TextureBaseSceneLayer*> (configurator->CreateTextureFromDicom(reader.GetAccessor(), parameters))); + + // <DEBUG-BLOCK> +#if 0 + Orthanc::JpegWriter writer; + writer.SetQuality(60); + static int index = 0; + std::string filePath = "C:\\temp\\sliceReader_P"; + filePath += boost::lexical_cast<std::string>(projection_); + filePath += "_I"; + filePath += boost::lexical_cast<std::string>(index); + filePath += ".jpg"; + index++; + writer.WriteToFile(filePath, reader.GetAccessor()); +#endif + // <END-OF-DEBUG-BLOCK> } - + const CoordinateSystem3D& system = volume_.GetGeometry().GetProjectionGeometry(projection_); double x0, y0, x1, y1; cuttingPlane.ProjectPoint(x0, y0, system.GetOrigin()); cuttingPlane.ProjectPoint(x1, y1, system.GetOrigin() + system.GetAxisX()); + + // <DEBUG-BLOCK> +#if 0 + { + LOG(ERROR) << "+----------------------------------------------------+"; + LOG(ERROR) << "| DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer |"; + LOG(ERROR) << "+----------------------------------------------------+"; + std::string projectionString; + switch (projection_) + { + case VolumeProjection_Coronal: + projectionString = "CORONAL"; + break; + case VolumeProjection_Axial: + projectionString = "CORONAL"; + break; + case VolumeProjection_Sagittal: + projectionString = "SAGITTAL"; + break; + default: + ORTHANC_ASSERT(false); + } + if(volume_.GetGeometry().GetDepth() == 200) + LOG(ERROR) << "| CT IMAGE 512x512 with projection " << projectionString; + else + LOG(ERROR) << "| RTDOSE IMAGE NNNxNNN with projection " << projectionString; + LOG(ERROR) << "+----------------------------------------------------+"; + LOG(ERROR) << "| cuttingPlane = " << cuttingPlane; + LOG(ERROR) << "| point to project = " << system.GetOrigin(); + LOG(ERROR) << "| result = x0: " << x0 << " y0: " << y0; + LOG(ERROR) << "+----------------------- END ------------------------+"; + } +#endif + // <END-OF-DEBUG-BLOCK> + +#if 1 // BGO 2019-08-13 + // The sagittal coordinate system has a Y vector going down. The displayed + // image (scene coords) has a Y vector pointing upwards (towards the patient + // coord Z index) + // we need to flip the Y local coordinates to get the scene-coord offset. + // TODO: this is quite ugly. Isn't there a better way? + if(projection_ == VolumeProjection_Sagittal) + texture->SetOrigin(x0, -y0); + else + texture->SetOrigin(x0, y0); +#else texture->SetOrigin(x0, y0); +#endif double dx = x1 - x0; double dy = y1 - y0; @@ -96,6 +162,19 @@ Vector tmp = volume_.GetGeometry().GetVoxelDimensions(projection_); texture->SetPixelSpacing(tmp[0], tmp[1]); + // <DEBUG-BLOCK> + { + //using std::endl; + //std::stringstream ss; + //ss << "DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer | cuttingPlane = " << cuttingPlane << " | projection_ = " << projection_ << endl; + //ss << "volume_.GetGeometry().GetProjectionGeometry(projection_) = " << system << endl; + //ss << "cuttingPlane.ProjectPoint(x0, y0, system.GetOrigin()); --> | x0 = " << x0 << " | y0 = " << y0 << "| x1 = " << x1 << " | y1 = " << y1 << endl; + //ss << "volume_.GetGeometry() = " << volume_.GetGeometry() << endl; + //ss << "volume_.GetGeometry() = " << volume_.GetGeometry() << endl; + //LOG(ERROR) << ss.str(); + } + // <END-OF-DEBUG-BLOCK> + return texture.release(); }