changed: gcc8 base update
[opensg.git] / Source / System / FileIO / Collada / OSGColladaSurface.cpp
blob6014bd9a23a82da01fa406d81e6abcb746ec6386
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2009 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #if __GNUC__ >= 4 || __GNUC_MINOR__ >=3
40 #pragma GCC diagnostic ignored "-Wold-style-cast"
41 #endif
43 #include "OSGColladaSurface.h"
45 #if defined(OSG_WITH_COLLADA) || defined(OSG_DO_DOC)
47 #include "OSGColladaLog.h"
48 #include "OSGColladaImage.h"
50 #include <dom/domFx_surface_common.h>
51 #include <dom/domImage.h>
53 OSG_BEGIN_NAMESPACE
55 ColladaElementRegistrationHelper ColladaSurface::_regHelper(
56 &ColladaSurface::create, "surface");
59 ColladaElementTransitPtr
60 ColladaSurface::create(daeElement *elem, ColladaGlobal *global)
62 return ColladaElementTransitPtr(new ColladaSurface(elem, global));
65 void
66 ColladaSurface::read(ColladaElement *colElemParent)
68 OSG_COLLADA_LOG(("ColladaSurface::read\n"));
70 domFx_surface_commonRef surface = getDOMElementAs<domFx_surface_common>();
72 switch(surface->getType())
74 case FX_SURFACE_TYPE_ENUM_UNTYPED:
75 readUntyped(surface);
76 break;
78 case FX_SURFACE_TYPE_ENUM_1D:
79 read1D(surface);
80 break;
82 case FX_SURFACE_TYPE_ENUM_2D:
83 read2D(surface);
84 break;
86 case FX_SURFACE_TYPE_ENUM_3D:
87 read3D(surface);
88 break;
90 case FX_SURFACE_TYPE_ENUM_RECT:
91 readRect(surface);
92 break;
94 case FX_SURFACE_TYPE_ENUM_CUBE:
95 readCube(surface);
96 break;
98 case FX_SURFACE_TYPE_ENUM_DEPTH:
99 readDepth(surface);
100 break;
101 case FX_SURFACE_TYPE_ENUM_COUNT:
102 SWARNING << "ColladaSurface::read FX_SURFACE_TYPE_ENUM_COUNT "
103 << "not handled"
104 << std::endl;
105 break;
109 Image *
110 ColladaSurface::getImage(void) const
112 return _image;
115 ColladaSurface::ColladaSurface(daeElement *elem, ColladaGlobal *global)
116 : Inherited(elem, global)
117 , _image (NULL)
121 ColladaSurface::~ColladaSurface(void)
125 void
126 ColladaSurface::readUntyped(domFx_surface_common *surface)
128 SWARNING << "ColladaSurface::readUntyped: NIY" << std::endl;
131 void
132 ColladaSurface::read1D(domFx_surface_common *surface)
134 SWARNING << "ColladaSurface::read1D: NIY" << std::endl;
137 void
138 ColladaSurface::read2D(domFx_surface_common *surface)
140 domFx_surface_init_commonRef init = surface->getFx_surface_init_common();
142 domFx_surface_init_common::domInit_as_nullRef initNull =
143 init->getInit_as_null();
144 domFx_surface_init_common::domInit_as_targetRef initTarget =
145 init->getInit_as_target();
146 domFx_surface_init_planar_commonRef initPlanar =
147 init->getInit_planar();
148 const domFx_surface_init_from_common_Array &initFroms =
149 init->getInit_from_array();
151 if(initNull != NULL)
153 SWARNING << "ColladaSurface::read2D: <init_as_null>: NIY"
154 << std::endl;
156 else if(initTarget != NULL)
158 SWARNING << "ColladaSurface::read2D: <init_as_target>: NIY"
159 << std::endl;
161 else if(initPlanar != NULL)
163 SWARNING << "ColladaSurface::read2D: <init_planar>: NIY"
164 << std::endl;
166 else if(initFroms.getCount() > 0)
168 if(initFroms.getCount() > 1)
170 SWARNING << "ColladaSurface::read2D: only one "
171 << "<init_from> supported." << std::endl;
174 daeElementRef imageElem = initFroms[0]->getValue().getElement();
176 if(imageElem == NULL)
177 return;
179 domImageRef image = daeSafeCast<domImage>(imageElem);
180 ColladaImageRefPtr colImage = getUserDataAs<ColladaImage>(image);
182 if(colImage == NULL)
184 colImage = dynamic_pointer_cast<ColladaImage>(
185 ColladaElementFactory::the()->create(image, getGlobal()));
187 colImage->read(this);
190 _image = colImage->getImage();
194 void
195 ColladaSurface::read3D(domFx_surface_common *surface)
197 SWARNING << "ColladaSurface::read3D: NIY" << std::endl;
200 void
201 ColladaSurface::readRect(domFx_surface_common *surface)
203 SWARNING << "ColladaSurface::readRect: NIY" << std::endl;
206 void
207 ColladaSurface::readCube(domFx_surface_common *surface)
209 SWARNING << "ColladaSurface::readCube: NIY" << std::endl;
212 void
213 ColladaSurface::readDepth(domFx_surface_common *surface)
215 SWARNING << "ColladaSurface::readDepth: NIY" << std::endl;
218 OSG_END_NAMESPACE
220 #endif // OSG_WITH_COLLADA