cylinder.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #include <rve_render_client/cylinder.h>
00031 #include <rve_render_client/material.h>
00032 #include <rve_render_client/scene.h>
00033 #include <rve_msgs/make_vector3.h>
00034 
00035 #include <rve_interfaces/Cylinder.h>
00036 
00037 #include <boost/bind.hpp>
00038 
00039 namespace rve_render_client
00040 {
00041 
00042 CylinderPtr createCylinder(Scene* scene)
00043 {
00044   CylinderPtr inst(new Cylinder(), destroySceneObject);
00045   scene->addObject(inst.get());
00046   return inst;
00047 }
00048 
00049 CylinderPtr createCylinder()
00050 {
00051   CylinderPtr inst(new Cylinder(), destroySceneObject);
00052   return inst;
00053 }
00054 
00055 Cylinder::Cylinder()
00056 : radius_(1.0)
00057 , height_(1.0)
00058 {
00059   orientation_.w = 1.0;
00060   proxy_index_ = addProxy("cylinder");
00061 }
00062 
00063 Cylinder::~Cylinder()
00064 {
00065 }
00066 
00067 rve_interfaces::CylinderProxy* Cylinder::getProxy(const ContextInfo& context)
00068 {
00069   return SceneObject::getProxy<rve_interfaces::CylinderProxy>(context, proxy_index_);
00070 }
00071 
00072 void Cylinder::doCreate(ContextInfo& context)
00073 {
00074   rve_interfaces::CylinderProxy* proxy = getProxy(context);
00075   proxy->create(getSceneID(context.scene), getID());
00076 
00077   const rve_common::UUID& scene_id = getSceneID(context.scene);
00078 
00079   if (material_)
00080   {
00081     proxy->setMaterialAsync(scene_id, getID(), material_->getID());
00082   }
00083 
00084   proxy->setPositionAsync(scene_id, getID(), position_);
00085   proxy->setOrientationAsync(scene_id, getID(), orientation_);
00086   proxy->setRadiusAsync(scene_id, getID(), radius_);
00087   proxy->setHeightAsync(scene_id, getID(), height_);
00088 }
00089 
00090 void Cylinder::doDestroy(ContextInfo& context)
00091 {
00092   rve_interfaces::CylinderProxy* proxy = getProxy(context);
00093   proxy->destroy(getSceneID(context.scene), getID());
00094 }
00095 
00096 #define CYLINDER_MULTIPLEX(func, ...) \
00097     multiplex<rve_interfaces::CylinderProxy>(boost::bind(&rve_interfaces::CylinderProxy::func, _1, _2, getID(), __VA_ARGS__), proxy_index_);
00098 
00099 void Cylinder::setPosition(const rve_msgs::Vector3& pos)
00100 {
00101   position_ = pos;
00102   CYLINDER_MULTIPLEX(setPositionAsync, pos);
00103 }
00104 
00105 void Cylinder::setOrientation(const rve_msgs::Quaternion& orient)
00106 {
00107   orientation_ = orient;
00108   CYLINDER_MULTIPLEX(setOrientationAsync, orient);
00109 }
00110 
00111 void Cylinder::setRadius(float radius)
00112 {
00113   radius_ = radius;
00114   CYLINDER_MULTIPLEX(setRadiusAsync, radius);
00115 }
00116 
00117 void Cylinder::setHeight(float height)
00118 {
00119   height_ = height;
00120   CYLINDER_MULTIPLEX(setHeightAsync, height);
00121 }
00122 
00123 void Cylinder::setMaterial(const MaterialPtr& mat)
00124 {
00125   material_ = mat;
00126   if (mat)
00127   {
00128     CYLINDER_MULTIPLEX(setMaterialAsync, mat->getID());
00129   }
00130 }
00131 
00132 void Cylinder::getContextDependencies(V_UUID& deps)
00133 {
00134   if (material_)
00135   {
00136     deps.push_back(material_->getID());
00137   }
00138 }
00139 
00140 } // namespace rviz_render_client
00141 
00142 


rve_render_client
Author(s): Josh Faust
autogenerated on Wed Dec 11 2013 14:31:32