667 |
khor |
1 |
/* ----------------------------------------------------------------------- *
|
|
|
2 |
* This file is part of GEL, http://www.imm.dtu.dk/GEL
|
|
|
3 |
* Copyright (C) the authors and DTU Informatics
|
|
|
4 |
* For license and list of authors, see ../../doc/intro.pdf
|
|
|
5 |
* ----------------------------------------------------------------------- */
|
|
|
6 |
|
|
|
7 |
/**
|
|
|
8 |
* @file BoundingNode.h
|
|
|
9 |
* @brief Abstract ancestor of the nodes of a bounding hierarchy.
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
#ifndef __GEOMETRY_BOUNDINGNODE_H
|
|
|
13 |
#define __GEOMETRY_BOUNDINGNODE_H
|
|
|
14 |
|
|
|
15 |
#include <vector>
|
|
|
16 |
#include "../CGLA/Vec3f.h"
|
|
|
17 |
#include "Ray.h"
|
|
|
18 |
#include "Triangle.h"
|
|
|
19 |
#include "AABox.h"
|
|
|
20 |
#include "OBox.h"
|
|
|
21 |
|
|
|
22 |
namespace Geometry
|
|
|
23 |
{
|
|
|
24 |
|
|
|
25 |
/// Abstract BOUNDINGNODE node.
|
|
|
26 |
template<class BoxType>
|
|
|
27 |
class BoundingNode: public BoxType
|
|
|
28 |
{
|
|
|
29 |
public:
|
|
|
30 |
|
|
|
31 |
BoundingNode(const BoxType& box): BoxType(box) {}
|
|
|
32 |
virtual ~BoundingNode() {}
|
|
|
33 |
|
|
|
34 |
/// Count number of intersections from a point in a given direction
|
|
|
35 |
virtual int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const=0;
|
|
|
36 |
|
|
|
37 |
/// Find the surface intersection point
|
|
|
38 |
virtual bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const=0;
|
|
|
39 |
|
|
|
40 |
virtual void intersect(Ray& r) const = 0;
|
|
|
41 |
|
|
|
42 |
/** For a given point, return the min and max square distance and the
|
|
|
43 |
sign. Non-leafs return zero for the sign. Leaves
|
|
|
44 |
return the square of the true distance as both min and max. */
|
|
|
45 |
virtual void sq_distance(const CGLA::Vec3f&, float&, float&, float&) const;
|
|
|
46 |
|
|
|
47 |
static BoundingNode* build(std::vector<Triangle>& triangles);
|
|
|
48 |
};
|
|
|
49 |
|
|
|
50 |
}
|
|
|
51 |
#endif
|