Identifyin and Splitting separate geometry elements
Posted: Mon 1. Aug 2011, 20:50
Hello,
I'm working on a project which requires me to read in files in the STL format. Oftentimes these files contain more than one discrete object, so I would like to split them up, or be able to create an element hierarchy and access them separately in the viewer. I've written some code which allows me to identify simple objects in small files, but the algorithm does not scale well for larger or more complicated files. I'm wondering if there are any existing tools which would allow me to efficiently identify separate geometry elements in the scene?
As a concrete example, here's an stl file containing two cubes (it seems files with an stl extension are not accepted as attachments). I'd like to be able to read this in, identify the two separate cubes and then either create a scene hierarchy with the two separate cubes, or simply write each out as a separate file.
Any help would be appreciated.
Thank you very much,
Norman
I'm working on a project which requires me to read in files in the STL format. Oftentimes these files contain more than one discrete object, so I would like to split them up, or be able to create an element hierarchy and access them separately in the viewer. I've written some code which allows me to identify simple objects in small files, but the algorithm does not scale well for larger or more complicated files. I'm wondering if there are any existing tools which would allow me to efficiently identify separate geometry elements in the scene?
As a concrete example, here's an stl file containing two cubes (it seems files with an stl extension are not accepted as attachments). I'd like to be able to read this in, identify the two separate cubes and then either create a scene hierarchy with the two separate cubes, or simply write each out as a separate file.
Any help would be appreciated.
Thank you very much,
Norman
- solid stl file generated by hand
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex -2.500000 -0.500000 -0.500000
vertex -1.500000 -0.500000 0.500000
vertex -2.500000 -0.500000 0.500000
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex -1.500000 -0.500000 0.500000
vertex -2.500000 -0.500000 -0.500000
vertex -1.500000 -0.500000 -0.500000
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex -1.500000 0.500000 -0.500000
vertex -2.500000 0.500000 0.500000
vertex -1.500000 0.500000 0.500000
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex -2.500000 0.500000 0.500000
vertex -1.500000 0.500000 -0.500000
vertex -2.500000 0.500000 -0.500000
endloop
endfacet
facet normal 0.000000 0.000000 1.000000
outer loop
vertex -2.500000 0.500000 0.500000
vertex -1.500000 -0.500000 0.500000
vertex -1.500000 0.500000 0.500000
endloop
endfacet
facet normal 0.000000 0.000000 1.000000
outer loop
vertex -1.500000 -0.500000 0.500000
vertex -2.500000 0.500000 0.500000
vertex -2.500000 -0.500000 0.500000
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -2.500000 -0.500000 -0.500000
vertex -1.500000 0.500000 -0.500000
vertex -1.500000 -0.500000 -0.500000
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex -1.500000 0.500000 -0.500000
vertex -2.500000 -0.500000 -0.500000
vertex -2.500000 0.500000 -0.500000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex -2.500000 -0.500000 -0.500000
vertex -2.500000 0.500000 0.500000
vertex -2.500000 0.500000 -0.500000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex -2.500000 0.500000 0.500000
vertex -2.500000 -0.500000 -0.500000
vertex -2.500000 -0.500000 0.500000
endloop
endfacet
facet normal 1.000000 0.000000 0.000000
outer loop
vertex -1.500000 -0.500000 0.500000
vertex -1.500000 0.500000 -0.500000
vertex -1.500000 0.500000 0.500000
endloop
endfacet
facet normal 1.000000 0.000000 0.000000
outer loop
vertex -1.500000 0.500000 -0.500000
vertex -1.500000 -0.500000 0.500000
vertex -1.500000 -0.500000 -0.500000
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex 1.500000 -0.500000 -0.500000
vertex 2.500000 -0.500000 0.500000
vertex 1.500000 -0.500000 0.500000
endloop
endfacet
facet normal 0.000000 -1.000000 0.000000
outer loop
vertex 2.500000 -0.500000 0.500000
vertex 1.500000 -0.500000 -0.500000
vertex 2.500000 -0.500000 -0.500000
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex 2.500000 0.500000 -0.500000
vertex 1.500000 0.500000 0.500000
vertex 2.500000 0.500000 0.500000
endloop
endfacet
facet normal 0.000000 1.000000 0.000000
outer loop
vertex 1.500000 0.500000 0.500000
vertex 2.500000 0.500000 -0.500000
vertex 1.500000 0.500000 -0.500000
endloop
endfacet
facet normal 0.000000 0.000000 1.000000
outer loop
vertex 1.500000 0.500000 0.500000
vertex 2.500000 -0.500000 0.500000
vertex 2.500000 0.500000 0.500000
endloop
endfacet
facet normal 0.000000 0.000000 1.000000
outer loop
vertex 2.500000 -0.500000 0.500000
vertex 1.500000 0.500000 0.500000
vertex 1.500000 -0.500000 0.500000
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex 1.500000 -0.500000 -0.500000
vertex 2.500000 0.500000 -0.500000
vertex 2.500000 -0.500000 -0.500000
endloop
endfacet
facet normal 0.000000 0.000000 -1.000000
outer loop
vertex 2.500000 0.500000 -0.500000
vertex 1.500000 -0.500000 -0.500000
vertex 1.500000 0.500000 -0.500000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex 1.500000 -0.500000 -0.500000
vertex 1.500000 0.500000 0.500000
vertex 1.500000 0.500000 -0.500000
endloop
endfacet
facet normal -1.000000 0.000000 0.000000
outer loop
vertex 1.500000 0.500000 0.500000
vertex 1.500000 -0.500000 -0.500000
vertex 1.500000 -0.500000 0.500000
endloop
endfacet
facet normal 1.000000 0.000000 0.000000
outer loop
vertex 2.500000 -0.500000 0.500000
vertex 2.500000 0.500000 -0.500000
vertex 2.500000 0.500000 0.500000
endloop
endfacet
facet normal 1.000000 0.000000 0.000000
outer loop
vertex 2.500000 0.500000 -0.500000
vertex 2.500000 -0.500000 0.500000
vertex 2.500000 -0.500000 -0.500000
endloop
endfacet
endsolid