LVRChunkedMeshCuller.cpp
Go to the documentation of this file.
1 
3 
4 //#include "MeshChunkActor.hpp"
5 
7 
8 #include <omp.h>
9 
10 #include <vtkSphereSource.h>
11 #include <vtkPolyDataMapper.h>
12 
13 //using namespace lvr2;
14 
15 namespace lvr2{
16 
17  double ChunkedMeshCuller::Cull(vtkRenderer *ren,
18  vtkProp **propList,
19  int &listLength,
20  int &initialized)
21  {
22  std::unordered_map<size_t, vtkSmartPointer<vtkActor>> lowRes = m_bridge->getLowResActors();
23  std::unordered_map<size_t, vtkSmartPointer<vtkActor>> highRes = m_bridge->getHighResActors();
24 
25  double planes[24];
26  vtkSmartPointer<vtkCamera> cam = ren->GetActiveCamera();
27  cam->GetFrustumPlanes(ren->GetTiledAspectRatio(), planes);
28  double clip[2];
29  cam->GetClippingRange(clip);
30 
31  //for(int i = 0; i < 6; ++i)
32  //{
33  // int index = 4 * i;
34 
35  //}
36 
37  double position[3];
38  cam->GetPosition(position);
39  double dir[3];
40  cam->GetDirectionOfProjection(dir);
41  double up[3];
42  cam->GetViewUp(up);
43 
44  std::vector<lvr2::BaseVector<float> > centroids;
45  std::vector<size_t> indices;
46  m_bridge->getActors(planes, centroids, indices);
47 
48 
49  double scale = cam->GetParallelScale();
50 
51  cam->SetParallelScale(1.0);
52  cam->SetClippingRange(0.01, m_highResDistance);
53  double planes_high[24];
54  cam->GetFrustumPlanes(ren->GetTiledAspectRatio(), planes_high);
55  BaseVector<float> base(dir[0], dir[1], dir[2]);
56  cam->SetParallelScale(scale);
57  cam->SetClippingRange(clip[0], clip[1]);
58  std::vector<lvr2::BaseVector<float> > centroids2;
59  std::vector<size_t> indices2;
60  m_bridge->getActors(planes_high, centroids2, indices2);
61 
62  BoundingBox<BaseVector<float> > highResArea;
63 
64  for(size_t i = 0; i < centroids2.size(); ++i)
65  {
66  highResArea.expand(centroids2[i]);
67  }
68  //std::cout << highResArea << std::endl;
69  //std::cout << highResArea.getVolume() << std::endl;
70 
71  //BaseVector<float> eye(position[0], position[1], position[2]);
72  //BaseVector<float> direction(dir[0], dir[1], dir[2]);
73  //direction.normalize();
74  //BaseVector<float> upVector(up[0], up[1], up[2]);
75  //upVector.normalize();
76  //BaseVector<float> perp = upVector.cross(direction);
77  //perp.normalize();
78 
79  //highResArea.expand(eye + (direction * 1.2 * 150.0));
80  //highResArea.expand(eye + (direction * ((-1) * 100.0/2.0)));
81  //highResArea.expand(eye + (upVector * 100.0));
82  //highResArea.expand(eye + (upVector * ((-1) * 100.0)));
83  //highResArea.expand(eye + (perp * 100.0));
84  //highResArea.expand(eye + (perp * ((-1) * 100.0)));
85 
86  m_bridge->fetchHighRes(highResArea, indices2, centroids2);
87 
88  //vtkActorCollection* actors = ren->GetActors();
89  //actors->InitTraversal();
90 
91 
92  if(lowRes.size() > 0)
93  {
94  for(size_t i = 0; i < indices.size(); ++i)
95  {
96  lowRes.at(indices[i])->VisibilityOn();
97  }
98  }
99 
100  for(auto& it: highRes)
101  {
102  if(std::find(indices2.begin(), indices2.end(), it.first) != indices2.end())
103  {
104  if(it.second)
105  {
106  it.second->VisibilityOn();
107  }
108  if(lowRes.size() > 0)
109  {
110  lowRes.at(it.first)->VisibilityOff();
111  }
112  }
113  else
114  {
115  if(it.second)
116  {
117  it.second->VisibilityOff();
118  }
119  }
120  }
121  return 0.0;
122  }
123 }
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > getHighResActors()
void expand(T v)
Expands the bounding box if the given Vector v} is outside the current volume.
virtual double Cull(vtkRenderer *ren, vtkProp **propList, int &listLength, int &initialized) override
void fetchHighRes(BoundingBox< BaseVector< float > > bb, std::vector< size_t > indices, std::vector< BaseVector< float >> centroids)
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
void getActors(double planes[24], std::vector< BaseVector< float > > &centroids, std::vector< size_t > &indices)
std::unordered_map< size_t, vtkSmartPointer< vtkActor > > getLowResActors()
LVRChunkedMeshBridge * m_bridge


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:08