STL file import support

Can we read STL files by using OCC components. If so, What is the class used for this purpose?
Please, give me some links to do it.

Thanks in advance,
Paheerathan

Sharjith Naramparambath's picture

I remember I had found some code somewhere on this forum long ago. Please see if it works for you. Attaching the source file herewith.

Attachments: 
rathan0001's picture

Dear Sharjith Naramparambath,

Thanks for your reply, but I'm having some problems.It is returning an error called
'NbDomains' : is not a member of 'Handle_StlMesh_Mesh.

Why is that?

Please let me know, how to overcome this problem or a small sample application.

Thank you,

Best Regards,
Pahee

Sharjith Naramparambath's picture

Hi Pahee,

I used the code and albeit with minor changes could successfully load the StL file. Attaching the full code and a snapshot too :) Refer the Translate.cpp file in the Import/Export Samples. I have just modified one of the import functions (iges) to accommodate the StL code. Hope this helps.

Attachments: 
rathan0001's picture

Thanks Sharjith.

I have done it. The problem was with following line
Standard_Integer NumberDomains = aSTLMesh->NbDomains(); //There is no NbDomains in aSTLMesh
I removed it from my code, then it is working fine

By the way What do you think about the performance. I feel it is really slow. it takes around 2-3 minutes to load a 6 MB binary file. Is it a problem with OCC?

Thanks for your help and time.

Best Regards,
Pahee

Sharjith Naramparambath's picture

There is definitely a method NbDomains for StlMesh_Mesh, even the documentation mentions that. Which version of OCC are you using? You see the code I sent also has the method call that worked successfully at my end. Regarding performance, yes it is very slow especially for large files but I have no clue why it is so. I am interested to know if you have any findings at your end.

Regards,
Sharjith

rathan0001's picture

Hi Sharith,

Thanks

I'm working with open cascade 6.3. It is giving some errors for NbDomains, So I commented out that line and it is working fine.

I'm wondering what is the contribution of NbDomains in STL file loading.If you know, please let me know.

By the way I'm working with performance issues currently, especially level of details (LOD). Let you know, if I find anything

Thanks again,

Regards,
Pahee

niubiao's picture

hi,
I have the same question about how to import the format of STL.
Perhaps,you have resolved it,can you help me to do it?
If it is possible can you give me some code of sample in detail.
Thank you in advance!