Developer Documentation

PluginFunctionsSplatCloud.cc
1
2 /*===========================================================================*\
3 * *
4 * OpenFlipper *
5 * Copyright (c) 2001-2015, RWTH-Aachen University *
6 * Department of Computer Graphics and Multimedia *
7 * All rights reserved. *
8 * www.openflipper.org *
9 * *
10 *---------------------------------------------------------------------------*
11 * This file is part of OpenFlipper. *
12 *---------------------------------------------------------------------------*
13 * *
14 * Redistribution and use in source and binary forms, with or without *
15 * modification, are permitted provided that the following conditions *
16 * are met: *
17 * *
18 * 1. Redistributions of source code must retain the above copyright notice, *
19 * this list of conditions and the following disclaimer. *
20 * *
21 * 2. Redistributions in binary form must reproduce the above copyright *
22 * notice, this list of conditions and the following disclaimer in the *
23 * documentation and/or other materials provided with the distribution. *
24 * *
25 * 3. Neither the name of the copyright holder nor the names of its *
26 * contributors may be used to endorse or promote products derived from *
27 * this software without specific prior written permission. *
28 * *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
31 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
32 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
33 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
34 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
35 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
36 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
37 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
38 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
40 * *
41 \*===========================================================================*/
42
43
44
45 //================================================================
46 //
47 // Plugin Functions for SplatClouds
48 //
49 //================================================================
50
51
52 //== INCLUDES ====================================================
53
54
55 #include "PluginFunctionsSplatCloud.hh"
56
57 #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
58
59
60 //== NAMESPACES ==================================================
61
62
63 namespace PluginFunctions {
64
65
66 //== IMPLEMENTATION ==============================================
67
68
69 //================================================================
70 // Get objects
71 //================================================================
72
73
74 bool getObject( int _identifier, SplatCloudObject *&_object )
75 {
76 if( _identifier == BaseObject::NOOBJECT )
77 {
78 _object = nullptr;
79 return false;
80 }
81
82 // Get object by using the map accelerated plugin function
83 BaseObjectData* object = nullptr;
84 PluginFunctions::getObject(_identifier,object);
85
86 _object = dynamic_cast<SplatCloudObject *>( object );
87 return (_object != nullptr);
88 }
89
90
91 //================================================================
92 // Getting data from objects and casting between them
93 //================================================================
94
95
96 ShaderNode* splatShaderNode( BaseObjectData *_object )
97 {
98 if( !_object )
99 return nullptr;
100
101 if( !_object->dataType( DATA_SPLATCLOUD ) )
102 return nullptr;
103
104 SplatCloudObject *object = dynamic_cast<SplatCloudObject *>( _object );
105
106 if ( object == nullptr )
107 return nullptr;
108
109 return object->shaderNode();
110 }
111
112
113 //----------------------------------------------------------------
114
115
116 SplatCloudNode* splatCloudNode( BaseObjectData *_object )
117 {
118 if( !_object )
119 return nullptr;
120
121 if( !_object->dataType( DATA_SPLATCLOUD ) )
122 return nullptr;
123
124 SplatCloudObject *object = dynamic_cast<SplatCloudObject *>( _object );
125
126 if ( object == nullptr )
127 return nullptr;
128
129 return object->splatCloudNode();
130 }
131
132
133 //----------------------------------------------------------------
134
135
136 SplatCloud* splatCloud( BaseObjectData *_object )
137 {
138 if( !_object )
139 return nullptr;
140
141 if( !_object->dataType( DATA_SPLATCLOUD ) )
142 return nullptr;
143
144 SplatCloudObject *object = dynamic_cast<SplatCloudObject *>( _object );
145
146 if ( object == nullptr )
147 return nullptr;
148
149 return object->splatCloud();
150 }
151
152
153 //----------------------------------------------------------------
154
155
156 SplatCloud* splatCloud( int _objectId )
157 {
158 auto object = splatCloudObject(_objectId);
159 if (object == nullptr)
160 return nullptr;
161 return object->splatCloud();
162 }
163
164
165 //----------------------------------------------------------------
166
167
168 SplatCloudObject* splatCloudObject( BaseObjectData *_object )
169 {
170 if( !_object )
171 return nullptr;
172
173 if( !_object->dataType( DATA_SPLATCLOUD ) )
174 return nullptr;
175
176 return dynamic_cast<SplatCloudObject *>( _object );
177 }
178
179
180 //----------------------------------------------------------------
181
182
183 SplatCloudObject* splatCloudObject( int _objectId ) {
184
185 if (_objectId == BaseObject::NOOBJECT)
186 return nullptr;
187
188 // Get object by using the map accelerated plugin function
189 BaseObjectData* object = nullptr;
190 PluginFunctions::getObject(_objectId,object);
191
192 if ( object == nullptr )
193 return nullptr;
194
195 SplatCloudObject* splatCloudObject = dynamic_cast< SplatCloudObject* >(object);
196
197 return splatCloudObject;
198 }
199
200
201 //================================================================
202
203
204 } // namespace PluginFunctions
PluginFunctionsSplatCloud.hh
SplatCloud
Definition: SplatCloud.hh:79
PluginFunctions::getObject
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
Definition: PluginFunctions.cc:296
SplatCloudObject
Definition: SplatCloudObject.hh:76
PluginFunctions::splatShaderNode
ShaderNode * splatShaderNode(BaseObjectData *_object)
Get a ShaderNode from an object.
Definition: PluginFunctionsSplatCloud.cc:96
ACG::SceneGraph::SplatCloudNode
Definition: SplatCloudNode.hh:89
SplatCloudObject::shaderNode
ShaderNode * shaderNode()
Get Shader&#39;s scenegraph Node.
Definition: SplatCloudObject.hh:176
DATA_SPLATCLOUD
#define DATA_SPLATCLOUD
Definition: SplatCloud.hh:59
ACG::SceneGraph::ShaderNode
Definition: ShaderNode.hh:81
PluginFunctions.hh
SplatCloudObject::splatCloud
SplatCloud * splatCloud()
Get SplatCloud.
Definition: SplatCloudObject.hh:162
BaseObject::dataType
bool dataType(DataType _type) const
Definition: BaseObject.cc:221
PluginFunctions::splatCloudObject
SplatCloudObject * splatCloudObject(BaseObjectData *_object)
Cast an SplatCloudObject to a SplatCloudObject if possible.
Definition: PluginFunctionsSplatCloud.cc:168
BaseObject::NOOBJECT
static int NOOBJECT
Definition: BaseObject.hh:106
PluginFunctions::splatCloud
SplatCloud * splatCloud(BaseObjectData *_object)
Get a SplatCloud from an object.
Definition: PluginFunctionsSplatCloud.cc:136
BaseObjectData
Definition: BaseObjectData.hh:102
PluginFunctions::splatCloudNode
SplatCloudNode * splatCloudNode(BaseObjectData *_object)
Get a SplatCloudNode from an object.
Definition: PluginFunctionsSplatCloud.cc:116
PluginFunctions
Definition: PluginFunctions.cc:57
SplatCloudObject::splatCloudNode
SplatCloudNode * splatCloudNode()
Get SplatCloud&#39;s scenegraph Node.
Definition: SplatCloudObject.hh:180