From bc987486f50b4a428c29f2b515a7ae4968abfa30 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 27 Oct 2004 20:37:10 +0000
Subject: [PATCH] if we have no geometry and no mesh, use the max of all view
 bounding boxes (instead of the bounding box of the last view only)

---
 Parser/OpenFile.cpp   | 20 +++++++++++++++-----
 doc/texinfo/gmsh.texi |  6 +++---
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp
index a8f4d26789..8e96c78440 100644
--- a/Parser/OpenFile.cpp
+++ b/Parser/OpenFile.cpp
@@ -1,4 +1,4 @@
-// $Id: OpenFile.cpp,v 1.63 2004-10-17 01:53:49 geuzaine Exp $
+// $Id: OpenFile.cpp,v 1.64 2004-10-27 20:37:10 geuzaine Exp $
 //
 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 //
@@ -92,10 +92,20 @@ void SetBoundingBox(void)
     CalculateMinMax(THEM->Points, NULL);
   }
   else if(List_Nbr(CTX.post.list)) {
-    // else, if we have views, use the last one
-    CalculateMinMax(NULL, ((Post_View *) List_Pointer
-                           (CTX.post.list,
-                            List_Nbr(CTX.post.list) - 1))->BBox);
+    // else, if we have views, use the max bb of all the views
+    double bbox[6];
+    Post_View *v = (Post_View *)List_Pointer(CTX.post.list, 0);
+    for(int i = 0; i < 6; i++) bbox[i] = v->BBox[i];
+    for(int i = 1; i < List_Nbr(CTX.post.list); i++){
+      v = (Post_View *)List_Pointer(CTX.post.list, i);
+      if(v->BBox[0] < bbox[0]) bbox[0] = v->BBox[0];
+      if(v->BBox[1] > bbox[1]) bbox[1] = v->BBox[1];
+      if(v->BBox[2] < bbox[2]) bbox[2] = v->BBox[2];
+      if(v->BBox[3] > bbox[3]) bbox[3] = v->BBox[3];
+      if(v->BBox[4] < bbox[4]) bbox[4] = v->BBox[4];
+      if(v->BBox[5] > bbox[5]) bbox[5] = v->BBox[5];
+    }
+    CalculateMinMax(NULL, bbox);
   }
   else {
     // else, use a default bbox
diff --git a/doc/texinfo/gmsh.texi b/doc/texinfo/gmsh.texi
index 9b822d3022..117ad3c0f7 100644
--- a/doc/texinfo/gmsh.texi
+++ b/doc/texinfo/gmsh.texi
@@ -1,5 +1,5 @@
 \input texinfo.tex @c -*-texinfo-*-
-@c $Id: gmsh.texi,v 1.144 2004-10-25 17:02:19 geuzaine Exp $
+@c $Id: gmsh.texi,v 1.145 2004-10-27 20:37:10 geuzaine Exp $
 @c
 @c Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
 @c
@@ -1259,8 +1259,8 @@ point), the bounding box is taken as the box enclosing all the geometrical
 points;
 @item
 If there is no mesh and no geometry, but there are some post-processing
-views, the bounding box is taken as the box enclosing all the primitives of
-the last post-processing view.
+views, the bounding box is taken as the box enclosing all the primitives in
+the views.
 @end enumerate
 
 @item BoundingBox @{ @var{expression}, @var{expression}, @var{expression}, @var{expression}, @var{expression}, @var{expression} @};
-- 
GitLab