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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkHyperTreeGridLocator.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkHyperTreeGridLocator
* @brief abstract base class for objects that implement accelerated searches through HyperTree
* Grids (HTGs)
*
* The goal of this abstract class is to define an interface to helper objects that implement
* optimized search methods through vtkHyperTreeGrids. This class is heavily inspired from the
* vtkLocator interface but constructed to be compatible with vtkHyperTreeGrids (which are not
* vtkDataSets at the time of this implementation). Ideally, implementations of this interface
* leverage the specific structure of HyperTrees and HyperTreeGrids to deliver accelerated search
* algorithms through their data.
*
* As a side comment: ideally we would inherit from vtkLocator which only supports vtkDataSets right
* now. Hopefully in the future vtkHyperTreeGrid will become a vtkDataSet or vtkCompositeDataSet and
* we could accomplish just that with minimal refactoring.
*
* @sa
* vtkHyperTreeGrid, vtkHyperTree, vtkHyperTreeGridOrientedCursor, vtkHyperTreeGridNonOrientedCursor
*/
#ifndef vtkHyperTreeGridLocator_h
#define vtkHyperTreeGridLocator_h
#include "vtkCommonDataModelModule.h" //For export macro
#include "vtkObject.h"
#include "vtkWeakPointer.h" //For HTG member
VTK_ABI_NAMESPACE_BEGIN
class vtkHyperTreeGrid;
class vtkPoints;
class vtkIdList;
class vtkGenericCell;
class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGridLocator : public vtkObject
{
public:
vtkTypeMacro(vtkHyperTreeGridLocator, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent) override;
/**
* Getter/Setter methods for setting the vtkHyperTreeGrid
*/
virtual vtkHyperTreeGrid* GetHTG();
virtual void SetHTG(vtkHyperTreeGrid*);
/**
* Initialize or reinitialize the locator (setting or re-setting clean objects in memory)
* (Does nothing)
*/
virtual void Initialize(){};
/**
* Update the locator's internal variables with respect to changes that could have happened
* outside.
*/
virtual void Update();
/**
* Basic search for cell holding a given point
* @param point coordinated of sought point
* @return the global index of the cell holding the point (-1 if cell not found or masked)
*/
virtual vtkIdType Search(const double point[3]) = 0;
/**
* Pure virtual. Find the cell where a given point lies
* @param[in] point an array holding the coordinates of the point to search for
* @param[in] tol tolerance level
* @param[out] cell pointer to a cell configured with information from return value cell index
* @param[out] subId index of the sub cell if composite cell
* @param[out] pcoords parametric coordinates of the point in the cell
* @param[out] weights interpolation weights of the sought point in the cell
* @return the global index of the cell holding the point (-1 if no cell is found or masked)
*/
virtual vtkIdType FindCell(const double point[3], const double tol, vtkGenericCell* cell,
int& subId, double pcoords[3], double* weights) = 0;
/**
* Pure virtual. Find first intersection of the line defined by (p0, p1) with the HTG
* @param[in] p0 first point of the line
* @param[in] p1 second point of the line
* @param[in] tol tolerance level
* @param[out] t pseudo-time along line path at intersection
* @param[out] x intersection point
* @param[out] pcoords parametric coordinatesof intersection
* @param[out] subId index of the sub cell if composite cell
* @param[out] cellId the global index of the intersected cell
* @param[out] cell pointer to a vtkCell object corresponding to cellId
* @return an integer with 0 if no intersection could be found
*/
virtual int IntersectWithLine(const double p0[3], const double p1[3], const double tol, double& t,
double x[3], double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell) = 0;
/**
* Pure virtual. Find all intersections of the line defined by (p0, p1) with the HTG
* @param[in] p0 first point of the line
* @param[in] p1 second point of the line
* @param[in] tol tolerance level
* @param[out] points array of points on the line intersecting the HTG
* @param[out] cellIds array of cellIds holding the different points of the points array
* @param[out] cell pointer to a vtkCell object corresponding to the last cellId found
* @return an integer with 0 if no intersection could be found
*/
virtual int IntersectWithLine(const double p0[3], const double p1[3], const double tol,
vtkPoints* points, vtkIdList* cellIds, vtkGenericCell* cell) = 0;
///@{
/**
* Get/Set tolerance used when searching for cells in the HTG.
* Default is 0.0
*/
vtkSetMacro(Tolerance, double);
vtkGetMacro(Tolerance, double);
///@}
protected:
// Constructor/Destructor defaults
vtkHyperTreeGridLocator() = default;
~vtkHyperTreeGridLocator() override = default;
/**
* Internal reference to the HyperTreeGrid one wants to search over
*/
vtkWeakPointer<vtkHyperTreeGrid> HTG;
double Tolerance = 0.0;
private:
/**
* Deletion of copy constructors
*/
vtkHyperTreeGridLocator(const vtkHyperTreeGridLocator&) = delete;
void operator=(const vtkHyperTreeGridLocator&) = delete;
}; // vtkHyperTreeGridLocator
VTK_ABI_NAMESPACE_END
#endif // vtkHyperTreeGridLocator_h
|