solution for 4.1b,c
[MicroTrace.git] / Box.cxx
diff --git a/Box.cxx b/Box.cxx
index ef9f750..b1951e4 100644 (file)
--- a/Box.cxx
+++ b/Box.cxx
@@ -1,6 +1,6 @@
 #include "Box.hxx"
 
-Box::Box()
+Box::Box() : m_min(-Infinity), m_max(Infinity)
 {
 }
 
@@ -10,11 +10,15 @@ Box::~Box()
 
 Box::Box(const Box& b)
 {
+  m_min = b.m_min;
+  m_max = b.m_max;
 }
 
 Box&
 Box::operator=(const Box& b)
 {
+  m_min = b.m_min;
+  m_max = b.m_max;
   return *this;
 }
 
@@ -26,9 +30,17 @@ Box::Clear()
 void
 Box::Extend(const Vec3f& a)
 {
+  // for all three coordinates, move m_max or m_min to the point
+  for(size_t i = 0; i < 3; i++) {
+    if(a[i] > m_max[i]) {
+      m_max[i] = a[i];
+    } else if(a[i] < m_min[i]) {
+      m_min[i] = a[i];
+    } // else: do nothing, coordinate is inside the box
+  }
 }
 
-void 
+void
 Box::Extend(const Box& box)
 {
 }
This page took 0.024735 seconds and 4 git commands to generate.