MCPcopy
hub / github.com/CadQuery/cadquery / check

Function check

cadquery/occ_impl/shapes.py:7861–7896  ·  view source on GitHub ↗

Check if a shape is valid.

(
    s: Shape,
    results: list[tuple[list[Shape], Any]] | None = None,
    tol: float | None = None,
    verbose: bool = True,
)

Source from the content-addressed store, hash-verified

7859
7860
7861def check(
7862 s: Shape,
7863 results: list[tuple[list[Shape], Any]] | None = None,
7864 tol: float | None = None,
7865 verbose: bool = True,
7866) -> bool:
7867 """
7868 Check if a shape is valid.
7869 """
7870
7871 analyzer = BRepAlgoAPI_Check(s.wrapped)
7872 analyzer.SetRunParallel(True)
7873 analyzer.SetUseOBB(True)
7874
7875 analyzer.Perform()
7876
7877 rv = analyzer.IsValid()
7878
7879 if tol:
7880 analyzer.SetFuzzyValue(tol)
7881
7882 # generate warnings, output detailed results if requested
7883 if results is not None:
7884 results.clear()
7885
7886 for r in analyzer.Result():
7887 res = (_toptools_list_to_shapes(r.GetFaultyShapes1()), r.GetCheckStatus())
7888 msg = f"\n\tCheck failed.\n\tSubshapes: {res[0]} \n\tStatus: {res[1]}"
7889
7890 if verbose:
7891 warn(msg)
7892
7893 if results is not None:
7894 results.append(res)
7895
7896 return rv
7897
7898
7899def isSubshape(s1: Shape, s2: Shape) -> bool:

Callers 1

test_checkFunction · 0.85

Calls 3

_toptools_list_to_shapesFunction · 0.85
appendMethod · 0.80
clearMethod · 0.45

Tested by 1

test_checkFunction · 0.68