Browse Source

get chain of patch mapping

V2
Zhicheng Wang 2 days ago
parent
commit
0b9ab0906d
  1. 8
      network_process/include/connect_by_topo/patch_connectivity.hpp
  2. 31
      network_process/src/connect_by_topo/patch_connectivity.cpp
  3. 8
      network_process/src/post_topo/filter_polygon_faces.cpp
  4. 30
      network_process/src/process.cpp

8
network_process/include/connect_by_topo/patch_connectivity.hpp

@ -30,14 +30,20 @@ void compute_patches(const stl_vector_mp<stl_vector_mp<uint32_t>> &edges_of_face
/**
* @brief Group non-manifold iso-edges into chains
* @param[in] iso_vert_count the count of iso-vertices.
* @param[in] patch_count the count of patches.
* @param[in] patch_of_face the mapping from face index to patch index.
* @param[in] patch_edges the list of edges on the patch.
* @param[out] chains non-manifold edges.
* @param[out] chain_representative_headers the headers of edges in chains.
* @param[out] chain_of_patch the mapping from chain index to patch index.
*/
void compute_chains(size_t iso_vert_count,
size_t patch_count,
stl_vector_mp<uint32_t> &patch_of_face,
stl_vector_mp<iso_edge_t> &patch_edges,
flat_index_group_t &chains,
stl_vector_mp<iso_edge_t> &chain_representative_headers);
stl_vector_mp<iso_edge_t> &chain_representative_headers,
flat_index_group_t &chain_of_patch);
/**
* @brief compute shells and connected components of isosurfaces, and build maps: half-patch --> shell, patch --> component

31
network_process/src/connect_by_topo/patch_connectivity.cpp

@ -81,9 +81,12 @@ void compute_patches(const stl_vector_mp<stl_vector_mp<uint32_t>>& edges_of_face
}
void compute_chains(size_t iso_vert_count,
size_t patch_count,
stl_vector_mp<uint32_t>& patch_of_face,
stl_vector_mp<iso_edge_t>& patch_edges,
flat_index_group_t& chains,
stl_vector_mp<iso_edge_t>& chain_representative_headers)
stl_vector_mp<iso_edge_t>& chain_representative_headers,
flat_index_group_t& chain_of_patch)
{
stl_vector_mp<stl_vector_mp<uint32_t>> non_manifold_edges_of_vert{};
stl_vector_mp<uint32_t> non_manifold_edges{};
@ -108,8 +111,9 @@ void compute_chains(size_t iso_vert_count,
// 1. each chain can start from arbitary vertex of a non-manifold edge, and end at visited edge (i.e. a ring is built) or
// singular vertex;
// 2. along each chain, the neighboring patch does not change, otherwise a new chain is raised.
stl_vector_mp<bool> visited_edge(patch_edges.size(), false);
std::list<uint32_t> chain_edges{};
stl_vector_mp<bool> visited_edge(patch_edges.size(), false);
std::list<uint32_t> chain_edges{};
stl_vector_mp<stl_vector_mp<uint32_t>> split_chain_of_patch(patch_count);
chains.index_group.reserve(non_manifold_edges.size() * 2);
chains.start_indices.reserve(8);
chain_representative_headers.reserve(8);
@ -118,17 +122,21 @@ void compute_chains(size_t iso_vert_count,
// unvisited non-manifold iso-edge (not a boundary edge)
// new chain
chains.start_indices.emplace_back(static_cast<uint32_t>(chains.index_group.size()));
auto& edge = patch_edges[i];
auto chain_index = static_cast<uint32_t>(chains.size());
auto& edge = patch_edges[i];
chain_edges.clear();
std::queue<uint32_t> Q{};
Q.emplace(i);
chain_edges.emplace_back(edge.v1);
chain_edges.emplace_back(edge.v2);
chain_representative_headers.emplace_back(edge);
visited_edge[i] = true;
chain_edges.clear();
while (!Q.empty()) {
const auto eId = Q.front();
Q.pop();
for (const auto& header : patch_edges[eId].headers) {
split_chain_of_patch[patch_of_face[header.face_index]].emplace_back(chain_index);
}
// v1
auto v = patch_edges[eId].v1;
if (non_manifold_edges_of_vert[v].size() == 2) {
@ -185,6 +193,19 @@ void compute_chains(size_t iso_vert_count,
chains.start_indices.emplace_back(static_cast<uint32_t>(chains.index_group.size()));
chains.start_indices.shrink_to_fit();
chains.index_group.shrink_to_fit();
{
size_t chain_patch_count{};
for (const auto& chain_patches : split_chain_of_patch) { chain_patch_count += chain_patches.size(); }
chain_of_patch.index_group.reserve(chain_patch_count);
chain_of_patch.start_indices.reserve(split_chain_of_patch.size() + 1);
for (const auto& chain_patches : split_chain_of_patch) {
chain_of_patch.start_indices.emplace_back(static_cast<uint32_t>(chain_of_patch.index_group.size()));
chain_of_patch.index_group.insert(chain_of_patch.index_group.end(),
std::make_move_iterator(chain_patches.begin()),
std::make_move_iterator(chain_patches.end()));
}
}
}
void compute_shells_and_components(const stl_vector_mp<stl_vector_mp<uint32_t>>& half_patch_adj_list,

8
network_process/src/post_topo/filter_polygon_faces.cpp

@ -2,6 +2,12 @@
#include <post_topo.hpp>
// ===========================================================================================================
// ===========================================================================================================
dynamic_bitset_mp<> filter_polygon_faces(const stl_vector_mp<polygon_face_t>& faces,
const flat_index_group_t& patches,
const flat_index_group_t& arrangement_cells,
@ -13,6 +19,8 @@ dynamic_bitset_mp<> filter_polygon_faces(const stl_vector_mp<polygon_face_t>& fa
stl_vector_mp<uint32_t>& output_vertex_counts_of_face)
{
dynamic_bitset_mp<> active_face_label(faces.size(), false);
dynamic_bitset_mp<> active_patch_label(patches.size(), false);
dynamic_bitset_mp<> patch_sign_label(patches.size(), false);
output_polygon_faces.reserve(faces.size() * 3);
output_vertex_counts_of_face.reserve(faces.size());

30
network_process/src/process.cpp

@ -68,24 +68,30 @@ ISNP_API void build_implicit_network_by_blobtree(const s_settings&
iso_faces);
}
// connect components by topology
// TODO: split headers of chains out, because it should not change during the chain
stl_vector_mp<iso_edge_t> chain_representative_headers{};
stl_vector_mp<uint32_t> patch_of_face(iso_faces.size());
stl_vector_mp<uint32_t> shell_of_half_patch{};
stl_vector_mp<uint32_t> component_of_patch{};
flat_index_group_t patches{};
flat_index_group_t chains{};
flat_index_group_t shells{};
flat_index_group_t components{};
flat_index_group_t arrangement_cells{};
stl_vector_mp<uint32_t> shell_to_cell{};
stl_vector_mp<uint32_t> patch_of_face(iso_faces.size());
stl_vector_mp<uint32_t> shell_of_half_patch{};
stl_vector_mp<uint32_t> component_of_patch{};
flat_index_group_t patches{};
flat_index_group_t chains{};
flat_index_group_t shells{};
flat_index_group_t components{};
flat_index_group_t arrangement_cells{};
stl_vector_mp<uint32_t> shell_to_cell{};
flat_index_group_t chain_of_patch{};
{
stl_vector_mp<iso_edge_t> chain_representative_headers{};
{
stl_vector_mp<stl_vector_mp<uint32_t>> edges_of_iso_face{};
stl_vector_mp<iso_edge_t> iso_edges{};
compute_patch_edges(iso_faces, edges_of_iso_face, iso_edges);
compute_patches(edges_of_iso_face, iso_edges, iso_faces, patches, patch_of_face);
compute_chains(iso_verts.size(), iso_edges, chains, chain_representative_headers);
compute_chains(iso_verts.size(),
patches.size(),
patch_of_face,
iso_edges,
chains,
chain_representative_headers,
chain_of_patch);
}
stl_vector_mp<stl_vector_mp<uint32_t>> half_patch_adj_list(2 * chains.size());
chains.group_foreach([&](uint32_t chain_index, uint32_t _, uint32_t __) {

Loading…
Cancel
Save