[Opal-commits] opal/src BlueprintInstance.cpp,1.2,1.3 BlueprintInstance.h,1.2,1.3 Simulator.cpp,1.40
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-03-03 04:40:08
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16484/src Modified Files: BlueprintInstance.cpp BlueprintInstance.h Simulator.cpp Simulator.h Log Message: added the ability to loop through a BlueprintInstance's objects Index: BlueprintInstance.h =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintInstance.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BlueprintInstance.h 26 Feb 2005 10:22:23 -0000 1.2 --- BlueprintInstance.h 3 Mar 2005 04:39:55 -0000 1.3 *************** *** 39,45 **** /// After instantiating a Blueprint, this container class holds ! /// pointers to the objects in the Blueprint with names; objects ! /// without names cannot be added. Pointers to specific objects ! /// can then be requested by name. class BlueprintInstance { --- 39,46 ---- /// After instantiating a Blueprint, this container class holds ! /// pointers to the objects in the Blueprint with names. Pointers ! /// to specific objects can then be requested in two ways: 1) by name, ! /// which is useful for finding a specific object, or 2) by index, ! /// which is useful for interating through every object. class BlueprintInstance { *************** *** 69,86 **** const std::string& name)const; ! /// Adds a new Solid pointer. If the pointer is NULL or the ! /// object's name is an empty string, this will do nothing. OPAL_DECL virtual void OPAL_CALL internal_addSolid(Solid* s); ! /// Adds a new Joint pointer. If the pointer is NULL or the ! /// object's name is an empty string, this will do nothing. OPAL_DECL virtual void OPAL_CALL internal_addJoint(Joint* j); ! /// Adds a new Motor pointer. If the pointer is NULL or the ! /// object's name is an empty string, this will do nothing. OPAL_DECL virtual void OPAL_CALL internal_addMotor(Motor* m); ! /// Adds a new Sensor pointer. If the pointer is NULL or the ! /// object's name is an empty string, this will do nothing. OPAL_DECL virtual void OPAL_CALL internal_addSensor(Sensor* s); --- 70,115 ---- const std::string& name)const; ! /// Returns the number of Solids in this BlueprintInstance. ! OPAL_DECL virtual int OPAL_CALL getNumSolids()const; ! ! /// Returns the number of Joints in this BlueprintInstance. ! OPAL_DECL virtual int OPAL_CALL getNumJoints()const; ! ! /// Returns the number of Motors in this BlueprintInstance. ! OPAL_DECL virtual int OPAL_CALL getNumMotors()const; ! ! /// Returns the number of Sensors in this BlueprintInstance. ! OPAL_DECL virtual int OPAL_CALL getNumSensors()const; ! ! /// Finds a Solid by index and returns its pointer. ! OPAL_DECL virtual Solid* OPAL_CALL getSolid(unsigned int i)const; ! ! /// Finds a Joint by index and returns its pointer. ! OPAL_DECL virtual Joint* OPAL_CALL getJoint(unsigned int i)const; ! ! /// Finds a Motor by index and returns its pointer. ! OPAL_DECL virtual Motor* OPAL_CALL getMotor(unsigned int i)const; ! ! /// Finds a Sensor by index and returns its pointer. ! OPAL_DECL virtual Sensor* OPAL_CALL getSensor(unsigned int i)const; ! ! /// Adds a new Solid pointer to the list. If the pointer is ! /// non-NULL and the object's name is not an empty string, this ! /// also adds the pointer to the Solid map. OPAL_DECL virtual void OPAL_CALL internal_addSolid(Solid* s); ! /// Adds a new Joint pointer. If the pointer is ! /// non-NULL and the object's name is not an empty string, this ! /// also adds the pointer to the Joint map. OPAL_DECL virtual void OPAL_CALL internal_addJoint(Joint* j); ! /// Adds a new Motor pointer. If the pointer is ! /// non-NULL and the object's name is not an empty string, this ! /// also adds the pointer to the Motor map. OPAL_DECL virtual void OPAL_CALL internal_addMotor(Motor* m); ! /// Adds a new Sensor pointer. If the pointer is ! /// non-NULL and the object's name is not an empty string, this ! /// also adds the pointer to the Sensor map. OPAL_DECL virtual void OPAL_CALL internal_addSensor(Sensor* s); *************** *** 97,100 **** --- 126,141 ---- /// Map of Sensor names to Sensor pointers. std::map<std::string, Sensor*> mSensorMap; + + /// List of Solid pointers. + std::vector<Solid*> mSolidList; + + /// List of Joint pointers. + std::vector<Joint*> mJointList; + + /// List of Motor pointers. + std::vector<Motor*> mMotorList; + + /// List of Sensor pointers. + std::vector<Sensor*> mSensorList; }; } Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Simulator.cpp 2 Mar 2005 05:30:32 -0000 1.40 --- Simulator.cpp 3 Mar 2005 04:39:55 -0000 1.41 *************** *** 377,384 **** solidList.push_back(s); ! if (!s->getName().empty()) ! { ! instance.internal_addSolid(s); ! } } --- 377,382 ---- solidList.push_back(s); ! // Add the Solid to the BlueprintInstance. ! instance.internal_addSolid(s); } *************** *** 412,419 **** jointList.push_back(j); ! if (!j->getName().empty()) ! { ! instance.internal_addJoint(j); ! } } --- 410,415 ---- jointList.push_back(j); ! // Add the Joint to the BlueprintInstance. ! instance.internal_addJoint(j); } *************** *** 492,499 **** } ! if (!m->getName().empty()) ! { ! instance.internal_addMotor(m); ! } } --- 488,493 ---- } ! // Add the Motor to the BlueprintInstance. ! instance.internal_addMotor(m); } *************** *** 516,523 **** // } ! // if (!s->getName().empty()) ! // { ! // instance.internal_addSensor(s); ! // } //} --- 510,515 ---- // } ! // // Add the Sensor to the BlueprintInstance. ! // instance.internal_addSensor(s); //} Index: BlueprintInstance.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintInstance.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BlueprintInstance.cpp 26 Feb 2005 10:22:23 -0000 1.2 --- BlueprintInstance.cpp 3 Mar 2005 04:39:55 -0000 1.3 *************** *** 44,47 **** --- 44,52 ---- mMotorMap.clear(); mSensorMap.clear(); + + mSolidList.clear(); + mJointList.clear(); + mMotorList.clear(); + mSensorList.clear(); } *************** *** 102,107 **** --- 107,154 ---- } + int BlueprintInstance::getNumSolids()const + { + return (int)(mSolidList.size()); + } + + int BlueprintInstance::getNumJoints()const + { + return (int)(mJointList.size()); + } + + int BlueprintInstance::getNumMotors()const + { + return (int)(mMotorList.size()); + } + + int BlueprintInstance::getNumSensors()const + { + return (int)(mSensorList.size()); + } + + Solid* BlueprintInstance::getSolid(unsigned int i)const + { + return mSolidList.at(i); + } + + Joint* BlueprintInstance::getJoint(unsigned int i)const + { + return mJointList.at(i); + } + + Motor* BlueprintInstance::getMotor(unsigned int i)const + { + return mMotorList.at(i); + } + + Sensor* BlueprintInstance::getSensor(unsigned int i)const + { + return mSensorList.at(i); + } + void BlueprintInstance::internal_addSolid(Solid* s) { + mSolidList.push_back(s); + if (NULL == s) { *************** *** 121,124 **** --- 168,173 ---- void BlueprintInstance::internal_addJoint(Joint* j) { + mJointList.push_back(j); + if (NULL == j) { *************** *** 138,141 **** --- 187,192 ---- void BlueprintInstance::internal_addMotor(Motor* m) { + mMotorList.push_back(m); + if (NULL == m) { *************** *** 155,158 **** --- 206,211 ---- void BlueprintInstance::internal_addSensor(Sensor* s) { + mSensorList.push_back(s); + if (NULL == s) { Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** Simulator.h 2 Mar 2005 05:30:32 -0000 1.76 --- Simulator.h 3 Mar 2005 04:39:56 -0000 1.77 *************** *** 48,52 **** /// A data structure containing information about a specific /// intersection from a ray cast. ! struct RayHit { /// The first Solid hit by the ray. --- 48,52 ---- /// A data structure containing information about a specific /// intersection from a ray cast. ! struct RaycastResult { /// The first Solid hit by the ray. *************** *** 107,111 **** /// A convenient ray casting function. TODO: replace with a /// Sensor. ! virtual RayHit OPAL_CALL shootRay(const Point3r& origin, const Vec3r& dir, real length) = 0; --- 107,111 ---- /// A convenient ray casting function. TODO: replace with a /// Sensor. ! virtual RaycastResult OPAL_CALL shootRay(const Point3r& origin, const Vec3r& dir, real length) = 0; |