30 |
|
|
31 |
#include <vob/Transform.hxx> |
#include <vob/Transform.hxx> |
32 |
#include <vob/Vec23.hxx> |
#include <vob/Vec23.hxx> |
33 |
|
#include <vob/Debug.hxx> |
34 |
#include "vob/intersect.hxx" |
#include "vob/intersect.hxx" |
35 |
|
|
36 |
using Vob::Transform; |
using Vob::Transform; |
37 |
using Vob::Vec23::ZPt; |
using Vob::Vec23::ZPt; |
38 |
using Vob::Vec23::Pt; |
using Vob::Vec23::Pt; |
39 |
|
|
40 |
|
namespace Vob { |
41 |
namespace Util { |
namespace Util { |
42 |
|
DBGVAR(dbg_intersect, "Intersect"); |
43 |
bool parallelRectIntersect(ZPt &p1, ZPt &p2, ZPt &p3, ZPt &p4) { |
bool parallelRectIntersect(ZPt &p1, ZPt &p2, ZPt &p3, ZPt &p4) { |
44 |
return (p2.x > p3.x) && (p4.x > p1.x) && (p2.y > p3.y) && (p4.y > p1.y); |
return (p2.x > p3.x) && (p4.x > p1.x) && (p2.y > p3.y) && (p4.y > p1.y); |
45 |
} |
} |
47 |
return (p1.x <= p3.x) && (p1.y <= p3.y) && (p4.x <= p2.x) && (p4.y <= p2.y); |
return (p1.x <= p3.x) && (p1.y <= p3.y) && (p4.x <= p2.x) && (p4.y <= p2.y); |
48 |
} |
} |
49 |
void findBoundingBox(const Transform *t, ZPt &p1, ZPt &p2) { |
void findBoundingBox(const Transform *t, ZPt &p1, ZPt &p2) { |
50 |
float i, j; |
int i0, j0; |
51 |
Pt box = t->getSqSize(); |
Pt box = t->getSqSize(); |
52 |
float x1=0, y1=0, x2=0, y2=0; |
float x1=0, y1=0, x2=0, y2=0; |
53 |
for (i=0; i<=box.x; i+=box.x) { |
DBG(dbg_intersect) << "Find bb "<<t<<" "<<box<<"\n"; |
54 |
for (j=0; j<=box.y; j+=box.y) { |
for (i0=0; i0<=1; i0+=1) { |
55 |
|
for (j0=0; j0<=1; j0+=1) { |
56 |
|
float i = i0 * box.x; |
57 |
|
float j = j0 * box.x; |
58 |
if (i==0 && j==0) { |
if (i==0 && j==0) { |
59 |
/** Initializing. */ |
/** Initializing. */ |
60 |
ZPt tmpPt = t->transform(ZPt(i, j, 0)); |
ZPt tmpPt = t->transform(ZPt(i, j, 0)); |
72 |
} |
} |
73 |
p1 = ZPt(x1, y1, 0); |
p1 = ZPt(x1, y1, 0); |
74 |
p2 = ZPt(x2, y2, 0); |
p2 = ZPt(x2, y2, 0); |
75 |
|
DBG(dbg_intersect) << "Return "<<p1<<" "<<p2<<"\n"; |
76 |
} |
} |
77 |
void findDistortedBoundingBox(const Transform *t, ZPt &p1, ZPt &p2) { |
void findDistortedBoundingBox(const Transform *t, ZPt &p1, ZPt &p2) { |
78 |
double i, step_x, step_y; |
double i, step_x, step_y; |
79 |
Pt box = t->getSqSize(); |
Pt box = t->getSqSize(); |
80 |
float x1, y1, x2, y2; |
float x1, y1, x2, y2; |
81 |
int check_dist; |
int check_dist; |
82 |
|
DBG(dbg_intersect) << "Find distortedbb "<<t<<" "<<box<<"\n"; |
83 |
|
|
84 |
/** Initializing. */ |
/** Initializing. */ |
85 |
check_dist = 100; // XXX Adjusts the scanning frequency. |
check_dist = 100; // XXX Adjusts the scanning frequency. |
136 |
|
|
137 |
p1 = ZPt(x1, y1, 0); |
p1 = ZPt(x1, y1, 0); |
138 |
p2 = ZPt(x2, y2, 0); |
p2 = ZPt(x2, y2, 0); |
139 |
|
DBG(dbg_intersect) << "Return "<<p1<<" "<<p2<<"\n"; |
140 |
} |
} |
141 |
} |
} |
142 |
|
} |