Changes in / [22425a:510f81]


Ignore:
Files:
94 added
4 deleted
60 edited

Legend:

Unmodified
Added
Removed
  • LinearAlgebra/src/LinearAlgebra/Line.cpp

    r22425a r510f81  
    3131#include "defs.hpp"
    3232#include "Exceptions.hpp"
     33#include "LinePoint.hpp"
    3334#include "MatrixContent.hpp"
    3435#include "Plane.hpp"
     
    308309}
    309310
    310 /******************************** Points on the line ********************/
    311 
    312 LinePoint::LinePoint(const LinePoint &src) :
    313   line(src.line),param(src.param)
    314 {}
    315 
    316 LinePoint::LinePoint(const Line &_line, double _param) :
    317   line(_line),param(_param)
    318 {}
    319 
    320 LinePoint& LinePoint::operator=(const LinePoint &src){
    321   line=src.line;
    322   param=src.param;
    323   return *this;
    324 }
    325 
    326 Vector LinePoint::getPoint() const{
    327   ASSERT(!isInfinite(),"getPoint() on infinite LinePoint called");
    328   return (*line.origin)+param*(*line.direction);
    329 }
    330 
    331 Line LinePoint::getLine() const{
    332   return line;
    333 }
    334 
    335 bool LinePoint::isInfinite() const{
    336   return isPosInfinity() || isNegInfinity();
    337 }
    338 bool LinePoint::isPosInfinity() const{
    339   return param == numeric_limits<double>::infinity();
    340 }
    341 bool LinePoint::isNegInfinity() const{
    342   return param ==-numeric_limits<double>::infinity();
    343 }
    344 
    345 bool operator==(const LinePoint &x, const LinePoint &y){
    346   ASSERT(x.line==y.line,"Operation on two points of different lines");
    347   return x.param == y.param;
    348 
    349 }
    350 bool operator<(const LinePoint &x, const LinePoint &y){
    351   ASSERT(x.line==y.line,"Operation on two points of different lines");
    352   return x.param<y.param;
    353 }
    354 
    355 ostream& operator<<(ostream& ost, const Line& m)
     311std::ostream& operator<<(std::ostream& ost, const Line& m)
    356312{
    357313  const Vector origin = m.getOrigin();
     
    373329};
    374330
     331
     332/******************************** Points on the line ********************/
  • LinearAlgebra/src/LinearAlgebra/Line.hpp

    r22425a r510f81  
    2525class LinePoint;
    2626
     27/** This class represents a line in space stretching to infinity.
     28 *
     29 * It is defined by its origin and a direction.
     30 *
     31 * \sa LinePoint and LineSegment
     32 */
    2733class Line : public Space
    2834{
     
    7480Line makeLineThrough(const Vector &x1, const Vector &x2);
    7581
    76 /**
    77  * Class for representing points on a line
    78  * These objects allow comparison of points on the same line as well as specifying the
    79  * infinite "endpoints" of a line.
    80  */
    81 class LinePoint{
    82   friend class Line;
    83   friend bool operator==(const LinePoint&, const LinePoint&);
    84   friend bool operator<(const LinePoint&, const LinePoint&);
    85 public:
    86   LinePoint(const LinePoint&);
    87   LinePoint& operator=(const LinePoint&);
    88   Vector getPoint() const;
    89   Line getLine() const;
    90   bool isInfinite() const;
    91   bool isPosInfinity() const;
    92   bool isNegInfinity() const;
    93 
    94 private:
    95   LinePoint(const Line&,double);
    96   Line line;
    97   double param;
    98 };
    99 
    100 bool operator==(const LinePoint&, const LinePoint&);
    101 bool operator<(const LinePoint&, const LinePoint&);
    102 
    103 inline bool operator!= (const LinePoint& x, const LinePoint& y) { return !(x==y); }
    104 inline bool operator>  (const LinePoint& x, const LinePoint& y) { return y<x; }
    105 inline bool operator<= (const LinePoint& x, const LinePoint& y) { return !(y<x); }
    106 inline bool operator>= (const LinePoint& x, const LinePoint& y) { return !(x<y); }
    107 
    108 
    10982#endif /* LINE_HPP_ */
  • LinearAlgebra/src/LinearAlgebra/LineSegment.cpp

    r22425a r510f81  
    2424
    2525#include "Line.hpp"
     26#include "LinePoint.hpp"
    2627#include "Vector.hpp"
    2728
  • LinearAlgebra/src/LinearAlgebra/LineSegment.hpp

    r22425a r510f81  
    2121class LinePoint;
    2222
     23/** This class represents a specific segment of a line, defined through
     24 * two points on the same line that form start and end.
     25 *
     26 */
    2327class LineSegment
    2428{
  • LinearAlgebra/src/LinearAlgebra/LineSegmentSet.cpp

    r22425a r510f81  
    2424#include "CodePatterns/Assert.hpp"
    2525#include "Line.hpp"
     26#include "LinePoint.hpp"
    2627#include "LineSegment.hpp"
    2728
  • LinearAlgebra/src/LinearAlgebra/LineSegmentSet.hpp

    r22425a r510f81  
    2222class LineSegment;
    2323
     24/** This class represents a continous set of LineSegment's all on the same
     25 * underlying line.
     26 *
     27 * Hence, it is basically a sorted container for LinePoints but
     28 * we iterate over it segment-wise.
     29 *
     30 */
    2431class LineSegmentSet {
    2532  friend LineSegmentSet merge(const LineSegmentSet&,const LineSegmentSet&);
  • LinearAlgebra/src/LinearAlgebra/Makefile.am

    r22425a r510f81  
    1111  leastsquaremin.cpp \
    1212  Line.cpp \
     13  LinePoint.cpp \
    1314  LineSegment.cpp \
    1415  LineSegmentSet.cpp \
     
    3132  leastsquaremin.hpp \
    3233  Line.hpp \
     34  LinePoint.hpp \
    3335  LineSegment.hpp \
    3436  LineSegmentSet.hpp \
  • LinearAlgebra/src/LinearAlgebra/defs.hpp

    r22425a r510f81  
    2323double LINALG_MYEPSILON()
    2424{
    25   return (std::numeric_limits<double>::epsilon()*100.);
     25  return (std::numeric_limits<double>::epsilon()*1.e+4);
    2626}
    2727
  • LinearAlgebra/src/documentation/mainpage.dox

    r22425a r510f81  
    2525 *
    2626 *
     27 * \ref lines Lines and subtypes
     28 *
    2729 * \date 2011-11-02
    2830 *
  • LinearAlgebra/tests/CodeChecks/Makefile.am

    r22425a r510f81  
    11AUTOM4TE = autom4te
     2
     3TESTSUITE = $(srcdir)/testsuite
     4
     5TESTSCRIPTS = \
     6        testsuite-config_h.at \
     7        testsuite-date_in_dox.at \
     8        testsuite-header-dist.at \
     9        testsuite-memdebug.at \
     10        testsuite-project-disclaimer.at
     11
     12DISTCLEANFILES = atconfig
     13
    214EXTRA_DIST = \
    315        atlocal.in \
    416        package.m4 \
    517        testsuite.at \
    6         testsuite-config_h.at \
    7         testsuite-date_in_dox.at \
    8         testsuite-memdebug.at \
    9         testsuite-project-disclaimer.at \
    10         $(TESTSUITE)
    11 TESTSUITE = $(srcdir)/testsuite
    12 
    13 DISTCLEANFILES = atconfig
    14 
    15 TESTSCRIPTS = \
    16         testsuite-config_h.at \
    17         testsuite-date_in_dox.at \
    18         testsuite-memdebug.at \
    19         testsuite-project-disclaimer.at
     18        $(TESTSUITE) \
     19        $(TESTSCRIPTS)
    2020
    2121max_jobs = 4
  • LinearAlgebra/tests/CodeChecks/testsuite.at

    r22425a r510f81  
    2121m4_include(testsuite-project-disclaimer.at)
    2222
     23m4_include(testsuite-header-dist.at)
  • src/Actions/GlobalListOfActions.hpp

    r22425a r510f81  
    105105        (SelectionNotAllAtomsInsideCuboid) \
    106106        (SelectionAtomById) \
    107         (FragmentationFragmentation)
     107        (FragmentationFragmentation) \
     108        (FillRegularGrid)
    108109
    109110#endif /* GLOBALLISTOFACTIONS_HPP_ */
  • src/Actions/Makefile.am

    r22425a r510f81  
    5252  ${ATOMACTIONSOURCE} \
    5353  ${CMDACTIONSOURCE} \
     54  ${FILLACTIONSOURCE} \
    5455  ${FRAGMENTATIONACTIONSOURCE} \
    5556  ${GRAPHACTIONSOURCE} \
     
    6768  ${ATOMACTIONHEADER} \
    6869  ${CMDACTIONHEADER} \
     70  ${FILLACTIONHEADER} \
    6971  ${FRAGMENTATIONACTIONHEADER} \
    7072  ${GRAPHACTIONHEADER} \
     
    8284  ${ATOMACTIONDEFS} \
    8385  ${CMDACTIONDEFS} \
     86  ${FILLACTIONDEFS} \
    8487  ${FRAGMENTATIONACTIONDEFS} \
    8588  ${GRAPHACTIONDEFS} \
     
    173176  Actions/CommandAction/VersionAction.def \
    174177  Actions/CommandAction/WarrantyAction.def
     178
     179FILLACTIONSOURCE = \
     180        Actions/FillAction/FillRegularGridAction.cpp
     181FILLACTIONHEADER = \
     182        Actions/FillAction/FillRegularGridAction.hpp
     183FILLACTIONDEFS = \
     184        Actions/FillAction/FillRegularGridAction.def
     185
    175186
    176187FRAGMENTATIONACTIONSOURCE = \
  • src/Actions/SelectionAction/Atoms/AllAtomsInsideCuboidAction.cpp

    r22425a r510f81  
    5454  LOG(1, "Selecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << params.position << " and extension of " << params.extension << ".");
    5555  Shape s = translate(transform(stretch(Cuboid(),params.extension),RotationMatrix),params.position);
    56   std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && AtomByShape(s));
    57   World::getInstance().selectAllAtoms(AtomByShape(s));
     56  std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && AtomsByShape(s));
     57  World::getInstance().selectAllAtoms(AtomsByShape(s));
    5858  LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected.");
    5959  return Action::state_ptr(new SelectionAllAtomsInsideCuboidState(selectedAtoms, s, params));
     
    6363  SelectionAllAtomsInsideCuboidState *state = assert_cast<SelectionAllAtomsInsideCuboidState*>(_state.get());
    6464
    65   World::getInstance().unselectAllAtoms(AtomByShape(state->s));
     65  World::getInstance().unselectAllAtoms(AtomsByShape(state->s));
    6666  BOOST_FOREACH(atom *_atom, state->selectedAtoms)
    6767    World::getInstance().selectAtom(_atom);
     
    7474  RealSpaceMatrix RotationMatrix;
    7575
    76   World::getInstance().selectAllAtoms(AtomByShape(state->s));
     76  World::getInstance().selectAllAtoms(AtomsByShape(state->s));
    7777
    7878  return Action::state_ptr(_state);
  • src/Actions/SelectionAction/Atoms/AllAtomsInsideSphereAction.cpp

    r22425a r510f81  
    4949  LOG(1, "Selecting all atoms inside a sphere at " << params.position << " with radius " << params.radius << ".");
    5050  Shape s = translate(resize(Sphere(),params.radius),params.position);
    51   std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && AtomByShape(s));
    52   World::getInstance().selectAllAtoms(AtomByShape(s));
     51  std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && AtomsByShape(s));
     52  World::getInstance().selectAllAtoms(AtomsByShape(s));
    5353  LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected.");
    5454  return Action::state_ptr(new SelectionAllAtomsInsideSphereState(selectedAtoms, s, params));
     
    5858  SelectionAllAtomsInsideSphereState *state = assert_cast<SelectionAllAtomsInsideSphereState*>(_state.get());
    5959
    60   World::getInstance().unselectAllAtoms(AtomByShape(state->s));
     60  World::getInstance().unselectAllAtoms(AtomsByShape(state->s));
    6161  BOOST_FOREACH(atom *_atom, state->selectedAtoms)
    6262    World::getInstance().selectAtom(_atom);
     
    6868  SelectionAllAtomsInsideSphereState *state = assert_cast<SelectionAllAtomsInsideSphereState*>(_state.get());
    6969
    70   World::getInstance().selectAllAtoms(AtomByShape(state->s));
     70  World::getInstance().selectAllAtoms(AtomsByShape(state->s));
    7171
    7272  return Action::state_ptr(_state);
  • src/Actions/SelectionAction/Atoms/NotAllAtomsInsideCuboidAction.cpp

    r22425a r510f81  
    5353  LOG(1, "Unselecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << params.position << " and extension of " << params.extension << ".");
    5454  Shape s = translate(transform(stretch(Cuboid(),params.extension),RotationMatrix),params.position);
    55   std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && AtomByShape(s));
    56   World::getInstance().unselectAllAtoms(AtomByShape(s));
     55  std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && AtomsByShape(s));
     56  World::getInstance().unselectAllAtoms(AtomsByShape(s));
    5757  LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected.");
    5858  return Action::state_ptr(new SelectionNotAllAtomsInsideCuboidState(unselectedAtoms, s, params));
     
    6262  SelectionNotAllAtomsInsideCuboidState *state = assert_cast<SelectionNotAllAtomsInsideCuboidState*>(_state.get());
    6363
    64   World::getInstance().selectAllAtoms(AtomByShape(state->s));
     64  World::getInstance().selectAllAtoms(AtomsByShape(state->s));
    6565  BOOST_FOREACH(atom *_atom, state->unselectedAtoms)
    6666    World::getInstance().unselectAtom(_atom);
     
    7373  RealSpaceMatrix RotationMatrix;
    7474
    75   World::getInstance().unselectAllAtoms(AtomByShape(state->s));
     75  World::getInstance().unselectAllAtoms(AtomsByShape(state->s));
    7676
    7777  return Action::state_ptr(_state);
  • src/Actions/SelectionAction/Atoms/NotAllAtomsInsideSphereAction.cpp

    r22425a r510f81  
    4949  LOG(1, "Unselecting all atoms inside a sphere at " << params.position << " with radius " << params.radius << ".");
    5050  Shape s = translate(resize(Sphere(),params.radius),params.position);
    51   std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && AtomByShape(s));
    52   World::getInstance().unselectAllAtoms(AtomByShape(s));
     51  std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && AtomsByShape(s));
     52  World::getInstance().unselectAllAtoms(AtomsByShape(s));
    5353  LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected.");
    5454  return Action::state_ptr(new SelectionNotAllAtomsInsideSphereState(unselectedAtoms, s, params));
     
    5858  SelectionNotAllAtomsInsideSphereState *state = assert_cast<SelectionNotAllAtomsInsideSphereState*>(_state.get());
    5959
    60   World::getInstance().selectAllAtoms(AtomByShape(state->s));
     60  World::getInstance().selectAllAtoms(AtomsByShape(state->s));
    6161  BOOST_FOREACH(atom *_atom, state->unselectedAtoms)
    6262    World::getInstance().unselectAtom(_atom);
     
    6868  SelectionNotAllAtomsInsideSphereState *state = assert_cast<SelectionNotAllAtomsInsideSphereState*>(_state.get());
    6969
    70   World::getInstance().unselectAllAtoms(AtomByShape(state->s));
     70  World::getInstance().unselectAllAtoms(AtomsByShape(state->s));
    7171
    7272  return Action::state_ptr(_state);
  • src/Atom/Makefile.am

    r22425a r510f81  
    2929  Atom/TesselPoint.hpp
    3030
     31COPYATOMSSOURCE = \
     32        Atom/CopyAtoms/CopyAtoms_SaturateDanglingBonds.cpp \
     33        Atom/CopyAtoms/CopyAtoms_withBonds.cpp
     34
     35COPYATOMSHEADER = \
     36        Atom/CopyAtoms/CopyAtoms_SaturateDanglingBonds.hpp \
     37        Atom/CopyAtoms/CopyAtoms_Simple.hpp \
     38        Atom/CopyAtoms/CopyAtoms_withBonds.hpp \
     39        Atom/CopyAtoms/CopyAtomsInterface.hpp
    3140
    3241noinst_LTLIBRARIES += libMolecuilderAtom.la
    3342libMolecuilderAtom_la_includedir = $(includedir)/MoleCuilder/Atom/
    3443
    35 nobase_libMolecuilderAtom_la_include_HEADERS = ${ATOMHEADER}
     44nobase_libMolecuilderAtom_la_include_HEADERS = $(ATOMHEADER) $(COPYATOMSHEADER)
    3645
    3746## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
     
    4352## from each source file.  Note that it is not necessary to list header files
    4453## which are already listed elsewhere in a _HEADERS variable assignment.
    45 libMolecuilderAtom_la_SOURCES = ${ATOMSOURCE}
     54libMolecuilderAtom_la_SOURCES = $(ATOMSOURCE) $(COPYATOMSSOURCE)
    4655
    4756## Instruct libtool to include ABI version information in the generated shared
  • src/Atom/unittests/Makefile.am

    r22425a r510f81  
    44ATOMTESTSSOURCES = \
    55        ../Atom/unittests/AtomObserverUnitTest.cpp \
     6        ../Atom/unittests/CopyAtomsInterfaceUnitTest.cpp \
    67        stubs/ObserverStub.cpp
    78
    89ATOMTESTSHEADERS = \
    910        ../Atom/unittests/AtomObserverUnitTest.hpp \
     11        ../Atom/unittests/CopyAtomsInterfaceUnitTest.hpp \
    1012        stubs/ObserverStub.hpp
    1113
    1214ATOMTESTS = \
    13   AtomObserverUnitTest
     15  AtomObserverUnitTest \
     16  CopyAtomsInterfaceUnitTest
    1417
    1518TESTS += $(ATOMTESTS)
     
    3538AtomObserverUnitTest_LDADD = ${ATOMTESTLIBS}
    3639
     40CopyAtomsInterfaceUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     41        ../Atom/unittests/CopyAtomsInterfaceUnitTest.cpp \
     42        ../Atom/unittests/CopyAtomsInterfaceUnitTest.hpp
     43CopyAtomsInterfaceUnitTest_LDADD = ${ATOMTESTLIBS}
    3744
    3845
  • src/Descriptors/AtomShapeDescriptor.cpp

    r22425a r510f81  
    3535}
    3636
     37atom* AtomShapeDescriptor_impl::find(){
     38  LinkedCell::LinkedCell_View view = World::getInstance().getLinkedCell(shape.getRadius());
     39  LinkedCell::LinkedList list = view.getPointsInsideSphere(shape.getRadius(), shape.getCenter());
     40  for (LinkedCell::LinkedList::iterator iter = list.begin(); iter != list.end(); ++iter) {
     41    atom * const _atom = static_cast<atom *>(const_cast<TesselPoint *>(*iter));
     42    if (shape.isInside(_atom->getPosition()))
     43      return _atom;
     44  }
     45  return NULL;
     46}
    3747
    38 AtomDescriptor AtomByShape(const Shape &shape){
     48std::vector<atom*> AtomShapeDescriptor_impl::findAll(){
     49  LinkedCell::LinkedCell_View view = World::getInstance().getLinkedCell(shape.getRadius());
     50  LinkedCell::LinkedList list = view.getPointsInsideSphere(shape.getRadius(), shape.getCenter());
     51  std::vector<atom*> res;
     52  for (LinkedCell::LinkedList::iterator iter = list.begin(); iter != list.end(); ++iter) {
     53    atom * const _atom = static_cast<atom *>(const_cast<TesselPoint *>(*iter));
     54    if (shape.isInside(_atom->getPosition()))
     55      res.push_back(_atom);
     56  }
     57  return res;
     58}
     59
     60
     61AtomDescriptor AtomsByShape(const Shape &shape){
    3962  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomShapeDescriptor_impl(shape)));
    4063}
  • src/Descriptors/AtomShapeDescriptor.hpp

    r22425a r510f81  
    2020class Shape;
    2121
    22 AtomDescriptor AtomByShape(const Shape &shape);
     22AtomDescriptor AtomsByShape(const Shape &shape);
    2323
    2424#endif /* ATOMSHAPEDESCRIPTOR_HPP_ */
  • src/Descriptors/AtomShapeDescriptor_impl.hpp

    r22425a r510f81  
    2727  bool predicate(std::pair<atomId_t,atom*> atom);
    2828private:
     29  virtual atom* find();
     30  virtual std::vector<atom*> findAll();
     31
    2932  Shape shape;
    3033};
  • src/Fragmentation/Fragmentation.cpp

    r22425a r510f81  
    2727#include "Atom/atom.hpp"
    2828#include "Bond/bond.hpp"
     29#include "Descriptors/MoleculeDescriptor.hpp"
    2930#include "Element/element.hpp"
    3031#include "Element/periodentafel.hpp"
  • src/Graph/DepthFirstSearchAnalysis.cpp

    r22425a r510f81  
    3232#include "CodePatterns/Verbose.hpp"
    3333#include "Descriptors/AtomDescriptor.hpp"
     34#include "Descriptors/MoleculeDescriptor.hpp"
    3435#include "molecule.hpp"
    3536#include "MoleculeLeafClass.hpp"
  • src/IdPool_impl.hpp

    r22425a r510f81  
    9696    return;
    9797  }
    98   LOG(1, "STATUS: Defragmenting id pool.");
     98  LOG(3, "DEBUG: Defragmenting id pool.");
    9999  for(typename IdPool_t::iterator iter = pool.begin();iter!=pool.end();) {
    100100    // see if this range is adjacent to the next one
  • src/LinkedCell/Makefile.am

    r22425a r510f81  
    2020  LinkedCell/LinkedCell_Model.hpp \
    2121  LinkedCell/LinkedCell_Model_changeModel.hpp \
     22  LinkedCell/LinkedCell_Model_inline.hpp \
    2223  LinkedCell/LinkedCell_Model_LinkedCellArrayCache.hpp \
    2324  LinkedCell/LinkedCell_Model_Update.hpp \
  • src/LinkedCell/unittests/Makefile.am

    r22425a r510f81  
    5353        ../LinkedCell/unittests/LinkedCell_ControllerUnitTest.hpp \
    5454        ../LinkedCell/unittests/defs.hpp \
    55         ../LinkedCell/unittests/stubs/AtomStub.cpp \
     55        stubs/AtomStub.cpp \
    5656        ../LinkedCell/unittests/stubs/AtomObserverStub.cpp \
    5757        ../LinkedCell/unittests/stubs/ObserverBoxStub.cpp \
    5858        ../LinkedCell/unittests/stubs/TesselPointStub.cpp \
    59         ../LinkedCell/unittests/stubs/WorldStub.cpp \
    6059        ../LinkedCell/unittests/stubs/WorldTimeStub.cpp \
     60        stubs/WorldStub.cpp \
    6161        ../LinkedCell/PointCloudAdaptor.hpp \
    6262        ../Box_BoundaryConditions.cpp \
  • src/Makefile.am

    r22425a r510f81  
    1313include Atom/Makefile.am
    1414include Element/Makefile.am
     15include Filling/Makefile.am
    1516include Fragmentation/Makefile.am
    1617include Graph/Makefile.am
     
    124125
    125126TESSELATIONSOURCE = \
     127  Tesselation/ApproximateShapeArea.cpp \
     128  Tesselation/ApproximateShapeVolume.cpp \
    126129  Tesselation/boundary.cpp \
    127130  Tesselation/BoundaryLineSet.cpp \
     
    136139 
    137140TESSELATIONHEADER = \
     141  Tesselation/ApproximateShapeArea.hpp \
     142  Tesselation/ApproximateShapeVolume.hpp \
    138143  Tesselation/boundary.hpp \
    139144  Tesselation/BoundaryLineSet.hpp \
     
    154159  ${THERMOSTATSOURCE} \
    155160  ${TESSELATIONSOURCE} \
     161  AtomIdSet.cpp \
    156162  Box.cpp \
    157163  Box_BoundaryConditions.cpp \
     
    175181  ${THERMOSTATHEADER} \
    176182  ${TESSELATIONHEADER} \
     183  AtomIdSet.hpp \
    177184  Box.hpp \
    178185  Box_BoundaryConditions.hpp \
  • src/Shapes/BaseShapes.cpp

    r22425a r510f81  
    3737#include <algorithm>
    3838
    39 bool Sphere_impl::isInside(const Vector &point){
    40   return point.NormSquared()<=1;
    41 }
    42 
    43 bool Sphere_impl::isOnSurface(const Vector &point){
    44   return fabs(point.NormSquared()-1)<MYEPSILON;
    45 }
    46 
    47 Vector Sphere_impl::getNormal(const Vector &point) throw(NotOnSurfaceException){
     39bool Sphere_impl::isInside(const Vector &point) const{
     40  return point.NormSquared()<=1.;
     41}
     42
     43bool Sphere_impl::isOnSurface(const Vector &point) const{
     44  return fabs(point.NormSquared()-1.)<MYEPSILON;
     45}
     46
     47Vector Sphere_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException){
    4848  if(!isOnSurface(point)){
    4949    throw NotOnSurfaceException() << ShapeVector(&point);
     
    5252}
    5353
    54 LineSegmentSet Sphere_impl::getLineIntersections(const Line &line){
     54Vector Sphere_impl::getCenter() const
     55{
     56  return Vector(0.,0.,0.);
     57}
     58
     59double Sphere_impl::getRadius() const
     60{
     61  return 1.;
     62}
     63
     64double Sphere_impl::getVolume() const
     65{
     66        return (4./3.)*M_PI; // 4/3 pi r^3
     67}
     68
     69double Sphere_impl::getSurfaceArea() const
     70{
     71        return 2.*M_PI; // 2 pi r^2
     72}
     73
     74
     75LineSegmentSet Sphere_impl::getLineIntersections(const Line &line) const{
    5576  LineSegmentSet res(line);
    5677  std::vector<Vector> intersections = line.getSphereIntersections();
     
    6182}
    6283
    63 std::string Sphere_impl::toString(){
     84std::string Sphere_impl::toString() const{
    6485  return "Sphere()";
     86}
     87
     88enum ShapeType Sphere_impl::getType() const
     89{
     90        return SphereType;
    6591}
    6692
     
    115141}
    116142
     143std::vector<Vector> Sphere_impl::getHomogeneousPointsInVolume(const size_t N) const {
     144        ASSERT(0,
     145                        "Sphere_impl::getHomogeneousPointsInVolume() - not implemented.");
     146        return std::vector<Vector>();
     147}
    117148
    118149Shape Sphere(){
     
    129160}
    130161
    131 bool Cuboid_impl::isInside(const Vector &point){
     162bool Cuboid_impl::isInside(const Vector &point) const{
    132163  return (point[0]>=0 && point[0]<=1) && (point[1]>=0 && point[1]<=1) && (point[2]>=0 && point[2]<=1);
    133164}
    134165
    135 bool Cuboid_impl::isOnSurface(const Vector &point){
     166bool Cuboid_impl::isOnSurface(const Vector &point) const{
    136167  bool retVal = isInside(point);
    137168  // test all borders of the cuboid
     
    144175}
    145176
    146 Vector Cuboid_impl::getNormal(const Vector &point) throw(NotOnSurfaceException){
     177Vector Cuboid_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException){
    147178  if(!isOnSurface(point)){
    148179    throw NotOnSurfaceException() << ShapeVector(&point);
     
    162193}
    163194
    164 LineSegmentSet Cuboid_impl::getLineIntersections(const Line &line){
     195
     196Vector Cuboid_impl::getCenter() const
     197{
     198  return Vector(0.5,0.5,0.5);
     199}
     200
     201double Cuboid_impl::getRadius() const
     202{
     203  return .5;
     204}
     205
     206double Cuboid_impl::getVolume() const
     207{
     208        return 1.; // l^3
     209}
     210
     211double Cuboid_impl::getSurfaceArea() const
     212{
     213        return 6.;      // 6 * l^2
     214}
     215
     216LineSegmentSet Cuboid_impl::getLineIntersections(const Line &line) const{
    165217  LineSegmentSet res(line);
    166218  // get the intersection on each of the six faces
     
    192244}
    193245
    194 std::string Cuboid_impl::toString(){
     246std::string Cuboid_impl::toString() const{
    195247  return "Cuboid()";
     248}
     249
     250enum ShapeType Cuboid_impl::getType() const
     251{
     252        return CuboidType;
    196253}
    197254
     
    203260  ASSERT(false, "Cuboid_impl::getHomogeneousPointsOnSurface() not implemented yet");
    204261  return PointsOnSurface;
     262}
     263
     264std::vector<Vector> Cuboid_impl::getHomogeneousPointsInVolume(const size_t N) const {
     265        ASSERT(0,
     266                        "Cuboid_impl::getHomogeneousPointsInVolume() - not implemented.");
     267        return std::vector<Vector>();
    205268}
    206269
  • src/Shapes/BaseShapes_impl.hpp

    r22425a r510f81  
    2020#include "Shapes/Shape_impl.hpp"
    2121#include "Shapes/ShapeExceptions.hpp"
     22#include "Shapes/ShapeType.hpp"
    2223
    2324class Sphere_impl : public Shape_impl {
    24   virtual bool isInside(const Vector &point);
    25   virtual bool isOnSurface(const Vector &point);
    26   virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
    27   virtual LineSegmentSet getLineIntersections(const Line&);
    28   virtual std::string toString();
     25  virtual bool isInside(const Vector &point) const;
     26  virtual bool isOnSurface(const Vector &point) const;
     27  virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
     28  virtual Vector getCenter() const;
     29  virtual double getRadius() const;
     30  virtual double getVolume() const;
     31  virtual double getSurfaceArea() const;
     32  virtual LineSegmentSet getLineIntersections(const Line&) const;
     33  virtual std::string toString() const;
     34  virtual enum ShapeType getType() const;
    2935  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     36  virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    3037};
    3138
    3239class Cuboid_impl : public Shape_impl {
    33   virtual bool isInside(const Vector &point);
    34   virtual bool isOnSurface(const Vector &point);
    35   virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
    36   virtual LineSegmentSet getLineIntersections(const Line&);
    37   virtual std::string toString();
     40  virtual bool isInside(const Vector &point) const;
     41  virtual bool isOnSurface(const Vector &point) const;
     42  virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
     43  virtual Vector getCenter() const;
     44  virtual double getRadius() const;
     45  virtual double getVolume() const;
     46  virtual double getSurfaceArea() const;
     47  virtual LineSegmentSet getLineIntersections(const Line&) const;
     48  virtual std::string toString() const;
     49  virtual enum ShapeType getType() const;
    3850  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     51  virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    3952};
    4053
  • src/Shapes/Makefile.am

    r22425a r510f81  
    1313  Shapes/ShapeExceptions.hpp \
    1414  Shapes/ShapeOps.hpp \
    15   Shapes/ShapeOps_impl.hpp
     15  Shapes/ShapeOps_impl.hpp \
     16  Shapes/ShapeType.hpp
    1617
    17  
    1818
    1919noinst_LTLIBRARIES += libMolecuilderShapes.la
  • src/Shapes/Shape.cpp

    r22425a r510f81  
    2626#include "Shapes/Shape_impl.hpp"
    2727#include "Shapes/ShapeExceptions.hpp"
    28 
     28#include "Shapes/ShapeType.hpp"
     29
     30#include "Tesselation/ApproximateShapeArea.hpp"
     31#include "Tesselation/ApproximateShapeVolume.hpp"
     32
     33#include <algorithm>
     34#include <limits>
    2935#include <string>
    3036
     
    4854}
    4955
    50 LineSegmentSet Shape::getLineIntersections(const Line &line){
     56Vector Shape::getCenter() const{
     57  return impl->getCenter();
     58}
     59
     60double Shape::getRadius() const{
     61  return impl->getRadius();
     62}
     63
     64/** Returns the volume of the Shape.
     65 *
     66 * If the underlying implementation does not have a working implementation,
     67 * i.e. returns -1., then we use an approximate method to calculate the
     68 * volume via a mesh of grid points and checking for isInside (basically
     69 * a Monte-Carlo integration of the volume).
     70 *
     71 * \return volume of the shape
     72 */
     73double Shape::getVolume() const
     74{
     75        const double volume = impl->getVolume();
     76        if (volume  != -1.) {
     77                return volume;
     78        } else {
     79                ApproximateShapeVolume Approximator(*this);
     80                return Approximator();
     81        }
     82}
     83
     84/** Returns the surface area of the Shape.
     85 *
     86 * If the underlying implementation does not have a working implementation,
     87 * i.e. returns -1., then we use the working filling of the shapes surface
     88 * with points and subsequent tesselation and obtaining the approximate
     89 * surface area therefrom.
     90 *
     91 * @return surface area of the Shape
     92 */
     93double Shape::getSurfaceArea() const
     94{
     95        const double surfacearea = impl->getSurfaceArea();
     96        if (surfacearea != -1.) {
     97                return surfacearea;
     98        } else {
     99                ApproximateShapeArea Approximator(*this);
     100                return Approximator();
     101        }
     102}
     103
     104LineSegmentSet Shape::getLineIntersections(const Line &line) const{
    51105  return impl->getLineIntersections(line);
    52106}
     
    54108std::vector<Vector> Shape::getHomogeneousPointsOnSurface(const size_t N) const {
    55109  return impl->getHomogeneousPointsOnSurface(N);
     110}
     111
     112std::vector<Vector> Shape::getHomogeneousPointsInVolume(const size_t N) const {
     113        return impl->getHomogeneousPointsInVolume(N);
    56114}
    57115
     
    67125}
    68126
     127bool Shape::operator==(const Shape &rhs) const{
     128        return (this->getType() == rhs.getType());
     129}
     130
    69131std::string Shape::toString() const{
    70132  return impl->toString();
     133}
     134
     135enum ShapeType Shape::getType() const{
     136        return impl->getType();
    71137}
    72138
     
    102168AndShape_impl::~AndShape_impl(){}
    103169
    104 bool AndShape_impl::isInside(const Vector &point){
     170bool AndShape_impl::isInside(const Vector &point) const{
    105171  return lhs->isInside(point) && rhs->isInside(point);
    106172}
    107173
    108 bool AndShape_impl::isOnSurface(const Vector &point){
     174bool AndShape_impl::isOnSurface(const Vector &point) const{
    109175  // check the number of surfaces that this point is on
    110176  int surfaces =0;
     
    138204}
    139205
    140 Vector AndShape_impl::getNormal(const Vector &point) throw (NotOnSurfaceException){
     206Vector AndShape_impl::getNormal(const Vector &point) const throw (NotOnSurfaceException){
    141207  Vector res;
    142208  if(!isOnSurface(point)){
     
    149215}
    150216
    151 LineSegmentSet AndShape_impl::getLineIntersections(const Line &line){
     217Vector AndShape_impl::getCenter() const
     218{
     219  // calculate closest position on sphere surface to other center ..
     220  const Vector rhsDistance = rhs->getCenter() + rhs->getRadius()*((lhs->getCenter() - rhs->getCenter()).getNormalized());
     221  const Vector lhsDistance = lhs->getCenter() + lhs->getRadius()*((rhs->getCenter() - lhs->getCenter()).getNormalized());
     222  // .. and then it's right in between those two
     223  return 0.5*(rhsDistance + lhsDistance);
     224}
     225
     226double AndShape_impl::getRadius() const
     227{
     228  const double distance = (lhs->getCenter() - rhs->getCenter()).Norm();
     229  const double minradii = std::min(lhs->getRadius(), rhs->getRadius());
     230  // if no intersection
     231  if (distance > (lhs->getRadius() + rhs->getRadius()))
     232    return 0.;
     233  else // if intersection it can only be the smaller one
     234    return minradii;
     235}
     236
     237double AndShape_impl::getVolume() const
     238{
     239        // TODO
     240        return -1.;
     241}
     242
     243double AndShape_impl::getSurfaceArea() const
     244{
     245        // TODO
     246        return -1.;
     247}
     248
     249LineSegmentSet AndShape_impl::getLineIntersections(const Line &line) const{
    152250  return intersect(lhs->getLineIntersections(line),rhs->getLineIntersections(line));
    153251}
    154252
    155 std::string AndShape_impl::toString() {
     253std::string AndShape_impl::toString() const{
    156254  return std::string("(") + lhs->toString() + std::string("&&") + rhs->toString() + std::string(")");
     255}
     256
     257enum ShapeType AndShape_impl::getType() const{
     258        return CombinedType;
    157259}
    158260
     
    174276}
    175277
     278std::vector<Vector> AndShape_impl::getHomogeneousPointsInVolume(const size_t N) const {
     279        ASSERT(0,
     280                        "AndShape_impl::getHomogeneousPointsInVolume() - not implemented.");
     281        return std::vector<Vector>();
     282}
     283
    176284
    177285Shape operator&&(const Shape &lhs,const Shape &rhs){
     
    188296OrShape_impl::~OrShape_impl(){}
    189297
    190 bool OrShape_impl::isInside(const Vector &point){
     298bool OrShape_impl::isInside(const Vector &point) const{
    191299  return rhs->isInside(point) || lhs->isInside(point);
    192300}
    193301
    194 bool OrShape_impl::isOnSurface(const Vector &point){
     302bool OrShape_impl::isOnSurface(const Vector &point) const{
    195303  // check the number of surfaces that this point is on
    196304  int surfaces =0;
     
    224332}
    225333
    226 Vector OrShape_impl::getNormal(const Vector &point) throw (NotOnSurfaceException){
     334Vector OrShape_impl::getNormal(const Vector &point) const throw (NotOnSurfaceException){
    227335  Vector res;
    228336  if(!isOnSurface(point)){
     
    235343}
    236344
    237 LineSegmentSet OrShape_impl::getLineIntersections(const Line &line){
     345Vector OrShape_impl::getCenter() const
     346{
     347  // calculate furthest position on sphere surface to other center ..
     348  const Vector rhsDistance = rhs->getCenter() + rhs->getRadius()*((rhs->getCenter() - lhs->getCenter()).getNormalized());
     349  const Vector lhsDistance = lhs->getCenter() + lhs->getRadius()*((lhs->getCenter() - rhs->getCenter()).getNormalized());
     350  // .. and then it's right in between those two
     351  return .5*(rhsDistance + lhsDistance);
     352}
     353
     354double OrShape_impl::getRadius() const
     355{
     356  const Vector rhsDistance = rhs->getCenter() + rhs->getRadius()*((rhs->getCenter() - lhs->getCenter()).getNormalized());
     357  const Vector lhsDistance = lhs->getCenter() + lhs->getRadius()*((lhs->getCenter() - rhs->getCenter()).getNormalized());
     358  return .5*(rhsDistance - lhsDistance).Norm();
     359}
     360
     361double OrShape_impl::getVolume() const
     362{
     363        // TODO
     364        return -1.;
     365}
     366
     367double OrShape_impl::getSurfaceArea() const
     368{
     369        // TODO
     370        return -1.;
     371}
     372
     373LineSegmentSet OrShape_impl::getLineIntersections(const Line &line) const{
    238374  return merge(lhs->getLineIntersections(line),rhs->getLineIntersections(line));
    239375}
    240376
    241 std::string OrShape_impl::toString() {
     377std::string OrShape_impl::toString() const{
    242378  return std::string("(") + lhs->toString() + std::string("||") + rhs->toString() + std::string(")");
     379}
     380
     381enum ShapeType OrShape_impl::getType() const{
     382        return CombinedType;
    243383}
    244384
     
    260400}
    261401
     402std::vector<Vector> OrShape_impl::getHomogeneousPointsInVolume(const size_t N) const {
     403        ASSERT(0,
     404                        "OrShape_impl::getHomogeneousPointsInVolume() - not implemented.");
     405        return std::vector<Vector>();
     406}
     407
    262408Shape operator||(const Shape &lhs,const Shape &rhs){
    263409  Shape::impl_ptr newImpl = Shape::impl_ptr(new OrShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
     
    273419NotShape_impl::~NotShape_impl(){}
    274420
    275 bool NotShape_impl::isInside(const Vector &point){
     421bool NotShape_impl::isInside(const Vector &point) const{
    276422  return !arg->isInside(point);
    277423}
    278424
    279 bool NotShape_impl::isOnSurface(const Vector &point){
     425bool NotShape_impl::isOnSurface(const Vector &point) const{
    280426  return arg->isOnSurface(point);
    281427}
    282428
    283 Vector NotShape_impl::getNormal(const Vector &point) throw(NotOnSurfaceException){
     429Vector NotShape_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException){
    284430  return -1.*arg->getNormal(point);
    285431}
    286432
    287 LineSegmentSet NotShape_impl::getLineIntersections(const Line &line){
     433Vector NotShape_impl::getCenter() const
     434{
     435  return arg->getCenter();
     436}
     437
     438double NotShape_impl::getRadius() const
     439{
     440  return std::numeric_limits<double>::infinity();
     441}
     442
     443double NotShape_impl::getVolume() const
     444{
     445        // TODO
     446        return -1.; //-arg->getVolume();
     447}
     448
     449double NotShape_impl::getSurfaceArea() const
     450{
     451        // TODO
     452        return -1.; // -arg->getSurfaceArea();
     453}
     454
     455LineSegmentSet NotShape_impl::getLineIntersections(const Line &line) const{
    288456  return invert(arg->getLineIntersections(line));
    289457}
    290458
    291 std::string NotShape_impl::toString(){
     459std::string NotShape_impl::toString() const{
    292460  return std::string("!") + arg->toString();
     461}
     462
     463enum ShapeType NotShape_impl::getType() const{
     464        return CombinedType;
    293465}
    294466
     
    296468  // surfaces are the same, only normal direction is different
    297469  return arg->getHomogeneousPointsOnSurface(N);
     470}
     471
     472std::vector<Vector> NotShape_impl::getHomogeneousPointsInVolume(const size_t N) const {
     473        ASSERT(0,
     474                        "NotShape_impl::getHomogeneousPointsInVolume() - not implemented.");
     475        return std::vector<Vector>();
    298476}
    299477
  • src/Shapes/Shape.hpp

    r22425a r510f81  
    1919
    2020#include "Shapes/ShapeExceptions.hpp"
     21#include "Shapes/ShapeType.hpp"
    2122
    2223#include <vector>
     
    4142  Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
    4243
    43   LineSegmentSet getLineIntersections(const Line&);
     44  Vector getCenter() const;
     45  double getRadius() const;
     46  double getVolume() const;
     47  double getSurfaceArea() const;
     48
     49  LineSegmentSet getLineIntersections(const Line&) const;
    4450  std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     51  std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    4552
    4653  Shape &operator=(const Shape& rhs);
    4754
     55  bool operator==(const Shape &rhs) const;
     56
    4857  std::string toString() const;
     58  enum ShapeType getType() const;
     59
    4960protected:
    5061  impl_ptr getImpl() const;
  • src/Shapes/ShapeOps.cpp

    r22425a r510f81  
    2020#include "CodePatterns/MemDebug.hpp"
    2121
     22#include <algorithm>
     23#include <boost/bind.hpp>
     24
    2225#include "Shapes/ShapeExceptions.hpp"
    2326#include "Shapes/ShapeOps.hpp"
     
    3437ShapeOpsBase_impl::~ShapeOpsBase_impl(){}
    3538
    36 bool ShapeOpsBase_impl::isInside(const Vector &point){
     39bool ShapeOpsBase_impl::isInside(const Vector &point) const{
    3740  return arg->isInside(translateIn(point));
    3841}
    3942
    40 bool ShapeOpsBase_impl::isOnSurface(const Vector &point){
     43bool ShapeOpsBase_impl::isOnSurface(const Vector &point) const{
    4144  return arg->isOnSurface(translateIn(point));
    4245}
    4346
    44 Vector ShapeOpsBase_impl::getNormal(const Vector &point) throw (NotOnSurfaceException){
     47Vector ShapeOpsBase_impl::getNormal(const Vector &point) const throw (NotOnSurfaceException){
    4548  Vector helper = translateIn(point);
    4649  if(!arg->isOnSurface(helper)){
     
    5255}
    5356
    54 LineSegmentSet ShapeOpsBase_impl::getLineIntersections(const Line &line){
     57Vector ShapeOpsBase_impl::getCenter() const
     58{
     59  return arg->getCenter();
     60}
     61
     62double ShapeOpsBase_impl::getRadius() const
     63{
     64  return translateOutPos(Vector(arg->getRadius(), 0., 0.)).Norm();
     65}
     66
     67
     68LineSegmentSet ShapeOpsBase_impl::getLineIntersections(const Line &line) const{
    5569  Line newLine(translateIn(line.getOrigin()),translateIn(line.getDirection()));
    5670  LineSegmentSet res(line);
     
    7185}
    7286
     87enum ShapeType ShapeOpsBase_impl::getType() const {
     88        return getArg()->getType();
     89}
     90
    7391std::vector<Vector> ShapeOpsBase_impl::getHomogeneousPointsOnSurface(const size_t N) const {
    74   return getArg()->getHomogeneousPointsOnSurface(N);;
     92  return getArg()->getHomogeneousPointsOnSurface(N);
     93}
     94
     95std::vector<Vector> ShapeOpsBase_impl::getHomogeneousPointsInVolume(const size_t N) const {
     96  return getArg()->getHomogeneousPointsInVolume(N);
    7597}
    7698
     
    89111Resize_impl::~Resize_impl(){}
    90112
    91 bool Resize_impl::isInside(const Vector& point){
     113double Resize_impl::getVolume() const
     114{
     115        return getArg()->getVolume() * size;
     116}
     117
     118double Resize_impl::getSurfaceArea() const
     119{
     120        return getArg()->getSurfaceArea() * size;
     121}
     122
     123
     124bool Resize_impl::isInside(const Vector& point) const{
    92125  return getArg()->isInside((1/size) * point);
    93126}
    94127
    95 Vector Resize_impl::translateIn(const Vector& point){
     128Vector Resize_impl::translateIn(const Vector& point) const{
    96129  return (1/size) * point;
    97130}
    98131
    99 Vector Resize_impl::translateOutPos(const Vector& point){
     132Vector Resize_impl::translateOutPos(const Vector& point) const{
    100133  return size * point;
    101134}
    102135
    103 Vector Resize_impl::translateOutNormal(const Vector& point){
     136Vector Resize_impl::translateOutNormal(const Vector& point) const{
    104137  return point;
    105138}
    106139
    107 std::string Resize_impl::toString() {
     140std::string Resize_impl::toString() const{
    108141  std::stringstream sstr;
    109142  sstr << "resize(" << getArg()->toString() << "," << size << ")";
     
    113146std::vector<Vector> Resize_impl::getHomogeneousPointsOnSurface(const size_t N) const {
    114147  std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N);
    115   for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
    116     *iter *= size;
    117   }
    118   return PointsOnSurface;
     148  std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(),
     149                boost::bind(&Vector::operator*, _1, size) );
     150  return PointsOnSurface;
     151}
     152
     153std::vector<Vector> Resize_impl::getHomogeneousPointsInVolume(const size_t N) const {
     154  std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsInVolume(N);
     155  std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(),
     156                boost::bind(&Vector::operator*, _1, size) );
     157        return std::vector<Vector>();
    119158}
    120159
     
    133172Translate_impl::~Translate_impl(){}
    134173
    135 bool Translate_impl::isInside(const Vector& point){
     174bool Translate_impl::isInside(const Vector& point) const{
    136175  return getArg()->isInside(point-offset);
    137176}
    138177
    139 Vector Translate_impl::translateIn(const Vector& point){
     178Vector Translate_impl::getCenter() const
     179{
     180  return getArg()->getCenter()+offset;
     181}
     182
     183double Translate_impl::getRadius() const
     184{
     185  return getArg()->getRadius();
     186}
     187
     188double Translate_impl::getVolume() const
     189{
     190        return getArg()->getVolume();
     191}
     192
     193double Translate_impl::getSurfaceArea() const
     194{
     195        return getArg()->getSurfaceArea();
     196}
     197
     198Vector Translate_impl::translateIn(const Vector& point) const{
    140199  return point-offset;
    141200}
    142201
    143 Vector Translate_impl::translateOutPos(const Vector& point){
     202Vector Translate_impl::translateOutPos(const Vector& point) const{
    144203  return point+offset;
    145204}
    146205
    147 Vector Translate_impl::translateOutNormal(const Vector& point){
     206Vector Translate_impl::translateOutNormal(const Vector& point) const{
    148207  return point;
    149208}
    150209
    151 std::string Translate_impl::toString() {
     210std::string Translate_impl::toString() const{
    152211  std::stringstream sstr;
    153212  sstr << "translate(" << getArg()->toString() << "," << offset << ")";
     
    157216std::vector<Vector> Translate_impl::getHomogeneousPointsOnSurface(const size_t N) const {
    158217  std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N);
    159   for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
    160     *iter += offset;
    161   }
     218  std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(),
     219                boost::bind(&Vector::operator+, _1, offset) );
     220  return PointsOnSurface;
     221}
     222
     223std::vector<Vector> Translate_impl::getHomogeneousPointsInVolume(const size_t N) const {
     224  std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsInVolume(N);
     225  std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(),
     226                boost::bind(&Vector::operator+, _1, offset) );
    162227  return PointsOnSurface;
    163228}
     
    173238  ShapeOpsBase_impl(_arg),factors(_factors)
    174239{
    175   ASSERT(factors[0]>0,"cannot stretch a shape by a negative amount");
    176   ASSERT(factors[1]>0,"cannot stretch a shape by a negative amount");
    177   ASSERT(factors[2]>0,"cannot stretch a shape by a negative amount");
    178240  for(int i = NDIM;i--;){
    179     reciFactors[i] = 1/factors[i];
     241    ASSERT(factors[i]>0.,"cannot stretch a shape by a negative amount");
     242    reciFactors[i] = 1./factors[i];
    180243  }
    181244}
     
    183246Stretch_impl::~Stretch_impl(){}
    184247
    185 bool Stretch_impl::isInside(const Vector& point){
     248double Stretch_impl::getVolume() const
     249{
     250        // TODO
     251        return -1.;
     252}
     253
     254double Stretch_impl::getSurfaceArea() const
     255{
     256        // TODO
     257        return -1.;
     258}
     259
     260bool Stretch_impl::isInside(const Vector& point) const{
    186261  Vector helper=point;
    187262  helper.ScaleAll(reciFactors);
     
    189264}
    190265
    191 Vector Stretch_impl::translateIn(const Vector& point){
     266Vector Stretch_impl::translateIn(const Vector& point) const{
    192267  Vector helper=point;
    193268  helper.ScaleAll(reciFactors);
     
    195270}
    196271
    197 Vector Stretch_impl::translateOutPos(const Vector& point){
     272Vector Stretch_impl::translateOutPos(const Vector& point) const{
    198273  Vector helper=point;
    199274  helper.ScaleAll(factors);
     
    201276}
    202277
    203 Vector Stretch_impl::translateOutNormal(const Vector& point){
     278Vector Stretch_impl::translateOutNormal(const Vector& point) const{
    204279  Vector helper=point;
    205280  // the normalFactors are derived from appearances of the factors
     
    213288}
    214289
    215 std::string Stretch_impl::toString() {
     290std::string Stretch_impl::toString() const{
    216291  std::stringstream sstr;
    217292  sstr << "stretch(" << getArg()->toString() << "," << factors << ")";
     
    221296std::vector<Vector> Stretch_impl::getHomogeneousPointsOnSurface(const size_t N) const {
    222297  std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N);
    223   for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
    224     (*iter).ScaleAll(reciFactors);
    225   }
     298  std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(),
     299                boost::bind( static_cast<void (Vector::*)(const Vector&)>(&Vector::ScaleAll), _1, reciFactors) );
     300  return PointsOnSurface;
     301}
     302
     303std::vector<Vector> Stretch_impl::getHomogeneousPointsInVolume(const size_t N) const {
     304  std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsInVolume(N);
     305  std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(),
     306      boost::bind( static_cast<void (Vector::*)(const Vector&)>(&Vector::ScaleAll), _1, reciFactors) );
    226307  return PointsOnSurface;
    227308}
     
    242323Transform_impl::~Transform_impl(){}
    243324
    244 bool Transform_impl::isInside(const Vector& point){
     325double Transform_impl::getVolume() const
     326{
     327        return getArg()->getVolume();
     328}
     329
     330double Transform_impl::getSurfaceArea() const
     331{
     332        return getArg()->getSurfaceArea();
     333}
     334
     335bool Transform_impl::isInside(const Vector& point) const{
    245336  return getArg()->isInside(transformationInv * point);
    246337}
    247338
    248 Vector Transform_impl::translateIn(const Vector& point){
     339Vector Transform_impl::translateIn(const Vector& point) const{
    249340  return transformationInv * point;
    250341}
    251342
    252 Vector Transform_impl::translateOutPos(const Vector& point){
     343Vector Transform_impl::translateOutPos(const Vector& point) const{
    253344  return transformation * point;
    254345}
    255346
    256 Vector Transform_impl::translateOutNormal(const Vector& point){
     347Vector Transform_impl::translateOutNormal(const Vector& point) const
     348{
    257349  RealSpaceMatrix mat = transformation.invert().transpose();
    258350  return mat * point;
    259351}
    260352
    261 std::string Transform_impl::toString() {
     353std::string Transform_impl::toString() const{
    262354  std::stringstream sstr;
    263355  sstr << "transform(" << getArg()->toString() << "," << transformation << ")";
     
    267359std::vector<Vector> Transform_impl::getHomogeneousPointsOnSurface(const size_t N) const {
    268360  std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N);
    269   for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) {
    270     *iter = transformation * (*iter);
    271   }
     361  std::transform( PointsOnSurface.begin(), PointsOnSurface.end(), PointsOnSurface.begin(),
     362      boost::bind(static_cast<Vector(*)(const RealSpaceMatrix&,const Vector&)>(operator*), transformation, _1));
     363  return PointsOnSurface;
     364}
     365
     366std::vector<Vector> Transform_impl::getHomogeneousPointsInVolume(const size_t N) const {
     367  std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsInVolume(N);
     368  std::transform( PointsOnSurface.begin(), PointsOnSurface.end(), PointsOnSurface.begin(),
     369      boost::bind(static_cast<Vector(*)(const RealSpaceMatrix&,const Vector&)>(operator*), transformation, _1));
    272370  return PointsOnSurface;
    273371}
  • src/Shapes/ShapeOps_impl.hpp

    r22425a r510f81  
    1717#include "Shapes/Shape_impl.hpp"
    1818#include "Shapes/ShapeExceptions.hpp"
     19#include "Shapes/ShapeType.hpp"
    1920#include "LinearAlgebra/Vector.hpp"
    2021#include "LinearAlgebra/RealSpaceMatrix.hpp"
     
    2829  ShapeOpsBase_impl(const Shape::impl_ptr&);
    2930  virtual ~ShapeOpsBase_impl();
    30   virtual bool isInside(const Vector &point);
    31   virtual bool isOnSurface(const Vector &point);
    32   virtual Vector getNormal(const Vector &point) throw (NotOnSurfaceException);
    33   virtual LineSegmentSet getLineIntersections(const Line&);
     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);
     34  virtual Vector getCenter() const;
     35  virtual double getRadius() const;
     36  virtual LineSegmentSet getLineIntersections(const Line&) const;
     37  virtual enum ShapeType getType() const;
    3438  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     39  virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    3540protected:
    36   virtual Vector translateIn(const Vector &point)=0;
    37   virtual Vector translateOutPos(const Vector &point)=0;
    38   virtual Vector translateOutNormal(const Vector &point)=0;
     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;
    3944  Shape::impl_ptr getArg() const;
    4045private:
     
    4853  virtual ~Resize_impl();
    4954protected:
    50   virtual Vector translateIn(const Vector &point);
    51   virtual Vector translateOutPos(const Vector &point);
    52   virtual Vector translateOutNormal(const Vector &point);
    53   virtual std::string toString();
    54   virtual bool isInside(const Vector& point);
     55  virtual double getVolume() const;
     56  virtual double getSurfaceArea() const;
     57  virtual Vector translateIn(const Vector &point) const;
     58  virtual Vector translateOutPos(const Vector &point) const;
     59  virtual Vector translateOutNormal(const Vector &point) const;
     60  virtual std::string toString() const;
     61  virtual bool isInside(const Vector& point) const;
    5562  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     63  virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    5664private:
    5765  double size;
     
    6472  virtual ~Translate_impl();
    6573protected:
    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   virtual bool isInside(const Vector& point);
     74  virtual Vector getCenter() const;
     75  virtual double getRadius() const;
     76  virtual double getVolume() const;
     77  virtual double getSurfaceArea() const;
     78  virtual Vector translateIn(const Vector &point) const;
     79  virtual Vector translateOutPos(const Vector &point) const;
     80  virtual Vector translateOutNormal(const Vector &point) const;
     81  virtual std::string toString() const;
     82  virtual bool isInside(const Vector& point) const;
    7183  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     84  virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    7285private:
    7386  Vector offset;
     
    7790{
    7891public:
    79   Stretch_impl(const Shape::impl_ptr&, const Vector&);
     92
     93
     94        Stretch_impl(const Shape::impl_ptr&, const Vector&);
    8095  virtual ~Stretch_impl();
    8196protected:
    82   virtual Vector translateIn(const Vector &point);
    83   virtual Vector translateOutPos(const Vector &point);
    84   virtual Vector translateOutNormal(const Vector &point);
    85   virtual std::string toString();
    86   virtual bool isInside(const Vector& point);
     97  virtual double getVolume() const;
     98  virtual double getSurfaceArea() const;
     99  virtual Vector translateIn(const Vector &point) const;
     100  virtual Vector translateOutPos(const Vector &point) const;
     101  virtual Vector translateOutNormal(const Vector &point) const;
     102  virtual std::string toString() const;
     103  virtual bool isInside(const Vector& point) const;
    87104  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     105  virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    88106private:
    89107  Vector factors;
     
    97115  virtual ~Transform_impl();
    98116protected:
    99   virtual Vector translateIn(const Vector &point);
    100   virtual Vector translateOutPos(const Vector &point);
    101   virtual Vector translateOutNormal(const Vector &point);
    102   virtual std::string toString();
    103   virtual bool isInside(const Vector& point);
     117  virtual double getVolume() const;
     118  virtual double getSurfaceArea() const;
     119  virtual Vector translateIn(const Vector &point) const;
     120  virtual Vector translateOutPos(const Vector &point) const;
     121  virtual Vector translateOutNormal(const Vector &point) const;
     122  virtual std::string toString() const;
     123  virtual bool isInside(const Vector& point) const;
    104124  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     125  virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    105126private:
    106127  RealSpaceMatrix transformation;
  • src/Shapes/Shape_impl.hpp

    r22425a r510f81  
    1515
    1616
     17#include <limits>
    1718#include <vector>
     19
     20#include "CodePatterns/Assert.hpp"
    1821
    1922#include "Shapes/Shape.hpp"
    2023#include "Shapes/ShapeExceptions.hpp"
     24#include "Shapes/ShapeType.hpp"
    2125#include "LinearAlgebra/Line.hpp"
     26#include "LinearAlgebra/LinePoint.hpp"
    2227#include "LinearAlgebra/LineSegment.hpp"
    2328#include "LinearAlgebra/LineSegmentSet.hpp"
     
    2934  Shape_impl(){};
    3035  virtual ~Shape_impl(){};
    31   virtual bool isInside(const Vector &point)=0;
    32   virtual bool isOnSurface(const Vector &point)=0;
    33   virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException)=0;
    34   virtual LineSegmentSet getLineIntersections(const Line&)=0;
    35   virtual std::string toString()=0;
     36  virtual bool isInside(const Vector &point) const=0;
     37  virtual bool isOnSurface(const Vector &point) const=0;
     38  virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException)=0;
     39  virtual Vector getCenter() const=0;
     40  virtual double getRadius() const=0;
     41  virtual double getVolume() const=0;
     42  virtual double getSurfaceArea() const=0;
     43  virtual LineSegmentSet getLineIntersections(const Line&) const=0;
     44  virtual std::string toString() const =0;
     45  virtual enum ShapeType getType() const =0;
    3646  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const=0;
     47  virtual   std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const=0;
    3748};
    3849
    3950class Everywhere_impl : public Shape_impl {
    4051public:
    41   virtual bool isInside(const Vector &point){
     52  virtual bool isInside(const Vector &point) const{
    4253    return true;
    4354  }
    44   virtual bool isOnSurface(const Vector &point){
     55  virtual bool isOnSurface(const Vector &point) const{
    4556    return false;
    4657  }
    47   virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException){
     58  virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException){
    4859    throw NotOnSurfaceException() << ShapeVector(&point);
    4960  }
    50   virtual LineSegmentSet getLineIntersections(const Line &line){
     61  virtual Vector getCenter() const {
     62    return Vector(0.,0.,0.);
     63  }
     64  virtual double getRadius() const {
     65    return std::numeric_limits<double>::infinity();
     66  }
     67  virtual double getVolume() const
     68  {
     69        // TODO
     70        return 0.;
     71  }
     72  virtual double getSurfaceArea() const
     73  {
     74        // TODO
     75        return 0.;
     76  }
     77  virtual LineSegmentSet getLineIntersections(const Line &line) const{
    5178    LineSegmentSet res(line);
    5279    res.insert(LineSegment(line.negEndpoint(),line.posEndpoint()));
    5380    return res;
    5481  }
    55   virtual std::string toString(){
     82  virtual std::string toString() const{
    5683    return "Everywhere()";
     84  }
     85  virtual enum ShapeType getType() const {
     86        return EverywhereType;
    5787  }
    5888  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const {
     
    6090    return PointsOnSurface;
    6191  }
     92  std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const {
     93        ASSERT(0,
     94                        "Everywhere_impl::getHomogeneousPointsInVolume() - not implemented.");
     95        return std::vector<Vector>();
     96  }
    6297};
    6398
    6499class Nowhere_impl : public Shape_impl {
    65   virtual bool isInside(const Vector &point){
     100  virtual bool isInside(const Vector &point) const{
    66101    return false;
    67102  }
    68   virtual bool isOnSurface(const Vector &point){
     103  virtual bool isOnSurface(const Vector &point) const{
    69104    return false;
    70105  }
    71   virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException){
     106  virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException){
    72107    throw NotOnSurfaceException() << ShapeVector(&point);
    73108  }
    74   virtual LineSegmentSet getLineIntersections(const Line &line){
     109  virtual Vector getCenter() const {
     110    return Vector(0.,0.,0.);
     111  }
     112  virtual double getRadius() const {
     113    return 0.;
     114  }
     115  virtual double getVolume() const
     116  {
     117        return 0.;
     118  }
     119  virtual double getSurfaceArea() const
     120  {
     121        return 0.;
     122  }
     123  virtual LineSegmentSet getLineIntersections(const Line &line) const{
    75124    return LineSegmentSet(line);
    76125  }
    77   virtual std::string toString(){
     126  virtual std::string toString() const{
    78127    return "Nowhere()";
     128  }
     129  virtual enum ShapeType getType() const {
     130        return NowhereType;
    79131  }
    80132  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const {
     
    82134    return PointsOnSurface;
    83135  }
     136  std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const {
     137        return std::vector<Vector>();
     138  }
    84139};
    85140
     
    88143  AndShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
    89144  virtual ~AndShape_impl();
    90   virtual bool isInside(const Vector &point);
    91   virtual bool isOnSurface(const Vector &point);
    92   virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
    93   virtual LineSegmentSet getLineIntersections(const Line&);
    94   virtual std::string toString();
     145  virtual bool isInside(const Vector &point) const;
     146  virtual bool isOnSurface(const Vector &point) const;
     147  virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
     148  virtual Vector getCenter() const;
     149  virtual double getRadius() const;
     150  virtual double getVolume() const;
     151  virtual double getSurfaceArea() const;
     152  virtual LineSegmentSet getLineIntersections(const Line&) const;
     153  virtual std::string toString() const;
     154  virtual enum ShapeType getType() const;
    95155  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     156  virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    96157private:
    97158  Shape::impl_ptr lhs;
     
    103164  OrShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&);
    104165  virtual ~OrShape_impl();
    105   virtual bool isInside(const Vector &point);
    106   virtual bool isOnSurface(const Vector &point);
    107   virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
    108   virtual LineSegmentSet getLineIntersections(const Line&);
    109   virtual std::string toString();
     166  virtual bool isInside(const Vector &point) const;
     167  virtual bool isOnSurface(const Vector &point) const;
     168  virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
     169  virtual Vector getCenter() const;
     170  virtual double getRadius() const;
     171  virtual double getVolume() const;
     172  virtual double getSurfaceArea() const;
     173  virtual LineSegmentSet getLineIntersections(const Line&) const;
     174  virtual std::string toString() const;
     175  virtual enum ShapeType getType() const;
    110176  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     177  virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    111178private:
    112179  Shape::impl_ptr lhs;
     
    118185  NotShape_impl(const Shape::impl_ptr&);
    119186  virtual ~NotShape_impl();
    120   virtual bool isInside(const Vector &point);
    121   virtual bool isOnSurface(const Vector &point);
    122   virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
    123   virtual LineSegmentSet getLineIntersections(const Line&);
    124   virtual std::string toString();
     187  virtual bool isInside(const Vector &point) const;
     188  virtual bool isOnSurface(const Vector &point) const;
     189  virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException);
     190  virtual Vector getCenter() const;
     191  virtual double getRadius() const;
     192  virtual double getVolume() const;
     193  virtual double getSurfaceArea() const;
     194  virtual LineSegmentSet getLineIntersections(const Line&) const;
     195  virtual std::string toString() const;
     196  virtual enum ShapeType getType() const;
    125197  virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const;
     198  virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;
    126199private:
    127200  Shape::impl_ptr arg;
  • src/Shapes/unittests/Makefile.am

    r22425a r510f81  
    44
    55SHAPETESTSSOURCES = \
    6         ../Shapes/unittests/ShapeUnitTest.cpp
     6        ../Shapes/unittests/BaseShapesUnitTest.cpp \
     7        ../Shapes/unittests/ShapeOpsUnitTest.cpp \
     8        ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.cpp
    79
    810SHAPETESTSHEADERS= \
    9         ../Shapes/unittests/ShapeUnitTest.hpp
     11        ../Shapes/unittests/BaseShapesUnitTest.hpp \
     12        ../Shapes/unittests/ShapeOpsUnitTest.hpp \
     13        ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.cpp
    1014
    1115SHAPETESTS = \
    12   ShapeUnittest
     16  BaseShapesUnitTest \
     17  ShapeOpsUnitTest \
     18  Shape_HomogeneousPointsUnitTest
    1319 
    1420TESTS += $(SHAPETESTS)
     
    2228#       $(BOOST_LIB)
    2329
    24 ShapeUnittest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
    25         ../Shapes/unittests/ShapeUnitTest.cpp \
    26         ../Shapes/unittests/ShapeUnitTest.hpp
    27 nodist_ShapeUnittest_SOURCES = \
     30BaseShapesUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     31        ../Shapes/unittests/BaseShapesUnitTest.cpp \
     32        ../Shapes/unittests/BaseShapesUnitTest.hpp \
     33        ../Shapes/unittests/stubs/ApproximateShapeAreaStub.cpp \
     34        ../Shapes/unittests/stubs/ApproximateShapeVolumeStub.cpp
     35nodist_BaseShapesUnitTest_SOURCES = \
    2836        ../Helpers/defs.hpp \
    2937        ../Helpers/defs.cpp
    30 ShapeUnittest_LDADD = $(SHAPELIBS)
     38BaseShapesUnitTest_LDADD = $(SHAPELIBS)
     39
     40ShapeOpsUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     41        ../Shapes/unittests/ShapeOpsUnitTest.cpp \
     42        ../Shapes/unittests/ShapeOpsUnitTest.hpp \
     43        ../Shapes/unittests/stubs/ApproximateShapeAreaStub.cpp \
     44        ../Shapes/unittests/stubs/ApproximateShapeVolumeStub.cpp
     45nodist_ShapeOpsUnitTest_SOURCES = \
     46        ../Helpers/defs.hpp \
     47        ../Helpers/defs.cpp
     48ShapeOpsUnitTest_LDADD = $(SHAPELIBS)
     49
     50Shape_HomogeneousPointsUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     51        ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.cpp \
     52        ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.hpp
     53nodist_Shape_HomogeneousPointsUnitTest_SOURCES = \
     54        ../Helpers/defs.hpp \
     55        ../Helpers/defs.cpp
     56Shape_HomogeneousPointsUnitTest_LDADD = $(SHAPELIBS)
    3157
    3258
  • src/Tesselation/BoundaryTriangleSet.cpp

    r22425a r510f81  
    230230  Vector Direction;
    231231
    232   // 1. get intersection with plane
     232  // 1. get intersection with plane and place in ClosestPoint
    233233  LOG(1, "INFO: Looking for closest point of triangle " << *this << " to " << x << ".");
    234   GetCenter(Direction);
     234  LOG(1, "INFO: endpoints are " << endpoints[0]->node->getPosition() << ","
     235      << endpoints[1]->node->getPosition() << ", and " << endpoints[2]->node->getPosition() << ".");
    235236  try {
    236     Line l = makeLineThrough(x, Direction);
    237     ClosestPoint = Plane(NormalVector, (endpoints[0]->node->getPosition())).GetIntersection(l);
     237    ClosestPoint = Plane(NormalVector, (endpoints[0]->node->getPosition())).getClosestPoint(x);
    238238  }
    239239  catch (LinearAlgebraException &excp) {
    240240    (ClosestPoint) = (x);
    241241  }
     242  Vector InPlane(ClosestPoint); // points from plane intersection to straight-down point
    242243
    243244  // 2. Calculate in plane part of line (x, intersection)
    244   Vector InPlane = (x) - (ClosestPoint); // points from plane intersection to straight-down point
    245   InPlane.ProjectOntoPlane(NormalVector);
    246   InPlane += ClosestPoint;
    247 
    248   LOG(2, "INFO: Triangle is " << *this << ".");
    249   LOG(2, "INFO: Line is from " << Direction << " to " << x << ".");
    250   LOG(2, "INFO: In-plane part is " << InPlane << ".");
     245  LOG(2, "INFO: Closest point on triangle plane is " << ClosestPoint << ".");
    251246
    252247  // Calculate cross point between one baseline and the desired point such that distance is shortest
    253   double ShortestDistance = -1.;
    254   bool InsideFlag = false;
    255248  Vector CrossDirection[3];
    256249  Vector CrossPoint[3];
    257   Vector helper;
    258250  for (int i = 0; i < 3; i++) {
    259     // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point
    260     Direction = (endpoints[(i+1)%3]->node->getPosition()) - (endpoints[i%3]->node->getPosition());
     251    const Vector Direction = (endpoints[i%3]->node->getPosition()) - (endpoints[(i+1)%3]->node->getPosition());
    261252    // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);
    262253    Line l = makeLineThrough((endpoints[i%3]->node->getPosition()), (endpoints[(i+1)%3]->node->getPosition()));
    263     CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(l);
    264     CrossDirection[i] = CrossPoint[i] - InPlane;
    265     CrossPoint[i] -= (endpoints[i%3]->node->getPosition());  // cross point was returned as absolute vector
     254    CrossPoint[i] = l.getClosestPoint(InPlane);
     255    // NOTE: direction of line is normalized, hence s must not necessarily be in [0,1] for the baseline
     256    LOG(2, "INFO: Closest point on line from " << (endpoints[(i+1)%3]->node->getPosition())
     257        << " to " << (endpoints[i%3]->node->getPosition()) << " is " << CrossPoint[i] << ".");
     258    CrossPoint[i] -= (endpoints[(i+1)%3]->node->getPosition());  // cross point was returned as absolute vector
    266259    const double s = CrossPoint[i].ScalarProduct(Direction)/Direction.NormSquared();
    267260    LOG(2, "INFO: Factor s is " << s << ".");
    268261    if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) {
    269           CrossPoint[i] += (endpoints[i%3]->node->getPosition());  // make cross point absolute again
    270       LOG(2, "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << endpoints[i % 3]->node->getPosition() << " and " << endpoints[(i + 1) % 3]->node->getPosition() << ".");
    271       const double distance = CrossPoint[i].DistanceSquared(x);
    272       if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
    273         ShortestDistance = distance;
    274         (ClosestPoint) = CrossPoint[i];
    275       }
    276     } else
    277       CrossPoint[i].Zero();
    278   }
    279   InsideFlag = true;
     262      CrossPoint[i] += (endpoints[(i+1)%3]->node->getPosition());  // make cross point absolute again
     263      LOG(2, "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between "
     264          << endpoints[i % 3]->node->getPosition() << " and "
     265          << endpoints[(i + 1) % 3]->node->getPosition() << ".");
     266    } else {
     267      // set to either endpoint of BoundaryLine
     268      if (s < -MYEPSILON)
     269        CrossPoint[i] = (endpoints[(i+1)%3]->node->getPosition());
     270      else
     271        CrossPoint[i] = (endpoints[i%3]->node->getPosition());
     272      LOG(2, "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting outside of BoundaryLine between "
     273          << endpoints[i % 3]->node->getPosition() << " and "
     274          << endpoints[(i + 1) % 3]->node->getPosition() << ".");
     275    }
     276    CrossDirection[i] = CrossPoint[i] - InPlane;
     277  }
     278
     279  bool InsideFlag = true;
     280  double ShortestDistance = -1.;
    280281  for (int i = 0; i < 3; i++) {
    281282    const double sign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 1) % 3]);
     
    284285    if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign
    285286      InsideFlag = false;
    286   }
     287    // update current best candidate
     288    const double distance = CrossPoint[i].DistanceSquared(x);
     289    if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
     290      ShortestDistance = distance;
     291      (ClosestPoint) = CrossPoint[i];
     292    }
     293  }
     294
    287295  if (InsideFlag) {
    288296    (ClosestPoint) = InPlane;
    289297    ShortestDistance = InPlane.DistanceSquared(x);
    290   } else { // also check endnodes
    291     for (int i = 0; i < 3; i++) {
    292       const double distance = x.DistanceSquared(endpoints[i]->node->getPosition());
    293       if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
    294         ShortestDistance = distance;
    295         (ClosestPoint) = (endpoints[i]->node->getPosition());
    296       }
    297     }
    298   }
     298  }
     299
    299300  LOG(1, "INFO: Closest Point is " << ClosestPoint << " with shortest squared distance is " << ShortestDistance << ".");
    300301  return ShortestDistance;
     
    370371}
    371372;
     373
     374/** Checks whether a given point is inside the plane of the triangle and inside the
     375 * bounds defined by its BoundaryLineSet's.
     376 *
     377 * @param point point to check
     378 * @return true - point is inside place and inside all BoundaryLine's
     379 */
     380bool BoundaryTriangleSet::IsInsideTriangle(const Vector &point) const
     381{
     382  Info FunctionInfo(__func__);
     383
     384  // check if it's inside the plane
     385  try {
     386    Plane trianglePlane(
     387        endpoints[0]->node->getPosition(),
     388        endpoints[1]->node->getPosition(),
     389        endpoints[2]->node->getPosition());
     390    if (!trianglePlane.isContained(point)) {
     391      LOG(1, "INFO: Point " << point << " is not inside plane " << trianglePlane << " by "
     392          << trianglePlane.distance(point) << ".");
     393      return false;
     394    }
     395  } catch(LinearDependenceException) {
     396    // triangle is degenerated, it's just a line (i.e. one endpoint is right in between two others
     397    for (size_t i = 0; i < NDIM; ++i) {
     398      try {
     399        Line l = makeLineThrough(
     400            lines[i]->endpoints[0]->node->getPosition(),
     401            lines[i]->endpoints[1]->node->getPosition());
     402        if (l.isContained(GetThirdEndpoint(lines[i])->node->getPosition())) {
     403          // we have the largest of the three lines
     404          LOG(1, "INFO: Linear-dependent case where point " << point << " is on line " << l << ".");
     405          return (l.isContained(point));
     406        }
     407      } catch(ZeroVectorException) {
     408        // two points actually coincide
     409        try {
     410          Line l = makeLineThrough(
     411              lines[i]->endpoints[0]->node->getPosition(),
     412              GetThirdEndpoint(lines[i])->node->getPosition());
     413          LOG(1, "INFO: Degenerated case where point " << point << " is on line " << l << ".");
     414          return (l.isContained(point));
     415        } catch(ZeroVectorException) {
     416          // all three points coincide
     417          if (point.DistanceSquared(lines[i]->endpoints[0]->node->getPosition()) < MYEPSILON) {
     418            LOG(1, "INFO: Full-Degenerated case where point " << point << " is on three endpoints "
     419                << lines[i]->endpoints[0]->node->getPosition() << ".");
     420            return true;
     421          }
     422          else return false;
     423        }
     424      }
     425    }
     426  }
     427
     428  // check whether it lies on the correct side as given by third endpoint for
     429  // each BoundaryLine.
     430  // NOTE: we assume here that endpoints are linear independent, as the case
     431  // has been caught before already extensively
     432  for (size_t i = 0; i < NDIM; ++i) {
     433    Line l = makeLineThrough(
     434        lines[i]->endpoints[0]->node->getPosition(),
     435        lines[i]->endpoints[1]->node->getPosition());
     436    Vector onLine( l.getClosestPoint(point) );
     437    LOG(1, "INFO: Closest point on boundary line is " << onLine << ".");
     438    Vector inTriangleDirection( GetThirdEndpoint(lines[i])->node->getPosition() - onLine );
     439    Vector inPointDirection(point - onLine);
     440    if ((inTriangleDirection.NormSquared() > MYEPSILON) && (inPointDirection.NormSquared() > MYEPSILON))
     441      if (inTriangleDirection.ScalarProduct(inPointDirection) < -MYEPSILON)
     442        return false;
     443  }
     444
     445  return true;
     446}
     447
    372448
    373449/** Returns the endpoint which is not contained in the given \a *line.
  • src/Tesselation/BoundaryTriangleSet.hpp

    r22425a r510f81  
    4242    bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;
    4343    bool IsPresentTupel(const BoundaryTriangleSet * const T) const;
     44    bool IsInsideTriangle(const Vector &point) const;
    4445
    4546    Plane getPlane() const;
  • src/Tesselation/boundary.cpp

    r22425a r510f81  
    10291029  for (int i=0;i<NDIM;i++) {
    10301030    phi[i] = (random()/(rng_max-rng_min))*(2.*M_PI);
    1031     std::cout << "Random angle is " << phi[i] << std::endl;
     1031    LOG(4, "DEBUG: Random angle is " << phi[i] << ".");
    10321032  }
    10331033
  • src/Tesselation/triangleintersectionlist.cpp

    r22425a r510f81  
    197197  if (!DistanceList.empty()) {
    198198    // get closest triangle(s)
    199     std::pair< DistanceTriangleMap::iterator, DistanceTriangleMap::iterator >  DistanceRange =
     199    std::pair< DistanceTriangleMap::const_iterator, DistanceTriangleMap::const_iterator >  DistanceRange =
    200200        DistanceList.equal_range(DistanceList.begin()->first);
     201    {
     202      size_t count = 0;
     203      for (DistanceTriangleMap::const_iterator iter = DistanceRange.first;
     204          iter != DistanceRange.second; ++iter)
     205        ++count;
     206      LOG(1, "INFO: There are " << count << " possible triangles at the smallest distance.");
     207    }
    201208    // if there is more than one, check all of their normal vectors
    202     // return the one with positive SKP if present
    203 
    204     runner = IntersectionList.find(DistanceList.begin()->second);
     209    // return the one with positive SKP if present because if the point
     210    // would be truely inside, all of the closest triangles would have to show
     211    // their inner side
     212    LOG(1, "INFO: Looking for first SKP greater than zero ...");
     213    for (DistanceTriangleMap::const_iterator iter = DistanceRange.first;
     214        iter != DistanceRange.second; ++iter) {
     215      // find the entry by the triangle key in IntersectionList to get the Intersection point
     216      runner = IntersectionList.find(iter->second);
     217      Vector TestVector = (Point) - (*(*runner).second);
     218      // construct SKP
     219      const double sign = (*iter).second->NormalVector.ScalarProduct(TestVector);
     220      LOG(1, "INFO: Checking SKP of closest triangle " << *(iter->second) << " = " << sign << ".");
     221      // if positive return
     222      if (sign > 0)
     223        break;
     224    }
     225    // if there's just one or all are negative, runner is not set yet
     226    if (runner == IntersectionList.end())
     227      runner = IntersectionList.find(DistanceList.begin()->second);
    205228  }
    206229  return runner;
  • src/Tesselation/unittests/Makefile.am

    r22425a r510f81  
    1414TESSELATIONTESTS = \
    1515  TesselationUnitTest \
    16   Tesselation_BoundaryTriangleUnitTest
    17  
    18 XFAIL_TESTS += Tesselation_InOutsideUnitTest
     16  Tesselation_BoundaryTriangleUnitTest \
     17  Tesselation_InOutsideUnitTest
    1918
    2019TESTS += $(TESSELATIONTESTS)
  • src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp

    r22425a r510f81  
    3030#include "Helpers/defs.hpp"
    3131#include "Atom/TesselPoint.hpp"
     32#include "LinearAlgebra/Plane.hpp"
     33#include "LinearAlgebra/RealSpaceMatrix.hpp"
     34#include "LinearAlgebra/VectorSet.hpp"
    3235#include "Tesselation/BoundaryPointSet.hpp"
    3336#include "Tesselation/BoundaryLineSet.hpp"
     
    4952
    5053
    51 void TesselationBoundaryTriangleTest::setUp()
    52 {
    53   setVerbosity(5);
     54void TesselationBoundaryTriangleTest::createTriangle(const std::vector<Vector> &Vectors)
     55{
     56  CPPUNIT_ASSERT_EQUAL( (size_t)3, Vectors.size() );
    5457
    5558  // create nodes
    56   tesselpoints[0] = new TesselPoint;
    57   tesselpoints[0]->setPosition(Vector(0., 0., 0.));
    58   tesselpoints[0]->setName("1");
    59   tesselpoints[0]->setNr(1);
    60   points[0] = new BoundaryPointSet(tesselpoints[0]);
    61   tesselpoints[1] = new TesselPoint;
    62   tesselpoints[1]->setPosition(Vector(0., 1., 0.));
    63   tesselpoints[1]->setName("2");
    64   tesselpoints[1]->setNr(2);
    65   points[1] = new BoundaryPointSet(tesselpoints[1]);
    66   tesselpoints[2] = new TesselPoint;
    67   tesselpoints[2]->setPosition(Vector(1., 0., 0.));
    68   tesselpoints[2]->setName("3");
    69   tesselpoints[2]->setNr(3);
    70   points[2] = new BoundaryPointSet(tesselpoints[2] );
     59  for (size_t count = 0; count < NDIM; ++count) {
     60    tesselpoints[count] = new TesselPoint;
     61    tesselpoints[count]->setPosition( Vectors[count] );
     62    tesselpoints[count]->setName(toString(count));
     63    tesselpoints[count]->setNr(count);
     64    points[count] = new BoundaryPointSet(tesselpoints[count]);
     65  }
    7166
    7267  // create line
     
    7772  // create triangle
    7873  triangle = new BoundaryTriangleSet(lines, 0);
    79   triangle->GetNormalVector(Vector(0.,0.,1.));
    80 };
    81 
     74  Plane p(Vectors[0], Vectors[1], Vectors[2]);
     75  triangle->GetNormalVector(p.getNormal());
     76}
     77
     78void TesselationBoundaryTriangleTest::setUp()
     79{
     80  setVerbosity(5);
     81
     82  // create nodes
     83  std::vector<Vector> Vectors;
     84  Vectors.push_back( Vector(0., 0., 0.) );
     85  Vectors.push_back( Vector(0., 1., 0.) );
     86  Vectors.push_back( Vector(1., 0., 0.) );
     87
     88  // create triangle
     89  createTriangle(Vectors);
     90}
    8291
    8392void TesselationBoundaryTriangleTest::tearDown()
     
    9099  logger::purgeInstance();
    91100  errorLogger::purgeInstance();
    92 };
     101}
     102
     103/** UnitTest for Tesselation::IsInsideTriangle()
     104 */
     105void TesselationBoundaryTriangleTest::IsInsideTriangleTest()
     106{
     107  // inside points
     108  {
     109    // check each endnode
     110    for (size_t i=0; i< NDIM; ++i) {
     111      const Vector testPoint(triangle->endpoints[i]->node->getPosition());
     112      LOG(1, "INFO: Testing whether " << testPoint << " is an inner point.");
     113      CPPUNIT_ASSERT( triangle->IsInsideTriangle( testPoint ) );
     114    }
     115  }
     116
     117  {
     118    // check points along each BoundaryLine
     119    for (size_t i=0; i< NDIM; ++i) {
     120      Vector offset = triangle->endpoints[i%3]->node->getPosition();
     121      Vector direction = triangle->endpoints[(i+1)%3]->node->getPosition() - offset;
     122      for (double s = 0.1; s < 1.; s+= 0.1) {
     123        Vector testPoint = offset + s*direction;
     124        LOG(1, "INFO: Testing whether " << testPoint << " is an inner point.");
     125        CPPUNIT_ASSERT( triangle->IsInsideTriangle( testPoint ) );
     126      }
     127    }
     128  }
     129
     130  {
     131    // check central point
     132    Vector center;
     133    triangle->GetCenter(center);
     134    LOG(1, "INFO: Testing whether " << center << " is an inner point.");
     135    CPPUNIT_ASSERT( triangle->IsInsideTriangle( center ) );
     136  }
     137
     138  // outside points
     139  {
     140    // check points outside (i.e. those not in xy-plane through origin)
     141    double n[3];
     142    const double boundary = 4.;
     143    const double step = 1.;
     144    // go through the cube and check each point
     145    for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
     146      for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
     147        for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
     148          const Vector testPoint(n[0], n[1], n[2]);
     149          if (n[2] != 0) {
     150            LOG(1, "INFO: Testing whether " << testPoint << " is not an inner point.");
     151            CPPUNIT_ASSERT( !triangle->IsInsideTriangle( testPoint ) );
     152          }
     153        }
     154  }
     155
     156  {
     157    // check points within the plane but outside of triangle
     158    double n[3];
     159    const double boundary = 4.;
     160    const double step = 1.;
     161    n[2] = 0;
     162    for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
     163      for (n[1] = -boundary; n[1] <= boundary; n[1]+=step) {
     164        const Vector testPoint(n[0], n[1], n[2]);
     165        if ((n[0] >=0) && (n[1] >=0) && (n[0]<=1) && (n[1]<=1)) {
     166          if (n[0]+n[1] <= 1) {
     167            LOG(1, "INFO: Testing whether " << testPoint << " is an inner point.");
     168            CPPUNIT_ASSERT( triangle->IsInsideTriangle( testPoint) );
     169          } else {
     170            LOG(1, "INFO: Testing whether " << testPoint << " is not an inner point.");
     171            CPPUNIT_ASSERT( !triangle->IsInsideTriangle( testPoint) );
     172          }
     173        } else {
     174          LOG(1, "INFO: Testing whether " << testPoint << " is not an inner point.");
     175          CPPUNIT_ASSERT( !triangle->IsInsideTriangle( testPoint) );
     176        }
     177      }
     178  }
     179}
     180
     181/** UnitTest for Tesselation::IsInsideTriangle()
     182 *
     183 * We test for some specific points that occured in larger examples of the code.
     184 *
     185 */
     186void TesselationBoundaryTriangleTest::IsInsideTriangle_specificTest()
     187{
     188  {
     189    delete triangle;
     190    // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
     191    // failure is: Intersection (23.1644,24.1867,65.1272) is not inside triangle [659|Na2451,O3652,Na3762].
     192    const Vector testPoint(1.57318,1.57612,10.9874);
     193    const Vector testIntersection(23.1644,24.1867,65.1272);
     194    std::vector<Vector> vectors;
     195    vectors.push_back( Vector(23.0563,30.4673,73.7555) );
     196    vectors.push_back( Vector(25.473,25.1512,68.5467) );
     197    vectors.push_back( Vector(23.1644,24.1867,65.1272) );
     198    createTriangle(vectors);
     199    CPPUNIT_ASSERT( triangle->IsInsideTriangle( testIntersection ) );
     200  }
     201  {
     202    delete triangle;
     203    // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
     204    // failure is: Intersection (20.6787,70.655,71.5657) is not inside triangle [622|Na1197,Na2166,O3366].
     205    // fix is lower LINALG_MYEPSILON (not std::numeric_limits<doubble>*100 but *1e-4)
     206    const Vector testPoint(1.57318,14.185,61.2155);
     207    const Vector testIntersection(20.67867516517798,70.65496977054023,71.56572984946152);
     208    std::vector<Vector> vectors;
     209    vectors.push_back( Vector(22.9592,68.7791,77.5907) );
     210    vectors.push_back( Vector(18.4729,72.0386,68.08839999999999) );
     211    vectors.push_back( Vector(20.3834,71.0154,70.1443) );
     212    createTriangle(vectors);
     213    CPPUNIT_ASSERT( triangle->IsInsideTriangle( testIntersection ) );
     214  }
     215  {
     216    delete triangle;
     217    // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
     218    // failure is:Intersection (27.56537519896,13.40256646925,6.672946688134) is not inside triangle [702|Na5016,O6388,Na6498].
     219    // note that the Intersection cannot possibly lie be within the triangle!
     220    // we test now against correct intersection
     221    const Vector testIntersection(14.6872,36.204,39.8043);
     222    std::vector<Vector> vectors;
     223    vectors.push_back( Vector(10.7513,43.4247,48.4127) );
     224    vectors.push_back( Vector(13.7119,37.0827,47.4203) );
     225    vectors.push_back( Vector(14.6872,36.204,39.8043) );
     226    createTriangle(vectors);
     227    CPPUNIT_ASSERT( triangle->IsInsideTriangle( testIntersection ) );
     228  }
     229}
     230
     231/** UnitTest for Tesselation::GetClosestPointInsideTriangle()
     232 *
     233 * We check whether this function always returns a intersection inside the
     234 * triangle.
     235 *
     236 */
     237void TesselationBoundaryTriangleTest::GetClosestPointInsideTriangleTest()
     238{
     239  Vector TestIntersection;
     240
     241  {
     242    // march through a cube mesh on triangle in xy plane
     243    double n[3];
     244    const double boundary = 4.;
     245    const double step = 1.;
     246    // go through the cube and check each point
     247    for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
     248      for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
     249        for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
     250          const Vector testPoint(n[0], n[1], n[2]);
     251          triangle->GetClosestPointInsideTriangle(testPoint, TestIntersection);
     252          CPPUNIT_ASSERT( triangle->IsInsideTriangle( TestIntersection ));
     253        }
     254  }
     255
     256  delete triangle;
     257  // create better triangle;
     258  VECTORSET(std::vector) Vectors;
     259  Vectors.push_back( Vector(0., 0., 0.) );
     260  Vectors.push_back( Vector(0., 1., 0.) );
     261  Vectors.push_back( Vector(1., 0., 0.) );
     262  RealSpaceMatrix M;
     263  M.setRotation(M_PI/3., M_PI/4., 2.*M_PI/3.);
     264  Vectors.transform(M);
     265  createTriangle(Vectors);
     266
     267  {
     268    // march through a cube mesh on rotated triangle
     269    double n[3];
     270    const double boundary = 4.;
     271    const double step = 1.;
     272    // go through the cube and check each point
     273    for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
     274      for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
     275        for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
     276          const Vector testPoint(n[0], n[1], n[2]);
     277          triangle->GetClosestPointInsideTriangle(testPoint, TestIntersection);
     278          CPPUNIT_ASSERT( triangle->IsInsideTriangle( TestIntersection ));
     279        }
     280  }
     281}
     282
     283/** UnitTest for Tesselation::GetClosestPointInsideTriangle()
     284 *
     285 * We test for some specific points that occured in larger examples of the code.
     286 *
     287 */
     288void TesselationBoundaryTriangleTest::GetClosestPointInsideTriangle_specificTest()
     289{
     290  {
     291    delete triangle;
     292    // test is from --create-micelle 200 --radius 30. --position "0,0,0" of sles.data
     293    // failure is:Intersection (27.56537519896,13.40256646925,6.672946688134) is not inside triangle [702|Na5016,O6388,Na6498].
     294    // note that the Intersection cannot possibly lie be within the triangle
     295    // however, it is on its plane (off only by 2.7e-12)
     296    // testPoint2 is corrected version
     297    const Vector testPoint(27.56537519896,13.40256646925,6.672946688134);
     298    const Vector testPoint2(14.6872,36.204,39.8043);
     299    Vector testIntersection;
     300    std::vector<Vector> vectors;
     301    vectors.push_back( Vector(10.7513,43.4247,48.4127) );
     302    vectors.push_back( Vector(13.7119,37.0827,47.4203) );
     303    vectors.push_back( Vector(14.6872,36.204,39.8043) );
     304    createTriangle(vectors);
     305    triangle->GetClosestPointInsideTriangle(testPoint, testIntersection);
     306    CPPUNIT_ASSERT ( testPoint != testIntersection );
     307    CPPUNIT_ASSERT ( testPoint2 == testIntersection );
     308  }
     309}
    93310
    94311/** UnitTest for Tesselation::IsInnerPoint()
  • src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp

    r22425a r510f81  
    1919#include <cppunit/extensions/HelperMacros.h>
    2020
     21#include <vector>
     22
     23#include "LinearAlgebra/Vector.hpp"
    2124#include "LinkedCell/linkedcell.hpp"
    2225#include "Tesselation/tesselation.hpp"
     
    2932{
    3033    CPPUNIT_TEST_SUITE( TesselationBoundaryTriangleTest) ;
     34    CPPUNIT_TEST ( IsInsideTriangleTest );
     35    CPPUNIT_TEST ( IsInsideTriangle_specificTest );
     36    CPPUNIT_TEST ( GetClosestPointInsideTriangleTest );
     37    CPPUNIT_TEST ( GetClosestPointInsideTriangle_specificTest );
    3138    CPPUNIT_TEST ( GetClosestPointOnPlaneTest );
    3239    CPPUNIT_TEST ( GetClosestPointOffPlaneTest );
     
    3643      void setUp();
    3744      void tearDown();
     45      void IsInsideTriangleTest();
     46      void IsInsideTriangle_specificTest();
     47      void GetClosestPointInsideTriangleTest();
     48      void GetClosestPointInsideTriangle_specificTest();
    3849      void GetClosestPointOnPlaneTest();
    3950      void GetClosestPointOffPlaneTest();
    4051
    4152private:
     53      void createTriangle(const std::vector<Vector> &Vectors);
     54
    4255      static const double SPHERERADIUS;
    4356
  • src/UIElements/CommandLineUI/CommandLineParser.cpp

    r22425a r510f81  
    5151  atom("Atom options"),
    5252  command("Command options"),
     53  fill("fill options"),
    5354  fragmentation("Fragmentation options"),
    5455  graph("Graph options"),
     
    6566  CmdParserLookup["command"] = &command;
    6667  CmdParserLookup["edit"] = &edit;
     68  CmdParserLookup["fill"] = &fill;
    6769  CmdParserLookup["fragmentation"] = &fragmentation;
    6870  CmdParserLookup["graph"] = &graph;
  • src/UIElements/CommandLineUI/CommandLineParser.hpp

    r22425a r510f81  
    5858  po::options_description command;
    5959  po::options_description edit;
     60  po::options_description fill;
    6061  po::options_description fragmentation;
    6162  po::options_description graph;
  • src/UIElements/Makefile.am

    r22425a r510f81  
    263263        libMolecuilderAnalysis.la \
    264264        libMolecuilderGraph.la \
     265        libMolecuilderFilling.la \
    265266        libMolecuilder.la \
    266267        libMolecuilderFragmentation.la \
  • src/UIElements/Menu/MenuDescription.cpp

    r22425a r510f81  
    4949  MenuPositionMap->insert(std::make_pair("command",TopPosition("",3)));
    5050  MenuPositionMap->insert(std::make_pair("edit",TopPosition("",2)));
     51  MenuPositionMap->insert(std::make_pair("fill",TopPosition("tools",5)));
    5152  MenuPositionMap->insert(std::make_pair("fragmentation",TopPosition("tools",3)));
    5253  MenuPositionMap->insert(std::make_pair("graph",TopPosition("tools",4)));
     
    6364  MenuDescriptionsMap->insert(std::make_pair("command","Configuration"));
    6465  MenuDescriptionsMap->insert(std::make_pair("edit","Edit"));
     66  MenuDescriptionsMap->insert(std::make_pair("fill","Fill"));
    6567  MenuDescriptionsMap->insert(std::make_pair("fragmentation","Fragmentation"));
    6668  MenuDescriptionsMap->insert(std::make_pair("graph","Graph"));
     
    7779  MenuNameMap->insert(std::make_pair("command","Configuration"));
    7880  MenuNameMap->insert(std::make_pair("edit","Edit"));
     81  MenuNameMap->insert(std::make_pair("fill","Fill"));
    7982  MenuNameMap->insert(std::make_pair("fragmentation","Fragmentation"));
    8083  MenuNameMap->insert(std::make_pair("graph","Graph"));
  • src/documentation/constructs/atoms.dox

    r22425a r510f81  
    5656 * compatible implementation.
    5757 *
     58 * \section atoms-copy Copying atoms
    5859 *
    59  * \date 2011-10-31
     60 * Copying atoms is a frequent action. That's why there are specific functors
     61 * to get it done in more and more complex ways. The functors all inherit
     62 * the \ref CopyAtomsInterface and the more complex ones build upon the
     63 * functionality of the simpler ones:
     64 * -# CopyAtomsInterface: Internally sets to the number of desired atoms.
     65 * -# CopyAtoms_Simple: Fills the internal set with true copies.
     66 * -# CopyAtoms_withBonds: Additionally also adds bonds in between the copies
     67 *    as they exist in between the original atoms.
     68 * -# CopyAtoms_SaturateDanglingBonds: additionally checks for cut bond that
     69 *    would now become dangling bonds and inserts additional hydrogens for
     70 *    each cut bond such that the copied array of atoms is saturated.
     71 *
     72 * The CopyAtomsInterface is simple to use:
     73 * \code
     74 *   std::vector<atom *> atoms_to_copy;
     75 *   CopyAtoms_Simple copyMethod;
     76 *   copyMethod(atoms_to_copy);
     77 *   std::vector<atom *> copiedAtoms = getCopiedAtoms();
     78 * \endcode
     79 *
     80 *
     81 * \date 2012-03-30
     82 *
    6083 */
  • src/documentation/constructs/constructs.dox

    r22425a r510f81  
    22 * Project: MoleCuilder
    33 * Description: creates and alters molecular systems
    4  * Copyright (C)  2010 University of Bonn. All rights reserved.
     4 * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
    55 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
    66 */
     
    2222 *  \li \ref atom
    2323 *  \li \ref bondgraph
     24 *  \li \ref filling
    2425 *  \li \ref descriptors
    2526 *  \li \ref fragmentation
     
    4142 *
    4243 *
    43  * \date 2012-01-05
     44 * \date 2012-01-16
    4445 *
    4546 */
  • src/molecule.cpp

    r22425a r510f81  
    4444#include "LinkedCell/linkedcell.hpp"
    4545#include "IdPool_impl.hpp"
     46#include "Shapes/BaseShapes.hpp"
    4647#include "Tesselation/tesselation.hpp"
    4748#include "World.hpp"
     
    165166/************************** Access to the List of Atoms ****************/
    166167
    167 
    168 molecule::iterator molecule::begin(){
    169   return iterator(atomIds.begin(), FromIdToAtom());
    170 }
    171 
    172 molecule::const_iterator molecule::begin() const{
    173   return const_iterator(atomIds.begin(), FromIdToAtom());
    174 }
    175 
    176 molecule::iterator molecule::end(){
    177   return iterator(atomIds.end(), FromIdToAtom());
    178 }
    179 
    180 molecule::const_iterator molecule::end() const{
    181   return const_iterator(atomIds.end(), FromIdToAtom());
    182 }
    183 
    184 bool molecule::empty() const
    185 {
    186   return (atomIds.empty());
    187 }
    188 
    189 size_t molecule::size() const
    190 {
    191   size_t counter = 0;
    192   for (const_iterator iter = begin(); iter != end (); ++iter)
    193     counter++;
    194   return counter;
    195 }
    196 
    197168molecule::const_iterator molecule::erase( const_iterator loc )
    198169{
     
    222193}
    223194
    224 molecule::const_iterator molecule::find ( atom * key ) const
    225 {
    226   return const_iterator(atomIds.find(key->getId()), FromIdToAtom());
    227 }
    228 
    229195pair<molecule::iterator,bool> molecule::insert ( atom * const key )
    230196{
    231197  OBSERVE;
    232   pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId());
     198  std::pair<iterator,bool> res = atomIds.insert(key->getId());
    233199  if (res.second) { // push atom if went well
    234200    key->setNr(atomIdPool.getNextId());
    235201    setAtomName(key);
    236202    formula+=key->getType();
    237     return pair<iterator,bool>(iterator(res.first, FromIdToAtom()),res.second);
     203    return res;
    238204  } else {
    239205    return pair<iterator,bool>(end(),res.second);
     
    256222{
    257223  World::AtomComposite vector_of_atoms;
    258 //  std::copy(MyIter(atomIds.begin(), FromIdToAtom()),
    259 //      MyIter(atomIds.end(), FromIdToAtom()),
    260 //      vector_of_atoms.begin());
    261 //  for (MyIter iter = MyIter(atomIds.begin(), FromIdToAtom());
    262 //      iter != MyIter(atomIds.end(), FromIdToAtom());
    263 //      ++iter)
    264224  for (molecule::iterator iter = begin(); iter != end(); ++iter)
    265225    vector_of_atoms.push_back(*iter);
     
    589549
    590550/** Creates a copy of this molecule.
     551 * \param offset translation Vector for the new molecule relative to old one
    591552 * \return copy of molecule
    592553 */
    593 molecule *molecule::CopyMolecule() const
     554molecule *molecule::CopyMolecule(const Vector &offset) const
    594555{
    595556  molecule *copy = World::getInstance().createMolecule();
     
    599560  for (iterator iter = begin(); iter != end(); ++iter) {
    600561    atom * const copy_atom = copy->AddCopyAtom(*iter);
     562    copy_atom->setPosition(copy_atom->getPosition() + offset);
    601563    FatherFinder.insert( std::make_pair( *iter, copy_atom ) );
    602564  }
     
    851813      "molecule::isInMolecule() - atom is not designated to be in molecule '"
    852814      +toString(this->getName())+"'.");
    853   molecule::atomIdSet::const_iterator iter = atomIds.find(_atom->getId());
     815  molecule::const_iterator iter = atomIds.find(_atom->getId());
    854816  return (iter != atomIds.end());
    855817}
     
    10631025}
    10641026
     1027Shape molecule::getBoundingShape() const
     1028{
     1029  // get center and radius
     1030  Vector center;
     1031  double radius = 0.;
     1032  {
     1033    center.Zero();
     1034    for(const_iterator iter = begin(); iter != end(); ++iter)
     1035      center += (*iter)->getPosition();
     1036    center *= 1./(double)size();
     1037    for(const_iterator iter = begin(); iter != end(); ++iter) {
     1038      const Vector &position = (*iter)->getPosition();
     1039      const double temp_distance = position.DistanceSquared(center);
     1040      if (temp_distance > radius)
     1041        radius = temp_distance;
     1042    }
     1043  }
     1044  // convert radius to true value and add some small boundary
     1045  radius = sqrt(radius) + 1e+6*std::numeric_limits<double>::epsilon();
     1046  LOG(1, "INFO: The " << size() << " atoms of the molecule are contained in a sphere at "
     1047      << center << " with radius " << radius << ".");
     1048
     1049  Shape BoundingShape(Sphere(center, radius));
     1050  LOG(1, "INFO: Created sphere at " << BoundingShape.getCenter() << " and radius "
     1051      << BoundingShape.getRadius() << ".");
     1052  return BoundingShape;
     1053}
     1054
    10651055// construct idpool
    10661056CONSTRUCT_IDPOOL(atomId_t, continuousId)
     1057
  • src/molecule.hpp

    r22425a r510f81  
    2121#include <vector>
    2222
    23 #include <boost/iterator/transform_iterator.hpp>
    24 
    2523#include <string>
    2624
     25#include "AtomIdSet.hpp"
    2726#include "Atom/AtomSet.hpp"
    2827#include "CodePatterns/Cacheable.hpp"
    2928#include "CodePatterns/Observer/Observable.hpp"
    30 #include "CodePatterns/Observer/ObservedIterator.hpp"
    3129#include "Descriptors/AtomIdDescriptor.hpp"
    3230#include "Fragmentation/HydrogenSaturation_enum.hpp"
     
    3533#include "IdPool_policy.hpp"
    3634#include "IdPool.hpp"
     35#include "Shapes/Shape.hpp"
    3736#include "types.hpp"
    38 
    39 // TODO: Was is the include of MoleculeDescriptor_impl.hpp doing in molecule.hpp
    40 #include "Descriptors/MoleculeDescriptor_impl.hpp"
    4137
    4238/****************************************** forward declarations *****************************/
     
    5450class MoleculeLeafClass;
    5551class MoleculeListClass;
    56 class periodentafel;
     52class MoleculeUnittest;
    5753class RealSpaceMatrix;
    5854class Vector;
    59 class Shape;
    60 
    61 /******************************** Some definitions for easier reading **********************************/
    62 
    63 struct FromIdToAtom :
    64   public std::unary_function<atom *, atomId_t>
    65 {
    66     atom * operator()(atomId_t id) const {
    67      return World::getInstance().getAtom(AtomById(id));
    68     }
    69 };
    7055
    7156/************************************* Class definitions ****************************************/
     
    7661class molecule : public Observable
    7762{
     63  //!> grant unit test access
     64  friend class MoleculeUnittest;
     65  //!> function may access cstor
    7866  friend molecule *NewMolecule();
     67  //!> function may access dstor
    7968  friend void DeleteMolecule(molecule *);
    8069
    8170public:
    82   typedef std::set<atomId_t> atomIdSet;
    83   typedef boost::transform_iterator<FromIdToAtom, atomIdSet::iterator, atom *, atomId_t> iterator;
    84   typedef boost::transform_iterator<FromIdToAtom, atomIdSet::const_iterator, const atom *, atomId_t const &> const_iterator;
     71  typedef AtomIdSet::atomIdSet atomIdSet;
     72  typedef AtomIdSet::iterator iterator;
     73  typedef AtomIdSet::const_iterator const_iterator;
    8574
    8675  int MDSteps; //!< The number of MD steps in Trajectories
     
    9786  Cacheable<int> BondCount; //!< number of atoms, brought up-to-date by doCountBonds()
    9887  moleculeId_t id;
    99   atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
     88  AtomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms
    10089  IdPool<atomId_t, uniqueId> atomIdPool;  //!< pool of internal ids such that way may guarantee uniqueness
    10190
     
    125114  World::AtomComposite getAtomSet() const;
    126115
    127   iterator begin();
    128   const_iterator begin() const;
    129   iterator end();
    130   const_iterator end() const;
    131   bool empty() const;
    132   size_t size() const;
    133   const_iterator find(atom * key) const;
    134   pair<iterator, bool> insert(atom * const key);
     116  // simply pass on all functions to AtomIdSet
     117  iterator begin() {
     118    return atomIds.begin();
     119  }
     120  const_iterator begin() const
     121  {
     122    return atomIds.begin();
     123  }
     124  iterator end()
     125  {
     126    return atomIds.end();
     127  }
     128  const_iterator end() const
     129  {
     130    return atomIds.end();
     131  }
     132  bool empty() const
     133  {
     134    return atomIds.empty();
     135  }
     136  size_t size() const
     137  {
     138    return atomIds.size();
     139  }
     140  const_iterator find(atom * key) const
     141  {
     142    return atomIds.find(key);
     143  }
     144
     145  /** Returns the set of atomic ids contained in this molecule.
     146   *
     147   * @return set of atomic ids
     148   */
     149  const atomIdSet & getAtomIds() const {
     150    return atomIds.getAtomIds();
     151  }
     152
     153  std::pair<iterator, bool> insert(atom * const key);
     154
    135155  bool containsAtom(atom* key);
    136156
     
    145165   */
    146166  const_iterator erase(const_iterator loc);
     167
    147168  /** Erase an atom from the list.
    148169   * \note This should only be called by atom::removeFromMolecule(),
     
    177198
    178199public:
     200
     201  /** Function to create a bounding spherical shape for the currently associated atoms.
     202   *
     203   */
     204  Shape getBoundingShape() const;
    179205
    180206  /// remove atoms from molecule.
     
    229255  bond * CopyBond(atom *left, atom *right, bond *CopyBond);
    230256
    231   molecule *CopyMolecule() const;
     257  molecule *CopyMolecule(const Vector &offset = zeroVec) const;
    232258  molecule* CopyMoleculeFromSubRegion(const Shape&) const;
    233259
  • src/unittests/Makefile.am

    r22425a r510f81  
    1212include ../../src/Descriptors/unittests/Makefile.am
    1313include ../../src/Element/unittests/Makefile.am
     14include ../../src/Filling/unittests/Makefile.am
    1415include ../../src/Fragmentation/unittests/Makefile.am
    1516include ../../src/Graph/unittests/Makefile.am
     
    2829
    2930GENERALTESTS = \
     31  AtomIdSetUnitTest \
    3032  BoxUnitTest \
    3133  Box_BoundaryConditionsTest \
    3234  FormulaUnittest \
    3335  ListOfBondsUnitTest \
     36  MoleculeUnitTest \
    3437  WorldTimeUnitTest
    3538
     
    5962
    6063ALLLIBS = \
     64        ../libMolecuilderFilling.la \
    6165        ../libMolecuilderUI.la \
    6266        ../libMolecuilder.la \
     
    7074        ${DESCRIPTORTESTSSOURCES} \
    7175        ${ELEMENTTESTSSOURCES} \
     76        ${FILLINGTESTSSOURCES} \
    7277        ${FRAGMENTATIONTESTSSOURCES} \
    7378        ${GRAPHTESTSSOURCES} \
     
    8186        ${UIELEMENTSMENUTESTSSOURCES} \
    8287        stubs/ObserverStub.cpp \
     88        AtomIdSetUnitTest.cpp \
    8389  BoxUnitTest.cpp \
    8490        Box_BoundaryConditionsUnitTest.cpp \
    8591  FormulaUnitTest.cpp \
    8692  ListOfBondsUnitTest.cpp \
     93  MoleculeUnitTest.cpp \
    8794  WorldTimeUnitTest.cpp
    8895
     
    9299        ${DESCRIPTORTESTSHEADERS} \
    93100        ${ELEMENTTESTSHEADERS} \
     101        ${FILLINGTESTSHEADERS} \
    94102        ${FRAGMENTATIONTESTSHEADERS} \
    95103        ${GRAPHTESTSHEADERS} \
     
    103111        ${UIELEMENTSMENUTESTSHEADERS} \
    104112        stubs/ObserverStub.hpp \
     113        AtomIdSetUnitTest.hpp \
    105114  BoxUnitTest.hpp \
    106115        Box_BoundaryConditionsUnitTest.hpp \
    107116  FormulaUnitTest.hpp \
    108117  ListOfBondsUnitTest.hpp \
     118  MoleculeUnitTest.hpp \
    109119  WorldTimeUnitTest.hpp
    110120 
     
    114124        BoxUnitTest.hpp \
    115125        stubs/ObserverStub.cpp \
    116         stubs/ObserverStub.hpp 
     126        stubs/ObserverStub.hpp \
     127        ../Shapes/unittests/stubs/ApproximateShapeAreaStub.cpp \
     128        ../Shapes/unittests/stubs/ApproximateShapeVolumeStub.cpp
    117129BoxUnitTest_LDADD = \
    118130        ../libMolecuilder.la \
     
    120132        ../libMolecuilderHelpers.la \
    121133        $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la
     134
     135AtomIdSetUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     136        AtomIdSetUnitTest.cpp \
     137        AtomIdSetUnitTest.hpp
     138AtomIdSetUnitTest_LDADD =  $(ALLLIBS)
    122139
    123140Box_BoundaryConditionsTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     
    140157ListOfBondsUnitTest_LDADD = $(ALLLIBS)
    141158
     159MoleculeUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     160        MoleculeUnitTest.cpp \
     161        MoleculeUnitTest.hpp
     162MoleculeUnitTest_LDADD = \
     163        ../libMolecuilderUI.la \
     164        ../libMolecuilder.la \
     165        $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la
     166
    142167WorldTimeUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
    143168        WorldTimeUnitTest.cpp \
  • tests/CodeChecks/Makefile.am

    r22425a r510f81  
    11AUTOM4TE = autom4te
    2 EXTRA_DIST = \
    3         atlocal.in \
    4         package.m4 \
    5         testsuite.at \
    6         testsuite-config_h.at \
    7         testsuite-date_in_dox.at \
    8         testsuite-globallistofactions_hpp.at \
    9         testsuite-memdebug.at \
    10         testsuite-project-disclaimer.at \
    11         $(TESTSUITE)
     2
    123TESTSUITE = $(srcdir)/testsuite
    13 
    14 DISTCLEANFILES = atconfig
    154
    165TESTSCRIPTS = \
     
    187        testsuite-date_in_dox.at \
    198        testsuite-globallistofactions_hpp.at \
     9        testsuite-header-dist.at \
    2010        testsuite-memdebug.at \
    2111        testsuite-project-disclaimer.at
     12
     13DISTCLEANFILES = atconfig
     14
     15EXTRA_DIST = \
     16        atlocal.in \
     17        package.m4 \
     18        testsuite.at \
     19        $(TESTSUITE) \
     20        $(TESTSCRIPTS)
    2221
    2322max_jobs = 4
  • tests/CodeChecks/testsuite.at

    r22425a r510f81  
    2323m4_include(testsuite-project-disclaimer.at)
    2424
     25m4_include(testsuite-header-dist.at)
  • tests/Python/AllActions/options.dat

    r22425a r510f81  
    7474MaxDistance     "-1"
    7575MDSteps "1"
     76mesh-offset     "0.5,0.5,0.5"
     77mesh-size       "10,10,10"
     78min-distance    "1."
    7679molecule-by-id  "0"
    7780nonconvex-envelope      "25"
     
    167170start-step      "0"
    168171suspend-in-water        "1.0"
     172tesselation-radius      "5."
    169173time-step-zero  "0"
    170174translate-atoms "1. 0. 0."
  • tests/regression/Makefile.am

    r22425a r510f81  
    155155        $(srcdir)/Selection/Atoms/AtomsInsideCuboid/testsuite-selection-unselect-atoms-inside-cuboid.at \
    156156        $(srcdir)/Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-sphere.at \
     157        $(srcdir)/Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-tiny-sphere.at \
    157158        $(srcdir)/Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-sphere.at \
     159        $(srcdir)/Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-tiny-sphere.at \
    158160        $(srcdir)/Selection/Atoms/ClearAtoms/testsuite-selection-clear-atoms.at \
    159161        $(srcdir)/Selection/Molecules/testsuite-selection-molecules.at \
  • tests/regression/Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-sphere.at

    r22425a r510f81  
    1414AT_SKIP_IF([! cat >/dev/null < /dev/null])  # check whether cat is there
    1515AT_SKIP_IF([! wc -l /dev/null])  # check whether wc is there
    16 AT_CHECK([cat < $file | awk -F" " '{ if (($2-10)*($2-10)+($3-10)*($3-10)+($4-10)*($4-10) > 100) print $1,$2,$3,$4;}' | wc -l], 0, [stdout], [ignore])
    17 AT_CHECK([fgrep "507" stdout], 0, [ignore], [ignore])
    18 AT_CHECK([cat < $file | awk -F" " '{ if (($2-10)*($2-10)+($3-10)*($3-10)+($4-10)*($4-10) < 100) print $1,$2,$3,$4;}' | wc -l], 0, [stdout], [ignore])
     16AT_CHECK([cat < $file | awk -F" " '{ if ((NF == 4) && (($2-10)*($2-10)+($3-10)*($3-10)+($4-10)*($4-10)) > 100) print $1,$2,$3,$4;}' | wc -l], 0, [stdout], [ignore])
     17AT_CHECK([fgrep "505" stdout], 0, [ignore], [ignore])
     18AT_CHECK([cat < $file | awk -F" " '{ if ((NF == 4) && (($2-10)*($2-10)+($3-10)*($3-10)+($4-10)*($4-10)) < 100) print $1,$2,$3,$4;}' | wc -l], 0, [stdout], [ignore])
    1919AT_CHECK([fgrep "0" stdout], 0, [ignore], [ignore])
    2020
  • tests/regression/Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-sphere.at

    r22425a r510f81  
    1515AT_SKIP_IF([! cat >/dev/null < /dev/null])  # check whether awk is there
    1616AT_SKIP_IF([! wc -l /dev/null])  # check whether wc is there
    17 AT_CHECK([cat < $file | awk -F" " '{ if (($2-10)*($2-10)+($3-10)*($3-10)+($4-10)*($4-10) > 100) print $1,$2,$3,$4;}' | wc -l], 0, [stdout], [ignore])
    18 AT_CHECK([fgrep "2" stdout], 0, [ignore], [ignore])
    19 AT_CHECK([cat < $file | awk -F" " '{ if (($2-10)*($2-10)+($3-10)*($3-10)+($4-10)*($4-10) < 100) print $1,$2,$3,$4;}' | wc -l], 0, [stdout], [ignore])
     17AT_CHECK([cat < $file | awk -F" " '{ if ((NF == 4) && (($2-10)*($2-10)+($3-10)*($3-10)+($4-10)*($4-10)) > 100) print $1,$2,$3,$4;}' | wc -l], 0, [stdout], [ignore])
     18AT_CHECK([fgrep "0" stdout], 0, [ignore], [ignore])
     19AT_CHECK([cat < $file | awk -F" " '{ if ((NF == 4) && (($2-10)*($2-10)+($3-10)*($3-10)+($4-10)*($4-10)) < 100) print $1,$2,$3,$4;}' | wc -l], 0, [stdout], [ignore])
    2020AT_CHECK([fgrep "524" stdout], 0, [ignore], [ignore])
    2121
  • tests/regression/Selection/Atoms/testsuite-selection-atoms.at

    r22425a r510f81  
    2626# (un)select atoms inside sphere
    2727m4_include(Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-sphere.at)
     28m4_include(Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-tiny-sphere.at)
    2829m4_include(Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-sphere.at)
     30m4_include(Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-tiny-sphere.at)
    2931
    3032# clear atom selection
Note: See TracChangeset for help on using the changeset viewer.