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

Update shapes.py #986

Merged
merged 1 commit into from
Feb 10, 2022
Merged

Update shapes.py #986

merged 1 commit into from
Feb 10, 2022

Conversation

bragostin
Copy link
Contributor

Use TopTools_ListOfShape() in assembleEdges() as explained in issue : List of wires is not closed : solution proposal #985

Use TopTools_ListOfShape() in assembleEdges()
@codecov
Copy link

codecov bot commented Feb 8, 2022

Codecov Report

Merging #986 (4461f73) into master (ccc8292) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 4461f73 differs from pull request most recent head f66cc32. Consider uploading reports for the commit f66cc32 to get more accurate results

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #986   +/-   ##
=======================================
  Coverage   96.17%   96.17%           
=======================================
  Files          40       40           
  Lines        9286     9288    +2     
  Branches     1109     1109           
=======================================
+ Hits         8931     8933    +2     
  Misses        208      208           
  Partials      147      147           
Impacted Files Coverage Δ
cadquery/occ_impl/shapes.py 92.56% <100.00%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ccc8292...f66cc32. Read the comment docs.

@bragostin
Copy link
Contributor Author

"##[error]No hosted parallelism has been purchased or granted. To request a free parallelism grant, please fill out the following form https://aka.ms/azpi"

Is that ok?

@adam-urbanczyk
Copy link
Member

That's an unrelated issue with azure - working on it.

Copy link
Member

@jmwright jmwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bragostin

@jmwright jmwright merged commit 7847224 into CadQuery:master Feb 10, 2022
@bragostin
Copy link
Contributor Author

I have just noticed that this new assembleEdges method crashes when fed with a list having consecutive duplicate points. For example this crashes now, while it did not before:

import cadquery as cq

(L, H, W, t) = (100.0, 20.0, 20.0, 1.0)
pts = [
    (0, H/2.0),
    (0, H/2.0),
    (W/2.0, H/2.0),
    (W/2.0, (H/2.0 - t)),
    (t/2.0, (H/2.0 - t)),
    (t/2.0, (t - H/2.0)),
    (W/2.0, (t - H/2.0)),
    (W/2.0, H/-2.0),
    (0, H/-2.0)
]
result = cq.Workplane("front").polyline(pts).mirrorY().extrude(L)

Do you think this is a problem?

@jmwright
Copy link
Member

@bragostin How does it crash? Does it segfault or raise an exception? Does it give a stacktrace?

@bragostin
Copy link
Contributor Author

@jmwright It raises the following exception

Traceback (most recent call last):
  File "/home/bruno/Documents/CadQuery/tests/issues/polyline.py", line 15, in <module>
    result = cq.Workplane("front").polyline(pts).mirrorY().extrude(L)
  File "/home/bruno/.conda/envs/cadquery/lib/python3.9/site-packages/cadquery/cq.py", line 2719, in polyline
    edges.append(Edge.makeLine(startPoint, endPoint))
  File "/home/bruno/.conda/envs/cadquery/lib/python3.9/site-packages/cadquery/occ_impl/shapes.py", line 1826, in makeLine
    return cls(BRepBuilderAPI_MakeEdge(v1.toPnt(), v2.toPnt()).Edge())
OCP.StdFail.StdFail_NotDone: BRep_API: command not done

It looks like using TopTools_ListOfShape() in assembleEdges() makes it able to handle unordered edges, but not duplicate points. I found this issue because by accident I has duplicate points in a list, but practically there is no point in having them.

@adam-urbanczyk
Copy link
Member

@bragostin you error is not in assembleEdges, it is in polyline.

@bragostin
Copy link
Contributor Author

@adam-urbanczyk @jmwright yes, but before we changed assembleEdges the same code was not raising an exception. I have no problem with it since I don't see the point of having duplicate points, it's for the record in case somebody meets this issue.

@adam-urbanczyk
Copy link
Member

Failure in BRepBuilderAPI_MakeEdge has no relation to your change AFAICT. Ar you sure that this is not incidental?

@bragostin
Copy link
Contributor Author

@adam-urbanczyk I would think not because if I change back assembleEdges with

    for e in listOfEdges:
        wire_builder.Add(e.wrapped)

this errors disappears.

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

Successfully merging this pull request may close these issues.

3 participants