Xmipp  v3.23.11-Nereus
Classes | Macros | Functions | Variables
test_transform_window.cpp File Reference
#include <stdlib.h>
#include <core/xmipp_image.h>
#include <core/xmipp_image_extension.h>
#include <iostream>
#include <gtest/gtest.h>
#include <data/phantom.h>
#include <core/xmipp_program.h>
#include <cstdio>
#include <unistd.h>
Include dependency graph for test_transform_window.cpp:

Go to the source code of this file.

Classes

class  TransformWindowTest
 

Macros

#define DEBUG
 

Functions

 TEST_F (TransformWindowTest, unitcell)
 

Variables

const char ico_i2 []
 

Macro Definition Documentation

◆ DEBUG

#define DEBUG

Function Documentation

◆ TEST_F()

TEST_F ( TransformWindowTest  ,
unitcell   
)

Definition at line 117 of file test_transform_window.cpp.

118 {
119  //create phantom volume
120  char filename[] = "/tmp/mytemp.XXXXXX"; // template for our file.
121  int fd = mkstemp(filename); // Creates and opens a new temp file r/w.
122  // Xs are replaced with a unique number.
123 #define DEBUG
124 #ifdef DEBUG
125  std::cerr << "filename: " << filename << std::endl;
126 #endif
127  if (fd == -1) {
128  std::cerr << " cannot open temporary file" << std::endl;
129  ASSERT_TRUE(false);
130  return;
131  }
132  if (write(fd, ico_i2,sizeof(ico_i2)) == -1) FAIL() << "Could not write to file " << filename;
133 
134  Phantom phantom;
135  Image<double> vol;
136  const char inFn[] = "/tmp/inTransformWindowTest.mrc";
137  const char outFn[] ="/tmp/outTransformWindowTest.mrc";
138  phantom.read(filename);
139  phantom.draw_in(vol());
140  vol().addNoise(0,0.1,"gaussian");
141  vol.write(inFn);
142  //transform window is not in a library as it should be
143  //so I need to make a system call
144  char commandBuff[180];
145 
146  snprintf(commandBuff, sizeof(commandBuff),
147  "xmipp_transform_window -i %s -o %s --unitcell i2 80 140 .25 0",
148  inFn, outFn);
149  ASSERT_EQ(0, system(commandBuff));
150 #ifdef DEBUG
151  std::cerr << "commandBuff: " << commandBuff << std::endl;
152 #endif
153 #ifndef DEBUG
154  unlink(inFn);
155  unlink(outFn);
156  unlink(filename);
157 #endif
158  ASSERT_TRUE(true);
159 #undef DEBUG
160 }
const char ico_i2[]
void write(std::ostream &os, const datablock &db)
Definition: cif2pdb.cpp:3747
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1893
#define ASSERT_TRUE(condition)
Definition: gtest.h:1810
void draw_in(MultidimArray< double > &V)
Definition: phantom.cpp:2432
void read(const FileName &fn_phantom, bool apply_scale=true)
Definition: phantom.cpp:2088
#define FAIL()
Definition: gtest.h:1749

Variable Documentation

◆ ico_i2

const char ico_i2[]

Definition at line 13 of file test_transform_window.cpp.