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 =========================================================================*/
137 #ifndef vtkSphere_h
138 #define vtkSphere_h
139 
140 #include "vtkCommonDataModelModule.h" // For export macro
141 #include "vtkImplicitFunction.h"
142 
143 class VTKCOMMONDATAMODEL_EXPORT vtkSphere : public vtkImplicitFunction
144 {
145 public:
147  void PrintSelf(ostream& os, vtkIndent indent) override;
148 
152  static vtkSphere* New();
153 
155 
159  double EvaluateFunction(double x[3]) override;
161 
165  void EvaluateGradient(double x[3], double n[3]) override;
166 
168 
171  vtkSetMacro(Radius, double);
172  vtkGetMacro(Radius, double);
174 
176 
179  vtkSetVector3Macro(Center, double);
180  vtkGetVectorMacro(Center, double, 3);
182 
186  static double Evaluate(double center[3], double R, double x[3])
187  {
188  return (x[0] - center[0]) * (x[0] - center[0]) + (x[1] - center[1]) * (x[1] - center[1]) +
189  (x[2] - center[2]) * (x[2] - center[2]) - R * R;
190  }
191 
193 
202  float* pts, vtkIdType numPts, float sphere[4], vtkIdType hints[2]);
204  double* pts, vtkIdType numPts, double sphere[4], vtkIdType hints[2]);
206 
208 
217  float** spheres, vtkIdType numSpheres, float sphere[4], vtkIdType hints[2]);
219  double** spheres, vtkIdType numSpheres, double sphere[4], vtkIdType hints[2]);
221 
222 protected:
224  ~vtkSphere() override = default;
225 
226  double Radius;
227  double Center[3];
228 
229 private:
230  vtkSphere(const vtkSphere&) = delete;
231  void operator=(const vtkSphere&) = delete;
232 };
233 
234 #endif
abstract interface for implicit functions
virtual double EvaluateFunction(double x[3])=0
Evaluate function at position x-y-z and return value.
a simple class to control print indentation
Definition: vtkIndent.h:119
implicit function for a sphere
Definition: vtkSphere.h:144
void EvaluateGradient(double x[3], double n[3]) override
Evaluate sphere gradient.
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:186
double Radius
Definition: vtkSphere.h:226
~vtkSphere() override=default
static void ComputeBoundingSphere(double **spheres, vtkIdType numSpheres, double sphere[4], vtkIdType hints[2])
Create a bounding sphere from a set of spheres.
static void ComputeBoundingSphere(double *pts, vtkIdType numPts, double sphere[4], vtkIdType hints[2])
Create a bounding sphere from a set of points.
double EvaluateFunction(double x[3]) override
Evaluate sphere equation ((x-x0)^2 + (y-y0)^2 + (z-z0)^2) - R^2.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkSphere * New()
Construct sphere with center at (0,0,0) and radius=0.5.
static void ComputeBoundingSphere(float *pts, vtkIdType numPts, float sphere[4], vtkIdType hints[2])
Create a bounding sphere from a set of points.
static void ComputeBoundingSphere(float **spheres, vtkIdType numSpheres, float sphere[4], vtkIdType hints[2])
Create a bounding sphere from a set of spheres.
@ center
Definition: vtkX3D.h:236
int vtkIdType
Definition: vtkType.h:332