VTK  9.4.20241124
vtkSphere.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
125#ifndef vtkSphere_h
126#define vtkSphere_h
127
128#include "vtkCommonDataModelModule.h" // For export macro
129#include "vtkImplicitFunction.h"
130
131VTK_ABI_NAMESPACE_BEGIN
132class VTKCOMMONDATAMODEL_EXPORT vtkSphere : public vtkImplicitFunction
133{
134public:
136 void PrintSelf(ostream& os, vtkIndent indent) override;
137
141 static vtkSphere* New();
142
144
148 double EvaluateFunction(double x[3]) override;
150
154 void EvaluateGradient(double x[3], double n[3]) override;
155
157
160 vtkSetMacro(Radius, double);
161 vtkGetMacro(Radius, double);
163
165
168 vtkSetVector3Macro(Center, double);
169 vtkGetVectorMacro(Center, double, 3);
171
175 static double Evaluate(double center[3], double R, double x[3])
176 {
177 return (x[0] - center[0]) * (x[0] - center[0]) + (x[1] - center[1]) * (x[1] - center[1]) +
178 (x[2] - center[2]) * (x[2] - center[2]) - R * R;
179 }
180
182
191 float* pts, vtkIdType numPts, float sphere[4], vtkIdType hints[2]);
193 double* pts, vtkIdType numPts, double sphere[4], vtkIdType hints[2]);
195
197
206 float** spheres, vtkIdType numSpheres, float sphere[4], vtkIdType hints[2]);
208 double** spheres, vtkIdType numSpheres, double sphere[4], vtkIdType hints[2]);
210
212
218 static void ComputeBoundingSphere(double* pts, vtkIdType numPts, double sphere[4])
219 {
220 return vtkSphere::ComputeBoundingSphere(pts, numPts, sphere, nullptr);
221 }
222 static void ComputeBoundingSphere(float* pts, vtkIdType numPts, float sphere[4])
223 {
224 return vtkSphere::ComputeBoundingSphere(pts, numPts, sphere, nullptr);
225 }
227
229
235 static void ComputeBoundingSphere(float** spheres, vtkIdType numSpheres, float sphere[4])
236 {
237 return vtkSphere::ComputeBoundingSphere(spheres, numSpheres, sphere, nullptr);
238 }
239 static void ComputeBoundingSphere(double** spheres, vtkIdType numSpheres, double sphere[4])
240 {
241 return vtkSphere::ComputeBoundingSphere(spheres, numSpheres, sphere, nullptr);
242 }
244
245protected:
247 ~vtkSphere() override = default;
248
249 double Radius;
250 double Center[3];
251
252private:
253 vtkSphere(const vtkSphere&) = delete;
254 void operator=(const vtkSphere&) = delete;
255};
256
257VTK_ABI_NAMESPACE_END
258#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:108
implicit function for a sphere
Definition vtkSphere.h:133
void EvaluateGradient(double x[3], double n[3]) override
Evaluate sphere gradient.
static void ComputeBoundingSphere(double **spheres, vtkIdType numSpheres, double sphere[4])
Create a bounding sphere from a set of spheres.
Definition vtkSphere.h:239
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:175
double Radius
Definition vtkSphere.h:249
~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.
static void ComputeBoundingSphere(float *pts, vtkIdType numPts, float sphere[4])
Create a bounding sphere from a set of points.
Definition vtkSphere.h:222
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static void ComputeBoundingSphere(float **spheres, vtkIdType numSpheres, float sphere[4])
Create a bounding sphere from a set of spheres.
Definition vtkSphere.h:235
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.
static void ComputeBoundingSphere(double *pts, vtkIdType numPts, double sphere[4])
Create a bounding sphere from a set of points.
Definition vtkSphere.h:218
int vtkIdType
Definition vtkType.h:315