diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 12cb1140e9a3c99ee2e6138b26dfea562abcc330..3159750e893b1774984b59bdcc79bd0cf3eaca36 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -92,13 +92,24 @@ void GModel::getPhysicalGroups(std::map<int, std::vector<GEntity*> > groups[4]) addInGroup(*it, groups[3]); } -SBoundingBox3d GModel::recomputeBounds() +SBoundingBox3d GModel::bounds() { SBoundingBox3d bb; for(viter it = firstVertex(); it != lastVertex(); ++it) bb += (*it)->bounds(); - boundingBox = bb; - return boundingBox; + + // use the mesh instead of the geometry for now + for(eiter it = firstEdge(); it != lastEdge(); ++it) + for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) + bb += (*it)->mesh_vertices[i]->point(); + for(fiter it = firstFace(); it != lastFace(); ++it) + for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) + bb += (*it)->mesh_vertices[i]->point(); + for(riter it = firstRegion(); it != lastRegion(); ++it) + for(unsigned int i = 0; i < (*it)->mesh_vertices.size(); i++) + bb += (*it)->mesh_vertices[i]->point(); + + return bb; } int GModel::getMeshStatus() diff --git a/Geo/GModel.h b/Geo/GModel.h index 8a348fc08d1f9799e9e2b18e5033071258a64a1e..a600527e30d8ea123bd75421ac1437d54924e4fb 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -79,8 +79,7 @@ class GModel void getPhysicalGroups(std::map<int, std::vector<GEntity*> > groups[4]); // The bounding box - virtual SBoundingBox3d getBounds() { return boundingBox; } - virtual SBoundingBox3d recomputeBounds(); + virtual SBoundingBox3d bounds(); // Returns the mesh status for the entire model. virtual int getMeshStatus(); diff --git a/Geo/GModelIO.cpp b/Geo/GModelIO.cpp index 2bb27d328c7867ffdda95b04c647a2911ca1c44c..3e260ca9867ae954c657ca7e5394747c757e13a2 100644 --- a/Geo/GModelIO.cpp +++ b/Geo/GModelIO.cpp @@ -162,7 +162,6 @@ int GModel::readMSH(const std::string &name) int elementTypes[7] = {LGN1, TRI1, QUA1, TET1, HEX1, PRI1, PYR1}; double version = 1.0; char str[256]; - SBoundingBox3d bbox; std::map<int, MVertex*> vertices; std::map<int, std::vector<MVertex*> > points; std::map<int, std::vector<MElement*> > elements[7]; @@ -195,7 +194,6 @@ int GModel::readMSH(const std::string &name) int num; double x, y, z; fscanf(fp, "%d %lf %lf %lf", &num, &x, &y, &z); - bbox += SPoint3(x, y, z); if(vertices.count(num)) Msg(WARNING, "Skipping duplicate vertex %d", num); else @@ -356,8 +354,6 @@ int GModel::readMSH(const std::string &name) for(int i = 0; i < 4; i++) storePhysicalTagsInEntities(this, i, physicals[i]); - boundingBox += bbox; - fclose(fp); return 1; } @@ -656,8 +652,6 @@ int GModel::readSTL(const std::string &name, double tolerance) face->triangles.push_back(new MTriangle(v[0], v[1], v[2])); } - boundingBox += bbox; - fclose(fp); return 1; } @@ -881,7 +875,6 @@ int GModel::readMESH(const std::string &name) std::map<int, MVertex*> vertices; int elementTypes[2] = {TRI1, QUA1}; std::map<int, std::vector<MElement*> > elements[2]; - SBoundingBox3d bbox; while(!feof(fp)) { fgets(buffer, sizeof(buffer), fp); @@ -900,7 +893,6 @@ int GModel::readMESH(const std::string &name) int cl; double x, y, z; sscanf(buffer, "%lf %lf %lf %d", &x, &y, &z, &cl); - bbox += SPoint3(x, y, z); vertices[i + 1] = new MVertex(x, y, z); } } @@ -944,8 +936,6 @@ int GModel::readMESH(const std::string &name) // store the vertices in their associated geometrical entity storeVerticesInEntities(vertices); - boundingBox += bbox; - fclose(fp); return 1; } diff --git a/Geo/MVertex.h b/Geo/MVertex.h index c1d8efc043fdef7e153022ec9a05910053279799..374b2bc1fc1b72ec2276497c2d05ba71fd297210 100644 --- a/Geo/MVertex.h +++ b/Geo/MVertex.h @@ -3,6 +3,7 @@ #include <stdio.h> #include <algorithm> +#include "SPoint3.h" class GEntity; @@ -39,6 +40,7 @@ class MVertex{ inline double & x() {return _x;} inline double & y() {return _y;} inline double & z() {return _z;} + inline SPoint3 point() { return SPoint3(_x, _y, _z); } // get/set the parent entity inline GEntity* onWhat() const {return _ge;} diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp index 5540ca470e603220d7c2b1da38f64ad4397b5a3a..86a8b407f774a37ec5a448415c7f3301da27bac8 100644 --- a/Parser/OpenFile.cpp +++ b/Parser/OpenFile.cpp @@ -1,4 +1,4 @@ -// $Id: OpenFile.cpp,v 1.108 2006-08-12 18:10:25 geuzaine Exp $ +// $Id: OpenFile.cpp,v 1.109 2006-08-12 18:27:47 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -142,10 +142,7 @@ void SetBoundingBox(void) SBoundingBox3d bb; - bb = GMODEL->getBounds(); - - if(bb.empty()) - bb = GMODEL->recomputeBounds(); + bb = GMODEL->bounds(); if(bb.empty() && List_Nbr(CTX.post.list)) { for(int i = 0; i < List_Nbr(CTX.post.list); i++){ @@ -208,7 +205,6 @@ int ParseFile(char *f, int close, int warn_if_missing) fclose(yyin); GMODEL->import(); - GMODEL->recomputeBounds(); strncpy(yyname, yyname_old, 255); yyin = yyin_old;