forked from mattjr/structured
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TexturedSource.cpp
94 lines (79 loc) · 3.37 KB
/
TexturedSource.cpp
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
//
// structured - Tools for the Generation and Visualization of Large-scale
// Three-dimensional Reconstructions from Image Data. This software includes
// source code from other projects, which is subject to different licensing,
// see COPYING for details. If this project is used for research see COPYING
// for making the appropriate citations.
// Copyright (C) 2013 Matthew Johnson-Roberson <[email protected]>
//
// This file is part of structured.
//
// structured is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// structured is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with structured. If not, see <http://www.gnu.org/licenses/>.
//
#include "TexturedSource.h"
using namespace SpatialIndex;
using namespace std;
TexturedSource::TexturedSource(Type type, const std::string& filename,const std::string &bbox_file,bool use_tex,bool use_texaux,
float expandByX, float expandByY, float expandByZ): Source(type,filename)
{
std::string mf=filename;
_bbox_file=bbox_file;
utilization=0.7;
capacity=4;
memstore = StorageManager::createNewMemoryStorageManager();
// Create a new storage manager with the provided base name and a 4K page size.
manager = StorageManager::createNewRandomEvictionsBuffer(*memstore, 10, false);
// applies a main memory random buffer on top of the persistent storage manager
// (LRU buffer, etc can be created the same way).
stream = new MyDataStream(_bbox_file,_cameras,expandByX,expandByY,expandByZ);
// Create and bulk load a new RTree with dimensionality 3, using "file" as
// the StorageManager and the RSTAR splitting policy.
id_type indexIdentifier;
tree = RTree::createAndBulkLoadNewRTree(
RTree::BLM_STR, *stream, *manager, utilization, capacity,capacity, 3, SpatialIndex::RTree::RV_RSTAR, indexIdentifier);
// std::cerr << *tree;
//std::cerr << "Buffer hits: " << file->getHits() << std::endl;
//std::cerr << "Index ID: " << indexIdentifier << std::endl;
bool ret = tree->isIndexValid();
if (ret == false){
osg::notify(osg::FATAL) << "ERROR: Structure is invalid!" << std::endl;
}else {
osg::notify(osg::INFO) << "The stucture seems O.K." << std::endl;
}
texAndAux=new osg::Vec4Array;
if(use_tex){
ids=new osg::Vec4Array;
tex.resize(4);
// for(int f=0; tex.size(); f++)
tex[0]=new osg::Vec3Array;
tex[1]=new osg::Vec3Array;
tex[2]=new osg::Vec3Array;
tex[3]=new osg::Vec3Array;
}
}
TexturedSource::TexturedSource(Type type, const std::string& filename): Source(type,filename)
{
}
TexturedSource::~TexturedSource(){
if(_bbox_file.size()){
delete tree;
delete manager;
delete memstore;
delete stream;
}
}
void TexturedSource::intersectsWithQuery(const SpatialIndex::IShape& query, SpatialIndex::IVisitor& v){
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_treeMutex);
tree->intersectsWithQuery(query,v);
}