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

Search the Forums
See All Topics
Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Advantages
FAQ
Screenshots
Shape factory
Shape gallery
Demonstrations
What's new
System requirements
Download Center
Public license
Documentation
Getting started
Forums
Open Source community
Training and e-learning
A-la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
News
Home / Developer Corner / Forums / Usage issues / Is it Possible to read 75MB Stl file through opencascade...

Is it Possible to read 75MB Stl file through opencascade...

Is it Possible to read 75MB Stl file through opencascade...
suman 2008/12/19 07:59
Hi...

I am able to read 2.7MB STL file by using my application which is using opencascade API.But I need to read 75MB Stl file..Is it possible?

If I'm trying to read through Read() method in StlAPI_Reader,I,m getting a cascade error while reading..How can I come out of that error...

I am in a hurry..If you know the solution,Can you please respond me immediately....

Thanks in Advance
Suman


Mikael Aronsson 2008/12/19 08:25
What kind of error do you get ?
suman 2008/12/19 08:41
Hello Mikael..
I am getting an empty Message box with a title "Cascade Error" while reading an STL file..

When I'm debugging,I have traced out the error where it's encountered...

The error is coming when the Read() function of StlAPI_Reader()...

Please help me out to solve this error...

Thanks in Advance
suman
ANANTH 2008/12/19 08:43
Error may be from

Read(TopoDS_Shape& aShape,const Standard_CString aFile);
in the StlAPI_Reader class.
while you are trying to read the data from "aFile" and getting out the result in to TopoDS_Shape object.
Have you checked the instance of TopoDS_Shape object....!

Roman Lygin 2008/12/19 08:50
You likely run out of memory, don't you ? On my laptop reading a 100Mb binary STL file (meaning that ascii would be even bigger) with 2Gb RAM took 1.5Gb and put the entire OS into swapping and I had to stop it without waiting. So converting that size of files into shapes (TopoDS_Shape) is useless, it creates about dozens of thousands faces which cannot be usable.
Reading into MeshVS structure finished in a few dozen seconds with Standard_OutOfMemory exception.
So, try to read into some compact data structure first. Did you try StlMesh_Mesh and use RWStl::ReadFile()?

Roman

P.S. Why are still in a hurry after a few days ;-) ? If you have to deal with new software in your project, you rather have to plan more buffers into your project schedule ;-)

---
opencascade.blogspot.com - blog on Open CASCADE
suman 2008/12/19 09:02
Hello Roman...
Thanks for your sharp reply.

Now I will try it and bring to your notice..

And finally regarding my hurry,I'm new to this openCascade..So I was keep on searching for conversion..Recently I've joined forum...

Now I'm getting answers very fast from experts like you....

Thanks
suman
suman 2008/12/20 08:49
Hello Roman

As you said,I have used RWStl::ReadFile()function and StlMesh_Mesh to read an Stl File.

With that code, I'm able to read file which is of 2.7MB size within 9 sec,where as previously it has taken 48sec...

But for converting into IGES,Previously it was taking 8sec,where as in this case it's taking 2 min...

And If I'm reading STL file of size 73.2MB,I am getting a Cascade Error with out any text on error window...

Please give me any suggestions to overcome this issue.....

The code which I have used is....


Handle(TopTools_HSequenceOfShape) aSequence = new TopTools_HSequenceOfShape();
     if (dlg.DoModal() == IDOK)
     {
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
CString C = dlg.GetPathName();
Standard_CString aFileName = (Standard_CString)(LPCTSTR)C;

     
     OSD_Path aFile(aFileName);
Standard_Boolean ReturnValue = Standard_True;

Handle(StlMesh_Mesh) aSTLMesh = RWStl::ReadFile(aFile);

TopoDS_Compound ResultShape;
BRep_Builder CompoundBuilder;
CompoundBuilder.MakeCompound(ResultShape);


Standard_Integer NumberDomains = aSTLMesh->NbDomains();
Standard_Integer iND;
gp_XYZ p1, p2, p3;
TopoDS_Vertex Vertex1, Vertex2, Vertex3;
TopoDS_Face AktFace;
TopoDS_Wire AktWire;
BRep_Builder B;
Standard_Real x1, y1, z1;
Standard_Real x2, y2, z2;
Standard_Real x3, y3, z3;

StlMesh_MeshExplorer aMExp (aSTLMesh);

// BRepBuilderAPI_MakeWire WireCollector;
for (iND=1;iND<=NumberDomains;iND++)
{
for (aMExp.InitTriangle (iND); aMExp.MoreTriangle (); aMExp.NextTriangle ())
{
aMExp.TriangleVertices (x1,y1,z1,x2,y2,z2,x3,y3,z3);
p1.SetCoord(x1,y1,z1);
p2.SetCoord(x2,y2,z2);
p3.SetCoord(x3,y3,z3);

if ((!(p1.IsEqual(p2,0.0))) && (!(p1.IsEqual(p3,0.0))))
{
Vertex1 = BRepBuilderAPI_MakeVertex(p1);
Vertex2 = BRepBuilderAPI_MakeVertex(p2);
Vertex3 = BRepBuilderAPI_MakeVertex(p3);

AktWire = BRepBuilderAPI_MakePolygon( Vertex1, Vertex2, Vertex3, Standard_True);

if( !AktWire.IsNull())
{
AktFace = BRepBuilderAPI_MakeFace( AktWire);
if(!AktFace.IsNull())
CompoundBuilder.Add(ResultShape,AktFace);
}
}
}
}
TopoDS_Shape aShape = ResultShape;
aSequence->Clear();
     
      aSequence->Append(aShape);


Thanks in Advance
Suman
Roman Lygin 2008/12/20 11:33
Suman,

The key problem, in my opinion, is in your concept of translating STL to IGES. Are you familiar with these formats ? STL is a set of plain triangles while IGES is aimed at containing precise geometry (NURBS, cylinders, etc). STL is used to dump a result of tessellation (triangulation) of the 3D model (that could originally come from IGES or other similar CAD format). Storing thousands/dozens of thousands of triangles in IGES (e.g. as Trimmed Surfaces, IGES type 144) has no sense. What will the receiving application do with it ? An IGES file itself would be of hundreds of megabytes and would be unreadable by most software, not saying a word about usability of the model in it.

So you better work on your concept than trying to fight a wrong target.

Roman

---
opencascade.blogspot.com - blog on Open CASCADE
suman 2008/12/22 06:55
Hi Roman...
I have studied about both the files...

But my customer needs IGES file to do reverse engineering...

If you provide your personal mail ID,I will send you both the STL and IGES files (Conversion has been done through opencascade for file less than 3MB)to your mail...Such that you will get clear picture.....

Thanks for our support....

Suman

suman 2008/12/22 06:55
Hi Roman...
I have studied about both the files...

But my customer needs IGES file to do reverse engineering...

If you provide your personal mail ID,I will send you both the STL and IGES files (Conversion has been done through opencascade for file less than 3MB)to your mail...Such that you will get clear picture.....

Thanks for our support....

Suman

Roman Lygin 2008/12/22 07:19
Suman,

My email is roman dot lygin at gmail dot com (now also visible on my blog). But let's stay on this thread meanwhile, so that others can read.

If it's critical for your customer to use IGES for reverse engineering, you might agree to transfer only a point set, so that every triple corresponds to an STL triangle. This will reduce your file size.

Roman

opencascade.blogspot.com - blog on Open CASCADE
suman 2008/12/22 08:39
Hi Roman....
Please heck out mail once....

Thanks
suman
suman 2008/12/24 04:48
Hello....
Thanks for your prompt replies....

I am able to render my STL file very fast...
Once again Thanks for extreme support....

Thanks
suman
Yogesh Dhakad 2008/12/24 18:36
Hi Suman,

If Roman has kindly solved your problem - why not share it with others on the forum here.

We all have always been grateful to Roman in the past and would be great to have this solution published as well. Thanks.
suman 2008/12/25 04:55
Hello Yogesh...
I am able to read STL file very fast.But to convert it int IGES again it's taking very long time...

I have written the following code to display STL file in the viewer...Which is already there in archives...I have moodified one or two lines....

aSTLMesh = RWStl::ReadFile(aFile);
Handle( MeshVS_Mesh ) aMesh = new MeshVS_Mesh();
Handle( XSDRAWSTLVRML_DataSource ) aDS = new XSDRAWSTLVRML_DataSource(aSTLMesh);

aMesh->SetDataSource(aDS);
aMesh->AddBuilder( new MeshVS_MeshPrsBuilder( aMesh),Standard_True);
      //False -> No selection
Handle_MeshVS_Drawer draw1 = aMesh->GetDrawer();
draw1->SetBoolean(MeshVS_DA_DisplayNodes,Standard_False);
      //MeshVS_DrawerAttribute
draw1->SetBoolean(MeshVS_DA_ShowEdges,Standard_False);
      aMesh->SetMeshSelMethod(MeshVS_MSM_BOX);
anInteractiveContext->Display(aMesh);


Thanks
Suman
 
 
Latest news
  • Open CASCADE Technology 6.7.0 is available for download!
  • Open CASCADE Technology 6.6.0 is available for download!
  • Open CASCADE Technology 6.5.5 is available for download!

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