| 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 | 
 | 
|---|
| 11 | #include "Shapes/Shape_impl.hpp"
 | 
|---|
| 12 | #include "vector.hpp"
 | 
|---|
| 13 | #include "Matrix.hpp"
 | 
|---|
| 14 | 
 | 
|---|
| 15 | class ShapeOpsBase_impl : public Shape_impl{
 | 
|---|
| 16 | public:
 | 
|---|
| 17 |   ShapeOpsBase_impl(const Shape::impl_ptr&);
 | 
|---|
| 18 |   virtual ~ShapeOpsBase_impl();
 | 
|---|
| 19 |   virtual bool isInside(const Vector &point);
 | 
|---|
| 20 |   virtual bool isOnSurface(const Vector &point);
 | 
|---|
| 21 |   virtual Vector getNormal(const Vector &point) throw (NotOnSurfaceException);
 | 
|---|
| 22 |   virtual LineSegmentSet getLineIntersections(const Line&);
 | 
|---|
| 23 | protected:
 | 
|---|
| 24 |   virtual Vector translateIn(const Vector &point)=0;
 | 
|---|
| 25 |   virtual Vector translateOutPos(const Vector &point)=0;
 | 
|---|
| 26 |   virtual Vector translateOutNormal(const Vector &point)=0;
 | 
|---|
| 27 |   Shape::impl_ptr getArg();
 | 
|---|
| 28 | private:
 | 
|---|
| 29 |   Shape::impl_ptr arg;
 | 
|---|
| 30 | };
 | 
|---|
| 31 | 
 | 
|---|
| 32 | class Resize_impl :  public ShapeOpsBase_impl
 | 
|---|
| 33 | {
 | 
|---|
| 34 | public:
 | 
|---|
| 35 |   Resize_impl(const Shape::impl_ptr&,double);
 | 
|---|
| 36 |   virtual ~Resize_impl();
 | 
|---|
| 37 | protected:
 | 
|---|
| 38 |   virtual Vector translateIn(const Vector &point);
 | 
|---|
| 39 |   virtual Vector translateOutPos(const Vector &point);
 | 
|---|
| 40 |   virtual Vector translateOutNormal(const Vector &point);
 | 
|---|
| 41 |   virtual std::string toString();
 | 
|---|
| 42 | private:
 | 
|---|
| 43 |   double size;
 | 
|---|
| 44 | };
 | 
|---|
| 45 | 
 | 
|---|
| 46 | class Translate_impl :  public ShapeOpsBase_impl
 | 
|---|
| 47 | {
 | 
|---|
| 48 | public:
 | 
|---|
| 49 |   Translate_impl(const Shape::impl_ptr&, const Vector&);
 | 
|---|
| 50 |   virtual ~Translate_impl();
 | 
|---|
| 51 | protected:
 | 
|---|
| 52 |   virtual Vector translateIn(const Vector &point);
 | 
|---|
| 53 |   virtual Vector translateOutPos(const Vector &point);
 | 
|---|
| 54 |   virtual Vector translateOutNormal(const Vector &point);
 | 
|---|
| 55 |   virtual std::string toString();
 | 
|---|
| 56 | private:
 | 
|---|
| 57 |   Vector offset;
 | 
|---|
| 58 | };
 | 
|---|
| 59 | 
 | 
|---|
| 60 | class Stretch_impl : public ShapeOpsBase_impl
 | 
|---|
| 61 | {
 | 
|---|
| 62 | public:
 | 
|---|
| 63 |   Stretch_impl(const Shape::impl_ptr&, const Vector&);
 | 
|---|
| 64 |   virtual ~Stretch_impl();
 | 
|---|
| 65 | protected:
 | 
|---|
| 66 |   virtual Vector translateIn(const Vector &point);
 | 
|---|
| 67 |   virtual Vector translateOutPos(const Vector &point);
 | 
|---|
| 68 |   virtual Vector translateOutNormal(const Vector &point);
 | 
|---|
| 69 |   virtual std::string toString();
 | 
|---|
| 70 | private:
 | 
|---|
| 71 |   Vector factors;
 | 
|---|
| 72 |   Vector reciFactors;
 | 
|---|
| 73 | };
 | 
|---|
| 74 | 
 | 
|---|
| 75 | class Transform_impl : public ShapeOpsBase_impl
 | 
|---|
| 76 | {
 | 
|---|
| 77 | public:
 | 
|---|
| 78 |   Transform_impl(const Shape::impl_ptr&, const Matrix&);
 | 
|---|
| 79 |   virtual ~Transform_impl();
 | 
|---|
| 80 | protected:
 | 
|---|
| 81 |   virtual Vector translateIn(const Vector &point);
 | 
|---|
| 82 |   virtual Vector translateOutPos(const Vector &point);
 | 
|---|
| 83 |   virtual Vector translateOutNormal(const Vector &point);
 | 
|---|
| 84 |   virtual std::string toString();
 | 
|---|
| 85 | private:
 | 
|---|
| 86 |   Matrix transformation;
 | 
|---|
| 87 |   Matrix transformationInv;
 | 
|---|
| 88 | };
 | 
|---|
| 89 | 
 | 
|---|
| 90 | #endif /* SHAPEOPS_IMPL_HPP_ */
 | 
|---|