[opengtl-commits] [355] implement needed and changed |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 355
Author: cyrille
Date: 2008-09-03 21:16:59 +0200 (Wed, 03 Sep 2008)
Log Message:
-----------
implement needed and changed
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/wrappers/Allocate.h
trunk/OpenGTL/OpenGTL/GTLCore/wrappers/ArrayWrap.h
trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.h
Modified: trunk/OpenGTL/OpenGTL/GTLCore/wrappers/Allocate.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/wrappers/Allocate.h 2008-09-03 07:29:51 UTC (rev 354)
+++ trunk/OpenGTL/OpenGTL/GTLCore/wrappers/Allocate.h 2008-09-03 19:16:59 UTC (rev 355)
@@ -23,9 +23,9 @@
#include <stdlib.h>
template<class T>
-T* gtlAllocate()
+T* gtlAllocate(int elt = 1)
{
- T* t = (T*)malloc( sizeof(T) );
+ T* t = (T*)malloc( elt * sizeof(T) );
// t.count = 1;
return t;
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/wrappers/ArrayWrap.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/wrappers/ArrayWrap.h 2008-09-03 07:29:51 UTC (rev 354)
+++ trunk/OpenGTL/OpenGTL/GTLCore/wrappers/ArrayWrap.h 2008-09-03 19:16:59 UTC (rev 355)
@@ -17,6 +17,7 @@
* Boston, MA 02110-1301, USA.
*/
+#include "GTLCore/wrappers/Allocate.h"
#include "GTLCore/wrappers/StructWrap.h"
/**
@@ -29,3 +30,30 @@
int size;
void* data;
};
+
+template<class _T_>
+inline ArrayWrap* gtlAllocateArray( int _size )
+{
+ ArrayWrap* arrayWrap = gtlAllocate<ArrayWrap>( );
+ arrayWrap->size = _size;
+ arrayWrap->data = gtlAllocate<_T_>( _size );
+ return arrayWrap;
+}
+
+inline void gtlFreeArray( ArrayWrap* aw )
+{
+ gtlFree( aw->data );
+ gtlFree( aw );
+}
+
+template< typename _T_>
+inline void gtlFreeAllArray( ArrayWrap* aw )
+{
+ _T_ elts = reinterpret_cast<_T_>(aw->data);
+ for( int i = 0; i < aw->size; ++i)
+ {
+ gtlFree( elts[i] );
+ }
+ gtlFree( aw->data );
+ gtlFree( aw );
+}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp 2008-09-03 07:29:51 UTC (rev 354)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Kernel.cpp 2008-09-03 19:16:59 UTC (rev 355)
@@ -193,7 +193,13 @@
GTLCore::Region Kernel::needed( GTLCore::Region output_region, int input_index, const std::list< GTLCore::Region>& input_DOD)
{
- return GTLCore::Region(0,0,0,0);
+ GTLCore::Function* neededFunction = d->moduleData->function( "MyKernel", "needed");
+ RegionWrap* (*func)( RegionWrap*, int, ArrayWrap* ) = ( RegionWrap* (*)( RegionWrap*, int, ArrayWrap* ) )GTLCore::VirtualMachine::instance()->getPointerToFunction( neededFunction, 3);
+ RegionWrap* rwrap = (*func)( regionToRegionWrap( output_region ), input_index, regionListToArrayWrap( input_DOD ) );
+
+ GTLCore::Region region = regionWrapToRegion( rwrap );
+ gtlFree( rwrap );
+ return region;
}
bool Kernel::hasNeededFunction() const
@@ -203,7 +209,13 @@
GTLCore::Region Kernel::changed( GTLCore::Region changed_input_region, int input_index, const std::list< GTLCore::Region>& input_DOD)
{
- return GTLCore::Region(0,0,0,0);
+ GTLCore::Function* changedFunction = d->moduleData->function( "MyKernel", "changed");
+ RegionWrap* (*func)( RegionWrap*, int, ArrayWrap* ) = ( RegionWrap* (*)( RegionWrap*, int, ArrayWrap* ) )GTLCore::VirtualMachine::instance()->getPointerToFunction( changedFunction, 3);
+ RegionWrap* rwrap = (*func)( regionToRegionWrap( changed_input_region ), input_index, regionListToArrayWrap( input_DOD ) );
+
+ GTLCore::Region region = regionWrapToRegion( rwrap );
+ gtlFree( rwrap );
+ return region;
}
bool Kernel::hasChangedFunction() const
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.h 2008-09-03 07:29:51 UTC (rev 354)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/wrappers/RegionWrap_p.h 2008-09-03 19:16:59 UTC (rev 355)
@@ -67,7 +67,13 @@
inline ArrayWrap* regionListToArrayWrap( const std::list<GTLCore::Region> & regions)
{
- return 0;
+ ArrayWrap* array = gtlAllocateArray<RegionWrap*>( regions.size() );
+ RegionWrap* wrapData = reinterpret_cast<RegionWrap*>(array->data);
+ for( std::list<GTLCore::Region>::const_iterator it = regions.begin(); it != regions.end(); ++it, ++wrapData)
+ {
+ wrapData = regionToRegionWrap( *it );
+ }
+ return array;
}