import 'dart:ffi'; import 'package:ffi/ffi.dart'; import 'package:segmentation_douglas_peucker_flutter/dali_point.dart'; import 'package:segmentation_douglas_peucker_flutter/dotnet_exception.dart'; import 'package:segmentation_douglas_peucker_flutter/gen/generated_bindings.dart'; import 'package:segmentation_douglas_peucker_flutter/lib.dart'; abstract class Douglas { static void runExample() { final NativeLibrary nativeLibrary = NativeLibrary(Lib.init('Dali.Segmentation.DouglasPeucker')); final Pointer exception = calloc(); print('Exception allocated ! ($exception)'); final System_Type_t type = nativeLibrary.System_Drawing_Point_TypeOf(); final System_Drawing_Point_t point1 = nativeLibrary.System_Drawing_Point_Create(200, 400, exception); exception.handle(); final DaliPoint daliPoint1 = DaliPoint.fromPointer(point1); print('Point1: $daliPoint1'); final System_Drawing_Point_t point2 = nativeLibrary.System_Drawing_Point_Create(200, 500, exception); exception.handle(); final DaliPoint daliPoint2 = DaliPoint.fromPointer(point2); print('Point2: $daliPoint2'); final System_Drawing_Point_t point3 = nativeLibrary.System_Drawing_Point_Create(200, 600, exception); exception.handle(); final DaliPoint daliPoint3 = DaliPoint.fromPointer(point3); print('Point3: $daliPoint3'); final System_Collections_Generic_List_A1_t points = nativeLibrary.System_Collections_Generic_List_A1_Create_1( type, 3, exception, ); exception.handle(onException: print); print('Points list created ! ($points)'); nativeLibrary.System_Collections_Generic_List_A1_Add( points, type, point1, exception); exception.handle(); print('Point1 added !'); nativeLibrary.System_Collections_Generic_List_A1_Add( points, type, point2, exception); exception.handle(); print('Point2 added !'); nativeLibrary.System_Collections_Generic_List_A1_Add( points, type, point3, exception); exception.handle(); print('Point3 added !'); } }