VTK  9.2.6
vtkBox.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkBox.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 =========================================================================*/
34 #ifndef vtkBox_h
35 #define vtkBox_h
36 
37 #include "vtkCommonDataModelModule.h" // For export macro
38 #include "vtkImplicitFunction.h"
39 class vtkBoundingBox;
40 
41 class VTKCOMMONDATAMODEL_EXPORT vtkBox : public vtkImplicitFunction
42 {
43 public:
44  vtkTypeMacro(vtkBox, vtkImplicitFunction);
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
50  static vtkBox* New();
51 
56  double EvaluateFunction(double x[3]) override;
57 
61  void EvaluateGradient(double x[3], double n[3]) override;
62 
64 
67  void SetXMin(double p[3]);
68  void SetXMin(double x, double y, double z);
69  void GetXMin(double p[3]);
70  void GetXMin(double& x, double& y, double& z);
72 
73  void SetXMax(double p[3]);
74  void SetXMax(double x, double y, double z);
75  void GetXMax(double p[3]);
76  void GetXMax(double& x, double& y, double& z);
77 
78  void SetBounds(double xMin, double xMax, double yMin, double yMax, double zMin, double zMax);
79  void SetBounds(const double bounds[6]);
80  void GetBounds(
81  double& xMin, double& xMax, double& yMin, double& yMax, double& zMin, double& zMax);
82  void GetBounds(double bounds[6]);
83  double* GetBounds() VTK_SIZEHINT(6);
84 
91  void AddBounds(const double bounds[6]);
92 
102  static char IntersectBox(const double bounds[6], const double origin[3], const double dir[3],
103  double coord[3], double& t, const double tolerance = 0.0);
104 
117  static int IntersectWithLine(const double bounds[6], const double p1[3], const double p2[3],
118  double& t1, double& t2, double x1[3], double x2[3], int& plane1, int& plane2);
119 
129  static bool IntersectWithInfiniteLine(const double bounds[6], const double p1[3],
130  const double p2[3], double& t1, double& t2, double x1[3], double x2[3], int& plane1,
131  int& plane2);
132 
140  static vtkTypeBool IntersectWithPlane(double bounds[6], double origin[3], double normal[3]);
141 
153  static vtkTypeBool IntersectWithPlane(
154  double bounds[6], double origin[3], double normal[3], double xout[18]);
155 
163  static vtkTypeBool IsBoxInFrustum(double planes[24], double bounds[6]);
164 
165 protected:
166  vtkBox();
167  ~vtkBox() override;
168 
170  double Bounds[6]; // supports the GetBounds() method
171 
172 private:
173  vtkBox(const vtkBox&) = delete;
174  void operator=(const vtkBox&) = delete;
175 };
176 
177 inline void vtkBox::SetXMin(double p[3])
178 {
179  this->SetXMin(p[0], p[1], p[2]);
180 }
181 
182 inline void vtkBox::SetXMax(double p[3])
183 {
184  this->SetXMax(p[0], p[1], p[2]);
185 }
186 
187 #endif
abstract interface for implicit functions
virtual double EvaluateFunction(double x[3])=0
Evaluate function at position x-y-z and return value.
void GetBounds(T a, double bds[6])
void SetXMax(double p[3])
Definition: vtkBox.h:182
virtual void EvaluateGradient(double x[3], double g[3])=0
Evaluate function gradient at position x-y-z and pass back vector.
int vtkTypeBool
Definition: vtkABI.h:69
a simple class to control print indentation
Definition: vtkIndent.h:39
#define VTK_SIZEHINT(...)
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
implicit function for a bounding box
Definition: vtkBox.h:41
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Fast, simple class for representing and operating on 3D bounds.