VTK  9.3.20240417
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 
14 #include "vtkCesium3DTilesWriter.h"
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 
23 VTK_ABI_NAMESPACE_BEGIN
24 class vtkActor;
26 class vtkDataArray;
27 class vtkIdList;
28 class vtkImageData;
29 class vtkIntArray;
30 class vtkPolyData;
31 class vtkPointSet;
32 class vtkRenderWindow;
35 
37 {
38 public:
40 
43  // buildings
44  TreeInformation(vtkIncrementalOctreeNode* root, int numberOfNodes,
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
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);
86  void SaveTilesMesh();
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 
96 protected:
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);
105 
107 
112  void VisitCompute(vtkIncrementalOctreeNode* node, void* aux);
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);
141  void Initialize();
142  double GetRootLength2();
149 
150 private:
154  enum vtkCesium3DTilesWriter::InputType InputType;
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 
190 VTK_ABI_NAMESPACE_END
191 #endif
192 // VTK-HeaderTest-Exclude: TreeInformation.h
Additional information and routines for 3D Tiles octree nodes.
bool ConvertTileCartesianBuildings(vtkIncrementalOctreeNode *node)
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()
std::array< double, 6 > ComputeTightBB(vtkIdList *tileBuildings)
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.
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 ...
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.
vtkSmartPointer< vtkImageData > SplitTileTexture(vtkPolyData *tileMesh, vtkImageData *textureImage, vtkDataArray *tcoordsTile)
Compute the texture image for the tile and recompute texture coordinates.
void WriteTileTexture(vtkIncrementalOctreeNode *node, const std::string &fileName, vtkImageData *tileImage)
void PreOrderTraversal(void(TreeInformation::*Visit)(vtkIncrementalOctreeNode *node, void *aux), vtkIncrementalOctreeNode *node, void *aux)
static std::array< double, 6 > ExpandBounds(double *first, double *second)
static void PrintBounds(const char *name, const double *bounds)
void PrintNode(vtkIncrementalOctreeNode *node)
void SaveTileset(vtkIncrementalOctreeNode *root, const std::string &output)
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)
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.
double ComputeGeometricErrorNodePoints(vtkIncrementalOctreeNode *node, void *aux)
Compute geometric error for the tileset and for a node.
void SaveTilesMesh()
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.
double ComputeGeometricErrorTileset()
Compute geometric error for the tileset and for a node.
double GetRootLength2()
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
Definition: vtkDataArray.h:155
list of point or cell ids
Definition: vtkIdList.h:133
topologically and geometrically regular array of data
Definition: vtkImageData.h:156
Octree node constituting incremental octree (in support of both point location and point insertion)
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:144
concrete class for storing a set of points
Definition: vtkPointSet.h:98
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:181
platform-independent render window interaction including picking and frame rate control.
create a window for renderers to draw into
@ points
Definition: vtkX3D.h:446
@ vector
Definition: vtkX3D.h:237
@ function
Definition: vtkX3D.h:249
@ name
Definition: vtkX3D.h:219
@ data
Definition: vtkX3D.h:315
@ string
Definition: vtkX3D.h:490