Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue in fixTJunctions #61

Open
bebbi opened this issue Apr 1, 2015 · 4 comments
Open

issue in fixTJunctions #61

bebbi opened this issue Apr 1, 2015 · 4 comments
Assignees

Comments

@bebbi
Copy link
Collaborator

bebbi commented Apr 1, 2015

See also #60 . This issue here is about fixing fixTJunctions..
While I think #60 is more important, here is another example that trigger either assertionFailed or sidemapIsEmpty depending on very minor changes in numbers. Possibly helps narrow down the issue.

    function main() {
        // this r produces assertion failed (unless H triggers sidemapisempty)
        var r = 2.306667;
        // this r produces sidemapisempty
        // var r = 2.30667;

        // this H produces sidemapisempty
        var H = 0.69333;
        // this H produces assertion failed
        // var H = 0.693333;

        var rotPath = CSG.Path2D.arc({
            center: [8.8, H],
            radius: r,
            startangle: 0,
            endangle: 90,
            resolution: 15 * r
        });
        rotPath = rotPath.appendPoints([[0, 3], [0, 0]]);
        var cag = CAG.fromPoints(rotPath.points);
        var csg_fail = cag.rotateExtrude({
            angle: 360,
            resolution: 50
        });
        var polys = csg_fail.polygons.filter(function(p){return p.getArea() > 1e-10});
        var csg_pass = CSG.fromPolygons(polys);
        return csg_fail; // vs csg_pass that works
    }
@joostn joostn self-assigned this Apr 1, 2015
@joostn
Copy link
Owner

joostn commented Apr 1, 2015

I haven't been able to get to the bottom of this but it looks like it's caused by nasty rounding errors. I guess these might leave small holes in the CSG so it's no longer watertight. At least that's what !sidemapisempty means: some sides have not been matched with a companion side in opposite direction.

I'd suggest (for now) just to comment out the 'throw new Error("!sidemapisempty");' line. The resulting solid is not watertight but many slicers will be able to handle this.

@bebbi
Copy link
Collaborator Author

bebbi commented Apr 3, 2015

For completeness, here's another one. It's a very different path to csg, so it may help (or distract..)

function main() {
    var res = CSG.sphere({
        radius: 1,
        resolution: 50
    });
    var stretchradius = [10, 4];
    var roundradius = [2, 3.5, 0.001];
    res = res.scale(roundradius);
    res = res.stretchAtPlane([1, 0, 0], [0, 0, 0], stretchradius[0]);
    res = res.stretchAtPlane([0, 1, 0], [0, 0, 0], stretchradius[1]);
    return res;
}

Meshmixer shows holes (blue pin) and non-manifold areas (red pin):
holes

@ghost
Copy link

ghost commented Nov 30, 2015

FYI, I've found that fixTJunctions() after a simple CSG operation leaves one T-junction untouched:

function main() {
   return CSG.cube({radius: 1.0, center: [0, 0, 0]})
         .subtract(CSG.cube({radius: 0.6, center: [0, 0, 0.5]}))
         .scale(10)
         .fixTJunctions();
}

Here is a screenshot of the output geometry opened in MeshLab:

t_junction_issue

@z3dev
Copy link
Collaborator

z3dev commented Dec 24, 2015

@sergerusso has an open pull request at @Spiritdude OpenJSCAD.org, which addresses this issue as well. Please review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants