[997784] | 1 | /*
|
---|
| 2 | * Shape_impl.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Jun 18, 2010
|
---|
| 5 | * Author: crueger
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef SHAPE_IMPL_HPP_
|
---|
| 9 | #define SHAPE_IMPL_HPP_
|
---|
| 10 |
|
---|
| 11 | #include "Shapes/Shape.hpp"
|
---|
[5de9da] | 12 | #include "vector.hpp"
|
---|
[997784] | 13 |
|
---|
| 14 | class Shape_impl {
|
---|
| 15 | public:
|
---|
[e09b70] | 16 | Shape_impl(){};
|
---|
| 17 | virtual ~Shape_impl(){};
|
---|
[997784] | 18 | virtual bool isInside(const Vector &point)=0;
|
---|
[5de9da] | 19 | virtual bool isOnSurface(const Vector &point)=0;
|
---|
| 20 | virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException)=0;
|
---|
[997784] | 21 | };
|
---|
| 22 |
|
---|
| 23 | class Everywhere_impl : public Shape_impl {
|
---|
| 24 | public:
|
---|
| 25 | virtual bool isInside(const Vector &point){
|
---|
| 26 | return true;
|
---|
| 27 | }
|
---|
[5de9da] | 28 | virtual bool isOnSurface(const Vector &point){
|
---|
| 29 | return false;
|
---|
| 30 | }
|
---|
| 31 | virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException){
|
---|
| 32 | throw NotOnSurfaceException(__FILE__,__LINE__);
|
---|
| 33 | }
|
---|
[997784] | 34 | };
|
---|
| 35 |
|
---|
| 36 | class Nowhere_impl : public Shape_impl {
|
---|
| 37 | virtual bool isInside(const Vector &point){
|
---|
| 38 | return false;
|
---|
| 39 | }
|
---|
[5de9da] | 40 | virtual bool isOnSurface(const Vector &point){
|
---|
| 41 | return false;
|
---|
| 42 | }
|
---|
| 43 | virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException){
|
---|
| 44 | throw NotOnSurfaceException(__FILE__,__LINE__);
|
---|
| 45 | }
|
---|
[997784] | 46 | };
|
---|
| 47 |
|
---|
| 48 | class AndShape_impl : public Shape_impl {
|
---|
| 49 | public:
|
---|
| 50 | AndShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
|
---|
| 51 | virtual ~AndShape_impl();
|
---|
| 52 | virtual bool isInside(const Vector &point);
|
---|
[5de9da] | 53 | virtual bool isOnSurface(const Vector &point);
|
---|
| 54 | virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
|
---|
[997784] | 55 | private:
|
---|
| 56 | Shape::impl_ptr lhs;
|
---|
| 57 | Shape::impl_ptr rhs;
|
---|
| 58 | };
|
---|
| 59 |
|
---|
| 60 | class OrShape_impl : public Shape_impl {
|
---|
| 61 | public:
|
---|
| 62 | OrShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
|
---|
| 63 | virtual ~OrShape_impl();
|
---|
| 64 | virtual bool isInside(const Vector &point);
|
---|
[5de9da] | 65 | virtual bool isOnSurface(const Vector &point);
|
---|
| 66 | virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
|
---|
[997784] | 67 | private:
|
---|
| 68 | Shape::impl_ptr lhs;
|
---|
| 69 | Shape::impl_ptr rhs;
|
---|
| 70 | };
|
---|
| 71 |
|
---|
| 72 | class NotShape_impl : public Shape_impl {
|
---|
| 73 | public:
|
---|
| 74 | NotShape_impl(const Shape::impl_ptr&);
|
---|
| 75 | virtual ~NotShape_impl();
|
---|
| 76 | virtual bool isInside(const Vector &point);
|
---|
[5de9da] | 77 | virtual bool isOnSurface(const Vector &point);
|
---|
| 78 | virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
|
---|
[997784] | 79 | private:
|
---|
| 80 | Shape::impl_ptr arg;
|
---|
| 81 | };
|
---|
| 82 |
|
---|
[e09b70] | 83 | Shape::impl_ptr getShapeImpl(const Shape&);
|
---|
| 84 |
|
---|
[997784] | 85 | #endif /* SHAPE_IMPL_HPP_ */
|
---|