JSCAD User Group

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Non manifold geometry with polyhedron

    General Discussions
    1
    5
    975
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      DrShoggoth last edited by

      I'm trying to generate threads and I'm there for the most part. As soon as I do any boolean operations with other geometries I end up with non-manifold geometries. I'm assuming that I am either misunderstanding how to use polyhedron() or I'm defining its polygons wrong. Does anybody know what I can do?

      function main() {
      const r = 10;
      const fn = 32;
      const h = 10;

      numSegments = (h+1)*fn;

      const points = seq(numSegments+1).flatMap( i => threadTriangle(r,360/fn*i,i/fn-1) );

      const closeFirst = [0,1,2];
      const segments = seq(numSegments).flatMap( i => {
      const m = i*3;
      return [
      [0,3,4,1].map(x => x+m),
      [1,4,5,2].map(x => x+m),
      [2,5,3,0].map(x => x+m)
      ];
      })
      const closeLast = [
      points.length-1,
      points.length-2,
      points.length-3,
      ];

      const threadPoly = polyhedron({
      points,
      polygons: [ closeFirst, ...segments, closeLast ]
      });

      const threadPolyTrimmed = intersection(
      threadPoly,
      cylinder({r:r+0.5,h,fn})
      );

      return union(
      threadPolyTrimmed,
      cylinder({r:r,h,fn})
      );

      }

      function threadTriangle(r,a,z) {
      const rad = a * Math.PI/180;
      const x1 = r * Math.cos(rad);
      const y1 = r * Math.sin(rad);

      const x2 = (r+0.475) * Math.cos(rad);
      const y2 = (r+0.475) * Math.sin(rad);

      return [[x1,y1,z],[x1,y1,0.95+z],[x2,y2,0.5+z]];
      }

      function seq(length) {
      return Array.apply(null, {length}).map(Function.call, Number);
      }

      1 Reply Last reply Reply Quote 0
      • D
        DrShoggoth last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • D
          DrShoggoth last edited by

          Nevermind, I fixed everything simply by using triangles instead of polygons.

          1 Reply Last reply Reply Quote 0
          • D
            DrShoggoth last edited by

            It's completely fine until I operate on it with any other geometry.
            0_1589397289948_Screenshot from 2020-05-13 14-14-17.png

            1 Reply Last reply Reply Quote 0
            • D
              DrShoggoth last edited by

              I double checked my polygons and they are all clockwise if you are facing them.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB | Contributors