VTK  9.6.1
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
15
16#ifndef vtkSphere_h
17#define vtkSphere_h
18
19#include "vtkCommonDataModelModule.h" // For export macro
20#include "vtkImplicitFunction.h"
21
22VTK_ABI_NAMESPACE_BEGIN
23class VTKCOMMONDATAMODEL_EXPORT vtkSphere : public vtkImplicitFunction
24{
25public:
27 void PrintSelf(ostream& os, vtkIndent indent) override;
28
32 static vtkSphere* New();
33
35
39 double EvaluateFunction(double x[3]) override;
41
45 void EvaluateGradient(double x[3], double n[3]) override;
46
48
51 vtkSetMacro(Radius, double);
52 vtkGetMacro(Radius, double);
54
56
59 vtkSetVector3Macro(Center, double);
60 vtkGetVectorMacro(Center, double, 3);
62
66 static double Evaluate(double center[3], double R, double x[3])
67 {
68 return (x[0] - center[0]) * (x[0] - center[0]) + (x[1] - center[1]) * (x[1] - center[1]) +
69 (x[2] - center[2]) * (x[2] - center[2]) - R * R;
70 }
71
73
82 float* pts, vtkIdType numPts, float sphere[4], vtkIdType hints[2]);
84 double* pts, vtkIdType numPts, double sphere[4], vtkIdType hints[2]);
86
88
97 float** spheres, vtkIdType numSpheres, float sphere[4], vtkIdType hints[2]);
99 double** spheres, vtkIdType numSpheres, double sphere[4], vtkIdType hints[2]);
101
103
109 static void ComputeBoundingSphere(double* pts, vtkIdType numPts, double sphere[4])
110 {
111 vtkSphere::ComputeBoundingSphere(pts, numPts, sphere, nullptr);
112 }
113 static void ComputeBoundingSphere(float* pts, vtkIdType numPts, float sphere[4])
114 {
115 vtkSphere::ComputeBoundingSphere(pts, numPts, sphere, nullptr);
116 }
117
118
120
126 static void ComputeBoundingSphere(float** spheres, vtkIdType numSpheres, float sphere[4])
127 {
128 vtkSphere::ComputeBoundingSphere(spheres, numSpheres, sphere, nullptr);
129 }
130 static void ComputeBoundingSphere(double** spheres, vtkIdType numSpheres, double sphere[4])
131 {
132 vtkSphere::ComputeBoundingSphere(spheres, numSpheres, sphere, nullptr);
133 }
134
135
136protected:
138 ~vtkSphere() override = default;
139
140 double Radius;
141 double Center[3];
142
143private:
144 vtkSphere(const vtkSphere&) = delete;
145 void operator=(const vtkSphere&) = delete;
146};
147
148VTK_ABI_NAMESPACE_END
149#endif
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:29
void EvaluateGradient(double x[3], double n[3]) override
Evaluate sphere gradient.
double Center[3]
Definition vtkSphere.h:141
static void ComputeBoundingSphere(double **spheres, vtkIdType numSpheres, double sphere[4])
Create a bounding sphere from a set of spheres.
Definition vtkSphere.h:130
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:66
double Radius
Definition vtkSphere.h:140
~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:113
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:126
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:109
int vtkIdType
Definition vtkType.h:368