本文整理汇总了C++中Projection::height方法的典型用法代码示例。如果您正苦于以下问题:C++ Projection::height方法的具体用法?C++ Projection::height怎么用?C++ Projection::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projection
的用法示例。
在下文中一共展示了Projection::height方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup_draw
void Slice::setup_draw (int axis, Projection& with_projection)
{
// info for projection:
float fov = FOV() / (float) (with_projection.width()+with_projection.height());
float depth = 2.0 * std::max (std::max (
image()->header().vox(0) * image()->header().dim(0),
image()->header().vox(1) * image()->header().dim(1)),
image()->header().vox(2) * image()->header().dim(2));
// set up projection & modelview matrices:
GL::mat4 P = GL::ortho (
-with_projection.width()*fov, with_projection.width()*fov,
-with_projection.height()*fov, with_projection.height()*fov,
-depth, depth);
GL::mat4 M = snap_to_image() ? GL::mat4 (image()->interp.image2scanner_matrix()) : GL::mat4 (orientation());
GL::mat4 MV = adjust_projection_matrix (M, axis) * GL::translate (-target());
with_projection.set (MV, P);
}
示例2: update_interp_image_buffer
void AbstractFixel::update_interp_image_buffer (const Projection& projection,
const MR::Image::ConstHeader &fixel_header,
const MR::Image::Transform &header_transform)
{
// Code below "inspired" by ODF::draw
Point<> p (Window::main->target());
p += projection.screen_normal() * (projection.screen_normal().dot (Window::main->focus() - p));
p = header_transform.scanner2voxel (p);
if (fixel_tool.do_lock_to_grid) {
p[0] = (int)std::round (p[0]);
p[1] = (int)std::round (p[1]);
p[2] = (int)std::round (p[2]);
}
p = header_transform.voxel2scanner (p);
const MR::Image::Info& header_info = fixel_header.info();
Point<> x_dir = projection.screen_to_model_direction (1.0f, 0.0f, projection.depth_of (p));
x_dir.normalise();
x_dir = header_transform.scanner2image_dir (x_dir);
x_dir[0] *= header_info.vox(0);
x_dir[1] *= header_info.vox(1);
x_dir[2] *= header_info.vox(2);
x_dir = header_transform.image2scanner_dir (x_dir);
Point<> y_dir = projection.screen_to_model_direction (0.0f, 1.0f, projection.depth_of (p));
y_dir.normalise();
y_dir = header_transform.scanner2image_dir (y_dir);
y_dir[0] *= header_info.vox(0);
y_dir[1] *= header_info.vox(1);
y_dir[2] *= header_info.vox(2);
y_dir = header_transform.image2scanner_dir (y_dir);
Point<> x_width = projection.screen_to_model_direction (projection.width()/2.0f, 0.0f, projection.depth_of (p));
int nx = std::ceil (x_width.norm() / x_dir.norm());
Point<> y_width = projection.screen_to_model_direction (0.0f, projection.height()/2.0f, projection.depth_of (p));
int ny = std::ceil (y_width.norm() / y_dir.norm());
regular_grid_buffer_pos.clear();
regular_grid_buffer_dir.clear();
regular_grid_buffer_val.clear();
for (int y = -ny; y <= ny; ++y) {
for (int x = -nx; x <= nx; ++x) {
Point<> scanner_pos = p + float(x)*x_dir + float(y)*y_dir;
Point<> voxel_pos = header_transform.scanner2voxel(scanner_pos);
// Round to nearest neighbour
voxel_pos[0] = (int)std::round (voxel_pos[0]);
voxel_pos[1] = (int)std::round (voxel_pos[1]);
voxel_pos[2] = (int)std::round (voxel_pos[2]);
// Find and add point indices that correspond to projected voxel
const auto &voxel_indices = voxel_to_indices_map[voxel_pos];
// Load all corresponding fixel data into separate buffer
// We can't reuse original buffer because off-axis rendering means that
// two or more points in our regular grid may correspond to the same nearest voxel
for(const GLsizei index : voxel_indices) {
regular_grid_buffer_pos.push_back(scanner_pos);
regular_grid_buffer_dir.push_back(buffer_dir[index]);
regular_grid_buffer_val.push_back(buffer_val[2 * index]);
regular_grid_buffer_val.push_back(buffer_val[(2 * index) + 1]);
}
}
}
if(!regular_grid_buffer_pos.size())
return;
regular_grid_vao.bind();
regular_grid_vertex_buffer.bind (gl::ARRAY_BUFFER);
gl::BufferData (gl::ARRAY_BUFFER, regular_grid_buffer_pos.size() * sizeof(Point<float>),
®ular_grid_buffer_pos[0], gl::DYNAMIC_DRAW);
gl::EnableVertexAttribArray (0);
gl::VertexAttribPointer (0, 3, gl::FLOAT, gl::FALSE_, 0, (void*)0);
// fixel directions
regular_grid_dir_buffer.bind (gl::ARRAY_BUFFER);
gl::BufferData (gl::ARRAY_BUFFER, regular_grid_buffer_dir.size() * sizeof(Point<float>),
®ular_grid_buffer_dir[0], gl::DYNAMIC_DRAW);
gl::EnableVertexAttribArray (1);
gl::VertexAttribPointer (1, 3, gl::FLOAT, gl::FALSE_, 0, (void*)0);
// fixel sizes and values
regular_grid_val_buffer.bind (gl::ARRAY_BUFFER);
gl::BufferData (gl::ARRAY_BUFFER, regular_grid_buffer_val.size() * sizeof(float),
®ular_grid_buffer_val[0], gl::DYNAMIC_DRAW);
gl::EnableVertexAttribArray (2);
gl::VertexAttribPointer (2, 2, gl::FLOAT, gl::FALSE_, 0, (void*)0);
}