VTK  9.2.6
TreeInformation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: TreeInformation.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
23 #ifndef TreeInformation_h
24 #define TreeInformation_h
25 
26 #include <vtkSmartPointer.h>
27 
28 #include <vtk_nlohmannjson.h>
29 #include VTK_NLOHMANN_JSON(json.hpp)
30 
31 #include <array>
32 #include <vector>
33 
34 class vtkActor;
36 class vtkIdList;
37 class vtkImageData;
38 class vtkIntArray;
39 class vtkPolyData;
40 class vtkPointSet;
41 class vtkRenderWindow;
44 
46 {
47 public:
49 
52  TreeInformation(vtkIncrementalOctreeNode* root, int numberOfNodes,
54  const std::string& textureBaseDirectory, bool saveTextures, bool contentGLTF, const char* crs,
55  const std::string& outputDir);
57  bool contentGLTF, const char* crs, const std::string& output);
58  TreeInformation(vtkIncrementalOctreeNode* root, int numberOfNodes, vtkPolyData* mesh,
59  const std::string& textureBaseDirectory, bool saveTextures, bool contentGLTF, const char* crs,
60  const std::string& output);
62 
64 
66 
71  std::array<double, 6> GetNodeTightBounds(int i) { return NodeTightBounds[i]; }
72  bool GetNodeTightBounds(int i, double* bounds);
73  static bool GetNodeTightBounds(void* data, vtkIncrementalOctreeNode* node, double* bounds);
75 
82  void AddGeometricError(vtkPolyData* representation);
88  void Compute();
89  void SaveTilesBuildings(bool mergeTilePolyData);
90  void SaveTilesMesh();
91  void SaveTilesPoints();
92  void SaveTileset(const std::string& output);
93  static void PrintBounds(const char* name, const double* bounds);
94  static void PrintBounds(const std::string& name, const double* bounds)
95  {
96  PrintBounds(name.c_str(), bounds);
97  }
98  static std::array<double, 6> ExpandBounds(double* first, double* second);
99 
100 protected:
101  void PostOrderTraversal(void (TreeInformation::*Visit)(vtkIncrementalOctreeNode* node, void* aux),
102  vtkIncrementalOctreeNode* node, void* aux);
103  void PreOrderTraversal(void (TreeInformation::*Visit)(vtkIncrementalOctreeNode* node, void* aux),
104  vtkIncrementalOctreeNode* node, void* aux);
105  void SaveTileset(vtkIncrementalOctreeNode* root, const std::string& output);
106  nlohmann::json GenerateTileJson(vtkIncrementalOctreeNode* node);
108  bool ConvertDataSetCartesian(vtkPointSet* points);
109 
111 
116  void VisitCompute(vtkIncrementalOctreeNode* node, void* aux);
119  void SaveTileBuildings(vtkIncrementalOctreeNode* node, void* auxData);
120  void SaveTileMesh(vtkIncrementalOctreeNode* node, void* auxData);
125  vtkPolyData* tileMesh, vtkImageData* textureImage);
126  void SaveTilePoints(vtkIncrementalOctreeNode* node, void* auxData);
127 
129 
139  double ComputeGeometricErrorNode(vtkIncrementalOctreeNode* node, void* aux);
141  std::array<double, 6> ComputeTightBB(vtkIdList* tileBuildings);
143  void Initialize();
144  double GetRootLength2();
145 
146 private:
150  int InputType;
153 
156  const std::vector<vtkSmartPointer<vtkCompositeDataSet>>* Buildings;
157  vtkPointSet* Points;
158  vtkPolyData* Mesh;
160 
161  std::string OutputDir;
162  std::string TextureBaseDirectory;
163  bool SaveTextures;
164  bool ContentGLTF;
165 
166  const char* CRS;
170  std::vector<std::array<double, 6>> NodeTightBounds;
175  std::vector<bool> EmptyNode;
180  std::vector<double> GeometricError;
181  nlohmann::json RootJson;
182 };
183 
184 #endif
185 // VTK-HeaderTest-Exclude: TreeInformation.h
void VisitCompute(vtkIncrementalOctreeNode *node, void *aux)
Computes the additional information for 'node'.
void SaveTilesPoints()
void SaveTileMesh(vtkIncrementalOctreeNode *node, void *auxData)
void PrintNode(vtkIncrementalOctreeNode *node)
double ComputeGeometricErrorNode(vtkIncrementalOctreeNode *node, void *aux)
Compute geometric error for the tileset and for a node.
static void PrintBounds(const std::string &name, const double *bounds)
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
nlohmann::json GenerateTileJson(vtkIncrementalOctreeNode *node)
bool ConvertDataSetCartesian(vtkPointSet *points)
double ComputeGeometricErrorTilesetBuildings()
Compute geometric error for the tileset and for a node.
void PreOrderTraversal(void(TreeInformation::*Visit)(vtkIncrementalOctreeNode *node, void *aux), vtkIncrementalOctreeNode *node, void *aux)
double ComputeGeometricErrorTilesetPoints()
Compute geometric error for the tileset and for a node.
Additional information and routins for 3D Tiles octree nodes.
concrete class for storing a set of points
Definition: vtkPointSet.h:69
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
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 ...
platform-independent render window interaction including picking and frame rate control.
void AddGeometricError(vtkPolyData *representation)
Adds a node geometric error cell attribute for the bounding box representation for nodes on a level...
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
abstract superclass for composite (multi-block or AMR) datasets
vtkSmartPointer< vtkImageData > ComputeTileMeshTexture(vtkPolyData *tileMesh, vtkImageData *textureImage)
Compute the texture image for the tile and recompute texture coordinates.
double ComputeGeometricErrorTileset()
Compute geometric error for the tileset and for a node.
void SaveTileset(const std::string &output)
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
TreeInformation(vtkIncrementalOctreeNode *root, int numberOfNodes, const std::vector< vtkSmartPointer< vtkCompositeDataSet >> *buildings, const std::string &textureBaseDirectory, bool saveTextures, bool contentGLTF, const char *crs, const std::string &outputDir)
Constructors for buildings, points and meshes.
list of point or cell ids
Definition: vtkIdList.h:33
double ComputeGeometricErrorNodeBuildings(vtkIncrementalOctreeNode *node, void *aux)
Compute geometric error for the tileset and for a node.
void PostOrderTraversal(void(TreeInformation::*Visit)(vtkIncrementalOctreeNode *node, void *aux), vtkIncrementalOctreeNode *node, void *aux)
bool ConvertTileCartesianBuildings(vtkIncrementalOctreeNode *node)
Octree node constituting incremental octree (in support of both point location and point insertion) ...
void SaveTileBuildings(vtkIncrementalOctreeNode *node, void *auxData)
void SaveTilesMesh()
std::string ContentTypeExtension() const
double GetRootLength2()
void SaveTilePoints(vtkIncrementalOctreeNode *node, void *auxData)
create a window for renderers to draw into
double ComputeGeometricErrorNodePoints(vtkIncrementalOctreeNode *node, void *aux)
Compute geometric error for the tileset and for a node.
void VisitComputeGeometricError(vtkIncrementalOctreeNode *node, void *aux)
Computes the additional information for 'node'.
std::array< double, 6 > ComputeTightBB(vtkIdList *tileBuildings)
static void PrintBounds(const char *name, const double *bounds)
static std::array< double, 6 > ExpandBounds(double *first, double *second)
void SaveTilesBuildings(bool mergeTilePolyData)
double ComputeGeometricErrorTilesetMesh()
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.
void Compute()
Computes the additional information for all nodes.