Home | History | Annotate | Download | only in dom
      1 /*
      2 * Copyright 2006 Sony Computer Entertainment Inc.
      3 *
      4 * Licensed under the MIT Open Source License, for details please see license.txt or the website
      5 * http://www.opensource.org/licenses/mit-license.php
      6 *
      7 */
      8 
      9 #ifndef __domPolygons_h__
     10 #define __domPolygons_h__
     11 
     12 #include <dae/daeDocument.h>
     13 #include <dom/domTypes.h>
     14 #include <dom/domElements.h>
     15 
     16 #include <dom/domP.h>
     17 #include <dom/domExtra.h>
     18 #include <dom/domInputLocalOffset.h>
     19 class DAE;
     20 
     21 /**
     22  * The polygons element provides the information needed to bind vertex attributes
     23  * together and  then organize those vertices into individual polygons. The
     24  * polygons described can contain  arbitrary numbers of vertices. These polygons
     25  * may be self intersecting and may also contain holes.
     26  */
     27 class domPolygons : public daeElement
     28 {
     29 public:
     30 	virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::POLYGONS; }
     31 	static daeInt ID() { return 620; }
     32 	virtual daeInt typeID() const { return ID(); }
     33 public:
     34 	class domPh;
     35 
     36 	typedef daeSmartRef<domPh> domPhRef;
     37 	typedef daeTArray<domPhRef> domPh_Array;
     38 
     39 /**
     40  * The ph element descripes a polygon with holes.
     41  */
     42 	class domPh : public daeElement
     43 	{
     44 	public:
     45 		virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::PH; }
     46 		static daeInt ID() { return 621; }
     47 		virtual daeInt typeID() const { return ID(); }
     48 	public:
     49 		class domH;
     50 
     51 		typedef daeSmartRef<domH> domHRef;
     52 		typedef daeTArray<domHRef> domH_Array;
     53 
     54 /**
     55  * The h element represents a hole in the polygon specified. There must be
     56  * at least one h element.
     57  */
     58 		class domH : public daeElement
     59 		{
     60 		public:
     61 			virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::H; }
     62 			static daeInt ID() { return 622; }
     63 			virtual daeInt typeID() const { return ID(); }
     64 
     65 		protected:  // Value
     66 			/**
     67 			 * The domListOfUInts value of the text data of this element.
     68 			 */
     69 			domListOfUInts _value;
     70 
     71 		public:	//Accessors and Mutators
     72 			/**
     73 			 * Gets the _value array.
     74 			 * @return Returns a domListOfUInts reference of the _value array.
     75 			 */
     76 			domListOfUInts &getValue() { return _value; }
     77 			/**
     78 			 * Gets the _value array.
     79 			 * @return Returns a constant domListOfUInts reference of the _value array.
     80 			 */
     81 			const domListOfUInts &getValue() const { return _value; }
     82 			/**
     83 			 * Sets the _value array.
     84 			 * @param val The new value for the _value array.
     85 			 */
     86 			void setValue( const domListOfUInts &val ) { _value = val; }
     87 
     88 		protected:
     89 			/**
     90 			 * Constructor
     91 			 */
     92 			domH(DAE& dae) : daeElement(dae), _value() {}
     93 			/**
     94 			 * Destructor
     95 			 */
     96 			virtual ~domH() {}
     97 			/**
     98 			 * Overloaded assignment operator
     99 			 */
    100 			virtual domH &operator=( const domH &cpy ) { (void)cpy; return *this; }
    101 
    102 		public: // STATIC METHODS
    103 			/**
    104 			 * Creates an instance of this class and returns a daeElementRef referencing it.
    105 			 * @return a daeElementRef referencing an instance of this object.
    106 			 */
    107 			static DLLSPEC daeElementRef create(DAE& dae);
    108 			/**
    109 			 * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
    110 			 * If a daeMetaElement already exists it will return that instead of creating a new one.
    111 			 * @return A daeMetaElement describing this COLLADA element.
    112 			 */
    113 			static DLLSPEC daeMetaElement* registerElement(DAE& dae);
    114 		};
    115 
    116 
    117 
    118 	protected:  // Elements
    119 /**
    120  *  Theere may only be one p element.  @see domP
    121  */
    122 		domPRef elemP;
    123 /**
    124  * The h element represents a hole in the polygon specified. There must be
    125  * at least one h element. @see domH
    126  */
    127 		domH_Array elemH_array;
    128 
    129 	public:	//Accessors and Mutators
    130 		/**
    131 		 * Gets the p element.
    132 		 * @return a daeSmartRef to the p element.
    133 		 */
    134 		const domPRef getP() const { return elemP; }
    135 		/**
    136 		 * Gets the h element array.
    137 		 * @return Returns a reference to the array of h elements.
    138 		 */
    139 		domH_Array &getH_array() { return elemH_array; }
    140 		/**
    141 		 * Gets the h element array.
    142 		 * @return Returns a constant reference to the array of h elements.
    143 		 */
    144 		const domH_Array &getH_array() const { return elemH_array; }
    145 	protected:
    146 		/**
    147 		 * Constructor
    148 		 */
    149 		domPh(DAE& dae) : daeElement(dae), elemP(), elemH_array() {}
    150 		/**
    151 		 * Destructor
    152 		 */
    153 		virtual ~domPh() {}
    154 		/**
    155 		 * Overloaded assignment operator
    156 		 */
    157 		virtual domPh &operator=( const domPh &cpy ) { (void)cpy; return *this; }
    158 
    159 	public: // STATIC METHODS
    160 		/**
    161 		 * Creates an instance of this class and returns a daeElementRef referencing it.
    162 		 * @return a daeElementRef referencing an instance of this object.
    163 		 */
    164 		static DLLSPEC daeElementRef create(DAE& dae);
    165 		/**
    166 		 * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
    167 		 * If a daeMetaElement already exists it will return that instead of creating a new one.
    168 		 * @return A daeMetaElement describing this COLLADA element.
    169 		 */
    170 		static DLLSPEC daeMetaElement* registerElement(DAE& dae);
    171 	};
    172 
    173 
    174 protected:  // Attributes
    175 /**
    176  *  The name attribute is the text string name of this element. Optional attribute.
    177  */
    178 	xsNCName attrName;
    179 /**
    180  *  The count attribute indicates the number of polygon primitives. Required
    181  * attribute.
    182  */
    183 	domUint attrCount;
    184 /**
    185  *  The material attribute declares a symbol for a material. This symbol is
    186  * bound to a material  at the time of instantiation. If the material attribute
    187  * is not specified then the lighting  and shading results are application
    188  * defined. Optional attribute.
    189  */
    190 	xsNCName attrMaterial;
    191 
    192 protected:  // Elements
    193 /**
    194  * The input element may occur any number of times. This input is a local
    195  * input with the  offset and set attributes. @see domInput
    196  */
    197 	domInputLocalOffset_Array elemInput_array;
    198 /**
    199  *  The p element may occur any number of times.  @see domP
    200  */
    201 	domP_Array elemP_array;
    202 /**
    203  * The ph element descripes a polygon with holes. @see domPh
    204  */
    205 	domPh_Array elemPh_array;
    206 /**
    207  *  The extra element may appear any number of times.  @see domExtra
    208  */
    209 	domExtra_Array elemExtra_array;
    210 	/**
    211 	 * Used to preserve order in elements that do not specify strict sequencing of sub-elements.
    212 	 */
    213 	daeElementRefArray _contents;
    214 	/**
    215 	 * Used to preserve order in elements that have a complex content model.
    216 	 */
    217 	daeUIntArray       _contentsOrder;
    218 
    219 	/**
    220 	 * Used to store information needed for some content model objects.
    221 	 */
    222 	daeTArray< daeCharArray * > _CMData;
    223 
    224 
    225 public:	//Accessors and Mutators
    226 	/**
    227 	 * Gets the name attribute.
    228 	 * @return Returns a xsNCName of the name attribute.
    229 	 */
    230 	xsNCName getName() const { return attrName; }
    231 	/**
    232 	 * Sets the name attribute.
    233 	 * @param atName The new value for the name attribute.
    234 	 */
    235 	void setName( xsNCName atName ) { *(daeStringRef*)&attrName = atName; _validAttributeArray[0] = true; }
    236 
    237 	/**
    238 	 * Gets the count attribute.
    239 	 * @return Returns a domUint of the count attribute.
    240 	 */
    241 	domUint getCount() const { return attrCount; }
    242 	/**
    243 	 * Sets the count attribute.
    244 	 * @param atCount The new value for the count attribute.
    245 	 */
    246 	void setCount( domUint atCount ) { attrCount = atCount; _validAttributeArray[1] = true; }
    247 
    248 	/**
    249 	 * Gets the material attribute.
    250 	 * @return Returns a xsNCName of the material attribute.
    251 	 */
    252 	xsNCName getMaterial() const { return attrMaterial; }
    253 	/**
    254 	 * Sets the material attribute.
    255 	 * @param atMaterial The new value for the material attribute.
    256 	 */
    257 	void setMaterial( xsNCName atMaterial ) { *(daeStringRef*)&attrMaterial = atMaterial; _validAttributeArray[2] = true; }
    258 
    259 	/**
    260 	 * Gets the input element array.
    261 	 * @return Returns a reference to the array of input elements.
    262 	 */
    263 	domInputLocalOffset_Array &getInput_array() { return elemInput_array; }
    264 	/**
    265 	 * Gets the input element array.
    266 	 * @return Returns a constant reference to the array of input elements.
    267 	 */
    268 	const domInputLocalOffset_Array &getInput_array() const { return elemInput_array; }
    269 	/**
    270 	 * Gets the p element array.
    271 	 * @return Returns a reference to the array of p elements.
    272 	 */
    273 	domP_Array &getP_array() { return elemP_array; }
    274 	/**
    275 	 * Gets the p element array.
    276 	 * @return Returns a constant reference to the array of p elements.
    277 	 */
    278 	const domP_Array &getP_array() const { return elemP_array; }
    279 	/**
    280 	 * Gets the ph element array.
    281 	 * @return Returns a reference to the array of ph elements.
    282 	 */
    283 	domPh_Array &getPh_array() { return elemPh_array; }
    284 	/**
    285 	 * Gets the ph element array.
    286 	 * @return Returns a constant reference to the array of ph elements.
    287 	 */
    288 	const domPh_Array &getPh_array() const { return elemPh_array; }
    289 	/**
    290 	 * Gets the extra element array.
    291 	 * @return Returns a reference to the array of extra elements.
    292 	 */
    293 	domExtra_Array &getExtra_array() { return elemExtra_array; }
    294 	/**
    295 	 * Gets the extra element array.
    296 	 * @return Returns a constant reference to the array of extra elements.
    297 	 */
    298 	const domExtra_Array &getExtra_array() const { return elemExtra_array; }
    299 	/**
    300 	 * Gets the _contents array.
    301 	 * @return Returns a reference to the _contents element array.
    302 	 */
    303 	daeElementRefArray &getContents() { return _contents; }
    304 	/**
    305 	 * Gets the _contents array.
    306 	 * @return Returns a constant reference to the _contents element array.
    307 	 */
    308 	const daeElementRefArray &getContents() const { return _contents; }
    309 
    310 protected:
    311 	/**
    312 	 * Constructor
    313 	 */
    314 	domPolygons(DAE& dae) : daeElement(dae), attrName(), attrCount(), attrMaterial(), elemInput_array(), elemP_array(), elemPh_array(), elemExtra_array() {}
    315 	/**
    316 	 * Destructor
    317 	 */
    318 	virtual ~domPolygons() { daeElement::deleteCMDataArray(_CMData); }
    319 	/**
    320 	 * Overloaded assignment operator
    321 	 */
    322 	virtual domPolygons &operator=( const domPolygons &cpy ) { (void)cpy; return *this; }
    323 
    324 public: // STATIC METHODS
    325 	/**
    326 	 * Creates an instance of this class and returns a daeElementRef referencing it.
    327 	 * @return a daeElementRef referencing an instance of this object.
    328 	 */
    329 	static DLLSPEC daeElementRef create(DAE& dae);
    330 	/**
    331 	 * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
    332 	 * If a daeMetaElement already exists it will return that instead of creating a new one.
    333 	 * @return A daeMetaElement describing this COLLADA element.
    334 	 */
    335 	static DLLSPEC daeMetaElement* registerElement(DAE& dae);
    336 };
    337 
    338 
    339 #endif
    340