Commit 3ab625cb by maarten

fixed hanging bug (infinite loop caused by invalid cell)

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@490 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 2583975a
...@@ -87,15 +87,21 @@ clipper::Coord_orth DistanceMap::CalculateOffsetForCell(const Structure& p, cons ...@@ -87,15 +87,21 @@ clipper::Coord_orth DistanceMap::CalculateOffsetForCell(const Structure& p, cons
auto calculateD = [&](float m, float c) auto calculateD = [&](float m, float c)
{ {
float d = 0; float d = 0;
if (c != 0)
{
while (m + d < -(c / 2)) while (m + d < -(c / 2))
d += c; d += c;
while (m + d > (c / 2)) while (m + d > (c / 2))
d -= c; d -= c;
}
return d; return d;
}; };
Point D; Point D;
if (cell.a() == 0 or cell.b() == 0 or cell.c() == 0)
throw runtime_error("Invalid cell, contains a dimension that is zero");
D.mX = calculateD(mx, cell.a()); D.mX = calculateD(mx, cell.a());
D.mY = calculateD(my, cell.b()); D.mY = calculateD(my, cell.b());
D.mZ = calculateD(mz, cell.c()); D.mZ = calculateD(mz, cell.c());
......
...@@ -76,13 +76,20 @@ clipper::Coord_orth CalculateOffsetForCell(const Structure& p, const clipper::Sp ...@@ -76,13 +76,20 @@ clipper::Coord_orth CalculateOffsetForCell(const Structure& p, const clipper::Sp
auto calculateD = [&](float m, float c) auto calculateD = [&](float m, float c)
{ {
float d = 0; float d = 0;
assert(c != 0);
if (c != 0)
{
while (m + d < -(c / 2)) while (m + d < -(c / 2))
d += c; d += c;
while (m + d > (c / 2)) while (m + d > (c / 2))
d -= c; d -= c;
}
return d; return d;
}; };
if (cell.a() == 0 or cell.b() == 0 or cell.c() == 0)
throw runtime_error("Invalid cell, contains a dimension that is zero");
Point D; Point D;
D.mX = calculateD(mx, cell.a()); D.mX = calculateD(mx, cell.a());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment