freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Freepooma-devel] Shrink.h completed implementation


From: Arno Candel
Subject: [Freepooma-devel] Shrink.h completed implementation
Date: Sun, 28 Nov 2004 19:58:08 +0100
User-agent: Mozilla Thunderbird 0.8 (X11/20041020)

Hi,
I added the missing implementations for the Domain operations shrinkLeft() and growLeft(). They had been advertised, but not implemented yet ;-)

/** @file
* @ingroup Domain
* @brief
* Interval<Dim> shrinking and growing on either side by int or Loc<Dim>.
*
* Examples:
* - shrinkRight(Interval<1>(0, 4), 1) == Interval<1>(0, 3)
* - growLeft(Interval<1>(0, 4), 1) == Interval<1>(-1, 4)
*/

Arno
Index: Shrink.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Domain/Shrink.h,v
retrieving revision 1.9
diff -u -r1.9 Shrink.h
--- Shrink.h    1 Nov 2004 18:16:32 -0000       1.9
+++ Shrink.h    28 Nov 2004 18:56:37 -0000
@@ -21,6 +21,8 @@
 // function:
 // shrinkRight
 // growRight
+// shrinkLeft
+// growLeft
 //-----------------------------------------------------------------------------
 
 #ifndef POOMA_DOMAIN_SHRINK_H
@@ -146,6 +148,97 @@
   return growRightInPlace(ret, s);
 }
 
+/// Deprecated. Use shrinkLeft().
+template<int Dim>
+Interval<Dim> &
+shrinkLeftInPlace(Interval<Dim> &dom, const Loc<Dim> &s)
+{
+  for (int d = 0; d < Dim; ++d)
+    {
+      int a = dom[d].first() + s[d].first();
+      int b = dom[d].last();
+      dom[d] = Interval<1>(a, b);
+    }
+  return dom;
+}
+
+/// Deprecated. Use shrinkLeft().
+template<int Dim>
+Interval<Dim> &
+shrinkLeftInPlace(Interval<Dim> &dom, int s)
+{
+  for (int d = 0; d < Dim; ++d)
+    {
+      int a = dom[d].first() + s;
+      int b = dom[d].last();
+      dom[d] = Interval<1>(a, b);
+    }
+  return dom;
+}
+
+/// Deprecated. Use growLeft().
+template<int Dim>
+Interval<Dim> &
+growLeftInPlace(Interval<Dim> &dom, const Loc<Dim> &s)
+{
+  for (int d = 0; d < Dim; ++d)
+    {
+      int a = dom[d].first() - s[d].first();
+      int b = dom[d].last();
+      dom[d] = Interval<1>(a, b);
+    }
+  return dom;
+}
+
+/// Deprecated. Use growLeft().
+template<int Dim>
+Interval<Dim> &
+growLeftInPlace(Interval<Dim> &dom, int s)
+{
+  for (int d = 0; d < Dim; ++d)
+    {
+      int a = dom[d].first() - s;
+      int b = dom[d].last();
+      dom[d] = Interval<1>(a, b);
+    }
+  return dom;
+}
+
+/// Shrinks the Interval dom from the right by s[i] in direction i.
+template<int Dim>
+inline Interval<Dim> 
+shrinkLeft(const Interval<Dim> &dom, const Loc<Dim> &s)
+{
+  Interval<Dim> ret(dom);
+  return shrinkLeftInPlace(ret, s);
+}
+
+/// Shrinks the Interval dom from the right by s in every direction.
+template<int Dim>
+inline Interval<Dim> 
+shrinkLeft(const Interval<Dim> &dom, int s)
+{
+  Interval<Dim> ret(dom);
+  return shrinkLeftInPlace(ret, s);
+}
+
+/// Grows the Interval dom to the right by s[i] in direction i.
+template<int Dim>
+inline Interval<Dim> 
+growLeft(const Interval<Dim> &dom, const Loc<Dim> &s)
+{
+  Interval<Dim> ret(dom);
+  return growLeftInPlace(ret, s);
+}
+
+/// Grows the Interval dom to the right by s in every direction.
+template<int Dim>
+inline Interval<Dim> 
+growLeft(const Interval<Dim> &dom, int s)
+{
+  Interval<Dim> ret(dom);
+  return growLeftInPlace(ret, s);
+}
 
 //////////////////////////////////////////////////////////////////////
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]