private static void MethodThatUsesUpMemory() { // Intercept vtkOutputWindow error events: // Kitware.VTK.vtkOutputWindow owi = Kitware.VTK.vtkOutputWindow.GetInstance(); owi.ErrorEvt += new Kitware.VTK.vtkObject.vtkObjectEventHandler( ErrorEvtHandler); // Intercept abort calls in builds that support // _CrtSetReportHook (Debug builds): // SetupReportHook(); // Now.... do some stuff to use up memory pronto: // System.Random r = new System.Random(); Kitware.VTK.vtkPoints pts1 = new Kitware.VTK.vtkPoints(); Kitware.VTK.vtkPoints pts2 = new Kitware.VTK.vtkPoints(); long index = 256; long max = System.Int64.MaxValue; if (System.IntPtr.Size < 8) { max = System.Int32.MaxValue; } while (index < max) { System.Console.Error.WriteLine(System.String.Format( "Inserting at index: {0}", index)); pts1.InsertPoint((int)index, r.NextDouble(), r.NextDouble(), r.NextDouble()); ThrowIfNonZeroReportCount(); pts2.InsertPoint((int)index, r.NextDouble(), r.NextDouble(), r.NextDouble()); ThrowIfNonZeroReportCount(); index = 2 * index; } Kitware.VTK.vtkPolyData p1 = new Kitware.VTK.vtkPolyData(); ThrowIfNonZeroReportCount(); p1.SetPoints(pts1); ThrowIfNonZeroReportCount(); Kitware.VTK.vtkPolyData p2 = new Kitware.VTK.vtkPolyData(); ThrowIfNonZeroReportCount(); p2.SetPoints(pts2); ThrowIfNonZeroReportCount(); }
// Static void method with same signature as "Main" is always // file base name: // /// <summary> /// VTK test Main method /// </summary> public static void vtkPointsTest(string[] args) { // From Common/vtkType.h: // // #define VTK_FLOAT 10 // #define VTK_DOUBLE 11 using (Kitware.VTK.vtkPoints p1 = Kitware.VTK.vtkPoints.New(10)) { System.Console.Error.WriteLine(p1.ToString()); } using (Kitware.VTK.vtkPoints p2 = Kitware.VTK.vtkPoints.New(11)) { System.Console.Error.WriteLine(p2.ToString()); } }
private static void MethodThatUsesUpMemory() { // Intercept vtkOutputWindow error events: // Kitware.VTK.vtkOutputWindow owi = Kitware.VTK.vtkOutputWindow.GetInstance(); owi.ErrorEvt += new Kitware.VTK.vtkObject.vtkObjectEventHandler( ErrorEvtHandler); // Intercept abort calls in builds that support // _CrtSetReportHook (Debug builds): // SetupReportHook(); // Now.... do some stuff to use up memory pronto: // System.Random r = new System.Random(); Kitware.VTK.vtkPoints pts1 = new Kitware.VTK.vtkPoints(); Kitware.VTK.vtkPoints pts2 = new Kitware.VTK.vtkPoints(); long index = 256; long max = System.Int64.MaxValue; if (System.IntPtr.Size < 8) { max = System.Int32.MaxValue; } while (index < max) { System.Console.Error.WriteLine(System.String.Format( "Inserting at index: {0}", index)); pts1.InsertPoint((int) index, r.NextDouble(), r.NextDouble(), r.NextDouble()); ThrowIfNonZeroReportCount(); pts2.InsertPoint((int)index, r.NextDouble(), r.NextDouble(), r.NextDouble()); ThrowIfNonZeroReportCount(); index = 2 * index; } Kitware.VTK.vtkPolyData p1 = new Kitware.VTK.vtkPolyData(); ThrowIfNonZeroReportCount(); p1.SetPoints(pts1); ThrowIfNonZeroReportCount(); Kitware.VTK.vtkPolyData p2 = new Kitware.VTK.vtkPolyData(); ThrowIfNonZeroReportCount(); p2.SetPoints(pts2); ThrowIfNonZeroReportCount(); }