473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

loading and saving large binary .stl (stereolithography) files

hi @all. i have written a c++ program for visualization of .stl files using opengl. for small files the loading time is no problem, but if the files get larger (a couple of mb which means a few hundred thousand triangles) the loading time gets minutes. for the read in process i use both ifstream and fopen. there is nearly no difference in time. i think the problem is the way i save the data in memory. i use a single linked list consisting of pointers to a class for each triangle. now i am thinking of using float** matrizes and initializing them with the values read in using malloc(). but i don't know if this will increase performance. i will try. does anyone have any other ideas to solve my loading problem?
thanks in advance, andrew
May 11 '10 #1
5 4346
Banfa
9,065 Expert Mod 8TB
If you are using C++ they you should be using a std::list

It is unlikely that you will be able to write anything that goes significantly faster than this.

Using a float** instead of your classes is also unlikely to make a difference.

How many of these triangle classes do you end up with? What is the memory size of each class? How much physical memory is in your machine?

I guess the problem may be doing lots of little memory allocations. You could try doing your memory allocation using a std::vector, as soon as you know how many triangles there are going to be reserve that much space in your std::vector so that the memory is allocated in 1 operation.

You may still want to use a std::list, particularly if you are going to be sorting or re-arranging the order of the triangles then sorting a std::list of pointers into a std::vector of objects will be much faster than sorting the std::vector directly.
May 11 '10 #2
thank you for your quick answer!
i am using the std::list to extract points and visualize as a point cloud - because the unique() function is very useful to delete repeated points. the performance of std::list is ok, but not for visualization. moving the 3d-object visualized as a point cloud using list performs relatively slow. but that doesn't matter.

i used a float** matrix now and the performance is much better now. the loading time of a 8mb .stl file (>200000 triangles) is 4 seconds now - and this is ok. and moving the object on the opengl screen works much better than it does with the point cloud using std::list.

you see, i end up with 10 000 to 500 000 triangles and for now i am happy with the loading time.

the memory size of one class (triangle) is 52 bytes.
my machine has 2gb ram and xp prof. sp3 but the program will run on a quad core ~3GHz, ~4GB RAM, win7 prof. in future.
May 11 '10 #3
donbock
2,426 Expert 2GB
Use a stopwatch to time how long it takes to make a copy of your triangle file (using operating system commands, no C++ program). This establishes the time it takes to read in, and write out, the triangle file. You can't go any faster than this without making the file smaller. If your program is taking substantially longer than this then you know the problem is something other than mere file I/O.
May 11 '10 #4
weaknessforcats
9,208 Expert Mod 8TB
Do you have to use floating point? That is incredibly slow.

I recommend using integers only unless there is a technical reason you can write down on paper that requires you use it.

If you do have to use it, then use double. C++ promotes float to double, does the calulation, and them demotes double back to float.

All major finance systems use intgers.
May 11 '10 #5
yes, the data i get is in floating point 4 bytes. for the moment there are no calculations, just visualization using GLfloat and opengl. and for now i am working on a 32bit system - so i think using float is the better choice.
does c++ really convert a float to double and back for calculations? that's new for me. as i said, i am working on a 32bit system.
a conversion to int isn't possible because the values will get changed in future and have to be saved as float again.
May 12 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Paul L | last post by:
Hi, what's the correct way to redirect to a large binary file? I have a simple database that holds a list of names and URLs. The URLs are of large mp3s (around 80-100mb). I take the name as a...
5
by: kids_pro | last post by:
Hi, How does File.Move implmented? I am like to use it a lot but when I come a cross a large file >500 MB my UI is freezed. I think about implement my own fileMove function but I am not sure...
1
by: M Keeton | last post by:
I currently have a picture which is stored in a "System.Drawing.Image" variable and I want to save it as a bitmap file. I have tried 2 different approaches and both give me the following error: ...
2
by: Sean Feldman | last post by:
Hi, I'm trying to upload a large binary object from Desktop c# application as an attachement (DIME) to web service, but fail with HTTP error 400 (invalid request or something) just before sending...
2
by: gauravkhanna | last post by:
Hi All I need some help for the below problem: Scenario We need to send large binary files (audio file of about 10 MB or so) from the client machine (.Net Windows based application, located...
1
by: pedagani | last post by:
Dear comp.lang.c++, I'm interested in knowing the general techniques used to handle large binary files (>10GB) efficiently such as tweaking with filebuf , etc. Reading chunk by chunk seems to be...
1
by: Peter Morris [Droopy eyes software] | last post by:
Hi all I'm writing a compact framework app. This app needs to receive a large binary (zip file) from a webservice. The problem is that the byte will be retrieved into RAM before I can save it...
3
by: sebastian.harko | last post by:
Helllo, What's the general accepted strategy for dealing with very large binary files in C# ? I have to do a program that reads some "multi frame bitmap " files which can reach up to one...
1
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
Using .NET 2.0 is it more efficient to copy files to a single folder versus spreading them across multiple folders. For instance if we have 100,000 files to be copied, Do we copy all of them to...
4
by: andrew78 | last post by:
hi @all. i am new to this forum and i'm searching for an answer regarding .stl (stereolithography) files and the use of them in c++. i use a binary version of the same file i have in ascii format to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.