Biomechanical Joint Model
 Author: Anderson Maciel

NBody.H

Go to the documentation of this file.
00001 /************************************************************************\
00002 
00003   Copyright 1997 The University of North Carolina at Chapel Hill.
00004   All Rights Reserved.
00005 
00006   Permission to use, copy, modify and distribute this software
00007   and its documentation for educational, research and non-profit
00008   purposes, without fee, and without a written agreement is
00009   hereby granted, provided that the above copyright notice and
00010   the following three paragraphs appear in all copies.
00011 
00012   IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL
00013   HILL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
00014   INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
00015   ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
00016   EVEN IF THE UNIVERSITY OF NORTH CAROLINA HAVE BEEN ADVISED OF
00017   THE POSSIBILITY OF SUCH DAMAGES.
00018 
00019 
00020   Permission to use, copy, modify and distribute this software
00021   and its documentation for educational, research and non-profit
00022   purposes, without fee, and without a written agreement is
00023   hereby granted, provided that the above copyright notice and
00024   the following three paragraphs appear in all copies.
00025 
00026   THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY
00027   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00028   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029   PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
00030   BASIS, AND THE UNIVERSITY OF NORTH CAROLINA HAS NO OBLIGATION
00031   TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
00032   MODIFICATIONS.
00033 
00034 
00035    --------------------------------- 
00036   |Please send all BUG REPORTS to:  |
00037   |                                 |
00038   |   geom@cs.unc.edu               |
00039   |                                 |
00040    ---------------------------------
00041   
00042      
00043   The authors may be contacted via:
00044 
00045   US Mail:  A. Pattekar/J. Cohen/T. Hudson/S. Gottschalk/M. Lin/D. Manocha
00046             Department of Computer Science
00047             Sitterson Hall, CB #3175
00048             University of N. Carolina
00049             Chapel Hill, NC 27599-3175
00050             
00051   Phone:    (919)962-1749
00052             
00053   EMail:    geom@cs.unc.edu
00054 
00055 \************************************************************************/
00056 
00057 
00058 /************************************************************************\
00059 Filename: NBody.H
00060 --
00061 Description: This file declares the class NBody.
00062 
00063 \************************************************************************/
00064 
00065 #ifndef NBODY_H
00066 #define NBODY_H
00067 
00068 #include "RAPID.H"
00069 #include "AABB.H"
00070 #include "EndPoint.H"
00071 #include "PairData.H"
00072 
00073 /************************************************************************\
00074 Class: NBody
00075 --
00076 Description: The class NBody forms the core of VCollide. It
00077              maintains a set of three linked lists and keeps
00078              updating them using the sweep and prune
00079              algorithm. At any point in execution, the class
00080              NBody maintains a set of pairs of objects whose
00081              AABBs overlap. VCollide uses this set while making
00082              collision calls to RAPID. In general, this set would
00083              be very small compared to the n(n-1)/2 possible
00084              pairs.
00085 
00086 \************************************************************************/
00087 
00088 
00089 
00090 class NBody
00091 {
00092 private:
00093 
00094   EndPoint *elist[3];  //pointers to the three linked lists, one for
00095                        //each axis.
00096   int      size;       //the size of dynamic array - AABB_arr
00097   AABB     **AABB_arr; //AABB_arr points to a dynamic array of pointers.
00098                        //Element at index "i" in this array points to an
00099                        //AABB corresponding to the object with id = i. If
00100                        //this object doesn't exist, then the pointer is NULL.
00101   
00102   
00103   int overlaps(AABB *obj1, AABB *obj2);   //to check if two AABBs overlap.
00104   
00105   void add_overlap_pair(int id1, int id2) //add a pair to the set of
00106     {                                     //overlapping pairs.
00107       if (id1 != id2)
00108         overlapping_pairs.AddPair(id1, id2);
00109     }
00110   
00111   void del_overlap_pair(int id1, int id2) //delete a pair from the set.
00112     {
00113       if (id1 != id2)
00114         overlapping_pairs.DelPair(id1, id2);
00115     }
00116   
00117 public:  
00118   PairData overlapping_pairs; //at any instance during the execution of the
00119                               //program, overlapping_pairs contains the set
00120                               //of pairs of ids whose AABBs overlap.
00121 
00122   NBody();                    //constructor.
00123   ~NBody();                   //destructor.
00124   
00125   void AddObject(int id, RAPID_model *b); //add an object to the NBody data
00126                                           //structure.
00127   void UpdateTrans(int id, double trans[][4]); //update the current position
00128                                                //and orientation of the object.
00129   void DeleteObject(int id);  //delete the object from the data structure.
00130   
00131 };
00132 
00133 #endif  /* NBODY_H */

Generated on Thu Dec 1 10:13:39 2005 for COME - Biomechanical Joint Model by  doxygen 1.4.5