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

  • Home
  • SEARCH
  • 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 1113587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:52:52+00:00 2026-05-17T02:52:52+00:00

I have a file format (.STL, stereo lithography, the structure is standard and can

  • 0

I have a file format (.STL, stereo lithography, the structure is standard and can not be changed. Not to be confused with standard template library) that uses a 50 byte data structure. Reading from the HD directly leads to wrong data being read as 50 bytes is not a multiple of 4.

Out of the entire 50 byte structure, I only need 36 of those bytes. The method I am using right now to extract the data is to manually offset the read position of the file to the point where the next set of data begins, read off the 36 bytes into a temporary variable and then dump the data in the temporary variable into it’s proper position on the array.

Here’s the code chunk:

threePoints* output = new threePoints [numTriangles]; // create an array to hold the entire file
threePoints* temp = new threePoints [1]; // temp variable to pull data out of each "cell"

// extract each triangle individualy
for (int i = 0; i < numTriangles; i++)
{
    stlFile.seekg (96 + i * 50, ios::beg);  //read vertex data and put them into tempoary array
                                            // offset = 80 header + 4 #triangles + 12 normal vector
    stlFile.read(reinterpret_cast<char*>(temp), (36)); // read the next 36 data blocks into holder, 3 points * 3 axis * 4 bytes per float
    output[i] = temp[0]; // dump values in holder into proper array
}

This method works but is slow. How would I go about doing this to make it faster and more efficiently?

Edit: I know manually disabling the byte alignment would solve this problem but I need to use the resulting array intensively and iterate over it many times. I’ve been told that disabling byte alignment can result in performance issues, thus i avoided it.

  • 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-17T02:52:52+00:00Added an answer on May 17, 2026 at 2:52 am

    Instead of doing a bunch of small seeks & reads, allocate a large buffer (say, enough for 1000 structures) and read a bunch of records at once. (Then iterate through that buffer copying out the 36-byte chunks you need).

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

Sidebar

Related Questions

So for example: I have file.mp3, I know that my desired format can play
I have a file format I'm trying to write to using C#. The format
I have file with this specific format: 0 2 4 0 1 A 0
I have a file in the format, where each line has double numbers seperated
I have file Image_RGB565.raw which contains image buffer in RGB565 format. I want this
I have to work a lot with the flexible file format Yaml, i like
I have a large Regular Expression I use for parsing my own file format
I have an XML file. There is some blank line in the file. How
The title is pretty self explanatory. the following code...: URL imageUrl = new URL(url);
I am debugging stored procedures, and right now I am interested in what ran

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.