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 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkDataObject.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkDataObject.h"
#include "vtkDataSetAttributes.h"
#include "vtkFieldData.h"
#include "vtkGarbageCollector.h"
#include "vtkInformation.h"
#include "vtkObjectFactory.h"
#include "vtkInformationDataObjectKey.h"
#include "vtkInformationDoubleKey.h"
#include "vtkInformationDoubleVectorKey.h"
#include "vtkInformationIntegerKey.h"
#include "vtkInformationIntegerPointerKey.h"
#include "vtkInformationIntegerVectorKey.h"
#include "vtkInformationInformationVectorKey.h"
#include "vtkInformationStringKey.h"
#include "vtkInformationVector.h"
#include "vtkDataSetAttributes.h"
vtkStandardNewMacro(vtkDataObject);
vtkCxxSetObjectMacro(vtkDataObject,Information,vtkInformation);
vtkCxxSetObjectMacro(vtkDataObject,FieldData,vtkFieldData);
vtkInformationKeyMacro(vtkDataObject, DATA_TYPE_NAME, String);
vtkInformationKeyMacro(vtkDataObject, DATA_OBJECT, DataObject);
vtkInformationKeyMacro(vtkDataObject, DATA_EXTENT_TYPE, Integer);
vtkInformationKeyMacro(vtkDataObject, DATA_PIECE_NUMBER, Integer);
vtkInformationKeyMacro(vtkDataObject, DATA_NUMBER_OF_PIECES, Integer);
vtkInformationKeyMacro(vtkDataObject, DATA_NUMBER_OF_GHOST_LEVELS, Integer);
vtkInformationKeyMacro(vtkDataObject, DATA_TIME_STEP, Double);
vtkInformationKeyMacro(vtkDataObject, POINT_DATA_VECTOR, InformationVector);
vtkInformationKeyMacro(vtkDataObject, CELL_DATA_VECTOR, InformationVector);
vtkInformationKeyMacro(vtkDataObject, VERTEX_DATA_VECTOR, InformationVector);
vtkInformationKeyMacro(vtkDataObject, EDGE_DATA_VECTOR, InformationVector);
vtkInformationKeyMacro(vtkDataObject, FIELD_ARRAY_TYPE, Integer);
vtkInformationKeyMacro(vtkDataObject, FIELD_ASSOCIATION, Integer);
vtkInformationKeyMacro(vtkDataObject, FIELD_ATTRIBUTE_TYPE, Integer);
vtkInformationKeyMacro(vtkDataObject, FIELD_ACTIVE_ATTRIBUTE, Integer);
vtkInformationKeyMacro(vtkDataObject, FIELD_NAME, String);
vtkInformationKeyMacro(vtkDataObject, FIELD_NUMBER_OF_COMPONENTS, Integer);
vtkInformationKeyMacro(vtkDataObject, FIELD_NUMBER_OF_TUPLES, Integer);
vtkInformationKeyRestrictedMacro(vtkDataObject, FIELD_RANGE, DoubleVector, 2);
vtkInformationKeyRestrictedMacro(vtkDataObject, PIECE_EXTENT, IntegerVector, 6);
vtkInformationKeyMacro(vtkDataObject, FIELD_OPERATION, Integer);
vtkInformationKeyRestrictedMacro(vtkDataObject, ALL_PIECES_EXTENT, IntegerVector, 6);
vtkInformationKeyRestrictedMacro(vtkDataObject, DATA_EXTENT, IntegerPointer, 6);
vtkInformationKeyRestrictedMacro(vtkDataObject, ORIGIN, DoubleVector, 3);
vtkInformationKeyRestrictedMacro(vtkDataObject, SPACING, DoubleVector, 3);
vtkInformationKeyMacro(vtkDataObject, SIL, DataObject);
vtkInformationKeyRestrictedMacro(vtkDataObject, BOUNDING_BOX, DoubleVector, 6);
// Initialize static member that controls global data release
// after use by filter
static int vtkDataObjectGlobalReleaseDataFlag = 0;
// this list must be kept in-sync with the FieldAssociations enum
static const char *FieldAssociationsNames[] = {
"vtkDataObject::FIELD_ASSOCIATION_POINTS",
"vtkDataObject::FIELD_ASSOCIATION_CELLS",
"vtkDataObject::FIELD_ASSOCIATION_NONE",
"vtkDataObject::FIELD_ASSOCIATION_POINTS_THEN_CELLS",
"vtkDataObject::FIELD_ASSOCIATION_VERTICES",
"vtkDataObject::FIELD_ASSOCIATION_EDGES",
"vtkDataObject::FIELD_ASSOCIATION_ROWS"
};
// this list must be kept in-sync with the AttributeTypes enum
static const char *AttributeTypesNames[] = {
"vtkDataObject::POINT",
"vtkDataObject::CELL",
"vtkDataObject::FIELD",
"vtkDataObject::POINT_THEN_CELL",
"vtkDataObject::VERTEX",
"vtkDataObject::EDGE",
"vtkDataObject::ROW"
};
//----------------------------------------------------------------------------
vtkDataObject::vtkDataObject()
{
this->Information = vtkInformation::New();
// We have to assume that if a user is creating the data on their own,
// then they will fill it with valid data.
this->DataReleased = 0;
this->FieldData = NULL;
vtkFieldData *fd = vtkFieldData::New();
this->SetFieldData(fd);
fd->FastDelete();
}
//----------------------------------------------------------------------------
vtkDataObject::~vtkDataObject()
{
this->SetInformation(0);
this->SetFieldData(NULL);
}
//----------------------------------------------------------------------------
void vtkDataObject::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
if ( this->Information )
{
os << indent << "Information: " << this->Information << "\n";
}
else
{
os << indent << "Information: (none)\n";
}
os << indent << "Data Released: "
<< (this->DataReleased ? "True\n" : "False\n");
os << indent << "Global Release Data: "
<< (vtkDataObjectGlobalReleaseDataFlag ? "On\n" : "Off\n");
os << indent << "UpdateTime: " << this->UpdateTime << endl;
os << indent << "Field Data:\n";
this->FieldData->PrintSelf(os,indent.GetNextIndent());
}
//----------------------------------------------------------------------------
// Determine the modified time of this object
unsigned long int vtkDataObject::GetMTime()
{
unsigned long result;
result = vtkObject::GetMTime();
if ( this->FieldData )
{
unsigned long mtime = this->FieldData->GetMTime();
result = ( mtime > result ? mtime : result);
}
return result;
}
//----------------------------------------------------------------------------
void vtkDataObject::Initialize()
{
if (this->FieldData)
{
this->FieldData->Initialize();
}
if (this->Information)
{
// Make sure the information is cleared.
this->Information->Remove(ALL_PIECES_EXTENT());
this->Information->Remove(DATA_PIECE_NUMBER());
this->Information->Remove(DATA_NUMBER_OF_PIECES());
this->Information->Remove(DATA_NUMBER_OF_GHOST_LEVELS());
this->Information->Remove(DATA_TIME_STEP());
}
this->Modified();
}
//----------------------------------------------------------------------------
void vtkDataObject::SetGlobalReleaseDataFlag(int val)
{
if (val == vtkDataObjectGlobalReleaseDataFlag)
{
return;
}
vtkDataObjectGlobalReleaseDataFlag = val;
}
//----------------------------------------------------------------------------
vtkInformation *vtkDataObject::GetActiveFieldInformation(vtkInformation *info,
int fieldAssociation, int attributeType)
{
int i;
vtkInformation *fieldDataInfo;
vtkInformationVector *fieldDataInfoVector;
if (fieldAssociation == FIELD_ASSOCIATION_POINTS)
{
fieldDataInfoVector = info->Get(POINT_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_CELLS)
{
fieldDataInfoVector = info->Get(CELL_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_VERTICES)
{
fieldDataInfoVector = info->Get(VERTEX_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_EDGES)
{
fieldDataInfoVector = info->Get(EDGE_DATA_VECTOR());
}
else
{
vtkGenericWarningMacro("Unrecognized field association!");
return NULL;
}
if (!fieldDataInfoVector)
{
return NULL;
}
for (i = 0; i < fieldDataInfoVector->GetNumberOfInformationObjects(); i++)
{
fieldDataInfo = fieldDataInfoVector->GetInformationObject(i);
if ( fieldDataInfo->Has(FIELD_ACTIVE_ATTRIBUTE()) &&
(fieldDataInfo->Get(FIELD_ACTIVE_ATTRIBUTE()) & (1 << attributeType )) )
{
return fieldDataInfo;
}
}
return NULL;
}
//----------------------------------------------------------------------------
vtkInformation *vtkDataObject::GetNamedFieldInformation(vtkInformation *info,
int fieldAssociation,
const char *name)
{
int i;
vtkInformation *fieldDataInfo;
vtkInformationVector *fieldDataInfoVector;
if (fieldAssociation == FIELD_ASSOCIATION_POINTS)
{
fieldDataInfoVector = info->Get(POINT_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_CELLS)
{
fieldDataInfoVector = info->Get(CELL_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_VERTICES)
{
fieldDataInfoVector = info->Get(VERTEX_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_EDGES)
{
fieldDataInfoVector = info->Get(EDGE_DATA_VECTOR());
}
else
{
vtkGenericWarningMacro("Unrecognized field association!");
return NULL;
}
if (!fieldDataInfoVector)
{
return NULL;
}
for (i = 0; i < fieldDataInfoVector->GetNumberOfInformationObjects(); i++)
{
fieldDataInfo = fieldDataInfoVector->GetInformationObject(i);
if ( fieldDataInfo->Has(FIELD_NAME()) &&
!strcmp(fieldDataInfo->Get(FIELD_NAME()),name))
{
return fieldDataInfo;
}
}
return NULL;
}
//----------------------------------------------------------------------------
void vtkDataObject::RemoveNamedFieldInformation(vtkInformation *info,
int fieldAssociation,
const char *name)
{
int i;
vtkInformation *fieldDataInfo;
vtkInformationVector *fieldDataInfoVector;
if (fieldAssociation == FIELD_ASSOCIATION_POINTS)
{
fieldDataInfoVector = info->Get(POINT_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_CELLS)
{
fieldDataInfoVector = info->Get(CELL_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_VERTICES)
{
fieldDataInfoVector = info->Get(VERTEX_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_EDGES)
{
fieldDataInfoVector = info->Get(EDGE_DATA_VECTOR());
}
else
{
vtkGenericWarningMacro("Unrecognized field association!");
return;
}
if (!fieldDataInfoVector)
{
return;
}
for (i = 0; i < fieldDataInfoVector->GetNumberOfInformationObjects(); i++)
{
fieldDataInfo = fieldDataInfoVector->GetInformationObject(i);
if ( fieldDataInfo->Has(FIELD_NAME()) &&
!strcmp(fieldDataInfo->Get(FIELD_NAME()),name))
{
fieldDataInfoVector->Remove(fieldDataInfo);
return;
}
}
return;
}
//----------------------------------------------------------------------------
vtkInformation *vtkDataObject::SetActiveAttribute(vtkInformation *info,
int fieldAssociation,
const char *attributeName,
int attributeType)
{
int i;
vtkInformation *fieldDataInfo;
vtkInformationVector *fieldDataInfoVector;
if (fieldAssociation == FIELD_ASSOCIATION_POINTS)
{
fieldDataInfoVector = info->Get(POINT_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_CELLS)
{
fieldDataInfoVector = info->Get(CELL_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_VERTICES)
{
fieldDataInfoVector = info->Get(VERTEX_DATA_VECTOR());
}
else if (fieldAssociation == FIELD_ASSOCIATION_EDGES)
{
fieldDataInfoVector = info->Get(EDGE_DATA_VECTOR());
}
else
{
vtkGenericWarningMacro("Unrecognized field association!");
return NULL;
}
if (!fieldDataInfoVector)
{
fieldDataInfoVector = vtkInformationVector::New();
if (fieldAssociation == FIELD_ASSOCIATION_POINTS)
{
info->Set(POINT_DATA_VECTOR(), fieldDataInfoVector);
}
else if (fieldAssociation == FIELD_ASSOCIATION_CELLS)
{
info->Set(CELL_DATA_VECTOR(), fieldDataInfoVector);
}
else if (fieldAssociation == FIELD_ASSOCIATION_VERTICES)
{
info->Set(VERTEX_DATA_VECTOR(), fieldDataInfoVector);
}
else // if (fieldAssociation == FIELD_ASSOCIATION_EDGES)
{
info->Set(EDGE_DATA_VECTOR(), fieldDataInfoVector);
}
fieldDataInfoVector->FastDelete();
}
// if we find a matching field, turn it on (active); if another field of same
// attribute type was active, turn it off (not active)
vtkInformation *activeField = NULL;
int activeAttribute;
const char *fieldName;
for (i = 0; i < fieldDataInfoVector->GetNumberOfInformationObjects(); i++)
{
fieldDataInfo = fieldDataInfoVector->GetInformationObject(i);
activeAttribute = fieldDataInfo->Get( FIELD_ACTIVE_ATTRIBUTE() );
fieldName = fieldDataInfo->Get(FIELD_NAME());
// if names match (or both empty... no field name), then set active
if ( (attributeName && fieldName && !strcmp(attributeName, fieldName)) ||
(!attributeName && !fieldName) )
{
activeAttribute |= 1 << attributeType;
fieldDataInfo->Set( FIELD_ACTIVE_ATTRIBUTE(), activeAttribute );
activeField = fieldDataInfo;
}
else if ( activeAttribute & (1 << attributeType) )
{
activeAttribute &= ~(1 << attributeType);
fieldDataInfo->Set( FIELD_ACTIVE_ATTRIBUTE(), activeAttribute );
}
}
// if we didn't find a matching field, create one
if (!activeField)
{
activeField = vtkInformation::New();
activeField->Set( FIELD_ACTIVE_ATTRIBUTE(), 1 << attributeType);
activeField->Set(FIELD_ASSOCIATION(), fieldAssociation);
if (attributeName)
{
activeField->Set( FIELD_NAME(), attributeName );
}
fieldDataInfoVector->Append(activeField);
activeField->FastDelete();
}
return activeField;
}
//----------------------------------------------------------------------------
void vtkDataObject::SetActiveAttributeInfo(vtkInformation *info,
int fieldAssociation,
int attributeType,
const char *name,
int arrayType,
int numComponents,
int numTuples)
{
vtkInformation *attrInfo = vtkDataObject::GetActiveFieldInformation(info,
fieldAssociation, attributeType);
if (!attrInfo)
{
// create an entry and set it as active
attrInfo = SetActiveAttribute(info, fieldAssociation, name, attributeType);
}
if (name)
{
attrInfo->Set(FIELD_NAME(), name);
}
// Set the scalar type if it was given. If it was not given and
// there is no current scalar type set the default to VTK_DOUBLE.
if (arrayType != -1)
{
attrInfo->Set(FIELD_ARRAY_TYPE(), arrayType);
}
else if(!attrInfo->Has(FIELD_ARRAY_TYPE()))
{
attrInfo->Set(FIELD_ARRAY_TYPE(), VTK_DOUBLE);
}
// Set the number of components if it was given. If it was not
// given and there is no current number of components set the
// default to 1.
if (numComponents != -1)
{
attrInfo->Set(FIELD_NUMBER_OF_COMPONENTS(), numComponents);
}
else if(!attrInfo->Has(FIELD_NUMBER_OF_COMPONENTS()))
{
attrInfo->Set(FIELD_NUMBER_OF_COMPONENTS(), 1);
}
if (numTuples != -1)
{
attrInfo->Set(FIELD_NUMBER_OF_TUPLES(), numTuples);
}
}
//----------------------------------------------------------------------------
void vtkDataObject::SetPointDataActiveScalarInfo(vtkInformation *info,
int arrayType, int numComponents)
{
vtkDataObject::SetActiveAttributeInfo(info, FIELD_ASSOCIATION_POINTS,
vtkDataSetAttributes::SCALARS, NULL, arrayType, numComponents, -1);
}
//----------------------------------------------------------------------------
void vtkDataObject::DataHasBeenGenerated()
{
this->DataReleased = 0;
this->UpdateTime.Modified();
}
//----------------------------------------------------------------------------
int vtkDataObject::GetGlobalReleaseDataFlag()
{
return vtkDataObjectGlobalReleaseDataFlag;
}
//----------------------------------------------------------------------------
void vtkDataObject::ReleaseData()
{
this->Initialize();
this->DataReleased = 1;
}
//----------------------------------------------------------------------------
unsigned long vtkDataObject::GetUpdateTime()
{
return this->UpdateTime.GetMTime();
}
//----------------------------------------------------------------------------
unsigned long vtkDataObject::GetActualMemorySize()
{
return this->FieldData->GetActualMemorySize();
}
//----------------------------------------------------------------------------
void vtkDataObject::ShallowCopy(vtkDataObject *src)
{
if (!src)
{
vtkWarningMacro("Attempted to ShallowCopy from null.");
return;
}
this->InternalDataObjectCopy(src);
if (!src->FieldData)
{
this->SetFieldData(0);
}
else
{
if (this->FieldData)
{
this->FieldData->ShallowCopy(src->FieldData);
}
else
{
vtkFieldData* fd = vtkFieldData::New();
fd->ShallowCopy(src->FieldData);
this->SetFieldData(fd);
fd->FastDelete();
}
}
}
//----------------------------------------------------------------------------
void vtkDataObject::DeepCopy(vtkDataObject *src)
{
vtkFieldData *srcFieldData = src->GetFieldData();
this->InternalDataObjectCopy(src);
if (srcFieldData)
{
vtkFieldData *newFieldData = vtkFieldData::New();
newFieldData->DeepCopy(srcFieldData);
this->SetFieldData(newFieldData);
newFieldData->FastDelete();
}
else
{
this->SetFieldData(NULL);
}
}
//----------------------------------------------------------------------------
void vtkDataObject::InternalDataObjectCopy(vtkDataObject *src)
{
this->DataReleased = src->DataReleased;
// Do not copy pipeline specific information from data object to
// data object. This meta-data is specific to the algorithm and the
// what was requested of it when it executed. What looks like a single
// piece to an internal algorithm may be a piece to an external
// algorithm.
/*
if(src->Information->Has(DATA_PIECE_NUMBER()))
{
this->Information->Set(DATA_PIECE_NUMBER(),
src->Information->Get(DATA_PIECE_NUMBER()));
}
if(src->Information->Has(DATA_NUMBER_OF_PIECES()))
{
this->Information->Set(DATA_NUMBER_OF_PIECES(),
src->Information->Get(DATA_NUMBER_OF_PIECES()));
}
if(src->Information->Has(DATA_NUMBER_OF_GHOST_LEVELS()))
{
this->Information->Set(DATA_NUMBER_OF_GHOST_LEVELS(),
src->Information->Get(DATA_NUMBER_OF_GHOST_LEVELS()));
}
*/
if(src->Information->Has(DATA_TIME_STEP()))
{
this->Information->CopyEntry(src->Information, DATA_TIME_STEP(), 1);
}
// This also caused a pipeline problem.
// An input pipelineMTime was copied to output. Pipeline did not execute...
// We do not copy MTime of object, so why should we copy these.
//this->PipelineMTime = src->PipelineMTime;
//this->UpdateTime = src->UpdateTime;
//this->Locality = src->Locality;
}
//----------------------------------------------------------------------------
// This should be a pure virtual method.
void vtkDataObject::Crop(const int*)
{
}
//----------------------------------------------------------------------------
vtkDataObject* vtkDataObject::GetData(vtkInformation* info)
{
return info? info->Get(DATA_OBJECT()) : 0;
}
//----------------------------------------------------------------------------
vtkDataObject* vtkDataObject::GetData(vtkInformationVector* v, int i)
{
return vtkDataObject::GetData(v->GetInformationObject(i));
}
//----------------------------------------------------------------------------
const char* vtkDataObject::GetAssociationTypeAsString(int associationType)
{
if (associationType < 0 || associationType >= NUMBER_OF_ASSOCIATIONS)
{
vtkGenericWarningMacro("Bad association type.");
return NULL;
}
return FieldAssociationsNames[associationType];
}
//----------------------------------------------------------------------------
int vtkDataObject::GetAssociationTypeFromString(const char* associationName)
{
if (!associationName)
{
vtkGenericWarningMacro("NULL association name.");
return -1;
}
// check for the name in the FieldAssociations enum
for(int i = 0; i < NUMBER_OF_ASSOCIATIONS; i++)
{
if(!strcmp(associationName, FieldAssociationsNames[i]))
{
return i;
}
}
// check for the name in the AttributeTypes enum
for(int i = 0; i < NUMBER_OF_ATTRIBUTE_TYPES; i++)
{
if(!strcmp(associationName, AttributeTypesNames[i]))
{
return i;
}
}
vtkGenericWarningMacro("Bad association name \"" << associationName << "\".");
return -1;
}
//----------------------------------------------------------------------------
vtkDataSetAttributes* vtkDataObject::GetAttributes(int type)
{
return vtkDataSetAttributes::SafeDownCast(this->GetAttributesAsFieldData(type));
}
//----------------------------------------------------------------------------
vtkFieldData* vtkDataObject::GetAttributesAsFieldData(int type)
{
switch (type)
{
case FIELD:
return this->FieldData;
}
return 0;
}
//----------------------------------------------------------------------------
int vtkDataObject::GetAttributeTypeForArray(vtkAbstractArray* arr)
{
for (int i = 0; i < NUMBER_OF_ATTRIBUTE_TYPES; ++i)
{
vtkFieldData* data = this->GetAttributesAsFieldData(i);
if (data)
{
for (int j = 0; j < data->GetNumberOfArrays(); ++j)
{
if (data->GetAbstractArray(j) == arr)
{
return i;
}
}
}
}
return -1;
}
//----------------------------------------------------------------------------
vtkIdType vtkDataObject::GetNumberOfElements(int type)
{
switch (type)
{
case FIELD:
return this->FieldData->GetNumberOfTuples();
}
return 0;
}
|