Changeset c67c65 for src/Shapes


Ignore:
Timestamp:
Mar 30, 2012, 9:18:25 AM (13 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:
595cfd
Parents:
7672551
git-author:
Frederik Heber <heber@…> (01/30/12 08:18:04)
git-committer:
Frederik Heber <heber@…> (03/30/12 09:18:25)
Message:

Added preliminary getVolume() and getSurfaceArea() implementation to all Shapes.

  • only BaseShapes are truely usable, the rest is mostly marked as TODO.
  • the problem is that intersections are not so easy to handle. Probably, we have to use polygonal intersections there and approximate volume calculations.
  • the functions return -1 when not implemented yet. this is preparatory to start approximate calculations at the top node of the Shape "graph" if -1. is returned from the implementation.
Location:
src/Shapes
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Shapes/BaseShapes.cpp

    r7672551 rc67c65  
    6060{
    6161  return 1.;
     62}
     63
     64double Sphere_impl::getVolume() const
     65{
     66        return (4./3.)*M_PI; // 4/3 pi r^3
     67}
     68
     69double Sphere_impl::getSurfaceArea() const
     70{
     71        return 2.*M_PI; // 2 pi r^2
    6272}
    6373
     
    194204}
    195205
     206double Cuboid_impl::getVolume() const
     207{
     208        return 1.; // l^3
     209}
     210
     211double Cuboid_impl::getSurfaceArea() const
     212{
     213        return 6.;      // 6 * l^2
     214}
     215
    196216LineSegmentSet Cuboid_impl::getLineIntersections(const Line &line) const{
    197217  LineSegmentSet res(line);
  • src/Shapes/BaseShapes_impl.hpp

    r7672551 rc67c65  
    2828  virtual Vector getCenter() const;
    2929  virtual double getRadius() const;
     30  virtual double getVolume() const;
     31  virtual double getSurfaceArea() const;
    3032  virtual LineSegmentSet getLineIntersections(const Line&) const;
    3133  virtual std::string toString() const;
     
    4143  virtual Vector getCenter() const;
    4244  virtual double getRadius() const;
     45  virtual double getVolume() const;
     46  virtual double getSurfaceArea() const;
    4347  virtual LineSegmentSet getLineIntersections(const Line&) const;
    4448  virtual std::string toString() const;
  • src/Shapes/Shape.cpp

    r7672551 rc67c65  
    5757double Shape::getRadius() const{
    5858  return impl->getRadius();
     59}
     60
     61/** Returns the volume of the Shape.
     62 *
     63 * If the underlying implementation does not have a working implementation,
     64 * i.e. returns -1., then we use an approximate method to calculate the
     65 * volume via a mesh of grid points and checking for isInside (basically
     66 * a Monte-Carlo integration of the volume).
     67 *
     68 * \return volume of the shape
     69 */
     70double Shape::getVolume() const
     71{
     72        const double volume = impl->getVolume();
     73        if (volume  != -1.) {
     74                return volume;
     75        } else {
     76                ASSERT(0, "Shape::getVolume() - functionality not implemented for this specific shape.");
     77        }
     78}
     79
     80/** Returns the surface area of the Shape.
     81 *
     82 * If the underlying implementation does not have a working implementation,
     83 * i.e. returns -1., then we use the working filling of the shapes surface
     84 * with points and subsequent tesselation and obtaining the approximate
     85 * surface area therefrom.
     86 *
     87 * @return surface area of the Shape
     88 */
     89double Shape::getSurfaceArea() const
     90{
     91        const double surfacearea = impl->getSurfaceArea();
     92        if (surfacearea != -1.) {
     93                return surfacearea;
     94        } else {
     95                ASSERT(0, "Shape::getSurfaceArea() - functionality not implemented for this specific shape.");
     96        }
    5997}
    6098
     
    192230}
    193231
     232double AndShape_impl::getVolume() const
     233{
     234        // TODO
     235        return -1.;
     236}
     237
     238double AndShape_impl::getSurfaceArea() const
     239{
     240        // TODO
     241        return -1.;
     242}
     243
    194244LineSegmentSet AndShape_impl::getLineIntersections(const Line &line) const{
    195245  return intersect(lhs->getLineIntersections(line),rhs->getLineIntersections(line));
     
    304354}
    305355
     356double OrShape_impl::getVolume() const
     357{
     358        // TODO
     359        return -1.;
     360}
     361
     362double OrShape_impl::getSurfaceArea() const
     363{
     364        // TODO
     365        return -1.;
     366}
     367
    306368LineSegmentSet OrShape_impl::getLineIntersections(const Line &line) const{
    307369  return merge(lhs->getLineIntersections(line),rhs->getLineIntersections(line));
     
    374436}
    375437
     438double NotShape_impl::getVolume() const
     439{
     440        // TODO
     441        return -1.; //-arg->getVolume();
     442}
     443
     444double NotShape_impl::getSurfaceArea() const
     445{
     446        // TODO
     447        return -1.; // -arg->getSurfaceArea();
     448}
     449
    376450LineSegmentSet NotShape_impl::getLineIntersections(const Line &line) const{
    377451  return invert(arg->getLineIntersections(line));
  • src/Shapes/Shape.hpp

    r7672551 rc67c65  
    4444  Vector getCenter() const;
    4545  double getRadius() const;
     46  double getVolume() const;
     47  double getSurfaceArea() const;
    4648
    4749  LineSegmentSet getLineIntersections(const Line&) const;
  • src/Shapes/ShapeOps.cpp

    r7672551 rc67c65  
    111111Resize_impl::~Resize_impl(){}
    112112
     113double Resize_impl::getVolume() const
     114{
     115        return getArg()->getVolume() * size;
     116}
     117
     118double Resize_impl::getSurfaceArea() const
     119{
     120        return getArg()->getSurfaceArea() * size;
     121}
     122
     123
    113124bool Resize_impl::isInside(const Vector& point) const{
    114125  return getArg()->isInside((1/size) * point);
     
    175186}
    176187
     188double Translate_impl::getVolume() const
     189{
     190        return getArg()->getVolume();
     191}
     192
     193double Translate_impl::getSurfaceArea() const
     194{
     195        return getArg()->getSurfaceArea();
     196}
    177197
    178198Vector Translate_impl::translateIn(const Vector& point) const{
     
    225245
    226246Stretch_impl::~Stretch_impl(){}
     247
     248double Stretch_impl::getVolume() const
     249{
     250        // TODO
     251        return -1.;
     252}
     253
     254double Stretch_impl::getSurfaceArea() const
     255{
     256        // TODO
     257        return -1.;
     258}
    227259
    228260bool Stretch_impl::isInside(const Vector& point) const{
     
    291323Transform_impl::~Transform_impl(){}
    292324
     325double Transform_impl::getVolume() const
     326{
     327        return getArg()->getVolume();
     328}
     329
     330double Transform_impl::getSurfaceArea() const
     331{
     332        return getArg()->getSurfaceArea();
     333}
     334
    293335bool Transform_impl::isInside(const Vector& point) const{
    294336  return getArg()->isInside(transformationInv * point);
  • src/Shapes/ShapeOps_impl.hpp

    r7672551 rc67c65  
    5353  virtual ~Resize_impl();
    5454protected:
     55  virtual double getVolume() const;
     56  virtual double getSurfaceArea() const;
    5557  virtual Vector translateIn(const Vector &point) const;
    5658  virtual Vector translateOutPos(const Vector &point) const;
     
    7274  virtual Vector getCenter() const;
    7375  virtual double getRadius() const;
     76  virtual double getVolume() const;
     77  virtual double getSurfaceArea() const;
    7478  virtual Vector translateIn(const Vector &point) const;
    7579  virtual Vector translateOutPos(const Vector &point) const;
     
    8690{
    8791public:
    88   Stretch_impl(const Shape::impl_ptr&, const Vector&);
     92
     93
     94        Stretch_impl(const Shape::impl_ptr&, const Vector&);
    8995  virtual ~Stretch_impl();
    9096protected:
     97  virtual double getVolume() const;
     98  virtual double getSurfaceArea() const;
    9199  virtual Vector translateIn(const Vector &point) const;
    92100  virtual Vector translateOutPos(const Vector &point) const;
     
    107115  virtual ~Transform_impl();
    108116protected:
     117  virtual double getVolume() const;
     118  virtual double getSurfaceArea() const;
    109119  virtual Vector translateIn(const Vector &point) const;
    110120  virtual Vector translateOutPos(const Vector &point) const;
  • src/Shapes/Shape_impl.hpp

    r7672551 rc67c65  
    3939  virtual Vector getCenter() const=0;
    4040  virtual double getRadius() const=0;
     41  virtual double getVolume() const=0;
     42  virtual double getSurfaceArea() const=0;
    4143  virtual LineSegmentSet getLineIntersections(const Line&) const=0;
    4244  virtual std::string toString() const =0;
     
    6365    return std::numeric_limits<double>::infinity();
    6466  }
     67  virtual double getVolume() const
     68  {
     69        // TODO
     70        return 0.;
     71  }
     72  virtual double getSurfaceArea() const
     73  {
     74        // TODO
     75        return 0.;
     76  }
    6577  virtual LineSegmentSet getLineIntersections(const Line &line) const{
    6678    LineSegmentSet res(line);
     
    100112  virtual double getRadius() const {
    101113    return 0.;
     114  }
     115  virtual double getVolume() const
     116  {
     117        return 0.;
     118  }
     119  virtual double getSurfaceArea() const
     120  {
     121        return 0.;
    102122  }
    103123  virtual LineSegmentSet getLineIntersections(const Line &line) const{
     
    128148  virtual Vector getCenter() const;
    129149  virtual double getRadius() const;
     150  virtual double getVolume() const;
     151  virtual double getSurfaceArea() const;
    130152  virtual LineSegmentSet getLineIntersections(const Line&) const;
    131153  virtual std::string toString() const;
     
    147169  virtual Vector getCenter() const;
    148170  virtual double getRadius() const;
     171  virtual double getVolume() const;
     172  virtual double getSurfaceArea() const;
    149173  virtual LineSegmentSet getLineIntersections(const Line&) const;
    150174  virtual std::string toString() const;
     
    166190  virtual Vector getCenter() const;
    167191  virtual double getRadius() const;
     192  virtual double getVolume() const;
     193  virtual double getSurfaceArea() const;
    168194  virtual LineSegmentSet getLineIntersections(const Line&) const;
    169195  virtual std::string toString() const;
Note: See TracChangeset for help on using the changeset viewer.