Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Shapes/Shape.cpp

    r205d9b rbcf653  
     1/*
     2 * Project: MoleCuilder
     3 * Description: creates and alters molecular systems
     4 * Copyright (C)  2010 University of Bonn. All rights reserved.
     5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
     6 */
     7
    18/*
    29 * Shape.cpp
     
    613 */
    714
     15// include config.h
     16#ifdef HAVE_CONFIG_H
     17#include <config.h>
     18#endif
     19
     20#include "Helpers/MemDebug.hpp"
     21
    822#include "Shape.hpp"
    923#include "Shape_impl.hpp"
     24
     25
     26#include "Helpers/Assert.hpp"
     27#include "LinearAlgebra/Vector.hpp"
    1028
    1129Shape::Shape(const Shape& src) :
     
    1735bool Shape::isInside(const Vector &point) const{
    1836  return impl->isInside(point);
     37}
     38
     39std::vector<Vector> Shape::getHomogeneousPointsOnSurface(const int N) const {
     40  return impl->getHomogeneousPointsOnSurface(N);
    1941}
    2042
     
    6587}
    6688
     89std::vector<Vector> AndShape_impl::getHomogeneousPointsOnSurface(const int N) const {
     90  std::vector<Vector> PointsOnSurface_lhs = lhs->getHomogeneousPointsOnSurface(N);
     91  std::vector<Vector> PointsOnSurface_rhs = rhs->getHomogeneousPointsOnSurface(N);
     92  std::vector<Vector> PointsOnSurface;
     93
     94  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_lhs.begin(); iter != PointsOnSurface_lhs.end(); ++iter) {
     95    if (rhs->isInside(*iter))
     96      PointsOnSurface.push_back(*iter);
     97  }
     98  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_rhs.begin(); iter != PointsOnSurface_rhs.end(); ++iter) {
     99    if (lhs->isInside(*iter))
     100      PointsOnSurface.push_back(*iter);
     101  }
     102
     103  return PointsOnSurface;
     104}
     105
     106
    67107Shape operator&&(const Shape &lhs,const Shape &rhs){
    68108  Shape::impl_ptr newImpl = Shape::impl_ptr(new AndShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
     
    80120bool OrShape_impl::isInside(const Vector &point){
    81121  return rhs->isInside(point) || lhs->isInside(point);
     122}
     123
     124std::vector<Vector> OrShape_impl::getHomogeneousPointsOnSurface(const int N) const {
     125  std::vector<Vector> PointsOnSurface_lhs = lhs->getHomogeneousPointsOnSurface(N);
     126  std::vector<Vector> PointsOnSurface_rhs = rhs->getHomogeneousPointsOnSurface(N);
     127  std::vector<Vector> PointsOnSurface;
     128
     129  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_lhs.begin(); iter != PointsOnSurface_lhs.end(); ++iter) {
     130    if (!rhs->isInside(*iter))
     131      PointsOnSurface.push_back(*iter);
     132  }
     133  for (std::vector<Vector>::const_iterator iter = PointsOnSurface_rhs.begin(); iter != PointsOnSurface_rhs.end(); ++iter) {
     134    if (!lhs->isInside(*iter))
     135      PointsOnSurface.push_back(*iter);
     136  }
     137
     138  return PointsOnSurface;
    82139}
    83140
     
    99156}
    100157
     158std::vector<Vector> NotShape_impl::getHomogeneousPointsOnSurface(const int N) const {
     159  // surfaces are the same, only normal direction is different
     160  return arg->getHomogeneousPointsOnSurface(N);
     161}
     162
    101163Shape operator!(const Shape &arg){
    102164  Shape::impl_ptr newImpl = Shape::impl_ptr(new NotShape_impl(getShapeImpl(arg)));
Note: See TracChangeset for help on using the changeset viewer.