vpExtract(3)
π vpExtract β bestie, let's pull one lil field out of a 3D volume β¨
okay so. this is the vpExtract(3) page from the VolPack library, and no cap, it's genuinely useful β it yanks one field out of a rectangular region of a volume and hands it to you in your own array. let's get into it π«Ά
πΈ SYNOPSIS πΈ
#include <volpack.h>
vpResult
vpExtract(vpc, volume_type, x0, y0, z0, x1, y1, z1, field, dst,
dst_size, dst_xstride, dst_ystride, dst_zstride)
vpContext *vpc;
int volume_type;
int x0, y0, z0;
int x1, y1, z1;
int field;
void *dst;
int dst_size;
int dst_xstride, dst_ystride, dst_zstride;
she's got a LOT of arguments. i know. breathe. we'll go one by one π
π ARGUMENTS π
vpcβ your VolPack context, the one you got fromvpCreateContext. your main character struct πvolume_typeβ a code telling her which volume data structure to extract the region from. your options areVP_RAW_VOLUME,VP_CLASSIFIED_VOLUME,VP_CLX_VOLUME,VP_CLY_VOLUMEorVP_CLZ_VOLUME.x0,y0,z0β the origin of the extracted region, in the voxel array. where we start, bestie πx1,y1,z1β the opposite corner of the extracted region, also in the voxel array. where we stop βfieldβ a voxel field number identifying which field to extract, OR one of these special codes:VP_OPACITY_FIELD,VP_CORRECTED_OPAC_FIELD,VP_COLOR_FIELD. choose your fighter βdstβ the destination array. where the goodies land πdst_sizeβ size of the destination array, in bytes. yes it's checking, and honestly? she should be.dst_xstride,dst_ystride,dst_zstrideβ strides (in bytes) for the X, Y and Z dimensions of the destination array. literally the walk-pattern through your array π
β¨ DESCRIPTION β¨
vpExtract is used to extract one field from a rectangular region of the 3D voxel array or the preclassified volume, and store the result in a separate array. it is also possible to retrieve computed voxel opacities or colors. it's giving "surgical little grabby hands" π₯
the volume_type argument is used to choose which data structure the region should be extracted from. the choices are:
VP_RAW_VOLUMEβ extract from the 3D voxel array (seevpSetRawVoxels(3)).VP_CLASSIFIED_VOLUMEβ extract from the preclassified volume (seevpClassifyVolume(3)). there are three copies of the voxel data in the preclassified volume, one for each principal viewing axis. the copy which will result in the fastest access (best memory stride) is selected. she picks the fastest one for you, because she's an icon like that πVP_CLX_VOLUMEβ extract from the preclassified volume used for X-axis viewing.VP_CLY_VOLUMEβ extract from the preclassified volume used for Y-axis viewing.VP_CLZ_VOLUMEβ extract from the preclassified volume used for Z-axis viewing.
the last three choices for the volume_type argument are usually used only for debugging. so like, niche. iykyk π
the next six arguments give the coordinates of the corners of the extracted region in the volume. the coordinates are indexes into the array. no floaty nonsense, indexes, periodt.
the field argument is used to select which voxel field to extract. any of the voxel field numbers previously specified with vpVoxelField may be specified. the output array must be sized appropriately for the dimensions of the region and the size of the extracted field. the following special constants may also be used instead of a voxel field number:
VP_OPACITY_FIELDβ return voxel opacities for voxels in the indicated region. if the 3D voxel array is selected, then the opacities are computed on-the-fly using the current opacity transfer function. the minimum opacity threshold is ignored. if the preclassified volume is selected, then the precomputed opacities are extracted. opacities below the minimum opacity threshold at the time the volume was classified are set to 0. the output array should have typeunsigned char, and the opacities are stored as number between 0 (transparent) and 255 (opaque). crystal clear, both ends of the scale π«§VP_CORRECTED_OPAC_FIELDβ this option is the same as theVP_OPACITY_FIELDoption, except that voxel opacities are corrected for the current view transformation. the opacity transfer function is assumed to produce the opacity of a voxel viewed perpendicular to one face of the volume with no scale factor. if the voxel has been scaled or rotated with respect to the viewer, then the apparent opacity must be corrected. it's the same vibe, just angle-aware πVP_COLOR_FIELDβ return voxel colors for voxels in the indicated region. the colors are computed on-the-fly using the current shading, lighting and material parameters. the output array should have typeunsigned char, and each color channel is stored as number between 0 (off) and 255 (full intensity). the number of color channels per pixels is determined by the current shading parameters. (not currently supported for preclassified volumes.) π¨ heads up on that last bit β no preclassified volumes here, bestie.
the remaining arguments specify the output array, its size (for error checking), and the stride for each dimension (to allow padding the end of scanlines or storing the result in a higher-dimension array). very "we prepared for every layout" of her π
π ERRORS π
the normal return value is VP_OK. the following error return values are possible:
VPERROR_BAD_VALUEβ the volume coordinates are out of bounds or invalid (x0 > x1, etc.), or the field number is invalid.VPERROR_BAD_SIZEβ the destination array size is incorrect.VPERROR_BAD_VOLUMEβ the volume data does not exist.VPERROR_BAD_OPTIONβ thevolume_typeargument is invalid.VPERROR_BAD_VOLUMEβ the volume size or data is missing or invalid. (yes,VPERROR_BAD_VOLUMEshows up twice in the original list. not me editing the lore. she's listed twice, we list her twice π)VPERROR_BAD_VOXELβ the voxel fields are incorrectly defined.VPERROR_BAD_CLASSIFIERβ the opacity transfer function is incorrectly specified.VPERROR_BAD_SHADERβ the shading parameters have been incorrectly specified.VPERROR_SINGULARβ one or more of the view transformation matrices is singular. math said no π
π¦ SEE ALSO π¦
VolPack(3), vpCreateContext(3)
okay that's the whole page bestie, go extract something gorgeous πβ¨
and for the record: this is vpExtract(3) from the VolPack library functions manual, VolPack version, dated alongside the rest of the VolPack set. that's the footer energy, folded into a little sign-off instead of a boring line at the bottom. mwah ππ
π¦ where this page comes from
- debian bookworm: libvolpack1-dev 1.0b3-9 Β· BSD-3-Clause
- debian trixie: libvolpack1-dev 1.0b3-10 Β· BSD-3-Clause
- ubuntu jammy: libvolpack1-dev 1.0b3-9 Β· BSD-3-Clause
- ubuntu noble: libvolpack1-dev 1.0b3-9.1 Β· BSD-3-Clause
- ubuntu questing: libvolpack1-dev 1.0b3-11
- ubuntu resolute: libvolpack1-dev 1.0b3-11build1 Β· BSD-3-Clause
- ubuntu stonking: libvolpack1-dev 1.0b3-11build1 Β· BSD-3-Clause
- Copyright (c) 1994 The Board of Trustees of The Leland Stanford
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms