miho / JCSG

Java implementation of BSP based CSG (Constructive Solid Geometry)
Other
177 stars 52 forks source link

STL file generated for a simple Polyhedron (L shape) : one face should not be part of the model #49

Open karimall72 opened 6 years ago

karimall72 commented 6 years ago

Hello,

I want to generate a simple polyhedron (L shape) with the following code:

    List<Vector3d> listPoint = new ArrayList<Vector3d>();
    listPoint.add(Vector3d.xyz(0, 10, 0));
    listPoint.add(Vector3d.xyz(2, 10, 0));
    listPoint.add(Vector3d.xyz(2, 5, 0));
    listPoint.add(Vector3d.xyz(10, 5, 0));
    listPoint.add(Vector3d.xyz(10, 0, 0));
    listPoint.add(Vector3d.xyz(0, 0, 0));
    listPoint.add(Vector3d.xyz(0, 10, 20));
    listPoint.add(Vector3d.xyz(2, 10, 20));
    listPoint.add(Vector3d.xyz(2, 5, 20));
    listPoint.add(Vector3d.xyz(10, 5, 20));
    listPoint.add(Vector3d.xyz(10, 0, 20));
    listPoint.add(Vector3d.xyz(0, 0, 20));
    listPoint.add(Vector3d.xyz(4, 5, 20));
    List<List<Integer>> listFace = new ArrayList<List<Integer>>();
    listFace.add(Arrays.asList(0, 1, 2, 3, 4, 5));
    listFace.add(Arrays.asList(8, 7, 6, 11, 10, 9));
    listFace.add(Arrays.asList(1, 0, 6, 7));
    listFace.add(Arrays.asList(2, 1, 7, 8));
    listFace.add(Arrays.asList(3, 2, 8, 9));
    listFace.add(Arrays.asList(4, 3, 9, 10));
    listFace.add(Arrays.asList(5, 4, 10, 11));
    listFace.add(Arrays.asList(0, 5, 11, 6));
    CSG polyhedron = new Polyhedron(listPoint, listFace).toCSG();

The STL generated file for this polyhedron looks like this:

polyhedronwithonebadface

The red triangle should not be there. Otherwise, everything is fine.

Do I misuse the Polyhedron class, or is there an issue in its implementation ? (of course, using the Extrude.points(...) method would be the right choice in that case, but I need to focus on Polyhedrons).

Regards

selvakarna commented 5 years ago

How did you get faces for STL forming? how to generate faces from Vertices automatically ?with perfect shape?

karimall72 commented 5 years ago

Thank you for you comment. Can you clarify ? Is your question related to the way I construct the L shape ? If yes, I am working on a 3D design software, which can save 3D model as "obj" or "stl" file. So, I just add to take coordinates and faces indices from a generated file to write the provided sample java code.

selvakarna commented 5 years ago

Yes it's possible ,vertices converted to STL 3d model. You are working 3d drawings or what?

Thanks and regards, SelvaKarna

On Thu, 9 May 2019, 02:27 karimall72, notifications@github.com wrote:

Thank you for you comment. Can you clarify ? Is your question related to the way I construct the L shape ? If yes, I am working on a 3D design software, which can save 3D model as "obj" or "stl" file. So, I just add to take coordinates and faces indices from a generated file to write the provided sample java code.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/miho/JCSG/issues/49#issuecomment-490648336, or mute the thread https://github.com/notifications/unsubscribe-auth/AGCXFJZ36ZOQE3SE6TT4BG3PUM5FBANCNFSM4FJ7ZBSA .