[e09b70] | 1 | /*
|
---|
| 2 | * ShapeOps_impl.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Jun 18, 2010
|
---|
| 5 | * Author: crueger
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef SHAPEOPS_IMPL_HPP_
|
---|
| 9 | #define SHAPEOPS_IMPL_HPP_
|
---|
| 10 |
|
---|
[56f73b] | 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 |
|
---|
[e09b70] | 17 | #include "Shapes/Shape_impl.hpp"
|
---|
[b94634] | 18 | #include "Shapes/ShapeExceptions.hpp"
|
---|
[b92e4a] | 19 | #include "Shapes/ShapeType.hpp"
|
---|
[57f243] | 20 | #include "LinearAlgebra/Vector.hpp"
|
---|
[cca9ef] | 21 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
---|
[e09b70] | 22 |
|
---|
[6c438f] | 23 | #include <vector>
|
---|
| 24 |
|
---|
| 25 | class LineSegment;
|
---|
[e09b70] | 26 |
|
---|
[5de9da] | 27 | class ShapeOpsBase_impl : public Shape_impl{
|
---|
| 28 | public:
|
---|
| 29 | ShapeOpsBase_impl(const Shape::impl_ptr&);
|
---|
| 30 | virtual ~ShapeOpsBase_impl();
|
---|
[735940] | 31 | virtual bool isInside(const Vector &point) const;
|
---|
| 32 | virtual bool isOnSurface(const Vector &point) const;
|
---|
| 33 | virtual Vector getNormal(const Vector &point) const throw (NotOnSurfaceException);
|
---|
[6acc2f3] | 34 | virtual Vector getCenter() const;
|
---|
| 35 | virtual double getRadius() const;
|
---|
[735940] | 36 | virtual LineSegmentSet getLineIntersections(const Line&) const;
|
---|
[b92e4a] | 37 | virtual enum ShapeType getType() const;
|
---|
[6c438f] | 38 | virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
|
---|
[5a8d61] | 39 | virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
|
---|
[5de9da] | 40 | protected:
|
---|
[735940] | 41 | virtual Vector translateIn(const Vector &point) const=0;
|
---|
| 42 | virtual Vector translateOutPos(const Vector &point) const=0;
|
---|
| 43 | virtual Vector translateOutNormal(const Vector &point) const=0;
|
---|
[6c438f] | 44 | Shape::impl_ptr getArg() const;
|
---|
[5de9da] | 45 | private:
|
---|
| 46 | Shape::impl_ptr arg;
|
---|
| 47 | };
|
---|
| 48 |
|
---|
| 49 | class Resize_impl : public ShapeOpsBase_impl
|
---|
[e09b70] | 50 | {
|
---|
| 51 | public:
|
---|
| 52 | Resize_impl(const Shape::impl_ptr&,double);
|
---|
| 53 | virtual ~Resize_impl();
|
---|
[5de9da] | 54 | protected:
|
---|
[c67c65] | 55 | virtual double getVolume() const;
|
---|
| 56 | virtual double getSurfaceArea() const;
|
---|
[735940] | 57 | virtual Vector translateIn(const Vector &point) const;
|
---|
| 58 | virtual Vector translateOutPos(const Vector &point) const;
|
---|
| 59 | virtual Vector translateOutNormal(const Vector &point) const;
|
---|
[b92e4a] | 60 | virtual std::string toString() const;
|
---|
[735940] | 61 | virtual bool isInside(const Vector& point) const;
|
---|
[9c1c89] | 62 | virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
|
---|
[5a8d61] | 63 | virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
|
---|
[e09b70] | 64 | private:
|
---|
| 65 | double size;
|
---|
| 66 | };
|
---|
| 67 |
|
---|
[5de9da] | 68 | class Translate_impl : public ShapeOpsBase_impl
|
---|
[e09b70] | 69 | {
|
---|
| 70 | public:
|
---|
| 71 | Translate_impl(const Shape::impl_ptr&, const Vector&);
|
---|
| 72 | virtual ~Translate_impl();
|
---|
[5de9da] | 73 | protected:
|
---|
[6acc2f3] | 74 | virtual Vector getCenter() const;
|
---|
| 75 | virtual double getRadius() const;
|
---|
[c67c65] | 76 | virtual double getVolume() const;
|
---|
| 77 | virtual double getSurfaceArea() const;
|
---|
[735940] | 78 | virtual Vector translateIn(const Vector &point) const;
|
---|
| 79 | virtual Vector translateOutPos(const Vector &point) const;
|
---|
| 80 | virtual Vector translateOutNormal(const Vector &point) const;
|
---|
[b92e4a] | 81 | virtual std::string toString() const;
|
---|
[735940] | 82 | virtual bool isInside(const Vector& point) const;
|
---|
[9c1c89] | 83 | virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
|
---|
[5a8d61] | 84 | virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
|
---|
[e09b70] | 85 | private:
|
---|
| 86 | Vector offset;
|
---|
| 87 | };
|
---|
| 88 |
|
---|
[5de9da] | 89 | class Stretch_impl : public ShapeOpsBase_impl
|
---|
[5e588b5] | 90 | {
|
---|
| 91 | public:
|
---|
[c67c65] | 92 |
|
---|
| 93 |
|
---|
| 94 | Stretch_impl(const Shape::impl_ptr&, const Vector&);
|
---|
[5e588b5] | 95 | virtual ~Stretch_impl();
|
---|
[5de9da] | 96 | protected:
|
---|
[c67c65] | 97 | virtual double getVolume() const;
|
---|
| 98 | virtual double getSurfaceArea() const;
|
---|
[735940] | 99 | virtual Vector translateIn(const Vector &point) const;
|
---|
| 100 | virtual Vector translateOutPos(const Vector &point) const;
|
---|
| 101 | virtual Vector translateOutNormal(const Vector &point) const;
|
---|
[b92e4a] | 102 | virtual std::string toString() const;
|
---|
[735940] | 103 | virtual bool isInside(const Vector& point) const;
|
---|
[9c1c89] | 104 | virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
|
---|
[5a8d61] | 105 | virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
|
---|
[5e588b5] | 106 | private:
|
---|
| 107 | Vector factors;
|
---|
| 108 | Vector reciFactors;
|
---|
| 109 | };
|
---|
| 110 |
|
---|
[5de9da] | 111 | class Transform_impl : public ShapeOpsBase_impl
|
---|
[5e588b5] | 112 | {
|
---|
| 113 | public:
|
---|
[cca9ef] | 114 | Transform_impl(const Shape::impl_ptr&, const RealSpaceMatrix&);
|
---|
[5e588b5] | 115 | virtual ~Transform_impl();
|
---|
[5de9da] | 116 | protected:
|
---|
[c67c65] | 117 | virtual double getVolume() const;
|
---|
| 118 | virtual double getSurfaceArea() const;
|
---|
[735940] | 119 | virtual Vector translateIn(const Vector &point) const;
|
---|
| 120 | virtual Vector translateOutPos(const Vector &point) const;
|
---|
| 121 | virtual Vector translateOutNormal(const Vector &point) const;
|
---|
[b92e4a] | 122 | virtual std::string toString() const;
|
---|
[735940] | 123 | virtual bool isInside(const Vector& point) const;
|
---|
[9c1c89] | 124 | virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
|
---|
[5a8d61] | 125 | virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
|
---|
[5e588b5] | 126 | private:
|
---|
[cca9ef] | 127 | RealSpaceMatrix transformation;
|
---|
| 128 | RealSpaceMatrix transformationInv;
|
---|
[5e588b5] | 129 | };
|
---|
| 130 |
|
---|
[e09b70] | 131 | #endif /* SHAPEOPS_IMPL_HPP_ */
|
---|