Closed FishOrBear closed 3 years ago
The algorithm ran in my WebCAD project, and the performance was very good.
vers: [0, 0, 0, -600, 0, 0, -600, -18, 0, -18, -18, 0, -18, -600.0000000000005, 0, 0, -600.0000000000005, 0] close:false
There is a problem with this result
Yeah the wasm performance is quite good, the the interactive web demo app for cavalier contours is here.
Can you give me the minimum reproducible data for the problem you found (vertexes, is_closed, offset value)?
I figured it out from your post + video, I'll look into it. Here it is in the cavalier contours web demo app:
{
"isClosed": false,
"vertexes": [
[0, 0, 0],
[-600, 0, 0],
[-600, -18, 0],
[-18, -18, 0],
[-18, -600.0000000000005, 0],
[0, -600.0000000000005, 0]
]
}
This fillet is sometimes not needed. AutoCAD's offset does not handle this.
Can you add a control field to control whether or not to chamfer?
Possibly, I don't currently have a use for that so I'm not sure when I'll get around to it. The algorithm performs distance checks between the offset segments and the original polyline to to prune collapsed regions, this may get falsely triggered in some cases if the lines are extended out rather than rounded (if the lines are truncated with a straight edge this wouldn't falsely trigger). I'd have to look into it more.
Is there a hosted interactive page for the CAD tool you're creating?
Page never finishes loading - download rate seems to be getting throttled/cut, I just see the loading screen and animation but it's stuck at 99%.
Our server is in China, and foreign access may be slower.
What chat software do you use, or can you use teamview to remotely assist?
Or open f12 to see if the js resource can be loaded normally
The progress bar is not accurate. Are you using chrome browser? We also don't support mobile devices.
I'm in US California, I think it's just blocking traffic from where I am, when I look at task manager network activity is always less than 0.1Mbps. I tried both Firefox and Microsoft Edge.
I looked into the issue you reported, I don't see any problems. The polyline you posted seems to offset correctly when either open or closed. What offset value are you using? In the video it looks like it's collapsed to a coincident segment (offset = 9) and everything looks correct in the cavalier contours web demo (the algorithm always keeps coincident/overlapping results).
{"vertexes":[[0,0,0],[-600,0,0],[-600,-18,0],[-18,-18,0],[-18,-600.0000000000005,0],[0,-600.0000000000005,0],[0,0,0]],"isClosed":false}
offset = 9
When isClosed=true, the result is correct.
So isClose
does not seem to be a closed mark closeMark
The behavior is different from autocad.
Even when open it produces the correct result when I tested it. The vertical edge just lines up with the origin axis line so it looks wrong visually in the screenshot, but it's an open polyline so the part sticking out past the arc should be there.
How do you expect the the result should be different?
I thought their behavior should be consistent.
Because the contour is the same when isClose=true or IsClose=false.
So their offset result should be the same.
{"vertexes":[[0,0,0],[100,0,0],[100,100,0],[0,100,0]],"isClosed":true}
{"vertexes":[[0,0,0],[100,0,0],[100,100,0],[0,100,0],[0,0,0]],"isClosed":false}
I think their offset results should be the same, But the offset result is different.
But this is not a problem, I can adapt this by changing the code
Pasting those examples into the cavalier contours web demo produces the same result... Am I missing something?
Oh are you saying the "isClosed" property isn't set to true in the result? Yes if the input is an open polyline then it returns it as an open polyline. If you want to close it you can test if polyline.firstVertexPosition == polyline.lastVertexPosition
.
Oh, it looks right, I did it wrong, I'm very sorry
Pasting those examples into the cavalier contours web demo produces the same result... Am I missing something?
What is this url address
{"vertexes":[[0,0,0],[100,0,0],[100,100,0],[0,100,0],[0,0,0]],"isClosed":true}
This doesn't look great
{"vertexes":[[12423.122820176195,3528.5133862542775,0],[12423.122820176195,3510.5133862542775,0],[12837.342864924894,3510.5133862542775,0],[12837.342864924894,2907.7942631500323,0],[12855.342864924894,2907.7942631500323,0],[12855.342864924894,3528.5133862542775,0]],"isClosed":true}
It should be better to return one line in this case
https://jbuckmccready.github.io/cavalier_contours_web_demo_page/ for the web demo page.
{"vertexes":[[0,0,0],[100,0,0],[100,100,0],[0,100,0],[0,0,0]],"isClosed":true}
...image removed for readability...
This doesn't look great
The offset algorithm does not test for/handle repeat position vertexes (here x=0, y=0 is repeated). You can use the remove_repeat_pos
polyline method to clean it up before performing the offset. Method is here: https://github.com/jbuckmccready/cavalier_contours/blob/master/cavalier_contours/src/polyline/pline.rs#L409
I plan to add a offset options flag that will cause the function to clean things up as best it can before performing the offset, currently it doesn't do it for performance reasons. Note it does have a debug assert to catch this case, I recommend compiling with debug asserts enabled for testing.
...image removed for readability...
{"vertexes":[[12423.122820176195,3528.5133862542775,0],[12423.122820176195,3510.5133862542775,0],[12837.342864924894,3510.5133862542775,0],[12837.342864924894,2907.7942631500323,0],[12855.342864924894,2907.7942631500323,0],[12855.342864924894,3528.5133862542775,0]],"isClosed":true}
It should be better to return one line in this case
The algorithm tries to join the longest connected sequence when overlapping is involved. Can you create a simpler example that is smaller and has the problem you describe?
{"vertexes":[[0,0,0],[432.22004474869937,0,0],[432.22004474869937,-620.7191231042452,0],[414.22004474869937,-620.7191231042452,0],[414.22004474869937,-18,0],[0,-18,0]],"isClosed":true}
There is no way to simplify the 6-point outline, it is already very simple
It looks like the results overlap
I think I found the overlap join bug and I have a fix working. I will try to review and commit it tomorrow, and add the case to the automated tests.
https://github.com/jbuckmccready/CavalierContours/blob/master/include/cavc/polylineoffsetislands.hpp
It seems that this feature has not been implemented in rust, and I haven't found this method.
This polyline cannot be offset outside
{"vertexes":[[0,0,2.9239855509708432],[422.7001801508977,-2181.678349165927,0.21373279590439873],[1217.850643134374,-1733.2038795014323,4.472986753391631],[961.0754444813574,-155.87051634718955,0.22947158823257166]],"isClosed":true}
I committed fix and added test case for issue you had with overlapping result, test it and let know how it goes.
I'm closing this issue, please make a new issues for each bug report, it's easier for me to track things
I don't have any plans currently to work on and maintain a wasm API but Rust supports wasm directly, see the web demo project here. The example file that creates an FFI for wasm is here.