108 :
MeshRemapper(m_pano_in, image, visualization_state_in)
196 for (
short unsigned int x = 0; x < 2; x++)
198 for (
short unsigned int y = 0; y < 2; y++)
214 for (
short unsigned int x = 0; x < 2; x++)
216 for (
short unsigned int y = 0; y < 2; y++)
312 unsigned int stretch_x,
unsigned stretch_y)
316 unsigned int x, y, row_size, depth;
327 for (
unsigned short int i = 0; i < 2; i++)
329 for (
unsigned short int j = 0; j < 2; j++)
336 node->
verts[i][j][1],
342 if (i == x %2 && j == y%2 && depth)
345 node->
verts[i][j][0] = parent->verts[i][j][0];
346 node->
verts[i][j][1] = parent->verts[i][j][1];
348 }
else if (x % 2 && !i) {
350 node->
verts[0][j][0] = left->verts[1][j][0];
351 node->
verts[0][j][1] = left->verts[1][j][1];
353 }
else if (y % 2 && !j) {
355 node->
verts[i][0][0] = top->verts[i][1][0];
356 node->
verts[i][0][1] = top->verts[i][1][1];
364 y + j * (1 << stretch_y),
365 depth, x, y, node->
verts[i][j][0],
366 node->
verts[i][j][1]))
371 node->
verts[i][j][1],
396 node->
verts[i][1][0] = (parent->verts[0][1][0]
397 + parent->verts[1][1][0]) / 2.0;
398 node->
verts[i][1][1] = (parent->verts[0][1][1]
399 + parent->verts[1][1][1]) / 2.0;
409 node->
verts[1][j][0] = (parent->verts[1][0][0]
410 + parent->verts[1][1][0]) / 2.0;
411 node->
verts[1][j][1] = (parent->verts[1][0][1]
412 + parent->verts[1][1][1]) / 2.0;
426 for (
unsigned int i = 0; i < 2; i++)
428 for (
unsigned int j = 0; j < 2; j++)
457 stretch_x, stretch_y);
462 stretch_x, stretch_y);
468 stretch_x, stretch_y);
473 stretch_x, stretch_y);
482 unsigned int x, y, row_size, depth;
484 unsigned short int flags = 0;
503 do_not_split_x =
true;
504 do_not_split_y =
true;
510 do_not_split_x =
true;
514 do_not_split_y =
true;
520 do_not_split_x =
true;
524 do_not_split_y =
true;
535 if (ang_x < 0) ang_x = -ang_x;
536 if (ang_x >
M_PI) ang_x = 2 *
M_PI - ang_x;
537 float length_difference_x
539 if (length_difference_x < 0.0)
541 length_difference_x = -length_difference_x;
545 do_not_split_x =
true;
548 if (ang_y < 0) ang_y = -ang_y;
549 if (ang_y >
M_PI) ang_y = 2 *
M_PI - ang_y;
550 float length_difference_y
552 if (length_difference_y < 0.0)
554 length_difference_y = -length_difference_y;
558 do_not_split_y =
true;
569 bool all_left =
true, all_right =
true,
570 all_above =
true, all_bellow =
true;
571 for (
unsigned int ix = 0; ix < 2; ix++)
573 for (
unsigned int iy = 0; iy < 2; iy++)
575 if (node->
verts[ix][iy][0] > viewport.left())
577 if (node->
verts[ix][iy][0] < viewport.right())
579 if (node->
verts[ix][iy][1] > viewport.top())
581 if (node->
verts[ix][iy][1] < viewport.bottom())
585 if (all_left || all_right || all_bellow || all_above)
589 do_not_split_x =
true;
590 do_not_split_y =
true;
607 bool noncontinuous =
false;
643 noncontinuous =
true;
675 noncontinuous =
true;
706 noncontinuous =
true;
749 double dest_x, dest_y;
750 unsigned int subdiv_node;
753 x * 2, y * 2, dest_x, dest_y);
754 if (subdiv_node > node_id)
764 double dest_x, dest_y;
765 unsigned int subdiv_node;
768 x * 2, y * 2, dest_x, dest_y);
769 if (subdiv_node > node_id)
780 float xdx = node->
verts[0][0][0] - node->
verts[1][0][0],
781 xdy = node->
verts[0][0][1] - node->
verts[1][0][1],
782 ydx = node->
verts[0][0][0] - node->
verts[0][1][0],
783 ydy = node->
verts[0][0][1] - node->
verts[0][1][1];
789 node->
angle_x = atan2(xdy, xdx);
790 node->
angle_y = atan2(ydy, ydx);
796 unsigned int x, y, row_size, depth;
803 unsigned int row_size,
813 return GetIndex(x, y, row_size, depth);
818 unsigned int depth = 0, count = 0;
819 while (node_num > count)
822 count += 1 << (depth * 2);
828 unsigned int &x,
unsigned int &y,
829 unsigned int &row_size,
832 depth = GetDepth(node_num);
833 row_size = 1 << depth;
834 unsigned int sub = 0;
837 for (
unsigned int d = 0; d < depth; d++)
839 sub += (1 << (d * 2));
842 unsigned int position_id = node_num - sub;
843 x = position_id % row_size;
844 y = position_id / row_size;
848 const unsigned int y,
849 const unsigned int row_size,
852 unsigned int add = 0;
856 add += 1 << (depth * 2);
858 return add + x + y * row_size;
862 double coords[2][2][2])
868 unsigned int x, y, row_size, depth;
869 GetPosition(node_num, x, y, row_size, depth);
871 double row_spacing = 1.0 / (double) row_size;
872 coords[0][0][0] = row_spacing * (double) x;
873 coords[0][0][1] = row_spacing * (double) y;
877 bool scale_x =
false;
881 unsigned int parent_id = GetParentId(x, y, row_size, depth);
884 while (!(nodes[parent_id].
flags & split_flag_x))
886 parent_id = GetParentId(parent_id);
893 parent_id = GetParentId(parent_id);
899 coords[1][0][0] = coords[0][0][0] + (scale_x ? opp : row_spacing);
900 coords[1][0][1] = coords[0][0][1];
901 coords[0][1][0] = coords[0][0][0];
902 coords[0][1][1] = coords[0][0][1] + (scale_x ? row_spacing : opp);
903 coords[1][1][0] = coords[1][0][0];
904 coords[1][1][1] = coords[0][1][1];
907 for (
unsigned int i = 0; i < 2; i++)
909 for (
unsigned int j = 0; j < 2; j++)
911 coords[i][j][0] = coords[i][j][0] * x_crop_scale + x_crop_offs;
912 coords[i][j][1] = coords[i][j][1] * y_crop_scale + y_crop_offs;
925 unsigned int x, y, row_size, depth;
926 GetPosition(cur_tree_node, x, y, row_size, depth);
929 if (cur_tree_node != 0)
932 while (!done && cur_tree_node != 0)
934 unsigned int xd = x % 2;
935 unsigned int yd = y % 2;
940 cur_tree_node = GetIndex(x, y, row_size, depth);
941 if (cur_tree_node == 0 && xd == 1 && yd == 1)
947 bool sx = ((nodes[cur_tree_node].flags &
split_flag_x) != 0);
948 bool sy = ((nodes[cur_tree_node].flags &
split_flag_y) != 0);
950 if (!(((sx && xd) || !sx) && ((sy && yd) || !sy)))
958 if (sx && !xd && !yd) {
960 }
else if ((sx && xd && sy && !yd) || (!sx && sy && !yd)) {
962 }
else if (sx && sy && !xd && yd) {
965 cur_tree_node = GetIndex(x, y, row_size, depth);
968 if (cur_tree_node == 0)
982 cur_tree_node = GetIndex(x, y, row_size, depth);
984 return cur_tree_node;
989 unsigned int stop_x,
unsigned int stop_y,
990 double &dest_x,
double &dest_y)
995 unsigned int no_x = 0, no_y = 0, row_size = 1, depth = 0,
996 rem_x = src_x, rem_y = src_y,
998 node_id = GetIndex(no_x, no_y, row_size, depth);
999 while ( !( (rem_x == 0 || rem_x == step_x)
1000 && (rem_y == 0 || rem_y == step_y))
1028 if (depth > max_depth)
return 0;
1029 node_id = GetIndex(no_x, no_y, row_size, depth);
1030 if (depth == max_depth && no_x >= stop_x && no_y >= stop_y)
return 0;
1045 double xf = (double) rem_x / (
double) step_x;
1046 double yf = (double) rem_y / (
double) step_y;
1048 double top_x = (1.0 - xf) * nodes[node_id].verts[0][0][0]
1049 + xf * nodes[node_id].verts[1][0][0],
1050 bottom_x = (1-.0 - xf) * nodes[node_id].verts[0][1][0]
1051 + xf * nodes[node_id].verts[1][1][0],
1052 top_y = (1.0 - xf) * nodes[node_id].verts[0][0][1]
1053 + xf * nodes[node_id].verts[1][0][1],
1054 bottom_y = (1.0 - xf) * nodes[node_id].verts[0][1][1]
1055 + xf * nodes[node_id].verts[1][1][1];
1056 dest_x = top_x * (1.0 - yf) + bottom_x * yf;
1057 dest_y = top_y * (1.0 - yf) + bottom_y* yf;
VertexCoordRemapper(HuginBase::Panorama *m_pano, HuginBase::SrcPanoImage *image, VisualizationState *visualization_state)
PanoramaOptions::ProjectionFormat getProjection() const
bool GiveClipFaceResult(Coords *result)
Get a face that was produced by ClipFace.
unsigned int GetDepth(const unsigned int nodenum)
An abstract base class for objects that calculate an approximate remap specified by quadrilatrials...
const double GetUpperY() const
double s_vertex_coords[2][2][2]
unsigned int GetIndex(const unsigned int x, const unsigned int y, const unsigned int row_size, unsigned int depth)
double tex_coords[2][2][2]
void SetLengthAndAngle(TreeNode *node)
A class for exchanging pointers to coordinates.
const unsigned short int split_flag_y
unsigned int getHeight() const
get panorama height
HuginBase::SrcPanoImage * image
const double GetRadius() const
virtual void UpdateAndResetIndex()
const double GetUpperX() const
void DiscontinuityFlip(double vertex_c[2])
include file for the hugin project
double(* tex_c)[2][2]
The coordinate in the source image ranging from 0 to 1.
void RecursiveUpdate(unsigned int node_id, unsigned int stretch_x, unsigned int stretch_y)
bool isInside(vigra::Point2D p, bool ignoreMasks=false) const
check if a coordinate is inside the source image
HuginBase::PanoramaOptions::ProjectionFormat output_projection
const double GetLowerY() const
VisualizationState * visualization_state
const unsigned short int split_flag_x
const double min_length_difference
const unsigned short int patch_flag_x
unsigned int tree_node_id
TreeNode nodes[1+4+16+64+256+1024+4096]
void ClipFace(Coords *face)
Crop a face to the source image, return true if there is anything left.
const double GetMiddleY() const
void SetCrop()
Fill the crop values of the MeshRemapper from the source image.
vigra::Rect2D GetVisibleArea()
double height
The sizes of the input images in pixels.
unsigned int GetParentId(const unsigned int nodenum)
void GetInputCoordinates(unsigned int node_num, double coords[2][2][2])
float scale
The number number of units between vertex coorinates that gives a pixel in the display.
const unsigned short int vertex_side_flag_start
const double GetMiddleX() const
virtual OutputProjectionInfo * GetProjectionInfo()
void GetPosition(const unsigned int nodenum, unsigned int &x, unsigned int &y, unsigned int &row_size, unsigned int &depth)
unsigned int GetTransform(unsigned int src_x, unsigned int src_y, unsigned int depth, unsigned int stop_x, unsigned int stop_y, double &dest_x, double &dest_y)
const double GetXAdd360() const
const double GetLowerX() const
HuginBase::PTools::Transform transform
A transform to use to remap the images.
unsigned int getWidth() const
include file for the hugin project
const unsigned int min_depth
const unsigned short int transform_fail_flag
const unsigned short int patch_flag_y
virtual HuginBase::PanoramaOptions * GetOptions()
const unsigned int max_depth
virtual bool GetNextFaceCoordinates(Coords *result)
Get the texture and vertex coordinates for the next face.
virtual void UpdateAndResetIndex()
static void info(const char *fmt,...)
unsigned short int discontinuity_flags
const double offscreen_safety_margin
double(* vertex_c)[2][2]
The coordinate in the panorama, in its pixel space.
All variables of a source image.
void TestSubdivide(unsigned int node_id)
const double GetYAdd360() const