Changes in / [22425a:510f81]
- Files:
-
- 94 added
- 4 deleted
- 60 edited
Legend:
- Unmodified
- Added
- Removed
-
LinearAlgebra/src/LinearAlgebra/Line.cpp
r22425a r510f81 31 31 #include "defs.hpp" 32 32 #include "Exceptions.hpp" 33 #include "LinePoint.hpp" 33 34 #include "MatrixContent.hpp" 34 35 #include "Plane.hpp" … … 308 309 } 309 310 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) 311 std::ostream& operator<<(std::ostream& ost, const Line& m) 356 312 { 357 313 const Vector origin = m.getOrigin(); … … 373 329 }; 374 330 331 332 /******************************** Points on the line ********************/ -
LinearAlgebra/src/LinearAlgebra/Line.hpp
r22425a r510f81 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 LineSegment 32 */ 27 33 class Line : public Space 28 34 { … … 74 80 Line makeLineThrough(const Vector &x1, const Vector &x2); 75 81 76 /**77 * Class for representing points on a line78 * These objects allow comparison of points on the same line as well as specifying the79 * 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 109 82 #endif /* LINE_HPP_ */ -
LinearAlgebra/src/LinearAlgebra/LineSegment.cpp
r22425a r510f81 24 24 25 25 #include "Line.hpp" 26 #include "LinePoint.hpp" 26 27 #include "Vector.hpp" 27 28 -
LinearAlgebra/src/LinearAlgebra/LineSegment.hpp
r22425a r510f81 21 21 class LinePoint; 22 22 23 /** This class represents a specific segment of a line, defined through 24 * two points on the same line that form start and end. 25 * 26 */ 23 27 class LineSegment 24 28 { -
LinearAlgebra/src/LinearAlgebra/LineSegmentSet.cpp
r22425a r510f81 24 24 #include "CodePatterns/Assert.hpp" 25 25 #include "Line.hpp" 26 #include "LinePoint.hpp" 26 27 #include "LineSegment.hpp" 27 28 -
LinearAlgebra/src/LinearAlgebra/LineSegmentSet.hpp
r22425a r510f81 22 22 class LineSegment; 23 23 24 /** This class represents a continous set of LineSegment's all on the same 25 * underlying line. 26 * 27 * Hence, it is basically a sorted container for LinePoints but 28 * we iterate over it segment-wise. 29 * 30 */ 24 31 class LineSegmentSet { 25 32 friend LineSegmentSet merge(const LineSegmentSet&,const LineSegmentSet&); -
LinearAlgebra/src/LinearAlgebra/Makefile.am
r22425a r510f81 11 11 leastsquaremin.cpp \ 12 12 Line.cpp \ 13 LinePoint.cpp \ 13 14 LineSegment.cpp \ 14 15 LineSegmentSet.cpp \ … … 31 32 leastsquaremin.hpp \ 32 33 Line.hpp \ 34 LinePoint.hpp \ 33 35 LineSegment.hpp \ 34 36 LineSegmentSet.hpp \ -
LinearAlgebra/src/LinearAlgebra/defs.hpp
r22425a r510f81 23 23 double LINALG_MYEPSILON() 24 24 { 25 return (std::numeric_limits<double>::epsilon()*1 00.);25 return (std::numeric_limits<double>::epsilon()*1.e+4); 26 26 } 27 27 -
LinearAlgebra/src/documentation/mainpage.dox
r22425a r510f81 25 25 * 26 26 * 27 * \ref lines Lines and subtypes 28 * 27 29 * \date 2011-11-02 28 30 * -
LinearAlgebra/tests/CodeChecks/Makefile.am
r22425a r510f81 1 1 AUTOM4TE = autom4te 2 3 TESTSUITE = $(srcdir)/testsuite 4 5 TESTSCRIPTS = \ 6 testsuite-config_h.at \ 7 testsuite-date_in_dox.at \ 8 testsuite-header-dist.at \ 9 testsuite-memdebug.at \ 10 testsuite-project-disclaimer.at 11 12 DISTCLEANFILES = atconfig 13 2 14 EXTRA_DIST = \ 3 15 atlocal.in \ 4 16 package.m4 \ 5 17 testsuite.at \ 6 testsuite-config_h.at \ 7 testsuite-date_in_dox.at \ 8 testsuite-memdebug.at \ 9 testsuite-project-disclaimer.at \ 10 $(TESTSUITE) 11 TESTSUITE = $(srcdir)/testsuite 12 13 DISTCLEANFILES = atconfig 14 15 TESTSCRIPTS = \ 16 testsuite-config_h.at \ 17 testsuite-date_in_dox.at \ 18 testsuite-memdebug.at \ 19 testsuite-project-disclaimer.at 18 $(TESTSUITE) \ 19 $(TESTSCRIPTS) 20 20 21 21 max_jobs = 4 -
LinearAlgebra/tests/CodeChecks/testsuite.at
r22425a r510f81 21 21 m4_include(testsuite-project-disclaimer.at) 22 22 23 m4_include(testsuite-header-dist.at) -
src/Actions/GlobalListOfActions.hpp
r22425a r510f81 105 105 (SelectionNotAllAtomsInsideCuboid) \ 106 106 (SelectionAtomById) \ 107 (FragmentationFragmentation) 107 (FragmentationFragmentation) \ 108 (FillRegularGrid) 108 109 109 110 #endif /* GLOBALLISTOFACTIONS_HPP_ */ -
src/Actions/Makefile.am
r22425a r510f81 52 52 ${ATOMACTIONSOURCE} \ 53 53 ${CMDACTIONSOURCE} \ 54 ${FILLACTIONSOURCE} \ 54 55 ${FRAGMENTATIONACTIONSOURCE} \ 55 56 ${GRAPHACTIONSOURCE} \ … … 67 68 ${ATOMACTIONHEADER} \ 68 69 ${CMDACTIONHEADER} \ 70 ${FILLACTIONHEADER} \ 69 71 ${FRAGMENTATIONACTIONHEADER} \ 70 72 ${GRAPHACTIONHEADER} \ … … 82 84 ${ATOMACTIONDEFS} \ 83 85 ${CMDACTIONDEFS} \ 86 ${FILLACTIONDEFS} \ 84 87 ${FRAGMENTATIONACTIONDEFS} \ 85 88 ${GRAPHACTIONDEFS} \ … … 173 176 Actions/CommandAction/VersionAction.def \ 174 177 Actions/CommandAction/WarrantyAction.def 178 179 FILLACTIONSOURCE = \ 180 Actions/FillAction/FillRegularGridAction.cpp 181 FILLACTIONHEADER = \ 182 Actions/FillAction/FillRegularGridAction.hpp 183 FILLACTIONDEFS = \ 184 Actions/FillAction/FillRegularGridAction.def 185 175 186 176 187 FRAGMENTATIONACTIONSOURCE = \ -
src/Actions/SelectionAction/Atoms/AllAtomsInsideCuboidAction.cpp
r22425a r510f81 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 ByShape(s));57 World::getInstance().selectAllAtoms(Atom ByShape(s));56 std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && AtomsByShape(s)); 57 World::getInstance().selectAllAtoms(AtomsByShape(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 ByShape(state->s));65 World::getInstance().unselectAllAtoms(AtomsByShape(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 ByShape(state->s));76 World::getInstance().selectAllAtoms(AtomsByShape(state->s)); 77 77 78 78 return Action::state_ptr(_state); -
src/Actions/SelectionAction/Atoms/AllAtomsInsideSphereAction.cpp
r22425a r510f81 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 ByShape(s));52 World::getInstance().selectAllAtoms(Atom ByShape(s));51 std::vector<atom *> selectedAtoms = World::getInstance().getAllAtoms(AtomsBySelection() && AtomsByShape(s)); 52 World::getInstance().selectAllAtoms(AtomsByShape(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 ByShape(state->s));60 World::getInstance().unselectAllAtoms(AtomsByShape(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 ByShape(state->s));70 World::getInstance().selectAllAtoms(AtomsByShape(state->s)); 71 71 72 72 return Action::state_ptr(_state); -
src/Actions/SelectionAction/Atoms/NotAllAtomsInsideCuboidAction.cpp
r22425a r510f81 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 ByShape(s));56 World::getInstance().unselectAllAtoms(Atom ByShape(s));55 std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && AtomsByShape(s)); 56 World::getInstance().unselectAllAtoms(AtomsByShape(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 ByShape(state->s));64 World::getInstance().selectAllAtoms(AtomsByShape(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 ByShape(state->s));75 World::getInstance().unselectAllAtoms(AtomsByShape(state->s)); 76 76 77 77 return Action::state_ptr(_state); -
src/Actions/SelectionAction/Atoms/NotAllAtomsInsideSphereAction.cpp
r22425a r510f81 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 ByShape(s));52 World::getInstance().unselectAllAtoms(Atom ByShape(s));51 std::vector<atom *> unselectedAtoms = World::getInstance().getAllAtoms((!AtomsBySelection()) && AtomsByShape(s)); 52 World::getInstance().unselectAllAtoms(AtomsByShape(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 ByShape(state->s));60 World::getInstance().selectAllAtoms(AtomsByShape(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 ByShape(state->s));70 World::getInstance().unselectAllAtoms(AtomsByShape(state->s)); 71 71 72 72 return Action::state_ptr(_state); -
src/Atom/Makefile.am
r22425a r510f81 29 29 Atom/TesselPoint.hpp 30 30 31 COPYATOMSSOURCE = \ 32 Atom/CopyAtoms/CopyAtoms_SaturateDanglingBonds.cpp \ 33 Atom/CopyAtoms/CopyAtoms_withBonds.cpp 34 35 COPYATOMSHEADER = \ 36 Atom/CopyAtoms/CopyAtoms_SaturateDanglingBonds.hpp \ 37 Atom/CopyAtoms/CopyAtoms_Simple.hpp \ 38 Atom/CopyAtoms/CopyAtoms_withBonds.hpp \ 39 Atom/CopyAtoms/CopyAtomsInterface.hpp 31 40 32 41 noinst_LTLIBRARIES += libMolecuilderAtom.la 33 42 libMolecuilderAtom_la_includedir = $(includedir)/MoleCuilder/Atom/ 34 43 35 nobase_libMolecuilderAtom_la_include_HEADERS = $ {ATOMHEADER}44 nobase_libMolecuilderAtom_la_include_HEADERS = $(ATOMHEADER) $(COPYATOMSHEADER) 36 45 37 46 ## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la" … … 43 52 ## from each source file. Note that it is not necessary to list header files 44 53 ## which are already listed elsewhere in a _HEADERS variable assignment. 45 libMolecuilderAtom_la_SOURCES = $ {ATOMSOURCE}54 libMolecuilderAtom_la_SOURCES = $(ATOMSOURCE) $(COPYATOMSSOURCE) 46 55 47 56 ## Instruct libtool to include ABI version information in the generated shared -
src/Atom/unittests/Makefile.am
r22425a r510f81 4 4 ATOMTESTSSOURCES = \ 5 5 ../Atom/unittests/AtomObserverUnitTest.cpp \ 6 ../Atom/unittests/CopyAtomsInterfaceUnitTest.cpp \ 6 7 stubs/ObserverStub.cpp 7 8 8 9 ATOMTESTSHEADERS = \ 9 10 ../Atom/unittests/AtomObserverUnitTest.hpp \ 11 ../Atom/unittests/CopyAtomsInterfaceUnitTest.hpp \ 10 12 stubs/ObserverStub.hpp 11 13 12 14 ATOMTESTS = \ 13 AtomObserverUnitTest 15 AtomObserverUnitTest \ 16 CopyAtomsInterfaceUnitTest 14 17 15 18 TESTS += $(ATOMTESTS) … … 35 38 AtomObserverUnitTest_LDADD = ${ATOMTESTLIBS} 36 39 40 CopyAtomsInterfaceUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 41 ../Atom/unittests/CopyAtomsInterfaceUnitTest.cpp \ 42 ../Atom/unittests/CopyAtomsInterfaceUnitTest.hpp 43 CopyAtomsInterfaceUnitTest_LDADD = ${ATOMTESTLIBS} 37 44 38 45 -
src/Descriptors/AtomShapeDescriptor.cpp
r22425a r510f81 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 } 37 47 38 AtomDescriptor AtomByShape(const Shape &shape){ 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){ 39 62 return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomShapeDescriptor_impl(shape))); 40 63 } -
src/Descriptors/AtomShapeDescriptor.hpp
r22425a r510f81 20 20 class Shape; 21 21 22 AtomDescriptor Atom ByShape(const Shape &shape);22 AtomDescriptor AtomsByShape(const Shape &shape); 23 23 24 24 #endif /* ATOMSHAPEDESCRIPTOR_HPP_ */ -
src/Descriptors/AtomShapeDescriptor_impl.hpp
r22425a r510f81 27 27 bool predicate(std::pair<atomId_t,atom*> atom); 28 28 private: 29 virtual atom* find(); 30 virtual std::vector<atom*> findAll(); 31 29 32 Shape shape; 30 33 }; -
src/Fragmentation/Fragmentation.cpp
r22425a r510f81 27 27 #include "Atom/atom.hpp" 28 28 #include "Bond/bond.hpp" 29 #include "Descriptors/MoleculeDescriptor.hpp" 29 30 #include "Element/element.hpp" 30 31 #include "Element/periodentafel.hpp" -
src/Graph/DepthFirstSearchAnalysis.cpp
r22425a r510f81 32 32 #include "CodePatterns/Verbose.hpp" 33 33 #include "Descriptors/AtomDescriptor.hpp" 34 #include "Descriptors/MoleculeDescriptor.hpp" 34 35 #include "molecule.hpp" 35 36 #include "MoleculeLeafClass.hpp" -
src/IdPool_impl.hpp
r22425a r510f81 96 96 return; 97 97 } 98 LOG( 1, "STATUS: Defragmenting id pool.");98 LOG(3, "DEBUG: 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
r22425a r510f81 20 20 LinkedCell/LinkedCell_Model.hpp \ 21 21 LinkedCell/LinkedCell_Model_changeModel.hpp \ 22 LinkedCell/LinkedCell_Model_inline.hpp \ 22 23 LinkedCell/LinkedCell_Model_LinkedCellArrayCache.hpp \ 23 24 LinkedCell/LinkedCell_Model_Update.hpp \ -
src/LinkedCell/unittests/Makefile.am
r22425a r510f81 53 53 ../LinkedCell/unittests/LinkedCell_ControllerUnitTest.hpp \ 54 54 ../LinkedCell/unittests/defs.hpp \ 55 ../LinkedCell/unittests/stubs/AtomStub.cpp \55 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 \60 59 ../LinkedCell/unittests/stubs/WorldTimeStub.cpp \ 60 stubs/WorldStub.cpp \ 61 61 ../LinkedCell/PointCloudAdaptor.hpp \ 62 62 ../Box_BoundaryConditions.cpp \ -
src/Makefile.am
r22425a r510f81 13 13 include Atom/Makefile.am 14 14 include Element/Makefile.am 15 include Filling/Makefile.am 15 16 include Fragmentation/Makefile.am 16 17 include Graph/Makefile.am … … 124 125 125 126 TESSELATIONSOURCE = \ 127 Tesselation/ApproximateShapeArea.cpp \ 128 Tesselation/ApproximateShapeVolume.cpp \ 126 129 Tesselation/boundary.cpp \ 127 130 Tesselation/BoundaryLineSet.cpp \ … … 136 139 137 140 TESSELATIONHEADER = \ 141 Tesselation/ApproximateShapeArea.hpp \ 142 Tesselation/ApproximateShapeVolume.hpp \ 138 143 Tesselation/boundary.hpp \ 139 144 Tesselation/BoundaryLineSet.hpp \ … … 154 159 ${THERMOSTATSOURCE} \ 155 160 ${TESSELATIONSOURCE} \ 161 AtomIdSet.cpp \ 156 162 Box.cpp \ 157 163 Box_BoundaryConditions.cpp \ … … 175 181 ${THERMOSTATHEADER} \ 176 182 ${TESSELATIONHEADER} \ 183 AtomIdSet.hpp \ 177 184 Box.hpp \ 178 185 Box_BoundaryConditions.hpp \ -
src/Shapes/BaseShapes.cpp
r22425a r510f81 37 37 #include <algorithm> 38 38 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){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) const throw(NotOnSurfaceException){ 48 48 if(!isOnSurface(point)){ 49 49 throw NotOnSurfaceException() << ShapeVector(&point); … … 52 52 } 53 53 54 LineSegmentSet Sphere_impl::getLineIntersections(const Line &line){ 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{ 55 76 LineSegmentSet res(line); 56 77 std::vector<Vector> intersections = line.getSphereIntersections(); … … 61 82 } 62 83 63 std::string Sphere_impl::toString() {84 std::string Sphere_impl::toString() const{ 64 85 return "Sphere()"; 86 } 87 88 enum ShapeType Sphere_impl::getType() const 89 { 90 return SphereType; 65 91 } 66 92 … … 115 141 } 116 142 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 } 117 148 118 149 Shape Sphere(){ … … 129 160 } 130 161 131 bool Cuboid_impl::isInside(const Vector &point) {162 bool Cuboid_impl::isInside(const Vector &point) const{ 132 163 return (point[0]>=0 && point[0]<=1) && (point[1]>=0 && point[1]<=1) && (point[2]>=0 && point[2]<=1); 133 164 } 134 165 135 bool Cuboid_impl::isOnSurface(const Vector &point) {166 bool Cuboid_impl::isOnSurface(const Vector &point) const{ 136 167 bool retVal = isInside(point); 137 168 // test all borders of the cuboid … … 144 175 } 145 176 146 Vector Cuboid_impl::getNormal(const Vector &point) throw(NotOnSurfaceException){177 Vector Cuboid_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException){ 147 178 if(!isOnSurface(point)){ 148 179 throw NotOnSurfaceException() << ShapeVector(&point); … … 162 193 } 163 194 164 LineSegmentSet Cuboid_impl::getLineIntersections(const Line &line){ 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{ 165 217 LineSegmentSet res(line); 166 218 // get the intersection on each of the six faces … … 192 244 } 193 245 194 std::string Cuboid_impl::toString() {246 std::string Cuboid_impl::toString() const{ 195 247 return "Cuboid()"; 248 } 249 250 enum ShapeType Cuboid_impl::getType() const 251 { 252 return CuboidType; 196 253 } 197 254 … … 203 260 ASSERT(false, "Cuboid_impl::getHomogeneousPointsOnSurface() not implemented yet"); 204 261 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>(); 205 268 } 206 269 -
src/Shapes/BaseShapes_impl.hpp
r22425a r510f81 20 20 #include "Shapes/Shape_impl.hpp" 21 21 #include "Shapes/ShapeExceptions.hpp" 22 #include "Shapes/ShapeType.hpp" 22 23 23 24 class Sphere_impl : public Shape_impl { 24 virtual bool isInside(const Vector &point); 25 virtual bool isOnSurface(const Vector &point); 26 virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException); 27 virtual LineSegmentSet getLineIntersections(const Line&); 28 virtual std::string toString(); 25 virtual bool isInside(const Vector &point) const; 26 virtual bool isOnSurface(const Vector &point) const; 27 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException); 28 virtual Vector getCenter() const; 29 virtual double getRadius() const; 30 virtual double getVolume() const; 31 virtual double getSurfaceArea() const; 32 virtual LineSegmentSet getLineIntersections(const Line&) const; 33 virtual std::string toString() const; 34 virtual enum ShapeType getType() const; 29 35 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 36 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 30 37 }; 31 38 32 39 class Cuboid_impl : public Shape_impl { 33 virtual bool isInside(const Vector &point); 34 virtual bool isOnSurface(const Vector &point); 35 virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException); 36 virtual LineSegmentSet getLineIntersections(const Line&); 37 virtual std::string toString(); 40 virtual bool isInside(const Vector &point) const; 41 virtual bool isOnSurface(const Vector &point) const; 42 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException); 43 virtual Vector getCenter() const; 44 virtual double getRadius() const; 45 virtual double getVolume() const; 46 virtual double getSurfaceArea() const; 47 virtual LineSegmentSet getLineIntersections(const Line&) const; 48 virtual std::string toString() const; 49 virtual enum ShapeType getType() const; 38 50 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 51 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 39 52 }; 40 53 -
src/Shapes/Makefile.am
r22425a r510f81 13 13 Shapes/ShapeExceptions.hpp \ 14 14 Shapes/ShapeOps.hpp \ 15 Shapes/ShapeOps_impl.hpp 15 Shapes/ShapeOps_impl.hpp \ 16 Shapes/ShapeType.hpp 16 17 17 18 18 19 19 noinst_LTLIBRARIES += libMolecuilderShapes.la -
src/Shapes/Shape.cpp
r22425a r510f81 26 26 #include "Shapes/Shape_impl.hpp" 27 27 #include "Shapes/ShapeExceptions.hpp" 28 28 #include "Shapes/ShapeType.hpp" 29 30 #include "Tesselation/ApproximateShapeArea.hpp" 31 #include "Tesselation/ApproximateShapeVolume.hpp" 32 33 #include <algorithm> 34 #include <limits> 29 35 #include <string> 30 36 … … 48 54 } 49 55 50 LineSegmentSet Shape::getLineIntersections(const Line &line){ 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{ 51 105 return impl->getLineIntersections(line); 52 106 } … … 54 108 std::vector<Vector> Shape::getHomogeneousPointsOnSurface(const size_t N) const { 55 109 return impl->getHomogeneousPointsOnSurface(N); 110 } 111 112 std::vector<Vector> Shape::getHomogeneousPointsInVolume(const size_t N) const { 113 return impl->getHomogeneousPointsInVolume(N); 56 114 } 57 115 … … 67 125 } 68 126 127 bool Shape::operator==(const Shape &rhs) const{ 128 return (this->getType() == rhs.getType()); 129 } 130 69 131 std::string Shape::toString() const{ 70 132 return impl->toString(); 133 } 134 135 enum ShapeType Shape::getType() const{ 136 return impl->getType(); 71 137 } 72 138 … … 102 168 AndShape_impl::~AndShape_impl(){} 103 169 104 bool AndShape_impl::isInside(const Vector &point) {170 bool AndShape_impl::isInside(const Vector &point) const{ 105 171 return lhs->isInside(point) && rhs->isInside(point); 106 172 } 107 173 108 bool AndShape_impl::isOnSurface(const Vector &point) {174 bool AndShape_impl::isOnSurface(const Vector &point) const{ 109 175 // check the number of surfaces that this point is on 110 176 int surfaces =0; … … 138 204 } 139 205 140 Vector AndShape_impl::getNormal(const Vector &point) throw (NotOnSurfaceException){206 Vector AndShape_impl::getNormal(const Vector &point) const throw (NotOnSurfaceException){ 141 207 Vector res; 142 208 if(!isOnSurface(point)){ … … 149 215 } 150 216 151 LineSegmentSet AndShape_impl::getLineIntersections(const Line &line){ 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{ 152 250 return intersect(lhs->getLineIntersections(line),rhs->getLineIntersections(line)); 153 251 } 154 252 155 std::string AndShape_impl::toString() {253 std::string AndShape_impl::toString() const{ 156 254 return std::string("(") + lhs->toString() + std::string("&&") + rhs->toString() + std::string(")"); 255 } 256 257 enum ShapeType AndShape_impl::getType() const{ 258 return CombinedType; 157 259 } 158 260 … … 174 276 } 175 277 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 176 284 177 285 Shape operator&&(const Shape &lhs,const Shape &rhs){ … … 188 296 OrShape_impl::~OrShape_impl(){} 189 297 190 bool OrShape_impl::isInside(const Vector &point) {298 bool OrShape_impl::isInside(const Vector &point) const{ 191 299 return rhs->isInside(point) || lhs->isInside(point); 192 300 } 193 301 194 bool OrShape_impl::isOnSurface(const Vector &point) {302 bool OrShape_impl::isOnSurface(const Vector &point) const{ 195 303 // check the number of surfaces that this point is on 196 304 int surfaces =0; … … 224 332 } 225 333 226 Vector OrShape_impl::getNormal(const Vector &point) throw (NotOnSurfaceException){334 Vector OrShape_impl::getNormal(const Vector &point) const throw (NotOnSurfaceException){ 227 335 Vector res; 228 336 if(!isOnSurface(point)){ … … 235 343 } 236 344 237 LineSegmentSet OrShape_impl::getLineIntersections(const Line &line){ 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{ 238 374 return merge(lhs->getLineIntersections(line),rhs->getLineIntersections(line)); 239 375 } 240 376 241 std::string OrShape_impl::toString() {377 std::string OrShape_impl::toString() const{ 242 378 return std::string("(") + lhs->toString() + std::string("||") + rhs->toString() + std::string(")"); 379 } 380 381 enum ShapeType OrShape_impl::getType() const{ 382 return CombinedType; 243 383 } 244 384 … … 260 400 } 261 401 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 262 408 Shape operator||(const Shape &lhs,const Shape &rhs){ 263 409 Shape::impl_ptr newImpl = Shape::impl_ptr(new OrShape_impl(getShapeImpl(lhs),getShapeImpl(rhs))); … … 273 419 NotShape_impl::~NotShape_impl(){} 274 420 275 bool NotShape_impl::isInside(const Vector &point) {421 bool NotShape_impl::isInside(const Vector &point) const{ 276 422 return !arg->isInside(point); 277 423 } 278 424 279 bool NotShape_impl::isOnSurface(const Vector &point) {425 bool NotShape_impl::isOnSurface(const Vector &point) const{ 280 426 return arg->isOnSurface(point); 281 427 } 282 428 283 Vector NotShape_impl::getNormal(const Vector &point) throw(NotOnSurfaceException){429 Vector NotShape_impl::getNormal(const Vector &point) const throw(NotOnSurfaceException){ 284 430 return -1.*arg->getNormal(point); 285 431 } 286 432 287 LineSegmentSet NotShape_impl::getLineIntersections(const Line &line){ 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{ 288 456 return invert(arg->getLineIntersections(line)); 289 457 } 290 458 291 std::string NotShape_impl::toString() {459 std::string NotShape_impl::toString() const{ 292 460 return std::string("!") + arg->toString(); 461 } 462 463 enum ShapeType NotShape_impl::getType() const{ 464 return CombinedType; 293 465 } 294 466 … … 296 468 // surfaces are the same, only normal direction is different 297 469 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>(); 298 476 } 299 477 -
src/Shapes/Shape.hpp
r22425a r510f81 19 19 20 20 #include "Shapes/ShapeExceptions.hpp" 21 #include "Shapes/ShapeType.hpp" 21 22 22 23 #include <vector> … … 41 42 Vector getNormal(const Vector &point) const throw(NotOnSurfaceException); 42 43 43 LineSegmentSet getLineIntersections(const Line&); 44 Vector getCenter() const; 45 double getRadius() const; 46 double getVolume() const; 47 double getSurfaceArea() const; 48 49 LineSegmentSet getLineIntersections(const Line&) const; 44 50 std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 51 std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 45 52 46 53 Shape &operator=(const Shape& rhs); 47 54 55 bool operator==(const Shape &rhs) const; 56 48 57 std::string toString() const; 58 enum ShapeType getType() const; 59 49 60 protected: 50 61 impl_ptr getImpl() const; -
src/Shapes/ShapeOps.cpp
r22425a r510f81 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include <algorithm> 23 #include <boost/bind.hpp> 24 22 25 #include "Shapes/ShapeExceptions.hpp" 23 26 #include "Shapes/ShapeOps.hpp" … … 34 37 ShapeOpsBase_impl::~ShapeOpsBase_impl(){} 35 38 36 bool ShapeOpsBase_impl::isInside(const Vector &point) {39 bool ShapeOpsBase_impl::isInside(const Vector &point) const{ 37 40 return arg->isInside(translateIn(point)); 38 41 } 39 42 40 bool ShapeOpsBase_impl::isOnSurface(const Vector &point) {43 bool ShapeOpsBase_impl::isOnSurface(const Vector &point) const{ 41 44 return arg->isOnSurface(translateIn(point)); 42 45 } 43 46 44 Vector ShapeOpsBase_impl::getNormal(const Vector &point) throw (NotOnSurfaceException){47 Vector ShapeOpsBase_impl::getNormal(const Vector &point) const throw (NotOnSurfaceException){ 45 48 Vector helper = translateIn(point); 46 49 if(!arg->isOnSurface(helper)){ … … 52 55 } 53 56 54 LineSegmentSet ShapeOpsBase_impl::getLineIntersections(const Line &line){ 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{ 55 69 Line newLine(translateIn(line.getOrigin()),translateIn(line.getDirection())); 56 70 LineSegmentSet res(line); … … 71 85 } 72 86 87 enum ShapeType ShapeOpsBase_impl::getType() const { 88 return getArg()->getType(); 89 } 90 73 91 std::vector<Vector> ShapeOpsBase_impl::getHomogeneousPointsOnSurface(const size_t N) const { 74 return getArg()->getHomogeneousPointsOnSurface(N);; 92 return getArg()->getHomogeneousPointsOnSurface(N); 93 } 94 95 std::vector<Vector> ShapeOpsBase_impl::getHomogeneousPointsInVolume(const size_t N) const { 96 return getArg()->getHomogeneousPointsInVolume(N); 75 97 } 76 98 … … 89 111 Resize_impl::~Resize_impl(){} 90 112 91 bool Resize_impl::isInside(const Vector& point){ 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{ 92 125 return getArg()->isInside((1/size) * point); 93 126 } 94 127 95 Vector Resize_impl::translateIn(const Vector& point) {128 Vector Resize_impl::translateIn(const Vector& point) const{ 96 129 return (1/size) * point; 97 130 } 98 131 99 Vector Resize_impl::translateOutPos(const Vector& point) {132 Vector Resize_impl::translateOutPos(const Vector& point) const{ 100 133 return size * point; 101 134 } 102 135 103 Vector Resize_impl::translateOutNormal(const Vector& point) {136 Vector Resize_impl::translateOutNormal(const Vector& point) const{ 104 137 return point; 105 138 } 106 139 107 std::string Resize_impl::toString() {140 std::string Resize_impl::toString() const{ 108 141 std::stringstream sstr; 109 142 sstr << "resize(" << getArg()->toString() << "," << size << ")"; … … 113 146 std::vector<Vector> Resize_impl::getHomogeneousPointsOnSurface(const size_t N) const { 114 147 std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N); 115 for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) { 116 *iter *= size; 117 } 118 return PointsOnSurface; 148 std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(), 149 boost::bind(&Vector::operator*, _1, size) ); 150 return PointsOnSurface; 151 } 152 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>(); 119 158 } 120 159 … … 133 172 Translate_impl::~Translate_impl(){} 134 173 135 bool Translate_impl::isInside(const Vector& point) {174 bool Translate_impl::isInside(const Vector& point) const{ 136 175 return getArg()->isInside(point-offset); 137 176 } 138 177 139 Vector Translate_impl::translateIn(const Vector& point){ 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{ 140 199 return point-offset; 141 200 } 142 201 143 Vector Translate_impl::translateOutPos(const Vector& point) {202 Vector Translate_impl::translateOutPos(const Vector& point) const{ 144 203 return point+offset; 145 204 } 146 205 147 Vector Translate_impl::translateOutNormal(const Vector& point) {206 Vector Translate_impl::translateOutNormal(const Vector& point) const{ 148 207 return point; 149 208 } 150 209 151 std::string Translate_impl::toString() {210 std::string Translate_impl::toString() const{ 152 211 std::stringstream sstr; 153 212 sstr << "translate(" << getArg()->toString() << "," << offset << ")"; … … 157 216 std::vector<Vector> Translate_impl::getHomogeneousPointsOnSurface(const size_t N) const { 158 217 std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N); 159 for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) { 160 *iter += offset; 161 } 218 std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(), 219 boost::bind(&Vector::operator+, _1, offset) ); 220 return PointsOnSurface; 221 } 222 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) ); 162 227 return PointsOnSurface; 163 228 } … … 173 238 ShapeOpsBase_impl(_arg),factors(_factors) 174 239 { 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");178 240 for(int i = NDIM;i--;){ 179 reciFactors[i] = 1/factors[i]; 241 ASSERT(factors[i]>0.,"cannot stretch a shape by a negative amount"); 242 reciFactors[i] = 1./factors[i]; 180 243 } 181 244 } … … 183 246 Stretch_impl::~Stretch_impl(){} 184 247 185 bool Stretch_impl::isInside(const Vector& point){ 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{ 186 261 Vector helper=point; 187 262 helper.ScaleAll(reciFactors); … … 189 264 } 190 265 191 Vector Stretch_impl::translateIn(const Vector& point) {266 Vector Stretch_impl::translateIn(const Vector& point) const{ 192 267 Vector helper=point; 193 268 helper.ScaleAll(reciFactors); … … 195 270 } 196 271 197 Vector Stretch_impl::translateOutPos(const Vector& point) {272 Vector Stretch_impl::translateOutPos(const Vector& point) const{ 198 273 Vector helper=point; 199 274 helper.ScaleAll(factors); … … 201 276 } 202 277 203 Vector Stretch_impl::translateOutNormal(const Vector& point) {278 Vector Stretch_impl::translateOutNormal(const Vector& point) const{ 204 279 Vector helper=point; 205 280 // the normalFactors are derived from appearances of the factors … … 213 288 } 214 289 215 std::string Stretch_impl::toString() {290 std::string Stretch_impl::toString() const{ 216 291 std::stringstream sstr; 217 292 sstr << "stretch(" << getArg()->toString() << "," << factors << ")"; … … 221 296 std::vector<Vector> Stretch_impl::getHomogeneousPointsOnSurface(const size_t N) const { 222 297 std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N); 223 for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) { 224 (*iter).ScaleAll(reciFactors); 225 } 298 std::for_each(PointsOnSurface.begin(), PointsOnSurface.end(), 299 boost::bind( static_cast<void (Vector::*)(const Vector&)>(&Vector::ScaleAll), _1, reciFactors) ); 300 return PointsOnSurface; 301 } 302 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) ); 226 307 return PointsOnSurface; 227 308 } … … 242 323 Transform_impl::~Transform_impl(){} 243 324 244 bool Transform_impl::isInside(const Vector& point){ 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{ 245 336 return getArg()->isInside(transformationInv * point); 246 337 } 247 338 248 Vector Transform_impl::translateIn(const Vector& point) {339 Vector Transform_impl::translateIn(const Vector& point) const{ 249 340 return transformationInv * point; 250 341 } 251 342 252 Vector Transform_impl::translateOutPos(const Vector& point) {343 Vector Transform_impl::translateOutPos(const Vector& point) const{ 253 344 return transformation * point; 254 345 } 255 346 256 Vector Transform_impl::translateOutNormal(const Vector& point){ 347 Vector Transform_impl::translateOutNormal(const Vector& point) const 348 { 257 349 RealSpaceMatrix mat = transformation.invert().transpose(); 258 350 return mat * point; 259 351 } 260 352 261 std::string Transform_impl::toString() {353 std::string Transform_impl::toString() const{ 262 354 std::stringstream sstr; 263 355 sstr << "transform(" << getArg()->toString() << "," << transformation << ")"; … … 267 359 std::vector<Vector> Transform_impl::getHomogeneousPointsOnSurface(const size_t N) const { 268 360 std::vector<Vector> PointsOnSurface = getArg()->getHomogeneousPointsOnSurface(N); 269 for(std::vector<Vector>::iterator iter = PointsOnSurface.begin(); iter != PointsOnSurface.end(); ++iter) { 270 *iter = transformation * (*iter); 271 } 361 std::transform( PointsOnSurface.begin(), PointsOnSurface.end(), PointsOnSurface.begin(), 362 boost::bind(static_cast<Vector(*)(const RealSpaceMatrix&,const Vector&)>(operator*), transformation, _1)); 363 return PointsOnSurface; 364 } 365 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)); 272 370 return PointsOnSurface; 273 371 } -
src/Shapes/ShapeOps_impl.hpp
r22425a r510f81 17 17 #include "Shapes/Shape_impl.hpp" 18 18 #include "Shapes/ShapeExceptions.hpp" 19 #include "Shapes/ShapeType.hpp" 19 20 #include "LinearAlgebra/Vector.hpp" 20 21 #include "LinearAlgebra/RealSpaceMatrix.hpp" … … 28 29 ShapeOpsBase_impl(const Shape::impl_ptr&); 29 30 virtual ~ShapeOpsBase_impl(); 30 virtual bool isInside(const Vector &point); 31 virtual bool isOnSurface(const Vector &point); 32 virtual Vector getNormal(const Vector &point) throw (NotOnSurfaceException); 33 virtual LineSegmentSet getLineIntersections(const Line&); 31 virtual bool isInside(const Vector &point) const; 32 virtual bool isOnSurface(const Vector &point) const; 33 virtual Vector getNormal(const Vector &point) const throw (NotOnSurfaceException); 34 virtual Vector getCenter() const; 35 virtual double getRadius() const; 36 virtual LineSegmentSet getLineIntersections(const Line&) const; 37 virtual enum ShapeType getType() const; 34 38 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 39 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 35 40 protected: 36 virtual Vector translateIn(const Vector &point) =0;37 virtual Vector translateOutPos(const Vector &point) =0;38 virtual Vector translateOutNormal(const Vector &point) =0;41 virtual Vector translateIn(const Vector &point) const=0; 42 virtual Vector translateOutPos(const Vector &point) const=0; 43 virtual Vector translateOutNormal(const Vector &point) const=0; 39 44 Shape::impl_ptr getArg() const; 40 45 private: … … 48 53 virtual ~Resize_impl(); 49 54 protected: 50 virtual Vector translateIn(const Vector &point); 51 virtual Vector translateOutPos(const Vector &point); 52 virtual Vector translateOutNormal(const Vector &point); 53 virtual std::string toString(); 54 virtual bool isInside(const Vector& point); 55 virtual double getVolume() const; 56 virtual double getSurfaceArea() const; 57 virtual Vector translateIn(const Vector &point) const; 58 virtual Vector translateOutPos(const Vector &point) const; 59 virtual Vector translateOutNormal(const Vector &point) const; 60 virtual std::string toString() const; 61 virtual bool isInside(const Vector& point) const; 55 62 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 63 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 56 64 private: 57 65 double size; … … 64 72 virtual ~Translate_impl(); 65 73 protected: 66 virtual Vector translateIn(const Vector &point); 67 virtual Vector translateOutPos(const Vector &point); 68 virtual Vector translateOutNormal(const Vector &point); 69 virtual std::string toString(); 70 virtual bool isInside(const Vector& point); 74 virtual Vector getCenter() const; 75 virtual double getRadius() const; 76 virtual double getVolume() const; 77 virtual double getSurfaceArea() const; 78 virtual Vector translateIn(const Vector &point) const; 79 virtual Vector translateOutPos(const Vector &point) const; 80 virtual Vector translateOutNormal(const Vector &point) const; 81 virtual std::string toString() const; 82 virtual bool isInside(const Vector& point) const; 71 83 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 84 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 72 85 private: 73 86 Vector offset; … … 77 90 { 78 91 public: 79 Stretch_impl(const Shape::impl_ptr&, const Vector&); 92 93 94 Stretch_impl(const Shape::impl_ptr&, const Vector&); 80 95 virtual ~Stretch_impl(); 81 96 protected: 82 virtual Vector translateIn(const Vector &point); 83 virtual Vector translateOutPos(const Vector &point); 84 virtual Vector translateOutNormal(const Vector &point); 85 virtual std::string toString(); 86 virtual bool isInside(const Vector& point); 97 virtual double getVolume() const; 98 virtual double getSurfaceArea() const; 99 virtual Vector translateIn(const Vector &point) const; 100 virtual Vector translateOutPos(const Vector &point) const; 101 virtual Vector translateOutNormal(const Vector &point) const; 102 virtual std::string toString() const; 103 virtual bool isInside(const Vector& point) const; 87 104 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 105 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 88 106 private: 89 107 Vector factors; … … 97 115 virtual ~Transform_impl(); 98 116 protected: 99 virtual Vector translateIn(const Vector &point); 100 virtual Vector translateOutPos(const Vector &point); 101 virtual Vector translateOutNormal(const Vector &point); 102 virtual std::string toString(); 103 virtual bool isInside(const Vector& point); 117 virtual double getVolume() const; 118 virtual double getSurfaceArea() const; 119 virtual Vector translateIn(const Vector &point) const; 120 virtual Vector translateOutPos(const Vector &point) const; 121 virtual Vector translateOutNormal(const Vector &point) const; 122 virtual std::string toString() const; 123 virtual bool isInside(const Vector& point) const; 104 124 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 125 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 105 126 private: 106 127 RealSpaceMatrix transformation; -
src/Shapes/Shape_impl.hpp
r22425a r510f81 15 15 16 16 17 #include <limits> 17 18 #include <vector> 19 20 #include "CodePatterns/Assert.hpp" 18 21 19 22 #include "Shapes/Shape.hpp" 20 23 #include "Shapes/ShapeExceptions.hpp" 24 #include "Shapes/ShapeType.hpp" 21 25 #include "LinearAlgebra/Line.hpp" 26 #include "LinearAlgebra/LinePoint.hpp" 22 27 #include "LinearAlgebra/LineSegment.hpp" 23 28 #include "LinearAlgebra/LineSegmentSet.hpp" … … 29 34 Shape_impl(){}; 30 35 virtual ~Shape_impl(){}; 31 virtual bool isInside(const Vector &point)=0; 32 virtual bool isOnSurface(const Vector &point)=0; 33 virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException)=0; 34 virtual LineSegmentSet getLineIntersections(const Line&)=0; 35 virtual std::string toString()=0; 36 virtual bool isInside(const Vector &point) const=0; 37 virtual bool isOnSurface(const Vector &point) const=0; 38 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException)=0; 39 virtual Vector getCenter() const=0; 40 virtual double getRadius() const=0; 41 virtual double getVolume() const=0; 42 virtual double getSurfaceArea() const=0; 43 virtual LineSegmentSet getLineIntersections(const Line&) const=0; 44 virtual std::string toString() const =0; 45 virtual enum ShapeType getType() const =0; 36 46 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const=0; 47 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const=0; 37 48 }; 38 49 39 50 class Everywhere_impl : public Shape_impl { 40 51 public: 41 virtual bool isInside(const Vector &point) {52 virtual bool isInside(const Vector &point) const{ 42 53 return true; 43 54 } 44 virtual bool isOnSurface(const Vector &point) {55 virtual bool isOnSurface(const Vector &point) const{ 45 56 return false; 46 57 } 47 virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException){58 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException){ 48 59 throw NotOnSurfaceException() << ShapeVector(&point); 49 60 } 50 virtual LineSegmentSet getLineIntersections(const Line &line){ 61 virtual Vector getCenter() const { 62 return Vector(0.,0.,0.); 63 } 64 virtual double getRadius() const { 65 return std::numeric_limits<double>::infinity(); 66 } 67 virtual double getVolume() const 68 { 69 // TODO 70 return 0.; 71 } 72 virtual double getSurfaceArea() const 73 { 74 // TODO 75 return 0.; 76 } 77 virtual LineSegmentSet getLineIntersections(const Line &line) const{ 51 78 LineSegmentSet res(line); 52 79 res.insert(LineSegment(line.negEndpoint(),line.posEndpoint())); 53 80 return res; 54 81 } 55 virtual std::string toString() {82 virtual std::string toString() const{ 56 83 return "Everywhere()"; 84 } 85 virtual enum ShapeType getType() const { 86 return EverywhereType; 57 87 } 58 88 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const { … … 60 90 return PointsOnSurface; 61 91 } 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 } 62 97 }; 63 98 64 99 class Nowhere_impl : public Shape_impl { 65 virtual bool isInside(const Vector &point) {100 virtual bool isInside(const Vector &point) const{ 66 101 return false; 67 102 } 68 virtual bool isOnSurface(const Vector &point) {103 virtual bool isOnSurface(const Vector &point) const{ 69 104 return false; 70 105 } 71 virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException){106 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException){ 72 107 throw NotOnSurfaceException() << ShapeVector(&point); 73 108 } 74 virtual LineSegmentSet getLineIntersections(const Line &line){ 109 virtual Vector getCenter() const { 110 return Vector(0.,0.,0.); 111 } 112 virtual double getRadius() const { 113 return 0.; 114 } 115 virtual double getVolume() const 116 { 117 return 0.; 118 } 119 virtual double getSurfaceArea() const 120 { 121 return 0.; 122 } 123 virtual LineSegmentSet getLineIntersections(const Line &line) const{ 75 124 return LineSegmentSet(line); 76 125 } 77 virtual std::string toString() {126 virtual std::string toString() const{ 78 127 return "Nowhere()"; 128 } 129 virtual enum ShapeType getType() const { 130 return NowhereType; 79 131 } 80 132 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const { … … 82 134 return PointsOnSurface; 83 135 } 136 std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const { 137 return std::vector<Vector>(); 138 } 84 139 }; 85 140 … … 88 143 AndShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&); 89 144 virtual ~AndShape_impl(); 90 virtual bool isInside(const Vector &point); 91 virtual bool isOnSurface(const Vector &point); 92 virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException); 93 virtual LineSegmentSet getLineIntersections(const Line&); 94 virtual std::string toString(); 145 virtual bool isInside(const Vector &point) const; 146 virtual bool isOnSurface(const Vector &point) const; 147 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException); 148 virtual Vector getCenter() const; 149 virtual double getRadius() const; 150 virtual double getVolume() const; 151 virtual double getSurfaceArea() const; 152 virtual LineSegmentSet getLineIntersections(const Line&) const; 153 virtual std::string toString() const; 154 virtual enum ShapeType getType() const; 95 155 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 156 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 96 157 private: 97 158 Shape::impl_ptr lhs; … … 103 164 OrShape_impl(const Shape::impl_ptr&, const Shape::impl_ptr&); 104 165 virtual ~OrShape_impl(); 105 virtual bool isInside(const Vector &point); 106 virtual bool isOnSurface(const Vector &point); 107 virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException); 108 virtual LineSegmentSet getLineIntersections(const Line&); 109 virtual std::string toString(); 166 virtual bool isInside(const Vector &point) const; 167 virtual bool isOnSurface(const Vector &point) const; 168 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException); 169 virtual Vector getCenter() const; 170 virtual double getRadius() const; 171 virtual double getVolume() const; 172 virtual double getSurfaceArea() const; 173 virtual LineSegmentSet getLineIntersections(const Line&) const; 174 virtual std::string toString() const; 175 virtual enum ShapeType getType() const; 110 176 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 177 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 111 178 private: 112 179 Shape::impl_ptr lhs; … … 118 185 NotShape_impl(const Shape::impl_ptr&); 119 186 virtual ~NotShape_impl(); 120 virtual bool isInside(const Vector &point); 121 virtual bool isOnSurface(const Vector &point); 122 virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException); 123 virtual LineSegmentSet getLineIntersections(const Line&); 124 virtual std::string toString(); 187 virtual bool isInside(const Vector &point) const; 188 virtual bool isOnSurface(const Vector &point) const; 189 virtual Vector getNormal(const Vector &point) const throw(NotOnSurfaceException); 190 virtual Vector getCenter() const; 191 virtual double getRadius() const; 192 virtual double getVolume() const; 193 virtual double getSurfaceArea() const; 194 virtual LineSegmentSet getLineIntersections(const Line&) const; 195 virtual std::string toString() const; 196 virtual enum ShapeType getType() const; 125 197 virtual std::vector<Vector> getHomogeneousPointsOnSurface(const size_t N) const; 198 virtual std::vector<Vector> getHomogeneousPointsInVolume(const size_t N) const; 126 199 private: 127 200 Shape::impl_ptr arg; -
src/Shapes/unittests/Makefile.am
r22425a r510f81 4 4 5 5 SHAPETESTSSOURCES = \ 6 ../Shapes/unittests/ShapeUnitTest.cpp 6 ../Shapes/unittests/BaseShapesUnitTest.cpp \ 7 ../Shapes/unittests/ShapeOpsUnitTest.cpp \ 8 ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.cpp 7 9 8 10 SHAPETESTSHEADERS= \ 9 ../Shapes/unittests/ShapeUnitTest.hpp 11 ../Shapes/unittests/BaseShapesUnitTest.hpp \ 12 ../Shapes/unittests/ShapeOpsUnitTest.hpp \ 13 ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.cpp 10 14 11 15 SHAPETESTS = \ 12 ShapeUnittest 16 BaseShapesUnitTest \ 17 ShapeOpsUnitTest \ 18 Shape_HomogeneousPointsUnitTest 13 19 14 20 TESTS += $(SHAPETESTS) … … 22 28 # $(BOOST_LIB) 23 29 24 ShapeUnittest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 25 ../Shapes/unittests/ShapeUnitTest.cpp \ 26 ../Shapes/unittests/ShapeUnitTest.hpp 27 nodist_ShapeUnittest_SOURCES = \ 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 = \ 28 36 ../Helpers/defs.hpp \ 29 37 ../Helpers/defs.cpp 30 ShapeUnittest_LDADD = $(SHAPELIBS) 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) 31 57 32 58 -
src/Tesselation/BoundaryTriangleSet.cpp
r22425a r510f81 230 230 Vector Direction; 231 231 232 // 1. get intersection with plane 232 // 1. get intersection with plane and place in ClosestPoint 233 233 LOG(1, "INFO: Looking for closest point of triangle " << *this << " to " << x << "."); 234 GetCenter(Direction); 234 LOG(1, "INFO: endpoints are " << endpoints[0]->node->getPosition() << "," 235 << endpoints[1]->node->getPosition() << ", and " << endpoints[2]->node->getPosition() << "."); 235 236 try { 236 Line l = makeLineThrough(x, Direction); 237 ClosestPoint = Plane(NormalVector, (endpoints[0]->node->getPosition())).GetIntersection(l); 237 ClosestPoint = Plane(NormalVector, (endpoints[0]->node->getPosition())).getClosestPoint(x); 238 238 } 239 239 catch (LinearAlgebraException &excp) { 240 240 (ClosestPoint) = (x); 241 241 } 242 Vector InPlane(ClosestPoint); // points from plane intersection to straight-down point 242 243 243 244 // 2. Calculate in plane part of line (x, intersection) 244 Vector InPlane = (x) - (ClosestPoint); // points from plane intersection to straight-down point 245 InPlane.ProjectOntoPlane(NormalVector); 246 InPlane += ClosestPoint; 247 248 LOG(2, "INFO: Triangle is " << *this << "."); 249 LOG(2, "INFO: Line is from " << Direction << " to " << x << "."); 250 LOG(2, "INFO: In-plane part is " << InPlane << "."); 245 LOG(2, "INFO: Closest point on triangle plane is " << ClosestPoint << "."); 251 246 252 247 // Calculate cross point between one baseline and the desired point such that distance is shortest 253 double ShortestDistance = -1.;254 bool InsideFlag = false;255 248 Vector CrossDirection[3]; 256 249 Vector CrossPoint[3]; 257 Vector helper;258 250 for (int i = 0; i < 3; i++) { 259 // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point 260 Direction = (endpoints[(i+1)%3]->node->getPosition()) - (endpoints[i%3]->node->getPosition()); 251 const Vector Direction = (endpoints[i%3]->node->getPosition()) - (endpoints[(i+1)%3]->node->getPosition()); 261 252 // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal); 262 253 Line l = makeLineThrough((endpoints[i%3]->node->getPosition()), (endpoints[(i+1)%3]->node->getPosition())); 263 CrossPoint[i] = Plane(Direction, InPlane).GetIntersection(l); 264 CrossDirection[i] = CrossPoint[i] - InPlane; 265 CrossPoint[i] -= (endpoints[i%3]->node->getPosition()); // cross point was returned as absolute vector 254 CrossPoint[i] = l.getClosestPoint(InPlane); 255 // NOTE: direction of line is normalized, hence s must not necessarily be in [0,1] for the baseline 256 LOG(2, "INFO: Closest point on line from " << (endpoints[(i+1)%3]->node->getPosition()) 257 << " to " << (endpoints[i%3]->node->getPosition()) << " is " << CrossPoint[i] << "."); 258 CrossPoint[i] -= (endpoints[(i+1)%3]->node->getPosition()); // cross point was returned as absolute vector 266 259 const double s = CrossPoint[i].ScalarProduct(Direction)/Direction.NormSquared(); 267 260 LOG(2, "INFO: Factor s is " << s << "."); 268 261 if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) { 269 CrossPoint[i] += (endpoints[i%3]->node->getPosition()); // make cross point absolute again 270 LOG(2, "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << endpoints[i % 3]->node->getPosition() << " and " << endpoints[(i + 1) % 3]->node->getPosition() << "."); 271 const double distance = CrossPoint[i].DistanceSquared(x); 272 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) { 273 ShortestDistance = distance; 274 (ClosestPoint) = CrossPoint[i]; 275 } 276 } else 277 CrossPoint[i].Zero(); 278 } 279 InsideFlag = true; 262 CrossPoint[i] += (endpoints[(i+1)%3]->node->getPosition()); // make cross point absolute again 263 LOG(2, "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " 264 << endpoints[i % 3]->node->getPosition() << " and " 265 << endpoints[(i + 1) % 3]->node->getPosition() << "."); 266 } else { 267 // set to either endpoint of BoundaryLine 268 if (s < -MYEPSILON) 269 CrossPoint[i] = (endpoints[(i+1)%3]->node->getPosition()); 270 else 271 CrossPoint[i] = (endpoints[i%3]->node->getPosition()); 272 LOG(2, "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting outside of BoundaryLine between " 273 << endpoints[i % 3]->node->getPosition() << " and " 274 << endpoints[(i + 1) % 3]->node->getPosition() << "."); 275 } 276 CrossDirection[i] = CrossPoint[i] - InPlane; 277 } 278 279 bool InsideFlag = true; 280 double ShortestDistance = -1.; 280 281 for (int i = 0; i < 3; i++) { 281 282 const double sign = CrossDirection[i].ScalarProduct(CrossDirection[(i + 1) % 3]); … … 284 285 if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign 285 286 InsideFlag = false; 286 } 287 // update current best candidate 288 const double distance = CrossPoint[i].DistanceSquared(x); 289 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) { 290 ShortestDistance = distance; 291 (ClosestPoint) = CrossPoint[i]; 292 } 293 } 294 287 295 if (InsideFlag) { 288 296 (ClosestPoint) = InPlane; 289 297 ShortestDistance = InPlane.DistanceSquared(x); 290 } else { // also check endnodes 291 for (int i = 0; i < 3; i++) { 292 const double distance = x.DistanceSquared(endpoints[i]->node->getPosition()); 293 if ((ShortestDistance < 0.) || (ShortestDistance > distance)) { 294 ShortestDistance = distance; 295 (ClosestPoint) = (endpoints[i]->node->getPosition()); 296 } 297 } 298 } 298 } 299 299 300 LOG(1, "INFO: Closest Point is " << ClosestPoint << " with shortest squared distance is " << ShortestDistance << "."); 300 301 return ShortestDistance; … … 370 371 } 371 372 ; 373 374 /** Checks whether a given point is inside the plane of the triangle and inside the 375 * bounds defined by its BoundaryLineSet's. 376 * 377 * @param point point to check 378 * @return true - point is inside place and inside all BoundaryLine's 379 */ 380 bool BoundaryTriangleSet::IsInsideTriangle(const Vector &point) const 381 { 382 Info FunctionInfo(__func__); 383 384 // check if it's inside the plane 385 try { 386 Plane trianglePlane( 387 endpoints[0]->node->getPosition(), 388 endpoints[1]->node->getPosition(), 389 endpoints[2]->node->getPosition()); 390 if (!trianglePlane.isContained(point)) { 391 LOG(1, "INFO: Point " << point << " is not inside plane " << trianglePlane << " by " 392 << trianglePlane.distance(point) << "."); 393 return false; 394 } 395 } catch(LinearDependenceException) { 396 // triangle is degenerated, it's just a line (i.e. one endpoint is right in between two others 397 for (size_t i = 0; i < NDIM; ++i) { 398 try { 399 Line l = makeLineThrough( 400 lines[i]->endpoints[0]->node->getPosition(), 401 lines[i]->endpoints[1]->node->getPosition()); 402 if (l.isContained(GetThirdEndpoint(lines[i])->node->getPosition())) { 403 // we have the largest of the three lines 404 LOG(1, "INFO: Linear-dependent case where point " << point << " is on line " << l << "."); 405 return (l.isContained(point)); 406 } 407 } catch(ZeroVectorException) { 408 // two points actually coincide 409 try { 410 Line l = makeLineThrough( 411 lines[i]->endpoints[0]->node->getPosition(), 412 GetThirdEndpoint(lines[i])->node->getPosition()); 413 LOG(1, "INFO: Degenerated case where point " << point << " is on line " << l << "."); 414 return (l.isContained(point)); 415 } catch(ZeroVectorException) { 416 // all three points coincide 417 if (point.DistanceSquared(lines[i]->endpoints[0]->node->getPosition()) < MYEPSILON) { 418 LOG(1, "INFO: Full-Degenerated case where point " << point << " is on three endpoints " 419 << lines[i]->endpoints[0]->node->getPosition() << "."); 420 return true; 421 } 422 else return false; 423 } 424 } 425 } 426 } 427 428 // check whether it lies on the correct side as given by third endpoint for 429 // each BoundaryLine. 430 // NOTE: we assume here that endpoints are linear independent, as the case 431 // has been caught before already extensively 432 for (size_t i = 0; i < NDIM; ++i) { 433 Line l = makeLineThrough( 434 lines[i]->endpoints[0]->node->getPosition(), 435 lines[i]->endpoints[1]->node->getPosition()); 436 Vector onLine( l.getClosestPoint(point) ); 437 LOG(1, "INFO: Closest point on boundary line is " << onLine << "."); 438 Vector inTriangleDirection( GetThirdEndpoint(lines[i])->node->getPosition() - onLine ); 439 Vector inPointDirection(point - onLine); 440 if ((inTriangleDirection.NormSquared() > MYEPSILON) && (inPointDirection.NormSquared() > MYEPSILON)) 441 if (inTriangleDirection.ScalarProduct(inPointDirection) < -MYEPSILON) 442 return false; 443 } 444 445 return true; 446 } 447 372 448 373 449 /** Returns the endpoint which is not contained in the given \a *line. -
src/Tesselation/BoundaryTriangleSet.hpp
r22425a r510f81 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; 44 45 45 46 Plane getPlane() const; -
src/Tesselation/boundary.cpp
r22425a r510f81 1029 1029 for (int i=0;i<NDIM;i++) { 1030 1030 phi[i] = (random()/(rng_max-rng_min))*(2.*M_PI); 1031 std::cout << "Random angle is " << phi[i] << std::endl;1031 LOG(4, "DEBUG: Random angle is " << phi[i] << "."); 1032 1032 } 1033 1033 -
src/Tesselation/triangleintersectionlist.cpp
r22425a r510f81 197 197 if (!DistanceList.empty()) { 198 198 // get closest triangle(s) 199 std::pair< DistanceTriangleMap:: iterator, DistanceTriangleMap::iterator > DistanceRange =199 std::pair< DistanceTriangleMap::const_iterator, DistanceTriangleMap::const_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 } 201 208 // if there is more than one, check all of their normal vectors 202 // return the one with positive SKP if present 203 204 runner = IntersectionList.find(DistanceList.begin()->second); 209 // return the one with positive SKP if present because if the point 210 // would be truely inside, all of the closest triangles would have to show 211 // their inner side 212 LOG(1, "INFO: Looking for first SKP greater than zero ..."); 213 for (DistanceTriangleMap::const_iterator iter = DistanceRange.first; 214 iter != DistanceRange.second; ++iter) { 215 // find the entry by the triangle key in IntersectionList to get the Intersection point 216 runner = IntersectionList.find(iter->second); 217 Vector TestVector = (Point) - (*(*runner).second); 218 // construct SKP 219 const double sign = (*iter).second->NormalVector.ScalarProduct(TestVector); 220 LOG(1, "INFO: Checking SKP of closest triangle " << *(iter->second) << " = " << sign << "."); 221 // if positive return 222 if (sign > 0) 223 break; 224 } 225 // if there's just one or all are negative, runner is not set yet 226 if (runner == IntersectionList.end()) 227 runner = IntersectionList.find(DistanceList.begin()->second); 205 228 } 206 229 return runner; -
src/Tesselation/unittests/Makefile.am
r22425a r510f81 14 14 TESSELATIONTESTS = \ 15 15 TesselationUnitTest \ 16 Tesselation_BoundaryTriangleUnitTest 17 18 XFAIL_TESTS += Tesselation_InOutsideUnitTest 16 Tesselation_BoundaryTriangleUnitTest \ 17 Tesselation_InOutsideUnitTest 19 18 20 19 TESTS += $(TESSELATIONTESTS) -
src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp
r22425a r510f81 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" 32 35 #include "Tesselation/BoundaryPointSet.hpp" 33 36 #include "Tesselation/BoundaryLineSet.hpp" … … 49 52 50 53 51 void TesselationBoundaryTriangleTest:: setUp()52 { 53 setVerbosity(5);54 void TesselationBoundaryTriangleTest::createTriangle(const std::vector<Vector> &Vectors) 55 { 56 CPPUNIT_ASSERT_EQUAL( (size_t)3, Vectors.size() ); 54 57 55 58 // create nodes 56 tesselpoints[0] = new TesselPoint; 57 tesselpoints[0]->setPosition(Vector(0., 0., 0.)); 58 tesselpoints[0]->setName("1"); 59 tesselpoints[0]->setNr(1); 60 points[0] = new BoundaryPointSet(tesselpoints[0]); 61 tesselpoints[1] = new TesselPoint; 62 tesselpoints[1]->setPosition(Vector(0., 1., 0.)); 63 tesselpoints[1]->setName("2"); 64 tesselpoints[1]->setNr(2); 65 points[1] = new BoundaryPointSet(tesselpoints[1]); 66 tesselpoints[2] = new TesselPoint; 67 tesselpoints[2]->setPosition(Vector(1., 0., 0.)); 68 tesselpoints[2]->setName("3"); 69 tesselpoints[2]->setNr(3); 70 points[2] = new BoundaryPointSet(tesselpoints[2] ); 59 for (size_t count = 0; count < NDIM; ++count) { 60 tesselpoints[count] = new TesselPoint; 61 tesselpoints[count]->setPosition( Vectors[count] ); 62 tesselpoints[count]->setName(toString(count)); 63 tesselpoints[count]->setNr(count); 64 points[count] = new BoundaryPointSet(tesselpoints[count]); 65 } 71 66 72 67 // create line … … 77 72 // create triangle 78 73 triangle = new BoundaryTriangleSet(lines, 0); 79 triangle->GetNormalVector(Vector(0.,0.,1.)); 80 }; 81 74 Plane p(Vectors[0], Vectors[1], Vectors[2]); 75 triangle->GetNormalVector(p.getNormal()); 76 } 77 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 } 82 91 83 92 void TesselationBoundaryTriangleTest::tearDown() … … 90 99 logger::purgeInstance(); 91 100 errorLogger::purgeInstance(); 92 }; 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 } 93 310 94 311 /** UnitTest for Tesselation::IsInnerPoint() -
src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp
r22425a r510f81 19 19 #include <cppunit/extensions/HelperMacros.h> 20 20 21 #include <vector> 22 23 #include "LinearAlgebra/Vector.hpp" 21 24 #include "LinkedCell/linkedcell.hpp" 22 25 #include "Tesselation/tesselation.hpp" … … 29 32 { 30 33 CPPUNIT_TEST_SUITE( TesselationBoundaryTriangleTest) ; 34 CPPUNIT_TEST ( IsInsideTriangleTest ); 35 CPPUNIT_TEST ( IsInsideTriangle_specificTest ); 36 CPPUNIT_TEST ( GetClosestPointInsideTriangleTest ); 37 CPPUNIT_TEST ( GetClosestPointInsideTriangle_specificTest ); 31 38 CPPUNIT_TEST ( GetClosestPointOnPlaneTest ); 32 39 CPPUNIT_TEST ( GetClosestPointOffPlaneTest ); … … 36 43 void setUp(); 37 44 void tearDown(); 45 void IsInsideTriangleTest(); 46 void IsInsideTriangle_specificTest(); 47 void GetClosestPointInsideTriangleTest(); 48 void GetClosestPointInsideTriangle_specificTest(); 38 49 void GetClosestPointOnPlaneTest(); 39 50 void GetClosestPointOffPlaneTest(); 40 51 41 52 private: 53 void createTriangle(const std::vector<Vector> &Vectors); 54 42 55 static const double SPHERERADIUS; 43 56 -
src/UIElements/CommandLineUI/CommandLineParser.cpp
r22425a r510f81 51 51 atom("Atom options"), 52 52 command("Command options"), 53 fill("fill options"), 53 54 fragmentation("Fragmentation options"), 54 55 graph("Graph options"), … … 65 66 CmdParserLookup["command"] = &command; 66 67 CmdParserLookup["edit"] = &edit; 68 CmdParserLookup["fill"] = &fill; 67 69 CmdParserLookup["fragmentation"] = &fragmentation; 68 70 CmdParserLookup["graph"] = &graph; -
src/UIElements/CommandLineUI/CommandLineParser.hpp
r22425a r510f81 58 58 po::options_description command; 59 59 po::options_description edit; 60 po::options_description fill; 60 61 po::options_description fragmentation; 61 62 po::options_description graph; -
src/UIElements/Makefile.am
r22425a r510f81 263 263 libMolecuilderAnalysis.la \ 264 264 libMolecuilderGraph.la \ 265 libMolecuilderFilling.la \ 265 266 libMolecuilder.la \ 266 267 libMolecuilderFragmentation.la \ -
src/UIElements/Menu/MenuDescription.cpp
r22425a r510f81 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))); 51 52 MenuPositionMap->insert(std::make_pair("fragmentation",TopPosition("tools",3))); 52 53 MenuPositionMap->insert(std::make_pair("graph",TopPosition("tools",4))); … … 63 64 MenuDescriptionsMap->insert(std::make_pair("command","Configuration")); 64 65 MenuDescriptionsMap->insert(std::make_pair("edit","Edit")); 66 MenuDescriptionsMap->insert(std::make_pair("fill","Fill")); 65 67 MenuDescriptionsMap->insert(std::make_pair("fragmentation","Fragmentation")); 66 68 MenuDescriptionsMap->insert(std::make_pair("graph","Graph")); … … 77 79 MenuNameMap->insert(std::make_pair("command","Configuration")); 78 80 MenuNameMap->insert(std::make_pair("edit","Edit")); 81 MenuNameMap->insert(std::make_pair("fill","Fill")); 79 82 MenuNameMap->insert(std::make_pair("fragmentation","Fragmentation")); 80 83 MenuNameMap->insert(std::make_pair("graph","Graph")); -
src/documentation/constructs/atoms.dox
r22425a r510f81 56 56 * compatible implementation. 57 57 * 58 * \section atoms-copy Copying atoms 58 59 * 59 * \date 2011-10-31 60 * Copying atoms is a frequent action. That's why there are specific functors 61 * to get it done in more and more complex ways. The functors all inherit 62 * the \ref CopyAtomsInterface and the more complex ones build upon the 63 * functionality of the simpler ones: 64 * -# CopyAtomsInterface: Internally sets to the number of desired atoms. 65 * -# CopyAtoms_Simple: Fills the internal set with true copies. 66 * -# CopyAtoms_withBonds: Additionally also adds bonds in between the copies 67 * as they exist in between the original atoms. 68 * -# CopyAtoms_SaturateDanglingBonds: additionally checks for cut bond that 69 * would now become dangling bonds and inserts additional hydrogens for 70 * each cut bond such that the copied array of atoms is saturated. 71 * 72 * The CopyAtomsInterface is simple to use: 73 * \code 74 * std::vector<atom *> atoms_to_copy; 75 * CopyAtoms_Simple copyMethod; 76 * copyMethod(atoms_to_copy); 77 * std::vector<atom *> copiedAtoms = getCopiedAtoms(); 78 * \endcode 79 * 80 * 81 * \date 2012-03-30 82 * 60 83 */ -
src/documentation/constructs/constructs.dox
r22425a r510f81 2 2 * Project: MoleCuilder 3 3 * Description: creates and alters molecular systems 4 * Copyright (C) 201 0University of Bonn. All rights reserved.4 * Copyright (C) 2011-2012 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 filling 24 25 * \li \ref descriptors 25 26 * \li \ref fragmentation … … 41 42 * 42 43 * 43 * \date 2012-01- 0544 * \date 2012-01-16 44 45 * 45 46 */ -
src/molecule.cpp
r22425a r510f81 44 44 #include "LinkedCell/linkedcell.hpp" 45 45 #include "IdPool_impl.hpp" 46 #include "Shapes/BaseShapes.hpp" 46 47 #include "Tesselation/tesselation.hpp" 47 48 #include "World.hpp" … … 165 166 /************************** Access to the List of Atoms ****************/ 166 167 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() const185 {186 return (atomIds.empty());187 }188 189 size_t molecule::size() const190 {191 size_t counter = 0;192 for (const_iterator iter = begin(); iter != end (); ++iter)193 counter++;194 return counter;195 }196 197 168 molecule::const_iterator molecule::erase( const_iterator loc ) 198 169 { … … 222 193 } 223 194 224 molecule::const_iterator molecule::find ( atom * key ) const225 {226 return const_iterator(atomIds.find(key->getId()), FromIdToAtom());227 }228 229 195 pair<molecule::iterator,bool> molecule::insert ( atom * const key ) 230 196 { 231 197 OBSERVE; 232 pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId());198 std::pair<iterator,bool> res = atomIds.insert(key->getId()); 233 199 if (res.second) { // push atom if went well 234 200 key->setNr(atomIdPool.getNextId()); 235 201 setAtomName(key); 236 202 formula+=key->getType(); 237 return pair<iterator,bool>(iterator(res.first, FromIdToAtom()),res.second);203 return res; 238 204 } else { 239 205 return pair<iterator,bool>(end(),res.second); … … 256 222 { 257 223 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)264 224 for (molecule::iterator iter = begin(); iter != end(); ++iter) 265 225 vector_of_atoms.push_back(*iter); … … 589 549 590 550 /** Creates a copy of this molecule. 551 * \param offset translation Vector for the new molecule relative to old one 591 552 * \return copy of molecule 592 553 */ 593 molecule *molecule::CopyMolecule( ) const554 molecule *molecule::CopyMolecule(const Vector &offset) const 594 555 { 595 556 molecule *copy = World::getInstance().createMolecule(); … … 599 560 for (iterator iter = begin(); iter != end(); ++iter) { 600 561 atom * const copy_atom = copy->AddCopyAtom(*iter); 562 copy_atom->setPosition(copy_atom->getPosition() + offset); 601 563 FatherFinder.insert( std::make_pair( *iter, copy_atom ) ); 602 564 } … … 851 813 "molecule::isInMolecule() - atom is not designated to be in molecule '" 852 814 +toString(this->getName())+"'."); 853 molecule:: atomIdSet::const_iterator iter = atomIds.find(_atom->getId());815 molecule::const_iterator iter = atomIds.find(_atom->getId()); 854 816 return (iter != atomIds.end()); 855 817 } … … 1063 1025 } 1064 1026 1027 Shape molecule::getBoundingShape() const 1028 { 1029 // get center and radius 1030 Vector center; 1031 double radius = 0.; 1032 { 1033 center.Zero(); 1034 for(const_iterator iter = begin(); iter != end(); ++iter) 1035 center += (*iter)->getPosition(); 1036 center *= 1./(double)size(); 1037 for(const_iterator iter = begin(); iter != end(); ++iter) { 1038 const Vector &position = (*iter)->getPosition(); 1039 const double temp_distance = position.DistanceSquared(center); 1040 if (temp_distance > radius) 1041 radius = temp_distance; 1042 } 1043 } 1044 // convert radius to true value and add some small boundary 1045 radius = sqrt(radius) + 1e+6*std::numeric_limits<double>::epsilon(); 1046 LOG(1, "INFO: The " << size() << " atoms of the molecule are contained in a sphere at " 1047 << center << " with radius " << radius << "."); 1048 1049 Shape BoundingShape(Sphere(center, radius)); 1050 LOG(1, "INFO: Created sphere at " << BoundingShape.getCenter() << " and radius " 1051 << BoundingShape.getRadius() << "."); 1052 return BoundingShape; 1053 } 1054 1065 1055 // construct idpool 1066 1056 CONSTRUCT_IDPOOL(atomId_t, continuousId) 1057 -
src/molecule.hpp
r22425a r510f81 21 21 #include <vector> 22 22 23 #include <boost/iterator/transform_iterator.hpp>24 25 23 #include <string> 26 24 25 #include "AtomIdSet.hpp" 27 26 #include "Atom/AtomSet.hpp" 28 27 #include "CodePatterns/Cacheable.hpp" 29 28 #include "CodePatterns/Observer/Observable.hpp" 30 #include "CodePatterns/Observer/ObservedIterator.hpp"31 29 #include "Descriptors/AtomIdDescriptor.hpp" 32 30 #include "Fragmentation/HydrogenSaturation_enum.hpp" … … 35 33 #include "IdPool_policy.hpp" 36 34 #include "IdPool.hpp" 35 #include "Shapes/Shape.hpp" 37 36 #include "types.hpp" 38 39 // TODO: Was is the include of MoleculeDescriptor_impl.hpp doing in molecule.hpp40 #include "Descriptors/MoleculeDescriptor_impl.hpp"41 37 42 38 /****************************************** forward declarations *****************************/ … … 54 50 class MoleculeLeafClass; 55 51 class MoleculeListClass; 56 class periodentafel;52 class MoleculeUnittest; 57 53 class RealSpaceMatrix; 58 54 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 };70 55 71 56 /************************************* Class definitions ****************************************/ … … 76 61 class molecule : public Observable 77 62 { 63 //!> grant unit test access 64 friend class MoleculeUnittest; 65 //!> function may access cstor 78 66 friend molecule *NewMolecule(); 67 //!> function may access dstor 79 68 friend void DeleteMolecule(molecule *); 80 69 81 70 public: 82 typedef std::set<atomId_t>atomIdSet;83 typedef boost::transform_iterator<FromIdToAtom, atomIdSet::iterator, atom *, atomId_t>iterator;84 typedef boost::transform_iterator<FromIdToAtom, atomIdSet::const_iterator, const atom *, atomId_t const &>const_iterator;71 typedef AtomIdSet::atomIdSet atomIdSet; 72 typedef AtomIdSet::iterator iterator; 73 typedef AtomIdSet::const_iterator const_iterator; 85 74 86 75 int MDSteps; //!< The number of MD steps in Trajectories … … 97 86 Cacheable<int> BondCount; //!< number of atoms, brought up-to-date by doCountBonds() 98 87 moleculeId_t id; 99 atomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms88 AtomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms 100 89 IdPool<atomId_t, uniqueId> atomIdPool; //!< pool of internal ids such that way may guarantee uniqueness 101 90 … … 125 114 World::AtomComposite getAtomSet() const; 126 115 127 iterator begin(); 128 const_iterator begin() const; 129 iterator end(); 130 const_iterator end() const; 131 bool empty() const; 132 size_t size() const; 133 const_iterator find(atom * key) const; 134 pair<iterator, bool> insert(atom * const key); 116 // simply pass on all functions to AtomIdSet 117 iterator begin() { 118 return atomIds.begin(); 119 } 120 const_iterator begin() const 121 { 122 return atomIds.begin(); 123 } 124 iterator end() 125 { 126 return atomIds.end(); 127 } 128 const_iterator end() const 129 { 130 return atomIds.end(); 131 } 132 bool empty() const 133 { 134 return atomIds.empty(); 135 } 136 size_t size() const 137 { 138 return atomIds.size(); 139 } 140 const_iterator find(atom * key) const 141 { 142 return atomIds.find(key); 143 } 144 145 /** Returns the set of atomic ids contained in this molecule. 146 * 147 * @return set of atomic ids 148 */ 149 const atomIdSet & getAtomIds() const { 150 return atomIds.getAtomIds(); 151 } 152 153 std::pair<iterator, bool> insert(atom * const key); 154 135 155 bool containsAtom(atom* key); 136 156 … … 145 165 */ 146 166 const_iterator erase(const_iterator loc); 167 147 168 /** Erase an atom from the list. 148 169 * \note This should only be called by atom::removeFromMolecule(), … … 177 198 178 199 public: 200 201 /** Function to create a bounding spherical shape for the currently associated atoms. 202 * 203 */ 204 Shape getBoundingShape() const; 179 205 180 206 /// remove atoms from molecule. … … 229 255 bond * CopyBond(atom *left, atom *right, bond *CopyBond); 230 256 231 molecule *CopyMolecule( ) const;257 molecule *CopyMolecule(const Vector &offset = zeroVec) const; 232 258 molecule* CopyMoleculeFromSubRegion(const Shape&) const; 233 259 -
src/unittests/Makefile.am
r22425a r510f81 12 12 include ../../src/Descriptors/unittests/Makefile.am 13 13 include ../../src/Element/unittests/Makefile.am 14 include ../../src/Filling/unittests/Makefile.am 14 15 include ../../src/Fragmentation/unittests/Makefile.am 15 16 include ../../src/Graph/unittests/Makefile.am … … 28 29 29 30 GENERALTESTS = \ 31 AtomIdSetUnitTest \ 30 32 BoxUnitTest \ 31 33 Box_BoundaryConditionsTest \ 32 34 FormulaUnittest \ 33 35 ListOfBondsUnitTest \ 36 MoleculeUnitTest \ 34 37 WorldTimeUnitTest 35 38 … … 59 62 60 63 ALLLIBS = \ 64 ../libMolecuilderFilling.la \ 61 65 ../libMolecuilderUI.la \ 62 66 ../libMolecuilder.la \ … … 70 74 ${DESCRIPTORTESTSSOURCES} \ 71 75 ${ELEMENTTESTSSOURCES} \ 76 ${FILLINGTESTSSOURCES} \ 72 77 ${FRAGMENTATIONTESTSSOURCES} \ 73 78 ${GRAPHTESTSSOURCES} \ … … 81 86 ${UIELEMENTSMENUTESTSSOURCES} \ 82 87 stubs/ObserverStub.cpp \ 88 AtomIdSetUnitTest.cpp \ 83 89 BoxUnitTest.cpp \ 84 90 Box_BoundaryConditionsUnitTest.cpp \ 85 91 FormulaUnitTest.cpp \ 86 92 ListOfBondsUnitTest.cpp \ 93 MoleculeUnitTest.cpp \ 87 94 WorldTimeUnitTest.cpp 88 95 … … 92 99 ${DESCRIPTORTESTSHEADERS} \ 93 100 ${ELEMENTTESTSHEADERS} \ 101 ${FILLINGTESTSHEADERS} \ 94 102 ${FRAGMENTATIONTESTSHEADERS} \ 95 103 ${GRAPHTESTSHEADERS} \ … … 103 111 ${UIELEMENTSMENUTESTSHEADERS} \ 104 112 stubs/ObserverStub.hpp \ 113 AtomIdSetUnitTest.hpp \ 105 114 BoxUnitTest.hpp \ 106 115 Box_BoundaryConditionsUnitTest.hpp \ 107 116 FormulaUnitTest.hpp \ 108 117 ListOfBondsUnitTest.hpp \ 118 MoleculeUnitTest.hpp \ 109 119 WorldTimeUnitTest.hpp 110 120 … … 114 124 BoxUnitTest.hpp \ 115 125 stubs/ObserverStub.cpp \ 116 stubs/ObserverStub.hpp 126 stubs/ObserverStub.hpp \ 127 ../Shapes/unittests/stubs/ApproximateShapeAreaStub.cpp \ 128 ../Shapes/unittests/stubs/ApproximateShapeVolumeStub.cpp 117 129 BoxUnitTest_LDADD = \ 118 130 ../libMolecuilder.la \ … … 120 132 ../libMolecuilderHelpers.la \ 121 133 $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la 134 135 AtomIdSetUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 136 AtomIdSetUnitTest.cpp \ 137 AtomIdSetUnitTest.hpp 138 AtomIdSetUnitTest_LDADD = $(ALLLIBS) 122 139 123 140 Box_BoundaryConditionsTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ … … 140 157 ListOfBondsUnitTest_LDADD = $(ALLLIBS) 141 158 159 MoleculeUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 160 MoleculeUnitTest.cpp \ 161 MoleculeUnitTest.hpp 162 MoleculeUnitTest_LDADD = \ 163 ../libMolecuilderUI.la \ 164 ../libMolecuilder.la \ 165 $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la 166 142 167 WorldTimeUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 143 168 WorldTimeUnitTest.cpp \ -
tests/CodeChecks/Makefile.am
r22425a r510f81 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) 2 12 3 TESTSUITE = $(srcdir)/testsuite 13 14 DISTCLEANFILES = atconfig15 4 16 5 TESTSCRIPTS = \ … … 18 7 testsuite-date_in_dox.at \ 19 8 testsuite-globallistofactions_hpp.at \ 9 testsuite-header-dist.at \ 20 10 testsuite-memdebug.at \ 21 11 testsuite-project-disclaimer.at 12 13 DISTCLEANFILES = atconfig 14 15 EXTRA_DIST = \ 16 atlocal.in \ 17 package.m4 \ 18 testsuite.at \ 19 $(TESTSUITE) \ 20 $(TESTSCRIPTS) 22 21 23 22 max_jobs = 4 -
tests/CodeChecks/testsuite.at
r22425a r510f81 23 23 m4_include(testsuite-project-disclaimer.at) 24 24 25 m4_include(testsuite-header-dist.at) -
tests/Python/AllActions/options.dat
r22425a r510f81 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." 76 79 molecule-by-id "0" 77 80 nonconvex-envelope "25" … … 167 170 start-step "0" 168 171 suspend-in-water "1.0" 172 tesselation-radius "5." 169 173 time-step-zero "0" 170 174 translate-atoms "1. 0. 0." -
tests/regression/Makefile.am
r22425a r510f81 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 \ 157 158 $(srcdir)/Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-sphere.at \ 159 $(srcdir)/Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-tiny-sphere.at \ 158 160 $(srcdir)/Selection/Atoms/ClearAtoms/testsuite-selection-clear-atoms.at \ 159 161 $(srcdir)/Selection/Molecules/testsuite-selection-molecules.at \ -
tests/regression/Selection/Atoms/AtomsInsideSphere/testsuite-selection-select-atoms-inside-sphere.at
r22425a r510f81 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 (( $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 7" 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])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 "505" 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]) 19 19 AT_CHECK([fgrep "0" stdout], 0, [ignore], [ignore]) 20 20 -
tests/regression/Selection/Atoms/AtomsInsideSphere/testsuite-selection-unselect-atoms-inside-sphere.at
r22425a r510f81 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 (( $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])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]) 20 20 AT_CHECK([fgrep "524" stdout], 0, [ignore], [ignore]) 21 21 -
tests/regression/Selection/Atoms/testsuite-selection-atoms.at
r22425a r510f81 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) 28 29 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) 29 31 30 32 # clear atom selection
Note:
See TracChangeset
for help on using the changeset viewer.