Пример #1
0
    def test_obtuse_triangle(self):
        points = np.array([
            [0.0, 0.0],
            [1.0, 0.0],
            [0.5, 0.1],
        ])
        segments = np.array([[0, 1], [1, 2], [2, 0]])

        vertices, edges = snap_rounding(points, segments, 0.2)
        self.assertEqual(3, len(vertices))
        self.assertEqual(4, len(edges))
Пример #2
0
    def test_near_degeneracy(self):
        points = np.array([
            [0.0, 0.0],
            [0.0, 1e-12],
        ])
        segments = np.array([
            [0, 1],
        ])

        vertices, edges = snap_rounding(points, segments, 0.2)
        self.assertEqual(1, len(vertices))
        self.assertEqual(0, len(edges))
Пример #3
0
def resolve_self_intersection(wires, logger):
    if wires.num_vertices == 0:
        return wires;
    bbox_min, bbox_max = wires.bbox;
    tol = norm(bbox_max - bbox_min) / 1000;
    start_time = time();
    vertices, edges = pymesh.snap_rounding(wires.vertices, wires.edges, tol);
    finish_time = time();
    t = finish_time - start_time;
    logger.info("Snap rounding running time: {}".format(t));
    wires.load(vertices, edges);
    return wires;
Пример #4
0
def resolve_self_intersection(wires, logger):
    if wires.num_vertices == 0:
        return wires
    bbox_min, bbox_max = wires.bbox
    tol = norm(bbox_max - bbox_min) / 1000
    start_time = time()
    vertices, edges = pymesh.snap_rounding(wires.vertices, wires.edges, tol)
    finish_time = time()
    t = finish_time - start_time
    logger.info("Snap rounding running time: {}".format(t))
    wires.load(vertices, edges)
    return wires
Пример #5
0
    def test_degeneracy(self):
        points = np.array([
            [0.0, 0.0],
            [0.0, 0.0],
            ]);
        segments = np.array([
            [0, 1],
            ]);

        vertices, edges = snap_rounding(points, segments, 0.2);
        self.assertEqual(0, len(vertices));
        self.assertEqual(0, len(edges));
Пример #6
0
    def test_non_intersecting(self):
        points = np.array([
            [1.0, 0.0],
            [0.0, 1.0],
            [0.6, 0.6],
            [0.6, 1.7],
        ])
        segments = np.array([
            [0, 1],
            [2, 3],
        ])

        vertices, edges = snap_rounding(points, segments, 0.2)
        self.assertEqual(4, len(vertices))
        self.assertEqual(3, len(edges))
Пример #7
0
    def test_cross(self):
        points = np.array([
            [0.0, 0.0],
            [1.0, 0.0],
            [0.5, 1.0],
            [0.5, -1.0],
        ])
        segments = np.array([
            [0, 1],
            [2, 3],
        ])

        vertices, edges = snap_rounding(points, segments, 0.2)
        self.assertEqual(5, len(vertices))
        self.assertEqual(4, len(edges))
Пример #8
0
    def test_obtuse_triangle(self):
        points = np.array([
            [0.0, 0.0],
            [1.0, 0.0],
            [0.5, 0.1],
            ]);
        segments = np.array([
            [0, 1],
            [1, 2],
            [2, 0]
            ]);

        vertices, edges = snap_rounding(points, segments, 0.2);
        self.assertEqual(3, len(vertices));
        self.assertEqual(4, len(edges));
Пример #9
0
    def test_non_intersecting(self):
        points = np.array([
            [1.0, 0.0],
            [0.0, 1.0],
            [0.6, 0.6],
            [0.6, 1.7],
            ]);
        segments = np.array([
            [0, 1],
            [2, 3],
            ]);

        vertices, edges = snap_rounding(points, segments, 0.2);
        self.assertEqual(4, len(vertices));
        self.assertEqual(3, len(edges));
Пример #10
0
    def test_cross(self):
        points = np.array([
            [0.0, 0.0],
            [1.0, 0.0],
            [0.5, 1.0],
            [0.5,-1.0],
            ]);
        segments = np.array([
            [0, 1],
            [2, 3],
            ]);

        vertices, edges = snap_rounding(points, segments, 0.2);
        self.assertEqual(5, len(vertices));
        self.assertEqual(4, len(edges));
Пример #11
0
    def test_T_junction(self):
        points = np.array([
            [0.0, 0.0],
            [1.0, 0.0],
            [0.5, 1.0],
            [0.5, 0.0],
            ]);
        segments = np.array([
            [0, 1],
            [2, 3],
            ]);

        vertices, edges = snap_rounding(points, segments, 0.2);
        self.assertEqual(4, len(vertices));
        self.assertEqual(3, len(edges));
Пример #12
0
    def test_parallel_line(self):
        points = np.array([
            [0.0, 0.0],
            [0.0, 1.0],
            [0.1, 0.1],
            [0.1, 2.1],
            [0.2, 0.2],
            [0.2, 2.2],
        ])
        segments = np.array([
            [0, 1],
            [2, 3],
            [4, 5],
        ])

        vertices, edges = snap_rounding(points, segments, 0.2)
        self.assertEqual(5, len(vertices))
        self.assertEqual(4, len(edges))
Пример #13
0
    def test_parallel_line(self):
        points = np.array([
            [0.0, 0.0],
            [0.0, 1.0],
            [0.1, 0.1],
            [0.1, 2.1],
            [0.2, 0.2],
            [0.2, 2.2],
            ]);
        segments = np.array([
            [0, 1],
            [2, 3],
            [4, 5],
            ]);

        vertices, edges = snap_rounding(points, segments, 0.2);
        self.assertEqual(5, len(vertices));
        self.assertEqual(4, len(edges));
Пример #14
0
def resolve_self_intersection(wires, min_edge_size=1):
    vertices, edges = pymesh.snap_rounding(wires.vertices, wires.edges,
                                           1.0 * min_edge_size)  # TODO
    wires.load(vertices, edges)
    return wires