Skip to content

Commit

Permalink
change method ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
true-real-michael committed Nov 4, 2023
1 parent 7665897 commit 669be2a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 63 deletions.
94 changes: 47 additions & 47 deletions octreelib/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,53 +127,6 @@ def filter(self, filtering_criteria: List[Callable[[RawPointCloud], bool]]):
for voxel_coordinates in self.__octrees:
self.__octrees[voxel_coordinates].filter(filtering_criteria)

def n_leaves(self, pose_number: int) -> int:
"""
:param pose_number: Pose number.
:return: Number of leaves in all octrees, which store points for given pose.
"""
return sum(
[
octree.n_leaves_by_pose_number(pose_number)
for octree in self.__octrees.values()
]
)

def n_points(self, pose_number: int) -> int:
"""
:param pose_number: Pose number.
:return: Number of points for given pose.
"""
return sum(
[
octree.n_points_by_pose_number(pose_number)
for octree in self.__octrees.values()
]
)

def n_nodes(self, pose_number: int) -> int:
"""
:param pose_number: Pose number.
:return: Number of nodes in all octrees, which store points for given pose
(either themselves, or through their child nodes).
"""
return sum(
[
octree.n_nodes_by_pose_number(pose_number)
for octree in self.__octrees.values()
]
)

def __get_voxel_for_point(self, point: RawPoint) -> RawPoint:
"""
Method to get coordinates of a voxel where the given point would be stored.
:param point: Point.
:return: Corner of the voxel in the grid, where an appropriate octree for the point resides.
"""
point = point[:3]
grid_voxel_edge_length = self._grid_config.grid_voxel_edge_length
return point // grid_voxel_edge_length * grid_voxel_edge_length

def visualize(self, config: VisualizationConfig) -> None:
"""
Produces `.html` file with Grid
Expand Down Expand Up @@ -233,3 +186,50 @@ def visualize(self, config: VisualizationConfig) -> None:

with open(config.filepath, "w") as f:
f.write(plot.get_snapshot())

def n_leaves(self, pose_number: int) -> int:
"""
:param pose_number: Pose number.
:return: Number of leaves in all octrees, which store points for given pose.
"""
return sum(
[
octree.n_leaves_by_pose_number(pose_number)
for octree in self.__octrees.values()
]
)

def n_points(self, pose_number: int) -> int:
"""
:param pose_number: Pose number.
:return: Number of points for given pose.
"""
return sum(
[
octree.n_points_by_pose_number(pose_number)
for octree in self.__octrees.values()
]
)

def n_nodes(self, pose_number: int) -> int:
"""
:param pose_number: Pose number.
:return: Number of nodes in all octrees, which store points for given pose
(either themselves, or through their child nodes).
"""
return sum(
[
octree.n_nodes_by_pose_number(pose_number)
for octree in self.__octrees.values()
]
)

def __get_voxel_for_point(self, point: RawPoint) -> RawPoint:
"""
Method to get coordinates of a voxel where the given point would be stored.
:param point: Point.
:return: Corner of the voxel in the grid, where an appropriate octree for the point resides.
"""
point = point[:3]
grid_voxel_edge_length = self._grid_config.grid_voxel_edge_length
return point // grid_voxel_edge_length * grid_voxel_edge_length
32 changes: 16 additions & 16 deletions octreelib/grid/grid_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,42 +146,42 @@ def map_leaf_points(self, function: Callable[[RawPointCloud], RawPointCloud]):
pass

@abstractmethod
def n_nodes(self, pose_number: int):
def get_leaf_points(self, pose_number: int) -> List[Voxel]:
"""
:param pose_number: desired pose number.
:return: number of nodes of an octree for given pose number
:param pose_number: the desired pose number
:return: List of voxels. Each voxel is a representation of a leaf node.
Each voxel has the same corner, edge_length and points as one of the leaf nodes.
"""
pass

@abstractmethod
def n_points(self, pose_number: int):
def visualize(self, config: VisualizationConfig) -> None:
"""
:param pose_number: desired pose number.
:return: number of points of an octree for given pose number
Represents method for visualizing Grid. It produces `.html` file using
[k3d](https://github.com/K3D-tools/K3D-jupyter) library
"""
pass

@abstractmethod
def n_leaves(self, pose_number: int):
def n_nodes(self, pose_number: int):
"""
:param pose_number: the desired pose number.
:return: number of leaf nodes in the octree for given pose number
:param pose_number: desired pose number.
:return: number of nodes of an octree for given pose number
"""
pass

@abstractmethod
def get_leaf_points(self, pose_number: int) -> List[Voxel]:
def n_points(self, pose_number: int):
"""
:param pose_number: the desired pose number
:return: List of voxels. Each voxel is a representation of a leaf node.
Each voxel has the same corner, edge_length and points as one of the leaf nodes.
:param pose_number: desired pose number.
:return: number of points of an octree for given pose number
"""
pass

@abstractmethod
def visualize(self, config: VisualizationConfig) -> None:
def n_leaves(self, pose_number: int):
"""
Represents method for visualizing Grid. It produces `.html` file using
[k3d](https://github.com/K3D-tools/K3D-jupyter) library
:param pose_number: the desired pose number.
:return: number of leaf nodes in the octree for given pose number
"""
pass

0 comments on commit 669be2a

Please sign in to comment.