Files
phy/spade/trait.HintGenerator.html
Orion Kindel 0ce894e6b0 doc
2025-03-18 10:30:23 -05:00

51 lines
13 KiB
HTML

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A structure used to speed up common operations on delaunay triangulations like insertion and geometry queries by providing hints on where to start searching for elements."><title>HintGenerator in spade - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="spade" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../spade/index.html">spade</a><span class="version">2.12.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Hint<wbr>Generator</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.get_hint" title="get_hint">get_hint</a></li><li><a href="#tymethod.initialize_from_triangulation" title="initialize_from_triangulation">initialize_from_triangulation</a></li><li><a href="#tymethod.notify_vertex_inserted" title="notify_vertex_inserted">notify_vertex_inserted</a></li><li><a href="#tymethod.notify_vertex_lookup" title="notify_vertex_lookup">notify_vertex_lookup</a></li><li><a href="#tymethod.notify_vertex_removed" title="notify_vertex_removed">notify_vertex_removed</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate spade</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">spade</a></span><h1>Trait <span class="trait">HintGenerator</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/spade/delaunay_core/hint_generator.rs.html#30-53">Source</a> </span></div><pre class="rust item-decl"><code>pub trait HintGenerator&lt;S: <a class="trait" href="trait.SpadeNum.html" title="trait spade::SpadeNum">SpadeNum</a>&gt;: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/default/trait.Default.html" title="trait core::default::Default">Default</a> {
// Required methods
fn <a href="#tymethod.get_hint" class="fn">get_hint</a>(&amp;self, position: <a class="struct" href="struct.Point2.html" title="struct spade::Point2">Point2</a>&lt;S&gt;) -&gt; <a class="type" href="handles/type.FixedVertexHandle.html" title="type spade::handles::FixedVertexHandle">FixedVertexHandle</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.notify_vertex_lookup" class="fn">notify_vertex_lookup</a>(&amp;self, vertex: <a class="type" href="handles/type.FixedVertexHandle.html" title="type spade::handles::FixedVertexHandle">FixedVertexHandle</a>);
<span class="item-spacer"></span> fn <a href="#tymethod.notify_vertex_inserted" class="fn">notify_vertex_inserted</a>(
&amp;mut self,
vertex: <a class="type" href="handles/type.FixedVertexHandle.html" title="type spade::handles::FixedVertexHandle">FixedVertexHandle</a>,
vertex_position: <a class="struct" href="struct.Point2.html" title="struct spade::Point2">Point2</a>&lt;S&gt;,
);
<span class="item-spacer"></span> fn <a href="#tymethod.notify_vertex_removed" class="fn">notify_vertex_removed</a>(
&amp;mut self,
swapped_in_point: <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Point2.html" title="struct spade::Point2">Point2</a>&lt;S&gt;&gt;,
vertex: <a class="type" href="handles/type.FixedVertexHandle.html" title="type spade::handles::FixedVertexHandle">FixedVertexHandle</a>,
vertex_position: <a class="struct" href="struct.Point2.html" title="struct spade::Point2">Point2</a>&lt;S&gt;,
);
<span class="item-spacer"></span> fn <a href="#tymethod.initialize_from_triangulation" class="fn">initialize_from_triangulation</a>&lt;TR, V&gt;(triangulation: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&amp;TR</a>) -&gt; Self
<span class="where">where TR: <a class="trait" href="trait.Triangulation.html" title="trait spade::Triangulation">Triangulation</a>&lt;Vertex = V&gt;,
V: <a class="trait" href="trait.HasPosition.html" title="trait spade::HasPosition">HasPosition</a>&lt;Scalar = S&gt;</span>;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A structure used to speed up common operations on delaunay triangulations like insertion and geometry queries by providing
hints on where to start searching for elements.</p>
<p>Without a hint, these operations run in <code>O(sqrt(n))</code> for <code>n</code> uniformly distributed vertices. Most time is spent by
“walking” to the queried site (e.g. the face that is being inserted to), starting at a random vertex. A hint generator can
speed this up by either using heuristics or a spatial data structure to determine where to start walking closer to the target
site.</p>
<p>Hints can also be given manually by using the <code>...with_hint</code> methods (e.g.
<a href="trait.Triangulation.html#method.insert_with_hint" title="method spade::Triangulation::insert_with_hint">Triangulation::insert_with_hint</a>)</p>
<p>Usually, you should not need to implement this trait. Spade currently implements two common hint generators that should
fulfill most needs:</p>
<ul>
<li>A heuristic that uses the last inserted vertex as hint (<a href="struct.LastUsedVertexHintGenerator.html" title="struct spade::LastUsedVertexHintGenerator">LastUsedVertexHintGenerator</a>)</li>
<li>A hint generator based on a hierarchy of triangulations that improves walk time to <code>O(log(n))</code>
(<a href="type.HierarchyHintGenerator.html" title="type spade::HierarchyHintGenerator">HierarchyHintGenerator</a>)</li>
</ul>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.get_hint" class="method"><a class="src rightside" href="../src/spade/delaunay_core/hint_generator.rs.html#34">Source</a><h4 class="code-header">fn <a href="#tymethod.get_hint" class="fn">get_hint</a>(&amp;self, position: <a class="struct" href="struct.Point2.html" title="struct spade::Point2">Point2</a>&lt;S&gt;) -&gt; <a class="type" href="handles/type.FixedVertexHandle.html" title="type spade::handles::FixedVertexHandle">FixedVertexHandle</a></h4></section></summary><div class="docblock"><p>Returns a vertex handle that should be close to a given position.</p>
<p>The returned vertex handle may be invalid.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.notify_vertex_lookup" class="method"><a class="src rightside" href="../src/spade/delaunay_core/hint_generator.rs.html#37">Source</a><h4 class="code-header">fn <a href="#tymethod.notify_vertex_lookup" class="fn">notify_vertex_lookup</a>(&amp;self, vertex: <a class="type" href="handles/type.FixedVertexHandle.html" title="type spade::handles::FixedVertexHandle">FixedVertexHandle</a>)</h4></section></summary><div class="docblock"><p>Notifies the hint generator that an element was looked up</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.notify_vertex_inserted" class="method"><a class="src rightside" href="../src/spade/delaunay_core/hint_generator.rs.html#39">Source</a><h4 class="code-header">fn <a href="#tymethod.notify_vertex_inserted" class="fn">notify_vertex_inserted</a>(
&amp;mut self,
vertex: <a class="type" href="handles/type.FixedVertexHandle.html" title="type spade::handles::FixedVertexHandle">FixedVertexHandle</a>,
vertex_position: <a class="struct" href="struct.Point2.html" title="struct spade::Point2">Point2</a>&lt;S&gt;,
)</h4></section></summary><div class="docblock"><p>Notifies the hint generator that a new vertex is inserted</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.notify_vertex_removed" class="method"><a class="src rightside" href="../src/spade/delaunay_core/hint_generator.rs.html#41-46">Source</a><h4 class="code-header">fn <a href="#tymethod.notify_vertex_removed" class="fn">notify_vertex_removed</a>(
&amp;mut self,
swapped_in_point: <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="struct.Point2.html" title="struct spade::Point2">Point2</a>&lt;S&gt;&gt;,
vertex: <a class="type" href="handles/type.FixedVertexHandle.html" title="type spade::handles::FixedVertexHandle">FixedVertexHandle</a>,
vertex_position: <a class="struct" href="struct.Point2.html" title="struct spade::Point2">Point2</a>&lt;S&gt;,
)</h4></section></summary><div class="docblock"><p>Notifies the hint generator that a vertex was removed</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.initialize_from_triangulation" class="method"><a class="src rightside" href="../src/spade/delaunay_core/hint_generator.rs.html#49-52">Source</a><h4 class="code-header">fn <a href="#tymethod.initialize_from_triangulation" class="fn">initialize_from_triangulation</a>&lt;TR, V&gt;(triangulation: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.reference.html">&amp;TR</a>) -&gt; Self<div class="where">where
TR: <a class="trait" href="trait.Triangulation.html" title="trait spade::Triangulation">Triangulation</a>&lt;Vertex = V&gt;,
V: <a class="trait" href="trait.HasPosition.html" title="trait spade::HasPosition">HasPosition</a>&lt;Scalar = S&gt;,</div></h4></section></summary><div class="docblock"><p>Creates a new hint generator initialized to give hints for a specific triangulation</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.0/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-HintGenerator%3CS%3E-for-LastUsedVertexHintGenerator" class="impl"><a class="src rightside" href="../src/spade/delaunay_core/hint_generator.rs.html#93-125">Source</a><a href="#impl-HintGenerator%3CS%3E-for-LastUsedVertexHintGenerator" class="anchor">§</a><h3 class="code-header">impl&lt;S: <a class="trait" href="trait.SpadeNum.html" title="trait spade::SpadeNum">SpadeNum</a>&gt; <a class="trait" href="trait.HintGenerator.html" title="trait spade::HintGenerator">HintGenerator</a>&lt;S&gt; for <a class="struct" href="struct.LastUsedVertexHintGenerator.html" title="struct spade::LastUsedVertexHintGenerator">LastUsedVertexHintGenerator</a></h3></section></div><script src="../trait.impl/spade/delaunay_core/hint_generator/trait.HintGenerator.js" async></script></section></div></main></body></html>