1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
* @class vtkFrustum
* @brief implicit function for a frustum
*
* vtkFrustum represents a 4-sided frustum, with a near plane but infinite on the far side. It is
* defined by the two angles between its forward axis and its horizontal and vertical planes, and
* the distance between its origin and near plane. vtkFrustum is a concrete implementation of
* vtkImplicitFunction. The frustum is oriented toward the Y Axis; its top face facing
* toward the Z Axis and its "right" face facing the X Axis.
*
* @warning
* The frustum is infinite in extent towards its far plane. To truncate the frustum in modeling
* operations use the vtkImplicitBoolean in combination with clipping planes.
*
*/
#ifndef vtkFrustum_h
#define vtkFrustum_h
#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkImplicitFunction.h"
#include "vtkNew.h" // For vtkNew
VTK_ABI_NAMESPACE_BEGIN
class vtkImplicitBoolean;
class vtkPlane;
class VTKCOMMONDATAMODEL_EXPORT vtkFrustum : public vtkImplicitFunction
{
public:
static vtkFrustum* New();
vtkTypeMacro(vtkFrustum, vtkImplicitFunction);
void PrintSelf(ostream& os, vtkIndent indent) override;
using vtkImplicitFunction::EvaluateFunction;
double EvaluateFunction(double x[3]) override;
using vtkImplicitFunction::EvaluateGradient;
void EvaluateGradient(double x[3], double g[3]) override;
///@{
/**
* Get/Set the near plane distance of the frustum, i.e. the distance between its origin and near
* plane along the forward axis. Values below 0 will be clamped. Defaults to 0.5.
*/
vtkGetMacro(NearPlaneDistance, double)
void SetNearPlaneDistance(double distance);
///@}
///@{
/**
* Get/Set the horizontal angle of the frustum in degrees. It represents the angle between its
* forward axis and its right and left planes. Clamped between 1 and 89 degrees. Defaults to 30.
*/
vtkGetMacro(HorizontalAngle, double)
void SetHorizontalAngle(double angleInDegrees);
///@}
///@{
/**
* Get/Set the vertical angle of the frustum in degrees. It represents the angle between its
* forward axis and its top and bottom planes. Clamped between 1 and 89 degrees. Defaults to 30.
*/
vtkGetMacro(VerticalAngle, double)
void SetVerticalAngle(double angleInDegrees);
///@}
///@{
/**
* Get individual planes that make up the frustum.
* @note: Do not attempt to modify ! Use the vertical/horizontal angles and near plane distance to
* parameterize the frustum instead.
*/
vtkPlane* GetTopPlane() { return this->TopPlane; }
vtkPlane* GetBottomPlane() { return this->BottomPlane; }
vtkPlane* GetRightPlane() { return this->RightPlane; }
vtkPlane* GetLeftPlane() { return this->LeftPlane; }
vtkPlane* GetNearPlane() { return this->NearPlane; }
///@}
protected:
vtkFrustum();
~vtkFrustum() override;
private:
vtkFrustum(const vtkFrustum&) = delete;
void operator=(const vtkFrustum&) = delete;
///@{
/**
* Compute and set the horizontal or vertical planes' normals according to the defined angle
* Normals are pointing "outside" the frustum
* @see vtkImplicitFunction and EvaluateFunction
*/
void CalculateHorizontalPlanesNormal();
void CalculateVerticalPlanesNormal();
///@}
double NearPlaneDistance = 0.5;
double VerticalAngle = 30;
double HorizontalAngle = 30;
vtkNew<vtkPlane> NearPlane;
vtkNew<vtkPlane> BottomPlane;
vtkNew<vtkPlane> TopPlane;
vtkNew<vtkPlane> RightPlane;
vtkNew<vtkPlane> LeftPlane;
vtkNew<vtkImplicitBoolean> BooleanOp;
};
VTK_ABI_NAMESPACE_END
#endif
|