コード例 #1
0
ファイル: test_inflator.py プロジェクト: wroldwiedbwe/PyMesh
    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())
コード例 #2
0
ファイル: microstructure_gen.py プロジェクト: mortezah/PyMesh
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;
コード例 #3
0
ファイル: test_inflator.py プロジェクト: gaoyue17/PyMesh
    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());
コード例 #4
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;
コード例 #5
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())
コード例 #6
0
ファイル: test_tiler.py プロジェクト: gaoyue17/PyMesh
    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());
コード例 #7
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()
    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