comparison OrthancStone/Sources/Toolbox/DicomStructureSet.cpp @ 1890:6ce81914f7e4

added classes BucketAccumulator1D/2D
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 18 Jan 2022 22:08:55 +0100
parents ddaee6b96501
children cdf91ad891a5
comparison
equal deleted inserted replaced
1889:fe4befc9c2b0 1890:6ce81914f7e4
1107 { 1107 {
1108 target.push_back(it->GetPoints()); 1108 target.push_back(it->GetPoints());
1109 } 1109 }
1110 } 1110 }
1111 } 1111 }
1112
1113
1114 void DicomStructureSet::Test()
1115 {
1116 printf("OK\n");
1117
1118 for (size_t i = 0; i < structures_.size(); i++)
1119 {
1120 const Polygons& polygons = structures_[i].polygons_;
1121
1122 for (Polygons::const_iterator it = polygons.begin(); it != polygons.end(); ++it)
1123 {
1124 const Points& points = it->GetPoints();
1125
1126 if (points.size() >= 3)
1127 {
1128 const Vector& a = points[0];
1129 const Vector& b = points[1];
1130 const Vector& c = points[2];
1131 Vector n;
1132 LinearAlgebra::CrossProduct(n, b - a, c - a);
1133 LinearAlgebra::NormalizeVector(n);
1134 if (n[2] < 0)
1135 n = -n;
1136 //LinearAlgebra::Print(n);
1137
1138 // https://en.wikipedia.org/wiki/Vector_fields_in_cylindrical_and_spherical_coordinates#Vector_fields_2
1139 double r = 1.0;
1140 double theta = acos(n[2]);
1141 double phi = atan(n[1]);
1142 printf("%.02f %.02f %.02f => ", n[0], n[1], n[2]);
1143 printf("%.02f %.02f =>", theta, phi);
1144 printf("%.02f %.02f %.02f\n", r * sin(theta) * cos(phi), r * sin(theta) * sin(phi), r * cos(theta));
1145 }
1146 }
1147 }
1148 }
1112 } 1149 }