Mercurial > hg > orthanc-stone
comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 2098:4288d635d77e dicom-sr
first rendering of dicom-sr
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 08 Nov 2023 17:23:31 +0100 |
parents | a9e23ef9ee09 |
children | 48a7f05c3bd5 |
comparison
equal
deleted
inserted
replaced
2097:a9e23ef9ee09 | 2098:4288d635d77e |
---|---|
455 double originX, | 455 double originX, |
456 double originY, | 456 double originY, |
457 double pixelSpacingX, | 457 double pixelSpacingX, |
458 double pixelSpacingY) const ORTHANC_OVERRIDE | 458 double pixelSpacingY) const ORTHANC_OVERRIDE |
459 { | 459 { |
460 size_t frameIndex; | 460 std::unique_ptr<OrthancStone::MacroSceneLayer> layer(new OrthancStone::MacroSceneLayer); |
461 if (!LookupFrame(frameIndex, sopInstanceUid, frameNumber)) | |
462 { | |
463 return NULL; | |
464 } | |
465 | |
466 const OrthancStone::DicomInstanceParameters& parameters = GetInstanceOfFrame(frameIndex); | |
467 | 461 |
468 const double x = originX - pixelSpacingX / 2.0; | 462 const double x = originX - pixelSpacingX / 2.0; |
469 const double y = originY - pixelSpacingY / 2.0; | 463 const double y = originY - pixelSpacingY / 2.0; |
470 const double w = parameters.GetWidth() * pixelSpacingX; | 464 |
471 const double h = parameters.GetHeight() * pixelSpacingY; | 465 for (size_t i = 0; i < sr_->GetStructuresCount(); i++) |
472 | 466 { |
473 std::unique_ptr<OrthancStone::MacroSceneLayer> layer(new OrthancStone::MacroSceneLayer); | 467 const OrthancStone::DicomStructuredReport::Structure& structure = sr_->GetStructure(i); |
474 | 468 if (structure.GetSopInstanceUid() == sopInstanceUid && |
475 { | 469 (!structure.HasFrameNumber() || |
476 std::unique_ptr<OrthancStone::PolylineSceneLayer> polyline(new OrthancStone::PolylineSceneLayer); | 470 structure.GetFrameNumber() == frameNumber)) |
477 { | 471 { |
478 OrthancStone::PolylineSceneLayer::Chain chain; | 472 OrthancStone::Color color(0, 0, 255); |
479 chain.push_back(OrthancStone::ScenePoint2D(x, y)); | 473 |
480 chain.push_back(OrthancStone::ScenePoint2D(x + pixelSpacingX, y)); | 474 if (structure.HasProbabilityOfCancer()) |
481 chain.push_back(OrthancStone::ScenePoint2D(x + pixelSpacingX, y + pixelSpacingY)); | 475 { |
482 chain.push_back(OrthancStone::ScenePoint2D(x, y + pixelSpacingY)); | 476 if (structure.GetProbabilityOfCancer() > 50.0f) |
483 | 477 { |
484 polyline->AddChain(chain, true, 255, 0, 0); | 478 color = OrthancStone::Color(255, 0, 0); |
485 } | 479 } |
486 | 480 else |
487 layer->AddLayer(polyline.release()); | 481 { |
488 } | 482 color = OrthancStone::Color(0, 255, 0); |
489 | 483 } |
490 { | 484 } |
491 std::unique_ptr<OrthancStone::PolylineSceneLayer> polyline(new OrthancStone::PolylineSceneLayer); | 485 |
492 { | 486 switch (structure.GetType()) |
493 OrthancStone::PolylineSceneLayer::Chain chain; | 487 { |
494 chain.push_back(OrthancStone::ScenePoint2D(x, y)); | 488 case OrthancStone::DicomStructuredReport::StructureType_Point: |
495 chain.push_back(OrthancStone::ScenePoint2D(x + w, y)); | 489 // TODO |
496 chain.push_back(OrthancStone::ScenePoint2D(x + w, y + h)); | 490 break; |
497 chain.push_back(OrthancStone::ScenePoint2D(x, y + h)); | 491 |
498 | 492 case OrthancStone::DicomStructuredReport::StructureType_Polyline: |
499 polyline->AddChain(chain, true, 255, 0, 0); | 493 { |
500 } | 494 const OrthancStone::DicomStructuredReport::Polyline& source = dynamic_cast<const OrthancStone::DicomStructuredReport::Polyline&>(structure); |
501 | 495 |
502 layer->AddLayer(polyline.release()); | 496 if (source.GetSize() > 1) |
497 { | |
498 std::unique_ptr<OrthancStone::PolylineSceneLayer> target(new OrthancStone::PolylineSceneLayer); | |
499 | |
500 OrthancStone::PolylineSceneLayer::Chain chain; | |
501 chain.resize(source.GetSize()); | |
502 for (size_t i = 0; i < source.GetSize(); i++) | |
503 { | |
504 chain[i] = OrthancStone::ScenePoint2D(x + source.GetPoint(i).GetX() * pixelSpacingX, | |
505 y + source.GetPoint(i).GetY() * pixelSpacingY); | |
506 } | |
507 | |
508 target->AddChain(chain, false, color.GetRed(), color.GetGreen(), color.GetBlue()); | |
509 layer->AddLayer(target.release()); | |
510 } | |
511 break; | |
512 } | |
513 | |
514 default: | |
515 break; | |
516 } | |
517 } | |
503 } | 518 } |
504 | 519 |
505 return layer.release(); | 520 return layer.release(); |
506 } | 521 } |
507 }; | 522 }; |