def surface_surface_check(strategy, surface1, surface2, *all_intersected): # NOTE: There is no corresponding "enable", but the disable only applies # in this lexical scope. # pylint: disable=too-many-locals assert surface1.is_valid assert surface2.is_valid intersections = surface1.intersect(surface2, strategy=strategy) extra_verify(strategy, intersections) if len(intersections) != len(all_intersected): raise utils.IncorrectCount( "Received wrong number of intersections", len(intersections), "Expected", len(all_intersected), ) all_edges = surface1._get_edges() + surface2._get_edges() for intersection, intersected in six.moves.zip( intersections, all_intersected ): if isinstance(intersection, bezier.CurvedPolygon): assert isinstance(intersected, utils.CurvedPolygonInfo) edge_info, int_edges = curved_polygon_edges(intersection) num_edges = len(edge_info) if num_edges != len(intersected.edge_list): raise utils.IncorrectCount( "Received wrong number of edges within an intersection", num_edges, "Expected", len(intersected.edge_list), ) assert num_edges == len(intersected.start_params) assert num_edges == len(intersected.end_params) assert num_edges == len(intersected.nodes) for index in six.moves.xrange(num_edges): edge_triple = edge_info[index] edge_index = intersected.edge_list[index] assert edge_triple[0] == edge_index start_val = intersected.start_params[index] end_val = intersected.end_params[index] CONFIG.assert_close(edge_triple[1], start_val) CONFIG.assert_close(edge_triple[2], end_val) expected_root = all_edges[edge_index] specialized = expected_root.specialize(start_val, end_val) edge = int_edges[index] assert np.allclose(specialized._nodes, edge._nodes) node = intersected.nodes[index, :] CONFIG.assert_close(edge._nodes[0, 0], node[0]) CONFIG.assert_close(edge._nodes[1, 0], node[1]) else: assert isinstance(intersection, bezier.Surface) assert isinstance(intersected, utils.SurfaceIntersectionInfo) if intersected.first: assert intersection is surface1 else: assert intersection is surface2
def get_sorted_intersections(intersection_info, strategy): nodes1 = intersection_info.nodes1 nodes2 = intersection_info.nodes2 if strategy is GEOMETRIC: intersections, _ = _geometric_intersection.all_intersections( nodes1, nodes2) else: intersections, _ = _algebraic_intersection.all_intersections( nodes1, nodes2) # Make we have the right number of intersections. if intersections.shape != (2, intersection_info.num_params): raise utils.IncorrectCount( "Received wrong number of intersections", intersections.shape, "Expected", intersection_info.num_params, intersection_info.test_id, ) # Sort the intersections by s-value. sorted_inds = np.argsort(intersections[0, :]) return intersections[:, sorted_inds]