/usr/include/openctmpp.h is in libopenctm-dev 1.0.3+dfsg1-1.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | //-----------------------------------------------------------------------------
// Product: OpenCTM
// File: openctmpp.h
// Description: C++ wrapper for the OpenCTM API.
//-----------------------------------------------------------------------------
// Copyright (c) 2009-2010 Marcus Geelnard
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//-----------------------------------------------------------------------------
// To disable C++ extensions, define OPENCTM_NO_CPP
#ifndef OPENCTM_NO_CPP
#ifndef __OPENCTMPP_H_
#define __OPENCTMPP_H_
// Just in case (if this file was included from outside openctm.h)...
#ifndef __OPENCTM_H_
#include "openctm.h"
#endif
#include <exception>
/// OpenCTM exception. When an error occurs, a \c ctm_error exception is
/// thrown. Its what() function returns the name of the OpenCTM error code
/// (for instance "CTM_INVALID_OPERATION").
class ctm_error: public std::exception
{
private:
CTMenum mErrorCode;
public:
explicit ctm_error(CTMenum aError)
{
mErrorCode = aError;
}
virtual const char* what() const throw()
{
return ctmErrorString(mErrorCode);
}
CTMenum error_code() const throw()
{
return mErrorCode;
}
};
/// OpenCTM importer class. This is a C++ wrapper class for an OpenCTM import
/// context. Usage example:
///
/// @code
/// // Create a new OpenCTM importer object
/// CTMimporter ctm;
///
/// // Load the OpenCTM file
/// ctm.Load("mymesh.ctm");
///
/// // Access the mesh data
/// vertCount = ctm.GetInteger(CTM_VERTEX_COUNT);
/// vertices = ctm.GetFloatArray(CTM_VERTICES);
/// triCount = ctm.GetInteger(CTM_TRIANGLE_COUNT);
/// indices = ctm.GetIntegerArray(CTM_INDICES);
///
/// // Deal with the mesh (e.g. transcode it to our internal representation)
/// // ...
/// @endcode
class CTMimporter {
private:
/// The OpenCTM context handle.
CTMcontext mContext;
/// Check for OpenCTM errors, and throw an exception if an error has
/// occured.
void CheckError()
{
CTMenum err = ctmGetError(mContext);
if(err != CTM_NONE)
throw ctm_error(err);
}
public:
/// Constructor
CTMimporter()
{
mContext = ctmNewContext(CTM_IMPORT);
}
/// Destructor
~CTMimporter()
{
ctmFreeContext(mContext);
}
/// Wrapper for ctmGetInteger()
CTMuint GetInteger(CTMenum aProperty)
{
CTMuint res = ctmGetInteger(mContext, aProperty);
CheckError();
return res;
}
/// Wrapper for ctmGetFloat()
CTMfloat GetFloat(CTMenum aProperty)
{
CTMfloat res = ctmGetFloat(mContext, aProperty);
CheckError();
return res;
}
/// Wrapper for ctmGetIntegerArray()
const CTMuint * GetIntegerArray(CTMenum aProperty)
{
const CTMuint * res = ctmGetIntegerArray(mContext, aProperty);
CheckError();
return res;
}
/// Wrapper for ctmGetFloatArray()
const CTMfloat * GetFloatArray(CTMenum aProperty)
{
const CTMfloat * res = ctmGetFloatArray(mContext, aProperty);
CheckError();
return res;
}
/// Wrapper for ctmGetNamedUVMap()
CTMenum GetNamedUVMap(const char * aName)
{
CTMenum res = ctmGetNamedUVMap(mContext, aName);
CheckError();
return res;
}
/// Wrapper for ctmGetUVMapString()
const char * GetUVMapString(CTMenum aUVMap, CTMenum aProperty)
{
const char * res = ctmGetUVMapString(mContext, aUVMap, aProperty);
CheckError();
return res;
}
/// Wrapper for ctmGetUVMapFloat()
CTMfloat GetUVMapFloat(CTMenum aUVMap, CTMenum aProperty)
{
CTMfloat res = ctmGetUVMapFloat(mContext, aUVMap, aProperty);
CheckError();
return res;
}
/// Wrapper for ctmGetNamedAttribMap()
CTMenum GetNamedAttribMap(const char * aName)
{
CTMenum res = ctmGetNamedAttribMap(mContext, aName);
CheckError();
return res;
}
/// Wrapper for ctmGetAttribMapString()
const char * GetAttribMapString(CTMenum aAttribMap, CTMenum aProperty)
{
const char * res = ctmGetAttribMapString(mContext, aAttribMap, aProperty);
CheckError();
return res;
}
/// Wrapper for ctmGetAttribMapFloat()
CTMfloat GetAttribMapFloat(CTMenum aAttribMap, CTMenum aProperty)
{
CTMfloat res = ctmGetAttribMapFloat(mContext, aAttribMap, aProperty);
CheckError();
return res;
}
/// Wrapper for ctmGetString()
const char * GetString(CTMenum aProperty)
{
const char * res = ctmGetString(mContext, aProperty);
CheckError();
return res;
}
/// Wrapper for ctmLoad()
void Load(const char * aFileName)
{
ctmLoad(mContext, aFileName);
CheckError();
}
/// Wrapper for ctmLoadCustom()
void LoadCustom(CTMreadfn aReadFn, void * aUserData)
{
ctmLoadCustom(mContext, aReadFn, aUserData);
CheckError();
}
// You can not copy nor assign from one CTMimporter object to another, since
// the object contains hidden state. By declaring these dummy prototypes
// without an implementation, you will at least get linker errors if you try
// to copy or assign a CTMimporter object.
CTMimporter(const CTMimporter& v);
CTMimporter& operator=(const CTMimporter& v);
};
/// OpenCTM exporter class. This is a C++ wrapper class for an OpenCTM export
/// context. Usage example:
/// @code
/// void MySaveFile(CTMuint aVertCount, CTMuint aTriCount, CTMfloat * aVertices,
/// CTMuint * aIndices, const char * aFileName)
/// {
/// // Create a new OpenCTM exporter object
/// CTMexporter ctm;
///
/// // Define our mesh representation to OpenCTM (store references to it in
/// // the context)
/// ctm.DefineMesh(aVertices, aVertCount, aIndices, aTriCount, NULL);
///
/// // Save the OpenCTM file
/// ctm.Save(aFileName);
/// }
/// @endcode
class CTMexporter {
private:
/// The OpenCTM context handle.
CTMcontext mContext;
/// Check for OpenCTM errors, and throw an exception if an error has
/// occured.
void CheckError()
{
CTMenum err = ctmGetError(mContext);
if(err != CTM_NONE)
throw ctm_error(err);
}
public:
/// Constructor
CTMexporter()
{
mContext = ctmNewContext(CTM_EXPORT);
}
/// Destructor
~CTMexporter()
{
ctmFreeContext(mContext);
}
/// Wrapper for ctmCompressionMethod()
void CompressionMethod(CTMenum aMethod)
{
ctmCompressionMethod(mContext, aMethod);
CheckError();
}
/// Wrapper for ctmCompressionLevel()
void CompressionLevel(CTMuint aLevel)
{
ctmCompressionLevel(mContext, aLevel);
CheckError();
}
/// Wrapper for ctmVertexPrecision()
void VertexPrecision(CTMfloat aPrecision)
{
ctmVertexPrecision(mContext, aPrecision);
CheckError();
}
/// Wrapper for ctmVertexPrecisionRel()
void VertexPrecisionRel(CTMfloat aRelPrecision)
{
ctmVertexPrecisionRel(mContext, aRelPrecision);
CheckError();
}
/// Wrapper for ctmNormalPrecision()
void NormalPrecision(CTMfloat aPrecision)
{
ctmNormalPrecision(mContext, aPrecision);
CheckError();
}
/// Wrapper for ctmUVCoordPrecision()
void UVCoordPrecision(CTMenum aUVMap, CTMfloat aPrecision)
{
ctmUVCoordPrecision(mContext, aUVMap, aPrecision);
CheckError();
}
/// Wrapper for ctmAttribPrecision()
void AttribPrecision(CTMenum aAttribMap, CTMfloat aPrecision)
{
ctmAttribPrecision(mContext, aAttribMap, aPrecision);
CheckError();
}
/// Wrapper for ctmFileComment()
void FileComment(const char * aFileComment)
{
ctmFileComment(mContext, aFileComment);
CheckError();
}
/// Wrapper for ctmDefineMesh()
void DefineMesh(const CTMfloat * aVertices, CTMuint aVertexCount,
const CTMuint * aIndices, CTMuint aTriangleCount,
const CTMfloat * aNormals)
{
ctmDefineMesh(mContext, aVertices, aVertexCount, aIndices, aTriangleCount,
aNormals);
CheckError();
}
/// Wrapper for ctmAddUVMap()
CTMenum AddUVMap(const CTMfloat * aUVCoords, const char * aName,
const char * aFileName)
{
CTMenum res = ctmAddUVMap(mContext, aUVCoords, aName, aFileName);
CheckError();
return res;
}
/// Wrapper for ctmAddAttribMap()
CTMenum AddAttribMap(const CTMfloat * aAttribValues, const char * aName)
{
CTMenum res = ctmAddAttribMap(mContext, aAttribValues, aName);
CheckError();
return res;
}
/// Wrapper for ctmSave()
void Save(const char * aFileName)
{
ctmSave(mContext, aFileName);
CheckError();
}
/// Wrapper for ctmSaveCustom()
void SaveCustom(CTMwritefn aWriteFn, void * aUserData)
{
ctmSaveCustom(mContext, aWriteFn, aUserData);
CheckError();
}
// You can not copy nor assign from one CTMexporter object to another, since
// the object contains hidden state. By declaring these dummy prototypes
// without an implementation, you will at least get linker errors if you try
// to copy or assign a CTMexporter object.
CTMexporter(const CTMexporter& v);
CTMexporter& operator=(const CTMexporter& v);
};
#endif // __OPENCTMPP_H_
#endif // OPENCTM_NO_CPP
|