From 217ea3fd01c70cdfb02d2360d9c1046d8071a1fd Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 28 Mar 2012 06:16:54 +0000 Subject: [PATCH] fix behavior of OctreePost: should be strict for both old-style and new-style views --- Geo/GModel.cpp | 5 +++-- Geo/GModel.h | 6 +++--- Geo/MElementOctree.cpp | 7 ++++--- Geo/partitionEdge.h | 13 +++++++------ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 279945e4d3..256032c68a 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -736,14 +736,15 @@ int GModel::getNumMeshElements(unsigned c[5]) return 0; } -MElement *GModel::getMeshElementByCoord(SPoint3 &p, int dim) +MElement *GModel::getMeshElementByCoord(SPoint3 &p, int dim, bool strict) { if(!_octree){ Msg::Debug("Rebuilding mesh element octree"); _octree = new MElementOctree(this); } - return _octree->find(p.x(), p.y(), p.z(), dim); + return _octree->find(p.x(), p.y(), p.z(), dim, strict); } + std::vector<MElement*> GModel::getMeshElementsByCoord(SPoint3 &p, int dim) { if(!_octree){ diff --git a/Geo/GModel.h b/Geo/GModel.h index 537d88bd14..257f6da1f1 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -312,8 +312,8 @@ class GModel int getNumMeshElements(unsigned c[5]); // access a mesh element by coordinates (using an octree search) - MElement *getMeshElementByCoord(SPoint3 &p, int dim = -1); - std::vector<MElement*> getMeshElementsByCoord(SPoint3 &p, int dim = -1); + MElement *getMeshElementByCoord(SPoint3 &p, int dim=-1, bool strict=true); + std::vector<MElement*> getMeshElementsByCoord(SPoint3 &p, int dim=-1); // access a mesh element by tag, using the element cache MElement *getMeshElementByTag(int n); @@ -487,7 +487,7 @@ class GModel std::vector<int> &elementary, std::vector<int> &partition); - // for elements cut having new vertices + // for elements cut having new vertices void store(std::vector<MVertex*> &vertices, int dim, std::map<int, std::vector<MElement*> > &entityMap, std::map<int, std::map<int, std::string> > &physicalMap); diff --git a/Geo/MElementOctree.cpp b/Geo/MElementOctree.cpp index fc72e00566..c7e6a94ce8 100644 --- a/Geo/MElementOctree.cpp +++ b/Geo/MElementOctree.cpp @@ -158,7 +158,7 @@ MElement *MElementOctree::find(double x, double y, double z, int dim, bool stric double tol = initialTol; while (tol < 1){ tol *= 10; - MElement::setTolerance(tol); + MElement::setTolerance(tol); std::vector<GEntity*> entities; _gm->getEntities(entities); for(unsigned int i = 0; i < entities.size(); i++){ @@ -168,12 +168,13 @@ MElement *MElementOctree::find(double x, double y, double z, int dim, bool stric if (MElementInEle(e, P)){ MElement::setTolerance(initialTol); return e; - } + } } } } } MElement::setTolerance(initialTol); Msg::Warning("Point %g %g %g not found",x,y,z); - } return NULL; + } + return NULL; } diff --git a/Geo/partitionEdge.h b/Geo/partitionEdge.h index 69437b89d6..d78af1d483 100644 --- a/Geo/partitionEdge.h +++ b/Geo/partitionEdge.h @@ -6,6 +6,7 @@ #ifndef _PARTITION_EDGE_H_ #define _PARTITION_EDGE_H_ +#include <stdio.h> #include "GModel.h" #include "GEdge.h" #include "discreteEdge.h" @@ -14,8 +15,8 @@ class partitionEdge : public discreteEdge { public: std::vector<int> _partitions; public: - partitionEdge(GModel *model, int num, GVertex *_v0, GVertex *_v1, - std::vector<int> &partitions) + partitionEdge(GModel *model, int num, GVertex *_v0, GVertex *_v1, + std::vector<int> &partitions) : discreteEdge(model, num, _v0, _v1), _partitions(partitions) { std::sort(_partitions.begin(), _partitions.end()); @@ -24,15 +25,15 @@ class partitionEdge : public discreteEdge { virtual GeomType geomType() const { return PartitionCurve; } }; -struct Less_partitionEdge : +struct Less_partitionEdge : public std::binary_function<partitionEdge*, partitionEdge*, bool> { bool operator()(const partitionEdge* e1, const partitionEdge* e2) const { - if (e1->_partitions.size() < e2->_partitions.size()) return true; + if (e1->_partitions.size() < e2->_partitions.size()) return true; if (e1->_partitions.size() > e2->_partitions.size()) return false; for (unsigned int i = 0; i < e1->_partitions.size(); i++){ - if (e1->_partitions[i] < e2->_partitions[i]) return true; - if (e1->_partitions[i] > e2->_partitions[i]) return false; + if (e1->_partitions[i] < e2->_partitions[i]) return true; + if (e1->_partitions[i] > e2->_partitions[i]) return false; } return false; } -- GitLab