Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkPAVesselDrawer.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkPAVesselDrawer.h"
14 #include "mitkPAVesselProperties.h"
15 
17 {
18 }
19 
21 {
22 }
23 
25  VesselProperties::Pointer properties,
26  InSilicoTissueVolume::Pointer volume)
27 {
28  Vector::Pointer stepDirection = properties->GetDirectionVector();
29  Vector::Pointer fromPosition = properties->GetPositionVector()->Clone();
30 
31  Vector::Pointer totalWalkingDistance = stepDirection->Clone();
32  totalWalkingDistance->Scale(1.0 / volume->GetSpacing());
33 
34  while (totalWalkingDistance->GetNorm() >= 1)
35  {
36  double xPos = fromPosition->GetElement(0);
37  double yPos = fromPosition->GetElement(1);
38  double zPos = fromPosition->GetElement(2);
39 
40  if (!volume->IsInsideVolume(xPos, yPos, zPos))
41  {
42  properties->SetRadiusInVoxel(0);
43  return;
44  }
45 
46  double radius = properties->GetRadiusInVoxel();
47  double ceiledRadius = ceil(radius);
48 
49  for (int x = xPos - ceiledRadius; x <= xPos + ceiledRadius; x += 1)
50  for (int y = yPos - ceiledRadius; y <= yPos + ceiledRadius; y += 1)
51  for (int z = zPos - ceiledRadius; z <= zPos + ceiledRadius; z += 1)
52  {
53  if (!volume->IsInsideVolume(x, y, z))
54  {
55  continue;
56  }
57  double xDiff = x - xPos;
58  double yDiff = y - yPos;
59  double zDiff = z - zPos;
60  double vectorLengthDiff = radius - sqrt(xDiff*xDiff + yDiff*yDiff + zDiff*zDiff);
61 
62  if (vectorLengthDiff > 0)
63  {
64  volume->SetVolumeValues(x, y, z,
65  properties->GetAbsorptionCoefficient(),
66  properties->GetScatteringCoefficient(),
67  properties->GetAnisotopyCoefficient(),
68  mitk::pa::InSilicoTissueVolume::SegmentationType::VESSEL);
69  }
70  }
71 
72  totalWalkingDistance->Subtract(stepDirection);
73  fromPosition->Add(stepDirection);
74  }
75 
76  properties->SetPositionVector(fromPosition);
77 }
void ExpandAndDrawVesselInVolume(VesselProperties::Pointer properties, InSilicoTissueVolume::Pointer volume)