[Opal-commits] opal/src BlueprintInstance.cpp,NONE,1.1 BlueprintInstance.h,NONE,1.1 Logger.cpp,NONE,
Status: Inactive
Brought to you by:
tylerstreeter
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5241/src Modified Files: AttractorMotor.cpp AttractorMotor.h AttractorMotorData.h Blueprint.cpp Blueprint.h BlueprintManager.cpp BlueprintManager.h Defines.h GearedMotor.cpp GearedMotor.h GearedMotorData.h Joint.cpp Joint.h JointData.h Motor.cpp Motor.h MotorData.h SConscript Sensor.cpp Sensor.h SensorData.h ServoMotor.cpp ServoMotor.h ServoMotorData.h Simulator.cpp Simulator.h Solid.cpp Solid.h SolidData.h SpringMotor.cpp SpringMotor.h SpringMotorData.h ThrusterMotor.cpp ThrusterMotor.h ThrusterMotorData.h opal.h Added Files: BlueprintInstance.cpp BlueprintInstance.h Logger.cpp Logger.h SolidData.cpp Log Message: updated XML parsing to reflect new object creation method Index: Sensor.h =================================================================== RCS file: /cvsroot/opal/opal/src/Sensor.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Sensor.h 21 Feb 2005 15:54:39 -0000 1.6 --- Sensor.h 25 Feb 2005 06:40:26 -0000 1.7 *************** *** 45,54 **** virtual ~Sensor(); - /// Returns true if the Sensor is enabled. - virtual bool OPAL_CALL isEnabled()const; - /// Sets whether the Sensor can update its measurements. If the /// Sensor has not yet been initialized, this will have no effect. ! virtual void OPAL_CALL setEnabled(bool e); /// Set the user data pointer to some external data. The user data --- 45,54 ---- virtual ~Sensor(); /// Sets whether the Sensor can update its measurements. If the /// Sensor has not yet been initialized, this will have no effect. ! virtual void OPAL_CALL setEnabled(bool e) = 0; ! ! /// Returns true if the Sensor is enabled. ! virtual bool OPAL_CALL isEnabled()const = 0; /// Set the user data pointer to some external data. The user data *************** *** 60,63 **** --- 60,69 ---- virtual void* OPAL_CALL getUserData(); + /// Sets the Sensor's name. + virtual void OPAL_CALL setName(const std::string& name) = 0; + + /// Returns the Sensor's name. + virtual const std::string& OPAL_CALL getName()const = 0; + /// Called regularly to update the Sensor. This does nothing if the /// Sensor is disabled. *************** *** 69,73 **** protected: /// True if the Sensor is enabled. ! bool mEnabled; /// Pointer to user data. This is totally user-managed (i.e. OPAL --- 75,79 ---- protected: /// True if the Sensor is enabled. ! //bool mEnabled; /// Pointer to user data. This is totally user-managed (i.e. OPAL Index: BlueprintManager.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintManager.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** BlueprintManager.cpp 23 Feb 2005 03:58:23 -0000 1.25 --- BlueprintManager.cpp 25 Feb 2005 06:40:26 -0000 1.26 *************** *** 27,30 **** --- 27,37 ---- #include "BlueprintManager.h" + #include "BoxShapeData.h" + #include "SphereShapeData.h" + #include "CapsuleShapeData.h" + #include "PlaneShapeData.h" + #include "RayShapeData.h" + #include "MotorData.h" + #include "SensorData.h" [...1616 lines suppressed...] #endif } - - Blueprint* BlueprintManager::getBlueprint(const std::string& name) - { - if (!blueprintExists(name)) - { - std::cout << "Error in opal::BlueprintManager::getBlueprint: \ - Invalid blueprint requested" - << std::endl; - return NULL; - } - else - { - return mBlueprintMap[name]; - } - } } } --- 944,947 ---- Index: opal.h =================================================================== RCS file: /cvsroot/opal/opal/src/opal.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** opal.h 23 Feb 2005 03:58:23 -0000 1.16 --- opal.h 25 Feb 2005 06:40:26 -0000 1.17 *************** *** 59,62 **** --- 59,73 ---- /// Creates a Simulator. OPAL_EXPORT Simulator* OPAL_CALL createSimulator(); + + /// Loads a Blueprint from an OPAL XML file. + OPAL_EXPORT void OPAL_CALL loadFile(Blueprint& bp, + const std::string& filename); + { + BlueprintManager::instance().loadFile(bp, filename); + } + + /// Saves a Blueprint in an OPAL XML file. + //OPAL_EXPORT void OPAL_CALL saveFile(const Blueprint& bp, + // const std::string& filename); } Index: Joint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.h,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** Joint.h 23 Feb 2005 04:56:49 -0000 1.55 --- Joint.h 25 Feb 2005 06:40:26 -0000 1.56 *************** *** 76,80 **** /// Returns all data describing the Joint. ! virtual const JointData& OPAL_CALL getJointData(); /// Returns the Joint type. --- 76,86 ---- /// Returns all data describing the Joint. ! virtual const JointData& OPAL_CALL getJointData()const; ! ! /// Sets the Joint's name. ! virtual void OPAL_CALL setName(const std::string& name); ! ! /// Returns the Joint's name. ! virtual const std::string& OPAL_CALL getName()const; /// Returns the Joint type. *************** *** 103,107 **** ///// Returns the limits for the given axis. ! //virtual const JointLimits& OPAL_CALL getLimits(int axisNum); /// Sets the Joint's limit angles in degrees. No limits are applied --- 109,113 ---- ///// Returns the limits for the given axis. ! //virtual const JointLimits& OPAL_CALL getLimits(int axisNum)const; /// Sets the Joint's limit angles in degrees. No limits are applied *************** *** 113,121 **** /// Returns the low limit for a given axis (angle in degrees for /// rotational Joints, distance for linear Joints). ! virtual real OPAL_CALL getLowLimit(int axisNum); /// Returns the high limit for a given axis (angle in degrees for /// rotational Joints, distance for linear Joints). ! virtual real OPAL_CALL getHighLimit(int axisNum); /// Sets the hardness for the given axis' limits. Hardness --- 119,127 ---- /// Returns the low limit for a given axis (angle in degrees for /// rotational Joints, distance for linear Joints). ! virtual real OPAL_CALL getLowLimit(int axisNum)const; /// Returns the high limit for a given axis (angle in degrees for /// rotational Joints, distance for linear Joints). ! virtual real OPAL_CALL getHighLimit(int axisNum)const; /// Sets the hardness for the given axis' limits. Hardness *************** *** 126,130 **** /// Returns the hardness for the given axis' limits. ! virtual real OPAL_CALL getLimitHardness(int axisNum); /// Sets the bounciness for the given axis' limits. Bounciness --- 132,136 ---- /// Returns the hardness for the given axis' limits. ! virtual real OPAL_CALL getLimitHardness(int axisNum)const; /// Sets the bounciness for the given axis' limits. Bounciness *************** *** 135,139 **** /// Returns the bounciness for the given axis' limits. ! virtual real OPAL_CALL getLimitBounciness(int axisNum); /// Returns the current state (angle in degrees for rotational --- 141,145 ---- /// Returns the bounciness for the given axis' limits. ! virtual real OPAL_CALL getLimitBounciness(int axisNum)const; /// Returns the current state (angle in degrees for rotational *************** *** 168,172 **** /// Returns the anchor point. ! virtual const Point3r& OPAL_CALL getAnchor(); /// Returns the number of axes used by this Joint. --- 174,178 ---- /// Returns the anchor point. ! virtual const Point3r& OPAL_CALL getAnchor()const; /// Returns the number of axes used by this Joint. Index: SConscript =================================================================== RCS file: /cvsroot/opal/opal/src/SConscript,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SConscript 22 Feb 2005 04:28:11 -0000 1.9 --- SConscript 25 Feb 2005 06:40:26 -0000 1.10 *************** *** 5,8 **** --- 5,9 ---- headers = Split(""" AttractorMotor.h + AttractorMotorData.h Blueprint.h BlueprintManager.h *************** *** 12,19 **** --- 13,24 ---- EventHandler.h GearedMotor.h + GearedMotorData.h Joint.h + JointData.h + Logger.h Matrix44r.h MeshShapeData.h Motor.h + MotorData.h opal.h OpalMath.h *************** *** 25,29 **** --- 30,36 ---- RayShapeData.h Sensor.h + SensorData.h ServoMotor.h + ServoMotorData.h ShapeData.h Simulator.h *************** *** 34,38 **** --- 41,47 ---- SphereShapeData.h SpringMotor.h + SpringMotorData.h ThrusterMotor.h + ThrusterMotorData.h Vec3r.h """) *************** *** 45,48 **** --- 54,58 ---- GearedMotor.cpp Joint.cpp + Logger.cpp Motor.cpp Sensor.cpp *************** *** 50,53 **** --- 60,64 ---- Simulator.cpp Solid.cpp + SolidData.cpp SpringMotor.cpp ThrusterMotor.cpp --- NEW FILE: SolidData.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #include "SolidData.h" #include "BoxShapeData.h" #include "SphereShapeData.h" #include "CapsuleShapeData.h" #include "PlaneShapeData.h" #include "RayShapeData.h" #include "MeshShapeData.h" namespace opal { SolidData::SolidData() { enabled = defaults::solid::enabled; name = ""; sleeping = defaults::solid::sleeping; sleepiness = defaults::solid::sleepiness; isStatic = defaults::solid::isStatic; // Leave the transform as an identity matrix. // "globalLinearVel" is already initialized in its constructor. // "globalAngularVel" is already initialized in its constructor. linearDamping = defaults::linearDamping; angularDamping = defaults::angularDamping; // The Shape list doesn't need to be initialized. } SolidData::SolidData(const SolidData& data) { (*this) = data; } SolidData::~SolidData() { destroyShapes(); } void SolidData::addShape(const ShapeData& data) { ShapeData* newShape = NULL; switch(data.getType()) { case BOX_SHAPE: { newShape = new BoxShapeData((BoxShapeData&)data); break; } case SPHERE_SHAPE: { newShape = new SphereShapeData((SphereShapeData&)data); break; } case CAPSULE_SHAPE: { newShape = new CapsuleShapeData((CapsuleShapeData&)data); break; } case PLANE_SHAPE: { newShape = new PlaneShapeData((PlaneShapeData&)data); break; } case RAY_SHAPE: { newShape = new RayShapeData((RayShapeData&)data); break; } case MESH_SHAPE: { newShape = new MeshShapeData((MeshShapeData&)data); break; } default: assert(false); } mShapes.push_back(newShape); } int SolidData::getNumShapes()const { return (int)(mShapes.size()); } ShapeData* SolidData::getShapeData(unsigned int i)const { return mShapes.at(i); } void SolidData::destroyShapes() { while (!mShapes.empty()) { delete mShapes.back(); mShapes.pop_back(); } } void SolidData::operator=(const SolidData& data) { enabled = data.enabled; name = data.name; sleeping = data.sleeping; sleepiness = data.sleepiness; isStatic = data.isStatic; transform = data.transform; globalLinearVel = data.globalLinearVel; globalAngularVel = data.globalAngularVel; linearDamping = data.linearDamping; angularDamping = data.angularDamping; // First remove the old Shapes. destroyShapes(); // Allocate copies of the new Shapes. for (unsigned int i=0; i<data.mShapes.size(); ++i) { addShape(*(data.mShapes[i])); } } } --- NEW FILE: Logger.h --- #ifndef OPAL_LOGGER_H #define OPAL_LOGGER_H #include <iomanip> #include <stdlib.h> #include <string> #include <ostream> #include <iostream> #include <map> #include <iosfwd> #include <stdexcept> namespace opal { /// This class is used to log any events, errors, or warnings that may /// come up. Calls to this class should replace all cout << statements /// in the form: Logger::stream("myStreamName") << ... /// where myStreamName was registered as a cout stream or file stream /// using the setStream function. class Logger { public: Logger(); ~Logger(); /// Register a new stream for later use. static void setStream(const std::string& name, std::ostream *stream, const std::string& prefix="", char mark='\0'); //static void silenceStream(const std::string& name); //static void unsilenceStream(const std::string& name); static std::ostream &stream(const std::string& name); private: struct Stream { std::ostream *nullStream; std::ostream *stream; bool silent; char mark; std::string prefix; }; static void init(); //static bool mInitCalled; static std::map<std::string, Stream> mStreams; }; } #endif Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** Simulator.h 23 Feb 2005 06:35:46 -0000 1.74 --- Simulator.h 25 Feb 2005 06:40:26 -0000 1.75 *************** *** 44,47 **** --- 44,49 ---- namespace opal { + class BlueprintInstance; + /// A data structure containing information about a specific /// intersection from a ray cast. *************** *** 62,107 **** }; - /// Contains maps of string names to object pointers for Solids, Joints, - /// Motors, and Sensors. - struct BlueprintInstance - { - ~BlueprintInstance() - { - solidMap.clear(); - jointMap.clear(); - } - - /// Convenience function for finding a Solid pointer by name. - /// Returns NULL if the pointer is not found. - Solid* getSolid(const std::string& name) - { - if (solidMap.end() == solidMap.find(name)) - { - return NULL; - } - else - { - return solidMap[name]; - } - } - - /// Convenience function for finding a Joint pointer by name. - /// Returns NULL if the pointer is not found. - Joint* getJoint(const std::string& name) - { - if (jointMap.end() == jointMap.find(name)) - { - return NULL; - } - else - { - return jointMap[name]; - } - } - - std::map<std::string, Solid*> solidMap; - std::map<std::string, Joint*> jointMap; - }; - /// A Simulator is an environment that contains simulated objects. /// It performs collision detection and physical simulation. It is --- 64,67 ---- *************** *** 128,140 **** virtual void OPAL_CALL setStepSize(real stepSize); ! //virtual NamedObjectCollection OPAL_CALL instantiateBlueprint( ! // const Blueprint& bp); /// A convenient volume collision check function. TODO: replace /// with a Sensor. TODO: the vector pointer here is bad because /// memory is allocated within the DLL and deallocated on the ! /// user's side ! virtual void OPAL_CALL collide(const Solid* solid, ! std::vector<Solid*>* solids) = 0; /// A convenient ray casting function. TODO: replace with a --- 88,103 ---- virtual void OPAL_CALL setStepSize(real stepSize); ! /// Creates instances of all objects in a Blueprint and fills the ! /// given BlueprintInstance with pointers of the named objects. ! virtual void OPAL_CALL instantiateBlueprint( ! BlueprintInstance& instance, const Blueprint& bp); /// A convenient volume collision check function. TODO: replace /// with a Sensor. TODO: the vector pointer here is bad because /// memory is allocated within the DLL and deallocated on the ! /// user's side; make a VolumeCollisionReport object with an ! /// add function ! //virtual void OPAL_CALL collide(const Solid* solid, ! // std::vector<Solid*>* solids) = 0; /// A convenient ray casting function. TODO: replace with a *************** *** 149,155 **** virtual Vec3r OPAL_CALL getGravity()const = 0; ! virtual void OPAL_CALL setSleepiness(real value); ! virtual real OPAL_CALL getSleepiness()const; /// Sets the accuracy level used by the physics engine's constraint --- 112,118 ---- virtual Vec3r OPAL_CALL getGravity()const = 0; ! //virtual void OPAL_CALL setDefaultSleepiness(real value); ! //virtual real OPAL_CALL getDefaultSleepiness()const; /// Sets the accuracy level used by the physics engine's constraint *************** *** 204,208 **** /// Returns all Solids in the Simulator. ! virtual const std::vector<Solid*>& OPAL_CALL getSolids()const; // JOINTS --- 167,171 ---- /// Returns all Solids in the Simulator. ! //virtual const std::vector<Solid*>& OPAL_CALL getSolids()const; // JOINTS *************** *** 309,313 **** // ranges from 0.0 to 1.0; TODO: make this per-Solid ! real mSleepiness; /// The accuracy level used internally by the physics engine's --- 272,276 ---- // ranges from 0.0 to 1.0; TODO: make this per-Solid ! //real mSleepiness; /// The accuracy level used internally by the physics engine's Index: Sensor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Sensor.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Sensor.cpp 21 Feb 2005 15:54:38 -0000 1.3 --- Sensor.cpp 25 Feb 2005 06:40:26 -0000 1.4 *************** *** 32,36 **** Sensor::Sensor() { ! mEnabled = false; mInitCalled = false; setUserData(NULL); --- 32,37 ---- Sensor::Sensor() { ! // "mData" is initialized in its own constructor. ! //mEnabled = false; mInitCalled = false; setUserData(NULL); *************** *** 41,59 **** } - bool Sensor::isEnabled()const - { - return mEnabled; - } - - void Sensor::setEnabled(bool e) - { - if (!mInitCalled) - { - return; - } - - mEnabled = e; - } - void Sensor::setUserData(void* data) { --- 42,45 ---- Index: GearedMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/GearedMotor.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GearedMotor.h 23 Feb 2005 03:58:23 -0000 1.6 --- GearedMotor.h 25 Feb 2005 06:40:26 -0000 1.7 *************** *** 62,66 **** /// Returns all data describing the Motor. ! virtual const GearedMotorData& OPAL_CALL getMotorData(); virtual bool OPAL_CALL isEnabled()const; --- 62,70 ---- /// Returns all data describing the Motor. ! virtual const GearedMotorData& OPAL_CALL getMotorData()const; ! ! virtual void OPAL_CALL setName(const std::string& name); ! ! virtual const std::string& OPAL_CALL getName()const; virtual bool OPAL_CALL isEnabled()const; Index: GearedMotorData.h =================================================================== RCS file: /cvsroot/opal/opal/src/GearedMotorData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GearedMotorData.h 23 Feb 2005 03:58:23 -0000 1.1 --- GearedMotorData.h 25 Feb 2005 06:40:26 -0000 1.2 *************** *** 64,67 **** --- 64,68 ---- mType = data.mType; enabled = data.enabled; + name = data.name; joint = data.joint; jointAxisNum = data.jointAxisNum; Index: BlueprintManager.h =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintManager.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** BlueprintManager.h 22 Feb 2005 01:25:55 -0000 1.14 --- BlueprintManager.h 25 Feb 2005 06:40:26 -0000 1.15 *************** *** 46,80 **** virtual ~BlueprintManager(); ! //virtual void OPAL_CALL loadFile(const std::string& filename); ! virtual void OPAL_CALL addBlueprint(Blueprint* bp); ! virtual Blueprint* OPAL_CALL getBlueprint( const std::string& filename); ! virtual bool OPAL_CALL blueprintExists(const std::string& name); ! private: ! //SolidData loadSolid(const TiXmlNode* nodePtr, ! // const std::string& filename); ! JointData loadJoint(const TiXmlNode* nodePtr, ! const std::string& filename); ! Matrix44r loadOffset(const TiXmlNode* nodePtr, const std::string& filename); ! //ShapeData loadShape(const TiXmlNode* nodePtr, ! // const std::string& filename); ! // helper function; returns false if the attribute doesn't exist real getAttributeReal(const TiXmlNode* nodePtr, ! const std::string& name); ! // helper function; returns false if the attribute doesn't exist std::string getAttributeString(const TiXmlNode* nodePtr, ! const std::string& name); ! ! std::map<std::string, Blueprint*> mBlueprintMap; }; } --- 46,111 ---- virtual ~BlueprintManager(); ! /// Loads a Blueprint from an OPAL XML file. The file should ! /// contain a single OpalBlueprint element (additional ones ! /// will be ignored). The Blueprint can contain any number ! /// of Solids, Joints, Motors, and Sensors. Most of the ! /// object parameters are optional, in which case the usual, ! /// default values will be used. The only required ! /// parameters are references to other objects (i.e. the ! /// "References" elements in an XML file. For example, ! /// a Joint refers to two Solids; if either of those Solids ! /// are not in the file, the Joint will be ignored. For a ! /// particular element, all attributes are always required. ! virtual void OPAL_CALL loadFile(Blueprint& bp, ! const std::string& filename); ! /// Saves a Blueprint to an OPAL XML file. ! //virtual void OPAL_CALL saveFile(const Blueprint& bp, ! // const std::string& filename); ! private: ! /// Helper function for parsing Solid XML elements. Allocates ! /// and returns a pointer to a new SolidData object. Returns ! /// NULL if the element could not be loaded. ! SolidData* loadSolid(const TiXmlNode* nodePtr, const std::string& filename); ! /// Helper function for parsing Joint XML elements. Allocates ! /// and returns a pointer to a new JointData object. Returns ! /// NULL if the element could not be loaded. ! JointData* loadJoint(const TiXmlNode* nodePtr, ! const Blueprint& bp, const std::string& filename); ! /// Helper function for parsing Motor XML elements. Allocates ! /// and returns a pointer to a new MotorData object. Returns ! /// NULL if the element could not be loaded. ! MotorData* loadMotor(const TiXmlNode* nodePtr, ! const Blueprint& bp, const std::string& filename); ! /// Helper function for parsing Sensor XML elements. Allocates ! /// and returns a pointer to a new SensorData object. Returns ! /// NULL if the element could not be loaded. ! SensorData* loadSensor(const TiXmlNode* nodePtr, ! const Blueprint& bp, const std::string& filename); ! /// Helper function for parsing Shape XML elements. Allocates ! /// and returns a pointer to a new ShapeData object. Returns ! /// NULL if the element could not be loaded. ! ShapeData* loadShape(const TiXmlNode* nodePtr, const std::string& filename); ! /// Helper function for parsing offset XML elements. ! void loadOffset(Matrix44r& offset, const TiXmlNode* nodePtr, ! const std::string& filename); ! /// Helper function; returns 0 if the attribute doesn't ! /// exist. real getAttributeReal(const TiXmlNode* nodePtr, ! const std::string& name)const; ! /// Helper function; returns false if the attribute doesn't ! /// exist. std::string getAttributeString(const TiXmlNode* nodePtr, ! const std::string& name)const; }; } Index: SpringMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/SpringMotor.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SpringMotor.h 23 Feb 2005 03:58:23 -0000 1.6 --- SpringMotor.h 25 Feb 2005 06:40:26 -0000 1.7 *************** *** 56,60 **** /// Returns all data describing the Motor. ! virtual const SpringMotorData& OPAL_CALL getMotorData(); virtual bool OPAL_CALL isEnabled()const; --- 56,64 ---- /// Returns all data describing the Motor. ! virtual const SpringMotorData& OPAL_CALL getMotorData()const; ! ! virtual void OPAL_CALL setName(const std::string& name); ! ! virtual const std::string& OPAL_CALL getName()const; virtual bool OPAL_CALL isEnabled()const; *************** *** 79,86 **** /// Returns the damping constant for linear mode. ! virtual real OPAL_CALL getLinearKd(); /// Returns the spring constant for linear mode. ! virtual real OPAL_CALL getLinearKs(); /// Sets the damping constant for angular mode. --- 83,90 ---- /// Returns the damping constant for linear mode. ! virtual real OPAL_CALL getLinearKd()const; /// Returns the spring constant for linear mode. ! virtual real OPAL_CALL getLinearKs()const; /// Sets the damping constant for angular mode. *************** *** 91,98 **** /// Returns the damping constant for angular mode. ! virtual real OPAL_CALL getAngularKd(); /// Returns the spring constant for angular mode. ! virtual real OPAL_CALL getAngularKs(); virtual void OPAL_CALL internal_update(); --- 95,102 ---- /// Returns the damping constant for angular mode. ! virtual real OPAL_CALL getAngularKd()const; /// Returns the spring constant for angular mode. ! virtual real OPAL_CALL getAngularKs()const; virtual void OPAL_CALL internal_update(); Index: ServoMotorData.h =================================================================== RCS file: /cvsroot/opal/opal/src/ServoMotorData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ServoMotorData.h 23 Feb 2005 03:58:23 -0000 1.1 --- ServoMotorData.h 25 Feb 2005 06:40:26 -0000 1.2 *************** *** 78,81 **** --- 78,82 ---- mType = data.mType; enabled = data.enabled; + name = data.name; joint = data.joint; mode = data.mode; Index: SensorData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SensorData.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SensorData.h 23 Feb 2005 04:56:49 -0000 1.2 --- SensorData.h 25 Feb 2005 06:40:26 -0000 1.3 *************** *** 49,52 **** --- 49,54 ---- // class will never be instantiated. mType = VELOCITY_SENSOR; + enabled = defaults::sensor::enabled; + name = ""; } *************** *** 61,64 **** --- 63,72 ---- } + /// True if the Motor is enabled. + bool enabled; + + /// An identifier for the Sensor. + std::string name; + protected: /// The Sensor type. Index: ThrusterMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/ThrusterMotor.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ThrusterMotor.h 23 Feb 2005 03:58:23 -0000 1.6 --- ThrusterMotor.h 25 Feb 2005 06:40:26 -0000 1.7 *************** *** 55,59 **** /// Returns all data describing the Motor. ! virtual const ThrusterMotorData& OPAL_CALL getMotorData(); virtual bool OPAL_CALL isEnabled()const; --- 55,63 ---- /// Returns all data describing the Motor. ! virtual const ThrusterMotorData& OPAL_CALL getMotorData()const; ! ! virtual void OPAL_CALL setName(const std::string& name); ! ! virtual const std::string& OPAL_CALL getName()const; virtual bool OPAL_CALL isEnabled()const; --- NEW FILE: BlueprintInstance.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #include "BlueprintInstance.h" #include "Solid.h" #include "Joint.h" #include "Motor.h" #include "Sensor.h" namespace opal { BlueprintInstance::BlueprintInstance() { } BlueprintInstance::~BlueprintInstance() { mSolidMap.clear(); mJointMap.clear(); mMotorMap.clear(); mSensorMap.clear(); } Solid* BlueprintInstance::getSolid(const std::string& name)const { std::map<std::string, Solid*>::const_iterator iter = mSolidMap.find(name); if (mSolidMap.end() == iter) { return NULL; } else { return (*iter).second; } } Joint* BlueprintInstance::getJoint(const std::string& name)const { std::map<std::string, Joint*>::const_iterator iter = mJointMap.find(name); if (mJointMap.end() == iter) { return NULL; } else { return (*iter).second; } } Motor* BlueprintInstance::getMotor(const std::string& name)const { std::map<std::string, Motor*>::const_iterator iter = mMotorMap.find(name); if (mMotorMap.end() == iter) { return NULL; } else { return (*iter).second; } } Sensor* BlueprintInstance::getSensor(const std::string& name)const { std::map<std::string, Sensor*>::const_iterator iter = mSensorMap.find(name); if (mSensorMap.end() == iter) { return NULL; } else { return (*iter).second; } } void BlueprintInstance::internal_addSolidPtr(Solid* s) { if (NULL == s) { return; } std::string name = s->getName(); if (name.empty()) { return; } mSolidMap[name] = s; } void BlueprintInstance::internal_addJoint(Joint* j) { if (NULL == j) { return; } std::string name = j->getName(); if (name.empty()) { return; } mJointMap[name] = j; } void BlueprintInstance::internal_addMotor(Motor* m) { if (NULL == m) { return; } std::string name = m->getName(); if (name.empty()) { return; } mMotorMap[name] = m; } void BlueprintInstance::internal_addSensor(Sensor* s) { if (NULL == s) { return; } std::string name = s->getName(); if (name.empty()) { return; } mSensorMap[name] = s; } //void Blueprint::addSolid(const SolidData& data) //{ // if (solidExists(data.name)) // { // Logger::stream("warning") << "opal::Blueprint::addSolid: Solid " // << data.name << " already exists in this Blueprint. \ // Ignoring the new one." << std::endl; // } // else // { // SolidData* newData = new SolidData(data); // mSolidList.push_back(newData); // } //} //void Blueprint::addJoint(const JointData& data) //{ // if (jointExists(data.name)) // { // Logger::stream("warning") << "opal::Blueprint::addJoint: Joint " // << data.name << " already exists in this Blueprint. \ // Ignoring the new one." << std::endl; // } // else // { // JointData* newData = new JointData(data); // mJointList.push_back(newData); // } //} //void Blueprint::addMotor(const MotorData& data) //{ // if (motorExists(data.name)) // { // Logger::stream("warning") << "opal::Blueprint::addMotor: Motor " // << data.name << " already exists in this Blueprint. \ // Ignoring the new one." << std::endl; // } // else // { // MotorData* newData = new MotorData(data); // mMotorList.push_back(newData); // } //} //void Blueprint::addSensor(const SensorData& data) //{ // if (sensorExists(data.name)) // { // Logger::stream("warning") << "opal::Blueprint::addSensor: Sensor " // << data.name << " already exists in this Blueprint. \ // Ignoring the new one." << std::endl; // } // else // { // SensorData* newData = new SensorData(data); // mSensorList.push_back(newData); // } //} //bool Blueprint::solidExists(const std::string& name) //{ // /// Ignore empty name strings. // if (name.empty()) // { // return false; // } // std::vector<SolidData*>::iterator iter; // for (iter = mSolidList.begin(); iter != mSolidList.end(); ++iter) // { // if ((*iter)->name == name) // { // return true; // } // } // return false; //} //bool Blueprint::jointExists(const std::string& name) //{ // /// Ignore empty name strings. // if (name.empty()) // { // return false; // } // std::vector<JointData*>::iterator iter; // for (iter = mJointList.begin(); iter != mJointList.end(); ++iter) // { // if ((*iter)->name == name) // { // return true; // } // } // return false; //} //bool Blueprint::motorExists(const std::string& name) //{ // /// Ignore empty name strings. // if (name.empty()) // { // return false; // } // std::vector<MotorData*>::iterator iter; // for (iter = mMotorList.begin(); iter != mMotorList.end(); ++iter) // { // if ((*iter)->name == name) // { // return true; // } // } // return false; //} //bool Blueprint::sensorExists(const std::string& name) //{ // /// Ignore empty name strings. // if (name.empty()) // { // return false; // } // std::vector<SensorData*>::iterator iter; // for (iter = mSensorList.begin(); iter != mSensorList.end(); ++iter) // { // if ((*iter)->name == name) // { // return true; // } // } // return false; //} //int Blueprint::internal_getSolidIndex(const std::string& name)const //{ // if (name.empty()) // { // return -1; // } // for (unsigned int i=0; i<mSolidList.size(); ++i) // { // if (mSolidList[i]->name == name) // { // return (int)i; // } // } // return -1; //} } Index: Joint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Joint.cpp 23 Feb 2005 03:58:23 -0000 1.20 --- Joint.cpp 25 Feb 2005 06:40:26 -0000 1.21 *************** *** 52,60 **** } ! const JointData& Joint::getJointData() { return mData; } JointType Joint::getType()const { --- 52,70 ---- } ! const JointData& Joint::getJointData()const { return mData; } + void Joint::setName(const std::string& name) + { + mData.name = name; + } + + const std::string& Joint::getName()const + { + return mData.name; + } + JointType Joint::getType()const { *************** *** 106,110 **** //} ! //const Joint::JointLimits& getLimits(int axisNum) //{ // assert(axisNum >= 0 && axisNum < mNumAxes); --- 116,120 ---- //} ! //const Joint::JointLimits& getLimits(int axisNum)const //{ // assert(axisNum >= 0 && axisNum < mNumAxes); *************** *** 120,124 **** } ! real Joint::getLowLimit(int axisNum) { assert(axisNum >= 0 && axisNum < mNumAxes); --- 130,134 ---- } ! real Joint::getLowLimit(int axisNum)const { assert(axisNum >= 0 && axisNum < mNumAxes); *************** *** 126,130 **** } ! real Joint::getHighLimit(int axisNum) { assert(axisNum >= 0 && axisNum < mNumAxes); --- 136,140 ---- } ! real Joint::getHighLimit(int axisNum)const { assert(axisNum >= 0 && axisNum < mNumAxes); *************** *** 139,143 **** } ! real Joint::getLimitHardness(int axisNum) { assert(axisNum >= 0 && axisNum < mNumAxes); --- 149,153 ---- } ! real Joint::getLimitHardness(int axisNum)const { assert(axisNum >= 0 && axisNum < mNumAxes); *************** *** 152,156 **** } ! real Joint::getLimitBounciness(int axisNum) { assert(axisNum >= 0 && axisNum < mNumAxes); --- 162,166 ---- } ! real Joint::getLimitBounciness(int axisNum)const { assert(axisNum >= 0 && axisNum < mNumAxes); *************** *** 172,176 **** if (!f.singleStep) { ! f.timeLeft = duration; } --- 182,186 ---- if (!f.singleStep) { ! f.duration = duration; } *************** *** 199,203 **** if (!f.singleStep) { ! f.timeLeft = duration; } --- 209,213 ---- if (!f.singleStep) { ! f.duration = duration; } *************** *** 256,260 **** } ! const Point3r& Joint::getAnchor() { return mData.anchor; --- 266,270 ---- } ! const Point3r& Joint::getAnchor()const { return mData.anchor; *************** *** 310,317 **** switch(mData.breakMode) { ! case UNBREAKABLE: //nothing to do break; ! case THRESHOLD: { if (currentStress >= mData.breakThresh) --- 320,327 ---- switch(mData.breakMode) { ! case UNBREAKABLE_MODE: //nothing to do break; ! case THRESHOLD_MODE: { if (currentStress >= mData.breakThresh) *************** *** 321,325 **** break; } ! case ACCUMULATED: { if (currentStress >= mData.accumThresh) --- 331,335 ---- break; } ! case ACCUMULATED_MODE: { if (currentStress >= mData.accumThresh) Index: Motor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Motor.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Motor.cpp 23 Feb 2005 03:58:23 -0000 1.13 --- Motor.cpp 25 Feb 2005 06:40:26 -0000 1.14 *************** *** 32,36 **** Motor::Motor() { ! //mEnabled = false; mIsCustom = false; mInitCalled = false; --- 32,36 ---- Motor::Motor() { ! // "mData" is initialized in its own constructor. mIsCustom = false; mInitCalled = false; Index: SolidData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SolidData.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SolidData.h 23 Feb 2005 06:35:46 -0000 1.5 --- SolidData.h 25 Feb 2005 06:40:26 -0000 1.6 *************** *** 31,40 **** #include "Defines.h" #include "ShapeData.h" - #include "BoxShapeData.h" - #include "SphereShapeData.h" - #include "CapsuleShapeData.h" - #include "PlaneShapeData.h" - #include "RayShapeData.h" - #include "MeshShapeData.h" namespace opal --- 31,34 ---- *************** *** 44,168 **** { public: ! SolidData() ! { ! enabled = defaults::solid::enabled; ! sleeping = defaults::solid::sleeping; ! isStatic = defaults::solid::isStatic; ! // Leave the transform as an identity matrix. ! // "globalLinearVel" is already initialized in its constructor. ! // "globalAngularVel" is already initialized in its constructor. ! linearDamping = defaults::linearDamping; ! angularDamping = defaults::angularDamping; ! // The Shape list doesn't need to be initialized. ! } ! ///// Copy constructor. ! //SolidData(const SolidData& data) ! //{ ! // (*this) = data; ! //} ! virtual ~SolidData() ! { ! destroyShapes(); ! } /// Adds a new Shape to the SolidData. This automatically /// allocates the right ShapeData type. ! virtual void OPAL_CALL addShape(const ShapeData& data) ! { ! ShapeData* newShape = NULL; ! ! switch(data.getType()) ! { ! case BOX_SHAPE: ! { ! newShape = new BoxShapeData((BoxShapeData&)data); ! break; ! } ! case SPHERE_SHAPE: ! { ! newShape = new SphereShapeData((SphereShapeData&)data); ! break; ! } ! case CAPSULE_SHAPE: ! { ! newShape = new CapsuleShapeData((CapsuleShapeData&)data); ! break; ! } ! case PLANE_SHAPE: ! { ! newShape = new PlaneShapeData((PlaneShapeData&)data); ! break; ! } ! case RAY_SHAPE: ! { ! newShape = new RayShapeData((RayShapeData&)data); ! break; ! } ! case MESH_SHAPE: ! { ! newShape = new MeshShapeData((MeshShapeData&)data); ! break; ! } ! default: ! assert(false); ! } ! ! mShapes.push_back(newShape); ! } /// Returns the number of Shapes in this SolidData. ! virtual int OPAL_CALL getNumShapes()const ! { ! return (int)(mShapes.size()); ! } /// Returns a pointer to the ShapeData at the given index. ! virtual ShapeData* OPAL_CALL getShapeData(unsigned int i)const ! { ! return mShapes.at(i); ! } /// Destroys all Shapes in the SolidData. ! virtual void OPAL_CALL destroyShapes() ! { ! while (!mShapes.empty()) ! { ! delete mShapes.back(); ! mShapes.pop_back(); ! } ! } ! ! ///// Makes a deep copy. ! //virtual void OPAL_CALL operator=(const SolidData& data) ! //{ ! // enabled = data.enabled; ! // sleeping = data.sleeping; ! // isStatic = data.isStatic; ! // transform = data.transform; ! // globalLinearVel = data.globalLinearVel; ! // globalAngularVel = data.globalAngularVel; ! // linearDamping = data.linearDamping; ! // angularDamping = data.angularDamping; ! // shapes.clear(); ! // for (unsigned int i=0; i<data.shapes.size(); ++i) ! // { ! // // TODO: need an actual ShapeData allocated here, but it ! // // must be the right type. ! // shapes.push_back(data.shapes[i]); ! // } ! //} bool enabled; bool sleeping; bool isStatic; Matrix44r transform; Vec3r globalLinearVel; Vec3r globalAngularVel; real linearDamping; real angularDamping; protected: std::vector<ShapeData*> mShapes; --- 38,97 ---- { public: ! SolidData(); ! /// Copy constructor. ! SolidData(const SolidData& data); ! virtual ~SolidData(); /// Adds a new Shape to the SolidData. This automatically /// allocates the right ShapeData type. ! virtual void OPAL_CALL addShape(const ShapeData& data); /// Returns the number of Shapes in this SolidData. ! virtual int OPAL_CALL getNumShapes()const; ! /// Returns a pointer to the ShapeData at the given index. ! virtual ShapeData* OPAL_CALL getShapeData(unsigned int i)const; /// Destroys all Shapes in the SolidData. ! virtual void OPAL_CALL destroyShapes(); ! /// Makes a deep copy. ! virtual void OPAL_CALL operator=(const SolidData& data); + /// Determines whether the Solid is enabled. bool enabled; + + /// An identifier for the Solid. + std::string name; + + /// Determines whether the Solid is sleeping. bool sleeping; + + /// The Solid's sleepiness level which determines how fast the + /// Solid falls asleep. + real sleepiness; + + /// Determines whether the Solid is static. bool isStatic; + + /// The Solid's transform relative to the global origin. Matrix44r transform; + + /// The Solid's linear velocity in global coordinates. Vec3r globalLinearVel; + + /// The Solid's angular velocity in global coordinates. Vec3r globalAngularVel; + + /// The amount of damping applied to the Solid's linear motion. real linearDamping; + + /// The amount of damping applied to the Solid's angular motion. real angularDamping; protected: + /// Pointers to the Solid's Shape data. std::vector<ShapeData*> mShapes; Index: GearedMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/GearedMotor.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GearedMotor.cpp 23 Feb 2005 03:58:23 -0000 1.6 --- GearedMotor.cpp 25 Feb 2005 06:40:26 -0000 1.7 *************** *** 56,64 **** } ! const GearedMotorData& GearedMotor::getMotorData() { return mData; } bool GearedMotor::isEnabled()const { --- 56,74 ---- } ! const GearedMotorData& GearedMotor::getMotorData()const { return mData; } + void GearedMotor::setName(const std::string& name) + { + mData.name = name; + } + + const std::string& GearedMotor::getName()const + { + return mData.name; + } + bool GearedMotor::isEnabled()const { Index: ServoMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/ServoMotor.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ServoMotor.h 23 Feb 2005 03:58:23 -0000 1.20 --- ServoMotor.h 25 Feb 2005 06:40:26 -0000 1.21 *************** *** 58,62 **** /// Returns all data describing the Motor. ! virtual const ServoMotorData& OPAL_CALL getMotorData(); virtual bool OPAL_CALL isEnabled()const; --- 58,66 ---- /// Returns all data describing the Motor. ! virtual const ServoMotorData& OPAL_CALL getMotorData()const; ! ! virtual void OPAL_CALL setName(const std::string& name); ! ! virtual const std::string& OPAL_CALL getName()const; virtual bool OPAL_CALL isEnabled()const; *************** *** 74,78 **** /// Gets the desired position, a value between the Joint axis' /// limits. ! virtual real OPAL_CALL getDesiredPos(); /// Sets the desired velocity. --- 78,82 ---- /// Gets the desired position, a value between the Joint axis' /// limits. ! virtual real OPAL_CALL getDesiredPos()const; /// Sets the desired velocity. *************** *** 80,84 **** /// Returns the desired velocity. ! virtual real OPAL_CALL getDesiredVel(); /// Sets the maximum amount of force/torque this Motor can use. --- 84,88 ---- /// Returns the desired velocity. ! virtual real OPAL_CALL getDesiredVel()const; /// Sets the maximum amount of force/torque this Motor can use. *************** *** 86,90 **** /// Returns the maximum amount of force/torque this Motor can use. ! virtual real OPAL_CALL getMaxForce(); /// Sets the restore speed, the parameter used to scale how fast --- 90,94 ---- /// Returns the maximum amount of force/torque this Motor can use. ! virtual real OPAL_CALL getMaxForce()const; /// Sets the restore speed, the parameter used to scale how fast *************** *** 94,98 **** /// Returns the restore speed. ! virtual real OPAL_CALL getRestoreSpeed(); virtual void OPAL_CALL internal_update(); --- 98,102 ---- /// Returns the restore speed. ! virtual real OPAL_CALL getRestoreSpeed()const; virtual void OPAL_CALL internal_update(); Index: AttractorMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/AttractorMotor.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** AttractorMotor.h 23 Feb 2005 03:58:23 -0000 1.22 --- AttractorMotor.h 25 Feb 2005 06:40:26 -0000 1.23 *************** *** 57,61 **** /// Returns all data describing the Motor. ! virtual const AttractorMotorData& OPAL_CALL getMotorData(); virtual bool OPAL_CALL isEnabled()const; --- 57,65 ---- /// Returns all data describing the Motor. ! virtual const AttractorMotorData& OPAL_CALL getMotorData()const; ! ! virtual void OPAL_CALL setName(const std::string& name); ! ! virtual const std::string& OPAL_CALL getName()const; virtual bool OPAL_CALL isEnabled()const; Index: ThrusterMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ThrusterMotor.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ThrusterMotor.cpp 23 Feb 2005 03:58:23 -0000 1.5 --- ThrusterMotor.cpp 25 Feb 2005 06:40:26 -0000 1.6 *************** *** 54,62 **** } ! const ThrusterMotorData& ThrusterMotor::getMotorData() { return mData; } bool ThrusterMotor::isEnabled()const { --- 54,72 ---- } ! const ThrusterMotorData& ThrusterMotor::getMotorData()const { return mData; } + void ThrusterMotor::setName(const std::string& name) + { + mData.name = name; + } + + const std::string& ThrusterMotor::getName()const + { + return mData.name; + } + bool ThrusterMotor::isEnabled()const { Index: Blueprint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Blueprint.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Blueprint.cpp 23 Feb 2005 03:58:23 -0000 1.13 --- Blueprint.cpp 25 Feb 2005 06:40:26 -0000 1.14 *************** *** 27,30 **** --- 27,34 ---- #include "Blueprint.h" + #include "SolidData.h" + #include "JointData.h" + #include "MotorData.h" + #include "SensorData.h" namespace opal *************** *** 36,134 **** Blueprint::~Blueprint() { ! mSolidMap.clear(); ! mJointMap.clear(); ! mSpaceList.clear(); ! } ! void Blueprint::setName(const std::string& name) ! { ! mName = name; } ! const std::string& Blueprint::getName()const { ! return mName; } ! //void Blueprint::addSolid(const SolidDescription& sd) ! //{ ! // if (solidExists(sd.name)) ! // { ! // std::cout << "Warning in opal::Blueprint::addSolid: Solid " << sd.name ! // << " already exists in Blueprint " << mName ! // << "; ignoring Solid" << std::endl; ! // } ! // else ! // { ! // mSolidMap[sd.name] = sd; ! // } ! //} ! ! //void Blueprint::addJoint(const JointData& data) ! //{ ! // if (jointExists(data.name)) ! // { ! // std::cout << "Warning in opal::Blueprint::addJoint: Joint " << ! // data.name << " already exists in Blueprint " << mName ! // << "; ignoring Joint" << std::endl; ! // } ! // else ! // { ! // mJointMap[data.name] = data; ! // } ! //} ! ! void Blueprint::addSpace(const SpaceDescription& sd) { ! mSpaceList.push_back(sd); } ! int Blueprint::getNumSolids()const { ! return (int)mSolidMap.size(); } ! int Blueprint::getNumJoints()const { ! return (int)mJointMap.size(); } ! const std::map<std::string, SolidData>& Blueprint::getSolidMap()const { ! return mSolidMap; } ! const std::map<std::string, JointData>& Blueprint::getJointMap()const { ! return mJointMap; } ! const std::vector<SpaceDescription>& Blueprint::getSpaceList()const { ! return mSpaceList; } ! bool Blueprint::solidExists(const std::string& name) { ! if (mSolidMap.end() == mSolidMap.find(name)) { return false; } ! else { ! return true; } } ! bool Blueprint::jointExists(const std::string& name) { ! if (mJointMap.end() == mJointMap.find(name)) { ! return false; } ! else { ! return true; } } } --- 40,224 ---- Blueprint::~Blueprint() { ! while (!mSolidList.empty()) ! { ! delete mSolidList.back(); ! mSolidList.pop_back(); ! } ! while (!mJointList.empty()) ! { ! delete mJointList.back(); ! mJointList.pop_back(); ! } ! ! while (!mMotorList.empty()) ! { ! delete mMotorList.back(); ! mMotorList.pop_back(); ! } ! ! while (!mSensorList.empty()) ! { ! delete mSensorList.back(); ! mSensorList.pop_back(); ! } } ! void Blueprint::addSolid(const SolidData& data) { ! if (solidExists(data.name)) ! { ! Logger::stream("warning") << "opal::Blueprint::addSolid: Solid " ! << data.name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; ! } ! else ! { ! SolidData* newData = new SolidData(data); ! mSolidList.push_back(newData); ! } } ! void Blueprint::addJoint(const JointData& data) { ! if (jointExists(data.name)) ! { ! Logger::stream("warning") << "opal::Blueprint::addJoint: Joint " ! << data.name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; ! } ! else ! { ! JointData* newData = new JointData(data); ! mJointList.push_back(newData); ! } } ! void Blueprint::addMotor(const MotorData& data) { ! if (motorExists(data.name)) ! { ! Logger::stream("warning") << "opal::Blueprint::addMotor: Motor " ! << data.name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; ! } ! else ! { ! MotorData* newData = new MotorData(data); ! mMotorList.push_back(newData); ! } } ! void Blueprint::addSensor(const SensorData& data) { ! if (sensorExists(data.name)) ! { ! Logger::stream("warning") << "opal::Blueprint::addSensor: Sensor " ! << data.name << " already exists in this Blueprint. \ ! Ignoring the new one." << std::endl; ! } ! else ! { ! SensorData* newData = new SensorData(data); ! mSensorList.push_back(newData); ! } } ! bool Blueprint::solidExists(const std::string& name) { ! /// Ignore empty name strings. ! if (name.empty()) ! { ! return false; ! } ! ! std::vector<SolidData*>::iterator iter; ! for (iter = mSolidList.begin(); iter != mSolidList.end(); ++iter) ! { ! if ((*iter)->name == name) ! { ! return true; ! } ! } ! ! return false; } ! bool Blueprint::jointExists(const std::string& name) { ! /// Ignore empty name strings. ! if (name.empty()) ! { ! return false; ! } ! ! std::vector<JointData*>::iterator iter; ! for (iter = mJointList.begin(); iter != mJointList.end(); ++iter) ! { ! if ((*iter)->name == name) ! { ! return true; ! } ! } ! ! return false; } ! bool Blueprint::motorExists(const std::string& name) { ! /// Ignore empty name strings. ! if (name.empty()) ! { ! return false; ! } ! ! std::vector<MotorData*>::iterator iter; ! for (iter = mMotorList.begin(); iter != mMotorList.end(); ++iter) ! { ! if ((*iter)->name == name) ! { ! return true; ! } ! } ! ! return false; } ! bool Blueprint::sensorExists(const std::string& name) { ! /// Ignore empty name strings. ! if (name.empty()) { return false; } ! ! std::vector<SensorData*>::iterator iter; ! for (iter = mSensorList.begin(); iter != mSensorList.end(); ++iter) { ! if ((*iter)->name == name) ! { ! return true; ! } } + + return false; } ! int Blueprint::internal_getSolidIndex(const std::string& name)const { ! if (name.empty()) { ! return -1; } ! ! for (unsigned int i=0; i<mSolidList.size(); ++i) { ! if (mSolidList[i]->name == name) ! { ! return (int)i; ! } } + + return -1; } } Index: Blueprint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Blueprint.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Blueprint.h 23 Feb 2005 03:58:23 -0000 1.21 --- Blueprint.h 25 Feb 2005 06:40:26 -0000 1.22 *************** *** 35,42 **** namespace opal { /// Blueprints are useful for saving and loading systems of Solids, /// Joints, Motors, and/or Sensors. They are not guaranteed to yield /// perfect repeatability after a save/restore sequence. - class Blueprint { --- 35,46 ---- namespace opal { + class SolidData; + class JointData; + class MotorData; + class SensorData; + /// Blueprints are useful for saving and loading systems of Solids, /// Joints, Motors, and/or Sensors. They are not guaranteed to yield /// perfect repeatability after a save/restore sequence. class Blueprint { *************** *** 46,79 **** virtual ~Blueprint(); ! virtual void OPAL_CALL setName(const std::string& name); ! ! virtual const std::string& OPAL_CALL getName()const; ! ! //virtual void OPAL_CALL addSolid(const SolidDescription& data); ! ! //virtual void OPAL_CALL addJoint(const JointData& data); ! ! virtual void OPAL_CALL addSpace(const SpaceDescription& sd); ! ! virtual int OPAL_CALL getNumSolids()const; ! virtual int OPAL_CALL getNumJoints()const; ! virtual const std::map<std::string, SolidData>& OPAL_CALL getSolidMap()const; ! virtual const std::map<std::string, JointData>& OPAL_CALL getJointMap()const; ! virtual const std::vector<SpaceDescription>& OPAL_CALL getSpaceList()const; private: bool solidExists(const std::string& name); bool jointExists(const std::string& name); ! std::string mName; ! std::map<std::string, SolidData> mSolidMap; ! std::map<std::string, JointData> mJointMap; ! std::vector<SpaceDescription> mSpaceList; }; } --- 50,99 ---- virtual ~Blueprint(); ! /// Adds a new SolidData object to the Blueprint. Makes a ! /// deep copy of the given data. ! virtual void OPAL_CALL addSolid(const SolidData& data); ! /// Adds a new JointData object to the Blueprint. Makes a ! /// deep copy of the given data. ! virtual void OPAL_CALL addJoint(const JointData& data); ! /// Adds a new MotorData object to the Blueprint. Makes a ! /// deep copy of the given data. ! virtual void OPAL_CALL addMotor(const MotorData& data); ! /// Adds a new SensorData object to the Blueprint. Makes a ! /// deep copy of the given data. ! virtual void OPAL_CALL addSensor(const SensorData& data); ! /// Returns the index of the given Solid name in the Blueprint's ! /// list of SolidData. Returns -1 if the Solid name is not found ! /// or if the given name is an empty string. ! int internal_getSolidIndex(const std::string& name)const; private: + /// Helper function that returns true if a Solid of the given + /// name already exists in the Blueprint. Ignores empty name + /// strings. bool solidExists(const std::string& name); + /// Helper function that returns true i... [truncated message content] |