Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 241f4afb authored by kraus's avatar kraus
Browse files

fixing bounding box of dipoles

parent a41bd0b0
No related branches found
No related tags found
No related merge requests found
......@@ -402,23 +402,6 @@ void OrbitThreader::computeBoundingBox() {
ElementBase::BoundingBox other = it->getBoundingBoxInLabCoords();
globalBoundingBox_m.getCombinedBoundingBox(other);
}
Vector_t const& X = globalBoundingBox_m.lowerLeftCorner;
Vector_t const& Y = globalBoundingBox_m.upperRightCorner;
Vector_t delta = Y - X;
Vector_t dX(delta(0), 0, 0), dY(0, delta(1), 0), dZ(0, 0, delta(2));
std::vector<Vector_t> corners{X, X + dX, X + dX + dY, X + dY, Y, Y - dX, Y - dX - dY, Y - dY};
std::vector<std::vector<unsigned int>> paths{{0, 1, 2, 3}, {4, 5, 6, 7}, {0, 1, 7, 6}, {1, 2, 4, 7}, {2, 3, 5, 4}, {3, 0, 6, 5}};
std::ofstream out("boundingBox.gpl");
std::ofstream traj("trajectories.gpl");
for (std::vector<unsigned int> const& path: paths) {
for (unsigned int i = 0; i < 5; ++ i) {
Vector_t const& point = corners[path[i % 4]];
out << point(0) << "\t" << point(1) << "\t" << point(2) << std::endl;
}
out << std::endl;
}
}
double OrbitThreader::computeDriftLengthToBoundingBox(const std::set<std::shared_ptr<Component>> & elements,
......
......@@ -1695,28 +1695,23 @@ ElementBase::BoundingBox Bend2D::getBoundingBoxInLabCoords() const {
CoordinateSystemTrafo toBegin = getEdgeToBegin() * csTrafoGlobal2Local_m;
CoordinateSystemTrafo toEnd = getEdgeToEnd() * csTrafoGlobal2Local_m;
const double &x = aperture_m.second[0];
const double &y = aperture_m.second[1];
std::vector<Vector_t> corners(8);
for (int i = -1; i < 2; i += 2) {
for (int j = -1; j < 2; j += 2) {
unsigned int idx = (i + 1)/2 + (j + 1);
corners[idx] = toBegin.transformFrom(Vector_t(i * x, j * y, 0.0));
corners[idx + 4] = toEnd.transformFrom(Vector_t(i * x, j * y, 0.0));
}
}
std::vector<Vector_t> outline = getOutline();
BoundingBox bb;
bb.lowerLeftCorner = bb.upperRightCorner = corners[0];
bb.lowerLeftCorner = std::numeric_limits<double>::max();
bb.upperRightCorner = std::numeric_limits<double>::lowest();
for (unsigned int i = 1; i < 8u; ++ i) {
for (unsigned int d; d < 3u; ++ d) {
if (bb.lowerLeftCorner(d) > corners[i](d)) {
bb.lowerLeftCorner(d) = corners[i](d);
}
if (bb.upperRightCorner(d) < corners[i](d)) {
bb.upperRightCorner(d) = corners[i](d);
Vector_t dY(0, 0.5 * getFullGap(), 0);
for (int i = -1; i < 2; i += 2) {
for (const Vector_t & vec: outline) {
Vector_t vecInLabCoords = csTrafoGlobal2Local_m.transformFrom(vec + i * dY);
for (unsigned int d = 0; d < 3; ++ d) {
if (vecInLabCoords(d) < bb.lowerLeftCorner(d)) {
bb.lowerLeftCorner(d) = vecInLabCoords(d);
}
if (vecInLabCoords(d) > bb.upperRightCorner(d)) {
bb.upperRightCorner(d) = vecInLabCoords(d);
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment