VTK  9.4.20250106
TreeInformation.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
11#ifndef TreeInformation_h
12#define TreeInformation_h
13
15#include <vtkSmartPointer.h>
16
17#include <vtk_nlohmannjson.h>
18#include VTK_NLOHMANN_JSON(json.hpp)
19
20#include <array>
21#include <vector>
22
23VTK_ABI_NAMESPACE_BEGIN
24class vtkActor;
26class vtkDataArray;
27class vtkIdList;
28class vtkImageData;
29class vtkIntArray;
30class vtkPolyData;
31class vtkPointSet;
32class vtkRenderWindow;
35
37{
38public:
40
43 // buildings
44 TreeInformation(vtkIncrementalOctreeNode* root, int numberOfNodes,
45 const std::vector<vtkSmartPointer<vtkCompositeDataSet>>* buildings,
46 const std::string& textureBaseDirectory, const std::string& propertyTextureFile,
47 bool saveTextures, bool contentGLTF, bool contentGLTFSaveGLB, const char* crs,
48 const std::string& outputDir);
49 // points
50 TreeInformation(vtkIncrementalOctreeNode* root, int numberOfNodes, vtkPointSet* points,
51 bool contentGLTF, bool contentGLTFSaveGLB, const char* crs, const std::string& output);
52 // mesh
53 TreeInformation(vtkIncrementalOctreeNode* root, int numberOfNodes, vtkPolyData* mesh,
54 const std::string& textureBaseDirectory, const std::string& propertyTextureFile,
55 bool saveTextures, bool contentGLTF, bool contentGLTFSaveGLB, const char* crs,
56 const std::string& output);
58
60
62
67 std::array<double, 6> GetNodeTightBounds(int i) { return NodeTightBounds[i]; }
68 bool GetNodeTightBounds(int i, double* bounds);
69 static bool GetNodeTightBounds(void* data, vtkIncrementalOctreeNode* node, double* bounds);
71
78 void AddGeometricError(vtkPolyData* representation);
84 void Compute();
85 void SaveTilesBuildings(bool mergeTilePolyData, size_t mergedTextureWidth);
88 void SaveTileset(const std::string& output);
89 static void PrintBounds(const char* name, const double* bounds);
90 static void PrintBounds(const std::string& name, const double* bounds)
91 {
92 PrintBounds(name.c_str(), bounds);
93 }
94 static std::array<double, 6> ExpandBounds(double* first, double* second);
95
96protected:
97 void PostOrderTraversal(void (TreeInformation::*Visit)(vtkIncrementalOctreeNode* node, void* aux),
98 vtkIncrementalOctreeNode* node, void* aux);
99 void PreOrderTraversal(void (TreeInformation::*Visit)(vtkIncrementalOctreeNode* node, void* aux),
100 vtkIncrementalOctreeNode* node, void* aux);
101 void SaveTileset(vtkIncrementalOctreeNode* root, const std::string& output);
105
107
115 void SaveTileBuildings(vtkIncrementalOctreeNode* node, void* auxData);
116 void SaveTileMesh(vtkIncrementalOctreeNode* node, void* auxData);
118 vtkIncrementalOctreeNode* node, const std::string& fileName, vtkImageData* tileImage);
123 vtkPolyData* tileMesh, vtkImageData* textureImage, vtkDataArray* tcoordsTile);
124 void SaveTilePoints(vtkIncrementalOctreeNode* node, void* auxData);
125
127
139 std::array<double, 6> ComputeTightBB(vtkIdList* tileBuildings);
140 std::string ContentTypeExtension() const;
148 bool ForEachBuilding(vtkIncrementalOctreeNode* node, std::function<bool(vtkPolyData*)> Execute);
149
150private:
157
160 const std::vector<vtkSmartPointer<vtkCompositeDataSet>>* Buildings;
161 vtkPointSet* Points;
162 vtkPolyData* Mesh;
164
165 std::string OutputDir;
166 std::string TextureBaseDirectory;
167 std::string PropertyTextureFile;
168 bool SaveTextures;
169 bool ContentGLTF;
170 bool ContentGLTFSaveGLB;
171
172 const char* CRS;
176 std::vector<std::array<double, 6>> NodeTightBounds;
181 std::vector<bool> EmptyNode;
186 std::vector<double> GeometricError;
187 nlohmann::json RootJson;
188};
189
190VTK_ABI_NAMESPACE_END
191#endif
192// VTK-HeaderTest-Exclude: TreeInformation.h
Additional information and routines for 3D Tiles octree nodes.
bool ConvertTileCartesianBuildings(vtkIncrementalOctreeNode *node)
TreeInformation(vtkIncrementalOctreeNode *root, int numberOfNodes, const std::vector< vtkSmartPointer< vtkCompositeDataSet > > *buildings, const std::string &textureBaseDirectory, const std::string &propertyTextureFile, bool saveTextures, bool contentGLTF, bool contentGLTFSaveGLB, const char *crs, const std::string &outputDir)
Constructors for buildings, points and meshes.
void VisitComputeGeometricError(vtkIncrementalOctreeNode *node, void *aux)
Computes the additional information for 'node'.
bool GetNodeTightBounds(int i, double *bounds)
Returns the bounds for node with index 'i' The versions that returns a bool returns true if the node ...
void SaveTilesPoints()
void SaveTilePoints(vtkIncrementalOctreeNode *node, void *auxData)
double ComputeGeometricErrorTilesetBuildings()
Compute geometric error for the tileset and for a node.
double ComputeGeometricErrorNodeMesh(vtkIncrementalOctreeNode *node, void *aux)
Compute geometric error for the tileset and for a node.
static bool GetNodeTightBounds(void *data, vtkIncrementalOctreeNode *node, double *bounds)
Returns the bounds for node with index 'i' The versions that returns a bool returns true if the node ...
void SaveTileset(const std::string &output)
TreeInformation(vtkIncrementalOctreeNode *root, int numberOfNodes, vtkPolyData *mesh, const std::string &textureBaseDirectory, const std::string &propertyTextureFile, bool saveTextures, bool contentGLTF, bool contentGLTFSaveGLB, const char *crs, const std::string &output)
Constructors for buildings, points and meshes.
void SaveTilesBuildings(bool mergeTilePolyData, size_t mergedTextureWidth)
double ComputeGeometricErrorNode(vtkIncrementalOctreeNode *node, void *aux)
Compute geometric error for the tileset and for a node.
void WriteTileTexture(vtkIncrementalOctreeNode *node, const std::string &fileName, vtkImageData *tileImage)
void PreOrderTraversal(void(TreeInformation::*Visit)(vtkIncrementalOctreeNode *node, void *aux), vtkIncrementalOctreeNode *node, void *aux)
static void PrintBounds(const char *name, const double *bounds)
void PrintNode(vtkIncrementalOctreeNode *node)
void SaveTileset(vtkIncrementalOctreeNode *root, const std::string &output)
std::array< double, 6 > ComputeTightBB(vtkIdList *tileBuildings)
double ComputeGeometricErrorNodeBuildings(vtkIncrementalOctreeNode *node, void *aux)
Compute geometric error for the tileset and for a node.
void VisitCompute(vtkIncrementalOctreeNode *node, void *aux)
Computes the additional information for 'node'.
void SaveTileBuildings(vtkIncrementalOctreeNode *node, void *auxData)
bool ForEachBuilding(vtkIncrementalOctreeNode *node, std::function< bool(vtkPolyData *)> Execute)
Execute the passed functor for each polydata.
void Compute()
Computes the additional information for all nodes.
nlohmann::json GenerateTileJson(vtkIncrementalOctreeNode *node)
static void PrintBounds(const std::string &name, const double *bounds)
void PostOrderTraversal(void(TreeInformation::*Visit)(vtkIncrementalOctreeNode *node, void *aux), vtkIncrementalOctreeNode *node, void *aux)
void SaveTileMesh(vtkIncrementalOctreeNode *node, void *auxData)
double ComputeGeometricErrorNodePoints(vtkIncrementalOctreeNode *node, void *aux)
Compute geometric error for the tileset and for a node.
void SaveTilesMesh()
vtkSmartPointer< vtkImageData > SplitTileTexture(vtkPolyData *tileMesh, vtkImageData *textureImage, vtkDataArray *tcoordsTile)
Compute the texture image for the tile and recompute texture coordinates.
std::string ContentTypeExtension() const
TreeInformation(vtkIncrementalOctreeNode *root, int numberOfNodes, vtkPointSet *points, bool contentGLTF, bool contentGLTFSaveGLB, const char *crs, const std::string &output)
Constructors for buildings, points and meshes.
static std::array< double, 6 > ExpandBounds(double *first, double *second)
double ComputeGeometricErrorTileset()
Compute geometric error for the tileset and for a node.
double GetRootLength2()
std::array< double, 6 > GetNodeTightBounds(int i)
Returns the bounds for node with index 'i' The versions that returns a bool returns true if the node ...
double ComputeGeometricErrorTilesetPoints()
Compute geometric error for the tileset and for a node.
double ComputeGeometricErrorTilesetMesh()
Compute geometric error for the tileset and for a node.
bool ConvertDataSetCartesian(vtkPointSet *points)
void AddGeometricError(vtkPolyData *representation)
Adds a node geometric error cell attribute for the bounding box representation for nodes on a level.
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
abstract superclass for composite (multi-block or AMR) datasets
abstract superclass for arrays of numeric data
list of point or cell ids
Definition vtkIdList.h:133
topologically and geometrically regular array of data
Octree node constituting incremental octree (in support of both point location and point insertion)
dynamic, self-adjusting array of int
concrete class for storing a set of points
Definition vtkPointSet.h:98
concrete dataset represents vertices, lines, polygons, and triangle strips
platform-independent render window interaction including picking and frame rate control.
create a window for renderers to draw into
Hold a reference to a vtkObjectBase instance.