From b1d7af5cfe3d80df30f79e8ad39f006ebd21d6e8 Mon Sep 17 00:00:00 2001 From: Guillaume Cerutti <guillaume.cerutti@inria.fr> Date: Mon, 12 Feb 2024 17:59:15 +0100 Subject: [PATCH] allow collapsing contour face edges + safer contiguous id --- src/cellcomplex/property_topomesh/extraction.py | 2 +- .../property_topomesh/topological_operations.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/cellcomplex/property_topomesh/extraction.py b/src/cellcomplex/property_topomesh/extraction.py index f36fe0c..3b73180 100644 --- a/src/cellcomplex/property_topomesh/extraction.py +++ b/src/cellcomplex/property_topomesh/extraction.py @@ -480,7 +480,7 @@ def contiguous_wisps_topomesh(input_topomesh): topomesh._regions[degree] = new_regions for property_name in topomesh._wisp_properties[degree].keys(): - if topomesh.has_wisp_property(property_name, degree, is_computed=True): + if all([w in topomesh._wisp_properties[degree][property_name].keys() for w in old_wisps]): topomesh._wisp_properties[degree][property_name] = array_dict(dict(zip( new_wisps, topomesh._wisp_properties[degree][property_name].values(old_wisps) diff --git a/src/cellcomplex/property_topomesh/topological_operations.py b/src/cellcomplex/property_topomesh/topological_operations.py index 48fa76c..974611a 100644 --- a/src/cellcomplex/property_topomesh/topological_operations.py +++ b/src/cellcomplex/property_topomesh/topological_operations.py @@ -185,7 +185,9 @@ def topomesh_collapse_edge(topomesh, eid, kept_pid=None, manifold=True, verbose= assert len(pids_to_link) == len(edge_fids) # assert np.all(np.array(map(len,[list(topomesh.regions(0,pid)) for pid in pids_to_link])) > 3) - assert np.all([np.all([len(list(topomesh.regions(1,e))) == 2 for e in topomesh.borders(2,fid) if e != eid]) for fid in edge_fids]) + + assert np.all([np.any([len(list(topomesh.regions(1,e))) == 2 for e in topomesh.borders(2,fid) if e != eid]) for fid in edge_fids]) + # assert np.all([np.all([len(list(topomesh.regions(1,e))) <= 2 for e in topomesh.borders(2,fid) if e != eid]) for fid in edge_fids]) for fid in edge_fids: # logging.info("".join([" " for l in range(loglevel)])+" --> Face ",fid," : ",list(topomesh.borders(2,fid))," (",eids_to_keep,")" @@ -200,10 +202,10 @@ def topomesh_collapse_edge(topomesh, eid, kept_pid=None, manifold=True, verbose= topomesh.unlink(2,fid,eid_to_keep) topomesh.unlink(2,fid,eid_to_delete) - fid_to_link = list(topomesh.regions(1,eid_to_delete))[0] - #for fid_to_link in topomesh.regions(1,eid_to_delete): - topomesh.unlink(2,fid_to_link,eid_to_delete) - topomesh.link(2,fid_to_link,eid_to_keep) + #fid_to_link = list(topomesh.regions(1,eid_to_delete))[0] + for fid_to_link in topomesh.regions(1,eid_to_delete): + topomesh.unlink(2,fid_to_link,eid_to_delete) + topomesh.link(2,fid_to_link,eid_to_keep) topomesh.remove_wisp(1,eid_to_delete) topomesh.remove_wisp(2,fid) @@ -250,8 +252,8 @@ def topomesh_collapse_edge(topomesh, eid, kept_pid=None, manifold=True, verbose= # logging.info("".join([" " for l in range(loglevel)])+eid," collapse error : (",pid_to_keep,pid_to_delete,@")",np.array(list(topomesh.wisps(1)))[nd.sum(np.ones_like(edge_vertex_id),edge_vertex_id,index=edge_vertex_id)>1] # raw_input() - except AssertionError: - logging.info("".join([" " for l in range(loglevel)])+"<-- Impossible to collapse edge : wrong configuration ( "+str(len(list(initial_topomesh.regions(1,eid))))+" regions)") + except AssertionError as Argument: + logging.exception("".join([" " for l in range(loglevel)])+"<-- Impossible to collapse edge : wrong configuration ( "+str(len(list(initial_topomesh.regions(1,eid))))+" regions)") assert np.max([initial_topomesh.nb_regions(1,e) for e in initial_topomesh.wisps(1)])==2 topomesh._borders = deepcopy(initial_topomesh._borders) topomesh._regions = deepcopy(initial_topomesh._regions) -- GitLab