Comments (9)
Code in question is here:
I think genericIntersects
returns true, because triangles touch at one point. But then genericFuse
returns Blueprints
because it cannot combine two triangles. This edge case is considered a "bug".
It was actually really hard to tell what is the difference between Blueprints
and CompoundBlueprint
.
The former produces Sketches
the latter - CompoundSketch
.
CompoundSketch
is an array of N
sketches with first one representing outer "shell", and remaining N-1
representing holes.
If that is correct, then wrapping every triangle into Blueprints
should have worked:
function main({BlueprintSketcher, fuse2D, Blueprints}) {
const blueprints = triangles.map(([a, b, c]) =>
new BlueprintSketcher().movePointerTo(a).lineTo(b).lineTo(c).close(),
)
const fused = blueprints.reduce(
(acc, bp) => fuse2D(acc, new Blueprints([bp])),
new Blueprints([new BlueprintSketcher().hLine(1e-5).vLine(1e-5).close()]),
)
return fused.sketchOnPlane('XY').extrude(1)
}
But it doesn't, which may mean an unrelated bug?
from replicad.
Note that you might alos have made some weird behaving with stuff with new BlueprintSketcher().hLine(1e-5).vLine(1e-5).close()
- which is close to the precision of the fusing algorithm. Changing to the following does not explode (while the fuse is not working):
function main({BlueprintSketcher, fuse2D}) {
const blueprints = triangles.map(([a, b, c]) =>
new BlueprintSketcher().movePointerTo(a).lineTo(b).lineTo(c).close(),
)
// return blueprints.map((b,i) => b.sketchOnPlane('XY').extrude(1+i*0.2))
const fused = blueprints.reduce(
(acc, bp) => fuse2D(acc, bp),
new BlueprintSketcher().hLine(1e-5).vLine(1e-5).close(),
)
return fused.sketchOnPlane('XY').extrude(1)
}
As an aside I would advice you to use the draw
API which hides some complexity (typically with the blueprints vs blueprint):
function main({ draw }) {
const drawings = triangles.map(([a, b, c]) =>
draw().movePointerTo(a).lineTo(b).lineTo(c).close()
);
const fused = drawings
.slice(1)
.reduce((acc, bp) => acc.fuse(bp), drawings[0]);
return fused.sketchOnPlane("XY").extrude(1);
}
All of this said, it looks like you have found a bug with the single common point - I will have a look! Note that the spirit of the error message is to say there is a bug in my algo because it reached a state I thought it would not. But you found an edge case where it does.
from replicad.
Yes, that "invisible" triangle was a workaround to get an empty Blueprint. I haven't yet found a correct way to do it, and assumed it doesn't exist.
Changing to the following does not explode (while the fuse is not working)
I went over your "changed" code sample several times to find what's changed and suspect you may have copy-pasted a wrong file π
But looking at your second example with slice(1)
and and drawings[0]
as the starting accumulator I think I know what you've meant. It does fix the "Bug in blueprint fusing" exception but result is incorrect.
from replicad.
Oups, yeah, copy paste error!
All in all, I have found (and fixed) the bug - can you confirm that once the latest version of the visulalizer is loaded it works?
from replicad.
(seems like my comment disappeared, maybe I hit a network glitch)
I can confirm that v0.12.3 works great for the original test case.
However, I'm now hitting an infinite call loop in cleanEdgeCases
/ handleNestedBlueprints
.
My test code is here, will try to clean it up to be under 200 lines of code.
Do you prefer to open a new issue (so we'd have a sense of progress by marking this one as fixed) or add a new test case here?
P.S. is visualizer closed source? I could not find its source code in the main repo.
from replicad.
Your triangle mesh code is perfect to find bugs in my fusing algorithm. I solved the bugs you originally reported here, but it uncovered more.
The general gist is that the mesh creates shapes that do not intersects themselves but touch themselves in one point. It messes with the assumptions I had made for my algo a lot by opening a bunch of edge cases I had not thought about. You can see my progress here
from replicad.
Glad you are having fun! I was worried I sent too many bug reports at once :)
These triangles are from an experiment in unwrapping faces on a flat surface (think papercraft). So none of them should overlap (save for some bugs in earlier stages of my code).
Does OCJS expose any APIs to use OCCT's 2d boolean operations? I'm very new to these libraries, but this forum thread suggests there may be a function for that.
from replicad.
This is for merging stuff and creating faces (i.e. a 2D surface in 3D space). What I am trying to achieve with drawings (and blueprints) is to have stuff in 2D in a 2D plane - not notion of the third dimension.
For the papercraft stuff, I am not sure that merging the triangles is the good way of doing it - you still want the borders to of the triangles to exists (to make folding patterns).
Is this what you expect from the merge? Is my algorithm dropping some triangles it should not, or are there some triangles missing in your example)?
This is all in 0.12.4 (and on the visualizer) - do you confirm?
from replicad.
Yes, your image matches the one I get if I simply extrude each triangle separately.
Closing this issue now.
Thanks a lot for fixing it!
from replicad.
Related Issues (20)
- Add Support for Exporting Reference Geometry HOT 4
- Section view broken for some models, hard to fix HOT 2
- [Request] Option to set parameter panel to uncollapsed in share links HOT 1
- Import STEP file in my scene HOT 2
- Interpolate curves HOT 1
- Some typing issues HOT 3
- Request: Export binary STL HOT 1
- Missing documentation on 3D operations HOT 7
- BUG: makeBaseBox HOT 3
- Missing UV mapping on the geometry HOT 4
- [Request] More compact parameters panel in studio
- Set a name for parts / the default scale in the output file HOT 4
- drawProjection import from node package failing HOT 3
- How to get the volume and surface area of a shape? HOT 3
- Convert Entities Function HOT 4
- Error more gracefully in set operations HOT 1
- [Request] Adding Threejs bufferGeometry to replicad object converter in replicad-threejs-helper HOT 1
- how to properly load the full wasm package from opencascade and/or see better errors HOT 8
- can't open existing model (.js) file HOT 1
- rotating the view is messed up after clicking an axis HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from replicad.