Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Shapes/Shape.cpp

    r205d9b rc5186e  
    99#include "Shape_impl.hpp"
    1010
     11
     12#include "Helpers/Assert.hpp"
     13#include "LinearAlgebra/Vector.hpp"
     14
    1115Shape::Shape(const Shape& src) :
    1216  impl(src.getImpl())
     
    1721bool Shape::isInside(const Vector &point) const{
    1822  return impl->isInside(point);
     23}
     24
     25std::vector<Vector> Shape::getHomogeneousPointsOnSurface(const int N) const {
     26  return impl->getHomogeneousPointsOnSurface(N);
    1927}
    2028
     
    6573}
    6674
     75std::vector<Vector> AndShape_impl::getHomogeneousPointsOnSurface(const int N) const {
     76  std::vector<Vector> PointsOnSurface;
     77  ASSERT(false, "AndShape_impl::getHomogeneousPointsOnSurface() not implemented yet");
     78  return PointsOnSurface;
     79}
     80
     81
    6782Shape operator&&(const Shape &lhs,const Shape &rhs){
    6883  Shape::impl_ptr newImpl = Shape::impl_ptr(new AndShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
     
    8095bool OrShape_impl::isInside(const Vector &point){
    8196  return rhs->isInside(point) || lhs->isInside(point);
     97}
     98
     99std::vector<Vector> OrShape_impl::getHomogeneousPointsOnSurface(const int N) const {
     100  std::vector<Vector> PointsOnSurface_lhs = lhs->getHomogeneousPointsOnSurface(N);
     101  std::vector<Vector> PointsOnSurface_rhs = rhs->getHomogeneousPointsOnSurface(N);
     102  std::vector<Vector> PointsOnSurface;
     103
     104  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_lhs.begin(); iter != PointsOnSurface_lhs.end(); ++iter) {
     105    if (!rhs->isInside(*iter))
     106      PointsOnSurface.push_back(*iter);
     107  }
     108  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_rhs.begin(); iter != PointsOnSurface_rhs.end(); ++iter) {
     109    if (!lhs->isInside(*iter))
     110      PointsOnSurface.push_back(*iter);
     111  }
     112
     113  return PointsOnSurface;
    82114}
    83115
     
    99131}
    100132
     133std::vector<Vector> NotShape_impl::getHomogeneousPointsOnSurface(const int N) const {
     134  // surfaces are the same, only normal direction is different
     135  return arg->getHomogeneousPointsOnSurface(N);
     136}
     137
    101138Shape operator!(const Shape &arg){
    102139  Shape::impl_ptr newImpl = Shape::impl_ptr(new NotShape_impl(getShapeImpl(arg)));
Note: See TracChangeset for help on using the changeset viewer.