[opengtl-commits] [185] wrap region's intersect and union

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 185
Author:   cyrille
Date:     2008-06-07 08:11:56 +0200 (Sat, 07 Jun 2008)

Log Message:
-----------
wrap region's intersect and union

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt
    trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h
    trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex

Added Paths:
-----------
    trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/
    trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/ImageWrap_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/ImageWrap_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/PixelWrap_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/PixelWrap_p.h
    trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.h


Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt	2008-06-06 21:59:29 UTC (rev 184)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CMakeLists.txt	2008-06-07 06:11:56 UTC (rev 185)
@@ -11,6 +11,10 @@
   Lexer_p.cpp
   Parser_p.cpp
   Types_p.cpp
+# Wrap
+  wrappers/ImageWrap_p.cpp
+  wrappers/PixelWrap_p.cpp
+  wrappers/RegionWrap_p.cpp
     )
 
 # Add the OpenSHIVA library for build

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h	2008-06-06 21:59:29 UTC (rev 184)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Types_p.h	2008-06-07 06:11:56 UTC (rev 185)
@@ -31,14 +31,12 @@
   namespace InternalStructure {
     //---------------------- WARNING ----------------------//
     // Whenever one of the following structures is edited, //
-    // it's llvm declaration must be changed too !         //
+    // it's llvm declaration must be changed too in        //
+    // Types_p.cpp !                                       //
     //---------------------- WARNING ----------------------//
     struct ImageWrap {
       AbstractImage* image;
     };
-    struct RegionWrap {
-      int x, y, width, height;
-    };
     struct PixelWrap {
     };
   }

Added: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/ImageWrap_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/ImageWrap_p.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/ImageWrap_p.cpp	2008-06-07 06:11:56 UTC (rev 185)
@@ -0,0 +1,19 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+


Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/ImageWrap_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/ImageWrap_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/ImageWrap_p.h	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/ImageWrap_p.h	2008-06-07 06:11:56 UTC (rev 185)
@@ -0,0 +1,19 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+


Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/ImageWrap_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/PixelWrap_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/PixelWrap_p.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/PixelWrap_p.cpp	2008-06-07 06:11:56 UTC (rev 185)
@@ -0,0 +1,19 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+


Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/PixelWrap_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/PixelWrap_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/PixelWrap_p.h	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/PixelWrap_p.h	2008-06-07 06:11:56 UTC (rev 185)
@@ -0,0 +1,19 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+


Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/PixelWrap_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.cpp	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.cpp	2008-06-07 06:11:56 UTC (rev 185)
@@ -0,0 +1,47 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "RegionWrap_p.h"
+
+void region_wrap_intersect( RegionWrap* self, const RegionWrap* reg )
+{
+  float s_x2 = self->x + self->width;
+  float s_y2 = self->y + self->height;
+  float r_x2 = reg->x + reg->width;
+  float r_y2 = reg->y + reg->height;
+  
+  if( self->x < reg->x) self->x = reg->x;
+  if( self->y < reg->y) self->y = reg->y;
+  self->width = ( ( s_x2 > r_x2 ) ? r_x2 : s_x2 ) - reg->x;
+  self->height = ( ( s_y2 > r_y2 ) ? r_y2 : s_y2 ) - reg->y;
+}
+
+void region_wrap_union( RegionWrap* self, const RegionWrap* reg )
+{
+  float s_x2 = self->x + self->width;
+  float s_y2 = self->y + self->height;
+  float r_x2 = reg->x + reg->width;
+  float r_y2 = reg->y + reg->height;
+  
+  
+  if( self->x > reg->x) self->x = reg->x;
+  if( self->y > reg->y) self->y = reg->y;
+  self->width = ( ( s_x2 > r_x2 ) ? s_x2 : r_x2 ) - reg->x;
+  self->height = ( ( s_y2 > r_y2 ) ? s_y2 : r_y2 ) - reg->y;
+}


Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.h	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.h	2008-06-07 06:11:56 UTC (rev 185)
@@ -0,0 +1,36 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _REGION_WRAP_P_H_
+#define _REGION_WRAP_P_H_
+
+//---------------------- WARNING ----------------------//
+// Whenever the following structure is edited,         //
+// it's llvm declaration must be changed too in        //
+// Types_p.cpp !                                       //
+//---------------------- WARNING ----------------------//
+
+struct RegionWrap {
+  int x, y, width, height;
+};
+
+void region_wrap_intersect( const RegionWrap& self, const RegionWrap* reg );
+void region_wrap_union( const RegionWrap& self, const RegionWrap* reg );
+
+#endif


Property changes on: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex
===================================================================
--- trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex	2008-06-06 21:59:29 UTC (rev 184)
+++ trunk/OpenGTL/OpenShiva/doc/specification/ShivaSpec.tex	2008-06-07 06:11:56 UTC (rev 185)
@@ -247,16 +247,46 @@
 
 \subsection{Region types}
 
+\begin{verbatim}
+struct Region {
+  float x;
+  float y;
+  float width;
+  float height;
+}
+\end{verbatim}
+
+\subsubsection{Members}
+\paragraph{Intersect}
+The intersect function will intersect the current region with an other region.
+
+\begin{verbatim}
+  Region reg1 = { 0, 0, 2, 2 };
+  Region reg2 = { 1, -1, 3, 2 };
+  reg1.intersect( reg2 );
+  // Now reg1 == { 1, 0, 1, 1 };
+\end{verbatim}
+
+\paragraph{Union}
+The union function will unify the current region with an other region.
+
+\begin{verbatim}
+  Region reg1 = { 0, 0, 2, 2 };
+  Region reg2 = { 1, -1, 3, 2 };
+  reg1.union( reg2 );
+  // Now reg1 == { 0, -1, 4, 2 };
+\end{verbatim}
+
 \section{Special types}
 
 \subsection{Void}
 Functions that do not return a value are declared with the type \verb|void|.
 For instance:
 \begin{verbatim}
- void addition(input int a, input int b, output c)
- {
+void addition(input int a, input int b, output int c)
+{
   c = a + b;
- }
+}
 \end{verbatim} 
 
 \chapter{Function declaration}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/