MCPcopy Create free account
hub / github.com/Kitware/VTK / MarshalDataObject

Method MarshalDataObject

Parallel/Core/vtkCommunicator.cxx:501–574  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

499
500//------------------------------------------------------------------------------
501int vtkCommunicator::MarshalDataObject(vtkDataObject* object, vtkCharArray* buffer)
502{
503 buffer->Initialize();
504 buffer->SetNumberOfComponents(1);
505
506 if (object == nullptr)
507 {
508 buffer->SetNumberOfTuples(0);
509 return 1;
510 }
511
512 VTK_CREATE(vtkGenericDataObjectWriter, writer);
513
514 vtkSmartPointer<vtkDataObject> copy;
515 copy.TakeReference(object->NewInstance());
516 copy->ShallowCopy(object);
517
518 writer->SetFileTypeToBinary();
519 // There is a problem with binary files with no data.
520 if (vtkDataSet::SafeDownCast(copy) != nullptr)
521 {
522 vtkDataSet* ds = vtkDataSet::SafeDownCast(copy);
523 if (ds->GetNumberOfCells() + ds->GetNumberOfPoints() == 0)
524 {
525 writer->SetFileTypeToASCII();
526 }
527 }
528 writer->WriteToOutputStringOn();
529 writer->SetInputData(copy);
530
531 if (!writer->Write())
532 {
533 vtkGenericWarningMacro("Error detected while marshaling data object.");
534 return 0;
535 }
536 const vtkIdType size = writer->GetOutputStringLength();
537 if (object->GetExtentType() == VTK_3D_EXTENT)
538 {
539 // You would think that the extent information would be properly saved, but
540 // no, it is not.
541 int extent[6] = { 0, 0, 0, 0, 0, 0 };
542 vtkRectilinearGrid* rg = vtkRectilinearGrid::SafeDownCast(object);
543 vtkStructuredGrid* sg = vtkStructuredGrid::SafeDownCast(object);
544 vtkImageData* id = vtkImageData::SafeDownCast(object);
545 if (rg)
546 {
547 rg->GetExtent(extent);
548 }
549 else if (sg)
550 {
551 sg->GetExtent(extent);
552 }
553 else if (id)
554 {
555 id->GetExtent(extent);
556 }
557 char extentHeader[EXTENT_HEADER_SIZE];
558 auto result =

Callers 1

Calls 15

format_to_nFunction · 0.50
InitializeMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNumberOfTuplesMethod · 0.45
TakeReferenceMethod · 0.45
NewInstanceMethod · 0.45
ShallowCopyMethod · 0.45
GetNumberOfCellsMethod · 0.45
GetNumberOfPointsMethod · 0.45
SetInputDataMethod · 0.45
WriteMethod · 0.45
GetExtentMethod · 0.45

Tested by

no test coverage detected