예제 #1
0
def load_parameters(wire_network, config):
    parameters = Parameters(wire_network, config["thickness"]);
    if "modifier_file" in config:
        if "dof_file" in config:
            print("dof_file is shadowed by modifier file!");
        parameters.load_modifier_file(config["modifier_file"]);
    elif "dof_file" in config:
        parameters.load_dof_file(config["dof_file"]);
    return parameters;
예제 #2
0
    def test_tile_with_guide_mesh(self):
        wire_network = self.get_brick5()
        params = Parameters(wire_network, 0.5)

        tiler = Tiler(wire_network)

        mesh = generate_box_mesh(np.zeros(3),
                                 np.ones(3),
                                 subdiv_order=1,
                                 using_simplex=False)

        tiler = Tiler(wire_network)
        tiler.tile_with_guide_mesh(mesh, params)
        tiled_wire_network = tiler.wire_network

        self.assertEqual(8 * wire_network.num_edges,
                         tiled_wire_network.num_edges)
        self.assertEqual(8 * wire_network.num_vertices - 12,
                         tiled_wire_network.num_vertices)
        self.assert_array_equal(mesh.bbox, tiled_wire_network.bbox)
        self.assertTrue(tiled_wire_network.has_attribute("thickness"))
        self.assertTrue(tiled_wire_network.has_attribute("vertex_offset"))
        self.assert_array_equal(
            np.ones(tiled_wire_network.num_vertices) * 0.5,
            tiled_wire_network.get_attribute("thickness").ravel())
예제 #3
0
    def test_tile_with_mixed_patterns(self):
        wire_networks = [self.get_brick5(),
                         self.get_cross_3D()]
        params = [
            Parameters(wire_networks[0], 0.1),
            Parameters(wire_networks[1], 0.0)
        ]
        params[0].load_default_isotropic_parameters()
        params[1].load_default_isotropic_parameters()

        max_num_dofs = max(params[0].num_dofs, params[1].num_dofs)
        pattern_id = np.array([0, 1, 1, 0, 1, 0, 0, 1])

        mesh = generate_box_mesh(np.zeros(3),
                                 np.ones(3),
                                 subdiv_order=1,
                                 using_simplex=False)
        mesh.add_attribute("pattern_id")
        mesh.set_attribute("pattern_id", pattern_id)
        for i in range(max_num_dofs):
            dof_name = "dof_{}".format(i)
            dof = np.array([
                params[j].dofs[i] if i < params[j].num_dofs else 0
                for j in pattern_id
            ])

            mesh.add_attribute(dof_name)
            mesh.set_attribute(dof_name, dof)

        tiler = Tiler(wire_networks)
        tiler.tile_with_mixed_patterns(mesh)
        tiled_wire_network = tiler.wire_network

        self.assert_array_equal(mesh.bbox, tiled_wire_network.bbox)
        self.assertEqual(
            (wire_networks[0].num_edges + wire_networks[1].num_edges) * 4,
            tiled_wire_network.num_edges)
        self.assertEqual(
            (wire_networks[0].num_vertices + wire_networks[1].num_vertices) * 4
            - 4 * 3, tiled_wire_network.num_vertices)
예제 #4
0
    def test_periodic(self):
        wire_network = self.get_pattern1065()
        wire_network.scale(5)

        params = Parameters(wire_network, 0.5)

        inflator = Inflator(wire_network)
        inflator.subdivide_order = 0
        inflator.inflate_periodic(params)
        mesh = inflator.mesh

        self.assertLess(0, mesh.num_vertices)
        self.assertLess(0, mesh.num_faces)
        self.assertTrue(mesh.is_closed())
예제 #5
0
def load_parameters(wire_network, config):
    parameters = Parameters(wire_network, config["thickness"])
    if "modifier_file" in config:
        if "dof_file" in config:
            print("dof_file is shadowed by modifier file!")
        parameters.load_modifier_file(config["modifier_file"])
    elif "dof_file" in config:
        parameters.load_dof_file(config["dof_file"])
    return parameters
예제 #6
0
    def test_tiled(self):
        wire_network = self.get_brick5()
        params = Parameters(wire_network, 0.1)
        tiler = Tiler()
        tiler.set_base_pattern(wire_network)
        tiler.tile_with_guide_bbox(np.zeros(3), np.ones(3),
                                   np.ones(3) * 2, params)
        tiled_wire_network = tiler.wire_network

        inflator = Inflator(tiled_wire_network)
        inflator.inflate(tiled_wire_network.get_attribute("thickness").ravel())
        mesh = inflator.mesh

        self.assertLess(0, mesh.num_vertices)
        self.assertLess(0, mesh.num_faces)
        self.assertTrue(mesh.is_closed())
예제 #7
0
    def test_tile_with_bbox(self):
        wire_network = self.get_brick5()
        params = Parameters(wire_network, 0.5)
        bbox_min = np.zeros(3)
        bbox_max = np.ones(3) * 5 * 2
        reps = np.ones(3) * 2

        tiler = Tiler(wire_network)
        tiler.tile_with_guide_bbox(bbox_min, bbox_max, reps, params)
        tiled_wire_network = tiler.wire_network

        self.assertEqual(8 * wire_network.num_edges,
                         tiled_wire_network.num_edges)
        self.assertEqual(8 * wire_network.num_vertices - 12,
                         tiled_wire_network.num_vertices)
        self.assert_array_equal([bbox_min, bbox_max], tiled_wire_network.bbox)
        self.assertTrue(tiled_wire_network.has_attribute("thickness"))
        self.assertTrue(tiled_wire_network.has_attribute("vertex_offset"))
        self.assert_array_equal(
            np.ones(tiled_wire_network.num_vertices) * 0.5,
            tiled_wire_network.get_attribute("thickness").ravel())