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

#include <phantom.h>

Inheritance diagram for Cube:
Inheritance graph
[legend]
Collaboration diagram for Cube:
Collaboration graph
[legend]

Public Member Functions

void prepare ()
 
void assign (const Cube &F)
 
int point_inside (const Matrix1D< double > &r, Matrix1D< double > &aux) const
 
double density_inside (const Matrix1D< double > &r, Matrix1D< double > &aux) const
 
Featurescale (double factor) const
 
 __attribute__ ((deprecated)) void scale(double factor
 
double intersection (const Matrix1D< double > &direction, const Matrix1D< double > &passing_point, Matrix1D< double > &r, Matrix1D< double > &u) const
 
double volume () const
 
void read_specific (char *line)
 
void read_specific (const std::vector< double > &vect)
 
void feat_printf (FILE *fh) const
 
void feat_printm (MetaData &MD, size_t id)
 
void init_rnd (double minXdim, double maxXdim, double minYdim=0, double maxYdim=0, double minZdim=0, double maxZdim=0, double minden=1.0, double maxden=1.0, double minx0=0, double maxx0=0, double miny0=0, double maxy0=0, double minz0=0, double maxz0=0, double minrot=0, double maxrot=360, double mintilt=0, double maxtilt=180, double minpsi=0, double maxpsi=360)
 
- Public Member Functions inherited from Oriented_Feature
void prepare_Euler ()
 
void assign (const Oriented_Feature &OF)
 
virtual void rotate (const Matrix2D< double > &E)
 
- Public Member Functions inherited from Feature
void assign (const Feature &F)
 
virtual void rotate_center (const Matrix2D< double > &E)
 
int point_inside (const Matrix1D< double > &r) const
 
int voxel_inside (const Matrix1D< double > &r, Matrix1D< double > &aux1, Matrix1D< double > &aux2) const
 
int voxel_inside (const Matrix1D< double > &r) const
 
double voxel_inside_by_normalized_density (const Matrix1D< double > &r, Matrix1D< double > &aux1, Matrix1D< double > &aux2) const
 
int intersects_sphere (const Matrix1D< double > &r, double radius, Matrix1D< double > &aux1, Matrix1D< double > &aux2, Matrix1D< double > &aux3) const
 
int intersects_sphere (const Matrix1D< double > &r, double radius) const
 
Featureencircle (double radius=0) const
 
Featurebackground (int back_mode, double back_param) const
 
double intersection (const Matrix1D< double > &direction, const Matrix1D< double > &passing_point) const
 
void mean_variance_in_plane (Image< double > *V, double z, double &mean, double &var)
 
void project_to (Projection &P, const Matrix2D< double > &VP, const Matrix2D< double > &PV) const
 
void corners (const MultidimArray< double > &V, Matrix1D< double > &corner1, Matrix1D< double > &corner2)
 
void draw_in (MultidimArray< double > &V, int color_mode=INTERNAL, double colour=-1)
 
void sketch_in (MultidimArray< double > &V, double colour=2)
 
void shift (double shiftX, double shiftY, double shiftZ)
 
void selfApplyGeometry (const Matrix2D< double > &A)
 
void readCommon (char *line)
 
void readCommon (MDRow &row)
 
void read (MDRow &row)
 

Public Attributes

double xdim
 X dimension before rotating. More...
 
double ydim
 Y dimension before rotating. More...
 
double zdim
 Z dimension before rotating. More...
 
Feature **_f const
 
- Public Attributes inherited from Oriented_Feature
double rot
 First Euler angle. More...
 
double tilt
 Second Euler angle. More...
 
double psi
 Third Euler angle. More...
 
Matrix2D< double > euler
 Euler matrix. More...
 
Matrix2D< double > eulert
 Inverse Euler matrix. More...
 
- Public Attributes inherited from Feature
std::string type
 
char add_assign
 
double density
 
Matrix1D< double > center
 
double max_distance
 

Friends

std::ostream & operator<< (std::ostream &o, const Cube &f)
 

Detailed Description

Cube. A cube is defined by its center, and the length in the 3 dimensions (X, Y and Z, before rotating), label="cub". The center of the cube is at the geometrical center, and the dimensions define the cube from "-Xdim/2" to "Xdim/2", ... around the center. Then the cube is rotated after the three Euler angles. The corresponding Euler matrix is stored in the field "euler" while its inverse is in "eulert".

A point (r) in the universal coordinate system, where cubes are defined in general, can be expressed (rp) with respect to a system where the cube is centered at the origin, all its dimensions are unity and its axes are aligned with XYZ by

V3_MINUS_V3(rp,r,cub.Center);
M3x3_BY_V3x1(rp,cub.euler,rp);
XX(rp) /= cub.xdim;
YY(rp) /= cub.ydim;
ZZ(rp) /= cub.zdim;

Directions (free vectors) are transformed in the same fashion except that for the first vector subtraction (referring the origin).

Definition at line 1010 of file phantom.h.

Member Function Documentation

◆ __attribute__()

Cube::__attribute__ ( (deprecated)  )

Another function for return a scaled cube.

◆ assign()

void Cube::assign ( const Cube F)

Another function for assignment.

Definition at line 133 of file phantom.cpp.

134 {
135  *this = F;
136 }

◆ density_inside()

double Cube::density_inside ( const Matrix1D< double > &  r,
Matrix1D< double > &  aux 
) const
inlinevirtual

Density inside an Cube. This function tells you the density of the cube at point r for constant valued features is trivial

Implements Feature.

Definition at line 1039 of file phantom.h.

1040  {
1041  return 1.;
1042  }

◆ feat_printf()

void Cube::feat_printf ( FILE *  fh) const
virtual

Print cube in the standard feature format. \ See {Feature::feat_printf}, Phantoms

Implements Feature.

Definition at line 500 of file phantom.cpp.

501 {
502  fprintf(fh, "cub %c %1.4f % 7.2f % 7.2f % 7.2f % 7.2f "
503  "% 7.2f % 7.2f % 7.2f % 7.2f % 7.2f\n",
505  xdim, ydim, zdim,
506  rot, tilt, psi);
507 }
double tilt
Second Euler angle.
Definition: phantom.h:430
Matrix1D< double > center
Definition: phantom.h:119
double density
Definition: phantom.h:114
char add_assign
Definition: phantom.h:108
#define XX(v)
Definition: matrix1d.h:85
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
#define YY(v)
Definition: matrix1d.h:93
double rot
First Euler angle.
Definition: phantom.h:427
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
double psi
Third Euler angle.
Definition: phantom.h:433
fprintf(glob_prnt.io, "\)
#define ZZ(v)
Definition: matrix1d.h:101
double xdim
X dimension before rotating.
Definition: phantom.h:1014

◆ feat_printm()

void Cube::feat_printm ( MetaData MD,
size_t  id 
)
virtual

Implements Feature.

Definition at line 510 of file phantom.cpp.

511 {
512  std::vector<double> FSVect;
513  FSVect.push_back(xdim);
514  FSVect.push_back(ydim);
515  FSVect.push_back(zdim);
516  FSVect.push_back(rot);
517  FSVect.push_back(tilt);
518  FSVect.push_back(psi);
520 }
double tilt
Second Euler angle.
Definition: phantom.h:430
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
Specific parameters for a feature (vector double)
bool setValue(const MDLabel label, const T &valueIn, size_t id)
double rot
First Euler angle.
Definition: phantom.h:427
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
double psi
Third Euler angle.
Definition: phantom.h:433
double xdim
X dimension before rotating.
Definition: phantom.h:1014

◆ init_rnd()

void Cube::init_rnd ( double  minXdim,
double  maxXdim,
double  minYdim = 0,
double  maxYdim = 0,
double  minZdim = 0,
double  maxZdim = 0,
double  minden = 1.0,
double  maxden = 1.0,
double  minx0 = 0,
double  maxx0 = 0,
double  miny0 = 0,
double  maxy0 = 0,
double  minz0 = 0,
double  maxz0 = 0,
double  minrot = 0,
double  maxrot = 360,
double  mintilt = 0,
double  maxtilt = 180,
double  minpsi = 0,
double  maxpsi = 360 
)

Generate a random cube. A cube is generated randomly within the range of the parameters given. Notice that most of them are set by default. The exact parameters are picked uniformly from the range. The maximum distance is adjusted properly according to the randomly generated feature. 'den' stands for density and (x0,y0,z0) is the center of the feature. The behaviour of the new sphere is always Add. If Ydim and Zdim ranges are restricted to 0, then it's applied the same range as for Xdim.

Definition at line 1813 of file phantom.cpp.

1824 {
1826  center.resize(3);
1827  type = "cub";
1828  add_assign = '+';
1829  density = rnd_unif(minden, maxden);
1830  XX(center) = rnd_unif(minx0, maxx0);
1831  YY(center) = rnd_unif(miny0, maxy0);
1832  ZZ(center) = rnd_unif(minz0, maxz0);
1833 
1834  if (minYdim == 0)
1835  minYdim = minXdim;
1836  if (minZdim == 0)
1837  minZdim = minXdim;
1838  if (maxYdim == 0)
1839  maxYdim = maxXdim;
1840  if (maxZdim == 0)
1841  maxZdim = maxXdim;
1842  xdim = rnd_unif(minXdim, maxXdim);
1843  ydim = rnd_unif(minYdim, maxYdim);
1844  zdim = rnd_unif(minZdim, maxZdim);
1845  rot = rnd_unif(minrot, maxrot);
1846  tilt = rnd_unif(mintilt, maxtilt);
1847  psi = rnd_unif(minpsi, maxpsi);
1849  eulert = euler.transpose();
1850 
1851  max_distance = sqrt(xdim * xdim + ydim * ydim + zdim * zdim);
1852 }
Matrix2D< double > eulert
Inverse Euler matrix.
Definition: phantom.h:439
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
Definition: geometry.cpp:624
double tilt
Second Euler angle.
Definition: phantom.h:430
Matrix2D< double > euler
Euler matrix.
Definition: phantom.h:436
void sqrt(Image< double > &op)
Matrix1D< double > center
Definition: phantom.h:119
double density
Definition: phantom.h:114
Matrix2D< T > transpose() const
Definition: matrix2d.cpp:1314
char add_assign
Definition: phantom.h:108
double rnd_unif()
#define XX(v)
Definition: matrix1d.h:85
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
double max_distance
Definition: phantom.h:126
#define YY(v)
Definition: matrix1d.h:93
std::string type
Definition: phantom.h:101
double rot
First Euler angle.
Definition: phantom.h:427
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
double psi
Third Euler angle.
Definition: phantom.h:433
unsigned int randomize_random_generator()
#define ZZ(v)
Definition: matrix1d.h:101
double xdim
X dimension before rotating.
Definition: phantom.h:1014

◆ intersection()

double Cube::intersection ( const Matrix1D< double > &  direction,
const Matrix1D< double > &  passing_point,
Matrix1D< double > &  r,
Matrix1D< double > &  u 
) const
virtual

Intersection of a ray with a cube, NOT IMPLEMENTED!!!. See Feature::intersection to know more about the parameters meaning.

Implements Feature.

Definition at line 1223 of file phantom.cpp.

1228 {
1229  double norm = direction.module();
1231 
1232  // Set the passing point in the cube coordinate system
1233  // and normalise to a unit cube
1234  V3_MINUS_V3(r, passing_point, center);
1235  M3x3_BY_V3x1(r, euler, r);
1236  XX(r) /= xdim;
1237  YY(r) /= ydim;
1238  ZZ(r) /= zdim;
1239 
1240  // Express also the direction in the cube coordinate system
1241  // and normalise to a unit cube
1242  M3x3_BY_V3x1(u, euler, direction);
1243  XX(u) /= xdim;
1244  YY(u) /= ydim;
1245  ZZ(u) /= zdim;
1246 
1247  return intersection_unit_cube(u, r) / norm;
1248 }
double module() const
Definition: matrix1d.h:983
Matrix2D< double > euler
Euler matrix.
Definition: phantom.h:436
#define V3_MINUS_V3(a, b, c)
Definition: matrix1d.h:202
Matrix1D< double > center
Definition: phantom.h:119
T norm(const std::vector< T > &v)
Definition: vector_ops.h:399
#define XX(v)
Definition: matrix1d.h:85
double intersection_unit_cube(const Matrix1D< double > &u, const Matrix1D< double > &r)
Definition: geometry.cpp:1190
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
#define M3x3_BY_V3x1(a, M, b)
Definition: matrix2d.h:170
#define YY(v)
Definition: matrix1d.h:93
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
#define ZZ(v)
Definition: matrix1d.h:101
double xdim
X dimension before rotating.
Definition: phantom.h:1014
#define SPEED_UP_temps012
Definition: xmipp_macros.h:403

◆ point_inside()

int Cube::point_inside ( const Matrix1D< double > &  r,
Matrix1D< double > &  aux 
) const
virtual

Speeded up point inside a cube. This function tells you if a point is inside the cube or not. See Feature::point_inside

Implements Feature.

Definition at line 778 of file phantom.cpp.

779 {
781 
782  // Express r in the feature coord. system
783  V3_MINUS_V3(aux, r, center);
784  M3x3_BY_V3x1(aux, euler, aux);
785 
786  // Check if inside
787  if (ABS(XX(aux)) <= xdim / 2 && ABS(YY(aux)) <= ydim / 2 &&
788  ABS(ZZ(aux)) <= zdim / 2)
789  return 1;
790  return 0;
791 }
Matrix2D< double > euler
Euler matrix.
Definition: phantom.h:436
#define V3_MINUS_V3(a, b, c)
Definition: matrix1d.h:202
Matrix1D< double > center
Definition: phantom.h:119
#define XX(v)
Definition: matrix1d.h:85
#define ABS(x)
Definition: xmipp_macros.h:142
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
#define M3x3_BY_V3x1(a, M, b)
Definition: matrix2d.h:170
#define YY(v)
Definition: matrix1d.h:93
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
#define ZZ(v)
Definition: matrix1d.h:101
double xdim
X dimension before rotating.
Definition: phantom.h:1014
#define SPEED_UP_temps012
Definition: xmipp_macros.h:403

◆ prepare()

void Cube::prepare ( )
virtual

Prepare cube for work. Computes the maximum distance, in this case, equal to "sqrt(xdim*xdim+ydim*ydim+zdim*zdim)", and computes the Euler and inverse Euler matrices as a function of the Euler angles

Implements Feature.

Definition at line 71 of file phantom.cpp.

72 {
73  prepare_Euler();
74  max_distance = sqrt(xdim * xdim + ydim * ydim + zdim * zdim);
75 }
void sqrt(Image< double > &op)
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
double max_distance
Definition: phantom.h:126
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
void prepare_Euler()
Definition: phantom.cpp:102
double xdim
X dimension before rotating.
Definition: phantom.h:1014

◆ read_specific() [1/2]

void Cube::read_specific ( char *  line)

Read specific description for a cube. An exception is thrown if the line doesn't conform the standard specification. See Feature::read_specific

Definition at line 332 of file phantom.cpp.

333 {
334  int stat;
335  stat = sscanf(line, "%*s %*c %*f %*f %*f %*f %lf %lf %lf %lf %lf %lf",
336  &xdim, &ydim, &zdim, &rot, &tilt, &psi);
337  if (stat != 6)
338  REPORT_ERROR(ERR_IO_NOREAD, (std::string)"Error when reading a cube" + line);
339  prepare();
340 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double tilt
Second Euler angle.
Definition: phantom.h:430
void prepare()
Definition: phantom.cpp:71
Couldn&#39;t read from file.
Definition: xmipp_error.h:139
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
double rot
First Euler angle.
Definition: phantom.h:427
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
double psi
Third Euler angle.
Definition: phantom.h:433
double xdim
X dimension before rotating.
Definition: phantom.h:1014

◆ read_specific() [2/2]

void Cube::read_specific ( const std::vector< double > &  vector)
virtual

Read a feature from a file, VIRTUAL!!!. The format must be the one given in Phantoms, and each subclass must implement its own I/O routines. These routines must fill only the non common part of the feature description, but they receive the whole line with the description.

Implements Feature.

Definition at line 343 of file phantom.cpp.

344 {
345  if (vect.size() != 6)
346  REPORT_ERROR(ERR_IO_NOREAD, (std::string)"Error when reading a cube");
347  xdim = vect[0];
348  ydim = vect[1];
349  zdim = vect[2];
350  rot = vect[3];
351  tilt = vect[4];
352  psi = vect[5];
353  prepare();
354 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double tilt
Second Euler angle.
Definition: phantom.h:430
void prepare()
Definition: phantom.cpp:71
Couldn&#39;t read from file.
Definition: xmipp_error.h:139
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
double rot
First Euler angle.
Definition: phantom.h:427
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
double psi
Third Euler angle.
Definition: phantom.h:433
double xdim
X dimension before rotating.
Definition: phantom.h:1014

◆ scale()

void Cube::scale ( double  factor) const
virtual

Return a scaled cube. The center, density, angles and behaviour of the new cube is exactly the same as the actual one. The dimensions are multiplied by the scale factor and the maximum distance is recalculated for the new cube.

Implements Feature.

Definition at line 1579 of file phantom.cpp.

1580 {
1581  Cube *f;
1582  f = new Cube;
1584  COPY_ANGLES;
1585 
1586  f->xdim = factor * xdim;
1587  f->ydim = factor * ydim;
1588  f->zdim = factor * zdim;
1589  f->prepare();
1590  return (Feature *)f;
1591 }
void prepare()
Definition: phantom.cpp:71
#define COPY_COMMON_PART
Definition: phantom.cpp:1473
double * f
Definition: phantom.h:1010
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
#define COPY_ANGLES
Definition: phantom.cpp:1479
double xdim
X dimension before rotating.
Definition: phantom.h:1014

◆ volume()

double Cube::volume ( ) const
inlinevirtual

Volume of a cube. This function returns xdim*ydim*zdim. See Feature::volume

Implements Feature.

Definition at line 1063 of file phantom.h.

1064  {
1065  return xdim*ydim*zdim;
1066  }
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
double xdim
X dimension before rotating.
Definition: phantom.h:1014

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  o,
const Cube f 
)
friend

Show feature not in the standard format but more informatively. This function only shows the non common part of the feature. Use the << operator of Feature to show the whole feature.

Definition at line 646 of file phantom.cpp.

647 {
648  o << " Xdim: " << f.xdim << std::endl;
649  o << " Ydim: " << f.ydim << std::endl;
650  o << " Zdim: " << f.zdim << std::endl;
651  o << " Rot: " << f.rot << std::endl;
652  o << " Tilt: " << f.tilt << std::endl;
653  o << " Psi: " << f.psi << std::endl;
654  return o;
655 }
double tilt
Second Euler angle.
Definition: phantom.h:430
double ydim
Y dimension before rotating.
Definition: phantom.h:1017
double rot
First Euler angle.
Definition: phantom.h:427
double zdim
Z dimension before rotating.
Definition: phantom.h:1020
double psi
Third Euler angle.
Definition: phantom.h:433
double xdim
X dimension before rotating.
Definition: phantom.h:1014

Member Data Documentation

◆ const

Feature** _f Cube::const

Definition at line 1051 of file phantom.h.

◆ xdim

double Cube::xdim

X dimension before rotating.

Definition at line 1014 of file phantom.h.

◆ ydim

double Cube::ydim

Y dimension before rotating.

Definition at line 1017 of file phantom.h.

◆ zdim

double Cube::zdim

Z dimension before rotating.

Definition at line 1020 of file phantom.h.


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