Esempio n. 1
0
def tile_with_guide_mesh(config):
    options = extract_options(config);
    network = load_wire(str(config["wire_network"]));
    parameters = load_parameters(network, config);
    guide_mesh = pymesh.load_mesh(config["guide_mesh"]);

    tiler = Tiler();
    tiler.set_base_pattern(network);
    tiler.tile_with_guide_mesh(guide_mesh, parameters);
    network = tiler.wire_network;

    inflator = Inflator(network);
    inflator.inflate(network.get_attribute("thickness").ravel(),
            parameters.per_vertex_thickness);
    return inflator.mesh;
Esempio n. 2
0
def tile_with_mixed_patterns(config):
    options = extract_options(config);
    options["dof_type"] = str(config.get("dof_type", "isotropic"));
    options["thickness_type"] = str(config.get("thickness_type", "vertex"));
    networks = load_wires(str(config["wire_list_file"]));
    guide_mesh = pymesh.load_mesh(config["guide_mesh"]);
    per_vertex_thickness = options["thickness_type"] == "vertex";

    tiler = Tiler();
    tiler.tile_with_mixed_patterns(mesh,
            per_vertex_thickness, options["dof_type"] == "isotropic");
    network = tiler.wire_network;

    inflator = Inflator(network);
    inflator.inflate(network.get_attribute("thickness").ravel(),
            per_vertex_thickness);
    return inflator.mesh;
Esempio n. 3
0
def tile_with_guide_box(config):
    options = extract_options(config);
    network = load_wire(str(config["wire_network"]));
    parameters = load_parameters(network, config);
    tiler = Tiler();
    tiler.set_base_pattern(network);
    tiler.tile_with_guide_bbox(
            config["bbox_min"][:network.dim],
            config["bbox_max"][:network.dim],
            config["repeats"][:network.dim],
            parameters);
    network = tiler.wire_network;

    inflator = Inflator(network);
    inflator.inflate(network.get_attribute("thickness").ravel(),
            parameters.per_vertex_thickness);
    return inflator.mesh;
Esempio n. 4
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());
Esempio n. 5
0
def tile_with_mixed_patterns(config):
    options = extract_options(config);
    options["dof_type"] = str(config.get("dof_type", "isotropic"));
    options["thickness_type"] = str(config.get("thickness_type", "vertex"));
    networks = load_wires(str(config["wire_list_file"]));
    guide_mesh = pymesh.load_mesh(config["guide_mesh"]);
    per_vertex_thickness = options["thickness_type"] == "vertex";

    tiler = Tiler();
    tiler.tile_with_mixed_patterns(mesh,
            per_vertex_thickness, options["dof_type"] == "isotropic");
    network = tiler.wire_network;

    if config.get("trim", False):
        network.trim();

    inflator = Inflator(network);
    inflator.inflate(network.get_attribute("thickness").ravel(),
            per_vertex_thickness);
    return inflator.mesh;
Esempio n. 6
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())
Esempio n. 7
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())
Esempio n. 8
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)
Esempio n. 9
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());
Esempio n. 10
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);
Esempio n. 11
0
def tile_with_mixed_patterns(config):
    options = extract_options(config)
    options["dof_type"] = str(config.get("dof_type", "isotropic"))
    options["thickness_type"] = str(config.get("thickness_type", "vertex"))
    networks = load_wires(str(config["wire_list_file"]))
    guide_mesh = pymesh.load_mesh(config["guide_mesh"])
    per_vertex_thickness = options["thickness_type"] == "vertex"

    tiler = Tiler()
    tiler.tile_with_mixed_patterns(mesh, per_vertex_thickness,
                                   options["dof_type"] == "isotropic")
    network = tiler.wire_network

    if config.get("trim", False):
        network.trim()
    if "output_wire_network" in config:
        network.write_to_file(config["output_wire_network"])

    inflator = Inflator(network)
    inflator.subdivide_order = options["subdiv"]
    inflator.subdivide_method = options["subdiv_method"]
    inflator.inflate(
        network.get_attribute("thickness").ravel(), per_vertex_thickness)
    return inflator.mesh
Esempio n. 12
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());
Esempio n. 13
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())
Esempio n. 14
0
def tile_with_guide_mesh(config):
    options = extract_options(config);
    network = load_wire(str(config["wire_network"]));
    parameters = load_parameters(network, config);
    guide_mesh = pymesh.load_mesh(config["guide_mesh"]);

    tiler = Tiler();
    tiler.set_base_pattern(network);
    tiler.tile_with_guide_mesh(guide_mesh, parameters);
    network = tiler.wire_network;

    if config.get("trim", False):
        network.trim();

    inflator = Inflator(network);
    inflator.inflate(network.get_attribute("thickness").ravel(),
            parameters.per_vertex_thickness);
    return inflator.mesh;
Esempio n. 15
0
def tile_with_guide_box(config):
    options = extract_options(config);
    network = load_wire(str(config["wire_network"]));
    parameters = load_parameters(network, config);
    tiler = Tiler();
    tiler.set_base_pattern(network);
    tiler.tile_with_guide_bbox(
            config["bbox_min"][:network.dim],
            config["bbox_max"][:network.dim],
            config["repeats"][:network.dim],
            parameters);
    network = tiler.wire_network;

    if config.get("trim", False):
        network.trim();

    inflator = Inflator(network);
    inflator.inflate(network.get_attribute("thickness").ravel(),
            parameters.per_vertex_thickness);
    return inflator.mesh;
Esempio n. 16
0
def tile_with_guide_mesh(config):
    options = extract_options(config)
    network = load_wire(str(config["wire_network"]))
    parameters = load_parameters(network, config)
    guide_mesh = pymesh.load_mesh(config["guide_mesh"])

    tiler = Tiler()
    tiler.set_base_pattern(network)
    tiler.tile_with_guide_mesh(guide_mesh, parameters)
    network = tiler.wire_network

    if config.get("trim", False):
        network.trim()
    if "output_wire_network" in config:
        network.write_to_file(config["output_wire_network"])

    inflator = Inflator(network)
    inflator.subdivide_order = options["subdiv"]
    inflator.subdivide_method = options["subdiv_method"]
    inflator.inflate(
        network.get_attribute("thickness").ravel(),
        parameters.per_vertex_thickness)
    return inflator.mesh