blob: eb353d9f91fb0703be558e3fea6c78474ca6761d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include <stdio.h>
#include <stdlib.h>
#include "rwbase.h"
#include "rwerror.h"
#include "rwplg.h"
#include "rwpipeline.h"
#include "rwobjects.h"
#include "rwengine.h"
#define PLUGIN_ID 0
namespace rw {
void
BBox::initialize(V3d *point)
{
this->inf = *point;
this->sup = *point;
}
void
BBox::addPoint(V3d *point)
{
if(point->x < this->inf.x)
this->inf.x = point->x;
if(point->y < this->inf.y)
this->inf.y = point->y;
if(point->z < this->inf.z)
this->inf.z = point->z;
if(point->x > this->sup.x)
this->sup.x = point->x;
if(point->y > this->sup.y)
this->sup.y = point->y;
if(point->z > this->sup.z)
this->sup.z = point->z;
}
void
BBox::calculate(V3d *points, int32 n)
{
this->inf = points[0];
this->sup = points[0];
while(--n){
points++;
if(points->x < this->inf.x)
this->inf.x = points->x;
if(points->y < this->inf.y)
this->inf.y = points->y;
if(points->z < this->inf.z)
this->inf.z = points->z;
if(points->x > this->sup.x)
this->sup.x = points->x;
if(points->y > this->sup.y)
this->sup.y = points->y;
if(points->z > this->sup.z)
this->sup.z = points->z;
}
}
bool
BBox::containsPoint(V3d *point)
{
return point->x >= this->inf.x && point->x <= this->sup.x &&
point->y >= this->inf.y && point->y <= this->sup.y &&
point->z >= this->inf.z && point->z <= this->sup.z;
}
}
|