vtk_rs/
vtkCommonMisc.rs

1/// helper object to manage setting and generating contour values
2///
3///
4/// vtkContourValues is a general class to manage the creation, generation,
5/// and retrieval of contour values. This class serves as a helper class for
6/// contouring classes, or those classes operating on lists of contour values.
7///
8/// @sa
9/// vtkContourFilter
10#[allow(non_camel_case_types)]
11pub struct vtkContourValues(*mut core::ffi::c_void);
12impl vtkContourValues {
13    /// Creates a new [vtkContourValues] wrapped inside `vtkNew`
14    #[doc(alias = "vtkContourValues")]
15    pub fn new() -> Self {
16        unsafe extern "C" {
17            fn vtkContourValues_new() -> *mut core::ffi::c_void;
18        }
19        Self(unsafe { &mut *vtkContourValues_new() })
20    }
21    #[cfg(test)]
22    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
23        unsafe extern "C" {
24            fn vtkContourValues_get_ptr(
25                sself: *mut core::ffi::c_void,
26            ) -> *mut core::ffi::c_void;
27        }
28        unsafe { vtkContourValues_get_ptr(self.0) }
29    }
30}
31impl std::default::Default for vtkContourValues {
32    fn default() -> Self {
33        Self::new()
34    }
35}
36impl Drop for vtkContourValues {
37    fn drop(&mut self) {
38        unsafe extern "C" {
39            fn vtkContourValues_destructor(sself: *mut core::ffi::c_void);
40        }
41        unsafe { vtkContourValues_destructor(self.0) }
42        self.0 = core::ptr::null_mut();
43    }
44}
45#[test]
46fn test_vtkContourValues_create_drop() {
47    let obj = vtkContourValues::new();
48    let ptr = obj.0;
49    assert!(!ptr.is_null());
50    assert!(unsafe { !obj._get_ptr().is_null() });
51    drop(obj);
52    let new_obj = vtkContourValues(ptr);
53    assert!(unsafe { new_obj._get_ptr().is_null() });
54}
55/// Parse and evaluate a mathematical expression
56///
57///
58/// vtkExprTkFunctionParser is a wrapper class of the ExprTK library that takes
59/// in a mathematical expression as a char string, parses it, and evaluates it
60/// at the specified values of the variables in the input string.
61///
62/// The detailed documentation of the supported functionality is described in
63/// https://github.com/ArashPartow/exprtk. In addition to the documented
64/// functionality, the following vector operations have been implemented:
65/// 1) cross(v1, v2), cross product of two vectors,
66/// 2) mag(v), magnitude of a vector,
67/// 3) norm(v), the normalized version of a vector.
68///
69/// @par Thanks:
70/// Arash Partow for implementing the ExprTk library.
71#[allow(non_camel_case_types)]
72pub struct vtkExprTkFunctionParser(*mut core::ffi::c_void);
73impl vtkExprTkFunctionParser {
74    /// Creates a new [vtkExprTkFunctionParser] wrapped inside `vtkNew`
75    #[doc(alias = "vtkExprTkFunctionParser")]
76    pub fn new() -> Self {
77        unsafe extern "C" {
78            fn vtkExprTkFunctionParser_new() -> *mut core::ffi::c_void;
79        }
80        Self(unsafe { &mut *vtkExprTkFunctionParser_new() })
81    }
82    #[cfg(test)]
83    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
84        unsafe extern "C" {
85            fn vtkExprTkFunctionParser_get_ptr(
86                sself: *mut core::ffi::c_void,
87            ) -> *mut core::ffi::c_void;
88        }
89        unsafe { vtkExprTkFunctionParser_get_ptr(self.0) }
90    }
91}
92impl std::default::Default for vtkExprTkFunctionParser {
93    fn default() -> Self {
94        Self::new()
95    }
96}
97impl Drop for vtkExprTkFunctionParser {
98    fn drop(&mut self) {
99        unsafe extern "C" {
100            fn vtkExprTkFunctionParser_destructor(sself: *mut core::ffi::c_void);
101        }
102        unsafe { vtkExprTkFunctionParser_destructor(self.0) }
103        self.0 = core::ptr::null_mut();
104    }
105}
106#[test]
107fn test_vtkExprTkFunctionParser_create_drop() {
108    let obj = vtkExprTkFunctionParser::new();
109    let ptr = obj.0;
110    assert!(!ptr.is_null());
111    assert!(unsafe { !obj._get_ptr().is_null() });
112    drop(obj);
113    let new_obj = vtkExprTkFunctionParser(ptr);
114    assert!(unsafe { new_obj._get_ptr().is_null() });
115}
116/// Parse and evaluate a mathematical expression
117///
118///
119/// vtkFunctionParser is a class that takes in a mathematical expression as
120/// a char string, parses it, and evaluates it at the specified values of
121/// the variables in the input string.
122///
123/// You can use the "if" operator to create conditional expressions
124/// such as if ( test, trueresult, falseresult). These evaluate the boolean
125/// valued test expression and then evaluate either the trueresult or the
126/// falseresult expression to produce a final (scalar or vector valued) value.
127/// "test" may contain <,>,=,|,&, and () and all three subexpressions can
128/// evaluate arbitrary function operators (ln, cos, +, if, etc)
129///
130/// @par Thanks:
131/// Juha Nieminen (juha.nieminen@gmail.com) for relicensing this branch of the
132/// function parser code that this class is based upon under the new BSD license
133/// so that it could be used in VTK. Note, the BSD license applies to this
134/// version of the function parser only (by permission of the author), and not
135/// the original library.
136///
137/// @par Thanks:
138/// Thomas Dunne (thomas.dunne@iwr.uni-heidelberg.de) for adding code for
139/// two-parameter-parsing and a few functions (sign, min, max).
140///
141/// @par Thanks:
142/// Sid Sydoriak (sxs@lanl.gov) for adding boolean operations and
143/// conditional expressions and for fixing a variety of bugs.
144#[allow(non_camel_case_types)]
145pub struct vtkFunctionParser(*mut core::ffi::c_void);
146impl vtkFunctionParser {
147    /// Creates a new [vtkFunctionParser] wrapped inside `vtkNew`
148    #[doc(alias = "vtkFunctionParser")]
149    pub fn new() -> Self {
150        unsafe extern "C" {
151            fn vtkFunctionParser_new() -> *mut core::ffi::c_void;
152        }
153        Self(unsafe { &mut *vtkFunctionParser_new() })
154    }
155    #[cfg(test)]
156    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
157        unsafe extern "C" {
158            fn vtkFunctionParser_get_ptr(
159                sself: *mut core::ffi::c_void,
160            ) -> *mut core::ffi::c_void;
161        }
162        unsafe { vtkFunctionParser_get_ptr(self.0) }
163    }
164}
165impl std::default::Default for vtkFunctionParser {
166    fn default() -> Self {
167        Self::new()
168    }
169}
170impl Drop for vtkFunctionParser {
171    fn drop(&mut self) {
172        unsafe extern "C" {
173            fn vtkFunctionParser_destructor(sself: *mut core::ffi::c_void);
174        }
175        unsafe { vtkFunctionParser_destructor(self.0) }
176        self.0 = core::ptr::null_mut();
177    }
178}
179#[test]
180fn test_vtkFunctionParser_create_drop() {
181    let obj = vtkFunctionParser::new();
182    let ptr = obj.0;
183    assert!(!ptr.is_null());
184    assert!(unsafe { !obj._get_ptr().is_null() });
185    drop(obj);
186    let new_obj = vtkFunctionParser(ptr);
187    assert!(unsafe { new_obj._get_ptr().is_null() });
188}
189/// replacement for malloc/free and new/delete
190///
191///
192/// This class is a replacement for malloc/free and new/delete for software
193/// that has inherent memory leak or performance problems. For example,
194/// external software such as the PLY library (vtkPLY) and VRML importer
195/// (vtkVRMLImporter) are often written with lots of malloc() calls but
196/// without the corresponding free() invocations. The class
197/// vtkOrderedTriangulator may create and delete millions of new/delete calls.
198/// This class allows the overloading of the C++ new operator (or other memory
199/// allocation requests) by using the method AllocateMemory(). Memory is
200/// deleted with an invocation of CleanAll() (which deletes ALL memory; any
201/// given memory allocation cannot be deleted). Note: a block size can be used
202/// to control the size of each memory allocation. Requests for memory are
203/// fulfilled from the block until the block runs out, then a new block is
204/// created.
205///
206/// @warning
207/// Do not use this class as a general replacement for system memory
208/// allocation.  This class should be used only as a last resort if memory
209/// leaks cannot be tracked down and eliminated by conventional means. Also,
210/// deleting memory from vtkHeap is not supported. Only the deletion of
211/// the entire heap is. (A Reset() method allows you to reuse previously
212/// allocated memory.)
213///
214/// @sa
215/// vtkVRMLImporter vtkPLY vtkOrderedTriangulator
216#[allow(non_camel_case_types)]
217pub struct vtkHeap(*mut core::ffi::c_void);
218impl vtkHeap {
219    /// Creates a new [vtkHeap] wrapped inside `vtkNew`
220    #[doc(alias = "vtkHeap")]
221    pub fn new() -> Self {
222        unsafe extern "C" {
223            fn vtkHeap_new() -> *mut core::ffi::c_void;
224        }
225        Self(unsafe { &mut *vtkHeap_new() })
226    }
227    #[cfg(test)]
228    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
229        unsafe extern "C" {
230            fn vtkHeap_get_ptr(sself: *mut core::ffi::c_void) -> *mut core::ffi::c_void;
231        }
232        unsafe { vtkHeap_get_ptr(self.0) }
233    }
234}
235impl std::default::Default for vtkHeap {
236    fn default() -> Self {
237        Self::new()
238    }
239}
240impl Drop for vtkHeap {
241    fn drop(&mut self) {
242        unsafe extern "C" {
243            fn vtkHeap_destructor(sself: *mut core::ffi::c_void);
244        }
245        unsafe { vtkHeap_destructor(self.0) }
246        self.0 = core::ptr::null_mut();
247    }
248}
249#[test]
250fn test_vtkHeap_create_drop() {
251    let obj = vtkHeap::new();
252    let ptr = obj.0;
253    assert!(!ptr.is_null());
254    assert!(unsafe { !obj._get_ptr().is_null() });
255    drop(obj);
256    let new_obj = vtkHeap(ptr);
257    assert!(unsafe { new_obj._get_ptr().is_null() });
258}
259/// utility to locate resource files.
260///
261///
262/// VTK based application often need to locate resource files, such configuration
263/// files, Python modules, etc. vtkResourceFileLocator provides methods that can
264/// be used to locate such resource files at runtime.
265///
266/// Using `Locate`, one can locate files relative to an
267/// anchor directory such as the executable directory, or the library directory.
268///
269/// `GetLibraryPathForSymbolUnix` and `GetLibraryPathForSymbolWin32` methods can
270/// be used to locate the library that provides a particular symbol. For example,
271/// this is used by `vtkPythonInterpreter` to ensure that the `vtk` Python package
272/// is located relative the VTK libraries, irrespective of the application location.
273#[allow(non_camel_case_types)]
274pub struct vtkResourceFileLocator(*mut core::ffi::c_void);
275impl vtkResourceFileLocator {
276    /// Creates a new [vtkResourceFileLocator] wrapped inside `vtkNew`
277    #[doc(alias = "vtkResourceFileLocator")]
278    pub fn new() -> Self {
279        unsafe extern "C" {
280            fn vtkResourceFileLocator_new() -> *mut core::ffi::c_void;
281        }
282        Self(unsafe { &mut *vtkResourceFileLocator_new() })
283    }
284    #[cfg(test)]
285    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
286        unsafe extern "C" {
287            fn vtkResourceFileLocator_get_ptr(
288                sself: *mut core::ffi::c_void,
289            ) -> *mut core::ffi::c_void;
290        }
291        unsafe { vtkResourceFileLocator_get_ptr(self.0) }
292    }
293}
294impl std::default::Default for vtkResourceFileLocator {
295    fn default() -> Self {
296        Self::new()
297    }
298}
299impl Drop for vtkResourceFileLocator {
300    fn drop(&mut self) {
301        unsafe extern "C" {
302            fn vtkResourceFileLocator_destructor(sself: *mut core::ffi::c_void);
303        }
304        unsafe { vtkResourceFileLocator_destructor(self.0) }
305        self.0 = core::ptr::null_mut();
306    }
307}
308#[test]
309fn test_vtkResourceFileLocator_create_drop() {
310    let obj = vtkResourceFileLocator::new();
311    let ptr = obj.0;
312    assert!(!ptr.is_null());
313    assert!(unsafe { !obj._get_ptr().is_null() });
314    drop(obj);
315    let new_obj = vtkResourceFileLocator(ptr);
316    assert!(unsafe { new_obj._get_ptr().is_null() });
317}