Meshpy
meshpy.py: The half-edge mesh data structure
area(self)
Computes the total surface area of the mesh.
This function calculates the total surface area by summing the areas of all faces in the mesh.
The main logic involves:
-
Calling
face_areas
to compute the area of each face. -
Summing the face areas to obtain the total surface area.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
total_area |
float
|
The total surface area of the mesh. |
Note
This function assumes that the mesh is manifold and orientable. The total area is computed based on the current face areas.
See Also
face_areas : Computes the areas of individual faces.
Source code in src/geometry/meshpy.py
are_boundary_edges(self)
Checks if edges are on the boundary of the mesh.
This function returns a boolean array indicating whether each edge is on the boundary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
is_boundary |
numpy array (bool)
|
A boolean array where True indicates that the edge is on the boundary. |
Note
This function assumes that the mesh is manifold and orientable. The boundary edges are useful for mesh analysis and processing.
See Also
boundary_edges : Retrieves the indices of boundary edges.
are_boundary_faces : Checks if faces are on the boundary.
Source code in src/geometry/meshpy.py
are_boundary_faces(self)
Checks if faces are on the boundary of the mesh.
This function returns a boolean array indicating whether each face is on the boundary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
is_boundary |
numpy array (bool)
|
A boolean array where True indicates that the face is on the boundary. |
Note
This function assumes that the mesh is manifold and orientable. The boundary faces are useful for mesh analysis and processing.
See Also
boundary_faces : Retrieves the indices of boundary faces.
are_boundary_edges : Checks if edges are on the boundary.
Source code in src/geometry/meshpy.py
boundary_curves(self, corner_split=False)
Retrieves the boundary curves of the mesh.
This function identifies and returns the boundary curves of the mesh, optionally splitting at corners.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
corner_split
|
(bool, optional(default=False))
|
Whether to split boundary curves at corners. |
False
|
Returns:
Name | Type | Description |
---|---|---|
boundary_curves |
list of numpy arrays
|
A list of boundary curves, where each curve is an array of vertex indices. |
Note
This function assumes that the mesh is manifold and orientable. The boundary curves are useful for mesh analysis and visualization.
See Also
boundary_vertices : Retrieves the indices of boundary vertices.
boundary_edges : Retrieves the indices of boundary edges.
Source code in src/geometry/meshpy.py
boundary_curves_halfedges(self, corner_split=False)
Retrieves the boundary curves of the mesh in terms of half-edges.
This function identifies and returns the boundary curves of the mesh, optionally splitting at corners, represented by half-edges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
corner_split
|
(bool, optional(default=False))
|
Whether to split boundary curves at corners. |
False
|
Returns:
Name | Type | Description |
---|---|---|
boundary_curves |
list of numpy arrays
|
A list of boundary curves, where each curve is an array of half-edge indices. |
Note
This function assumes that the mesh is manifold and orientable. The boundary curves are useful for mesh analysis and processing.
See Also
boundary_curves : Retrieves the boundary curves in terms of vertices.
boundary_halfedges : Retrieves the indices of boundary half-edges.
Source code in src/geometry/meshpy.py
boundary_edges(self)
Retrieves the indices of boundary edges in the mesh.
This function identifies and returns the edges that lie on the boundary of the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
boundary_edges |
numpy array
|
The indices of edges on the boundary. |
Note
This function assumes that the mesh is manifold and orientable. The boundary edges are useful for mesh analysis and processing.
See Also
boundary_vertices : Retrieves the indices of boundary vertices.
boundary_faces : Retrieves the indices of boundary faces.
Source code in src/geometry/meshpy.py
boundary_faces(self)
Retrieves the indices of boundary faces in the mesh.
This function identifies and returns the faces that lie on the boundary of the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
boundary_faces |
numpy array
|
The indices of faces on the boundary. |
Note
This function assumes that the mesh is manifold and orientable. The boundary faces are useful for mesh analysis and processing.
See Also
boundary_vertices : Retrieves the indices of boundary vertices.
boundary_edges : Retrieves the indices of boundary edges.
Source code in src/geometry/meshpy.py
boundary_halfedges(self)
Retrieves the indices of boundary half-edges in the mesh.
This function identifies and returns the half-edges that lie on the boundary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
boundary_halfedges |
numpy array
|
The indices of boundary half-edges. |
Note
This function assumes that the mesh is manifold and orientable. The boundary half-edges are useful for mesh analysis and processing.
See Also
inner_halfedges : Retrieves the indices of inner half-edges.
boundary_edges : Retrieves the indices of boundary edges.
Source code in src/geometry/meshpy.py
boundary_normals(self)
Computes the normal vectors for boundary edges in the mesh.
This function calculates the boundary normals by considering the adjacent faces and edges. For each boundary edge, it computes a normal vector that is perpendicular to the edge and lies in the plane of the adjacent face.
The main logic involves:
-
Identifying boundary edges and their adjacent faces.
-
Computing the cross product of edge vectors and face normals.
-
Normalizing the resulting vectors to obtain unit normals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
normals |
numpy array
|
An array of boundary normals, where each normal is a unit vector [nx, ny, nz]. |
Note
This function assumes that the mesh is manifold and orientable. The boundary normals are computed based on the current mesh topology and geometry.
See Also
boundary_edges : Retrieves the indices of boundary edges.
edge_normals : Computes the normal vectors for each edge.
Source code in src/geometry/meshpy.py
boundary_polylines(self)
Converts the boundary curves of the mesh to polyline objects.
This function creates polyline objects from the boundary curves of the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
polylines |
list of Polyline objects
|
A list of polyline objects representing the boundary curves. |
Note
This function assumes that the mesh is manifold and orientable. The polylines are useful for visualization and further processing.
See Also
boundary_curves : Retrieves the boundary curves in terms of vertices.
Polyline : A class representing a polyline object.
Source code in src/geometry/meshpy.py
boundary_tangents(self, normalize=True)
Computes the tangent vectors for boundary edges in the mesh.
This function calculates the tangent vectors along the boundary edges. The tangents are computed as the direction vectors of the boundary edges.
The main logic involves:
-
Identifying boundary edges.
-
Computing the direction vectors of these edges.
-
Optionally normalizing the tangent vectors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
normalize
|
(bool, optional(default=True))
|
Whether to normalize the tangent vectors to unit length. |
True
|
Returns:
Name | Type | Description |
---|---|---|
tangents |
numpy array
|
An array of boundary tangents, where each tangent is a vector [tx, ty, tz]. |
Note
This function assumes that the mesh is manifold and orientable. The boundary tangents are computed based on the current mesh topology and geometry.
See Also
boundary_edges : Retrieves the indices of boundary edges.
boundary_normals : Computes the normal vectors for boundary edges.
Source code in src/geometry/meshpy.py
boundary_vertices(self)
Retrieves the indices of boundary vertices in the mesh.
This function identifies and returns the vertices that lie on the boundary of the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
boundary_vertices |
numpy array
|
The indices of vertices on the boundary. |
Note
This function assumes that the mesh is manifold and orientable. The boundary vertices are useful for mesh analysis and processing.
See Also
boundary_edges : Retrieves the indices of boundary edges.
boundary_faces : Retrieves the indices of boundary faces.
Source code in src/geometry/meshpy.py
bounding_box(self)
Computes the axis-aligned bounding box of the mesh.
This function calculates the minimum and maximum coordinates of the mesh along each axis (x, y, z).
The main logic involves:
-
Finding the minimum and maximum x, y, and z coordinates of all vertices.
-
Returning the bounding box as a list of ranges for each axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
bbox |
list of tuples
|
The bounding box, represented as [(xmin, xmax), (ymin, ymax), (zmin, zmax)]. |
Note
This function assumes that the mesh vertices are valid and non-empty. The bounding box is computed based on the current vertex positions.
See Also
mesh_center : Computes the geometric center of the mesh.
Source code in src/geometry/meshpy.py
cell_arrays(self)
Converts the mesh faces to a cell array format.
This function returns the faces in a cell array format, where each face is represented by its vertices and a length indicator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
cells |
numpy array
|
The cell array representation of the mesh faces. |
cell_types |
numpy array
|
The types of cells (e.g., triangles, quads). |
Note
This function assumes that the mesh is manifold and orientable. The cell arrays are useful for visualization and further processing.
See Also
faces_list : Retrieves the list of faces.
face_lengths : Computes the number of edges for each face.
Source code in src/geometry/meshpy.py
closest_vertices(self, points, make_tree=False)
Finds the closest vertices in the mesh to a set of query points.
This function uses a k-d tree to efficiently find the closest vertices in the mesh to the given points. If the k-d tree does not exist, it will be constructed automatically.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
numpy array
|
An array of query points [x, y, z]. |
required |
make_tree
|
(bool, optional(default=False))
|
Whether to force the reconstruction of the k-d tree. |
False
|
Returns:
Name | Type | Description |
---|---|---|
closest |
numpy array
|
The indices of the closest vertices in the mesh. |
Note
This function assumes that the mesh vertices are valid and non-empty. The k-d tree is used to accelerate nearest-neighbor queries.
See Also
make_kdtree : Constructs a k-d tree from the mesh vertices.
Source code in src/geometry/meshpy.py
collapse_edge(self, edge_index)
Collapses the specified edge into a single vertex.
This function merges the two vertices of the specified edge into a single vertex. The resulting vertex replaces the original vertices in the mesh topology.
The main logic involves:
-
Identifying the half-edges associated with the edge.
-
Merging the two vertices of the edge into a single vertex.
-
Updating the half-edge structure to maintain mesh consistency.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge_index
|
int
|
The index of the edge to be collapsed. |
required |
Returns:
Name | Type | Description |
---|---|---|
success |
bool
|
Whether the edge collapse was successful. |
Note
This function assumes that the specified edge exists in the mesh. The edge collapse is only performed if it results in a valid mesh topology.
See Also
split_edge : Splits an edge into two edges.
flip_edge : Flips an edge by swapping its adjacent faces.
Source code in src/geometry/meshpy.py
collapse_edges(self, min_length)
Collapses edges in the mesh that are shorter than a specified minimum length.
This function iterates over all edges and collapses those that are shorter than the specified minimum length. The two vertices of each collapsed edge are merged into a single vertex, and the mesh topology is updated accordingly.
The main logic involves:
-
Iterating over all edges and checking their lengths.
-
Collapsing edges that are shorter than the minimum length.
-
Updating the mesh topology with merged vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_length
|
float
|
The minimum allowed length for edges. |
required |
Returns:
Name | Type | Description |
---|---|---|
success |
bool
|
Whether the edge collapse was successful. |
Note
This function assumes that the mesh is a triangular mesh. The mesh topology is updated to ensure all edges are longer than the specified length.
See Also
split_edges : Splits edges that exceed a specified maximum length.
equalize_valences : Balances vertex valences in the mesh.
Source code in src/geometry/meshpy.py
catmull_clark(self, steps=1)
Applies the Catmull-Clark subdivision algorithm to the mesh.
This function refines the mesh by subdividing each face into smaller faces using the Catmull-Clark rules. It works for both triangular and quadrilateral meshes.
The main logic involves:
-
Iterating over each face and its vertices.
-
Computing new vertex positions using the Catmull-Clark weights.
-
Creating new faces and updating the mesh topology.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
steps
|
(int, optional(default=1))
|
The number of subdivision steps to apply. |
1
|
Returns:
Type | Description |
---|---|
None
|
The mesh is updated within the class instance. |
Note
This function assumes that the mesh is manifold and orientable. The Catmull-Clark algorithm is applicable to both triangular and quadrilateral meshes.
See Also
loop : Applies the Loop subdivision algorithm (for triangular meshes).
Source code in src/geometry/meshpy.py
4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 |
|
cut(self, vertex_index)
Cuts the mesh along a boundary edge starting from a specified vertex.
This function modifies the mesh topology by splitting a boundary edge and creating new vertices and half-edges. The cut is performed along the boundary until another boundary vertex is reached.
The main logic involves:
-
Identifying the boundary edge starting from the specified vertex.
-
Iteratively splitting the boundary edge and updating the half-edge structure.
-
Creating new vertices and half-edges to maintain mesh consistency.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vertex_index
|
int
|
The index of the vertex where the cut starts. |
required |
Returns:
Name | Type | Description |
---|---|---|
Hcouple |
numpy array
|
An array of half-edge pairs representing the cut edges. |
Note
This function assumes that the specified vertex is on the boundary of the mesh. The mesh must be manifold and orientable for the cut operation to be valid.
See Also
make_simply_connected : Simplifies the mesh topology by making it simply connected.
Source code in src/geometry/meshpy.py
3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 |
|
delete_edge(self, edge_index)
Deletes a specified edge from the mesh.
This function removes the specified edge and updates the mesh topology. It also removes any half-edges and vertices that are no longer connected.
The main logic involves:
-
Identifying the half-edges associated with the edge to be deleted.
-
Removing the edge and updating the half-edge structure.
-
Cleaning up any unconnected vertices and edges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge_index
|
int
|
The index of the edge to be deleted. |
required |
Returns:
Type | Description |
---|---|
None
|
The mesh is updated within the class instance. |
Note
This function assumes that the specified edge exists in the mesh. The mesh topology is updated to maintain consistency after deletion.
See Also
delete_faces : Deletes specified faces from the mesh.
delete_unconnected_vertices : Removes unconnected vertices from the mesh.
Source code in src/geometry/meshpy.py
delete_faces(self, faces)
Deletes specified faces from the mesh.
This function removes the specified faces and updates the mesh topology. It also removes any half-edges and vertices that are no longer connected.
The main logic involves:
-
Identifying the half-edges and vertices associated with the faces to be deleted.
-
Removing the faces and updating the half-edge structure.
-
Cleaning up any unconnected vertices and edges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
faces
|
int or list of int
|
The indices of the faces to be deleted. |
required |
Returns:
Type | Description |
---|---|
None
|
The mesh is updated within the class instance. |
Note
This function assumes that the specified faces exist in the mesh. The mesh topology is updated to maintain consistency after deletion.
See Also
delete_unconnected_vertices : Removes unconnected vertices from the mesh.
Source code in src/geometry/meshpy.py
delete_unconnected_vertices(self)
Removes unconnected vertices from the mesh.
This function identifies and deletes vertices that are not part of any face. It updates the mesh topology accordingly.
The main logic involves:
-
Identifying vertices that are not referenced by any half-edge.
-
Removing these vertices from the mesh.
-
Updating the vertex indices in the half-edge structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Type | Description |
---|---|
None
|
The mesh is updated within the class instance. |
Note
This function assumes that the mesh is manifold and orientable. The mesh topology is updated to maintain consistency after deletion.
See Also
delete_faces : Deletes specified faces from the mesh.
Source code in src/geometry/meshpy.py
dual_mesh(self, make_boundary=True)
Constructs the dual mesh of the current mesh.
This function creates a new mesh where each face in the original mesh corresponds to a vertex in the dual mesh, and each vertex in the original mesh corresponds to a face in the dual mesh.
The main logic involves:
-
Computing the barycenters of the original faces to define the dual vertices.
-
Creating new faces in the dual mesh based on the original vertex connectivity.
-
Handling boundary cases if
make_boundary
is True.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
make_boundary
|
(bool, optional(default=True))
|
Whether to create boundary faces in the dual mesh. |
True
|
Returns:
Name | Type | Description |
---|---|---|
dual_mesh |
Mesh
|
The dual mesh instance. |
Note
This function assumes that the input mesh is manifold and orientable. The dual mesh is constructed based on the current mesh topology and geometry.
See Also
exploded_mesh : Creates an exploded version of the mesh.
Source code in src/geometry/meshpy.py
4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 |
|
edge(self, halfedge_index=None)
Retrieves the edge associated with a specified half-edge.
This function returns the index of the edge that the specified half-edge belongs to.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
(int, optional(default=None))
|
The index of the half-edge. If None, returns the edge indices for all half-edges. |
None
|
Returns:
Name | Type | Description |
---|---|---|
edge_index |
int or numpy array
|
The index of the edge associated with the specified half-edge, or an array of edge indices for all half-edges. |
Note
This function assumes that the specified half-edge exists in the mesh. The edge index is shared by the specified half-edge and its twin.
See Also
origin : Retrieves the origin vertex of a half-edge.
face : Retrieves the face associated with a half-edge.
twin : Retrieves the twin half-edge.
Source code in src/geometry/meshpy.py
edge_angles(self)
Computes the dihedral angles for each edge in the mesh.
This function calculates the dihedral angle between adjacent faces for each edge. The dihedral angle is the angle between the face normals.
The main logic involves:
-
Iterating over each edge and its adjacent faces.
-
Computing the dot product of the face normals.
-
Calculating the dihedral angle using the arccosine function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
angles |
numpy array
|
An array of dihedral angles for each edge. |
Note
This function assumes that the mesh is manifold and orientable. The dihedral angles are computed based on the current face normals.
See Also
edge_angle_vectors : Computes the angle vectors for each edge.
face_normals : Computes the normal vectors of all faces.
Source code in src/geometry/meshpy.py
edge_cotangents_weigths(self)
Computes the cotangent weights for each edge in the mesh.
This function calculates the cotangent weights based on the angles between adjacent edges. Cotangent weights are commonly used in discrete differential geometry for various computations.
The main logic involves:
-
Iterating over each edge and its adjacent faces.
-
Computing the cotangent of the angles between adjacent edges.
-
Summing the cotangent weights for each edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
cotangent_weights |
numpy array
|
The cotangent weights for each edge. |
Note
This function assumes that the mesh is manifold and orientable. The cotangent weights are computed based on the current mesh topology and geometry.
See Also
mean_curvature_normal : Computes the mean curvature normal using cotangent weights.
Source code in src/geometry/meshpy.py
edge_faces(self)
Retrieves the faces adjacent to each edge in the mesh.
This function returns the indices of the two faces that share each edge. For boundary edges, one of the face indices will be -1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
f1 |
numpy array
|
The indices of the first face adjacent to each edge. |
f2 |
numpy array
|
The indices of the second face adjacent to each edge. |
Note
This function assumes that the mesh is manifold and orientable. The edge faces are useful for local mesh analysis and processing.
See Also
edge_vertices : Retrieves the vertices of each edge.
are_boundary_edges : Checks if edges are on the boundary.
Source code in src/geometry/meshpy.py
edge_lengths(self)
Computes the lengths of all edges in the mesh.
This function calculates the length of each edge using the Euclidean distance between its two vertices.
The main logic involves:
-
Iterating over all edges.
-
Computing the length as the Euclidean distance between the two vertex positions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
lengths |
numpy array
|
An array of edge lengths. |
Note
This function assumes that the mesh edges are valid and non-degenerate. The edge lengths are computed based on the current vertex positions.
See Also
edge_vectors : Computes the direction vectors of all edges.
mean_edge_length : Computes the mean length of all edges.
Source code in src/geometry/meshpy.py
edge_mid_points(self)
Computes the midpoints of all edges in the mesh.
This function calculates the midpoint of each edge by averaging the positions of its two vertices.
The main logic involves:
-
Iterating over all edges.
-
Computing the midpoint as the average of the two vertex positions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
midpoints |
numpy array
|
An array of edge midpoints, where each midpoint is a vector [x, y, z]. |
Note
This function assumes that the mesh edges are valid and non-degenerate. The edge midpoints are computed based on the current vertex positions.
See Also
edge_lengths : Computes the lengths of all edges.
edge_vectors : Computes the direction vectors of all edges.
Source code in src/geometry/meshpy.py
edge_normals(self)
Computes the normal vectors for each edge in the mesh.
This function calculates the edge normals by averaging the face normals of the faces adjacent to each edge. If an edge is on the boundary, its normal is computed based on the single adjacent face.
The main logic involves:
-
Identifying the faces adjacent to each edge.
-
Averaging the face normals of these adjacent faces.
-
Normalizing the resulting vector to obtain the edge normal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
normals |
numpy array
|
An array of edge normals, where each normal is a unit vector [nx, ny, nz]. |
Note
This function assumes that the mesh is manifold and orientable. The edge normals are computed based on the current face normals and mesh topology.
See Also
face_normals : Computes the normal vectors for each face.
vertex_normals : Computes the normal vectors for each vertex.
Source code in src/geometry/meshpy.py
edge_sine_vectors(self)
Computes the sine vectors for each edge in the mesh.
This function calculates the sine vectors by considering the sine of the dihedral angle between adjacent faces. The sine vector is proportional to the cross product of the face normals.
The main logic involves:
-
Iterating over each edge and its adjacent faces.
-
Computing the cross product of the face normals.
-
Normalizing the resulting vector to obtain the sine vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
sine_vectors |
numpy array
|
An array of sine vectors for each edge. |
Note
This function assumes that the mesh is manifold and orientable. The sine vectors are computed based on the current face normals.
See Also
edge_angle_vectors : Computes the angle vectors for each edge.
face_normals : Computes the normal vectors of all faces.
Source code in src/geometry/meshpy.py
edge_vertices(self)
Retrieves the vertices of each edge in the mesh.
This function returns the indices of the two vertices that form each edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
v1 |
numpy array
|
The indices of the first vertex of each edge. |
v2 |
numpy array
|
The indices of the second vertex of each edge. |
Note
This function assumes that the mesh is manifold and orientable. The edge vertices are useful for local mesh analysis and processing.
See Also
edge_faces : Retrieves the faces adjacent to each edge.
edge_lengths : Computes the lengths of all edges.
Source code in src/geometry/meshpy.py
edge_vertices_iterators(self, sort=False)
Iterates over the vertices of each edge.
This function provides iterators for the vertices that form each edge, with an option for sorting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sort
|
(bool, optional(default=False))
|
Whether to sort the vertices by vertex index. |
False
|
Returns:
Name | Type | Description |
---|---|---|
e |
numpy array
|
The indices of the edges. |
vi |
numpy array
|
The indices of the vertices forming each edge. |
Note
This function assumes that the mesh is manifold and orientable. The edge vertices are useful for local mesh analysis and processing.
See Also
edge_faces : Retrieves the faces adjacent to each edge.
Source code in src/geometry/meshpy.py
equalize_valences(self)
Equalizes the valences of vertices in a triangular mesh.
This function attempts to balance the number of edges connected to each vertex by performing local mesh operations such as edge flips, splits, and collapses. The goal is to achieve a more uniform vertex valence distribution.
The main logic involves:
-
Iterating over all edges and checking their valences.
-
Performing edge flips, splits, or collapses to balance valences.
-
Repeating the process until the desired valence distribution is achieved.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
success |
bool
|
Whether the valence equalization was successful. |
Note
This function assumes that the mesh is a triangular mesh. The mesh topology is updated to achieve a more uniform valence distribution.
See Also
split_edges : Splits edges to achieve a desired maximum length.
collapse_edges : Collapses edges to achieve a desired minimum length.
Source code in src/geometry/meshpy.py
4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 |
|
exploded_mesh(self)
Creates an exploded version of the mesh.
This function generates a new mesh where each face is separated from the others, effectively "exploding" the mesh into individual faces.
The main logic involves:
-
Duplicating the vertices for each face.
-
Creating new faces using the duplicated vertices.
-
Constructing the exploded mesh topology.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
exploded_mesh |
Mesh
|
The exploded mesh instance. |
Note
This function assumes that the input mesh is manifold and orientable. The exploded mesh is constructed based on the current mesh topology and geometry.
See Also
dual_mesh : Constructs the dual mesh of the current mesh.
Source code in src/geometry/meshpy.py
face(self, halfedge_index=None)
Retrieves the face associated with a specified half-edge.
This function returns the index of the face that the specified half-edge belongs to.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
(int, optional(default=None))
|
The index of the half-edge. If None, returns the face indices for all half-edges. |
None
|
Returns:
Name | Type | Description |
---|---|---|
face_index |
int or numpy array
|
The index of the face associated with the specified half-edge, or an array of face indices for all half-edges. |
Note
This function assumes that the specified half-edge exists in the mesh. The face index is -1 if the half-edge is on the boundary.
See Also
origin : Retrieves the origin vertex of a half-edge.
next : Retrieves the next half-edge in the face loop.
previous : Retrieves the previous half-edge in the face loop.
Source code in src/geometry/meshpy.py
face_areas(self)
Computes the areas of all faces in the mesh.
This function calculates the area of each face using the cross product of its edge vectors. For triangular faces, the area is half the magnitude of the cross product of two edges.
The main logic involves:
-
Iterating over each face to extract its vertices.
-
Computing the cross product of two edge vectors.
-
Calculating the area as half the magnitude of the cross product.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
areas |
numpy array
|
An array of face areas. |
Note
This function assumes that the mesh faces are planar. The face areas are computed based on the current vertex positions.
See Also
area : Computes the total surface area of the mesh.
face_vector_areas : Computes the vector areas of faces.
Source code in src/geometry/meshpy.py
face_barycenters(self)
Computes the barycenters (geometric centers) of all faces in the mesh.
This function calculates the barycenter of each face by averaging the positions of its vertices.
The main logic involves:
-
Iterating over all faces.
-
Computing the barycenter as the average of the vertex positions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
barycenters |
numpy array
|
An array of face barycenters, where each barycenter is a vector [x, y, z]. |
Note
This function assumes that the mesh faces are valid and non-degenerate. The barycenters are computed based on the current vertex positions.
See Also
face_areas : Computes the areas of all faces.
face_circum_circles : Computes the circumcircles of all faces.
Source code in src/geometry/meshpy.py
face_circum_circles(self)
Computes the circumcircles of all faces in the mesh.
This function calculates the circumcircle of each face by finding the circle that passes through its vertices. For triangular faces, the circumcircle is defined by the three vertices.
The main logic involves:
-
Iterating over all faces.
-
Computing the circumcircle using the vertices of each face.
-
Returning the center and radius of each circumcircle.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
circumcircles |
list of tuples
|
A list of circumcircle information for each face, where each entry is (center_x, center_y, center_z, radius). |
Note
This function assumes that the mesh faces are valid and non-degenerate. The circumcircles are computed based on the current vertex positions.
See Also
face_barycenters : Computes the barycenters of all faces.
face_areas : Computes the areas of all faces.
Source code in src/geometry/meshpy.py
face_edges_iterators(self)
Iterates over the edges in each face.
This function provides iterators for the edges that form each face.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
f |
numpy array
|
The indices of the faces. |
ei |
numpy array
|
The indices of the edges in each face. |
Note
This function assumes that the mesh is manifold and orientable. The face edges are useful for local mesh analysis and processing.
See Also
face_vertices_iterators : Iterates over vertices in each face.
face_edge_vertices_iterators : Iterates over vertices of edges in each face.
Source code in src/geometry/meshpy.py
face_lengths(self)
Computes the number of edges (length) for each face in the mesh.
This function returns the number of edges for each face, which is equivalent to the number of vertices forming the face.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
face_lengths |
numpy array
|
The number of edges for each face. |
Note
This function assumes that the mesh is manifold and orientable. The face lengths are useful for mesh analysis and processing.
See Also
faces_list : Retrieves the list of faces.
face_vertices_iterators : Iterates over vertices of each face.
Source code in src/geometry/meshpy.py
face_normals(self)
Computes the normal vectors for each face in the mesh.
This function calculates the face normals by taking the cross product of two edges of each face and normalizing the resulting vector.
The main logic involves:
-
Iterating over each face to extract its vertices.
-
Computing the cross product of two edges to obtain the normal vector.
-
Normalizing the normal vector to ensure unit length.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
normals |
numpy array
|
An array of face normals, where each normal is a unit vector [nx, ny, nz]. |
Note
This function assumes that the mesh faces are planar and that the half-edge structure is correctly defined. The normals are computed based on the current vertex positions.
See Also
vertex_normals : Computes the normal vectors for each vertex.
edge_normals : Computes the normal vectors for each edge.
Source code in src/geometry/meshpy.py
face_ordered_halfedges(self)
Retrieves the half-edges in each face, ordered by traversal.
This function returns the indices of half-edges that form each face, ordered in a consistent traversal direction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
ordered_halfedges |
numpy array
|
The indices of half-edges in each face, ordered by traversal. |
Note
This function assumes that the mesh is manifold and orientable. The half-edges are ordered to facilitate consistent traversal around each face.
See Also
face_vertices_iterators : Iterates over vertices in each face.
Source code in src/geometry/meshpy.py
face_planarity(self, scale_invariant=True)
Computes the planarity of each face in the mesh.
This function calculates the planarity of each face by measuring the deviation from a perfect plane. The planarity can be computed as either absolute or scale-invariant.
The main logic involves:
-
Iterating over all faces.
-
Computing the deviation from planarity using the cross product of edge vectors.
-
Normalizing the deviation if scale-invariant planarity is requested.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale_invariant
|
(bool, optional(default=True))
|
Whether to compute scale-invariant planarity. |
True
|
Returns:
Name | Type | Description |
---|---|---|
planarity |
numpy array
|
An array of face planarity values. |
Note
This function assumes that the mesh faces are valid and non-degenerate. The planarity is computed based on the current vertex positions.
See Also
face_areas : Computes the areas of all faces.
face_normals : Computes the normal vectors of all faces.
Source code in src/geometry/meshpy.py
2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 |
|
face_triangles(self)
Decomposes each face into triangles.
This function splits each face of the mesh into triangles, which is useful for rendering or further processing. The resulting triangles are returned along with their corresponding face indices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
triangles |
numpy array
|
An array of triangles, where each triangle is represented by three vertex indices. |
face_indices |
numpy array
|
The indices of the original faces that each triangle belongs to. |
Note
This function assumes that the mesh is manifold and orientable. The decomposition is useful for rendering or further processing.
See Also
faces_list : Retrieves the list of faces.
face_lengths : Computes the number of edges for each face.
Source code in src/geometry/meshpy.py
face_vector_areas(self)
Computes the vector areas of all faces in the mesh.
This function calculates the vector area of each face, which is the cross product of two edge vectors scaled by half. The vector area is a vector perpendicular to the face with a magnitude equal to the face area.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
vector_areas |
numpy array
|
An array of vector areas for each face. |
Note
This function assumes that the mesh faces are planar. The vector areas are computed based on the current vertex positions.
See Also
face_areas : Computes the scalar areas of all faces.
face_normals : Computes the normal vectors of all faces.
Source code in src/geometry/meshpy.py
face_vertices_iterators(self)
Iterates over the vertices in each face.
This function provides iterators for the vertices that form each face.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
f |
numpy array
|
The indices of the faces. |
vi |
numpy array
|
The indices of the vertices in each face. |
Note
This function assumes that the mesh is manifold and orientable. The face vertices are useful for local mesh analysis and processing.
See Also
face_edge_vertices_iterators : Iterates over vertices of edges in each face.
face_edges_iterators : Iterates over edges in each face.
Source code in src/geometry/meshpy.py
flip_edge(self, edge_index)
Flips the specified edge in the mesh.
This function reverses the direction of the specified edge by swapping its adjacent faces. This operation is useful for optimizing mesh quality.
The main logic involves:
-
Identifying the half-edges associated with the edge.
-
Swapping the adjacent faces of the edge.
-
Updating the half-edge structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge_index
|
int
|
The index of the edge to be flipped. |
required |
Returns:
Name | Type | Description |
---|---|---|
success |
bool
|
Whether the edge flip was successful. |
Note
This function assumes that the specified edge exists in the mesh. The edge flip is only performed if it results in a valid mesh topology.
See Also
split_edge : Splits an edge into two edges.
collapse_edge : Collapses an edge into a single vertex.
Source code in src/geometry/meshpy.py
flip_normals(self)
Flips the normals of the mesh by reversing the half-edge orientation.
This function inverts the direction of all face normals by swapping the orientation of the half-edges. This effectively reverses the winding order of the faces.
The main logic involves:
-
Iterating over all half-edges.
-
Swapping the origin and destination vertices of each half-edge.
-
Updating the face normals accordingly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Type | Description |
---|---|
None
|
The mesh normals are updated in place. |
Note
This function assumes that the mesh is manifold and orientable. The normals are flipped based on the current half-edge structure.
See Also
face_normals : Computes the normal vectors of all faces.
vertex_normals : Computes the normal vectors of all vertices.
Source code in src/geometry/meshpy.py
halfedge_face_vertices(self, halfedge_index)
Retrieves the vertices of the face associated with a specified half-edge.
This function returns the sequence of vertices that form the face associated with the specified half-edge. The vertices are returned in the order they appear around the face.
The main logic involves:
-
Starting from the specified half-edge.
-
Iteratively following the next half-edge in the face loop to collect vertices.
-
Returning the sequence of vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
int
|
The index of the half-edge. |
required |
Returns:
Name | Type | Description |
---|---|---|
face_vertices |
list of int
|
The indices of vertices forming the face. |
Note
This function assumes that the specified half-edge exists in the mesh. The vertices are returned in the order they appear around the face.
See Also
halfedge_ring_vertices : Retrieves the vertices in the half-edge ring.
face_vertices_iterators : Iterates over vertices of all faces.
Source code in src/geometry/meshpy.py
halfedge_length(self, halfedge_index)
Computes the length of a specified half-edge.
This function calculates the Euclidean distance between the origin and destination vertices of the specified half-edge.
The main logic involves:
-
Retrieving the origin and destination vertices of the half-edge.
-
Computing the Euclidean distance between the two vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
int
|
The index of the half-edge. |
required |
Returns:
Name | Type | Description |
---|---|---|
length |
float
|
The length of the specified half-edge. |
Note
This function assumes that the specified half-edge exists in the mesh. The length is computed based on the current vertex positions.
See Also
edge_lengths : Computes the lengths of all edges in the mesh.
Source code in src/geometry/meshpy.py
halfedge_ring(self, halfedge_index)
Retrieves the half-edge ring around a specified half-edge.
This function returns the sequence of half-edges that form a loop around the specified half-edge. The half-edge ring can be used to traverse the mesh topology.
The main logic involves:
-
Starting from the specified half-edge.
-
Iteratively following the next half-edge in the loop until the starting half-edge is reached.
-
Returning the sequence of half-edges in the loop.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
int
|
The index of the starting half-edge. |
required |
Returns:
Name | Type | Description |
---|---|---|
ring |
list of int
|
The indices of half-edges in the half-edge ring. |
Note
This function assumes that the specified half-edge exists in the mesh. The half-edge ring can be used for further mesh traversal and manipulation.
See Also
vertex_halfedge : Retrieves a half-edge originating from a specified vertex.
halfedge_ring_vertices : Retrieves the vertices in the half-edge ring.
Source code in src/geometry/meshpy.py
halfedge_ring_faces(self, halfedge_index)
Retrieves the faces adjacent to the half-edge ring of a specified half-edge.
This function returns the sequence of faces that are adjacent to the half-edge ring starting from the specified half-edge. The faces are returned in the order they appear around the ring.
The main logic involves:
-
Starting from the specified half-edge.
-
Iteratively following the next half-edge in the ring to collect adjacent faces.
-
Returning the sequence of faces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
int
|
The index of the starting half-edge. |
required |
Returns:
Name | Type | Description |
---|---|---|
ring_faces |
list of int
|
The indices of faces adjacent to the half-edge ring. |
Note
This function assumes that the specified half-edge exists in the mesh. The faces are returned in the order they appear around the ring.
See Also
halfedge_ring : Retrieves the half-edge ring around a specified half-edge.
face_vertices_iterators : Iterates over vertices of all faces.
Source code in src/geometry/meshpy.py
halfedge_ring_vertices(self, halfedge_index)
Retrieves the vertices in the half-edge ring around a specified half-edge.
This function returns the sequence of vertices that form the half-edge ring starting from the specified half-edge. The vertices are returned in the order they appear around the ring.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
int
|
The index of the starting half-edge. |
required |
Returns:
Name | Type | Description |
---|---|---|
vertices |
list of int
|
The indices of vertices in the half-edge ring. |
Note
This function assumes that the specified half-edge exists in the mesh. The half-edge ring vertices are useful for local mesh analysis and processing.
See Also
halfedge_ring : Retrieves the half-edge ring around a specified half-edge.
vertex_ring_vertices_iterators : Iterates over vertices in the vertex ring.
Source code in src/geometry/meshpy.py
inner_halfedges(self)
Retrieves the indices of inner half-edges in the mesh.
This function identifies and returns the half-edges that are not on the boundary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
inner_halfedges |
numpy array
|
The indices of inner half-edges. |
Note
This function assumes that the mesh is manifold and orientable. The inner half-edges are useful for mesh analysis and processing.
See Also
boundary_halfedges : Retrieves the indices of boundary half-edges.
Source code in src/geometry/meshpy.py
inner_vertices(self)
Retrieves the indices of inner vertices in the mesh.
This function identifies and returns the vertices that are not on the boundary of the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
inner_vertices |
numpy array
|
The indices of vertices that are not on the boundary. |
Note
This function assumes that the mesh is manifold and orientable. The inner vertices are useful for mesh analysis and processing.
See Also
boundary_vertices : Retrieves the indices of boundary vertices.
Source code in src/geometry/meshpy.py
is_boundary_halfedge_ring(self, ring)
Checks if a half-edge ring is on the boundary of the mesh.
This function verifies whether the specified half-edge ring is part of the mesh boundary. It returns True if the ring is on the boundary, False otherwise.
The main logic involves:
-
Iterating over the half-edge ring.
-
Checking if any half-edge in the ring is a boundary half-edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ring
|
list of int
|
The indices of half-edges in the ring. |
required |
Returns:
Name | Type | Description |
---|---|---|
is_boundary |
bool
|
Whether the half-edge ring is on the boundary. |
Note
This function assumes that the mesh is manifold and orientable. The check is based on the current mesh topology and half-edge definitions.
See Also
is_halfedge_bounding_tri_faces : Checks if a half-edge bounds triangular faces.
Source code in src/geometry/meshpy.py
is_halfedge_bounding_tri_faces(self, halfedge_index)
Checks if a specified half-edge bounds triangular faces.
This function verifies whether the specified half-edge is part of a triangular face or a boundary edge. It returns True if the half-edge bounds triangular faces, False otherwise.
The main logic involves:
-
Checking the face associated with the half-edge.
-
Verifying if the face is triangular or a boundary face.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
int
|
The index of the half-edge. |
required |
Returns:
Name | Type | Description |
---|---|---|
is_bounding |
bool
|
Whether the half-edge bounds triangular faces. |
Note
This function assumes that the mesh is manifold and orientable. The check is based on the current mesh topology and face definitions.
See Also
is_boundary_halfedge_ring : Checks if a half-edge ring is on the boundary.
Source code in src/geometry/meshpy.py
is_triangular_mesh(self)
Checks if the mesh is a triangular mesh.
This function verifies whether all faces in the mesh are triangles.
The main logic involves:
-
Iterating over all faces.
-
Checking the number of vertices per face.
-
Returning True if all faces are triangles, otherwise False.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
is_triangular |
bool
|
Whether the mesh is a triangular mesh. |
Note
This function assumes that the mesh is manifold and orientable. The check is based on the current mesh topology.
See Also
loop : Applies the Loop subdivision algorithm (requires a triangular mesh).
Source code in src/geometry/meshpy.py
loop(self, steps=1)
Applies the Loop subdivision algorithm to the mesh.
This function refines the mesh by subdividing each triangle into four smaller triangles. The new vertices are positioned based on the Loop subdivision rules.
The main logic involves:
-
Identifying the vertices and edges of each triangle.
-
Computing the new vertex positions using the Loop subdivision weights.
-
Creating new faces and updating the mesh topology.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
steps
|
(int, optional(default=1))
|
The number of subdivision steps to apply. |
1
|
Returns:
Type | Description |
---|---|
None
|
The mesh is updated within the class instance. |
Note
This function assumes that the mesh is triangular and manifold. The Loop subdivision algorithm is only applicable to triangular meshes.
See Also
catmull_clark : Applies the Catmull-Clark subdivision algorithm.
Source code in src/geometry/meshpy.py
4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 |
|
make_kdtree(self)
Constructs a k-d tree from the mesh vertices for efficient nearest-neighbor queries.
This function creates a k-d tree data structure using the vertex positions, allowing for fast nearest-neighbor searches.
The main logic involves:
-
Creating a k-d tree from the vertex positions.
-
Storing the k-d tree within the mesh instance for later use.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Type | Description |
---|---|
None
|
The k-d tree is stored within the mesh instance. |
Note
This function assumes that the mesh vertices are valid and non-empty. The k-d tree is used to accelerate nearest-neighbor queries.
See Also
closest_vertices : Finds the closest vertices to a set of query points.
Source code in src/geometry/meshpy.py
make_mesh(self, vertices_list, faces_list)
Constructs a half-edge mesh data structure from a list of vertices and faces.
This function initializes the half-edge mesh by creating the necessary data structures, including half-edges, vertices, and faces. It ensures that the mesh is manifold and orientable, and it reorients the mesh if necessary.
The main logic involves:
-
Creating half-edges from the input vertices and faces.
-
Establishing relationships between half-edges, vertices, and faces.
-
Handling boundary edges and faces.
-
Reorienting the mesh if it is not initially orientable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vertices_list
|
list of lists
|
A list of vertex coordinates, where each vertex is represented as [x, y, z]. |
required |
faces_list
|
list of lists
|
A list of faces, where each face is represented as a list of vertex indices. |
required |
Returns:
Type | Description |
---|---|
None
|
The mesh is constructed within the class instance. |
Raises:
Type | Description |
---|---|
ValueError
|
If the mesh is not manifold and orientable. |
Note
This function assumes that the input vertices and faces form a valid mesh. The mesh must be manifold and orientable for the half-edge structure to be correctly defined.
See Also
read_obj_file : Reads mesh data from an OBJ file.
Source code in src/geometry/meshpy.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
make_obj_file(self, file_name, overwrite=False)
Writes the mesh data to an OBJ file.
This function exports the mesh vertices and faces to an OBJ file, which can be used for visualization or further processing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name
|
str
|
The path to the OBJ file. |
required |
overwrite
|
(bool, optional(default=False))
|
Whether to overwrite the file if it already exists. |
False
|
Returns:
Name | Type | Description |
---|---|---|
file_path |
str
|
The path to the created OBJ file (without the extension). |
Note
This function assumes that the mesh data is valid and manifold. The OBJ file format is widely supported for 3D visualization and modeling.
See Also
read_obj_file : Reads mesh data from an OBJ file.
Source code in src/geometry/meshpy.py
make_simply_connected(self)
Modifies the mesh to make it simply connected by removing boundary loops.
This function cuts the mesh along boundary edges to eliminate multiple boundary loops, resulting in a simply connected mesh.
The main logic involves:
-
Identifying all boundary loops in the mesh.
-
Cutting the mesh along boundary edges to merge boundary loops.
-
Reconstructing the mesh topology after cutting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Type | Description |
---|---|
None
|
The mesh topology is updated in place. |
Note
This function assumes that the mesh is manifold and orientable. The resulting mesh will have a single boundary loop.
See Also
boundary_curves : Retrieves the boundary loops of the mesh.
cut : Cuts the mesh along a specified boundary edge.
Source code in src/geometry/meshpy.py
mesh_center(self)
Computes the geometric center of the mesh.
This function calculates the center of the mesh by averaging the coordinates of its bounding box.
The main logic involves:
-
Calling
bounding_box
to compute the axis-aligned bounding box. -
Computing the center as the midpoint of each axis range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
center |
numpy array
|
The geometric center of the mesh, represented as [x, y, z]. |
Note
This function assumes that the mesh vertices are valid and non-empty. The center is computed based on the current bounding box.
See Also
bounding_box : Computes the axis-aligned bounding box of the mesh.
Source code in src/geometry/meshpy.py
mesh_corners(self)
Identifies the corner vertices of the mesh.
This function detects and returns the vertices that are considered corners based on the angle between adjacent edges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
corners |
numpy array
|
The indices of corner vertices. |
Note
This function assumes that the mesh is manifold and orientable. The corner vertices are useful for mesh analysis and processing.
See Also
boundary_curves : Retrieves the boundary curves in terms of vertices.
boundary_curves_halfedges : Retrieves the boundary curves in terms of half-edges.
Source code in src/geometry/meshpy.py
mesh_curves(self)
Extracts the curves from the mesh, including boundary and internal curves.
This function identifies and extracts curves from the mesh by following edges and vertices. The curves can be used for analysis or visualization.
The main logic involves:
-
Identifying boundary and internal edges.
-
Following edges to form continuous curves.
-
Returning the extracted curves as lists of vertex indices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
curves |
list of lists
|
A list of curves, where each curve is represented by a list of vertex indices. |
Note
This function assumes that the mesh is manifold and orientable. The curves are extracted based on the current mesh topology.
See Also
boundary_curves : Retrieves the boundary loops of the mesh.
mesh_polylines : Converts curves to polyline objects.
Source code in src/geometry/meshpy.py
3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 |
|
mesh_polylines(self)
Converts the mesh curves to polyline objects for visualization.
This function takes the extracted curves from the mesh and converts them into polyline objects, which can be used for visualization or further processing.
The main logic involves:
-
Calling
mesh_curves
to extract the curves from the mesh. -
Converting each curve to a polyline object using vertex positions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
polylines |
list of Polyline objects
|
A list of polyline objects representing the mesh curves. |
Note
This function assumes that the mesh curves are valid and non-degenerate. The polylines are created based on the current vertex positions.
See Also
mesh_curves : Extracts the curves from the mesh.
Polyline : A class representing a polyline object.
Source code in src/geometry/meshpy.py
move(self, displacement_vector)
Translates the mesh by a specified displacement vector.
This function moves the entire mesh by adding the displacement vector to each vertex position.
The main logic involves:
-
Adding the displacement vector to each vertex coordinate.
-
Updating the vertex positions in place.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
displacement_vector
|
list or numpy array
|
The displacement vector [dx, dy, dz] to apply to the mesh. |
required |
Returns:
Type | Description |
---|---|
None
|
The mesh vertices are updated in place. |
Note
This function assumes that the displacement vector is valid. The mesh is translated based on the current vertex positions.
See Also
scale : Scales the mesh by a specified factor.
Source code in src/geometry/meshpy.py
next(self, halfedge_index=None)
Retrieves the next half-edge in the face loop.
This function returns the index of the next half-edge in the face loop starting from the specified half-edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
(int, optional(default=None))
|
The index of the half-edge. If None, returns the next half-edges for all half-edges. |
None
|
Returns:
Name | Type | Description |
---|---|---|
next_halfedge |
int or numpy array
|
The index of the next half-edge in the face loop, or an array of next half-edges for all half-edges. |
Note
This function assumes that the specified half-edge exists in the mesh. The next half-edge is part of the same face as the specified half-edge.
See Also
previous : Retrieves the previous half-edge in the face loop.
origin : Retrieves the origin vertex of a half-edge.
face : Retrieves the face associated with a half-edge.
Source code in src/geometry/meshpy.py
orient_faces(self, vertices_list, faces_list)
Reorients the faces of the mesh to ensure consistent winding order.
This function processes the input vertices and faces to ensure that all faces have a consistent orientation. This is necessary for creating a valid half-edge structure.
The main logic involves:
-
Iterating over all faces and checking their orientation.
-
Reversing the vertex order of any face with inconsistent orientation.
-
Returning the reoriented face list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vertices_list
|
list of lists
|
The list of vertex coordinates [x, y, z]. |
required |
faces_list
|
list of lists
|
The list of faces, where each face is defined by vertex indices. |
required |
Returns:
Name | Type | Description |
---|---|---|
oriented_faces |
list of lists
|
The reoriented face list with consistent winding order. |
Note
This function assumes that the input mesh is manifold and orientable. The reoriented faces are necessary for constructing a valid half-edge structure.
See Also
make_mesh : Constructs the half-edge mesh from vertices and faces.
Source code in src/geometry/meshpy.py
2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 |
|
origin(self, halfedge_index=None)
Retrieves the origin vertex of a specified half-edge.
This function returns the index of the vertex where the specified half-edge originates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
(int, optional(default=None))
|
The index of the half-edge. If None, returns the origin vertices for all half-edges. |
None
|
Returns:
Name | Type | Description |
---|---|---|
origin_vertex |
int or numpy array
|
The index of the origin vertex for the specified half-edge, or an array of origin vertices for all half-edges. |
Note
This function assumes that the specified half-edge exists in the mesh. The origin vertex is the starting vertex of the half-edge.
See Also
next : Retrieves the next half-edge in the face loop.
previous : Retrieves the previous half-edge in the face loop.
twin : Retrieves the twin half-edge.
Source code in src/geometry/meshpy.py
previous(self, halfedge_index=None)
Retrieves the previous half-edge in the face loop.
This function returns the index of the previous half-edge in the face loop starting from the specified half-edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
(int, optional(default=None))
|
The index of the half-edge. If None, returns the previous half-edges for all half-edges. |
None
|
Returns:
Name | Type | Description |
---|---|---|
previous_halfedge |
int or numpy array
|
The index of the previous half-edge in the face loop, or an array of previous half-edges for all half-edges. |
Note
This function assumes that the specified half-edge exists in the mesh. The previous half-edge is part of the same face as the specified half-edge.
See Also
next : Retrieves the next half-edge in the face loop.
origin : Retrieves the origin vertex of a half-edge.
face : Retrieves the face associated with a half-edge.
Source code in src/geometry/meshpy.py
principal_curvatures(self, area_normalization=False, use_sine=False)
Computes the principal curvatures and directions for each vertex in the mesh.
This function calculates the principal curvatures and their corresponding directions by analyzing the extended shape operator at each vertex.
The main logic involves:
-
Computing the extended shape operator for each vertex.
-
Diagonalizing the shape operator to obtain the principal curvatures and directions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
area_normalization
|
(bool, optional(default=False))
|
Whether to normalize the shape operator by the vertex area. |
False
|
use_sine
|
(bool, optional(default=False))
|
Whether to use sine vectors instead of angle vectors. |
False
|
Returns:
Name | Type | Description |
---|---|---|
k1 |
numpy array
|
The first principal curvature at each vertex. |
k2 |
numpy array
|
The second principal curvature at each vertex. |
D1 |
numpy array
|
The direction of the first principal curvature. |
D2 |
numpy array
|
The direction of the second principal curvature. |
Note
This function assumes that the mesh is manifold and orientable. The principal curvatures are computed based on the current mesh geometry and topology.
See Also
extended_shape_operator : Computes the extended shape operator for each vertex.
gaussian_curvature : Computes the Gaussian curvature from principal curvatures.
mean_curvature : Computes the mean curvature from principal curvatures.
Source code in src/geometry/meshpy.py
3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 |
|
read_obj_file(self, file_name)
Reads mesh data from an OBJ file and constructs the half-edge mesh.
This function parses the OBJ file to extract vertices and faces, and then calls
the make_mesh
method to construct the half-edge mesh data structure.
The main logic involves:
-
Reading the OBJ file line by line to extract vertex and face information.
-
Handling different formats of face definitions (e.g., with or without texture coordinates).
-
Calling
make_mesh
to construct the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name
|
str
|
The path to the OBJ file. |
required |
Returns:
Type | Description |
---|---|
None
|
The mesh is constructed within the class instance. |
Note
This function assumes that the OBJ file is correctly formatted and contains valid mesh data. The mesh must be manifold and orientable for the half-edge structure to be correctly defined.
See Also
make_mesh : Constructs the half-edge mesh from vertices and faces.
make_obj_file : Writes the mesh data to an OBJ file.
Source code in src/geometry/meshpy.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
|
scale(self, factor, center=[0, 0, 0])
Scales the mesh by a specified factor relative to a center point.
This function scales the mesh by multiplying each vertex position by the specified factor, relative to a given center point.
The main logic involves:
-
Translating the mesh to the origin by subtracting the center point.
-
Scaling the mesh by the specified factor.
-
Translating the mesh back to the original center point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
factor
|
float
|
The scaling factor to apply to the mesh. |
required |
center
|
list or numpy array, optional (default=[0, 0, 0])
|
The center point relative to which the mesh is scaled. |
[0, 0, 0]
|
Returns:
Type | Description |
---|---|
None
|
The mesh vertices are updated in place. |
Note
This function assumes that the scaling factor is non-zero. The mesh is scaled based on the current vertex positions.
See Also
move : Translates the mesh by a specified displacement vector.
Source code in src/geometry/meshpy.py
split_edges(self, max_length)
Splits edges in the mesh that exceed a specified maximum length.
This function iterates over all edges and splits those that are longer than the specified maximum length. New vertices are inserted at the midpoints of these edges, and the mesh topology is updated accordingly.
The main logic involves:
-
Iterating over all edges and checking their lengths.
-
Splitting edges that exceed the maximum length.
-
Updating the mesh topology with new vertices and edges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_length
|
float
|
The maximum allowed length for edges. |
required |
Returns:
Name | Type | Description |
---|---|---|
success |
bool
|
Whether the edge splitting was successful. |
Note
This function assumes that the mesh is a triangular mesh. The mesh topology is updated to ensure all edges are within the specified length.
See Also
collapse_edges : Collapses edges that are shorter than a specified minimum length.
equalize_valences : Balances vertex valences in the mesh.
Source code in src/geometry/meshpy.py
split_edge(self, edge_index)
Splits the specified edge into two edges by inserting a new vertex.
This function subdivides the specified edge by adding a new vertex at its midpoint. The new vertex is connected to the original vertices of the edge.
The main logic involves:
-
Identifying the half-edges associated with the edge.
-
Inserting a new vertex at the midpoint of the edge.
-
Creating new half-edges and updating the mesh topology.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge_index
|
int
|
The index of the edge to be split. |
required |
Returns:
Name | Type | Description |
---|---|---|
success |
bool
|
Whether the edge split was successful. |
Note
This function assumes that the specified edge exists in the mesh. The edge split is only performed if it results in a valid mesh topology.
See Also
flip_edge : Flips an edge by swapping its adjacent faces.
collapse_edge : Collapses an edge into a single vertex.
Source code in src/geometry/meshpy.py
twin(self, halfedge_index=None)
Retrieves the twin half-edge of a specified half-edge.
This function returns the index of the twin half-edge, which is the counterpart of the specified half-edge across the shared edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
halfedge_index
|
(int, optional(default=None))
|
The index of the half-edge. If None, returns the twin half-edges for all half-edges. |
None
|
Returns:
Name | Type | Description |
---|---|---|
twin_halfedge |
int or numpy array
|
The index of the twin half-edge, or an array of twin half-edges for all half-edges. |
Note
This function assumes that the specified half-edge exists in the mesh. The twin half-edge is part of the same edge as the specified half-edge but belongs to a different face.
See Also
origin : Retrieves the origin vertex of a half-edge.
face : Retrieves the face associated with a half-edge.
Source code in src/geometry/meshpy.py
vertex_double_ring_vertices_iterators(self)
Iterates over the vertices in the double ring around each vertex.
This function provides iterators for the vertices in the double ring around each vertex, which includes the vertex ring and the vertices adjacent to it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
v |
numpy array
|
The indices of the central vertices. |
vj |
numpy array
|
The indices of the vertices in the double ring. |
Note
This function assumes that the mesh is manifold and orientable. The double ring vertices are useful for local mesh analysis and processing.
See Also
vertex_ring_vertices_iterators : Iterates over vertices in the vertex ring.
Source code in src/geometry/meshpy.py
vertex_double_ring_vertices_list(self)
Returns a list of double rings for each vertex.
This function constructs a list where each entry corresponds to a vertex and contains the indices of vertices in its double ring.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
ring_list |
list of lists
|
A list where each entry is a list of vertex indices in the double ring. |
Note
This function assumes that the mesh is manifold and orientable. The double ring vertices are useful for local mesh analysis and processing.
See Also
vertex_double_ring_vertices_iterators : Iterates over vertices in the double ring.
vertex_ring_vertices_list : Returns a list of vertex rings for each vertex.
Source code in src/geometry/meshpy.py
vertex_halfedge(self, vertex_index)
Retrieves a half-edge originating from a specified vertex.
This function returns one of the half-edges that starts at the specified vertex. The returned half-edge can be used to traverse the mesh topology.
The main logic involves:
-
Searching for a half-edge that originates from the specified vertex.
-
Returning the index of the found half-edge.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vertex_index
|
int
|
The index of the vertex. |
required |
Returns:
Name | Type | Description |
---|---|---|
halfedge_index |
int
|
The index of a half-edge originating from the specified vertex. |
Note
This function assumes that the specified vertex exists in the mesh. The returned half-edge can be used for further mesh traversal and manipulation.
See Also
halfedge_ring : Retrieves the half-edge ring around a specified half-edge.
vertex_ring_vertices : Retrieves the vertices in the vertex ring around a specified vertex.
Source code in src/geometry/meshpy.py
vertex_local_frame(self)
Computes a local coordinate frame (origin, x, y, z) for each vertex.
This function assigns a local frame to each vertex, where: - The origin is the vertex position. - The z-axis is aligned with the vertex normal. - The x and y axes are orthogonal to the z-axis and each other.
The main logic involves:
-
Computing the vertex normals.
-
Finding orthogonal vectors to the vertex normals.
-
Constructing the local frames.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
frame |
Frame object
|
A Frame object containing the local frames for each vertex. |
Note
This function assumes that the mesh is manifold and orientable. The local frames are computed based on the current vertex positions and normals.
See Also
vertex_normals : Computes the normal vectors of all vertices.
Frame : A class representing a local coordinate frame.
Source code in src/geometry/meshpy.py
vertex_normals(self)
Computes the normal vectors for each vertex in the mesh.
This function calculates the vertex normals by averaging the face normals of the faces adjacent to each vertex. The resulting normals are normalized to ensure they are unit vectors.
The main logic involves:
-
Iterating over each vertex to identify its adjacent faces.
-
Summing the face normals of these adjacent faces.
-
Normalizing the summed vector to obtain the vertex normal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
normals |
numpy array
|
An array of vertex normals, where each normal is a unit vector [nx, ny, nz]. |
Note
This function assumes that the mesh is manifold and orientable. The vertex normals are computed based on the current face normals and mesh topology.
See Also
face_normals : Computes the normal vectors for each face.
edge_normals : Computes the normal vectors for each edge.
Source code in src/geometry/meshpy.py
vertex_ring_edges_iterators(self, sort=False, order=False)
Iterates over the edges in the vertex ring around each vertex.
This function provides iterators for the edges in the vertex ring around each vertex, with options for sorting and ordering.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sort
|
(bool, optional(default=False))
|
Whether to sort the edges by edge index. |
False
|
order
|
(bool, optional(default=False))
|
Whether to order the edges by traversal direction. |
False
|
Returns:
Name | Type | Description |
---|---|---|
v |
numpy array
|
The indices of the central vertices. |
ej |
numpy array
|
The indices of the adjacent edges in the vertex ring. |
Note
This function assumes that the mesh is manifold and orientable. The vertex ring edges are useful for local mesh analysis and processing.
See Also
vertex_ring_vertices_iterators : Iterates over vertices in the vertex ring.
vertex_ring_faces_iterators : Iterates over faces in the vertex ring.
Source code in src/geometry/meshpy.py
vertex_ring_edges_list(self)
Returns a list of edges in the vertex ring for each vertex.
This function constructs a list where each entry corresponds to a vertex and contains the indices of edges in its vertex ring.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
ring_list |
list of lists
|
A list where each entry is a list of edge indices in the vertex ring. |
Note
This function assumes that the mesh is manifold and orientable. The vertex ring edges are useful for local mesh analysis and processing.
See Also
vertex_ring_edges_iterators : Iterates over edges in the vertex ring.
vertex_ring_vertices_list : Returns a list of vertex rings for each vertex.
Source code in src/geometry/meshpy.py
vertex_ring_expansion(self, v_index, callback=None, depth=None)
Expands the vertex ring around a specified vertex up to a given depth.
This function performs a breadth-first traversal of the mesh starting from the specified vertex and collects all vertices within the given depth.
The main logic involves:
-
Initializing the traversal from the specified vertex.
-
Iteratively expanding the vertex ring by following adjacent vertices.
-
Optionally applying a callback function to each vertex during traversal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v_index
|
int
|
The index of the starting vertex. |
required |
callback
|
(function, optional(default=None))
|
An optional callback function to apply to each vertex. |
None
|
depth
|
(int, optional(default=None))
|
The maximum depth of the traversal. If None, expands to the entire mesh. |
None
|
Returns:
Name | Type | Description |
---|---|---|
expanded_vertices |
numpy array
|
The indices of all vertices within the specified depth. |
Note
This function assumes that the mesh is manifold and connected. The vertex ring expansion is based on the current mesh topology.
See Also
vertex_ring_vertices_iterators : Iterates over vertices in the vertex ring.
Source code in src/geometry/meshpy.py
vertex_ring_faces_iterators(self, sort=False, order=False)
Iterates over the faces in the vertex ring around each vertex.
This function provides iterators for the faces in the vertex ring around each vertex, with options for sorting and ordering.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sort
|
(bool, optional(default=False))
|
Whether to sort the faces by face index. |
False
|
order
|
(bool, optional(default=False))
|
Whether to order the faces by traversal direction. |
False
|
Returns:
Name | Type | Description |
---|---|---|
v |
numpy array
|
The indices of the central vertices. |
fj |
numpy array
|
The indices of the adjacent faces in the vertex ring. |
Note
This function assumes that the mesh is manifold and orientable. The vertex ring faces are useful for local mesh analysis and processing.
See Also
vertex_ring_vertices_iterators : Iterates over vertices in the vertex ring.
vertex_ring_edges_iterators : Iterates over edges in the vertex ring.
Source code in src/geometry/meshpy.py
vertex_ring_faces_list(self)
Returns a list of faces in the vertex ring for each vertex.
This function constructs a list where each entry corresponds to a vertex and contains the indices of faces in its vertex ring.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
ring_list |
list of lists
|
A list where each entry is a list of face indices in the vertex ring. |
Note
This function assumes that the mesh is manifold and orientable. The vertex ring faces are useful for local mesh analysis and processing.
See Also
vertex_ring_faces_iterators : Iterates over faces in the vertex ring.
vertex_ring_vertices_list : Returns a list of vertex rings for each vertex.
Source code in src/geometry/meshpy.py
vertex_ring_ordered_halfedges(self)
Retrieves the half-edges in the vertex ring around each vertex, ordered by traversal.
This function returns the indices of half-edges that form the vertex ring around each vertex, ordered in a consistent traversal direction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
ordered_halfedges |
numpy array
|
The indices of half-edges in the vertex ring, ordered by traversal. |
Note
This function assumes that the mesh is manifold and orientable. The half-edges are ordered to facilitate consistent traversal around each vertex.
See Also
vertex_ring_vertices_iterators : Iterates over vertices in the vertex ring.
Source code in src/geometry/meshpy.py
vertex_ring_parametrization(self)
Computes a parametrization of the vertex ring around each vertex.
This function assigns a parametric coordinate (U, V) to each vertex in the vertex ring, based on the angular position around the central vertex.
The main logic involves:
-
Iterating over each vertex and its adjacent vertices (vertex ring).
-
Computing the angular position of each adjacent vertex.
-
Assigning parametric coordinates (U, V) based on the angular position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
v |
numpy array
|
The indices of the central vertices. |
vj |
numpy array
|
The indices of the adjacent vertices in the vertex ring. |
U |
numpy array
|
The U-coordinates of the parametrization. |
V |
numpy array
|
The V-coordinates of the parametrization. |
Note
This function assumes that the mesh is manifold and orientable. The parametrization is based on the current mesh topology and geometry.
See Also
vertex_ring_vertices_iterators : Iterates over vertices in the vertex ring.
Source code in src/geometry/meshpy.py
vertex_ring_vertices(self, vertex_index)
Retrieves the vertices in the vertex ring around a specified vertex.
This function returns the sequence of vertices that are directly connected to the specified vertex. The vertex ring can be used to traverse the mesh topology.
The main logic involves:
-
Starting from a half-edge originating from the specified vertex.
-
Iteratively following the next half-edge in the loop to collect adjacent vertices.
-
Returning the sequence of vertices in the vertex ring.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vertex_index
|
int
|
The index of the vertex. |
required |
Returns:
Name | Type | Description |
---|---|---|
ring_vertices |
list of int
|
The indices of vertices in the vertex ring. |
Note
This function assumes that the specified vertex exists in the mesh. The vertex ring can be used for further mesh traversal and manipulation.
See Also
vertex_halfedge : Retrieves a half-edge originating from a specified vertex.
halfedge_ring : Retrieves the half-edge ring around a specified half-edge.
Source code in src/geometry/meshpy.py
vertex_ring_vertices_iterators(self, sort=False, order=False, return_lengths=False)
Iterates over the vertices in the vertex ring around each vertex.
This function provides iterators for the vertices in the vertex ring around each vertex, with options for sorting and ordering.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sort
|
(bool, optional(default=False))
|
Whether to sort the vertices by vertex index. |
False
|
order
|
(bool, optional(default=False))
|
Whether to order the vertices by traversal direction. |
False
|
return_lengths
|
(bool, optional(default=False))
|
Whether to return the lengths of the vertex rings. |
False
|
Returns:
Name | Type | Description |
---|---|---|
v |
numpy array
|
The indices of the central vertices. |
vj |
numpy array
|
The indices of the adjacent vertices in the vertex ring. |
lengths |
numpy array, optional
|
The lengths of the vertex rings (returned if |
Note
This function assumes that the mesh is manifold and orientable. The vertex ring vertices are useful for local mesh analysis and processing.
See Also
vertex_ring_faces_iterators : Iterates over faces in the vertex ring.
vertex_ring_edges_iterators : Iterates over edges in the vertex ring.
Source code in src/geometry/meshpy.py
vertex_ring_vertices_list(self)
Returns a list of vertex rings for each vertex.
This function constructs a list where each entry corresponds to a vertex and contains the indices of vertices in its vertex ring.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
ring_list |
list of lists
|
A list where each entry is a list of vertex indices in the vertex ring. |
Note
This function assumes that the mesh is manifold and orientable. The vertex ring vertices are useful for local mesh analysis and processing.
See Also
vertex_ring_vertices_iterators : Iterates over vertices in the vertex ring.
Source code in src/geometry/meshpy.py
vertex_multiple_ring_vertices(self, vertex_index, depth=1)
Retrieves the vertices within a specified depth from a given vertex.
This function performs a breadth-first traversal starting from the specified vertex and collects all vertices within the specified depth. The result includes the starting vertex and all vertices reachable within the given depth.
The main logic involves:
-
Initializing a queue with the starting vertex.
-
Iteratively expanding the vertex ring up to the specified depth.
-
Collecting all visited vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vertex_index
|
int
|
The index of the starting vertex. |
required |
depth
|
(int, optional(default=1))
|
The maximum depth of traversal. |
1
|
Returns:
Name | Type | Description |
---|---|---|
ring_vertices |
numpy array
|
The indices of vertices within the specified depth. |
Note
This function assumes that the mesh is manifold and orientable. The traversal is based on the current mesh topology.
See Also
vertex_ring_vertices : Retrieves the vertices in the immediate vertex ring.
ertex_ring_expansion : Expands the vertex ring with optional callbacks.
Source code in src/geometry/meshpy.py
vertices_edge_faces_maps(self)
Creates sparse matrices mapping vertex pairs to edge and face indices.
This function constructs sparse matrices where each entry corresponds to a pair of vertices and contains the indices of the edge and adjacent faces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
f1Map |
coo_matrix
|
A sparse matrix mapping vertex pairs to the first adjacent face. |
f2Map |
coo_matrix
|
A sparse matrix mapping vertex pairs to the second adjacent face. |
Note
This function assumes that the mesh is manifold and orientable. The maps are useful for efficient lookups and mesh analysis.
See Also
vertices_edge_map : Creates a map for vertices and edges.
edge_faces : Retrieves the faces adjacent to each edge.
Source code in src/geometry/meshpy.py
vertices_edge_map(self)
Creates a sparse matrix mapping vertex pairs to edge indices.
This function constructs a sparse matrix where each entry corresponds to a pair of vertices and contains the index of the edge connecting them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
None
|
The function operates on the mesh data within the class instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
edge_map |
coo_matrix
|
A sparse matrix mapping vertex pairs to edge indices. |
Note
This function assumes that the mesh is manifold and orientable. The edge map is useful for efficient edge lookups and mesh analysis.
See Also
vertices_edge_faces_maps : Creates maps for vertices, edges, and faces.
edge_vertices : Retrieves the vertices of each edge.