Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "vil3d_copy.h"
00009 #include <vcl_algorithm.h>
00010 #include <vil3d/vil3d_image_resource.h>
00011 #include <vil3d/vil3d_property.h>
00012
00013 #if 0
00014
00015 static const unsigned long large_image_limit = 1024ul * 1024ul * 16ul;
00016 #endif
00017
00018
00019
00020
00021
00022
00023
00024
00025 bool vil3d_copy_deep(const vil3d_image_resource_sptr &src, vil3d_image_resource_sptr &dest)
00026 {
00027 if (dest->ni() != src->ni() || dest->nj() != src->nj() || dest->nk() != src->nk() ||
00028 dest->nplanes() != src->nplanes() || dest->pixel_format() != src->pixel_format() )
00029 return false;
00030
00031 if (src->ni() == 0 || src->nj() == 0 || src->nk() == 0 || src->nplanes() == 0) return true;
00032
00033 float sizes[3];
00034 if (dest->get_property(vil3d_property_voxel_size, sizes))
00035 {
00036 dest->set_voxel_size(sizes[0], sizes[1], sizes[2]);
00037 }
00038
00039 vil3d_image_view_base_sptr view_ref = src->get_view();
00040 if (!view_ref) return false;
00041 return dest->put_view(*view_ref);
00042
00043 #if 0
00044 const unsigned long large_image_limit = 1024ul * 1024ul * 16ul;
00045 if (src->ni() * src->nj() * src->nk() * src->nplanes() >= large_image_limit)
00046 {
00047 unsigned got_to_slice =0;
00048 unsigned block_size = vcl_max(static_cast<unsigned>(large_image_limit / src->ni()),1u);
00049
00050 while (got_to_line < src->nj())
00051 {
00052 view_ref = src->get_view(0, src->ni(), got_to_slice, vcl_min(got_to_line+block_size, src->nj()));
00053 if (!view_ref) return false;
00054 if (!dest->put_view(*view_ref,0,got_to_line)) return false;
00055 got_to_line += block_size;
00056 }
00057 return true;
00058 }
00059 #endif
00060 }
00061