VTK  9.2.6
vtkSphere.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSphere.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
28 #ifndef vtkSphere_h
29 #define vtkSphere_h
30 
31 #include "vtkCommonDataModelModule.h" // For export macro
32 #include "vtkImplicitFunction.h"
33 
34 class VTKCOMMONDATAMODEL_EXPORT vtkSphere : public vtkImplicitFunction
35 {
36 public:
38  void PrintSelf(ostream& os, vtkIndent indent) override;
39 
43  static vtkSphere* New();
44 
46 
50  double EvaluateFunction(double x[3]) override;
52 
56  void EvaluateGradient(double x[3], double n[3]) override;
57 
59 
62  vtkSetMacro(Radius, double);
63  vtkGetMacro(Radius, double);
65 
67 
70  vtkSetVector3Macro(Center, double);
71  vtkGetVectorMacro(Center, double, 3);
73 
77  static double Evaluate(double center[3], double R, double x[3])
78  {
79  return (x[0] - center[0]) * (x[0] - center[0]) + (x[1] - center[1]) * (x[1] - center[1]) +
80  (x[2] - center[2]) * (x[2] - center[2]) - R * R;
81  }
82 
84 
92  static void ComputeBoundingSphere(
93  float* pts, vtkIdType numPts, float sphere[4], vtkIdType hints[2]);
94  static void ComputeBoundingSphere(
95  double* pts, vtkIdType numPts, double sphere[4], vtkIdType hints[2]);
97 
99 
107  static void ComputeBoundingSphere(
108  float** spheres, vtkIdType numSpheres, float sphere[4], vtkIdType hints[2]);
109  static void ComputeBoundingSphere(
110  double** spheres, vtkIdType numSpheres, double sphere[4], vtkIdType hints[2]);
112 
113 protected:
114  vtkSphere();
115  ~vtkSphere() override = default;
116 
117  double Radius;
118  double Center[3];
119 
120 private:
121  vtkSphere(const vtkSphere&) = delete;
122  void operator=(const vtkSphere&) = delete;
123 };
124 
125 #endif
abstract interface for implicit functions
virtual double EvaluateFunction(double x[3])=0
Evaluate function at position x-y-z and return value.
int vtkIdType
Definition: vtkType.h:332
virtual void EvaluateGradient(double x[3], double g[3])=0
Evaluate function gradient at position x-y-z and pass back vector.
implicit function for a sphere
Definition: vtkSphere.h:34
a simple class to control print indentation
Definition: vtkIndent.h:39
double Radius
Definition: vtkSphere.h:117
static double Evaluate(double center[3], double R, double x[3])
Quick evaluation of the sphere equation ((x-x0)^2 + (y-y0)^2 + (z-z0)^2) - R^2.
Definition: vtkSphere.h:77
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.