PQP_Internal.h
Go to the documentation of this file.
00001 /*************************************************************************\
00002 
00003   Copyright 1999 The University of North Carolina at Chapel Hill.
00004   All Rights Reserved.
00005 
00006   Permission to use, copy, modify and distribute this software and its
00007   documentation for educational, research and non-profit purposes, without
00008   fee, and without a written agreement is hereby granted, provided that the
00009   above copyright notice and the following three paragraphs appear in all
00010   copies.
00011 
00012   IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE
00013   LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
00014   CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE
00015   USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY
00016   OF NORTH CAROLINA HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
00017   DAMAGES.
00018 
00019   THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY
00020   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE
00022   PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
00023   NORTH CAROLINA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
00024   UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
00025 
00026   The authors may be contacted via:
00027 
00028   US Mail:             S. Gottschalk, E. Larsen
00029                        Department of Computer Science
00030                        Sitterson Hall, CB #3175
00031                        University of N. Carolina
00032                        Chapel Hill, NC 27599-3175
00033 
00034   Phone:               (919)962-1749
00035 
00036   EMail:               geom@cs.unc.edu
00037 
00038 
00039 \**************************************************************************/
00040 
00041 #include "Tri.h"
00042 #include "BV.h"
00043 
00044 class PQP_Model
00045 {
00046 
00047 public:
00048 
00049   int build_state;
00050 
00051   Tri *tris;  
00052   int num_tris;
00053   int num_tris_alloced;
00054 
00055   BV *b;
00056   int num_bvs;
00057   int num_bvs_alloced;
00058 
00059   Tri *last_tri;       // closest tri on this model in last distance test
00060   
00061   BV *child(int n) { return &b[n]; }
00062 
00063   PQP_Model();
00064   ~PQP_Model();
00065 
00066   int BeginModel(int num_tris = 8); // preallocate for num_tris triangles;
00067                                     // the parameter is optional, since
00068                                     // arrays are reallocated as needed
00069   int AddTri(const PQP_REAL *p1, const PQP_REAL *p2, const PQP_REAL *p3, 
00070              int id);
00071   int EndModel();
00072   int MemUsage(int msg);  // returns model mem usage.  
00073                           // prints message to stderr if msg == TRUE
00074 };
00075 
00076 struct CollisionPair
00077 {
00078   int id1;
00079   int id2;
00080 };
00081 
00082 struct PQP_CollideResult  
00083 {
00084   // stats
00085 
00086   int num_bv_tests;
00087   int num_tri_tests;
00088   double query_time_secs;
00089 
00090   // xform from model 1 to model 2
00091 
00092   PQP_REAL R[3][3];
00093   PQP_REAL T[3];
00094 
00095   int num_pairs_alloced;
00096   int num_pairs;
00097   CollisionPair *pairs;
00098 
00099   void SizeTo(int n);    
00100   void Add(int i1, int i2); 
00101 
00102   PQP_CollideResult();
00103   ~PQP_CollideResult();
00104 
00105   // statistics
00106 
00107   int NumBVTests() { return num_bv_tests; }
00108   int NumTriTests() { return num_tri_tests; }
00109   double QueryTimeSecs() { return query_time_secs; }
00110 
00111   // free the list of contact pairs; ordinarily this list is reused
00112   // for each query, and only deleted in the destructor.
00113 
00114   void FreePairsList(); 
00115 
00116   // query results
00117 
00118   int Colliding() { return (num_pairs > 0); }
00119   int NumPairs() { return num_pairs; }
00120   int Id1(int k) { return pairs[k].id1; }
00121   int Id2(int k) { return pairs[k].id2; }
00122 };
00123 
00124 #if PQP_BV_TYPE & RSS_TYPE // distance/tolerance are only available with RSS
00125 
00126 struct PQP_DistanceResult 
00127 {
00128   // stats
00129 
00130   int num_bv_tests;
00131   int num_tri_tests;
00132   double query_time_secs;
00133 
00134   // xform from model 1 to model 2
00135 
00136   PQP_REAL R[3][3];
00137   PQP_REAL T[3];
00138 
00139   PQP_REAL rel_err; 
00140   PQP_REAL abs_err; 
00141 
00142   PQP_REAL distance;
00143   PQP_REAL p1[3]; 
00144   PQP_REAL p2[3];
00145   int qsize;
00146   
00147   // statistics
00148 
00149   int NumBVTests() { return num_bv_tests; }
00150   int NumTriTests() { return num_tri_tests; }
00151   double QueryTimeSecs() { return query_time_secs; }
00152 
00153   // The following distance and points established the minimum distance
00154   // for the models, within the relative and absolute error bounds 
00155   // specified.
00156   // Points are defined: PQP_REAL p1[3], p2[3];
00157 
00158   PQP_REAL Distance() { return distance; }
00159   const PQP_REAL *P1() { return p1; }
00160   const PQP_REAL *P2() { return p2; }
00161 };
00162 
00163 struct PQP_ToleranceResult 
00164 {
00165   // stats
00166 
00167   int num_bv_tests;
00168   int num_tri_tests;
00169   double query_time_secs;
00170 
00171   // xform from model 1 to model 2
00172 
00173   PQP_REAL R[3][3];
00174   PQP_REAL T[3];
00175 
00176   int    closer_than_tolerance;   
00177   PQP_REAL tolerance;      
00178 
00179   PQP_REAL distance;
00180   PQP_REAL p1[3]; 
00181   PQP_REAL p2[3]; 
00182   int qsize;
00183 
00184   // statistics
00185 
00186   int NumBVTests() { return num_bv_tests; }
00187   int NumTriTests() { return num_tri_tests; }
00188   double QueryTimeSecs() { return query_time_secs; }
00189 
00190   // If the models are closer than ( <= ) tolerance, these points 
00191   // and distance were what established this.  Otherwise, 
00192   // distance and point values are not meaningful.
00193 
00194   PQP_REAL Distance() { return distance; }
00195   const PQP_REAL *P1() { return p1; }
00196   const PQP_REAL *P2() { return p2; }
00197 
00198   // boolean says whether models are closer than tolerance distance
00199 
00200   int CloserThanTolerance() { return closer_than_tolerance; }
00201 };
00202 
00203 #endif


jskeus
Author(s): JSK Alumnis
autogenerated on Fri Aug 28 2015 11:15:08