VTK  9.0.20200925
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 =========================================================================*/
25 #ifndef vtkSphere_h
26 #define vtkSphere_h
27 
28 #include "vtkCommonDataModelModule.h" // For export macro
29 #include "vtkImplicitFunction.h"
30 
31 class VTKCOMMONDATAMODEL_EXPORT vtkSphere : public vtkImplicitFunction
32 {
33 public:
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
40  static vtkSphere* New();
41 
43 
47  double EvaluateFunction(double x[3]) override;
49 
53  void EvaluateGradient(double x[3], double n[3]) override;
54 
56 
59  vtkSetMacro(Radius, double);
60  vtkGetMacro(Radius, double);
62 
64 
67  vtkSetVector3Macro(Center, double);
68  vtkGetVectorMacro(Center, double, 3);
70 
74  static double Evaluate(double center[3], double R, double x[3])
75  {
76  return (x[0] - center[0]) * (x[0] - center[0]) + (x[1] - center[1]) * (x[1] - center[1]) +
77  (x[2] - center[2]) * (x[2] - center[2]) - R * R;
78  }
79 
81 
89  static void ComputeBoundingSphere(
90  float* pts, vtkIdType numPts, float sphere[4], vtkIdType hints[2]);
91  static void ComputeBoundingSphere(
92  double* pts, vtkIdType numPts, double sphere[4], vtkIdType hints[2]);
94 
96 
104  static void ComputeBoundingSphere(
105  float** spheres, vtkIdType numSpheres, float sphere[4], vtkIdType hints[2]);
106  static void ComputeBoundingSphere(
107  double** spheres, vtkIdType numSpheres, double sphere[4], vtkIdType hints[2]);
109 
110 protected:
111  vtkSphere();
112  ~vtkSphere() override = default;
113 
114  double Radius;
115  double Center[3];
116 
117 private:
118  vtkSphere(const vtkSphere&) = delete;
119  void operator=(const vtkSphere&) = delete;
120 };
121 
122 #endif
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkImplicitFunction::EvaluateFunction
virtual double EvaluateFunction(double x[3])=0
Evaluate function at position x-y-z and return value.
vtkX3D::center
Definition: vtkX3D.h:236
vtkSphere
implicit function for a sphere
Definition: vtkSphere.h:31
vtkImplicitFunction
abstract interface for implicit functions
Definition: vtkImplicitFunction.h:60
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkImplicitFunction::EvaluateGradient
virtual void EvaluateGradient(double x[3], double g[3])=0
Evaluate function gradient at position x-y-z and pass back vector.
vtkSphere::Radius
double Radius
Definition: vtkSphere.h:114
vtkSphere::Evaluate
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:74
vtkImplicitFunction.h
vtkImplicitFunction::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.