Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics
 

Stl Import

Stl Import
Teguetio 2006/04/12 22:02
Hey!!
i'm currently working with .stl Format and i would be very thankful if anyone helps with tips about importing a STL file in Opencascade as fast as possible. i've used the STLReader from the OCC library,but it seems very slow and use a lot of memory.
Thanks for any advice.
Thomas 2006/04/13 02:09
1) The STL file format is *VERY* simple, you should be able to read it by yourself.
2) Put the data you read into a Poly_Triangulation structure (easy to manage) and use as you want!

:) Bye
Teguetio 2006/04/13 07:22
Hallo Thomas..
Thanks for your advices.please could u give me more infos about it?i have never worked with the Poly_Triangulation structure you've talked about.
Thanks and best regards.
Thomas 2006/04/13 08:56
The poly_triangulation stores 2 informations: the vertexs of the triangles (Nodes array) and the triangles. Each triangle contains three indexs, one per vertex, that refer to the vertexs array.
You need to create a [Handle]Poly_Triangulation passing the number of the triangles and vertexs (triangles *3). Then you just load the vertexs and then the triangles with the right values.
A simple-unoptimized way if you don't need poly_connect:
Handle(Poly_Triangulation) T = new Poly_Triangulation(Tri_Num, TriNum*3); (or inverted)
for (i = 1; i < ... ){ // Remember 1-Based
T->Nodes(i*3)->SetValue(STLTriangle[i]) [i-1 if it is 0 based]
T->Nodes(i*3+1)->SetValue(STLTriangle[i])
T->Nodes(i*3+2)->SetValue(STLTriangle[i])
T->Triangles(i)->Set(i*3,i*3+1,i*3+2)
}

It's the same old Vertexs-Indexs structure :O)
If you have time, do it in the right way : instead of adding each vertex, try to avoid to insert it if it is duplicate.Doing so allow you to use Poly_Connect that gives some usefoul informations (like the triangles belonging to a vertex).

Creating a TOPODS_Shell or Compound using the facets it's possible (and easier to display), but ... why ? :)

Sorry for my english, I hope you understand this !
Teguetio 2006/04/13 15:12
hi Thomas..

Thanks....I'll try!!don't worry about your english.I'm also not that good..:-)
Patrik Müller 2006/04/13 22:00
Hi Thomas,

you could also just use Handle(StlMesh_Mesh) and RWStl to read STL files. After that you can get the triangles with an StlMesh_MeshExplorer. So there is no need to use a Poly_Triangulation structure!

Greets,

Patrik
Teguetio 2006/04/14 01:10
Hi Patrick...

Some codes would be welcome.:-)

Thanks!
Patrik Müller 2006/04/14 02:43
No problem - just look here:

http://www.opencascade.org/org/forum/thread_3145/

there should be enough infos how to use it ;-)

Greets,

Patrik
Teguetio 2006/04/14 08:49
Hey Patrick....

Thanks a lot..that's what i initially used. I'm trying now to improved it by using the Poly_Triangulation.Some argue it could be faster!

best regards.
Patrik Müller 2006/04/14 14:47
Hi,

if you just need it for visualization I would recommend other ways:
1) use a MeshVS structure (I haven't used it - but you find a good example in the "ros\src\XSDRAWSTLVRML" folder
2) derive a class from AIS_InteractiveObject for meshes - thats the way I've done it

Greets,

Patrik
Thomas 2006/04/15 12:44
MeshVS works really great on 6.1 , and deriving the MeshVS_DataSource is simplier than it appears on the example :) you need just 20 lines of code! (in 5.2.0 didn't worked very well!)

A standard implementation (based on Poly_Triangulation) would be usefoul since that format is the result of the Mesh function !
It seems that MeshVS is much more advanced , but the lack of detailed documentation makes it impossible to use :(
Yogesh Dhakad 2006/07/04 13:13
Hi Patrik,

My app needs to just visualize the STL file read in. I compared the timings and the method you suggested (RWStl::ReadFile) refer forum http://www.opencascade.org/org/forum/thread_3145/ works just fine and is much faster that than StlAPI::Read(). I also checked the timings with OMF (OpenCascade Mesh Framework) and it was significantly low. Here are my readings.
For a STL file of size 20MB;
StlAPI::Read() is just hopeless and does not come out for 10+ mins.
RWStl::ReadFile() does the job in @2 mins
OMF does the same job in 16 secs.

If you don't mind, could you share the code / implementation ideas on #2 mentioned (derive a class from AIS_InteractiveObject). What is the gain in the speed of opening the STL file?

Thanks in Advance,
Yogesh
Patrik Müller 2006/07/04 13:47
Hi Yogesh,

as I wrote my kind of "AIS_Mesh" there was no OMF and no MeshVS - so its old code. I use it also for displaying other formats like 3DS.
It wasn't only the displaying speed - my main interest was reducing memory size.
I'm not sure about sharing code - what exactly are oyu interested in?

Greets,

Patrik
 
 
Latest news
  • Open CASCADE Technology 6.8.0 is available for download!
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!

  • © OPEN CASCADE 2000 - 2014  |  Search  |  Contacts   |  Site map