Skip to content
Snippets Groups Projects
Commit 0938a26a authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

don't even try to build octree for list-based datasets that have interpolation

matrices (and ask users to select 'Adapt visualization grid' first)
parent b4deb5c6
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,7 @@ void free_buckets(octantBucket * bucket) ...@@ -46,6 +46,7 @@ void free_buckets(octantBucket * bucket)
void Octree_Delete(Octree *myOctree) void Octree_Delete(Octree *myOctree)
{ {
if(!myOctree) return;
delete myOctree->info; delete myOctree->info;
free_buckets(myOctree->root); free_buckets(myOctree->root);
delete myOctree->root; delete myOctree->root;
...@@ -54,6 +55,7 @@ void Octree_Delete(Octree *myOctree) ...@@ -54,6 +55,7 @@ void Octree_Delete(Octree *myOctree)
void Octree_Insert(void * element, Octree *myOctree) void Octree_Insert(void * element, Octree *myOctree)
{ {
if(!myOctree) return;
double minBB[3], maxBB[3], centroid[3]; double minBB[3], maxBB[3], centroid[3];
octantBucket *bucket; octantBucket *bucket;
(*(myOctree->function_BB))(element, minBB, maxBB); (*(myOctree->function_BB))(element, minBB, maxBB);
...@@ -65,6 +67,7 @@ void Octree_Insert(void * element, Octree *myOctree) ...@@ -65,6 +67,7 @@ void Octree_Insert(void * element, Octree *myOctree)
void Octree_Arrange(Octree *myOctree) void Octree_Arrange(Octree *myOctree)
{ {
if(!myOctree) return;
std::list<void *>::iterator iter; std::list<void *>::iterator iter;
double minPt[3], maxPt[3]; double minPt[3], maxPt[3];
for(iter = myOctree->info->listAllElements.begin(); iter!= for(iter = myOctree->info->listAllElements.begin(); iter!=
...@@ -77,12 +80,14 @@ void Octree_Arrange(Octree *myOctree) ...@@ -77,12 +80,14 @@ void Octree_Arrange(Octree *myOctree)
void *Octree_Search(double *pt, Octree *myOctree) void *Octree_Search(double *pt, Octree *myOctree)
{ {
if(!myOctree) return 0;
return searchElement(myOctree->root, pt, myOctree->info, return searchElement(myOctree->root, pt, myOctree->info,
myOctree->function_BB, myOctree->function_inElement); myOctree->function_BB, myOctree->function_inElement);
} }
void Octree_SearchAll(double *pt, Octree *myOctree, std::list<void*> *output) void Octree_SearchAll(double *pt, Octree *myOctree, std::list<void*> *output)
{ {
if(!myOctree) return;
searchAllElements(myOctree->root, pt, myOctree->info, myOctree->function_BB, searchAllElements(myOctree->root, pt, myOctree->info, myOctree->function_BB,
myOctree->function_inElement, output); myOctree->function_inElement, output);
} }
...@@ -203,7 +203,7 @@ void GModel::destroyMeshCaches() ...@@ -203,7 +203,7 @@ void GModel::destroyMeshCaches()
_vertexMapCache.clear(); _vertexMapCache.clear();
_elementVectorCache.clear(); _elementVectorCache.clear();
_elementMapCache.clear(); _elementMapCache.clear();
if(_octree) Octree_Delete(_octree); Octree_Delete(_octree);
_octree = 0; _octree = 0;
} }
......
// Gmsh - Copyright (C) 1997-2010 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#include "MElement.h" #include "MElement.h"
#include "GModel.h" #include "GModel.h"
#include "Octree.h" #include "Octree.h"
......
...@@ -201,17 +201,19 @@ static void addListOfStuff(Octree *o, std::vector<double> &l, int nbelm) ...@@ -201,17 +201,19 @@ static void addListOfStuff(Octree *o, std::vector<double> &l, int nbelm)
OctreePost::~OctreePost() OctreePost::~OctreePost()
{ {
if(_ST) Octree_Delete(_ST); if(_VT) Octree_Delete(_VT); if(_TT) Octree_Delete(_TT); Octree_Delete(_SL); Octree_Delete(_VL); Octree_Delete(_TL);
if(_SQ) Octree_Delete(_SQ); if(_VQ) Octree_Delete(_VQ); if(_TQ) Octree_Delete(_TQ); Octree_Delete(_ST); Octree_Delete(_VT); Octree_Delete(_TT);
if(_SS) Octree_Delete(_SS); if(_VS) Octree_Delete(_VS); if(_TS) Octree_Delete(_TS); Octree_Delete(_SQ); Octree_Delete(_VQ); Octree_Delete(_TQ);
if(_SH) Octree_Delete(_SH); if(_VH) Octree_Delete(_VH); if(_TH) Octree_Delete(_TH); Octree_Delete(_SS); Octree_Delete(_VS); Octree_Delete(_TS);
if(_SI) Octree_Delete(_SI); if(_VI) Octree_Delete(_VI); if(_TI) Octree_Delete(_TI); Octree_Delete(_SH); Octree_Delete(_VH); Octree_Delete(_TH);
if(_SY) Octree_Delete(_SY); if(_VY) Octree_Delete(_VY); if(_TY) Octree_Delete(_TY); Octree_Delete(_SI); Octree_Delete(_VI); Octree_Delete(_TI);
Octree_Delete(_SY); Octree_Delete(_VY); Octree_Delete(_TY);
} }
OctreePost::OctreePost(PView *v) OctreePost::OctreePost(PView *v)
: _ST(0), _VT(0), _TT(0), _SQ(0), _VQ(0), _TQ(0), _SS(0), _VS(0), _TS(0), : _SL(0), _VL(0), _TL(0), _ST(0), _VT(0), _TT(0), _SQ(0), _VQ(0), _TQ(0),
_SH(0), _VH(0), _TH(0), _SI(0), _VI(0), _TI(0), _SY(0), _VY(0), _TY(0), _SS(0), _VS(0), _TS(0), _SH(0), _VH(0), _TH(0), _SI(0), _VI(0), _TI(0),
_SY(0), _VY(0), _TY(0),
_theView(v), _theViewDataList(0), _theViewDataGModel(0) _theView(v), _theViewDataList(0), _theViewDataGModel(0)
{ {
_theViewDataGModel = dynamic_cast<PViewDataGModel*>(_theView->getData()); _theViewDataGModel = dynamic_cast<PViewDataGModel*>(_theView->getData());
...@@ -222,14 +224,21 @@ OctreePost::OctreePost(PView *v) ...@@ -222,14 +224,21 @@ OctreePost::OctreePost(PView *v)
_theViewDataList = dynamic_cast<PViewDataList*>(_theView->getData(true)); _theViewDataList = dynamic_cast<PViewDataList*>(_theView->getData(true));
if(_theViewDataList){ if(_theViewDataList){
SBoundingBox3d bb = _theViewDataList->getBoundingBox(); PViewDataList *l = _theViewDataList;
if(l->haveInterpolationMatrices() && !_theView->getData()->isAdaptive()){
Msg::Error("Cannot create octree for non-adapted high-order view: you need");
Msg::Error("to select 'Adapt visualization grid' first");
return;
}
SBoundingBox3d bb = l->getBoundingBox();
double min[3] = {bb.min().x(), bb.min().y(), bb.min().z()}; double min[3] = {bb.min().x(), bb.min().y(), bb.min().z()};
double size[3] = {bb.max().x() - bb.min().x(), double size[3] = {bb.max().x() - bb.min().x(),
bb.max().y() - bb.min().y(), bb.max().y() - bb.min().y(),
bb.max().z() - bb.min().z()}; bb.max().z() - bb.min().z()};
const int maxElePerBucket = 100; // memory vs. speed trade-off const int maxElePerBucket = 100; // memory vs. speed trade-off
PViewDataList *l = _theViewDataList;
_SL = Octree_Create(maxElePerBucket, min, size, linBB, linCentroid, linInEle); _SL = Octree_Create(maxElePerBucket, min, size, linBB, linCentroid, linInEle);
addListOfStuff(_SL, l->SL, 6 + 2 * l->getNumTimeSteps()); addListOfStuff(_SL, l->SL, 6 + 2 * l->getNumTimeSteps());
Octree_Arrange(_SL); Octree_Arrange(_SL);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment