Xmipp  v3.23.11-Nereus
Public Member Functions | Friends | List of all members
Grid Class Reference

#include <grids.h>

Public Member Functions

void add_grid (const SimpleGrid &SG)
 
const SimpleGridoperator() (size_t n) const
 
SimpleGridoperator() (size_t n)
 
void get_SimpleGrid (int n, SimpleGrid &G) const
 
size_t GridsNo () const
 
void assign (const Grid &G)
 
void clear ()
 
void voxel_corners (Matrix1D< double > &Gcorner1, Matrix1D< double > &Gcorner2, const Matrix2D< double > *V=nullptr) const
 

Friends

std::ostream & operator<< (std::ostream &o, const Grid &grid)
 

Detailed Description

Complex Grids. Grid is the structure where "true" grids like (BCC, FCC, CC, ...) are stored. A complex grid is nothing else than a list of Simple Grids, and this is so because a complex grid is supposed to be the superposition of several simple grids, each one with all the information that a SimpleGrid has got. When projecting the volume or whatever what you must do is to project each simple grid, or apply the function you want to each simple grid. For instance, here you have a function to show a complex grid

std::ostream& operator << (std::ostream& o, Grid &grid) {
o << "Complex Grid -------------------------------------\n";
for (int i=0; i<grid.GridsNo(); i++) o << grid(i);
return o;
}

Initially the complex grid is empty, and you must fill it adding new simple grids to it with the function Grid::add_grid . The simple grids must be prepared to work before entering into the complex one.

Definition at line 479 of file grids.h.

Member Function Documentation

◆ add_grid()

void Grid::add_grid ( const SimpleGrid SG)
inline

Add a grid to the set. The complex grid is a list of simple grids, use this function to add a simple grid to the complex one, remember that before using this function the simple grid must have been prepared to work (see SimpleGrid::prepare_grid ). See class documentation for an example of use.

Definition at line 491 of file grids.h.

492  {
493  LG.push_back(SG);
494  }

◆ assign()

void Grid::assign ( const Grid G)
inline

Another function for assignment.

Definition at line 553 of file grids.h.

554  {
555  *this = G;
556  }

◆ clear()

void Grid::clear ( )
inline

Clear.

Definition at line 559 of file grids.h.

560  {
561  LG.clear();
562  }

◆ get_SimpleGrid()

void Grid::get_SimpleGrid ( int  n,
SimpleGrid G 
) const
inline

Another function for get a "pointer" to a simple grid.

Definition at line 527 of file grids.h.

528  {
529  G = (*this)(n);
530  }
int * n

◆ GridsNo()

size_t Grid::GridsNo ( ) const
inline

Number of simple grids inside. This function returns the number of simple grids inside the complex grid. \ Ex: std::cout << "In BCC there are " << BCC.GridsNo() << " grids\n";

Definition at line 536 of file grids.h.

537  {
538  return LG.size();
539  }

◆ operator()() [1/2]

const SimpleGrid& Grid::operator() ( size_t  n) const
inline

Get a constant "pointer" to a simple grid. The complex grid is built upon the STL vectors, using this function you can access (constant access, you cannot modify the simple grid) any of the simple grids inside the list. Remember that the first grid is the number 0. An exception is thrown if you try to access a simple grid beyond the number of actual simple grids inside the complex one. \ Ex: std::cout << "The first grid in the BCC grid is " << BCC(0);

Definition at line 504 of file grids.h.

505  {
506  if (n>LG.size())
507  REPORT_ERROR(ERR_VALUE_INCORRECT, "The Grid hasn't got so many Simple Grids");
508  return LG[n];
509  }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Incorrect value received.
Definition: xmipp_error.h:195
int * n

◆ operator()() [2/2]

SimpleGrid& Grid::operator() ( size_t  n)
inline

Get a "pointer" to a simple grid. The complex grid is built upon the STL vectors, using this function you can access any of the simple grids inside the list. Remember that the first grid is the number 0. An exception is thrown if you try to access a simple grid beyond the number of actual simple grids inside the complex one. \ Ex: BCC(0).origin=vectorR3(1,1,1);

Definition at line 519 of file grids.h.

520  {
521  if (n>LG.size())
522  REPORT_ERROR(ERR_VALUE_INCORRECT, "The Grid hasn't got so many Simple Grids");
523  return LG[n];
524  }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Incorrect value received.
Definition: xmipp_error.h:195
int * n

◆ voxel_corners()

void Grid::voxel_corners ( Matrix1D< double > &  Gcorner1,
Matrix1D< double > &  Gcorner2,
const Matrix2D< double > *  V = nullptr 
) const

Minimum size for a voxel volume if it is to hold the whole grid. The returned vectors Gcorner1 and Gcorner2 enclose this grid. You can supply a deformation matrix (see blobs2voxels )

Definition at line 120 of file grids.cpp.

122 {
123  Matrix1D<double> SGcorner1(3); // Subgrid corners
124  Matrix1D<double> SGcorner2(3); // Subgrid corners
126 
127  // Look for the lowest and highest volume coordinate
128  Gcorner1.resize(3); // lowest and highest coord.
129  Gcorner2.resize(3);
130  for (size_t n = 0; n < GridsNo(); n++)
131  {
132  // Find box for this grid
133  bool first;
134  first = true;
135  for (auto k = (int)ZZ(LG[n].lowest); k <= ZZ(LG[n].highest); k++)
136  for (auto i = (int)YY(LG[n].lowest); i <= YY(LG[n].highest); i++)
137  for (auto j = (int)XX(LG[n].lowest); j <= XX(LG[n].highest); j++)
138  {
139  Matrix1D<double> grid_index(3);
140  Matrix1D<double> univ_position(3);
141  VECTOR_R3(grid_index, j, i, k);
142  LG[n].grid2universe(grid_index, univ_position);
143  if (V != nullptr)
144  {
145  M3x3_BY_V3x1(univ_position, *V, univ_position);
146  }
147  if (!LG[n].is_interesting(univ_position)) continue;
148  if (!first)
149  {
150  XX(SGcorner1) = XMIPP_MIN(XX(SGcorner1), XX(univ_position));
151  YY(SGcorner1) = XMIPP_MIN(YY(SGcorner1), YY(univ_position));
152  ZZ(SGcorner1) = XMIPP_MIN(ZZ(SGcorner1), ZZ(univ_position));
153 
154  XX(SGcorner2) = XMIPP_MAX(XX(SGcorner2), XX(univ_position));
155  YY(SGcorner2) = XMIPP_MAX(YY(SGcorner2), YY(univ_position));
156  ZZ(SGcorner2) = XMIPP_MAX(ZZ(SGcorner2), ZZ(univ_position));
157  }
158  else
159  {
160  SGcorner2 = SGcorner1 = univ_position;
161  first = false;
162  }
163  }
164 
165  // Compare with the rest of the grids
166  if (n != 0)
167  {
168  XX(Gcorner1) = XMIPP_MIN(XX(Gcorner1), XX(SGcorner1));
169  YY(Gcorner1) = XMIPP_MIN(YY(Gcorner1), YY(SGcorner1));
170  ZZ(Gcorner1) = XMIPP_MIN(ZZ(Gcorner1), ZZ(SGcorner1));
171 
172  XX(Gcorner2) = XMIPP_MAX(XX(Gcorner2), XX(SGcorner2));
173  YY(Gcorner2) = XMIPP_MAX(YY(Gcorner2), YY(SGcorner2));
174  ZZ(Gcorner2) = XMIPP_MAX(ZZ(Gcorner2), ZZ(SGcorner2));
175  }
176  else
177  {
178  Gcorner1 = SGcorner1;
179  Gcorner2 = SGcorner2;
180  }
181 
182 #ifdef DEBUG
183  std::cout << LG[n];
184  std::cout << "SGcorner1 " << SGcorner1.transpose() << std::endl;
185  std::cout << "SGcorner2 " << SGcorner2.transpose() << std::endl;
186  std::cout << "Gcorner1 " << Gcorner1.transpose() << std::endl;
187  std::cout << "Gcorner2 " << Gcorner2.transpose() << std::endl;
188 #endif
189  }
190 }
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
size_t GridsNo() const
Definition: grids.h:536
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
Matrix1D< T > transpose() const
Definition: matrix1d.cpp:644
glob_log first
#define XX(v)
Definition: matrix1d.h:85
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
#define j
#define M3x3_BY_V3x1(a, M, b)
Definition: matrix2d.h:170
#define YY(v)
Definition: matrix1d.h:93
#define VECTOR_R3(v, x, y, z)
Definition: matrix1d.h:124
int * n
#define ZZ(v)
Definition: matrix1d.h:101
#define SPEED_UP_temps012
Definition: xmipp_macros.h:403

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  o,
const Grid grid 
)
friend

Show a complex grid. Show all simple grids inside the complex one. \ Ex: std::cout << BCC;

Definition at line 544 of file grids.h.

545  {
546  o << "Complex Grid -------------------------------------\n";
547  for (size_t i = 0; i < grid.GridsNo(); i++)
548  o << grid(i);
549  return o;
550  }
size_t GridsNo() const
Definition: grids.h:536
#define i

The documentation for this class was generated from the following files: