/usr/include/opencollada/COLLADAStreamWriter/COLLADASWPrimitves.h is in opencollada-dev 0.1.0~20140703.ddf8f47+dfsg1-2.
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 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | /*
Copyright (c) 2008-2009 NetAllied Systems GmbH
This file is part of COLLADAStreamWriter.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/
#ifndef __COLLADASTREAMWRITER_PRIMITIVES_H__
#define __COLLADASTREAMWRITER_PRIMITIVES_H__
#include "COLLADASWPrerequisites.h"
#include "COLLADASWElementWriter.h"
#include "COLLADASWInputList.h"
#include "COLLADASWConstants.h"
#include <vector>
#include <string.h>
namespace COLLADASW
{
class PrimitivesBase : public ElementWriter
{
public:
/** The list of vertex counts per polygons. */
typedef std::vector<unsigned long> VCountList;
private:
/** Pointer to the primitives closer. */
TagCloser mPrimitiveCloser;
/** List of all the inputs*/
InputList mInputList;
/** Name of the current primitive. */
String mPrimitiveName;
/** The material symbol*/
String mMaterial;
/** The primitive count*/
unsigned long mCount;
/** List of the number in the @a \<vcount\> element*/
VCountList mVCountList;
public:
/**
* Constructor.
* @param streamWriter Pointer to the collada stream.
*/
PrimitivesBase ( StreamWriter* streamWriter, const String& primitiveName=EMPTY_STRING )
: ElementWriter ( streamWriter )
, mInputList ( streamWriter )
, mPrimitiveName ( primitiveName )
{
if ( strcmp(primitiveName.c_str(), mPrimitiveName.c_str() ) != 0)
{
mPrimitiveCloser = mSW->openElement ( primitiveName );
}
}
/**
* Destructor.
*/
virtual ~PrimitivesBase() {}
/** Opens the primitives name element. */
void openPrimitiveElement ( );
/** Appends the material symbol. */
void appendMaterial ( const String& material );
/** Appends the input list. */
void appendInputList ( );
/** Append the given count to the list. */
void appendCount ( const unsigned int count );
/** Appends the the count. */
void appendCount ( const unsigned long count );
/** Appends the vertex count element. */
void appendVertexCount( const unsigned long vCount );
/** Appends the vertex count elements in the list. */
void appendVertexCount( const VCountList& vCountList );
/** Opens the vertex count list element. */
void openVertexCountListElement();
/** Closes the \<vcount\> element and opens the \<v\> element. Call openVertexCountListElement() to open
the \<vcount\> element. Call finish() to close the \<v\> element.*/
void CloseVCountAndOpenVElement();
/** Close the last opened element. */
void closeElement ();
/** Opens the polylist element. */
void openPolylistElement ();
/** Sets the material symbol*/
void setMaterial ( const String& material )
{
mMaterial = material;
}
/** Returns the material Symbol*/
const String& getMaterial() const
{
return mMaterial;
}
/** Sets the primitive count*/
void setCount ( unsigned long count )
{
mCount = count;
}
/** Returns the primitive count*/
unsigned long getCount() const
{
return mCount;
}
/** Returns a reference to the list of all the inputs*/
InputList& getInputList()
{
return mInputList;
}
/**
* Returns a reference to the vCountList.
* @return VCountList& Reference to the vCountList.
*/
VCountList& getVCountList()
{
return mVCountList;
}
/**
* Set the vCountList.
* @param VCountList& The vCountList.
*/
void setVCountList(VCountList vCountList)
{
mVCountList = vCountList;
}
/** Adds @a number to the array*/
void appendValues ( const std::vector<unsigned long>& numberVec )
{
mSW->appendValues ( numberVec );
}
/** Adds @a number to the array*/
void appendValues ( const int number )
{
mSW->appendValues ( number );
}
/** Adds @a number to the array*/
void appendValues ( const unsigned int number )
{
mSW->appendValues ( number );
}
/** Adds @a number to the array*/
void appendValues ( const long number )
{
mSW->appendValues ( number );
}
/** Adds @a number to the array*/
void appendValues ( const unsigned long number )
{
mSW->appendValues ( number );
}
/** Adds @a number1 and @a number2 to the array*/
void appendValues ( const unsigned long number1, const unsigned long number2 )
{
mSW->appendValues ( number1, number2 );
}
/** Adds @a number1, @a number2 and @a number3 to the array*/
void appendValues ( const unsigned long number1, const unsigned long number2, const unsigned long number3 )
{
mSW->appendValues ( number1, number2, number3 );
}
/** Adds @a number1, @a number2, @a number3 and @a number4 to the array*/
void appendValues ( const unsigned long number1, const unsigned long number2, const unsigned long number3, const unsigned long number4 )
{
mSW->appendValues ( number1, number2, number3, number4 );
};
/**
* This function must be called after the last value has been added to
* the array and before another element has been opened
*/
void finish();
protected:
/**
* Prepares to fill the <p> element. This member must be called exactly
* once before add is called the first time.
* @param openPolyListElement If true, the <p> element will be opened.
* @param openVertexListElement
* If true, and the parameter @openPolylistElement is false,
* the <v> element will be opened.
*/
void prepareBaseToAppendValues ( bool openPolyListElement=true, bool openVertexListElement=false );
};
template<const String& primitiveName>
class Primitive : public PrimitivesBase
{
public:
Primitive ( StreamWriter* streamWriter )
: PrimitivesBase ( streamWriter, primitiveName )
{}
/** This constructor should never be called. It is only provided to make std::map happy*/
Primitive() : PrimitivesBase ( 0 )
{
assert ( false );
}
/** Copy constructor */
Primitive ( PrimitivesBase primitivesBase )
: PrimitivesBase ( primitivesBase ) {}
/** Prepares to fill the @a \<p\> element.
This member must be called exactly once before add is called the first time.*/
void prepareToAppendValues()
{
prepareBaseToAppendValues ( );
}
};
/**
* Class for the polygons element.
*/
class Polygons : public PrimitivesBase
{
public:
/**
* Constructor.
* @param streamWriter Pointer to the collada stream.
*/
Polygons ( StreamWriter* streamWriter )
: PrimitivesBase ( streamWriter, CSWC::CSW_ELEMENT_POLYGONS ) {}
/** Copy constructor */
Polygons ( PrimitivesBase primitivesBase )
: PrimitivesBase ( primitivesBase ) {}
/** We don't want to open the polylist tag */
void prepareToAppendValues()
{
prepareBaseToAppendValues ( false );
}
/**
* Opens the polylist hole element.
*/
void openPolylistHoleElement()
{
mSW->openElement ( CSWC::CSW_ELEMENT_PH );
}
/**
* Opens the hole element.
*/
void openHoleElement()
{
mSW->openElement ( CSWC::CSW_ELEMENT_H );
}
};
/**
* Class for the polygons element.
*/
class VertexWeightsElement : public PrimitivesBase
{
public:
/**
* Constructor.
* @param streamWriter Pointer to the collada stream.
*/
VertexWeightsElement ( StreamWriter* streamWriter )
: PrimitivesBase ( streamWriter, CSWC::CSW_ELEMENT_VERTEX_WEIGHTS ) {}
/** Copy constructor */
VertexWeightsElement ( PrimitivesBase primitivesBase )
: PrimitivesBase ( primitivesBase ) {}
/** We want to open the vertexlist tag. */
void prepareToAppendValues()
{
prepareBaseToAppendValues ( false, true );
}
/** Writes the \<wertex_weights\> element until the opening \<vcount\> element. Use this
function if you want to fill the \<vcount\> element using appandValues(). Call CloseVCountAndOpenVElement()
to start filling the \<v\> element.*/
void prepareToAppendVCountValues();
};
/**
* Class for the linestrips element.
*/
class Linestrips : public PrimitivesBase
{
public:
Linestrips ( StreamWriter* streamWriter )
: PrimitivesBase ( streamWriter, CSWC::CSW_ELEMENT_LINE_STRIPS ) {}
void prepareToAppendValues()
{
prepareBaseToAppendValues ( false, false );
}
private:
Linestrips ( const Linestrips& primitivesBase );
Linestrips& operator= ( const Linestrips& primitivesBase );
};
/**
* Class for the trifans element.
*/
class Trifans : public PrimitivesBase
{
public:
Trifans ( StreamWriter* streamWriter )
: PrimitivesBase ( streamWriter, CSWC::CSW_ELEMENT_TRIFANS ) {}
void prepareToAppendValues()
{
prepareBaseToAppendValues ( false, false );
}
private:
Trifans ( const Trifans& primitivesBase );
Trifans& operator= ( const Trifans& primitivesBase );
};
/**
* Class for the tristrips element.
*/
class Tristrips : public PrimitivesBase
{
public:
Tristrips ( StreamWriter* streamWriter )
: PrimitivesBase ( streamWriter, CSWC::CSW_ELEMENT_TRISTRIPS ) {}
void prepareToAppendValues()
{
prepareBaseToAppendValues ( false, false );
}
private:
Tristrips ( const Tristrips& primitivesBase );
Tristrips& operator= ( const Tristrips& primitivesBase );
};
typedef Primitive<CSWC::CSW_ELEMENT_LINES> Lines;
typedef Primitive<CSWC::CSW_ELEMENT_TRIANGLES> Triangles;
typedef Primitive<CSWC::CSW_ELEMENT_POLYLIST> Polylist;
} //namespace COLLADASW
#endif //__COLLADASTREAMWRITER_PRIMITIVES_H__
|