/usr/include/vtk-6.3/vtkPixelTransfer.h is in libvtk6-dev 6.3.0+dfsg1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkPixelTransfer.h
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.
=========================================================================*/
// .NAME vtkPixelTransfer -- For movement of pixel data described by
// pixel extents
//
// .SECTION Description
// Class to handle non-contiguous data transfers of data described
// by pixel extents within a process. For transfering data between
// processes see vtkPPixelTransfer.
//
// .SECTION See also
// vtkPixelExtent vtkPPixelTransfer
#ifndef vtkPixelTransfer_h
#define vtkPixelTransfer_h
#include "vtkRenderingLICModule.h" // for export
#include "vtkSetGet.h" // for macros
#include "vtkPixelExtent.h" // for pixel extent
#include <cstring> // for memcpy
class VTKRENDERINGLIC_EXPORT vtkPixelTransfer
{
public:
vtkPixelTransfer(){}
~vtkPixelTransfer(){}
// Description:
// for memory to memory transfers. Conveinience api for working
// with vtk type enum rather than c-data types and simple extents.
static
int Blit(
const vtkPixelExtent &ext,
int nComps,
int srcType,
void *srcData,
int destType,
void *destData);
// Description:
// for memory to memory transfers. Conveinience api for working
// with vtk type enum rather than c-data types.
static
int Blit(
const vtkPixelExtent &srcWhole,
const vtkPixelExtent &srcSubset,
const vtkPixelExtent &destWhole,
const vtkPixelExtent &destSubset,
int nSrcComps,
int srcType,
void *srcData,
int nDestComps,
int destType,
void *destData);
// Description:
// for local memory to memory transfers
template<typename SOURCE_TYPE, typename DEST_TYPE>
static
int Blit(
const vtkPixelExtent &srcWhole,
const vtkPixelExtent &srcSubset,
const vtkPixelExtent &destWhole,
const vtkPixelExtent &destSubset,
int nSrcComps,
SOURCE_TYPE *srcData,
int nDestComps,
DEST_TYPE *destData);
private:
// distpatch helper for vtk data type enum
template<typename SOURCE_TYPE>
static
int Blit(
const vtkPixelExtent &srcWhole,
const vtkPixelExtent &srcSubset,
const vtkPixelExtent &destWhole,
const vtkPixelExtent &destSubset,
int nSrcComps,
SOURCE_TYPE *srcData,
int nDestComps,
int destType,
void *destData);
};
//-----------------------------------------------------------------------------
inline
int vtkPixelTransfer::Blit(
const vtkPixelExtent &ext,
int nComps,
int srcType,
void *srcData,
int destType,
void *destData)
{
return vtkPixelTransfer::Blit(
ext,
ext,
ext,
ext,
nComps,
srcType,
srcData,
nComps,
destType,
destData);
}
//-----------------------------------------------------------------------------
template<typename SOURCE_TYPE>
int vtkPixelTransfer::Blit(
const vtkPixelExtent &srcWholeExt,
const vtkPixelExtent &srcExt,
const vtkPixelExtent &destWholeExt,
const vtkPixelExtent &destExt,
int nSrcComps,
SOURCE_TYPE *srcData,
int nDestComps,
int destType,
void *destData)
{
// second layer of dispatch
switch(destType)
{
vtkTemplateMacro(
return vtkPixelTransfer::Blit(
srcWholeExt,
srcExt,
destWholeExt,
destExt,
nSrcComps,
srcData,
nDestComps,
(VTK_TT*)destData););
}
return 0;
}
//-----------------------------------------------------------------------------
template<typename SOURCE_TYPE, typename DEST_TYPE>
int vtkPixelTransfer::Blit(
const vtkPixelExtent &srcWholeExt,
const vtkPixelExtent &srcSubset,
const vtkPixelExtent &destWholeExt,
const vtkPixelExtent &destSubset,
int nSrcComps,
SOURCE_TYPE *srcData,
int nDestComps,
DEST_TYPE *destData)
{
if ( (srcData == NULL) || (destData == NULL) )
{
return -1;
}
if ( (srcWholeExt == srcSubset)
&& (destWholeExt == destSubset)
&& (nSrcComps == nDestComps) )
{
// buffers are contiguous
size_t n = srcWholeExt.Size()*nSrcComps;
for (size_t i=0; i<n; ++i)
{
destData[i] = static_cast<DEST_TYPE>(srcData[i]);
}
}
else
{
// buffers are not contiguous
int tmp[2];
// get the dimensions of the arrays
srcWholeExt.Size(tmp);
int swnx = tmp[0];
destWholeExt.Size(tmp);
int dwnx = tmp[0];
// move from logical extent to memory extent
vtkPixelExtent srcExt(srcSubset);
srcExt.Shift(srcWholeExt);
vtkPixelExtent destExt(destSubset);
destExt.Shift(destWholeExt);
// get size of sub-set to copy (it's the same in src and dest)
int nxny[2];
srcExt.Size(nxny);
// use smaller ncomps for loop index to avoid reading/writing
// invalid mem
int nCopyComps = nSrcComps < nDestComps ? nSrcComps : nDestComps;
for (int j=0; j<nxny[1]; ++j)
{
int sjj = swnx*(srcExt[2]+j)+srcExt[0];
int djj = dwnx*(destExt[2]+j)+destExt[0];
for (int i=0; i<nxny[0]; ++i)
{
int sidx = nSrcComps*(sjj+i);
int didx = nDestComps*(djj+i);
// copy values from source
for (int p=0; p<nCopyComps; ++p)
{
destData[didx+p] = static_cast<DEST_TYPE>(srcData[sidx+p]);
}
// ensure all dest comps are initialized
for (int p=nCopyComps; p<nDestComps; ++p)
{
destData[didx+p] = static_cast<DEST_TYPE>(0);
}
}
}
}
return 0;
}
ostream &operator<<(ostream &os, const vtkPixelTransfer >);
#endif
// VTK-HeaderTest-Exclude: vtkPixelTransfer.h
|