Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

DistanceResults.hpp

Go to the documentation of this file.
00001 
00002 //
00003 //       Title           : DistanceResults.hpp
00004 //       Project         : D&D Demos
00005 //       Created         : March 15, 2005
00006 //       Author          : Ethan Swint
00007 //       Platforms       :
00008 //       Copyright       : Copyright© The University of Texas at Austin, 2002. All rights reserved.
00009 //                 
00010 //          This software and documentation constitute an unpublished work
00011 //          and contain valuable trade secrets and proprietary information
00012 //          belonging to the University. None of the foregoing material may be
00013 //          copied or duplicated or disclosed without the express, written
00014 //          permission of University. THE UNIVERSITY EXPRESSLY DISCLAIMS ANY
00015 //          AND ALL WARRANTIES CONCERNING THIS SOFTWARE AND DOCUMENTATION,
00016 //          INCLUDING ANY WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00017 //          PARTICULAR PURPOSE, AND WARRANTIES OF PERFORMANCE, AND ANY WARRANTY
00018 //          THAT MIGHT OTHERWISE ARISE FROM COURSE OF DEALING OR USAGE OF TRADE.
00019 //          NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH RESPECT TO THE USE OF
00020 //          THE SOFTWARE OR DOCUMENTATION. Under no circumstances shall the
00021 //          University be liable for incidental, special, indirect, direct or
00022 //          consequential damages or loss of profits, interruption of business,
00023 //          or related expenses which may arise from use of software or documentation,
00024 //          including but not limited to those resulting from defects in software
00025 //          and/or documentation, or loss or inaccuracy of data of any kind.
00026 //       Purpose         : Container  to hold obstacle information.
00027 //
00028 //
00029 //----------------------------------------------------------------------------
00030 //
00031 //       $Revisions$
00032 //
00033 //       $Log: DistanceResults.hpp,v $
00034 //       Revision 1.8  2007/03/30 20:41:27  aspencer
00035 //       Changed obstacle avoidance criteria to use the new node structure as the basis for its modeling.
00036 //
00037 //       Revision 1.7  2006/04/09 20:48:00  mitch
00038 //       moved Dhat from ipp (inline) to cpp file
00039 //
00040 //       Revision 1.6  2005/09/26 16:29:37  aspencer
00041 //       Moved commenting so that the class will show up correctly in doxygen
00042 //
00043 //       Revision 1.5  2005/09/02 17:53:38  josh
00044 //       Added methods to more easily access distance results.
00045 //
00046 //       Revision 1.4  2005/07/15 16:27:01  aspencer
00047 //       Changed the way that DistanceCalculator stores results in DistanceResults. Now DistanceResults can be re-used for the same manipulator/enviornment over and over, without being cleared, and without having a memory explosion.
00048 //
00049 //       Revision 1.3  2005/07/01 19:18:08  aspencer
00050 //       Added doxygen commenting (ingroup, class brief)
00051 //
00052 //       Revision 1.2  2005/06/23 21:28:43  josh
00053 //       Fixed bugs in CalcDist between two nodes. Changed method signatures in DistanceResults.
00054 //
00055 //       Revision 1.1  2005/06/15 21:53:17  aspencer
00056 //       Initial Commit
00057 //
00058 //
00059 //
00060 //
00062 
00063 #ifndef DistanceResults_h
00064 #define DistanceResults_h
00065 
00066 #ifdef _MSC_VER
00067         //disable warnI ngs due to truncation of mangled function names of STL template 
00068         //instantiations
00069         #pragma warning (disable: 4786)
00070 #endif //_MSC_VER
00071 
00072 #include "Primitive.hpp"
00073 #include "ScaleInverseF.hpp"
00074 #include "Math/Vector3.h"
00075 #include <assert.h>
00076 #include <map>
00077 #include <vector>
00078 
00079 
00080 
00081 namespace OSCAR {
00082 
00088 class DistanceCalculator;
00089 typedef std::vector<Vector3> Vector3vec;
00090 
00091 class DistanceResults {
00092   friend class DistanceCalculator;
00093 public:
00094   typedef std::map<const Primitive*, std::pair<Vector3, int> > InnerMap;
00095   typedef std::map<const Primitive*, InnerMap> OuterMap;
00096   typedef std::map<const Primitive*, vector<double> > InnerGMap;
00097   typedef std::map<const Primitive*, InnerGMap> OuterGMap;
00098   //typedef std::map<const Primitive*, Tensor> hFuncMap;
00099   typedef std::map<const Primitive*, Matrix*> InnerHMap;
00100   typedef std::map<const Primitive*, InnerHMap> OuterHMap;
00101         typedef InnerMap::const_iterator        InnerMapIterator;
00102 
00103         DistanceResults();
00104 
00127   bool LocateDHat(const Primitive* const from, const Primitive* const to, int& index) const;
00128   
00147         bool LocatePair(const Primitive* const from, const Primitive* const to, InnerMapIterator& iter) const;
00148   
00155   bool Distance(const Primitive* const p0, const Primitive* const p1, double& distance) const;
00156 
00164   bool CalculateForce(const Primitive* const p0, const Primitive* const p1, const ArtificialPotentialF& func);
00165 
00173   bool GetForce(const Primitive* const p0, const Primitive* const p1, double& force) const;
00174     
00180   double Distance(InnerMapIterator iter) const;
00181 
00189   bool CalculateForceD1(const Primitive* const p0, const Primitive* const p1, const ArtificialPotentialF& func);
00190 
00198   bool GetForceD1(const Primitive* const p0, const Primitive* const p1, double& forceD1) const;
00199         
00200 
00205         Vector3 Dhat(InnerMapIterator iter) const;
00206 
00211         const Vector3& WitnessPoint(InnerMapIterator iter) const;
00212 
00219   bool GetWitnessPoint(const Primitive* const locatedOn, const Primitive* const closestTo, Vector3& wit) const;
00220   
00226   const Vector3vec& Dhat() const;
00227   
00232   bool Contains(const Primitive* const thisObject) const;
00233 
00237   ~DistanceResults();
00238   
00272         void Clear();
00273 
00282   bool GetGFunctions(const Primitive* from, const Primitive* to, const vector<double>*& gFunctions) const;
00283 
00291   bool GetHFunctions(const Primitive* from, const Primitive* to, const Matrix* hFunctions);
00292 
00293   
00294 
00295 private:
00296   Vector3vec dHats;
00297   std::vector<double> distances;
00298   std::vector<double> forces;
00299   std::vector<double> forcesD1;
00300   OuterMap results;
00301   OuterGMap gFuncs;
00302   OuterHMap hFuncs;
00303   bool contains(const Primitive* prim1, const Primitive* prim2, int& index);
00304   bool setHFunctions(const Primitive* to, const Primitive* from, Matrix* hFunctions);
00305   Matrix* containsHFunction(const Primitive* from, const Primitive* to);
00306 };//end of class
00307 
00308 //Include definition of inline methods
00309 #include "DistanceResults.ipp"
00310 
00311 }  //namespace OSCAR
00312 #endif //DistanceResults_h
RRG Homepage OSCAR Overview OSCAR Tutorials Simulations