Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Shapes/Shape.cpp

    rbf3817 r23bade  
    66 */
    77
    8 // include config.h
    9 #ifdef HAVE_CONFIG_H
    10 #include <config.h>
    11 #endif
    12 
    13 #include "Helpers/MemDebug.hpp"
    14 
    158#include "Shape.hpp"
    169#include "Shape_impl.hpp"
     10
     11
     12#include "Helpers/Assert.hpp"
     13#include "LinearAlgebra/Vector.hpp"
    1714
    1815Shape::Shape(const Shape& src) :
     
    2421bool Shape::isInside(const Vector &point) const{
    2522  return impl->isInside(point);
     23}
     24
     25std::vector<Vector> Shape::getHomogeneousPointsOnSurface(const int N) const {
     26  return impl->getHomogeneousPointsOnSurface(N);
    2627}
    2728
     
    7273}
    7374
     75std::vector<Vector> AndShape_impl::getHomogeneousPointsOnSurface(const int N) const {
     76  std::vector<Vector> PointsOnSurface_lhs = lhs->getHomogeneousPointsOnSurface(N);
     77  std::vector<Vector> PointsOnSurface_rhs = rhs->getHomogeneousPointsOnSurface(N);
     78  std::vector<Vector> PointsOnSurface;
     79
     80  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_lhs.begin(); iter != PointsOnSurface_lhs.end(); ++iter) {
     81    if (rhs->isInside(*iter))
     82      PointsOnSurface.push_back(*iter);
     83  }
     84  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_rhs.begin(); iter != PointsOnSurface_rhs.end(); ++iter) {
     85    if (lhs->isInside(*iter))
     86      PointsOnSurface.push_back(*iter);
     87  }
     88
     89  return PointsOnSurface;
     90}
     91
     92
    7493Shape operator&&(const Shape &lhs,const Shape &rhs){
    7594  Shape::impl_ptr newImpl = Shape::impl_ptr(new AndShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
     
    87106bool OrShape_impl::isInside(const Vector &point){
    88107  return rhs->isInside(point) || lhs->isInside(point);
     108}
     109
     110std::vector<Vector> OrShape_impl::getHomogeneousPointsOnSurface(const int N) const {
     111  std::vector<Vector> PointsOnSurface_lhs = lhs->getHomogeneousPointsOnSurface(N);
     112  std::vector<Vector> PointsOnSurface_rhs = rhs->getHomogeneousPointsOnSurface(N);
     113  std::vector<Vector> PointsOnSurface;
     114
     115  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_lhs.begin(); iter != PointsOnSurface_lhs.end(); ++iter) {
     116    if (!rhs->isInside(*iter))
     117      PointsOnSurface.push_back(*iter);
     118  }
     119  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_rhs.begin(); iter != PointsOnSurface_rhs.end(); ++iter) {
     120    if (!lhs->isInside(*iter))
     121      PointsOnSurface.push_back(*iter);
     122  }
     123
     124  return PointsOnSurface;
    89125}
    90126
     
    106142}
    107143
     144std::vector<Vector> NotShape_impl::getHomogeneousPointsOnSurface(const int N) const {
     145  // surfaces are the same, only normal direction is different
     146  return arg->getHomogeneousPointsOnSurface(N);
     147}
     148
    108149Shape operator!(const Shape &arg){
    109150  Shape::impl_ptr newImpl = Shape::impl_ptr(new NotShape_impl(getShapeImpl(arg)));
Note: See TracChangeset for help on using the changeset viewer.