def test_landtake_flood_overwrite_material(self): (border, hole, line) = self.build_simple_scene() pond = self.mesher.insert_polyline( #NB CCW rect(3, 2.5, 4, 3.5), close_it=True, material='water', altitude=0, id='pond') self.mesher.update_info_for_edges() flooder = self.mesher.flood_polygon(mesh.LandtakeFaceFlooder, hole[0], close_it=True, flood_right=True) # hole is CW if runVisualTests: plotter = visu.MeshedCDTPlotter(self.mesher, title=self._testMethodName) plotter.plot_edges() marks = [self.mesher.point_for_face(f) for f in flooder.visited] visu.plot_points_seq(plotter.ax, marks, marker='*') plotter.show() face_in_both, expected_None = self.mesher.locate_point((3.25, 3)) self.assertIsNone(expected_None) self.assertIn(face_in_both, flooder.visited) face_out, expected_None = self.mesher.locate_point((1, 1.25)) self.assertIsNone(expected_None) self.assertNotIn(face_out, flooder.visited)
def test_input_constraints_orientation(self): (border, hole, line) = self.build_simple_scene() plotter = visu.MeshedCDTPlotter(self.mesher, title=self._testMethodName) plotter.plot_edges() faces_left, faces_right = mesh.left_and_right_faces( self.mesher.iter_faces_for_input_polyline(hole[0], close_it=True)) points_left = [self.mesher.point_for_face(f) for f in faces_left] points_right = [self.mesher.point_for_face(f) for f in faces_right] visu.plot_points_seq(plotter.ax, points_left, marker='<') visu.plot_points_seq(plotter.ax, points_right, marker='>') plotter.show()
def test_faces_from_input_constraint(self): # NB ABCD is given in counter-clock-wise orientation (vA, vB, vC, vD), _ = self.mesher.insert_polyline([(0, 0), (2, 0), (2, 1), (0, 1)], close_it=True) (vM, vN), _ = self.mesher.insert_polyline([(1, 2), (1, -1)]) # Get the two added vertices vP = self._find_vertex_at((1, 0)) self.assertIsNotNone(vP) vQ = self._find_vertex_at((1, 1)) self.assertIsNotNone(vQ) # Get the faces of interest f1 = self.mesher.face_for_vertices(vN, vP, vA) self.assertIsNotNone(f1) f2a = self.mesher.face_for_vertices(vP, vQ, vA) f2b = self.mesher.face_for_vertices(vP, vQ, vD) f2 = f2a or f2b self.assertIsNotNone(f2) f3 = self.mesher.face_for_vertices(vQ, vM, vD) self.assertIsNotNone(f3) faces_left, faces_right = mesh.left_and_right_faces( self.mesher.iter_faces_for_input_constraint(vM, vN)) if runVisualTests: plotter = visu.MeshedCDTPlotter(self.mesher, title=self._testMethodName) plotter.plot_edges() points_left = [self.mesher.point_for_face(f) for f in faces_left] points_right = [self.mesher.point_for_face(f) for f in faces_right] for vertex, name in zip((vA, vB, vC, vD, vM, vN, vP, vQ), ("A", "B", "C", "D", "M", "N", "P", "Q")): plotter.annotate_vertex(vertex, name) for i, f in enumerate((f1, f2, f3), 1): plotter.annotate_finite_face(f, "F%d" % i) visu.plot_points_seq(plotter.ax, points_left, marker='<') visu.plot_points_seq(plotter.ax, points_right, marker='>') plotter.show() self.assertEqual(faces_right, (f1, f2, f3))
def test_plot_landtake_flooding(self): cleaner = builder.recursively_merge_all_subsites(self.mainsite) site = cleaner.merged_site() mbuilder = builder.MeshBuilder(msite) bmesh = mbuilder.build_mesh(refine=False) mfiller = builder.MeshFiller(bmesh, mbuilder.vertices_for_feature) flood_seeds = mfiller._fill_polygonal_feature(self.building, mesh.LandtakeFaceFlooder) plotter = visu.MeshedCDTPlotter(bmesh, title=self._testMethodName) cleaner.equivalent_site.plot(plotter.ax, alt_geom_map=cleaner.geom) plotter.plot_edges() for fh in flood_seeds: marks = [bmesh.point_for_face(f) for f in flood_seeds] visu.plot_points_seq(plotter.ax, marks, marker='*') material_by_face = builder.material_by_face( mfiller.fill_material_and_landtakes(self.mainsite, cleaner)) for fh in bmesh.cdt.finite_faces(): material = material_by_face.get(fh) if material is None: continue plotter.plot_face(fh, material_id=material.id) plotter.show()