artorg-unibe-ch / spline_mesher

Meshing tool for homogenised finite elements based on HR-pQCT images
https://artorg-unibe-ch.github.io/spline_mesher/
MIT License
0 stars 0 forks source link

write docstring #34

Closed github-actions[bot] closed 9 months ago

github-actions[bot] commented 1 year ago

trab_points = [self.model.getValue(0, idx, []) for idx in trab_point_tags]

https://github.com/simoneponcioni/spline-mesher/blob/8963344f902e3b88d03b4f1928642399019be105/src/spline_mesher/gmsh_mesh_builder.py#L488


        return volume_tag

    def query_closest_idx(self, list_1: list, list_2: list):
        """# TODO: write docstring

        Args:
            coi (list): _description_
            array (list): _description_
        """ """"""
        coi_coords = []
        trab_coords = []
        for i, idx in enumerate(list_1):
            coi_coords_s = [self.model.getValue(0, idx, []) for idx in list_1[i]]
            trab_coords_s = [
                self.model.getValue(0, idx, []) for idx in list_2[i]
            ]  # noqa
            coi_coords.append(coi_coords_s)
            trab_coords.append(trab_coords_s)

        # coi_points = [self.model.getValue(0, idx, []) for idx in coi_idx]
        # trab_points = [self.model.getValue(0, idx, []) for idx in trab_point_tags]
        coi_idx_s = np.array(list_1, dtype=int).flatten()
        trab_point_tags_s = np.array(list_2, dtype=int).flatten()
        # for each trab_point_tags, find the closest point in coi_idx with KDTree
        tree = KDTree(np.array(coi_coords).reshape((-1, 3)))
        _, ind = tree.query(np.array(trab_coords).reshape((-1, 3)))
        coi_closest = (coi_idx_s[ind]).reshape((-1, 4))
        trab_idx_closest = trab_point_tags_s.reshape((-1, 4))
        return coi_closest, trab_idx_closest

    def trabecular_cortical_connection(
        self, coi_idx: list[int], trab_point_tags: list[int]
    ):
        """
        # TODO: write docstring

        Args:
            coi_idx (list[int]): _description_
            trab_point_tags (list[int]): _description_
        """
        coi_idx = np.array(coi_idx, dtype=int).tolist()
        trab_point_tags = np.array(trab_point_tags, dtype=int).tolist()

        coi_closest, trab_idx_closest = self.query_closest_idx(coi_idx, trab_point_tags)

        for i, _ in enumerate(coi_closest):
            for j, _ in enumerate(coi_closest[i]):
                # print(f"{coi_closest[i][j]}\t{trab_idx_closest[i][j]}")
                self.factory.addLine(coi_closest[i][j], trab_idx_closest[i][j], tag=-1)

        print("testing")

    def mesh_generate(self, dim):
        gmsh.option.setNumber("Mesh.RecombineAll", 1)
        gmsh.option.setNumber("Mesh.RecombinationAlgorithm", 1)
simoneponcioni commented 9 months ago

Added on https://github.com/artorg-unibe-ch/spline_mesher/commit/42ddda01c96a72adbc9b4bda77b891e98d1536e5