Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7530101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:49:09+00:00 2026-05-30T04:49:09+00:00

As in my previous question , I’m working loading a 1D array with volumetric

  • 0

As in my previous question, I’m working loading a 1D array with volumetric data of a .raw file. The answer by Jonathan Leffler proved helpful, but now I’m working with a volume dataset of different dimensions (X,Y,Z aren’t the same). How would the formula be generalized?

pVolume[((x * 256) + y) * 256 + z] // works when all dims are 256


int XDIM=256, YDIM=256, ZDIM=256; // I want this sizes to be arbitrary
const int size = XDIM*YDIM*ZDIM;
bool LoadVolumeFromFile(const char* fileName) {

    FILE *pFile = fopen(fileName,"rb");
   if(NULL == pFile) {
    return false;
   }

   GLubyte* pVolume=new GLubyte[size]; //<- here pVolume is a 1D byte array 
   fread(pVolume,sizeof(GLubyte),size,pFile);
   fclose(pFile);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:49:10+00:00Added an answer on May 30, 2026 at 4:49 am

    Access in strides follows a simple principle:

    A[i][j][k] = B[k + j * Dim3 + i * Dim3 * Dim2];
    
    // k = 1..Dim3,  (or 0 <= k < Dim3, as one does in C)
    // j = 1..Dim2,
    // i = 1..Dim1.
    

    Here B is a 1D array of size Dim1 * Dim2 * Dim3. The formula obviously generalizes to arbitrarily many dimensions. If you want a mnemonic, start the sum with the fasted index, and in each summand you multiply further by the extent of the previous dimension.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(This question is related to my previous question , or rather to my answer
Previous question linky: MySQL Left Joins Very kindly we got the following code working:
My previous question about this subject was answered and I got some tests working
In relation to this previous question I am trying to create a batch file
A previous question showed a nice way of printing to a string. The answer
In a previous question about overriding Time.now , I was working toward a solution
my question is related to my previous question ( How to display data from
This question relates to my previous question which asks about loading a page into
Previous question: (Thank you Tonny Madsen to answer me) Add keyevent to switch ViewPart
In previous question of mine, someone had meantioned that using Semaphores were expensive in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.