Changes in / [510f81:22425a]
- Files:
-
- 4 added
- 94 deleted
- 60 edited
Legend:
- Unmodified
- Added
- Removed
-
LinearAlgebra/src/LinearAlgebra/Line.cpp
r510f81 r22425a 31 31 #include "defs.hpp" 32 32 #include "Exceptions.hpp" 33 #include "LinePoint.hpp"34 33 #include "MatrixContent.hpp" 35 34 #include "Plane.hpp" … … 309 308 } 310 309 311 std::ostream& operator<<(std::ostream& ost, const Line& m) 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) 312 356 { 313 357 const Vector origin = m.getOrigin(); … … 329 373 }; 330 374 331 332 /******************************** Points on the line ********************/ -
LinearAlgebra/src/LinearAlgebra/Line.hpp
r510f81 r22425a 25 25 class LinePoint; 26 26 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 LineSegment32 */33 27 class Line : public Space 34 28 { … … 80 74 Line makeLineThrough(const Vector &x1, const Vector &x2); 81 75 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 82 109 #endif /* LINE_HPP_ */ -
LinearAlgebra/src/LinearAlgebra/LineSegment.cpp
r510f81 r22425a 24 24 25 25 #include "Line.hpp" 26 #include "LinePoint.hpp"27 26 #include "Vector.hpp" 28 27 -
LinearAlgebra/src/LinearAlgebra/LineSegment.hpp
r510f81 r22425a 21 21 class LinePoint; 22 22 23 /** This class represents a specific segment of a line, defined through24 * two points on the same line that form start and end.25 *26 */27 23 class LineSegment 28 24 { -
LinearAlgebra/src/LinearAlgebra/LineSegmentSet.cpp
r510f81 r22425a 24 24 #include "CodePatterns/Assert.hpp" 25 25 #include "Line.hpp" 26 #include "LinePoint.hpp"27 26 #include "LineSegment.hpp" 28 27 -
LinearAlgebra/src/LinearAlgebra/LineSegmentSet.hpp
r510f81 r22425a 22 22 class LineSegment; 23 23 24 /** This class represents a continous set of LineSegment's all on the same25 * underlying line.26 *27 * Hence, it is basically a sorted container for LinePoints but28 * we iterate over it segment-wise.29 *30 */31 24 class LineSegmentSet { 32 25 friend LineSegmentSet merge(const LineSegmentSet&,const LineSegmentSet&); -
LinearAlgebra/src/LinearAlgebra/Makefile.am
r510f81 r22425a 11 11 leastsquaremin.cpp \ 12 12 Line.cpp \ 13 LinePoint.cpp \14 13 LineSegment.cpp \ 15 14 LineSegmentSet.cpp \ … … 32 31 leastsquaremin.hpp \ 33 32 Line.hpp \ 34 LinePoint.hpp \35 33 LineSegment.hpp \ 36 34 LineSegmentSet.hpp \ -
LinearAlgebra/src/LinearAlgebra/defs.hpp
r510f81 r22425a 23 23 double LINALG_MYEPSILON() 24 24 { 25 return (std::numeric_limits<double>::epsilon()*1 .e+4);25 return (std::numeric_limits<double>::epsilon()*100.); 26 26 } 27 27 -
LinearAlgebra/src/documentation/mainpage.dox
r510f81 r22425a 25 25 * 26 26 * 27 * \ref lines Lines and subtypes28 *29 27 * \date 2011-11-02 30 28 * -
LinearAlgebra/tests/CodeChecks/Makefile.am
r510f81 r22425a 1 1 AUTOM4TE = 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-memdebug.at \ 9 testsuite-project-disclaimer.at \ 10 $(TESTSUITE) 11 TESTSUITE = $(srcdir)/testsuite 2 12 3 TESTSUITE = $(srcdir)/testsuite 13 DISTCLEANFILES = atconfig 4 14 5 15 TESTSCRIPTS = \ 6 16 testsuite-config_h.at \ 7 17 testsuite-date_in_dox.at \ 8 testsuite-header-dist.at \9 18 testsuite-memdebug.at \ 10 19 testsuite-project-disclaimer.at 11 12 DISTCLEANFILES = atconfig13 14 EXTRA_DIST = \15 atlocal.in \16 package.m4 \17 testsuite.at \18 $(TESTSUITE) \19 $(TESTSCRIPTS)20 20 21 21 max_jobs = 4 -
LinearAlgebra/tests/CodeChecks/testsuite.at
r510f81 r22425a 21 21 m4_include(testsuite-project-disclaimer.at) 22 22 23 m4_include(testsuite-header-dist.at) -
src/Actions/GlobalListOfActions.hpp
r510f81 r22425a 105 105 (SelectionNotAllAtomsInsideCuboid) \ 106 106 (SelectionAtomById) \ 107 (FragmentationFragmentation) \ 108 (FillRegularGrid) 107 (FragmentationFragmentation) 109 108 110 109 #endif /* GLOBALLISTOFACTIONS_HPP_ */ -
src/Actions/Makefile.am
r510f81 r22425a 52 52 ${ATOMACTIONSOURCE} \ 53 53 ${CMDACTIONSOURCE} \ 54 ${FILLACTIONSOURCE} \55 54 ${FRAGMENTATIONACTIONSOURCE} \ 56 55 ${GRAPHACTIONSOURCE} \ … … 68 67 ${ATOMACTIONHEADER} \ 69 68 ${CMDACTIONHEADER} \ 70 ${FILLACTIONHEADER} \71 69 ${FRAGMENTATIONACTIONHEADER} \ 72 70 ${GRAPHACTIONHEADER} \ … … 84 82 ${ATOMACTIONDEFS} \ 85 83 ${CMDACTIONDEFS} \ 86 ${FILLACTIONDEFS} \87 84 ${FRAGMENTATIONACTIONDEFS} \ 88 85 ${GRAPHACTIONDEFS} \ … … 176 173 Actions/CommandAction/VersionAction.def \ 177 174 Actions/CommandAction/WarrantyAction.def 178 179 FILLACTIONSOURCE = \180 Actions/FillAction/FillRegularGridAction.cpp181 FILLACTIONHEADER = \182 Actions/FillAction/FillRegularGridAction.hpp183 FILLACTIONDEFS = \184 Actions/FillAction/FillRegularGridAction.def185 186 175 187 176 FRAGMENTATIONACTIONSOURCE = \ -
src/Actions/SelectionAction/Atoms/AllAtomsInsideCuboidAction.cpp
r510f81 r22425a 54 54 LOG(1, "Selecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << params.position << " and extension of " << params.extension << "."); 55 55 Shape s = translate(transform(stretch(Cuboid(),params.extension),RotationMatrix),params.position); 56 std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && Atom sByShape(s));57 World::getInstance().selectAllAtoms(Atom sByShape(s));56 std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && AtomByShape(s)); 57 World::getInstance().selectAllAtoms(AtomByShape(s)); 58 58 LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected."); 59 59 return Action::state_ptr(new SelectionAllAtomsInsideCuboidState(selectedAtoms, s, params)); … … 63 63 SelectionAllAtomsInsideCuboidState *state = assert_cast<SelectionAllAtomsInsideCuboidState*>(_state.get()); 64 64 65 World::getInstance().unselectAllAtoms(Atom sByShape(state->s));65 World::getInstance().unselectAllAtoms(AtomByShape(state->s)); 66 66 BOOST_FOREACH(atom *_atom, state->selectedAtoms) 67 67 World::getInstance().selectAtom(_atom); … … 74 74 RealSpaceMatrix RotationMatrix; 75 75 76 World::getInstance().selectAllAtoms(Atom sByShape(state->s));76 World::getInstance().selectAllAtoms(AtomByShape(state->s)); 77 77 78 78 return Action::state_ptr(_state); -
src/Actions/SelectionAction/Atoms/AllAtomsInsideSphereAction.cpp
r510f81 r22425a 49 49 LOG(1, "Selecting all atoms inside a sphere at " << params.position << " with radius " << params.radius << "."); 50 50 Shape s = translate(resize(Sphere(),params.radius),params.position); 51 std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && Atom sByShape(s));52 World::getInstance().selectAllAtoms(Atom sByShape(s));51 std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && AtomByShape(s)); 52 World::getInstance().selectAllAtoms(AtomByShape(s)); 53 53 LOG(0, World::getInstance().countSelectedAtoms() << " atoms selected."); 54 54 return Action::state_ptr(new SelectionAllAtomsInsideSphereState(selectedAtoms, s, params)); … … 58 58 SelectionAllAtomsInsideSphereState *state = assert_cast<SelectionAllAtomsInsideSphereState*>(_state.get()); 59 59 60 World::getInstance().unselectAllAtoms(Atom sByShape(state->s));60 World::getInstance().unselectAllAtoms(AtomByShape(state->s)); 61 61 BOOST_FOREACH(atom *_atom, state->selectedAtoms) 62 62 World::getInstance().selectAtom(_atom); … … 68 68 SelectionAllAtomsInsideSphereState *state = assert_cast<SelectionAllAtomsInsideSphereState*>(_state.get()); 69 69 70 World::getInstance().selectAllAtoms(Atom sByShape(state->s));70 World::getInstance().selectAllAtoms(AtomByShape(state->s)); 71 71 72 72 return Action::state_ptr(_state); -
src/Actions/SelectionAction/Atoms/NotAllAtomsInsideCuboidAction.cpp
r510f81 r22425a 53 53 LOG(1, "Unselecting all atoms inside a rotated " << RotationMatrix << " cuboid at " << params.position << " and extension of " << params.extension << "."); 54 54 Shape s = translate(transform(stretch(Cuboid(),params.extension),RotationMatrix),params.position); 55 std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && Atom sByShape(s));56 World::getInstance().unselectAllAtoms(Atom sByShape(s));55 std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && AtomByShape(s)); 56 World::getInstance().unselectAllAtoms(AtomByShape(s)); 57 57 LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected."); 58 58 return Action::state_ptr(new SelectionNotAllAtomsInsideCuboidState(unselectedAtoms, s, params)); … … 62 62 SelectionNotAllAtomsInsideCuboidState *state = assert_cast<SelectionNotAllAtomsInsideCuboidState*>(_state.get()); 63 63 64 World::getInstance().selectAllAtoms(Atom sByShape(state->s));64 World::getInstance().selectAllAtoms(AtomByShape(state->s)); 65 65 BOOST_FOREACH(atom *_atom, state->unselectedAtoms) 66 66 World::getInstance().unselectAtom(_atom); … … 73 73 RealSpaceMatrix RotationMatrix; 74 74 75 World::getInstance().unselectAllAtoms(Atom sByShape(state->s));75 World::getInstance().unselectAllAtoms(AtomByShape(state->s)); 76 76 77 77 return Action::state_ptr(_state); -
src/Actions/SelectionAction/Atoms/NotAllAtomsInsideSphereAction.cpp
r510f81 r22425a 49 49 LOG(1, "Unselecting all atoms inside a sphere at " << params.position << " with radius " << params.radius << "."); 50 50 Shape s = translate(resize(Sphere(),params.radius),params.position); 51 std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && Atom sByShape(s));52 World::getInstance().unselectAllAtoms(Atom sByShape(s));51 std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && AtomByShape(s)); 52 World::getInstance().unselectAllAtoms(AtomByShape(s)); 53 53 LOG(0, World::getInstance().countSelectedAtoms() << " atoms remain selected."); 54 54 return Action::state_ptr(new SelectionNotAllAtomsInsideSphereState(unselectedAtoms, s, params)); … … 58 58 SelectionNotAllAtomsInsideSphereState *state = assert_cast<SelectionNotAllAtomsInsideSphereState*>(_state.get()); 59 59 60 World::getInstance().selectAllAtoms(Atom sByShape(state->s));60 World::getInstance().selectAllAtoms(AtomByShape(state->s)); 61 61 BOOST_FOREACH(atom *_atom, state->unselectedAtoms) 62 62 World::getInstance().unselectAtom(_atom); … … 68 68 SelectionNotAllAtomsInsideSphereState *state = assert_cast<SelectionNotAllAtomsInsideSphereState*>(_state.get()); 69 69 70 World::getInstance().unselectAllAtoms(Atom sByShape(state->s));70 World::getInstance().unselectAllAtoms(AtomByShape(state->s)); 71 71 72 72 return Action::state_ptr(_state); -
src/Atom/Makefile.am
r510f81 r22425a 29 29 Atom/TesselPoint.hpp 30 30 31 COPYATOMSSOURCE = \32 Atom/CopyAtoms/CopyAtoms_SaturateDanglingBonds.cpp \33 Atom/CopyAtoms/CopyAtoms_withBonds.cpp34 35 COPYATOMSHEADER = \36 Atom/CopyAtoms/CopyAtoms_SaturateDanglingBonds.hpp \37 Atom/CopyAtoms/CopyAtoms_Simple.hpp \38 Atom/CopyAtoms/CopyAtoms_withBonds.hpp \39 Atom/CopyAtoms/CopyAtomsInterface.hpp40 31 41 32 noinst_LTLIBRARIES += libMolecuilderAtom.la 42 33 libMolecuilderAtom_la_includedir = $(includedir)/MoleCuilder/Atom/ 43 34 44 nobase_libMolecuilderAtom_la_include_HEADERS = $ (ATOMHEADER) $(COPYATOMSHEADER)35 nobase_libMolecuilderAtom_la_include_HEADERS = ${ATOMHEADER} 45 36 46 37 ## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la" … … 52 43 ## from each source file. Note that it is not necessary to list header files 53 44 ## which are already listed elsewhere in a _HEADERS variable assignment. 54 libMolecuilderAtom_la_SOURCES = $ (ATOMSOURCE) $(COPYATOMSSOURCE)45 libMolecuilderAtom_la_SOURCES = ${ATOMSOURCE} 55 46 56 47 ## Instruct libtool to include ABI version information in the generated shared -
src/Atom/unittests/Makefile.am
r510f81 r22425a 4 4 ATOMTESTSSOURCES = \ 5 5 ../Atom/unittests/AtomObserverUnitTest.cpp \ 6 ../Atom/unittests/CopyAtomsInterfaceUnitTest.cpp \7 6 stubs/ObserverStub.cpp 8 7 9 8 ATOMTESTSHEADERS = \ 10 9 ../Atom/unittests/AtomObserverUnitTest.hpp \ 11 ../Atom/unittests/CopyAtomsInterfaceUnitTest.hpp \12 10 stubs/ObserverStub.hpp 13 11 14 12 ATOMTESTS = \ 15 AtomObserverUnitTest \ 16 CopyAtomsInterfaceUnitTest 13 AtomObserverUnitTest 17 14 18 15 TESTS += $(ATOMTESTS) … … 38 35 AtomObserverUnitTest_LDADD = ${ATOMTESTLIBS} 39 36 40 CopyAtomsInterfaceUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \41 ../Atom/unittests/CopyAtomsInterfaceUnitTest.cpp \42 ../Atom/unittests/CopyAtomsInterfaceUnitTest.hpp43 CopyAtomsInterfaceUnitTest_LDADD = ${ATOMTESTLIBS}44 37 45 38 -
src/Descriptors/AtomShapeDescriptor.cpp
r510f81 r22425a 35 35 } 36 36 37 atom* 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 }47 37 48 std::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 61 AtomDescriptor AtomsByShape(const Shape &shape){ 38 AtomDescriptor AtomByShape(const Shape &shape){ 62 39 return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomShapeDescriptor_impl(shape))); 63 40 } -
src/Descriptors/AtomShapeDescriptor.hpp
r510f81 r22425a 20 20 class Shape; 21 21 22 AtomDescriptor Atom sByShape(const Shape &shape);22 AtomDescriptor AtomByShape(const Shape &shape); 23 23 24 24 #endif /* ATOMSHAPEDESCRIPTOR_HPP_ */ -
src/Descriptors/AtomShapeDescriptor_impl.hpp
r510f81 r22425a 27 27 bool predicate(std::pair<atomId_t,atom*> atom); 28 28 private: 29 virtual atom* find();30 virtual std::vector<atom*> findAll();31 32 29 Shape shape; 33 30 }; -
src/Fragmentation/Fragmentation.cpp
r510f81 r22425a 27 27 #include "Atom/atom.hpp" 28 28 #include "Bond/bond.hpp" 29 #include "Descriptors/MoleculeDescriptor.hpp"30 29 #include "Element/element.hpp" 31 30 #include "Element/periodentafel.hpp" -
src/Graph/DepthFirstSearchAnalysis.cpp
r510f81 r22425a 32 32 #include "CodePatterns/Verbose.hpp" 33 33 #include "Descriptors/AtomDescriptor.hpp" 34 #include "Descriptors/MoleculeDescriptor.hpp"35 34 #include "molecule.hpp" 36 35 #include "MoleculeLeafClass.hpp" -
src/IdPool_impl.hpp
r510f81 r22425a 96 96 return; 97 97 } 98 LOG( 3, "DEBUG: Defragmenting id pool.");98 LOG(1, "STATUS: Defragmenting id pool."); 99 99 for(typename IdPool_t::iterator iter = pool.begin();iter!=pool.end();) { 100 100 // see if this range is adjacent to the next one -
src/LinkedCell/Makefile.am
r510f81 r22425a 20 20 LinkedCell/LinkedCell_Model.hpp \ 21 21 LinkedCell/LinkedCell_Model_changeModel.hpp \ 22 LinkedCell/LinkedCell_Model_inline.hpp \23 22 LinkedCell/LinkedCell_Model_LinkedCellArrayCache.hpp \ 24 23 LinkedCell/LinkedCell_Model_Update.hpp \ -
src/LinkedCell/unittests/Makefile.am
r510f81 r22425a 53 53 ../LinkedCell/unittests/LinkedCell_ControllerUnitTest.hpp \ 54 54 ../LinkedCell/unittests/defs.hpp \ 55 stubs/AtomStub.cpp \55 ../LinkedCell/unittests/stubs/AtomStub.cpp \ 56 56 ../LinkedCell/unittests/stubs/AtomObserverStub.cpp \ 57 57 ../LinkedCell/unittests/stubs/ObserverBoxStub.cpp \ 58 58 ../LinkedCell/unittests/stubs/TesselPointStub.cpp \ 59 ../LinkedCell/unittests/stubs/WorldStub.cpp \ 59 60 ../LinkedCell/unittests/stubs/WorldTimeStub.cpp \ 60 stubs/WorldStub.cpp \61 61 ../LinkedCell/PointCloudAdaptor.hpp \ 62 62 ../Box_BoundaryConditions.cpp \ -
src/Makefile.am
r510f81 r22425a 13 13 include Atom/Makefile.am 14 14 include Element/Makefile.am 15 include Filling/Makefile.am16 15 include Fragmentation/Makefile.am 17 16 include Graph/Makefile.am … … 125 124 126 125 TESSELATIONSOURCE = \ 127 Tesselation/ApproximateShapeArea.cpp \128 Tesselation/ApproximateShapeVolume.cpp \129 126 Tesselation/boundary.cpp \ 130 127 Tesselation/BoundaryLineSet.cpp \ … … 139 136 140 137 TESSELATIONHEADER = \ 141 Tesselation/ApproximateShapeArea.hpp \142 Tesselation/ApproximateShapeVolume.hpp \143 138 Tesselation/boundary.hpp \ 144 139 Tesselation/BoundaryLineSet.hpp \ … … 159 154 ${THERMOSTATSOURCE} \ 160 155 ${TESSELATIONSOURCE} \ 161 AtomIdSet.cpp \162 156 Box.cpp \ 163 157 Box_BoundaryConditions.cpp \ … … 181 175 ${THERMOSTATHEADER} \ 182 176 ${TESSELATIONHEADER} \ 183 AtomIdSet.hpp \184 177 Box.hpp \ 185 178 Box_BoundaryConditions.hpp \ -
src/Shapes/BaseShapes.cpp
r510f81 r22425a 37 37 #include <algorithm> 38 38 39 bool Sphere_impl::isInside(const Vector &point) const{40 return point.NormSquared()<=1 .;41 } 42 43 bool Sphere_impl::isOnSurface(const Vector &point) const{44 return fabs(point.NormSquared()-1 .)<MYEPSILON;45 } 46 47 Vector Sphere_impl::getNormal(const Vector &point) constthrow(NotOnSurfaceException){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){ 48 48 if(!isOnSurface(point)){ 49 49 throw NotOnSurfaceException() << ShapeVector(&point); … … 52 52 } 53 53 54 Vector Sphere_impl::getCenter() const 55 { 56 return Vector(0.,0.,0.); 57 } 58 59 double Sphere_impl::getRadius() const 60 { 61 return 1.; 62 } 63 64 double Sphere_impl::getVolume() const 65 { 66 return (4./3.)*M_PI; // 4/3 pi r^3 67 } 68 69 double Sphere_impl::getSurfaceArea() const 70 { 71 return 2.*M_PI; // 2 pi r^2 72 } 73 74 75 LineSegmentSet Sphere_impl::getLineIntersections(const Line &line) const{ 54 LineSegmentSet Sphere_impl::getLineIntersections(const Line &line){ 76 55 LineSegmentSet res(line); 77 56 std::vector<Vector> intersections = line.getSphereIntersections(); … … 82 61 } 83 62 84 std::string Sphere_impl::toString() const{63 std::string Sphere_impl::toString(){ 85 64 return "Sphere()"; 86 }87 88 enum ShapeType Sphere_impl::getType() const89 {90 return SphereType;91 65 } 92 66 … … 141 115 } 142 116 143 std::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 }148 117 149 118 Shape Sphere(){ … … 160 129 } 161 130 162 bool Cuboid_impl::isInside(const Vector &point) const{131 bool Cuboid_impl::isInside(const Vector &point){ 163 132 return (point[0]>=0 && point[0]<=1) && (point[1]>=0 && point[1]<=1) && (point[2]>=0 && point[2]<=1); 164 133 } 165 134 166 bool Cuboid_impl::isOnSurface(const Vector &point) const{135 bool Cuboid_impl::isOnSurface(const Vector &point){ 167 136 bool retVal = isInside(point); 168 137 // test all borders of the cuboid … … 175 144 } 176 145 177 Vector Cuboid_impl::getNormal(const Vector &point) constthrow(NotOnSurfaceException){146 Vector Cuboid_impl::getNormal(const Vector &point) throw(NotOnSurfaceException){ 178 147 if(!isOnSurface(point)){ 179 148 throw NotOnSurfaceException() << ShapeVector(&point); … … 193 162 } 194 163 195 196 Vector Cuboid_impl::getCenter() const 197 { 198 return Vector(0.5,0.5,0.5); 199 } 200 201 double Cuboid_impl::getRadius() const 202 { 203 return .5; 204 } 205 206 double Cuboid_impl::getVolume() const 207 { 208 return 1.; // l^3 209 } 210 211 double Cuboid_impl::getSurfaceArea() const 212 { 213 return 6.; // 6 * l^2 214 } 215 216 LineSegmentSet Cuboid_impl::getLineIntersections(const Line &line) const{ 164 LineSegmentSet Cuboid_impl::getLineIntersections(const Line &line){ 217 165 LineSegmentSet res(line); 218 166 // get the intersection on each of the six faces … … 244 192 } 245 193 246 std::string Cuboid_impl::toString() const{194 std::string Cuboid_impl::toString(){ 247 195 return "Cuboid()"; 248 }249 250 enum ShapeType Cuboid_impl::getType() const251 {252 return CuboidType;253 196 } 254 197 … … 260 203 ASSERT(false, "Cuboid_impl::getHomogeneousPointsOnSurface() not implemented yet"); 261 204 return PointsOnSurface; 262 }263 264 std::vector<Vector> Cuboid_impl::getHomogeneousPointsInVolume(const size_t N) const {265 ASSERT(0,266 "Cuboid_impl::getHomogeneousPointsInVolume() - not implemented.");267 return std::vector<Vector>();268 205 } 269 206 -
src/Shapes/BaseShapes_impl.hpp
r510f81 r22425a 20 20 #include "Shapes/Shape_impl.hpp" 21 21 #include "Shapes/ShapeExceptions.hpp" 22 #include "Shapes/ShapeType.hpp"23 22 24 23 class Sphere_impl : public Shape_impl { 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; 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(); 35 29 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 36 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;37 30 }; 38 31 39 32 class Cuboid_impl : public Shape_impl { 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; 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(); 50 38 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 51 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;52 39 }; 53 40 -
src/Shapes/Makefile.am
r510f81 r22425a 13 13 Shapes/ShapeExceptions.hpp \ 14 14 Shapes/ShapeOps.hpp \ 15 Shapes/ShapeOps_impl.hpp \ 16 Shapes/ShapeType.hpp 15 Shapes/ShapeOps_impl.hpp 17 16 17 18 18 19 19 noinst_LTLIBRARIES += libMolecuilderShapes.la -
src/Shapes/Shape.cpp
r510f81 r22425a 26 26 #include "Shapes/Shape_impl.hpp" 27 27 #include "Shapes/ShapeExceptions.hpp" 28 #include "Shapes/ShapeType.hpp" 29 30 #include "Tesselation/ApproximateShapeArea.hpp" 31 #include "Tesselation/ApproximateShapeVolume.hpp" 32 33 #include <algorithm> 34 #include <limits> 28 35 29 #include <string> 36 30 … … 54 48 } 55 49 56 Vector Shape::getCenter() const{ 57 return impl->getCenter(); 58 } 59 60 double 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 */ 73 double 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 */ 93 double 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 104 LineSegmentSet Shape::getLineIntersections(const Line &line) const{ 50 LineSegmentSet Shape::getLineIntersections(const Line &line){ 105 51 return impl->getLineIntersections(line); 106 52 } … … 108 54 std::vector<Vector> Shape::getHomogeneousPointsOnSurface(const size_t N) const { 109 55 return impl->getHomogeneousPointsOnSurface(N); 110 }111 112 std::vector<Vector> Shape::getHomogeneousPointsInVolume(const size_t N) const {113 return impl->getHomogeneousPointsInVolume(N);114 56 } 115 57 … … 125 67 } 126 68 127 bool Shape::operator==(const Shape &rhs) const{128 return (this->getType() == rhs.getType());129 }130 131 69 std::string Shape::toString() const{ 132 70 return impl->toString(); 133 }134 135 enum ShapeType Shape::getType() const{136 return impl->getType();137 71 } 138 72 … … 168 102 AndShape_impl::~AndShape_impl(){} 169 103 170 bool AndShape_impl::isInside(const Vector &point) const{104 bool AndShape_impl::isInside(const Vector &point){ 171 105 return lhs->isInside(point) && rhs->isInside(point); 172 106 } 173 107 174 bool AndShape_impl::isOnSurface(const Vector &point) const{108 bool AndShape_impl::isOnSurface(const Vector &point){ 175 109 // check the number of surfaces that this point is on 176 110 int surfaces =0; … … 204 138 } 205 139 206 Vector AndShape_impl::getNormal(const Vector &point) constthrow (NotOnSurfaceException){140 Vector AndShape_impl::getNormal(const Vector &point) throw (NotOnSurfaceException){ 207 141 Vector res; 208 142 if(!isOnSurface(point)){ … … 215 149 } 216 150 217 Vector 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 226 double 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 237 double AndShape_impl::getVolume() const 238 { 239 // TODO 240 return -1.; 241 } 242 243 double AndShape_impl::getSurfaceArea() const 244 { 245 // TODO 246 return -1.; 247 } 248 249 LineSegmentSet AndShape_impl::getLineIntersections(const Line &line) const{ 151 LineSegmentSet AndShape_impl::getLineIntersections(const Line &line){ 250 152 return intersect(lhs->getLineIntersections(line),rhs->getLineIntersections(line)); 251 153 } 252 154 253 std::string AndShape_impl::toString() const{155 std::string AndShape_impl::toString() { 254 156 return std::string("(") + lhs->toString() + std::string("&&") + rhs->toString() + std::string(")"); 255 }256 257 enum ShapeType AndShape_impl::getType() const{258 return CombinedType;259 157 } 260 158 … … 276 174 } 277 175 278 std::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 284 176 285 177 Shape operator&&(const Shape &lhs,const Shape &rhs){ … … 296 188 OrShape_impl::~OrShape_impl(){} 297 189 298 bool OrShape_impl::isInside(const Vector &point) const{190 bool OrShape_impl::isInside(const Vector &point){ 299 191 return rhs->isInside(point) || lhs->isInside(point); 300 192 } 301 193 302 bool OrShape_impl::isOnSurface(const Vector &point) const{194 bool OrShape_impl::isOnSurface(const Vector &point){ 303 195 // check the number of surfaces that this point is on 304 196 int surfaces =0; … … 332 224 } 333 225 334 Vector OrShape_impl::getNormal(const Vector &point) constthrow (NotOnSurfaceException){226 Vector OrShape_impl::getNormal(const Vector &point) throw (NotOnSurfaceException){ 335 227 Vector res; 336 228 if(!isOnSurface(point)){ … … 343 235 } 344 236 345 Vector 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 354 double 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 361 double OrShape_impl::getVolume() const 362 { 363 // TODO 364 return -1.; 365 } 366 367 double OrShape_impl::getSurfaceArea() const 368 { 369 // TODO 370 return -1.; 371 } 372 373 LineSegmentSet OrShape_impl::getLineIntersections(const Line &line) const{ 237 LineSegmentSet OrShape_impl::getLineIntersections(const Line &line){ 374 238 return merge(lhs->getLineIntersections(line),rhs->getLineIntersections(line)); 375 239 } 376 240 377 std::string OrShape_impl::toString() const{241 std::string OrShape_impl::toString() { 378 242 return std::string("(") + lhs->toString() + std::string("||") + rhs->toString() + std::string(")"); 379 }380 381 enum ShapeType OrShape_impl::getType() const{382 return CombinedType;383 243 } 384 244 … … 400 260 } 401 261 402 std::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 408 262 Shape operator||(const Shape &lhs,const Shape &rhs){ 409 263 Shape::impl_ptr newImpl = Shape::impl_ptr(new OrShape_impl(getShapeImpl(lhs),getShapeImpl(rhs))); … … 419 273 NotShape_impl::~NotShape_impl(){} 420 274 421 bool NotShape_impl::isInside(const Vector &point) const{275 bool NotShape_impl::isInside(const Vector &point){ 422 276 return !arg->isInside(point); 423 277 } 424 278 425 bool NotShape_impl::isOnSurface(const Vector &point) const{279 bool NotShape_impl::isOnSurface(const Vector &point){ 426 280 return arg->isOnSurface(point); 427 281 } 428 282 429 Vector NotShape_impl::getNormal(const Vector &point) constthrow(NotOnSurfaceException){283 Vector NotShape_impl::getNormal(const Vector &point) throw(NotOnSurfaceException){ 430 284 return -1.*arg->getNormal(point); 431 285 } 432 286 433 Vector NotShape_impl::getCenter() const 434 { 435 return arg->getCenter(); 436 } 437 438 double NotShape_impl::getRadius() const 439 { 440 return std::numeric_limits<double>::infinity(); 441 } 442 443 double NotShape_impl::getVolume() const 444 { 445 // TODO 446 return -1.; //-arg->getVolume(); 447 } 448 449 double NotShape_impl::getSurfaceArea() const 450 { 451 // TODO 452 return -1.; // -arg->getSurfaceArea(); 453 } 454 455 LineSegmentSet NotShape_impl::getLineIntersections(const Line &line) const{ 287 LineSegmentSet NotShape_impl::getLineIntersections(const Line &line){ 456 288 return invert(arg->getLineIntersections(line)); 457 289 } 458 290 459 std::string NotShape_impl::toString() const{291 std::string NotShape_impl::toString(){ 460 292 return std::string("!") + arg->toString(); 461 }462 463 enum ShapeType NotShape_impl::getType() const{464 return CombinedType;465 293 } 466 294 … … 468 296 // surfaces are the same, only normal direction is different 469 297 return arg->getHomogeneousPointsOnSurface(N); 470 }471 472 std::vector<Vector> NotShape_impl::getHomogeneousPointsInVolume(const size_t N) const {473 ASSERT(0,474 "NotShape_impl::getHomogeneousPointsInVolume() - not implemented.");475 return std::vector<Vector>();476 298 } 477 299 -
src/Shapes/Shape.hpp
r510f81 r22425a 19 19 20 20 #include "Shapes/ShapeExceptions.hpp" 21 #include "Shapes/ShapeType.hpp"22 21 23 22 #include <vector> … … 42 41 Vector getNormal(const Vector &point) const throw(NotOnSurfaceException); 43 42 44 Vector getCenter() const; 45 double getRadius() const; 46 double getVolume() const; 47 double getSurfaceArea() const; 48 49 LineSegmentSet getLineIntersections(const Line&) const; 43 LineSegmentSet getLineIntersections(const Line&); 50 44 std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 51 std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;52 45 53 46 Shape &operator=(const Shape& rhs); 54 47 55 bool operator==(const Shape &rhs) const;56 57 48 std::string toString() const; 58 enum ShapeType getType() const;59 60 49 protected: 61 50 impl_ptr getImpl() const; -
src/Shapes/ShapeOps.cpp
r510f81 r22425a 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include <algorithm>23 #include <boost/bind.hpp>24 25 22 #include "Shapes/ShapeExceptions.hpp" 26 23 #include "Shapes/ShapeOps.hpp" … … 37 34 ShapeOpsBase_impl::~ShapeOpsBase_impl(){} 38 35 39 bool ShapeOpsBase_impl::isInside(const Vector &point) const{36 bool ShapeOpsBase_impl::isInside(const Vector &point){ 40 37 return arg->isInside(translateIn(point)); 41 38 } 42 39 43 bool ShapeOpsBase_impl::isOnSurface(const Vector &point) const{40 bool ShapeOpsBase_impl::isOnSurface(const Vector &point){ 44 41 return arg->isOnSurface(translateIn(point)); 45 42 } 46 43 47 Vector ShapeOpsBase_impl::getNormal(const Vector &point) constthrow (NotOnSurfaceException){44 Vector ShapeOpsBase_impl::getNormal(const Vector &point) throw (NotOnSurfaceException){ 48 45 Vector helper = translateIn(point); 49 46 if(!arg->isOnSurface(helper)){ … … 55 52 } 56 53 57 Vector ShapeOpsBase_impl::getCenter() const 58 { 59 return arg->getCenter(); 60 } 61 62 double ShapeOpsBase_impl::getRadius() const 63 { 64 return translateOutPos(Vector(arg->getRadius(), 0., 0.)).Norm(); 65 } 66 67 68 LineSegmentSet ShapeOpsBase_impl::getLineIntersections(const Line &line) const{ 54 LineSegmentSet ShapeOpsBase_impl::getLineIntersections(const Line &line){ 69 55 Line newLine(translateIn(line.getOrigin()),translateIn(line.getDirection())); 70 56 LineSegmentSet res(line); … … 85 71 } 86 72 87 enum ShapeType ShapeOpsBase_impl::getType() const {88 return getArg()->getType();89 }90 91 73 std::vector<Vector> ShapeOpsBase_impl::getHomogeneousPointsOnSurface(const size_t N) const { 92 return getArg()->getHomogeneousPointsOnSurface(N); 93 } 94 95 std::vector<Vector> ShapeOpsBase_impl::getHomogeneousPointsInVolume(const size_t N) const { 96 return getArg()->getHomogeneousPointsInVolume(N); 74 return getArg()->getHomogeneousPointsOnSurface(N);; 97 75 } 98 76 … … 111 89 Resize_impl::~Resize_impl(){} 112 90 113 double Resize_impl::getVolume() const 114 { 115 return getArg()->getVolume() * size; 116 } 117 118 double Resize_impl::getSurfaceArea() const 119 { 120 return getArg()->getSurfaceArea() * size; 121 } 122 123 124 bool Resize_impl::isInside(const Vector& point) const{ 91 bool Resize_impl::isInside(const Vector& point){ 125 92 return getArg()->isInside((1/size) * point); 126 93 } 127 94 128 Vector Resize_impl::translateIn(const Vector& point) const{95 Vector Resize_impl::translateIn(const Vector& point){ 129 96 return (1/size) * point; 130 97 } 131 98 132 Vector Resize_impl::translateOutPos(const Vector& point) const{99 Vector Resize_impl::translateOutPos(const Vector& point){ 133 100 return size * point; 134 101 } 135 102 136 Vector Resize_impl::translateOutNormal(const Vector& point) const{103 Vector Resize_impl::translateOutNormal(const Vector& point){ 137 104 return point; 138 105 } 139 106 140 std::string Resize_impl::toString() const{107 std::string Resize_impl::toString() { 141 108 std::stringstream sstr; 142 109 sstr << "resize(" << getArg()->toString() << "," << size << ")"; … … 146 113 std::vector<Vector> Resize_impl::getHomogeneousPointsOnSurface(const size_t N) const { 147 114 std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N); 148 std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(), 149 boost::bind(&Vector::operator*, _1, size) ); 150 return PointsOnSurface; 151 } 152 153 std::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>(); 115 for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) { 116 *iter *= size; 117 } 118 return PointsOnSurface; 158 119 } 159 120 … … 172 133 Translate_impl::~Translate_impl(){} 173 134 174 bool Translate_impl::isInside(const Vector& point) const{135 bool Translate_impl::isInside(const Vector& point){ 175 136 return getArg()->isInside(point-offset); 176 137 } 177 138 178 Vector Translate_impl::getCenter() const 179 { 180 return getArg()->getCenter()+offset; 181 } 182 183 double Translate_impl::getRadius() const 184 { 185 return getArg()->getRadius(); 186 } 187 188 double Translate_impl::getVolume() const 189 { 190 return getArg()->getVolume(); 191 } 192 193 double Translate_impl::getSurfaceArea() const 194 { 195 return getArg()->getSurfaceArea(); 196 } 197 198 Vector Translate_impl::translateIn(const Vector& point) const{ 139 Vector Translate_impl::translateIn(const Vector& point){ 199 140 return point-offset; 200 141 } 201 142 202 Vector Translate_impl::translateOutPos(const Vector& point) const{143 Vector Translate_impl::translateOutPos(const Vector& point){ 203 144 return point+offset; 204 145 } 205 146 206 Vector Translate_impl::translateOutNormal(const Vector& point) const{147 Vector Translate_impl::translateOutNormal(const Vector& point){ 207 148 return point; 208 149 } 209 150 210 std::string Translate_impl::toString() const{151 std::string Translate_impl::toString() { 211 152 std::stringstream sstr; 212 153 sstr << "translate(" << getArg()->toString() << "," << offset << ")"; … … 216 157 std::vector<Vector> Translate_impl::getHomogeneousPointsOnSurface(const size_t N) const { 217 158 std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N); 218 std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(), 219 boost::bind(&Vector::operator+, _1, offset) ); 220 return PointsOnSurface; 221 } 222 223 std::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) ); 159 for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) { 160 *iter += offset; 161 } 227 162 return PointsOnSurface; 228 163 } … … 238 173 ShapeOpsBase_impl(_arg),factors(_factors) 239 174 { 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"); 240 178 for(int i = NDIM;i--;){ 241 ASSERT(factors[i]>0.,"cannot stretch a shape by a negative amount"); 242 reciFactors[i] = 1./factors[i]; 179 reciFactors[i] = 1/factors[i]; 243 180 } 244 181 } … … 246 183 Stretch_impl::~Stretch_impl(){} 247 184 248 double Stretch_impl::getVolume() const 249 { 250 // TODO 251 return -1.; 252 } 253 254 double Stretch_impl::getSurfaceArea() const 255 { 256 // TODO 257 return -1.; 258 } 259 260 bool Stretch_impl::isInside(const Vector& point) const{ 185 bool Stretch_impl::isInside(const Vector& point){ 261 186 Vector helper=point; 262 187 helper.ScaleAll(reciFactors); … … 264 189 } 265 190 266 Vector Stretch_impl::translateIn(const Vector& point) const{191 Vector Stretch_impl::translateIn(const Vector& point){ 267 192 Vector helper=point; 268 193 helper.ScaleAll(reciFactors); … … 270 195 } 271 196 272 Vector Stretch_impl::translateOutPos(const Vector& point) const{197 Vector Stretch_impl::translateOutPos(const Vector& point){ 273 198 Vector helper=point; 274 199 helper.ScaleAll(factors); … … 276 201 } 277 202 278 Vector Stretch_impl::translateOutNormal(const Vector& point) const{203 Vector Stretch_impl::translateOutNormal(const Vector& point){ 279 204 Vector helper=point; 280 205 // the normalFactors are derived from appearances of the factors … … 288 213 } 289 214 290 std::string Stretch_impl::toString() const{215 std::string Stretch_impl::toString() { 291 216 std::stringstream sstr; 292 217 sstr << "stretch(" << getArg()->toString() << "," << factors << ")"; … … 296 221 std::vector<Vector> Stretch_impl::getHomogeneousPointsOnSurface(const size_t N) const { 297 222 std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N); 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 303 std::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) ); 223 for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) { 224 (*iter).ScaleAll(reciFactors); 225 } 307 226 return PointsOnSurface; 308 227 } … … 323 242 Transform_impl::~Transform_impl(){} 324 243 325 double Transform_impl::getVolume() const 326 { 327 return getArg()->getVolume(); 328 } 329 330 double Transform_impl::getSurfaceArea() const 331 { 332 return getArg()->getSurfaceArea(); 333 } 334 335 bool Transform_impl::isInside(const Vector& point) const{ 244 bool Transform_impl::isInside(const Vector& point){ 336 245 return getArg()->isInside(transformationInv * point); 337 246 } 338 247 339 Vector Transform_impl::translateIn(const Vector& point) const{248 Vector Transform_impl::translateIn(const Vector& point){ 340 249 return transformationInv * point; 341 250 } 342 251 343 Vector Transform_impl::translateOutPos(const Vector& point) const{252 Vector Transform_impl::translateOutPos(const Vector& point){ 344 253 return transformation * point; 345 254 } 346 255 347 Vector Transform_impl::translateOutNormal(const Vector& point) const 348 { 256 Vector Transform_impl::translateOutNormal(const Vector& point){ 349 257 RealSpaceMatrix mat = transformation.invert().transpose(); 350 258 return mat * point; 351 259 } 352 260 353 std::string Transform_impl::toString() const{261 std::string Transform_impl::toString() { 354 262 std::stringstream sstr; 355 263 sstr << "transform(" << getArg()->toString() << "," << transformation << ")"; … … 359 267 std::vector<Vector> Transform_impl::getHomogeneousPointsOnSurface(const size_t N) const { 360 268 std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N); 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 366 std::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)); 269 for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) { 270 *iter = transformation * (*iter); 271 } 370 272 return PointsOnSurface; 371 273 } -
src/Shapes/ShapeOps_impl.hpp
r510f81 r22425a 17 17 #include "Shapes/Shape_impl.hpp" 18 18 #include "Shapes/ShapeExceptions.hpp" 19 #include "Shapes/ShapeType.hpp"20 19 #include "LinearAlgebra/Vector.hpp" 21 20 #include "LinearAlgebra/RealSpaceMatrix.hpp" … … 29 28 ShapeOpsBase_impl(const Shape::impl_ptr&); 30 29 virtual ~ShapeOpsBase_impl(); 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; 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&); 38 34 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 39 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;40 35 protected: 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;36 virtual Vector translateIn(const Vector &point)=0; 37 virtual Vector translateOutPos(const Vector &point)=0; 38 virtual Vector translateOutNormal(const Vector &point)=0; 44 39 Shape::impl_ptr getArg() const; 45 40 private: … … 53 48 virtual ~Resize_impl(); 54 49 protected: 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; 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); 62 55 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 63 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;64 56 private: 65 57 double size; … … 72 64 virtual ~Translate_impl(); 73 65 protected: 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; 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); 83 71 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 84 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;85 72 private: 86 73 Vector offset; … … 90 77 { 91 78 public: 92 93 94 Stretch_impl(const Shape::impl_ptr&, const Vector&); 79 Stretch_impl(const Shape::impl_ptr&, const Vector&); 95 80 virtual ~Stretch_impl(); 96 81 protected: 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; 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); 104 87 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 105 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;106 88 private: 107 89 Vector factors; … … 115 97 virtual ~Transform_impl(); 116 98 protected: 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; 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); 124 104 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 125 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;126 105 private: 127 106 RealSpaceMatrix transformation; -
src/Shapes/Shape_impl.hpp
r510f81 r22425a 15 15 16 16 17 #include <limits>18 17 #include <vector> 19 20 #include "CodePatterns/Assert.hpp"21 18 22 19 #include "Shapes/Shape.hpp" 23 20 #include "Shapes/ShapeExceptions.hpp" 24 #include "Shapes/ShapeType.hpp"25 21 #include "LinearAlgebra/Line.hpp" 26 #include "LinearAlgebra/LinePoint.hpp"27 22 #include "LinearAlgebra/LineSegment.hpp" 28 23 #include "LinearAlgebra/LineSegmentSet.hpp" … … 34 29 Shape_impl(){}; 35 30 virtual ~Shape_impl(){}; 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; 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; 46 36 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const=0; 47 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const=0;48 37 }; 49 38 50 39 class Everywhere_impl : public Shape_impl { 51 40 public: 52 virtual bool isInside(const Vector &point) const{41 virtual bool isInside(const Vector &point){ 53 42 return true; 54 43 } 55 virtual bool isOnSurface(const Vector &point) const{44 virtual bool isOnSurface(const Vector &point){ 56 45 return false; 57 46 } 58 virtual Vector getNormal(const Vector &point) constthrow(NotOnSurfaceException){47 virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException){ 59 48 throw NotOnSurfaceException() << ShapeVector(&point); 60 49 } 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{ 50 virtual LineSegmentSet getLineIntersections(const Line &line){ 78 51 LineSegmentSet res(line); 79 52 res.insert(LineSegment(line.negEndpoint(),line.posEndpoint())); 80 53 return res; 81 54 } 82 virtual std::string toString() const{55 virtual std::string toString(){ 83 56 return "Everywhere()"; 84 }85 virtual enum ShapeType getType() const {86 return EverywhereType;87 57 } 88 58 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const { … … 90 60 return PointsOnSurface; 91 61 } 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 }97 62 }; 98 63 99 64 class Nowhere_impl : public Shape_impl { 100 virtual bool isInside(const Vector &point) const{65 virtual bool isInside(const Vector &point){ 101 66 return false; 102 67 } 103 virtual bool isOnSurface(const Vector &point) const{68 virtual bool isOnSurface(const Vector &point){ 104 69 return false; 105 70 } 106 virtual Vector getNormal(const Vector &point) constthrow(NotOnSurfaceException){71 virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException){ 107 72 throw NotOnSurfaceException() << ShapeVector(&point); 108 73 } 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{ 74 virtual LineSegmentSet getLineIntersections(const Line &line){ 124 75 return LineSegmentSet(line); 125 76 } 126 virtual std::string toString() const{77 virtual std::string toString(){ 127 78 return "Nowhere()"; 128 }129 virtual enum ShapeType getType() const {130 return NowhereType;131 79 } 132 80 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const { 133 81 std::vector<Vector> PointsOnSurface; 134 82 return PointsOnSurface; 135 }136 std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const {137 return std::vector<Vector>();138 83 } 139 84 }; … … 143 88 AndShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&); 144 89 virtual ~AndShape_impl(); 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; 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(); 155 95 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 156 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;157 96 private: 158 97 Shape::impl_ptr lhs; … … 164 103 OrShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&); 165 104 virtual ~OrShape_impl(); 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; 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(); 176 110 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 177 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;178 111 private: 179 112 Shape::impl_ptr lhs; … … 185 118 NotShape_impl(const Shape::impl_ptr&); 186 119 virtual ~NotShape_impl(); 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; 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(); 197 125 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 198 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const;199 126 private: 200 127 Shape::impl_ptr arg; -
src/Shapes/unittests/Makefile.am
r510f81 r22425a 4 4 5 5 SHAPETESTSSOURCES = \ 6 ../Shapes/unittests/BaseShapesUnitTest.cpp \ 7 ../Shapes/unittests/ShapeOpsUnitTest.cpp \ 8 ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.cpp 6 ../Shapes/unittests/ShapeUnitTest.cpp 9 7 10 8 SHAPETESTSHEADERS= \ 11 ../Shapes/unittests/BaseShapesUnitTest.hpp \ 12 ../Shapes/unittests/ShapeOpsUnitTest.hpp \ 13 ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.cpp 9 ../Shapes/unittests/ShapeUnitTest.hpp 14 10 15 11 SHAPETESTS = \ 16 BaseShapesUnitTest \ 17 ShapeOpsUnitTest \ 18 Shape_HomogeneousPointsUnitTest 12 ShapeUnittest 19 13 20 14 TESTS += $(SHAPETESTS) … … 28 22 # $(BOOST_LIB) 29 23 30 BaseShapesUnitTest_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 35 nodist_BaseShapesUnitTest_SOURCES = \ 24 ShapeUnittest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 25 ../Shapes/unittests/ShapeUnitTest.cpp \ 26 ../Shapes/unittests/ShapeUnitTest.hpp 27 nodist_ShapeUnittest_SOURCES = \ 36 28 ../Helpers/defs.hpp \ 37 29 ../Helpers/defs.cpp 38 BaseShapesUnitTest_LDADD = $(SHAPELIBS) 39 40 ShapeOpsUnitTest_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 45 nodist_ShapeOpsUnitTest_SOURCES = \ 46 ../Helpers/defs.hpp \ 47 ../Helpers/defs.cpp 48 ShapeOpsUnitTest_LDADD = $(SHAPELIBS) 49 50 Shape_HomogeneousPointsUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 51 ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.cpp \ 52 ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.hpp 53 nodist_Shape_HomogeneousPointsUnitTest_SOURCES = \ 54 ../Helpers/defs.hpp \ 55 ../Helpers/defs.cpp 56 Shape_HomogeneousPointsUnitTest_LDADD = $(SHAPELIBS) 30 ShapeUnittest_LDADD = $(SHAPELIBS) 57 31 58 32 -
src/Tesselation/BoundaryTriangleSet.cpp
r510f81 r22425a 230 230 Vector Direction; 231 231 232 // 1. get intersection with plane and place in ClosestPoint232 // 1. get intersection with plane 233 233 LOG(1, "INFO: Looking for closest point of triangle " << *this << " to " << x << "."); 234 LOG(1, "INFO: endpoints are " << endpoints[0]->node->getPosition() << "," 235 << endpoints[1]->node->getPosition() << ", and " << endpoints[2]->node->getPosition() << "."); 234 GetCenter(Direction); 236 235 try { 237 ClosestPoint = Plane(NormalVector, (endpoints[0]->node->getPosition())).getClosestPoint(x); 236 Line l = makeLineThrough(x, Direction); 237 ClosestPoint = Plane(NormalVector, (endpoints[0]->node->getPosition())).GetIntersection(l); 238 238 } 239 239 catch (LinearAlgebraException &excp) { 240 240 (ClosestPoint) = (x); 241 241 } 242 Vector InPlane(ClosestPoint); // points from plane intersection to straight-down point243 242 244 243 // 2. Calculate in plane part of line (x, intersection) 245 LOG(2, "INFO: Closest point on triangle plane is " << ClosestPoint << "."); 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 << "."); 246 251 247 252 // Calculate cross point between one baseline and the desired point such that distance is shortest 253 double ShortestDistance = -1.; 254 bool InsideFlag = false; 248 255 Vector CrossDirection[3]; 249 256 Vector CrossPoint[3]; 250 for (int i = 0; i < 3; i++) { 251 const Vector Direction = (endpoints[i%3]->node->getPosition()) - (endpoints[(i+1)%3]->node->getPosition()); 257 Vector helper; 258 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()); 252 261 // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal); 253 262 Line l = makeLineThrough((endpoints[i%3]->node->getPosition()), (endpoints[(i+1)%3]->node->getPosition())); 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 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 259 266 const double s = CrossPoint[i].ScalarProduct(Direction)/Direction.NormSquared(); 260 267 LOG(2, "INFO: Factor s is " << s << "."); 261 268 if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) { 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.; 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; 281 280 for (int i = 0; i < 3; i++) { 282 281 const double sign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 1) % 3]); … … 285 284 if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign 286 285 InsideFlag = false; 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 286 } 295 287 if (InsideFlag) { 296 288 (ClosestPoint) = InPlane; 297 289 ShortestDistance = InPlane.DistanceSquared(x); 298 } 299 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 } 300 299 LOG(1, "INFO: Closest Point is " << ClosestPoint << " with shortest squared distance is " << ShortestDistance << "."); 301 300 return ShortestDistance; … … 371 370 } 372 371 ; 373 374 /** Checks whether a given point is inside the plane of the triangle and inside the375 * bounds defined by its BoundaryLineSet's.376 *377 * @param point point to check378 * @return true - point is inside place and inside all BoundaryLine's379 */380 bool BoundaryTriangleSet::IsInsideTriangle(const Vector &point) const381 {382 Info FunctionInfo(__func__);383 384 // check if it's inside the plane385 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 others397 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 lines404 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 coincide409 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 coincide417 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 for429 // each BoundaryLine.430 // NOTE: we assume here that endpoints are linear independent, as the case431 // has been caught before already extensively432 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 448 372 449 373 /** Returns the endpoint which is not contained in the given \a *line. -
src/Tesselation/BoundaryTriangleSet.hpp
r510f81 r22425a 42 42 bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const; 43 43 bool IsPresentTupel(const BoundaryTriangleSet * const T) const; 44 bool IsInsideTriangle(const Vector &point) const;45 44 46 45 Plane getPlane() const; -
src/Tesselation/boundary.cpp
r510f81 r22425a 1029 1029 for (int i=0;i<NDIM;i++) { 1030 1030 phi[i] = (random()/(rng_max-rng_min))*(2.*M_PI); 1031 LOG(4, "DEBUG: Random angle is " << phi[i] << ".");1031 std::cout << "Random angle is " << phi[i] << std::endl; 1032 1032 } 1033 1033 -
src/Tesselation/triangleintersectionlist.cpp
r510f81 r22425a 197 197 if (!DistanceList.empty()) { 198 198 // get closest triangle(s) 199 std::pair< DistanceTriangleMap:: const_iterator, DistanceTriangleMap::const_iterator > DistanceRange =199 std::pair< DistanceTriangleMap::iterator, DistanceTriangleMap::iterator > DistanceRange = 200 200 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 }208 201 // if there is more than one, check all of their normal vectors 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); 202 // return the one with positive SKP if present 203 204 runner = IntersectionList.find(DistanceList.begin()->second); 228 205 } 229 206 return runner; -
src/Tesselation/unittests/Makefile.am
r510f81 r22425a 14 14 TESSELATIONTESTS = \ 15 15 TesselationUnitTest \ 16 Tesselation_BoundaryTriangleUnitTest \ 17 Tesselation_InOutsideUnitTest 16 Tesselation_BoundaryTriangleUnitTest 17 18 XFAIL_TESTS += Tesselation_InOutsideUnitTest 18 19 19 20 TESTS += $(TESSELATIONTESTS) -
src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp
r510f81 r22425a 30 30 #include "Helpers/defs.hpp" 31 31 #include "Atom/TesselPoint.hpp" 32 #include "LinearAlgebra/Plane.hpp"33 #include "LinearAlgebra/RealSpaceMatrix.hpp"34 #include "LinearAlgebra/VectorSet.hpp"35 32 #include "Tesselation/BoundaryPointSet.hpp" 36 33 #include "Tesselation/BoundaryLineSet.hpp" … … 52 49 53 50 54 void TesselationBoundaryTriangleTest:: createTriangle(const std::vector<Vector> &Vectors)55 { 56 CPPUNIT_ASSERT_EQUAL( (size_t)3, Vectors.size());51 void TesselationBoundaryTriangleTest::setUp() 52 { 53 setVerbosity(5); 57 54 58 55 // create nodes 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 } 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] ); 66 71 67 72 // create line … … 72 77 // create triangle 73 78 triangle = new BoundaryTriangleSet(lines, 0); 74 Plane p(Vectors[0], Vectors[1], Vectors[2]); 75 triangle->GetNormalVector(p.getNormal()); 76 } 77 78 void 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 } 79 triangle->GetNormalVector(Vector(0.,0.,1.)); 80 }; 81 91 82 92 83 void TesselationBoundaryTriangleTest::tearDown() … … 99 90 logger::purgeInstance(); 100 91 errorLogger::purgeInstance(); 101 } 102 103 /** UnitTest for Tesselation::IsInsideTriangle() 104 */ 105 void 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 */ 186 void 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 */ 237 void 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 */ 288 void 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 } 92 }; 310 93 311 94 /** UnitTest for Tesselation::IsInnerPoint() -
src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp
r510f81 r22425a 19 19 #include <cppunit/extensions/HelperMacros.h> 20 20 21 #include <vector>22 23 #include "LinearAlgebra/Vector.hpp"24 21 #include "LinkedCell/linkedcell.hpp" 25 22 #include "Tesselation/tesselation.hpp" … … 32 29 { 33 30 CPPUNIT_TEST_SUITE( TesselationBoundaryTriangleTest) ; 34 CPPUNIT_TEST ( IsInsideTriangleTest );35 CPPUNIT_TEST ( IsInsideTriangle_specificTest );36 CPPUNIT_TEST ( GetClosestPointInsideTriangleTest );37 CPPUNIT_TEST ( GetClosestPointInsideTriangle_specificTest );38 31 CPPUNIT_TEST ( GetClosestPointOnPlaneTest ); 39 32 CPPUNIT_TEST ( GetClosestPointOffPlaneTest ); … … 43 36 void setUp(); 44 37 void tearDown(); 45 void IsInsideTriangleTest();46 void IsInsideTriangle_specificTest();47 void GetClosestPointInsideTriangleTest();48 void GetClosestPointInsideTriangle_specificTest();49 38 void GetClosestPointOnPlaneTest(); 50 39 void GetClosestPointOffPlaneTest(); 51 40 52 41 private: 53 void createTriangle(const std::vector<Vector> &Vectors);54 55 42 static const double SPHERERADIUS; 56 43 -
src/UIElements/CommandLineUI/CommandLineParser.cpp
r510f81 r22425a 51 51 atom("Atom options"), 52 52 command("Command options"), 53 fill("fill options"),54 53 fragmentation("Fragmentation options"), 55 54 graph("Graph options"), … … 66 65 CmdParserLookup["command"] = &command; 67 66 CmdParserLookup["edit"] = &edit; 68 CmdParserLookup["fill"] = &fill;69 67 CmdParserLookup["fragmentation"] = &fragmentation; 70 68 CmdParserLookup["graph"] = &graph; -
src/UIElements/CommandLineUI/CommandLineParser.hpp
r510f81 r22425a 58 58 po::options_description command; 59 59 po::options_description edit; 60 po::options_description fill;61 60 po::options_description fragmentation; 62 61 po::options_description graph; -
src/UIElements/Makefile.am
r510f81 r22425a 263 263 libMolecuilderAnalysis.la \ 264 264 libMolecuilderGraph.la \ 265 libMolecuilderFilling.la \266 265 libMolecuilder.la \ 267 266 libMolecuilderFragmentation.la \ -
src/UIElements/Menu/MenuDescription.cpp
r510f81 r22425a 49 49 MenuPositionMap->insert(std::make_pair("command",TopPosition("",3))); 50 50 MenuPositionMap->insert(std::make_pair("edit",TopPosition("",2))); 51 MenuPositionMap->insert(std::make_pair("fill",TopPosition("tools",5)));52 51 MenuPositionMap->insert(std::make_pair("fragmentation",TopPosition("tools",3))); 53 52 MenuPositionMap->insert(std::make_pair("graph",TopPosition("tools",4))); … … 64 63 MenuDescriptionsMap->insert(std::make_pair("command","Configuration")); 65 64 MenuDescriptionsMap->insert(std::make_pair("edit","Edit")); 66 MenuDescriptionsMap->insert(std::make_pair("fill","Fill"));67 65 MenuDescriptionsMap->insert(std::make_pair("fragmentation","Fragmentation")); 68 66 MenuDescriptionsMap->insert(std::make_pair("graph","Graph")); … … 79 77 MenuNameMap->insert(std::make_pair("command","Configuration")); 80 78 MenuNameMap->insert(std::make_pair("edit","Edit")); 81 MenuNameMap->insert(std::make_pair("fill","Fill"));82 79 MenuNameMap->insert(std::make_pair("fragmentation","Fragmentation")); 83 80 MenuNameMap->insert(std::make_pair("graph","Graph")); -
src/documentation/constructs/atoms.dox
r510f81 r22425a 56 56 * compatible implementation. 57 57 * 58 * \section atoms-copy Copying atoms59 58 * 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 * 59 * \date 2011-10-31 83 60 */ -
src/documentation/constructs/constructs.dox
r510f81 r22425a 2 2 * Project: MoleCuilder 3 3 * Description: creates and alters molecular systems 4 * Copyright (C) 201 1-2012University of Bonn. All rights reserved.4 * Copyright (C) 2010 University of Bonn. All rights reserved. 5 5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. 6 6 */ … … 22 22 * \li \ref atom 23 23 * \li \ref bondgraph 24 * \li \ref filling25 24 * \li \ref descriptors 26 25 * \li \ref fragmentation … … 42 41 * 43 42 * 44 * \date 2012-01- 1643 * \date 2012-01-05 45 44 * 46 45 */ -
src/molecule.cpp
r510f81 r22425a 44 44 #include "LinkedCell/linkedcell.hpp" 45 45 #include "IdPool_impl.hpp" 46 #include "Shapes/BaseShapes.hpp"47 46 #include "Tesselation/tesselation.hpp" 48 47 #include "World.hpp" … … 166 165 /************************** Access to the List of Atoms ****************/ 167 166 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 168 197 molecule::const_iterator molecule::erase( const_iterator loc ) 169 198 { … … 193 222 } 194 223 224 molecule::const_iterator molecule::find ( atom * key ) const 225 { 226 return const_iterator(atomIds.find(key->getId()), FromIdToAtom()); 227 } 228 195 229 pair<molecule::iterator,bool> molecule::insert ( atom * const key ) 196 230 { 197 231 OBSERVE; 198 std::pair<iterator,bool> res = atomIds.insert(key->getId());232 pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId()); 199 233 if (res.second) { // push atom if went well 200 234 key->setNr(atomIdPool.getNextId()); 201 235 setAtomName(key); 202 236 formula+=key->getType(); 203 return res;237 return pair<iterator,bool>(iterator(res.first, FromIdToAtom()),res.second); 204 238 } else { 205 239 return pair<iterator,bool>(end(),res.second); … … 222 256 { 223 257 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) 224 264 for (molecule::iterator iter = begin(); iter != end(); ++iter) 225 265 vector_of_atoms.push_back(*iter); … … 549 589 550 590 /** Creates a copy of this molecule. 551 * \param offset translation Vector for the new molecule relative to old one552 591 * \return copy of molecule 553 592 */ 554 molecule *molecule::CopyMolecule( const Vector &offset) const593 molecule *molecule::CopyMolecule() const 555 594 { 556 595 molecule *copy = World::getInstance().createMolecule(); … … 560 599 for (iterator iter = begin(); iter != end(); ++iter) { 561 600 atom * const copy_atom = copy->AddCopyAtom(*iter); 562 copy_atom->setPosition(copy_atom->getPosition() + offset);563 601 FatherFinder.insert( std::make_pair( *iter, copy_atom ) ); 564 602 } … … 813 851 "molecule::isInMolecule() - atom is not designated to be in molecule '" 814 852 +toString(this->getName())+"'."); 815 molecule:: const_iterator iter = atomIds.find(_atom->getId());853 molecule::atomIdSet::const_iterator iter = atomIds.find(_atom->getId()); 816 854 return (iter != atomIds.end()); 817 855 } … … 1025 1063 } 1026 1064 1027 Shape molecule::getBoundingShape() const1028 {1029 // get center and radius1030 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 boundary1045 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 1055 1065 // construct idpool 1056 1066 CONSTRUCT_IDPOOL(atomId_t, continuousId) 1057 -
src/molecule.hpp
r510f81 r22425a 21 21 #include <vector> 22 22 23 #include <boost/iterator/transform_iterator.hpp> 24 23 25 #include <string> 24 26 25 #include "AtomIdSet.hpp"26 27 #include "Atom/AtomSet.hpp" 27 28 #include "CodePatterns/Cacheable.hpp" 28 29 #include "CodePatterns/Observer/Observable.hpp" 30 #include "CodePatterns/Observer/ObservedIterator.hpp" 29 31 #include "Descriptors/AtomIdDescriptor.hpp" 30 32 #include "Fragmentation/HydrogenSaturation_enum.hpp" … … 33 35 #include "IdPool_policy.hpp" 34 36 #include "IdPool.hpp" 35 #include "Shapes/Shape.hpp"36 37 #include "types.hpp" 38 39 // TODO: Was is the include of MoleculeDescriptor_impl.hpp doing in molecule.hpp 40 #include "Descriptors/MoleculeDescriptor_impl.hpp" 37 41 38 42 /****************************************** forward declarations *****************************/ … … 50 54 class MoleculeLeafClass; 51 55 class MoleculeListClass; 52 class MoleculeUnittest;56 class periodentafel; 53 57 class RealSpaceMatrix; 54 58 class 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 }; 55 70 56 71 /************************************* Class definitions ****************************************/ … … 61 76 class molecule : public Observable 62 77 { 63 //!> grant unit test access64 friend class MoleculeUnittest;65 //!> function may access cstor66 78 friend molecule *NewMolecule(); 67 //!> function may access dstor68 79 friend void DeleteMolecule(molecule *); 69 80 70 81 public: 71 typedef AtomIdSet::atomIdSetatomIdSet;72 typedef AtomIdSet::iteratoriterator;73 typedef AtomIdSet::const_iteratorconst_iterator;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; 74 85 75 86 int MDSteps; //!< The number of MD steps in Trajectories … … 86 97 Cacheable<int> BondCount; //!< number of atoms, brought up-to-date by doCountBonds() 87 98 moleculeId_t id; 88 AtomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms99 atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms 89 100 IdPool<atomId_t, uniqueId> atomIdPool; //!< pool of internal ids such that way may guarantee uniqueness 90 101 … … 114 125 World::AtomComposite getAtomSet() const; 115 126 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 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); 155 135 bool containsAtom(atom* key); 156 136 … … 165 145 */ 166 146 const_iterator erase(const_iterator loc); 167 168 147 /** Erase an atom from the list. 169 148 * \note This should only be called by atom::removeFromMolecule(), … … 198 177 199 178 public: 200 201 /** Function to create a bounding spherical shape for the currently associated atoms.202 *203 */204 Shape getBoundingShape() const;205 179 206 180 /// remove atoms from molecule. … … 255 229 bond * CopyBond(atom *left, atom *right, bond *CopyBond); 256 230 257 molecule *CopyMolecule( const Vector &offset = zeroVec) const;231 molecule *CopyMolecule() const; 258 232 molecule* CopyMoleculeFromSubRegion(const Shape&) const; 259 233 -
src/unittests/Makefile.am
r510f81 r22425a 12 12 include ../../src/Descriptors/unittests/Makefile.am 13 13 include ../../src/Element/unittests/Makefile.am 14 include ../../src/Filling/unittests/Makefile.am15 14 include ../../src/Fragmentation/unittests/Makefile.am 16 15 include ../../src/Graph/unittests/Makefile.am … … 29 28 30 29 GENERALTESTS = \ 31 AtomIdSetUnitTest \32 30 BoxUnitTest \ 33 31 Box_BoundaryConditionsTest \ 34 32 FormulaUnittest \ 35 33 ListOfBondsUnitTest \ 36 MoleculeUnitTest \37 34 WorldTimeUnitTest 38 35 … … 62 59 63 60 ALLLIBS = \ 64 ../libMolecuilderFilling.la \65 61 ../libMolecuilderUI.la \ 66 62 ../libMolecuilder.la \ … … 74 70 ${DESCRIPTORTESTSSOURCES} \ 75 71 ${ELEMENTTESTSSOURCES} \ 76 ${FILLINGTESTSSOURCES} \77 72 ${FRAGMENTATIONTESTSSOURCES} \ 78 73 ${GRAPHTESTSSOURCES} \ … … 86 81 ${UIELEMENTSMENUTESTSSOURCES} \ 87 82 stubs/ObserverStub.cpp \ 88 AtomIdSetUnitTest.cpp \89 83 BoxUnitTest.cpp \ 90 84 Box_BoundaryConditionsUnitTest.cpp \ 91 85 FormulaUnitTest.cpp \ 92 86 ListOfBondsUnitTest.cpp \ 93 MoleculeUnitTest.cpp \94 87 WorldTimeUnitTest.cpp 95 88 … … 99 92 ${DESCRIPTORTESTSHEADERS} \ 100 93 ${ELEMENTTESTSHEADERS} \ 101 ${FILLINGTESTSHEADERS} \102 94 ${FRAGMENTATIONTESTSHEADERS} \ 103 95 ${GRAPHTESTSHEADERS} \ … … 111 103 ${UIELEMENTSMENUTESTSHEADERS} \ 112 104 stubs/ObserverStub.hpp \ 113 AtomIdSetUnitTest.hpp \114 105 BoxUnitTest.hpp \ 115 106 Box_BoundaryConditionsUnitTest.hpp \ 116 107 FormulaUnitTest.hpp \ 117 108 ListOfBondsUnitTest.hpp \ 118 MoleculeUnitTest.hpp \119 109 WorldTimeUnitTest.hpp 120 110 … … 124 114 BoxUnitTest.hpp \ 125 115 stubs/ObserverStub.cpp \ 126 stubs/ObserverStub.hpp \ 127 ../Shapes/unittests/stubs/ApproximateShapeAreaStub.cpp \ 128 ../Shapes/unittests/stubs/ApproximateShapeVolumeStub.cpp 116 stubs/ObserverStub.hpp 129 117 BoxUnitTest_LDADD = \ 130 118 ../libMolecuilder.la \ … … 132 120 ../libMolecuilderHelpers.la \ 133 121 $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la 134 135 AtomIdSetUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \136 AtomIdSetUnitTest.cpp \137 AtomIdSetUnitTest.hpp138 AtomIdSetUnitTest_LDADD = $(ALLLIBS)139 122 140 123 Box_BoundaryConditionsTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ … … 157 140 ListOfBondsUnitTest_LDADD = $(ALLLIBS) 158 141 159 MoleculeUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \160 MoleculeUnitTest.cpp \161 MoleculeUnitTest.hpp162 MoleculeUnitTest_LDADD = \163 ../libMolecuilderUI.la \164 ../libMolecuilder.la \165 $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la166 167 142 WorldTimeUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 168 143 WorldTimeUnitTest.cpp \ -
tests/CodeChecks/Makefile.am
r510f81 r22425a 1 1 AUTOM4TE = 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) 12 TESTSUITE = $(srcdir)/testsuite 2 13 3 TESTSUITE = $(srcdir)/testsuite 14 DISTCLEANFILES = atconfig 4 15 5 16 TESTSCRIPTS = \ … … 7 18 testsuite-date_in_dox.at \ 8 19 testsuite-globallistofactions_hpp.at \ 9 testsuite-header-dist.at \10 20 testsuite-memdebug.at \ 11 21 testsuite-project-disclaimer.at 12 13 DISTCLEANFILES = atconfig14 15 EXTRA_DIST = \16 atlocal.in \17 package.m4 \18 testsuite.at \19 $(TESTSUITE) \20 $(TESTSCRIPTS)21 22 22 23 max_jobs = 4 -
tests/CodeChecks/testsuite.at
r510f81 r22425a 23 23 m4_include(testsuite-project-disclaimer.at) 24 24 25 m4_include(testsuite-header-dist.at) -
tests/Python/AllActions/options.dat
r510f81 r22425a 74 74 MaxDistance "-1" 75 75 MDSteps "1" 76 mesh-offset "0.5,0.5,0.5"77 mesh-size "10,10,10"78 min-distance "1."79 76 molecule-by-id "0" 80 77 nonconvex-envelope "25" … … 170 167 start-step "0" 171 168 suspend-in-water "1.0" 172 tesselation-radius "5."173 169 time-step-zero "0" 174 170 translate-atoms "1. 0. 0." -
tests/regression/Makefile.am
r510f81 r22425a 155 155 $(srcdir)/Selection/Atoms/AtomsInsideCuboid/testsuite-selection-unselect-atoms-inside-cuboid.at \ 156 156 $(srcdir)/Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-sphere.at \ 157 $(srcdir)/Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-tiny-sphere.at \158 157 $(srcdir)/Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-sphere.at \ 159 $(srcdir)/Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-tiny-sphere.at \160 158 $(srcdir)/Selection/Atoms/ClearAtoms/testsuite-selection-clear-atoms.at \ 161 159 $(srcdir)/Selection/Molecules/testsuite-selection-molecules.at \ -
tests/regression/Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-sphere.at
r510f81 r22425a 14 14 AT_SKIP_IF([! cat >/dev/null < /dev/null]) # check whether cat is there 15 15 AT_SKIP_IF([! wc -l /dev/null]) # check whether wc is there 16 AT_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])17 AT_CHECK([fgrep "50 5" stdout], 0, [ignore], [ignore])18 AT_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])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]) 19 19 AT_CHECK([fgrep "0" stdout], 0, [ignore], [ignore]) 20 20 -
tests/regression/Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-sphere.at
r510f81 r22425a 15 15 AT_SKIP_IF([! cat >/dev/null < /dev/null]) # check whether awk is there 16 16 AT_SKIP_IF([! wc -l /dev/null]) # check whether wc is there 17 AT_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])18 AT_CHECK([fgrep " 0" stdout], 0, [ignore], [ignore])19 AT_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])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]) 20 20 AT_CHECK([fgrep "524" stdout], 0, [ignore], [ignore]) 21 21 -
tests/regression/Selection/Atoms/testsuite-selection-atoms.at
r510f81 r22425a 26 26 # (un)select atoms inside sphere 27 27 m4_include(Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-sphere.at) 28 m4_include(Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-tiny-sphere.at)29 28 m4_include(Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-sphere.at) 30 m4_include(Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-tiny-sphere.at)31 29 32 30 # clear atom selection
Note:
See TracChangeset
for help on using the changeset viewer.