(box_and_vertex)
| 1982 | |
| 1983 | |
| 1984 | def test_PointInPlane_constraint(box_and_vertex): |
| 1985 | |
| 1986 | # add first constraint |
| 1987 | box_and_vertex.constrain( |
| 1988 | "vertex", |
| 1989 | box_and_vertex.children[0].obj.val(), |
| 1990 | "box", |
| 1991 | box_and_vertex.obj.faces(">X").val(), |
| 1992 | "PointInPlane", |
| 1993 | param=0, |
| 1994 | ) |
| 1995 | box_and_vertex.solve() |
| 1996 | solve_result_check(box_and_vertex._solve_result) |
| 1997 | |
| 1998 | x_pos = ( |
| 1999 | box_and_vertex.children[0].loc.wrapped.Transformation().TranslationPart().X() |
| 2000 | ) |
| 2001 | assert x_pos == pytest.approx(0.5) |
| 2002 | |
| 2003 | # add a second PointInPlane constraint |
| 2004 | box_and_vertex.constrain("vertex", "box@faces@>Y", "PointInPlane", param=0) |
| 2005 | box_and_vertex.solve() |
| 2006 | solve_result_check(box_and_vertex._solve_result) |
| 2007 | |
| 2008 | vertex_translation_part = ( |
| 2009 | box_and_vertex.children[0].loc.wrapped.Transformation().TranslationPart() |
| 2010 | ) |
| 2011 | # should still be on the >X face from the first constraint |
| 2012 | assert vertex_translation_part.X() == pytest.approx(0.5) |
| 2013 | # now should additionally be on the >Y face |
| 2014 | assert vertex_translation_part.Y() == pytest.approx(1) |
| 2015 | |
| 2016 | # add a third PointInPlane constraint |
| 2017 | box_and_vertex.constrain("vertex", "box@faces@>Z", "PointInPlane", param=0) |
| 2018 | box_and_vertex.solve() |
| 2019 | solve_result_check(box_and_vertex._solve_result) |
| 2020 | |
| 2021 | # should now be on the >X and >Y and >Z corner |
| 2022 | assert ( |
| 2023 | box_and_vertex.children[0] |
| 2024 | .loc.wrapped.Transformation() |
| 2025 | .TranslationPart() |
| 2026 | .IsEqual(gp_XYZ(0.5, 1, 1.5), 1e-6) |
| 2027 | ) |
| 2028 | |
| 2029 | |
| 2030 | def test_PointInPlane_3_parts(box_and_vertex): |
nothing calls this directly
no test coverage detected