Changeset cfda65 for src


Ignore:
Timestamp:
Jul 15, 2010, 10:37:56 AM (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:
4506cc
Parents:
ef84ca
Message:

Added methods to output shapes on the screen

Location:
src/Shapes
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Shapes/BaseShapes.cpp

    ref84ca rcfda65  
    2727  }
    2828  return point;
     29}
     30
     31string Sphere_impl::toString(){
     32  return "Sphere()";
    2933}
    3034
     
    6771}
    6872
     73string Cuboid_impl::toString(){
     74  return "Cuboid()";
     75}
     76
    6977Shape Cuboid(){
    7078  Shape::impl_ptr impl = Shape::impl_ptr(new Cuboid_impl());
  • src/Shapes/BaseShapes_impl.hpp

    ref84ca rcfda65  
    1515  virtual bool isOnSurface(const Vector &point);
    1616  virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
     17  virtual std::string toString();
    1718};
    1819
     
    2122  virtual bool isOnSurface(const Vector &point);
    2223  virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
     24  virtual std::string toString();
    2325};
    2426
  • src/Shapes/Shape.cpp

    ref84ca rcfda65  
    1111#include "Helpers/Assert.hpp"
    1212
     13#include <string>
     14
     15using namespace std;
     16
    1317Shape::Shape(const Shape& src) :
    1418  impl(src.getImpl())
     
    3842  }
    3943  return *this;
     44}
     45
     46std::string Shape::toString() const{
     47  return impl->toString();
    4048}
    4149
     
    118126}
    119127
     128string AndShape_impl::toString(){
     129  return string("(") + lhs->toString() + string("&&") + rhs->toString() + string(")");
     130}
     131
    120132Shape operator&&(const Shape &lhs,const Shape &rhs){
    121133  Shape::impl_ptr newImpl = Shape::impl_ptr(new AndShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
     
    178190}
    179191
     192string OrShape_impl::toString(){
     193  return string("(") + lhs->toString() + string("||") + rhs->toString() + string(")");
     194}
     195
    180196Shape operator||(const Shape &lhs,const Shape &rhs){
    181197  Shape::impl_ptr newImpl = Shape::impl_ptr(new OrShape_impl(getShapeImpl(lhs),getShapeImpl(rhs)));
     
    203219}
    204220
     221string NotShape_impl::toString(){
     222  return string("!") + arg->toString();
     223}
     224
    205225Shape operator!(const Shape &arg){
    206226  Shape::impl_ptr newImpl = Shape::impl_ptr(new NotShape_impl(getShapeImpl(arg)));
    207227  return Shape(newImpl);
    208228}
     229
     230/**************** global operations *********************************/
     231ostream &operator<<(ostream &ost,const Shape &shape){
     232  ost << shape.toString();
     233  return ost;
     234}
  • src/Shapes/Shape.hpp

    ref84ca rcfda65  
    1010
    1111#include <boost/shared_ptr.hpp>
     12#include <iosfwd>
    1213
    1314#include "Exceptions/NotOnSurfaceException.hpp"
     
    3233  Shape &operator=(const Shape& rhs);
    3334
     35  std::string toString() const;
    3436protected:
    3537  impl_ptr getImpl() const;
     
    4648Shape operator!(const Shape&);
    4749
     50std::ostream &operator<<(std::ostream&,const Shape&);
     51
    4852#endif /* SHAPE_HPP_ */
  • src/Shapes/ShapeOps.cpp

    ref84ca rcfda65  
    3434}
    3535
     36Shape::impl_ptr ShapeOpsBase_impl::getArg(){
     37  return arg;
     38}
     39
    3640/********************* Resize ********************/
    3741
     
    5458Vector Resize_impl::translateOutNormal(const Vector& point){
    5559  return point;
     60}
     61
     62string Resize_impl::toString(){
     63  stringstream sstr;
     64  sstr << "resize(" << getArg()->toString() << "," << size << ")";
     65  return sstr.str();
    5666}
    5767
     
    7989Vector Translate_impl::translateOutNormal(const Vector& point){
    8090  return point;
     91}
     92
     93string Translate_impl::toString(){
     94  stringstream sstr;
     95  sstr << "translate(" << getArg()->toString() << "," << offset << ")";
    8196}
    8297
     
    125140}
    126141
     142string Stretch_impl::toString(){
     143  stringstream sstr;
     144  sstr << "stretch(" << getArg()->toString() << "," << factors << ")";
     145  return sstr.str();
     146}
     147
    127148Shape stretch(const Shape &arg, const Vector &factors){
    128149  Shape::impl_ptr impl = Shape::impl_ptr(new Stretch_impl(getShapeImpl(arg),factors));
     
    153174}
    154175
     176string Transform_impl::toString(){
     177  stringstream sstr;
     178  sstr << "transform(" << getArg()->toString() << "," << transformation << ")";
     179  return sstr.str();
     180}
     181
    155182Shape transform(const Shape &arg, const Matrix &transformation){
    156183  Shape::impl_ptr impl = Shape::impl_ptr(new Transform_impl(getShapeImpl(arg),transformation));
  • src/Shapes/ShapeOps_impl.hpp

    ref84ca rcfda65  
    2424  virtual Vector translateOutPos(const Vector &point)=0;
    2525  virtual Vector translateOutNormal(const Vector &point)=0;
     26  Shape::impl_ptr getArg();
    2627private:
    2728  Shape::impl_ptr arg;
     
    3738  virtual Vector translateOutPos(const Vector &point);
    3839  virtual Vector translateOutNormal(const Vector &point);
     40  virtual std::string toString();
    3941private:
    4042  double size;
     
    5052  virtual Vector translateOutPos(const Vector &point);
    5153  virtual Vector translateOutNormal(const Vector &point);
     54  virtual std::string toString();
    5255private:
    5356  Vector offset;
     
    6366  virtual Vector translateOutPos(const Vector &point);
    6467  virtual Vector translateOutNormal(const Vector &point);
     68  virtual std::string toString();
    6569private:
    6670  Vector factors;
     
    7781  virtual Vector translateOutPos(const Vector &point);
    7882  virtual Vector translateOutNormal(const Vector &point);
     83  virtual std::string toString();
    7984private:
    8085  Matrix transformation;
  • src/Shapes/Shape_impl.hpp

    ref84ca rcfda65  
    1919  virtual bool isOnSurface(const Vector &point)=0;
    2020  virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException)=0;
     21  virtual std::string toString()=0;
    2122};
    2223
     
    3233    throw NotOnSurfaceException(__FILE__,__LINE__);
    3334  }
     35  virtual std::string toString(){
     36    return "Everywhere()";
     37  }
    3438};
    3539
     
    4448    throw NotOnSurfaceException(__FILE__,__LINE__);
    4549  }
     50  virtual std::string toString(){
     51    return "Nowhere()";
     52  }
    4653};
    4754
     
    5360  virtual bool isOnSurface(const Vector &point);
    5461  virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
     62  virtual std::string toString();
    5563private:
    5664  Shape::impl_ptr lhs;
     
    6573  virtual bool isOnSurface(const Vector &point);
    6674  virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
     75  virtual std::string toString();
    6776private:
    6877  Shape::impl_ptr lhs;
     
    7786  virtual bool isOnSurface(const Vector &point);
    7887  virtual Vector getNormal(const Vector &point) throw(NotOnSurfaceException);
     88  virtual std::string toString();
    7989private:
    8090  Shape::impl_ptr arg;
Note: See TracChangeset for help on using the changeset viewer.