VolumeSensor.h

Go to the documentation of this file.
00001 /*************************************************************************
00002  *                                                                       *
00003  * Open Physics Abstraction Layer                                        *
00004  * Copyright (C) 2004-2005                                               *
00005  * Alan Fischer  alan.fischer@gmail.com                                  *
00006  * Andres Reinot  andres@reinot.com                                      *
00007  * Tyler Streeter  tylerstreeter@gmail.com                               *
00008  * All rights reserved.                                                  *
00009  * Web: opal.sourceforge.net                                             *
00010  *                                                                       *
00011  * This library is free software; you can redistribute it and/or         *
00012  * modify it under the terms of EITHER:                                  *
00013  *   (1) The GNU Lesser General Public License as published by the Free  *
00014  *       Software Foundation; either version 2.1 of the License, or (at  *
00015  *       your option) any later version. The text of the GNU Lesser      *
00016  *       General Public License is included with this library in the     *
00017  *       file license-LGPL.txt.                                          *
00018  *   (2) The BSD-style license that is included with this library in     *
00019  *       the file license-BSD.txt.                                       *
00020  *                                                                       *
00021  * This library is distributed in the hope that it will be useful,       *
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00024  * license-LGPL.txt and license-BSD.txt for more details.                *
00025  *                                                                       *
00026  *************************************************************************/
00027 
00028 #ifndef OPAL_VOLUME_SENSOR_H
00029 #define OPAL_VOLUME_SENSOR_H
00030 
00031 #include "Defines.h"
00032 #include "Sensor.h"
00033 #include "VolumeSensorData.h"
00034 
00035 namespace opal
00036 {
00037         class Simulator;
00038 
00041         struct VolumeQueryResult
00042         {
00043                 OPAL_DECL VolumeQueryResult()
00044                 {
00045                 }
00046 
00048                 OPAL_DECL VolumeQueryResult(const VolumeQueryResult& result)
00049                 {
00050                         (*this) = result;
00051                 }
00052 
00053                 OPAL_DECL ~VolumeQueryResult()
00054                 {
00055                         internal_clearSolids();
00056                 }
00057 
00059                 OPAL_DECL void OPAL_CALL operator=(
00060                         const VolumeQueryResult& result)
00061                 {
00062                         unsigned int i=0;
00063                         for (i=0; i<result.mSolidList.size(); ++i)
00064                         {
00065                                 mSolidList.push_back(result.mSolidList[i]);
00066                         }
00067                 }
00068 
00070                 OPAL_DECL void OPAL_CALL internal_addSolid(Solid* s)
00071                 {
00072                         assert(s);
00073                         mSolidList.push_back(s);
00074                 }
00075 
00077                 OPAL_DECL unsigned int OPAL_CALL getNumSolids()const
00078                 {
00079                         return (unsigned int)(mSolidList.size());
00080                 }
00081 
00082                 OPAL_DECL Solid* OPAL_CALL getSolid(unsigned int i)const
00083                 {
00084                         return mSolidList.at(i);
00085                 }
00086 
00088                 OPAL_DECL void OPAL_CALL internal_clearSolids()
00089                 {
00090                         mSolidList.clear();
00091                 }
00092 
00094                 OPAL_DECL void OPAL_CALL internal_removeSolid(const Solid* s)
00095                 {
00096                         for(size_t i = 0; i<mSolidList.size(); ++i)
00097                         {
00098                                 if(mSolidList[i] == s)
00099                                 {
00100                                         mSolidList[i] = mSolidList.back();
00101                                         mSolidList.pop_back();
00102                                         return;
00103                                 }
00104                         }
00105                 }
00106 
00107         private:
00109                 std::vector<Solid*> mSolidList;
00110         };
00111 
00117         class VolumeSensor : public Sensor
00118         {
00119         public:
00120                 VolumeSensor(Simulator* s);
00121 
00122                 virtual ~VolumeSensor();
00123 
00125                 virtual void OPAL_CALL init(const VolumeSensorData& data);
00126 
00128                 virtual const VolumeSensorData& OPAL_CALL getData()const;
00129 
00135                 virtual const VolumeQueryResult& OPAL_CALL queryVolume(
00136                         Solid* volume);
00137 
00138                 virtual void OPAL_CALL setEnabled(bool e);
00139 
00140                 virtual bool OPAL_CALL isEnabled()const;
00141 
00142                 virtual void OPAL_CALL setTransform(const Matrix44r& t);
00143 
00144                 virtual const Matrix44r& OPAL_CALL getTransform()const;
00145 
00146                 virtual SensorType OPAL_CALL getType()const;
00147 
00148                 virtual void OPAL_CALL setName(const std::string& name);
00149 
00150                 virtual const std::string& OPAL_CALL getName()const;
00151 
00152                 virtual void OPAL_CALL internal_update();
00153 
00154                 virtual bool OPAL_CALL internal_dependsOnSolid(Solid* s);
00155 
00156         protected:
00158                 VolumeSensorData mData;
00159 
00162                 Simulator* mSim;
00163 
00164         private:
00165         };
00166 }
00167 
00168 #endif
00169 

Generated on Tue May 16 17:49:53 2006 for OPAL by  doxygen 1.4.6-NO