MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / UniformTriRefiner

Class UniformTriRefiner

lib/matplotlib/tri/_trirefine.py:47–307  ·  view source on GitHub ↗

Uniform mesh refinement by recursive subdivisions. Parameters ---------- triangulation : `~matplotlib.tri.Triangulation` The encapsulated triangulation (to be refined)

Source from the content-addressed store, hash-verified

45
46
47class UniformTriRefiner(TriRefiner):
48 """
49 Uniform mesh refinement by recursive subdivisions.
50
51 Parameters
52 ----------
53 triangulation : `~matplotlib.tri.Triangulation`
54 The encapsulated triangulation (to be refined)
55 """
56# See Also
57# --------
58# :class:`~matplotlib.tri.CubicTriInterpolator` and
59# :class:`~matplotlib.tri.TriAnalyzer`.
60# """
61 def __init__(self, triangulation):
62 super().__init__(triangulation)
63
64 def refine_triangulation(self, return_tri_index=False, subdiv=3):
65 """
66 Compute a uniformly refined triangulation *refi_triangulation* of
67 the encapsulated :attr:`!triangulation`.
68
69 This function refines the encapsulated triangulation by splitting each
70 father triangle into 4 child sub-triangles built on the edges midside
71 nodes, recursing *subdiv* times. In the end, each triangle is hence
72 divided into ``4**subdiv`` child triangles.
73
74 Parameters
75 ----------
76 return_tri_index : bool, default: False
77 Whether an index table indicating the father triangle index of each
78 point is returned.
79 subdiv : int, default: 3
80 Recursion level for the subdivision.
81 Each triangle is divided into ``4**subdiv`` child triangles;
82 hence, the default results in 64 refined subtriangles for each
83 triangle of the initial triangulation.
84
85 Returns
86 -------
87 refi_triangulation : `~matplotlib.tri.Triangulation`
88 The refined triangulation.
89 found_index : int array
90 Index of the initial triangulation containing triangle, for each
91 point of *refi_triangulation*.
92 Returned only if *return_tri_index* is set to True.
93 """
94 refi_triangulation = self._triangulation
95 ntri = refi_triangulation.triangles.shape[0]
96
97 # Computes the triangulation ancestors numbers in the reference
98 # triangulation.
99 ancestors = np.arange(ntri, dtype=np.int32)
100 for _ in range(subdiv):
101 refi_triangulation, ancestors = self._refine_triangulation_once(
102 refi_triangulation, ancestors)
103 refi_npts = refi_triangulation.x.shape[0]
104 refi_triangles = refi_triangulation.triangles

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…