package org.jcae.opencascade.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import org.jcae.opencascade.jni.*;

/** Test native stream */
public class NativeStream
{
	public static void main(String[] args)
	{
		try
		{
			TopoDS_Shape shape=new BRepPrimAPI_MakeSphere(new double[]{1,1,1}, 1).shape();
			File f=File.createTempFile("occjava", "brep");
			f.deleteOnExit();
			FileChannel c = new FileOutputStream(f).getChannel();
			BRepTools.write(shape, c);
			c.close();
			TopoDS_Shape s=new TopoDS_Shape();
			BRepTools.read(new TopoDS_Shape(),
				new FileInputStream(f).getChannel(),new BRep_Builder());
			TopoDS_Solid solid=(TopoDS_Solid)TopoDS_Shape.downcast(s);
		}
		catch(IOException ex)
		{
			ex.printStackTrace();
		}
	}
}

@@ -181,16 +181,55 @@
 hannel;%0A
+import org.jcae.opencascade.Utilities;%0A
 import o
@@ -255,16 +255,16 @@
 .jni.*;%0A
-
 %0A/** Tes
@@ -662,47 +662,57 @@
 %0A%09%09%09
-BRepTools.read(new TopoDS_Shape(),%0A%09%09%09%09
+System.out.println(%22read%22);%0A%09%09%09BRepTools.read(s, 
 new 
@@ -771,66 +771,292 @@
 %0A%09%09%09
-TopoDS_Solid solid=(TopoDS_Solid)TopoDS_Shape.downcast(s);
+Utilities.dumpTopology(s);%0A%09%09%09%0A%09%09%09//Test reading an empty brep file%0A%09%09%09s=new TopoDS_Shape();%0A%09%09%09f=File.createTempFile(%22occjava%22, %22brep%22);%0A%09%09%09f.deleteOnExit();%0A%09%09%09c = new FileInputStream(f).getChannel();%0A%09%09%09System.out.println(BRepTools.read(s, c, new BRep_Builder()));%0A%09%09%09c.close();%09%09%09
 %0A%09%09%7D

Test reading empty stream