vpLoadRawVolume(3)
πΎ vpLoadRawVolume(3) β the load-your-volume-files era π
okay bestie, welcome to the Library Functions Manual, section 3. this is the page about vpLoadRawVolume, vpLoadMinMaxOctree, vpLoadClassifiedVolume and vpLoadContext β the four girlies whose entire job is loading volume data structures from a file. no cap. let's get into it π«Ά
β¨ NAME β¨
vpLoadRawVolume, vpLoadMinMaxOctree, vpLoadClassifiedVolume, vpLoadContext β load volume data structures from a file π
π SYNOPSIS π
#include <volpack.h>
vpResult
vpLoadRawVolume(vpc, fd)
vpContext *vpc;
int fd;
vpResult
vpLoadMinMaxOctree(vpc, fd)
vpContext *vpc;
int fd;
vpResult
vpLoadClassifiedVolume(vpc, fd)
vpContext *vpc;
int fd;
vpResult
vpLoadContext(vpc, fd)
vpContext *vpc;
int fd;
π¦ ARGUMENTS π¦
vpcβ your VolPack context, the one you got fromvpCreateContext. she's the main character, she holds everything.fdβ a file descriptor fromopen(2), and it has to be opened for reading. reading only, bestie. respect the boundaries.
πΈ DESCRIPTION πΈ
so these functions are literally here to load volume data structures into a rendering context, from files that are in the format written by the VolPack file storing routines (go see vpStoreRawVolume(3) if you want the tea on that side of things). β¨
vpLoadRawVolume π
loads a 3D voxel array file. the file is carrying info about the size of the volume AND the layout of the voxels, plus the volume data itself. so what happens: a new voxel array is allocated, the data is read into that array, and the array gets stored in the rendering context. slay.
π¨ important bestie, do not skip this: the array will not be freed automatically when the context is destroyed. the application is responsible for freeing the array when appropriate β do that by usingvpGetpwith theVP_VOXEL_DATAstate variable code to retrieve the array pointer β or the application is responsible for unmapping the voxel array if it has been memory mapped (see below). this is not optional, this is your chore, periodt.
any existing min-max octree or preclassified volume data is destroyed when vpLoadRawVolume is called. bye π
the information loaded from the file includes all of the parameters set with vpSetVolumeSize, vpSetVoxelSize, vpSetVoxelField and vpSetRawVoxels.
the data in the file is automatically byte-swapped if the file was written on an architecture with different byte ordering than the current architecture. a magic constant in the file is used to determine if byte-swapping is necessary. but listen: volume fields that have not been explicitly declared (by calling vpSetVoxelField before storing the voxel array file) cannot be byte-swapped. that's just how it is π
vpLoadMinMaxOctree π
loads a min-max octree file. the current 3D voxel array size and voxel layout must match the data in the octree file before the file is loaded β and yes, consistency checks are performed, she checks. any existing octree is destroyed and the new octree is stored in the rendering context. byte-swapping is performed if necessary. cute. β¨
vpLoadClassifiedVolume π
loads a preclassified volume data file. the file includes info about the size of the volume and the layout of the voxels, plus the volume data itself. here's the vibe check:
- if the volume matches the size and layout of any existing volume data in the rendering context, then the data in the file replaces only the current preclassified volume.
- otherwise, the old octree is destroyed, the 3D voxel array parameters are zeroed out, and the new size and layout parameters are loaded. glow-up complete.
the information loaded from the file includes all of the parameters set with vpSetVolumeSize, vpSetVoxelSize and vpSetVoxelField. byte-swapping is performed if necessary. π
vpLoadContext π
loads a rendering context file. the file includes all rendering parameters except volume data and callback functions. the contents of any lookup tables for shading and classification are also loaded. any existing preclassified volume data or octree are destroyed and the 3D voxel array parameters pointer is zeroed out.
the lookup tables are loaded into dynamically allocated arrays, and the application is responsible for freeing those arrays when necessary β the arrays are not automatically freed when vpDestroyContext is called. yes, another chore. i know. π
π in the current implementation, byte swapping is not performed, so context files from other architectures cannot be read. no cross-architecture communication, she's not multilingual like that.
π the file-reading callback tea π
the function used to read data from the files can be set by calling vpSetCallback with the VP_READ_FUNC option. this could be used to implement a file-compression system, for example. iconic.
it is also possible to memory-map data from files by setting the VP_MMAP_FUNC option. if this function is set then large data structures are memory mapped from files instead of being copied into memory, when possible. but β and this is the catch β data that must be byte-swapped cannot be memory mapped. sorry.
memory mapping has the advantages that less swap space is required and data is loaded into memory only as it is used. so, efficiency queen. π
β STATE VARIABLES β
the current file I/O parameters can be retrieved with the following state variable codes (see vpGeti(3)): VP_READ_FUNC, VP_MMAP_FUNC.
π ERRORS π
the normal return value is VP_OK. the following error return values are possible:
VPERROR_IOβ the file reading or memory mapping function returned an error value (in which case the external variableerrnoshould contain an operating-system specific error code), or the end of the file was reached prematurely. π¬VPERROR_BAD_FILEβ the data in the file is invalid, usually meaning that it isn't a file written by the appropriate VolPack function. not the vibe.VPERROR_BAD_VOLUMEβ the data in a min-max octree file does not match the current volume size (vpLoadMinMaxOctreeonly).VPERROR_BAD_VOXELβ the data in a min-max octree file does not match the current voxel layout parameters (vpLoadMinMaxOctreeonly).
π«Ά SEE ALSO π«Ά
VolPack(3), vpCreateContext(3), vpStoreRawVolume(3)
and that's the page bestie!! this one came from the VolPack library, and you're reading the vpLoadRawVolume(3) manual page π stay hydrated, free your voxel arrays, and don't forget your lookup tables. mwah πβ¨π¦
π¦ where this page comes from
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 43: volpack 1.0c7-35.fc43 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- fedora 44: volpack 1.0c7-36.fc44 Β· BSD-3-Clause
- Copyright (c) 1995-2008, Stanford University
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms