vtk_rs/
vtkCommonMath.rs

1/// nonlinear optimization with a simplex
2///
3///
4/// vtkAmoebaMinimizer will modify a set of parameters in order to find
5/// the minimum of a specified function.  The method used is commonly
6/// known as the amoeba method, it constructs an n-dimensional simplex
7/// in parameter space (i.e. a tetrahedron if the number or parameters
8/// is 3) and moves the vertices around parameter space until a local
9/// minimum is found.  The amoeba method is robust, reasonably efficient,
10/// but is not guaranteed to find the global minimum if several local
11/// minima exist.
12#[allow(non_camel_case_types)]
13pub struct vtkAmoebaMinimizer(*mut core::ffi::c_void);
14impl vtkAmoebaMinimizer {
15    /// Creates a new [vtkAmoebaMinimizer] wrapped inside `vtkNew`
16    #[doc(alias = "vtkAmoebaMinimizer")]
17    pub fn new() -> Self {
18        unsafe extern "C" {
19            fn vtkAmoebaMinimizer_new() -> *mut core::ffi::c_void;
20        }
21        Self(unsafe { &mut *vtkAmoebaMinimizer_new() })
22    }
23    #[cfg(test)]
24    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
25        unsafe extern "C" {
26            fn vtkAmoebaMinimizer_get_ptr(
27                sself: *mut core::ffi::c_void,
28            ) -> *mut core::ffi::c_void;
29        }
30        unsafe { vtkAmoebaMinimizer_get_ptr(self.0) }
31    }
32}
33impl std::default::Default for vtkAmoebaMinimizer {
34    fn default() -> Self {
35        Self::new()
36    }
37}
38impl Drop for vtkAmoebaMinimizer {
39    fn drop(&mut self) {
40        unsafe extern "C" {
41            fn vtkAmoebaMinimizer_destructor(sself: *mut core::ffi::c_void);
42        }
43        unsafe { vtkAmoebaMinimizer_destructor(self.0) }
44        self.0 = core::ptr::null_mut();
45    }
46}
47#[test]
48fn test_vtkAmoebaMinimizer_create_drop() {
49    let obj = vtkAmoebaMinimizer::new();
50    let ptr = obj.0;
51    assert!(!ptr.is_null());
52    assert!(unsafe { !obj._get_ptr().is_null() });
53    drop(obj);
54    let new_obj = vtkAmoebaMinimizer(ptr);
55    assert!(unsafe { new_obj._get_ptr().is_null() });
56}
57/// perform Discrete Fourier Transforms
58///
59///
60/// vtkFFT provides methods to perform Discrete Fourier Transforms (DFT).
61/// These include providing forward and reverse Fourier transforms.
62/// The current implementation uses the third-party library kissfft.
63///
64/// The terminology tries to follow the Numpy terminology, that is :
65/// - Fft means the Fast Fourier Transform algorithm
66/// - Prefix `R` stands for Real (meaning optimized function for real inputs)
67/// - Prefix `I` stands for Inverse
68///
69/// Some functions provides pointer-based version of themself in order to
70/// prevent copying memory when possible.
71#[allow(non_camel_case_types)]
72pub struct vtkFFT(*mut core::ffi::c_void);
73impl vtkFFT {
74    /// Creates a new [vtkFFT] wrapped inside `vtkNew`
75    #[doc(alias = "vtkFFT")]
76    pub fn new() -> Self {
77        unsafe extern "C" {
78            fn vtkFFT_new() -> *mut core::ffi::c_void;
79        }
80        Self(unsafe { &mut *vtkFFT_new() })
81    }
82    #[cfg(test)]
83    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
84        unsafe extern "C" {
85            fn vtkFFT_get_ptr(sself: *mut core::ffi::c_void) -> *mut core::ffi::c_void;
86        }
87        unsafe { vtkFFT_get_ptr(self.0) }
88    }
89}
90impl std::default::Default for vtkFFT {
91    fn default() -> Self {
92        Self::new()
93    }
94}
95impl Drop for vtkFFT {
96    fn drop(&mut self) {
97        unsafe extern "C" {
98            fn vtkFFT_destructor(sself: *mut core::ffi::c_void);
99        }
100        unsafe { vtkFFT_destructor(self.0) }
101        self.0 = core::ptr::null_mut();
102    }
103}
104#[test]
105fn test_vtkFFT_create_drop() {
106    let obj = vtkFFT::new();
107    let ptr = obj.0;
108    assert!(!ptr.is_null());
109    assert!(unsafe { !obj._get_ptr().is_null() });
110    drop(obj);
111    let new_obj = vtkFFT(ptr);
112    assert!(unsafe { new_obj._get_ptr().is_null() });
113}
114/// represent and manipulate 3x3 transformation matrices
115///
116///
117/// vtkMatrix3x3 is a class to represent and manipulate 3x3 matrices.
118/// Specifically, it is designed to work on 3x3 transformation matrices
119/// found in 2D rendering using homogeneous coordinates [x y w].
120///
121/// @sa
122/// vtkTransform2D
123#[allow(non_camel_case_types)]
124pub struct vtkMatrix3x3(*mut core::ffi::c_void);
125impl vtkMatrix3x3 {
126    /// Creates a new [vtkMatrix3x3] wrapped inside `vtkNew`
127    #[doc(alias = "vtkMatrix3x3")]
128    pub fn new() -> Self {
129        unsafe extern "C" {
130            fn vtkMatrix3x3_new() -> *mut core::ffi::c_void;
131        }
132        Self(unsafe { &mut *vtkMatrix3x3_new() })
133    }
134    #[cfg(test)]
135    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
136        unsafe extern "C" {
137            fn vtkMatrix3x3_get_ptr(
138                sself: *mut core::ffi::c_void,
139            ) -> *mut core::ffi::c_void;
140        }
141        unsafe { vtkMatrix3x3_get_ptr(self.0) }
142    }
143}
144impl std::default::Default for vtkMatrix3x3 {
145    fn default() -> Self {
146        Self::new()
147    }
148}
149impl Drop for vtkMatrix3x3 {
150    fn drop(&mut self) {
151        unsafe extern "C" {
152            fn vtkMatrix3x3_destructor(sself: *mut core::ffi::c_void);
153        }
154        unsafe { vtkMatrix3x3_destructor(self.0) }
155        self.0 = core::ptr::null_mut();
156    }
157}
158#[test]
159fn test_vtkMatrix3x3_create_drop() {
160    let obj = vtkMatrix3x3::new();
161    let ptr = obj.0;
162    assert!(!ptr.is_null());
163    assert!(unsafe { !obj._get_ptr().is_null() });
164    drop(obj);
165    let new_obj = vtkMatrix3x3(ptr);
166    assert!(unsafe { new_obj._get_ptr().is_null() });
167}
168/// represent and manipulate 4x4 transformation matrices
169///
170///
171/// vtkMatrix4x4 is a class to represent and manipulate 4x4 matrices.
172/// Specifically, it is designed to work on 4x4 transformation matrices
173/// found in 3D rendering using homogeneous coordinates [x y z w].
174/// Many of the methods take an array of 16 doubles in row-major format.
175/// Note that OpenGL stores matrices in column-major format, so the matrix
176/// contents must be transposed when they are moved between OpenGL and VTK.
177/// @sa
178/// vtkTransform
179#[allow(non_camel_case_types)]
180pub struct vtkMatrix4x4(*mut core::ffi::c_void);
181impl vtkMatrix4x4 {
182    /// Creates a new [vtkMatrix4x4] wrapped inside `vtkNew`
183    #[doc(alias = "vtkMatrix4x4")]
184    pub fn new() -> Self {
185        unsafe extern "C" {
186            fn vtkMatrix4x4_new() -> *mut core::ffi::c_void;
187        }
188        Self(unsafe { &mut *vtkMatrix4x4_new() })
189    }
190    #[cfg(test)]
191    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
192        unsafe extern "C" {
193            fn vtkMatrix4x4_get_ptr(
194                sself: *mut core::ffi::c_void,
195            ) -> *mut core::ffi::c_void;
196        }
197        unsafe { vtkMatrix4x4_get_ptr(self.0) }
198    }
199}
200impl std::default::Default for vtkMatrix4x4 {
201    fn default() -> Self {
202        Self::new()
203    }
204}
205impl Drop for vtkMatrix4x4 {
206    fn drop(&mut self) {
207        unsafe extern "C" {
208            fn vtkMatrix4x4_destructor(sself: *mut core::ffi::c_void);
209        }
210        unsafe { vtkMatrix4x4_destructor(self.0) }
211        self.0 = core::ptr::null_mut();
212    }
213}
214#[test]
215fn test_vtkMatrix4x4_create_drop() {
216    let obj = vtkMatrix4x4::new();
217    let ptr = obj.0;
218    assert!(!ptr.is_null());
219    assert!(unsafe { !obj._get_ptr().is_null() });
220    drop(obj);
221    let new_obj = vtkMatrix4x4(ptr);
222    assert!(unsafe { new_obj._get_ptr().is_null() });
223}
224/// polynomial solvers
225///
226///
227/// vtkPolynomialSolversUnivariate provides solvers for
228/// univariate polynomial equations with real coefficients.
229/// The Tartaglia-Cardan and Ferrari solvers work on polynomials of fixed
230/// degree 3 and 4, respectively.
231/// The Lin-Bairstow and Sturm solvers work on polynomials of arbitrary
232/// degree. The Sturm solver is the most robust solver but only reports
233/// roots within an interval and does not report multiplicities.
234/// The Lin-Bairstow solver reports multiplicities.
235///
236/// For difficult polynomials, you may wish to use FilterRoots to
237/// eliminate some of the roots reported by the Sturm solver.
238/// FilterRoots evaluates the derivatives near each root to
239/// eliminate cases where a local minimum or maximum is close
240/// to zero.
241///
242/// @par Thanks:
243/// Thanks to Philippe Pebay, Korben Rusek, David Thompson, and Maurice Rojas
244/// for implementing these solvers.
245#[allow(non_camel_case_types)]
246pub struct vtkPolynomialSolversUnivariate(*mut core::ffi::c_void);
247impl vtkPolynomialSolversUnivariate {
248    /// Creates a new [vtkPolynomialSolversUnivariate] wrapped inside `vtkNew`
249    #[doc(alias = "vtkPolynomialSolversUnivariate")]
250    pub fn new() -> Self {
251        unsafe extern "C" {
252            fn vtkPolynomialSolversUnivariate_new() -> *mut core::ffi::c_void;
253        }
254        Self(unsafe { &mut *vtkPolynomialSolversUnivariate_new() })
255    }
256    #[cfg(test)]
257    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
258        unsafe extern "C" {
259            fn vtkPolynomialSolversUnivariate_get_ptr(
260                sself: *mut core::ffi::c_void,
261            ) -> *mut core::ffi::c_void;
262        }
263        unsafe { vtkPolynomialSolversUnivariate_get_ptr(self.0) }
264    }
265}
266impl std::default::Default for vtkPolynomialSolversUnivariate {
267    fn default() -> Self {
268        Self::new()
269    }
270}
271impl Drop for vtkPolynomialSolversUnivariate {
272    fn drop(&mut self) {
273        unsafe extern "C" {
274            fn vtkPolynomialSolversUnivariate_destructor(sself: *mut core::ffi::c_void);
275        }
276        unsafe { vtkPolynomialSolversUnivariate_destructor(self.0) }
277        self.0 = core::ptr::null_mut();
278    }
279}
280#[test]
281fn test_vtkPolynomialSolversUnivariate_create_drop() {
282    let obj = vtkPolynomialSolversUnivariate::new();
283    let ptr = obj.0;
284    assert!(!ptr.is_null());
285    assert!(unsafe { !obj._get_ptr().is_null() });
286    drop(obj);
287    let new_obj = vtkPolynomialSolversUnivariate(ptr);
288    assert!(unsafe { new_obj._get_ptr().is_null() });
289}
290/// interpolate a quaternion
291///
292///
293/// This class is used to interpolate a series of quaternions representing
294/// the rotations of a 3D object.  The interpolation may be linear in form
295/// (using spherical linear interpolation SLERP), or via spline interpolation
296/// (using SQUAD). In either case the interpolation is specialized to
297/// quaternions since the interpolation occurs on the surface of the unit
298/// quaternion sphere.
299///
300/// To use this class, specify at least two pairs of (t,q[4]) with the
301/// AddQuaternion() method.  Next interpolate the tuples with the
302/// InterpolateQuaternion(t,q[4]) method, where "t" must be in the range of
303/// (t_min,t_max) parameter values specified by the AddQuaternion() method (t
304/// is clamped otherwise), and q[4] is filled in by the method.
305///
306/// There are several important background references. Ken Shoemake described
307/// the practical application of quaternions for the interpolation of rotation
308/// (K. Shoemake, "Animating rotation with quaternion curves", Computer
309/// Graphics (Siggraph '85) 19(3):245--254, 1985). Another fine reference
310/// (available on-line) is E. B. Dam, M. Koch, and M. Lillholm, Technical
311/// Report DIKU-TR-98/5, Dept. of Computer Science, University of Copenhagen,
312/// Denmark.
313///
314/// @warning
315/// Note that for two or less quaternions, Slerp (linear) interpolation is
316/// performed even if spline interpolation is requested. Also, the tangents to
317/// the first and last segments of spline interpolation are (arbitrarily)
318/// defined by repeating the first and last quaternions.
319///
320/// @warning
321/// There are several methods particular to quaternions (norms, products,
322/// etc.) implemented interior to this class. These may be moved to a separate
323/// quaternion class at some point.
324///
325/// @sa
326/// vtkQuaternion
327#[allow(non_camel_case_types)]
328pub struct vtkQuaternionInterpolator(*mut core::ffi::c_void);
329impl vtkQuaternionInterpolator {
330    /// Creates a new [vtkQuaternionInterpolator] wrapped inside `vtkNew`
331    #[doc(alias = "vtkQuaternionInterpolator")]
332    pub fn new() -> Self {
333        unsafe extern "C" {
334            fn vtkQuaternionInterpolator_new() -> *mut core::ffi::c_void;
335        }
336        Self(unsafe { &mut *vtkQuaternionInterpolator_new() })
337    }
338    #[cfg(test)]
339    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
340        unsafe extern "C" {
341            fn vtkQuaternionInterpolator_get_ptr(
342                sself: *mut core::ffi::c_void,
343            ) -> *mut core::ffi::c_void;
344        }
345        unsafe { vtkQuaternionInterpolator_get_ptr(self.0) }
346    }
347}
348impl std::default::Default for vtkQuaternionInterpolator {
349    fn default() -> Self {
350        Self::new()
351    }
352}
353impl Drop for vtkQuaternionInterpolator {
354    fn drop(&mut self) {
355        unsafe extern "C" {
356            fn vtkQuaternionInterpolator_destructor(sself: *mut core::ffi::c_void);
357        }
358        unsafe { vtkQuaternionInterpolator_destructor(self.0) }
359        self.0 = core::ptr::null_mut();
360    }
361}
362#[test]
363fn test_vtkQuaternionInterpolator_create_drop() {
364    let obj = vtkQuaternionInterpolator::new();
365    let ptr = obj.0;
366    assert!(!ptr.is_null());
367    assert!(unsafe { !obj._get_ptr().is_null() });
368    drop(obj);
369    let new_obj = vtkQuaternionInterpolator(ptr);
370    assert!(unsafe { new_obj._get_ptr().is_null() });
371}
372/// Integrate an initial value problem using 2nd
373///
374/// order Runge-Kutta method.
375///
376///
377/// This is a concrete sub-class of vtkInitialValueProblemSolver.
378/// It uses a 2nd order Runge-Kutta method to obtain the values of
379/// a set of functions at the next time step.
380///
381/// @sa
382/// vtkInitialValueProblemSolver vtkRungeKutta4 vtkRungeKutta45 vtkFunctionSet
383#[allow(non_camel_case_types)]
384pub struct vtkRungeKutta2(*mut core::ffi::c_void);
385impl vtkRungeKutta2 {
386    /// Creates a new [vtkRungeKutta2] wrapped inside `vtkNew`
387    #[doc(alias = "vtkRungeKutta2")]
388    pub fn new() -> Self {
389        unsafe extern "C" {
390            fn vtkRungeKutta2_new() -> *mut core::ffi::c_void;
391        }
392        Self(unsafe { &mut *vtkRungeKutta2_new() })
393    }
394    #[cfg(test)]
395    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
396        unsafe extern "C" {
397            fn vtkRungeKutta2_get_ptr(
398                sself: *mut core::ffi::c_void,
399            ) -> *mut core::ffi::c_void;
400        }
401        unsafe { vtkRungeKutta2_get_ptr(self.0) }
402    }
403}
404impl std::default::Default for vtkRungeKutta2 {
405    fn default() -> Self {
406        Self::new()
407    }
408}
409impl Drop for vtkRungeKutta2 {
410    fn drop(&mut self) {
411        unsafe extern "C" {
412            fn vtkRungeKutta2_destructor(sself: *mut core::ffi::c_void);
413        }
414        unsafe { vtkRungeKutta2_destructor(self.0) }
415        self.0 = core::ptr::null_mut();
416    }
417}
418#[test]
419fn test_vtkRungeKutta2_create_drop() {
420    let obj = vtkRungeKutta2::new();
421    let ptr = obj.0;
422    assert!(!ptr.is_null());
423    assert!(unsafe { !obj._get_ptr().is_null() });
424    drop(obj);
425    let new_obj = vtkRungeKutta2(ptr);
426    assert!(unsafe { new_obj._get_ptr().is_null() });
427}
428/// Integrate an initial value problem using 4th
429///
430/// order Runge-Kutta method.
431///
432///
433/// This is a concrete sub-class of vtkInitialValueProblemSolver.
434/// It uses a 4th order Runge-Kutta method to obtain the values of
435/// a set of functions at the next time step.
436///
437/// @sa
438/// vtkInitialValueProblemSolver vtkRungeKutta45 vtkRungeKutta2 vtkFunctionSet
439#[allow(non_camel_case_types)]
440pub struct vtkRungeKutta4(*mut core::ffi::c_void);
441impl vtkRungeKutta4 {
442    /// Creates a new [vtkRungeKutta4] wrapped inside `vtkNew`
443    #[doc(alias = "vtkRungeKutta4")]
444    pub fn new() -> Self {
445        unsafe extern "C" {
446            fn vtkRungeKutta4_new() -> *mut core::ffi::c_void;
447        }
448        Self(unsafe { &mut *vtkRungeKutta4_new() })
449    }
450    #[cfg(test)]
451    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
452        unsafe extern "C" {
453            fn vtkRungeKutta4_get_ptr(
454                sself: *mut core::ffi::c_void,
455            ) -> *mut core::ffi::c_void;
456        }
457        unsafe { vtkRungeKutta4_get_ptr(self.0) }
458    }
459}
460impl std::default::Default for vtkRungeKutta4 {
461    fn default() -> Self {
462        Self::new()
463    }
464}
465impl Drop for vtkRungeKutta4 {
466    fn drop(&mut self) {
467        unsafe extern "C" {
468            fn vtkRungeKutta4_destructor(sself: *mut core::ffi::c_void);
469        }
470        unsafe { vtkRungeKutta4_destructor(self.0) }
471        self.0 = core::ptr::null_mut();
472    }
473}
474#[test]
475fn test_vtkRungeKutta4_create_drop() {
476    let obj = vtkRungeKutta4::new();
477    let ptr = obj.0;
478    assert!(!ptr.is_null());
479    assert!(unsafe { !obj._get_ptr().is_null() });
480    drop(obj);
481    let new_obj = vtkRungeKutta4(ptr);
482    assert!(unsafe { new_obj._get_ptr().is_null() });
483}
484/// Integrate an initial value problem using 5th
485///
486/// order Runge-Kutta method with adaptive stepsize control.
487///
488///
489/// This is a concrete sub-class of vtkInitialValueProblemSolver.
490/// It uses a 5th order Runge-Kutta method with stepsize control to obtain
491/// the values of a set of functions at the next time step. The stepsize
492/// is adjusted by calculating an estimated error using an embedded 4th
493/// order Runge-Kutta formula:
494/// Press, W. H. et al., 1992, Numerical Recipes in Fortran, Second
495/// Edition, Cambridge University Press
496/// Cash, J.R. and Karp, A.H. 1990, ACM Transactions on Mathematical
497/// Software, vol 16, pp 201-222
498///
499/// @sa
500/// vtkInitialValueProblemSolver vtkRungeKutta4 vtkRungeKutta2 vtkFunctionSet
501#[allow(non_camel_case_types)]
502pub struct vtkRungeKutta45(*mut core::ffi::c_void);
503impl vtkRungeKutta45 {
504    /// Creates a new [vtkRungeKutta45] wrapped inside `vtkNew`
505    #[doc(alias = "vtkRungeKutta45")]
506    pub fn new() -> Self {
507        unsafe extern "C" {
508            fn vtkRungeKutta45_new() -> *mut core::ffi::c_void;
509        }
510        Self(unsafe { &mut *vtkRungeKutta45_new() })
511    }
512    #[cfg(test)]
513    unsafe fn _get_ptr(&self) -> *mut core::ffi::c_void {
514        unsafe extern "C" {
515            fn vtkRungeKutta45_get_ptr(
516                sself: *mut core::ffi::c_void,
517            ) -> *mut core::ffi::c_void;
518        }
519        unsafe { vtkRungeKutta45_get_ptr(self.0) }
520    }
521}
522impl std::default::Default for vtkRungeKutta45 {
523    fn default() -> Self {
524        Self::new()
525    }
526}
527impl Drop for vtkRungeKutta45 {
528    fn drop(&mut self) {
529        unsafe extern "C" {
530            fn vtkRungeKutta45_destructor(sself: *mut core::ffi::c_void);
531        }
532        unsafe { vtkRungeKutta45_destructor(self.0) }
533        self.0 = core::ptr::null_mut();
534    }
535}
536#[test]
537fn test_vtkRungeKutta45_create_drop() {
538    let obj = vtkRungeKutta45::new();
539    let ptr = obj.0;
540    assert!(!ptr.is_null());
541    assert!(unsafe { !obj._get_ptr().is_null() });
542    drop(obj);
543    let new_obj = vtkRungeKutta45(ptr);
544    assert!(unsafe { new_obj._get_ptr().is_null() });
545}