sghr / iGeo

iGeo: Computational Design and 3D Modeling Library for Processing
http://igeo.jp
GNU Lesser General Public License v3.0
146 stars 34 forks source link

Turning extruded point arrays into solids? #9

Open bennlich opened 10 years ago

bennlich commented 10 years ago

Is there currently a way to represent a closed object in iGeo? For example, if I want to extrude a surface? I saw iBox, which looks like one representation, but I didn't see anything more general. I suppose meshes can be closed?

sghr commented 10 years ago

There is extrude method in IG class and also cap method generating a brep as IBrep instance. For example, ICurve crv = new ICurve(IG.v(0,0,0, 10,0,0, 10,20,0, 0,10,0), true); // true is to close the curve ISurface srf = IG.extrude(crv, IG.v(0,0,30)); IBrep solid = IG.cap(srf);

However, cap and brep is still a bit experimental and it has bugs. You could also directly build IBrep instance out of surfaces and turn on closed flag but this is more experimental and tricky now.

If you are making 3D printable solid, I'd do with polygon mesh as IMesh instance, but you'd need to build all vertices and faces by yourself.

IVertex[] v = new IVertex[]{ new IVertex(0,0,0), new IVertex(0,10,0), new IVertex(10,0,0), new IVertex(0,0,20), new IVertex(0,10,20), new IVertex(10,0,30) }; IMesh mesh = new IMesh(); mesh.addQuads(new IVertex[]{ v[0],v[1],v[4],v[3] }); mesh.addQuads(new IVertex[]{ v[1],v[2],v[5],v[4] }); mesh.addQuads(new IVertex[]{ v[2],v[0],v[3],v[5] }); mesh.addTriangles(new IVertex[]{ v[2],v[1],v[0] }); mesh.addTriangles(new IVertex[]{ v[3],v[4],v[5] });