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

Search the Forums
See All Topics
 

STL import

STL import
Freeman 2006/05/06 13:31
Hey...
could anybody help me???i have a Shape stored in a STL file and i would like to load it as fast as possible into a viewer.any idea?
pliz help.
Pawel 2006/05/08 19:44
Search the forum...

You could try this:
http://www.opencascade.org/org/forum/thread_9699/

PK
Freeman 2006/05/11 13:54
Thanks Pawel..i did it but its quite slow...any idea about a faster codes?
Freeman.
Pawel 2006/05/12 00:53
Reading a file is not a problem - it's fast enough. Just use:

Handle_StlMesh_Mesh theStlMesh = RWStl::ReadFile(thePath);

You can display a mesh quite fast if you use MeshVS:

Handle( MeshVS_Mesh ) aMesh = new MeshVS_Mesh();
                    Handle( XSDRAWSTLVRML_DataSource ) aDS = new XSDRAWSTLVRML_DataSource( theStlMesh );

                    aMesh->SetDataSource(aDS);
                    
                    aMesh->GetDrawer()->SetBoolean(MeshVS_DA_DisplayNodes,Standard_False); //MeshVS_DrawerAttribute
                    aMesh->AddBuilder( new MeshVS_MeshPrsBuilder( aMesh.operator->() ), Standard_True );
                    
                    myAISContext->Display(aMesh);

However it is still a wireframe model... I can't get over it. I'm planning to do some node reduction of the almost cooplanar faces in the mesh and the display it as a sewed (and possibly shaded) TopoShape (otherwise it's to slow). If someone has any other suggestions I would appreciate them.

Another issue is memory consumption either by meshes or topos... Some hints would be appreciated as well.

PK
Freeman 2006/05/12 06:15
Hi Pavel...
thanks for this approach.
Ok i'll start working on it.Another approach could be to use the PolyTriangulation class to split the Shape into an Array of triangles, and then used the sewing Class to gain a TopoDS_Shape from the array which could make things faster, and allow Boolean operations and other useful issues.I'm still exploring this possibility..the problem is that the sources of this class are not documented at all!
Freeman.
Pawel 2006/05/12 09:10
Sewing more than 20000 triangles and displaying them is not a good idea (at least with OC). It's totally slow. I've tried that. That's why I want to do the reduction of the nodes/faces.

PK
Marcel Janer 2006/10/13 04:53
I write about the reason that MeshVS_Mesh, XSDRAWSTLVRML_DataSource and MeshVS_MeshPrsBuilder aproach, only displays in WireFrame. I've token a look in occ source code (visualitzation.sln), and I've seen that can display in shade mode, the problem is that member MeshVS_Mesh::Compute(..) the argument "theMode" has lose its value, and always is 0, for this reason allways display as wireframe. Does anybody know how to solve this instead to change by a constant 2 the call of aCurrent->Build ( thePresentation, anElements, Standard_True, 2 /*theMode*/);?


the stl load and shading render is very fast!

best regards,

marcel janer.
Marcel Janer 2006/10/13 10:32
I write about the reason that MeshVS_Mesh, XSDRAWSTLVRML_DataSource and MeshVS_MeshPrsBuilder aproach, only displays in WireFrame. I've token a look in occ source code (visualitzation.sln), and I've seen that can display in shade mode, the problem is that member MeshVS_Mesh::Compute(..) the argument "theMode" has lose its value, and always is 0, for this reason allways display as wireframe. Does anybody know how to solve this instead to change by a constant 2 the call of aCurrent->Build ( thePresentation, anElements, Standard_True, 2 /*theMode*/);?


the stl load and shading render is very fast!

best regards,

marcel janer.
Marcel Janer 2006/10/13 11:18
you can do:

for fast load and render, in shade mode:
------------------------------

     Handle(StlMesh_Mesh) 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

     aMesh->GetDrawer()->SetBoolean(MeshVS_DA_DisplayNodes,Standard_False); //MeshVS_DrawerAttribute
     aMesh->GetDrawer()->SetBoolean(MeshVS_DA_ShowEdges,Standard_False);
     aMesh->GetDrawer()->SetMaterial(MeshVS_DA_FrontMaterial,DEFAULT_MATERIAL);


     aMesh->SetColor(Quantity_NOC_AZURE);
     aMesh->SetDisplayMode( MeshVS_DMF_Shading ); // Mode as defaut
     aMesh->SetHilightMode( MeshVS_DMF_WireFrame ); // Wireframe as default hilight mode

     myDoc->m_AISContext->Display(aMesh);


-----------------------


Marcel Janer.
Pawel 2006/10/18 09:21
Great post. I've been looking for it a long time.

Thanks
Pawel
 
 
Latest news
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!
  • Open CASCADE Technology 6.7.0 is available for download!

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