| 634 | } |
| 635 | |
| 636 | bool mitk::Image::SetImportVolume(void *data, int t, int n, ImportMemoryManagementType importMemoryManagement) |
| 637 | { |
| 638 | if (IsValidVolume(t, n) == false) |
| 639 | return false; |
| 640 | |
| 641 | const size_t ptypeSize = this->m_ImageDescriptor->GetChannelTypeById(n).GetSize(); |
| 642 | ImageDataItemPointer vol; |
| 643 | if (IsVolumeSet(t, n)) |
| 644 | { |
| 645 | vol = GetVolumeData(t, n, data, importMemoryManagement); |
| 646 | if (vol->GetManageMemory() == false) |
| 647 | { |
| 648 | vol = AllocateVolumeData(t, n, data, importMemoryManagement); |
| 649 | if (vol.GetPointer() == nullptr) |
| 650 | return false; |
| 651 | } |
| 652 | if (vol->GetData() != data) |
| 653 | std::memcpy(vol->GetData(), data, m_OffsetTable[3] * (ptypeSize)); |
| 654 | vol->Modified(); |
| 655 | vol->SetComplete(true); |
| 656 | // we have changed the data: call Modified()! |
| 657 | Modified(); |
| 658 | } |
| 659 | else |
| 660 | { |
| 661 | vol = AllocateVolumeData(t, n, data, importMemoryManagement); |
| 662 | if (vol.GetPointer() == nullptr) |
| 663 | return false; |
| 664 | if (vol->GetData() != data) |
| 665 | { |
| 666 | std::memcpy(vol->GetData(), data, m_OffsetTable[3] * (ptypeSize)); |
| 667 | } |
| 668 | vol->SetComplete(true); |
| 669 | this->m_ImageDescriptor->GetChannelDescriptor(n).SetData(vol->GetData()); |
| 670 | // we just added a missing Volume, which is not regarded as modification. |
| 671 | // Therefore, we do not call Modified()! |
| 672 | } |
| 673 | return true; |
| 674 | } |
| 675 | |
| 676 | bool mitk::Image::SetImportVolume(const void *const_data, int t, int n) |
| 677 | { |