Polyhedral-net Splines
Loading...
Searching...
No Matches
Helper.hpp
1/* copyright(c)Jorg Peters [jorg.peters@gmail.com] */
2
3#pragma once
4
5#include "Matrix.hpp"
6#include "../Patch/Patch.hpp"
7#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
8
9typedef OpenMesh::PolyMesh_ArrayKernelT<> MeshType;
10typedef MeshType::VertexHandle VertexHandle;
11typedef MeshType::EdgeHandle EdgeHandle;
12typedef MeshType::FaceHandle FaceHandle;
13typedef MeshType::HalfedgeHandle HalfedgeHandle;
14typedef MeshType::Point Point;
15
16typedef std::vector<double> Vec3d;
17
18
19
20namespace Helper
21{
22
23// Vert functions
24int get_vert_valence(const MeshType& a_Mesh, const VertexHandle& a_VertexHandle);
25bool is_vert_3_valence(const MeshType& a_Mesh, const VertexHandle& a_VertexHandle);
26bool is_vert_4_valence(const MeshType& a_Mesh, const VertexHandle& a_VertexHandle);
27bool is_vert_5_valence(const MeshType& a_Mesh, const VertexHandle& a_VertexHandle);
28bool are_verts_of_face_all_4_valence(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
29bool is_vert_in_face(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle, const VertexHandle& a_VertHandle);
30void set_vert_vector_to_default(const int a_Size, std::vector<VertexHandle>& a_VertexHandles);
31std::vector<FaceHandle> get_faces_around_vert_counterclock(const MeshType& a_Mesh, const VertexHandle& a_VertHandle);
32std::vector<FaceHandle> get_two_layers_faces_around_vert(const MeshType& a_Mesh, const VertexHandle& a_VertHandle);
33std::vector<VertexHandle> get_two_layers_verts_around_vert(const MeshType& a_Mesh, const VertexHandle& a_VertHandle);
34std::vector<VertexHandle> get_first_layers_verts_around_vert(const MeshType& a_Mesh, const VertexHandle& a_VertHandle);
35std::vector<VertexHandle> get_surrounding_verts(const MeshType& a_Mesh, const VertexHandle& a_VertHandle);
36std::vector<FaceHandle> get_second_layer_faces_around_vert(const MeshType& a_Mesh, const VertexHandle& a_VertHandle);
37bool is_marked(const MeshType& a_Mesh, const VertexHandle& a_VertHandle);
38void mark_vert(MeshType& a_Mesh, const VertexHandle& a_VertHandle);
39// Face functions
40bool is_triangle(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
41bool is_quad(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
42bool is_pentagon(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
43bool is_hexagon(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
44std::vector<FaceHandle> init_neighbor_faces(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
45bool has_7_neighbor_faces(const std::vector<FaceHandle>& a_NBFaceHandles);
46bool has_8_neighbor_faces(const std::vector<FaceHandle>& a_NBFaceHandles);
47bool has_9_neighbor_faces(const std::vector<FaceHandle>& a_NBFaceHandles);
48bool are_faces_all_quads(const MeshType& a_Mesh, const std::vector<FaceHandle>& a_FaceHandles);
49bool is_only_surrounded_by_quad(const MeshType& a_Mesh, const VertexHandle& a_VertHandle);
50bool is_polar_surrounding_vert(const MeshType& a_Mesh, const VertexHandle& a_VertexHandle, bool only_regular = false, int max_valence = 8);
51bool is_polar(const MeshType& a_Mesh, const VertexHandle& a_VertexHandle, bool only_regular = false, int max_valence = 8, int surrounding_max_valence = 8);
52VertexHandle find_polar_vertex(const MeshType& mesh, VertexHandle outerVH);
53int get_num_of_verts_for_face(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
54int get_num_of_neighbor_faces(const std::vector<FaceHandle>& a_NBFaceHandles);
55std::vector<VertexHandle> get_verts_of_face(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
56std::vector<VertexHandle> get_verts_of_faces(const MeshType& a_Mesh, const std::vector<FaceHandle>& a_FaceHandles);
57int num_of_quads(const MeshType& a_Mesh, std::vector<FaceHandle> a_FaceHandles);
58int num_of_triangles(const MeshType& a_Mesh, std::vector<FaceHandle> a_FaceHandles);
59std::vector<FaceHandle> get_second_layer_faces_around_face(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
60bool is_marked(const MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
61void mark_face_verts(MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
62void mark_face(MeshType& a_Mesh, const FaceHandle& a_FaceHandle);
63// Type conversion
64Vec3d verthandles_to_point_vec(const MeshType& a_Mesh, const VertexHandle& a_VertHandle);
65Matrix verthandles_to_points_mat(const MeshType& a_Mesh, const std::vector<VertexHandle>& a_VertHandle);
66
67// Patch
68Patch points_mat_to_patch(const Matrix& a_PointMat);
69Patch points_mat_to_patch(const int a_PatchDegU, const int a_PatchDegV, const Matrix& a_PointMat);
70Patch points_mat_to_patch(const int a_PatchDegU, const int a_PatchDegV, const std::string a_Group, const Matrix& a_PointMat);
71Patch points_mat_to_patch(const int a_PatchDegU, const int a_PatchDegV, const std::string a_Group, const Matrix& a_PointMat, const int a_StartIndex);
72std::vector<Patch> points_mat_to_patches(const int a_NumOfPatch, const std::string a_Group, const Matrix& a_PointMat);
73std::vector<Patch> points_mat_to_patches(const int a_PatchDegU, const int a_PatchDegV, const std::string a_Group, const Matrix& a_PointMat);
74
75// Others
76template <typename T> std::vector<T> duplicate_vector(int a_Times, const std::vector<T>& a_Vector);
77
78} // end of Helper namespace
bool has_7_neighbor_faces(const std::vector< FaceHandle > &a_NBFaceHandles)
Check if the number of neighbor faces is 7.
Definition Helper.cpp:554
bool has_9_neighbor_faces(const std::vector< FaceHandle > &a_NBFaceHandles)
Check if the number of neighbor faces is 9.
Definition Helper.cpp:580
std::vector< FaceHandle > get_two_layers_faces_around_vert(const MeshType &a_Mesh, const VertexHandle &a_VertHandle)
Get first and second layers of faces aroumnd the vert (unordered) ex:
Definition Helper.cpp:289
bool is_polar(const MeshType &a_Mesh, const VertexHandle &a_VertexHandle, bool only_regular, int max_valence, int surrounding_max_valence)
Checks if the given vertex could be a polar point. A polar point is defined as a vertex that is surro...
Definition Helper.cpp:172
int num_of_quads(const MeshType &a_Mesh, std::vector< FaceHandle > a_FaceHandles)
Given a neighborhood of faces, count how many quads are there.
Definition Helper.cpp:701
Vec3d verthandles_to_point_vec(const MeshType &a_Mesh, const VertexHandle &a_VertHandle)
Convert a vertex handle to a 3D point vector.
Definition Helper.cpp:853
void mark_face_verts(MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Mark all the vertices of the given face. A marked vertex is determined by the bool named property "ma...
Definition Helper.cpp:823
std::vector< FaceHandle > init_neighbor_faces(const MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Initialize the neighbor faces of the given face.
Definition Helper.cpp:524
Patch points_mat_to_patch(const Matrix &a_PointMat)
Convert a Matrix of 3D points to a Patch.
Definition Helper.cpp:896
std::vector< VertexHandle > get_verts_of_faces(const MeshType &a_Mesh, const std::vector< FaceHandle > &a_FaceHandles)
Get the vertices of the given faces.
Definition Helper.cpp:677
int get_vert_valence(const MeshType &a_Mesh, const VertexHandle &a_VertexHandle)
Get the vert valence object.
Definition Helper.cpp:27
int get_num_of_verts_for_face(const MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Get the number of vertices for the given face.
Definition Helper.cpp:634
bool are_faces_all_quads(const MeshType &a_Mesh, const std::vector< FaceHandle > &a_FaceHandles)
Check if all the given faces are quads.
Definition Helper.cpp:594
void mark_face(MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Mark the given face. A marked face is determined by the bool named property "marked_status" on a face...
Definition Helper.cpp:837
bool is_pentagon(const MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Check if the given face is a pentagon.
Definition Helper.cpp:496
std::vector< VertexHandle > get_two_layers_verts_around_vert(const MeshType &a_Mesh, const VertexHandle &a_VertHandle)
Get first and second layers of verts around the given vert (unordered). The layout does not need to b...
Definition Helper.cpp:329
std::vector< FaceHandle > get_second_layer_faces_around_vert(const MeshType &a_Mesh, const VertexHandle &a_VertHandle)
Get second layer of faces around the given vert (unordered). The layout does not need to be regular.
Definition Helper.cpp:414
void mark_vert(MeshType &a_Mesh, const VertexHandle &a_VertHandle)
Mark the given vertex. A marked vertex is determined by the bool named property "marked_status" on a ...
Definition Helper.cpp:451
bool are_verts_of_face_all_4_valence(const MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Checks if all the vertices of the given face are 4-valence.
Definition Helper.cpp:79
std::vector< FaceHandle > get_second_layer_faces_around_face(const MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Get the second layer of faces around the given face (unordered). Output faces do not include the firs...
Definition Helper.cpp:758
Matrix verthandles_to_points_mat(const MeshType &a_Mesh, const std::vector< VertexHandle > &a_VertHandle)
Convert a vector of vertex handles to a Matrix of 3D points.
Definition Helper.cpp:874
std::vector< VertexHandle > get_surrounding_verts(const MeshType &a_Mesh, const VertexHandle &a_VertHandle)
Get surrounding verts around the given vert (unordered)
Definition Helper.cpp:384
std::vector< VertexHandle > get_verts_of_face(const MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Get the vertices of the given face.
Definition Helper.cpp:659
bool is_marked(const MeshType &a_Mesh, const VertexHandle &a_VertHandle)
Check if the given vertex is marked. A marked vertex is determined by the bool named property "marked...
Definition Helper.cpp:437
std::vector< VertexHandle > get_first_layers_verts_around_vert(const MeshType &a_Mesh, const VertexHandle &a_VertHandle)
Get first layer of verts around the given vert. The layout does not need to be regular.
Definition Helper.cpp:364
bool is_hexagon(const MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Check if the given face is a hexagon.
Definition Helper.cpp:510
bool is_only_surrounded_by_quad(const MeshType &a_Mesh, const VertexHandle &a_VertHandle)
Check if the given vertex is only surrounded by quads.
Definition Helper.cpp:614
bool is_vert_4_valence(const MeshType &a_Mesh, const VertexHandle &a_VertexHandle)
Checks if the valence of the given vertex is 4.
Definition Helper.cpp:53
bool is_quad(const MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Check if the given face is a quad.
Definition Helper.cpp:482
int get_num_of_neighbor_faces(const std::vector< FaceHandle > &a_NBFaceHandles)
Get the number of neighbor faces for the given neighborhood.
Definition Helper.cpp:646
bool is_triangle(const MeshType &a_Mesh, const FaceHandle &a_FaceHandle)
Check if the given face is a triangle.
Definition Helper.cpp:468
std::vector< Patch > points_mat_to_patches(const int a_NumOfPatch, const std::string a_Group, const Matrix &a_PointMat)
Convert a Matrix of 3D points to multiple Patch es.
Definition Helper.cpp:988
bool is_vert_in_face(const MeshType &a_Mesh, const FaceHandle &a_FaceHandle, const VertexHandle &a_VertHandle)
Check if the given vertex is one of the vertices in face.
Definition Helper.cpp:99
std::vector< T > duplicate_vector(int a_Times, const std::vector< T > &a_Vector)
Duplicate a vector multiple times.
Definition Helper.cpp:1037
void set_vert_vector_to_default(const int a_Size, std::vector< VertexHandle > &a_VertexHandles)
Set the vert vector to default object.
Definition Helper.cpp:241
bool is_polar_surrounding_vert(const MeshType &a_Mesh, const VertexHandle &a_VertexHandle, bool only_regular, int max_valence)
Checks if the given vertex could be a polar surrounding vertex. A polar patch must be surrounded by q...
Definition Helper.cpp:123
bool is_vert_3_valence(const MeshType &a_Mesh, const VertexHandle &a_VertexHandle)
Checks if the valence of the given vertex is 3.
Definition Helper.cpp:40
int num_of_triangles(const MeshType &a_Mesh, std::vector< FaceHandle > a_FaceHandles)
Given a neighborhood of faces, count how many triangles are there.
Definition Helper.cpp:722
std::vector< FaceHandle > get_faces_around_vert_counterclock(const MeshType &a_Mesh, const VertexHandle &a_VertHandle)
Get the faces around vert counterclock object.
Definition Helper.cpp:259
bool has_8_neighbor_faces(const std::vector< FaceHandle > &a_NBFaceHandles)
Check if the number of neighbor faces is 8.
Definition Helper.cpp:567
VertexHandle find_polar_vertex(const MeshType &mesh, VertexHandle outerVH)
Given a vertex that is potintially a vertex surrounding a polar point, find the polar point vertex.
Definition Helper.cpp:219
bool is_vert_5_valence(const MeshType &a_Mesh, const VertexHandle &a_VertexHandle)
Checks if the valence of the given vertex is 5.
Definition Helper.cpp:66