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 155 156 157 158 159 160 161 162 163
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
* @class vtkHyperTreeGridGeometry3DImpl
* @brief vtkHyperTreeGridGeometry internal classes for 3D vtkHyperTreeGrid
*
* This class is an internal class used in by the vtkHyperTreeGridGeometry filter
* to generate the HTG surface in the 3D case.
*/
#ifndef vtkHyperTreeGridGeometry3DImpl_h
#define vtkHyperTreeGridGeometry3DImpl_h
#include "vtkHyperTreeGridGeometryImpl.h"
#include <map> // For std::map
VTK_ABI_NAMESPACE_BEGIN
class vtkBitArray;
class vtkHyperTreeGridNonOrientedVonNeumannSuperCursor;
class vtkHyperTreeGridGeometry3DImpl : public vtkHyperTreeGridGeometryImpl
{
public:
vtkHyperTreeGridGeometry3DImpl(bool mergePoints, vtkHyperTreeGrid* input, vtkPoints* outPoints,
vtkCellArray* outCells, vtkDataSetAttributes* inCellDataAttributes,
vtkDataSetAttributes* outCellDataAttributes, bool passThroughCellIds,
const std::string& originalCellIdArrayName, bool fillMaterial);
~vtkHyperTreeGridGeometry3DImpl() override;
/**
* Generate the external surface of the input vtkHyperTreeGrid.
*/
void GenerateGeometry() override;
protected:
/**
* Recursively browse the input HTG in order to generate the output surface.
* This method is called by GenerateGeometry.
*
* XXX: We need to determine a common interface for all cursors in order to
* define RecursivelyProcessTree as virtual in upper classes.
*/
void RecursivelyProcessTree(vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* cursor,
unsigned char coarseCellFacesToBeTreated = 0);
private:
struct HTG3DPoint;
/**
* Generate the surface for a leaf cell if needed, taking account of the
* presence of interface(s) in the cell.
*/
void GenerateCellSurface(vtkHyperTreeGridNonOrientedVonNeumannSuperCursor* cursor,
unsigned char coarseCellFacesToBeTreated, vtkIdType cellId);
/**
* Iteratively generate the face at faceId for the leaf cell at cellId.
*/
void GenerateOneCellFace(std::vector<HTG3DPoint>& cellPoints,
std::vector<std::pair<HTG3DPoint, HTG3DPoint>>& edgePoints, unsigned int faceId,
vtkIdType cellId, const double* cellOrigin, const double* cellSize, unsigned int zOffset,
unsigned int orientation,
std::map<unsigned int, std::pair<HTG3DPoint*, unsigned int>>& internalFaceA,
std::map<unsigned int, std::pair<HTG3DPoint*, unsigned int>>& internalFaceB);
/**
* This method compute the intermediate point(s) on the given edge.
* These points describe the interface points on the edges of the cell faces.
* They are contained in the edgePoints variable.
* edgeId corresponds to the id of the edge we consider.
* internalFaceA and internalFaceB are structures filled during successive calls
* of ComputeEdge and represent a linked list of points describing the internal
* faces (i.e. the interface faces).
*/
void ComputeEdge(const HTG3DPoint& firstPoint, const HTG3DPoint& secondPoint,
std::vector<std::pair<HTG3DPoint, HTG3DPoint>>& edgePoints, unsigned int edgeAxis,
unsigned int edgeId,
std::map<unsigned int, std::pair<HTG3DPoint*, unsigned int>>& internalFaceA,
std::map<unsigned int, std::pair<HTG3DPoint*, unsigned int>>& internalFaceB,
unsigned int& currentEdgePointA, unsigned int& currentEdgePointB);
/**
* Compute the coordinates of the intermediate point representing the intersection
* between the interface and the edges of the current cell. The result is stored in
* pointInter. This method return true if the interface corresponds exactly to the
* edge (which is an edge case).
*/
bool ComputeEdgeInterface(const HTG3DPoint& firstPoint, const HTG3DPoint& secondPoint,
std::vector<std::pair<HTG3DPoint, HTG3DPoint>>& edgePoints, unsigned int edgeAxis,
unsigned int edgeId, std::map<unsigned int, std::pair<HTG3DPoint*, unsigned int>>& internalFace,
HTG3DPoint& pointInter, unsigned int& edgePointId, bool isInterfaceA);
/**
* Construct the internal faces of the cells (cut inside the cell by the interface).
* This face is described by the internalFace structure, which is a linked list of
* intersection points. Each point index is mapped to the corresponding HTG3DPoint
* and the next point index of the linkage.
*/
void CompleteLinkage(std::map<unsigned int, std::pair<HTG3DPoint*, unsigned int>>& internalFace,
unsigned int edgePointId1, unsigned int edgePointId2);
/**
* Initialize the internalFace variable, containing representing an internal (interface) face
* with a linked list. Associate an edge with it's associate intersection point, then map it to
* the next one.
*/
void SetInterfaceFace(unsigned int edgeId,
std::map<unsigned int, std::pair<HTG3DPoint*, unsigned int>>& internalFace, HTG3DPoint* point);
/**
* Return if the given point is inside the cell, taking account the presence of an interface.
*/
bool IsInside(const HTG3DPoint& point);
/**
* Set the point coordinates.
*/
void SetXYZ(HTG3DPoint& point, const double* coords);
/**
* Set the intersection point coordinates.
*/
void SetIntersectXYZ(HTG3DPoint& point, const double* coords, bool isInterfaceA);
/**
* Helper methods used to insert new points into the output polydata
* (constructed surface). The point will be inserted only if it it has not
* already been. If a locator is set, this method will internally use it
* during the point insertion.
*/
vtkIdType InsertUniquePoint(HTG3DPoint& point);
/**
* Return true if the cell has a "valid" (coherent) interface.
* - HasIterface is true,
* - Intercepts[2] != 2,
* - Normals is defined and not null.
*/
bool GetHasInterface(vtkIdType cellId) const;
/**
* Branch factor of the input HTG, stored for quick access
*/
int BranchFactor;
/**
* Retrieved from the input HTG.
* Bit arrays indicating which HTG cells are marked as "pure".
* Note that cells with "invalid" interfaces will also be considered as such.
*/
vtkBitArray* InPureMaskArray;
/**
* Locator used to merge duplicated points during insertion.
*/
vtkSmartPointer<vtkMergePoints> Locator;
};
VTK_ABI_NAMESPACE_END
#endif /* vtkHyperTreeGridGeometry3DImpl_h */
|