From 0938a26a6bdaa917521df333ef6ddeb231cc370b Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 27 Mar 2010 08:07:45 +0000 Subject: [PATCH] don't even try to build octree for list-based datasets that have interpolation matrices (and ask users to select 'Adapt visualization grid' first) --- Common/Octree.cpp | 11 ++++++++--- Geo/GModel.cpp | 2 +- Geo/MElementOctree.cpp | 5 +++++ Post/OctreePost.cpp | 29 +++++++++++++++++++---------- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Common/Octree.cpp b/Common/Octree.cpp index a880fd2da7..055a8ccb34 100644 --- a/Common/Octree.cpp +++ b/Common/Octree.cpp @@ -46,6 +46,7 @@ void free_buckets(octantBucket * bucket) void Octree_Delete(Octree *myOctree) { + if(!myOctree) return; delete myOctree->info; free_buckets(myOctree->root); delete myOctree->root; @@ -54,6 +55,7 @@ void Octree_Delete(Octree *myOctree) void Octree_Insert(void * element, Octree *myOctree) { + if(!myOctree) return; double minBB[3], maxBB[3], centroid[3]; octantBucket *bucket; (*(myOctree->function_BB))(element, minBB, maxBB); @@ -64,7 +66,8 @@ void Octree_Insert(void * element, Octree *myOctree) } void Octree_Arrange(Octree *myOctree) -{ +{ + if(!myOctree) return; std::list<void *>::iterator iter; double minPt[3], maxPt[3]; for(iter = myOctree->info->listAllElements.begin(); iter!= @@ -75,14 +78,16 @@ void Octree_Arrange(Octree *myOctree) myOctree->info->listAllElements.clear(); } -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, 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, myOctree->function_inElement, output); } diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index a0f00bb5d7..cdbd9c3750 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -203,7 +203,7 @@ void GModel::destroyMeshCaches() _vertexMapCache.clear(); _elementVectorCache.clear(); _elementMapCache.clear(); - if(_octree) Octree_Delete(_octree); + Octree_Delete(_octree); _octree = 0; } diff --git a/Geo/MElementOctree.cpp b/Geo/MElementOctree.cpp index fe6e1a0128..b16d8aebbd 100644 --- a/Geo/MElementOctree.cpp +++ b/Geo/MElementOctree.cpp @@ -1,3 +1,8 @@ +// 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 "GModel.h" #include "Octree.h" diff --git a/Post/OctreePost.cpp b/Post/OctreePost.cpp index a70f21228d..8850cf7788 100644 --- a/Post/OctreePost.cpp +++ b/Post/OctreePost.cpp @@ -201,17 +201,19 @@ static void addListOfStuff(Octree *o, std::vector<double> &l, int nbelm) OctreePost::~OctreePost() { - if(_ST) Octree_Delete(_ST); if(_VT) Octree_Delete(_VT); if(_TT) Octree_Delete(_TT); - if(_SQ) Octree_Delete(_SQ); if(_VQ) Octree_Delete(_VQ); if(_TQ) Octree_Delete(_TQ); - if(_SS) Octree_Delete(_SS); if(_VS) Octree_Delete(_VS); if(_TS) Octree_Delete(_TS); - if(_SH) Octree_Delete(_SH); if(_VH) Octree_Delete(_VH); if(_TH) Octree_Delete(_TH); - if(_SI) Octree_Delete(_SI); if(_VI) Octree_Delete(_VI); if(_TI) Octree_Delete(_TI); - if(_SY) Octree_Delete(_SY); if(_VY) Octree_Delete(_VY); if(_TY) Octree_Delete(_TY); + Octree_Delete(_SL); Octree_Delete(_VL); Octree_Delete(_TL); + Octree_Delete(_ST); Octree_Delete(_VT); Octree_Delete(_TT); + Octree_Delete(_SQ); Octree_Delete(_VQ); Octree_Delete(_TQ); + Octree_Delete(_SS); Octree_Delete(_VS); Octree_Delete(_TS); + Octree_Delete(_SH); Octree_Delete(_VH); Octree_Delete(_TH); + Octree_Delete(_SI); Octree_Delete(_VI); Octree_Delete(_TI); + Octree_Delete(_SY); Octree_Delete(_VY); Octree_Delete(_TY); } OctreePost::OctreePost(PView *v) - : _ST(0), _VT(0), _TT(0), _SQ(0), _VQ(0), _TQ(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), + : _SL(0), _VL(0), _TL(0), _ST(0), _VT(0), _TT(0), _SQ(0), _VQ(0), _TQ(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) { _theViewDataGModel = dynamic_cast<PViewDataGModel*>(_theView->getData()); @@ -222,14 +224,21 @@ OctreePost::OctreePost(PView *v) _theViewDataList = dynamic_cast<PViewDataList*>(_theView->getData(true)); 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 size[3] = {bb.max().x() - bb.min().x(), bb.max().y() - bb.min().y(), bb.max().z() - bb.min().z()}; const int maxElePerBucket = 100; // memory vs. speed trade-off - PViewDataList *l = _theViewDataList; _SL = Octree_Create(maxElePerBucket, min, size, linBB, linCentroid, linInEle); addListOfStuff(_SL, l->SL, 6 + 2 * l->getNumTimeSteps()); Octree_Arrange(_SL); -- GitLab