27 #include "MeshImplTags.hpp"
28 #include "MsqError.hpp"
50 for (msq_std::vector<TagData*>::iterator iter =
tagList.begin();
66 default: assert(0);
return 0;
76 size_t h =
handle( name, err );
89 TagData* tag =
new TagData( name, type, length );
95 tag->defaultValue = malloc( tag->desc.size );
96 memcpy( tag->defaultValue, defval, tag->desc.size );
105 size_t h =
handle( desc.name.c_str(), err );
118 TagData* tag =
new TagData( desc );
149 static TagDescription dummy_desc;
158 return tagList[tag_index]->desc;
164 const size_t* index_array,
177 TagData* tag =
tagList[tag_index];
180 size_t total = tag->elementCount;
181 for (i = 0; i < num_indices; ++
i)
182 if (index_array[i] >= total)
183 total = index_array[
i] + 1;
186 if (total > tag->elementCount)
189 tag->elementData = realloc( tag->elementData, tag->desc.size * total );
191 if (tag->defaultValue)
193 data = ((
char*)tag->elementData) + tag->elementCount * tag->desc.size;
194 for (i = tag->elementCount; i < total; ++i)
196 memcpy( data, tag->defaultValue, tag->desc.size );
197 data += tag->desc.size;
200 tag->elementCount = total;
204 data = (
char*)tag->elementData;
205 const char* iter = (
const char*)values;
206 for (i = 0; i < num_indices; ++
i)
208 memcpy( data + index_array[i]*tag->desc.size, iter, tag->desc.size );
209 iter += tag->desc.size;
215 const size_t* index_array,
217 MsqError& err )
const
226 TagData* tag =
tagList[tag_index];
228 char* iter = (
char*)values;
229 const char* data = (
const char*)tag->elementData;
231 for (
size_t i = 0; i < num_indices; ++
i)
234 size_t index = index_array[
i];
235 if (index >= tag->elementCount)
237 ptr = tag->defaultValue;
246 ptr = data + index * tag->desc.size;
249 memcpy( iter, ptr, tag->desc.size );
250 iter += tag->desc.size;
256 const size_t* index_array,
269 TagData* tag =
tagList[tag_index];
272 size_t total = tag->vertexCount;
273 for (i = 0; i < num_indices; ++
i)
274 if (index_array[i] >= total)
275 total = index_array[
i] + 1;
278 if (total > tag->vertexCount)
281 tag->vertexData = realloc( tag->vertexData, tag->desc.size * total );
283 if (tag->defaultValue)
285 data = ((
char*)tag->vertexData) + tag->vertexCount * tag->desc.size;
286 for (i = tag->vertexCount; i < total; ++i)
288 memcpy( data, tag->defaultValue, tag->desc.size );
289 data += tag->desc.size;
292 tag->vertexCount = total;
296 data = (
char*)tag->vertexData;
297 const char* iter = (
const char*)values;
298 for (i = 0; i < num_indices; ++
i)
300 memcpy( data + index_array[i]*tag->desc.size, iter, tag->desc.size );
301 iter += tag->desc.size;
307 const size_t* index_array,
309 MsqError& err )
const
318 TagData* tag =
tagList[tag_index];
320 char* iter = (
char*)values;
321 const char* data = (
const char*)tag->vertexData;
323 for (
size_t i = 0; i < num_indices; ++
i)
326 size_t index = index_array[
i];
327 if (index >= tag->vertexCount)
329 ptr = tag->defaultValue;
338 ptr = data + index * tag->desc.size;
341 memcpy( iter, ptr, tag->desc.size );
342 iter += tag->desc.size;
355 TagData* tag =
tagList[tag_index];
356 return 0 != tag->vertexData || tag->defaultValue;
368 TagData* tag =
tagList[tag_index];
369 return 0 != tag->elementData || tag->defaultValue;
377 return TagIterator(
this, index );
383 while (index < tags->
tagList.size() || NULL == tags->tagList[index])
385 return TagIterator( tags, index );
391 while (index < tags->
tagList.size() || NULL == tags->tagList[index])
393 return TagIterator( tags, index );
400 while (index < tags->
tagList.size() || NULL == tags->tagList[index])
402 return TagIterator( tags, old );
409 while (index < tags->
tagList.size() || NULL == tags->tagList[index])
411 return TagIterator( tags, old );
TagType
The type of a tag.
Attempt to create tag that already exists.
double length(Vector3D *const v, int n)
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
Specified tag does not exist.