Changeset c550dd for src


Ignore:
Timestamp:
Jul 1, 2010, 2:37:53 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
4b94bb
Parents:
205d9b
Message:

Removed the VectorIsInParallelepiped in favor of more general methods in the Shape class

Location:
src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    r205d9b rc550dd  
    1717#include "World.hpp"
    1818#include "molecule.hpp"
     19#include "Shapes/Shape.hpp"
    1920
    2021/************************************* Functions for class atom *************************************/
     
    112113 * \return true - is inside, false - is not
    113114 */
    114 bool atom::IsInParallelepiped(const Vector offset, const Matrix& parallelepiped) const
    115 {
    116   return (node->IsInParallelepiped(offset, parallelepiped));
     115bool atom::IsInShape(const Shape& shape) const
     116{
     117  return shape.isInside(*node);
    117118};
    118119
  • src/atom.hpp

    r205d9b rc550dd  
    3535class World;
    3636class molecule;
     37class Shape;
    3738
    3839/********************************************** declarations *******************************/
     
    6667  double DistanceToVector(const Vector &origin) const;
    6768  double DistanceSquaredToVector(const Vector &origin) const;
    68   bool IsInParallelepiped(const Vector offset, const Matrix &parallelepiped) const;
     69  bool IsInShape(const Shape&) const;
    6970
    7071  // getter and setter
  • src/molecule.cpp

    r205d9b rc550dd  
    659659 * @param three vectors forming the matrix that defines the shape of the parallelpiped
    660660 */
    661 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const Matrix &parallelepiped) const {
     661molecule* molecule::CopyMoleculeFromSubRegion(const Shape &region) const {
    662662  molecule *copy = World::getInstance().createMolecule();
    663663
    664664  BOOST_FOREACH(atom *iter,atoms){
    665     if(iter->IsInParallelepiped(offset,parallelepiped)){
     665    if(iter->IsInShape(region)){
    666666      copy->AddCopyAtom(iter);
    667667    }
  • src/molecule.hpp

    r205d9b rc550dd  
    5353class periodentafel;
    5454class Vector;
     55class Shape;
    5556
    5657/******************************** Some definitions for easier reading **********************************/
     
    316317
    317318  molecule *CopyMolecule();
    318   molecule* CopyMoleculeFromSubRegion(const Vector offset, const Matrix &parallelepiped) const;
     319  molecule* CopyMoleculeFromSubRegion(const Shape&) const;
    319320
    320321  /// Fragment molecule by two different approaches:
  • src/unittests/vectorunittest.cpp

    r205d9b rc550dd  
    215215  CPPUNIT_ASSERT(testVector.ScalarProduct(three) < MYEPSILON);
    216216}
    217 
    218 
    219 /**
    220  * UnitTest for Vector::IsInParallelepiped().
    221  */
    222 void VectorTest::IsInParallelepipedTest()
    223 {
    224   Matrix parallelepiped;
    225   parallelepiped.at(0,0) = 1;
    226   parallelepiped.at(1,0) = 0;
    227   parallelepiped.at(2,0) = 0;
    228   parallelepiped.at(0,1) = 0;
    229   parallelepiped.at(1,1) = 1;
    230   parallelepiped.at(2,1) = 0;
    231   parallelepiped.at(0,2) = 0;
    232   parallelepiped.at(1,2) = 0;
    233   parallelepiped.at(2,2) = 1;
    234 
    235   fixture = zero;
    236   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    237   fixture = Vector(2.5,2.5,2.5);
    238   CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    239   fixture = Vector(1.,1.,1.);
    240   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    241   fixture = Vector(3.5,3.5,3.5);
    242   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    243   fixture = Vector(2.,2.,2.);
    244   CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    245   fixture = Vector(2.,3.,2.);
    246   CPPUNIT_ASSERT_EQUAL( true, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    247   fixture = Vector(-2.,2.,-1.);
    248   CPPUNIT_ASSERT_EQUAL( false, fixture.IsInParallelepiped(Vector(2.,2.,2.), parallelepiped) );
    249 }
    250 
  • src/unittests/vectorunittest.hpp

    r205d9b rc550dd  
    2727    CPPUNIT_TEST ( ProjectionTest );
    2828    CPPUNIT_TEST ( NormalsTest );
    29     CPPUNIT_TEST ( IsInParallelepipedTest );
    3029    CPPUNIT_TEST_SUITE_END();
    3130
     
    4544    void LineIntersectionTest();
    4645    void VectorRotationTest();
    47     void IsInParallelepipedTest();
    4846
    4947private:
  • src/vector.cpp

    r205d9b rc550dd  
    543543}
    544544
    545 /**
    546  * Checks whether this vector is within the parallelepiped defined by the given three vectors and
    547  * their offset.
    548  *
    549  * @param offest for the origin of the parallelepiped
    550  * @param three vectors forming the matrix that defines the shape of the parallelpiped
    551  */
    552 bool Vector::IsInParallelepiped(const Vector &offset, const Matrix& _parallelepiped) const
    553 {
    554   Matrix parallelepiped = _parallelepiped.invert();
    555   Vector a = parallelepiped * ((*this)-offset);
    556   bool isInside = true;
    557 
    558   for (int i=NDIM;i--;)
    559     isInside = isInside && ((a[i] <= 1) && (a[i] >= 0));
    560 
    561   return isInside;
    562 }
    563 
    564545
    565546// some comonly used vectors
  • src/vector.hpp

    r205d9b rc550dd  
    6060  bool GetOneNormalVector(const Vector &x1);
    6161  bool MakeNormalTo(const Vector &y1);
    62   bool IsInParallelepiped(const Vector &offset, const Matrix& _parallelepiped) const;
    6362  std::pair<Vector,Vector> partition(const Vector&) const;
    6463  std::pair<pointset,Vector> partition(const pointset&) const;
Note: See TracChangeset for help on using the changeset viewer.