File: SymOp.cpp

package info (click to toggle)
pymol 2.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 42,288 kB
  • sloc: cpp: 476,472; python: 76,538; ansic: 29,510; javascript: 6,792; sh: 47; makefile: 24
file content (41 lines) | stat: -rw-r--r-- 660 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
 * @file Symmetry operation stuff
 *
 * (c) Schrodinger, Inc.
 */

#include "SymOp.h"

#include <cassert>
#include <cstdio>

namespace pymol
{

bool SymOp::reset(const char* code)
{
  assert(code);

  auto n = std::sscanf(code, "%hhu_%c%c%c", &index, &x, &y, &z);

  index = (n > 0) ? (index - 1) : 0;

  if (n < 4) {
    x = y = z = 0;
  } else {
    x -= static_cast<signed char>('5');
    y -= static_cast<signed char>('5');
    z -= static_cast<signed char>('5');
  }

  return true;
}

std::string SymOp::to_string() const
{
  char code[8];
  std::snprintf(code, 8, "%u_%d%d%d", index + 1, x + 5, y + 5, z + 5);
  return code;
}

} // namespace pymol