From df526bc5a7346ea596645e7dac0259f2dd7d8400 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 21 May 2010 10:41:33 +0000 Subject: [PATCH] fix crash in octree for high-order model-based views --- Geo/GModel.cpp | 9 ++++----- Geo/MElementOctree.cpp | 7 +++---- Plugin/CutGrid.cpp | 2 +- Post/OctreePost.cpp | 6 +++--- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index d91dbfb76e..6b2b35e887 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -99,9 +99,8 @@ static int connected_bounds(std::set<MEdge, Less_Edge> &edges, return boundaries.size(); } -//-------------------------------------------------------------- -static int connectedRegions (std::vector<MElement*> &elements, - std::vector<std::vector<MElement*> > ®ions) +static int connectedRegions(std::vector<MElement*> &elements, + std::vector<std::vector<MElement*> > ®ions) { std::multimap<MEdge,MElement*,Less_Edge> e2e; for (unsigned int i = 0; i < elements.size(); ++i){ @@ -122,11 +121,11 @@ static int connectedRegions (std::vector<MElement*> &elements, return regions.size(); } -//----------------------------------------------------------------------------- GModel::GModel(std::string name) : _name(name), _visible(1), _octree(0), - _geo_internals(0), _occ_internals(0), _acis_internals(0), _fm_internals(0),_factory(0), _fields(0), _currentMeshEntity(0), normals(0) + _geo_internals(0), _occ_internals(0), _acis_internals(0), _fm_internals(0), + _factory(0), _fields(0), _currentMeshEntity(0), normals(0) { partitionSize[0] = 0; partitionSize[1] = 0; list.push_back(this); diff --git a/Geo/MElementOctree.cpp b/Geo/MElementOctree.cpp index 5d71100df4..a1e151adb5 100644 --- a/Geo/MElementOctree.cpp +++ b/Geo/MElementOctree.cpp @@ -47,7 +47,7 @@ static int MElementInEle(void *a, double *x) return e->isInside(uvw[0], uvw[1], uvw[2]) ? 1 : 0; } -Octree *buildMElementOctree (GModel *m) +Octree *buildMElementOctree(GModel *m) { SBoundingBox3d bb = m->bounds(); double min[3] = {bb.min().x(), bb.min().y(), bb.min().z()}; @@ -69,8 +69,8 @@ Octree *buildMElementOctree (GModel *m) Octree *buildMElementOctree(std::vector<MElement*> &v) { SBoundingBox3d bb; - for (unsigned int i=0;i<v.size();i++){ - for(int j=0;j<v[i]->getNumVertices();j++){ + for (unsigned int i = 0; i < v.size(); i++){ + for(int j = 0; j < v[i]->getNumVertices(); j++){ bb += SPoint3(v[i]->getVertex(j)->x(), v[i]->getVertex(j)->y(), v[i]->getVertex(j)->z()); @@ -88,4 +88,3 @@ Octree *buildMElementOctree(std::vector<MElement*> &v) Octree_Arrange(_octree); return _octree; } - diff --git a/Plugin/CutGrid.cpp b/Plugin/CutGrid.cpp index 61417da264..4230432aec 100644 --- a/Plugin/CutGrid.cpp +++ b/Plugin/CutGrid.cpp @@ -299,7 +299,7 @@ PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect) if(getNbU() <= 0 || getNbV() <= 0) return v1; - PViewData *data1 = v1->getData(); + PViewData *data1 = v1->getData(true); // get adaptive data if available PView *v2 = new PView(); PViewDataList *data2 = getDataList(v2); diff --git a/Post/OctreePost.cpp b/Post/OctreePost.cpp index 8850cf7788..7a226a566d 100644 --- a/Post/OctreePost.cpp +++ b/Post/OctreePost.cpp @@ -227,7 +227,7 @@ OctreePost::OctreePost(PView *v) PViewDataList *l = _theViewDataList; if(l->haveInterpolationMatrices() && !_theView->getData()->isAdaptive()){ - Msg::Error("Cannot create octree for non-adapted high-order view: you need"); + Msg::Error("Cannot create octree for non-adapted high-order list-based view: you need"); Msg::Error("to select 'Adapt visualization grid' first"); return; } @@ -351,7 +351,7 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int timestep, MElement *e = (MElement*)in; - int dataIndex[8]; + std::vector<int> dataIndex(e->getNumVertices()); if(_theViewDataGModel->getType() == PViewDataGModel::NodeData) for(int i = 0; i < e->getNumVertices(); i++) dataIndex[i] = e->getVertex(i)->getNum(); @@ -362,7 +362,7 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int timestep, double U[3]; e->xyz2uvw(P, U); - double nodeval[8 * 9]; + std::vector<double> nodeval(e->getNumVertices() * 9); for(int step = 0; step < _theViewDataGModel->getNumTimeSteps(); step++){ if(timestep < 0 || step == timestep){ for(int nod = 0; nod < e->getNumVertices(); nod++){ -- GitLab