Changeset d61161 for src/Shapes


Ignore:
Timestamp:
Nov 19, 2012, 10:27:51 AM (12 years ago)
Author:
Frederik Heber <heber@…>
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:
d5307b
Parents:
286a967 (diff), 315351 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'michi-list-query-validator' into stable

Location:
src/Shapes
Files:
8 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/Shapes/BaseShapes.cpp

    r286a967 rd61161  
    6161
    6262bool Cylinder_impl::isOnSurface(const Vector &point) const {
    63   return fabs(Vector(point[0], point[1], 0.0).NormSquared()-1.0)<MYEPSILON &&
    64       (point[2] > -1.0-MYEPSILON) && (point[2] < 1.0+MYEPSILON);
     63  // on the side?
     64  if (fabs(Vector(point[0], point[1], 0.0).NormSquared()-1.0)<MYEPSILON &&
     65      (point[2] > -1.0-MYEPSILON) && (point[2] < 1.0+MYEPSILON))
     66    return true;
     67  // on top/bottom?
     68  if ((Vector(point[0], point[1], 0.0).NormSquared()< 1.0 + MYEPSILON) &&
     69      ((fabs(point[2]-1)<MYEPSILON) || (fabs(point[2]+1)<MYEPSILON)))
     70      return true;
     71  return false;
    6572
    6673}
     
    7178  }
    7279
    73   if ((fabs(point[2]-1)<MYEPSILON) || (fabs(point[2])<MYEPSILON))
    74       return Vector(0.0, 0.0, point[2]);
     80  Vector n = Vector(0, 0, 0);
     81  if ((fabs(point[2]-1)<MYEPSILON) || (fabs(point[2]+1)<MYEPSILON))
     82      n += Vector(0.0, 0.0, point[2]);
    7583  else
    76     return Vector(point[0], point[1], 0.0);
     84    n += Vector(point[0], point[1], 0.0);
     85  n.Normalize();
     86  return n;
    7787}
    7888
     
    109119    std::vector<double> solutions;
    110120
    111     // Common routine to solve quadratic quations, anywhere?
     121    // Common routine to solve quadratic equations, anywhere?
    112122    const double neg_p_half = -B/(2.0*A);
    113123    const double q = C/A;
     
    168178   
    169179    for(int useg=0; useg<nu; useg++)
    170         for(int zseg=0; zseg<nz; zseg++)
     180        for(int zseg=0; zseg<=nz; zseg++)
    171181            result.push_back(Vector(cos(useg*dphi), sin(useg*dphi), zseg*dz-1.0));
    172182
     
    366376  // figure out on which sides the Vector lies (maximum 3, when it is in a corner)
    367377  for(int i=NDIM;i--;){
    368     if(fabs(fabs(point[i])-1)<MYEPSILON){
     378    if((fabs(point[i])<MYEPSILON) || (fabs(point[i]-1)<MYEPSILON)){
    369379      // add the scaled (-1/+1) Vector to the set of surface vectors
    370       res[i] = point[i];
     380      res[i] = point[i] * 2.0 - 1.0;
    371381    }
    372382  }
     
    442452std::vector<Vector> Cuboid_impl::getHomogeneousPointsOnSurface(const size_t N) const {
    443453  std::vector<Vector> PointsOnSurface;
    444   ASSERT(false, "Cuboid_impl::getHomogeneousPointsOnSurface() not implemented yet");
     454  // sides
     455  int n = sqrt((N - 1) / 6) + 1;
     456  for (int i=0; i<=n; i++){
     457    double ii = (double)i / (double)n;
     458    for (int k=0; k<n; k++){
     459      double kk = (double)k / (double)n;
     460      PointsOnSurface.push_back(Vector(ii, kk, 1));
     461      PointsOnSurface.push_back(Vector(ii, 1, 1-kk));
     462      PointsOnSurface.push_back(Vector(ii, 1-kk, 0));
     463      PointsOnSurface.push_back(Vector(ii, 0, kk));
     464    }
     465  }
     466  // top and bottom
     467  for (int i=1; i<n; i++){
     468    double ii = (double)i / (double)n;
     469    for (int k=1; k<n; k++){
     470      double kk = (double)k / (double)n;
     471      PointsOnSurface.push_back(Vector(0, ii, kk));
     472      PointsOnSurface.push_back(Vector(1, ii, kk));
     473    }
     474  }
    445475  return PointsOnSurface;
    446476}
  • src/Shapes/Makefile.am

    r286a967 rd61161  
    55  Shapes/BaseShapes.cpp \
    66  Shapes/Shape.cpp \
    7   Shapes/ShapeOps.cpp
     7  Shapes/ShapeFactory.cpp \
     8  Shapes/ShapeOps.cpp \
     9  Shapes/ShapeRegistry.cpp
    810SHAPEHEADER = \
    911  Shapes/BaseShapes.hpp \
     
    1214  Shapes/Shape_impl.hpp \
    1315  Shapes/ShapeExceptions.hpp \
     16  Shapes/ShapeFactory.hpp \
    1417  Shapes/ShapeOps.hpp \
    1518  Shapes/ShapeOps_impl.hpp \
     19  Shapes/ShapeRegistry.hpp \
    1620  Shapes/ShapeType.hpp
    1721
  • src/Shapes/Shape.cpp

    r286a967 rd61161  
    5252
    5353Shape::Shape(const Shape& src) :
    54   impl(src.getImpl())
     54  impl(src.getImpl()), name(src.getName())
    5555{}
    5656
     
    7575double Shape::getRadius() const{
    7676  return impl->getRadius();
     77}
     78
     79void Shape::setName(const std::string &_name){
     80  name = _name;
     81}
     82
     83std::string Shape::getName() const{
     84  return name;
    7785}
    7886
  • src/Shapes/Shape.hpp

    r286a967 rd61161  
    5858  enum ShapeType getType() const;
    5959
     60  void setName(const std::string &_name);
     61  std::string getName() const;
     62
    6063protected:
    6164  impl_ptr getImpl() const;
     
    6366private:
    6467  impl_ptr impl;
     68  std::string name;
    6569};
    6670
  • src/Shapes/ShapeType.hpp

    r286a967 rd61161  
    2222        PolygonType,
    2323        CombinedType,
    24         MAX_ShapeType,
    25     CylinderType
     24  CylinderType,
     25        MAX_ShapeType
    2626};
    2727
  • src/Shapes/unittests/Makefile.am

    r286a967 rd61161  
    55SHAPETESTSSOURCES = \
    66        ../Shapes/unittests/BaseShapesUnitTest.cpp \
     7        ../Shapes/unittests/ShapeFactoryUnitTest.cpp \
    78        ../Shapes/unittests/ShapeOpsUnitTest.cpp \
     9        ../Shapes/unittests/ShapeRegistryUnitTest.cpp \
    810        ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.cpp
    911
    1012SHAPETESTSHEADERS= \
    1113        ../Shapes/unittests/BaseShapesUnitTest.hpp \
     14        ../Shapes/unittests/ShapeFactoryUnitTest.hpp \
    1215        ../Shapes/unittests/ShapeOpsUnitTest.hpp \
     16        ../Shapes/unittests/ShapeRegistryUnitTest.hpp \
    1317        ../Shapes/unittests/Shape_HomogeneousPointsUnitTest.cpp
    1418
    1519SHAPETESTS = \
    1620  BaseShapesUnitTest \
     21  ShapeFactoryUnitTest \
    1722  ShapeOpsUnitTest \
     23  ShapeRegistryUnitTest \
    1824  Shape_HomogeneousPointsUnitTest
    1925 
     
    3844BaseShapesUnitTest_LDADD = $(SHAPELIBS)
    3945
     46ShapeFactoryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     47        ../Shapes/unittests/ShapeFactoryUnitTest.cpp \
     48        ../Shapes/unittests/ShapeFactoryUnitTest.hpp \
     49        ../Shapes/unittests/stubs/ApproximateShapeAreaStub.cpp \
     50        ../Shapes/unittests/stubs/ApproximateShapeVolumeStub.cpp
     51nodist_ShapeFactoryUnitTest_SOURCES = \
     52        ../Helpers/defs.hpp \
     53        ../Helpers/defs.cpp
     54ShapeFactoryUnitTest_LDADD = $(SHAPELIBS)
     55
    4056ShapeOpsUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
    4157        ../Shapes/unittests/ShapeOpsUnitTest.cpp \
     
    4763        ../Helpers/defs.cpp
    4864ShapeOpsUnitTest_LDADD = $(SHAPELIBS)
     65
     66ShapeRegistryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
     67        ../Shapes/unittests/ShapeRegistryUnitTest.cpp \
     68        ../Shapes/unittests/ShapeRegistryUnitTest.hpp \
     69        ../Shapes/unittests/stubs/ApproximateShapeAreaStub.cpp \
     70        ../Shapes/unittests/stubs/ApproximateShapeVolumeStub.cpp
     71nodist_ShapeRegistryUnitTest_SOURCES = \
     72        ../Helpers/defs.hpp \
     73        ../Helpers/defs.cpp
     74ShapeRegistryUnitTest_LDADD = $(SHAPELIBS)
    4975
    5076Shape_HomogeneousPointsUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
Note: See TracChangeset for help on using the changeset viewer.