Either I'm not understanding what you mean or you didn't understand my problem.
Here is thescenario:
I have the images in .obj format on the server. These can be compressed there before hand or on the fly using a servlet into the .cg format.
The destination of these images will be an applet. If needed, I could make it a signed applet.
The problem is getting the compressed images to the client, which is the applet. Compressing them at the applet makes no sense to me as the files are not located on the client machine, but across the Internet on my server.
Now, I have used the compressed images in a local test, and the decompression was very fast. It is just the transmission (or more likely the actual reading) of the compressed image that was slow. In fact, I could transmit the uncompressed image 5 times faster than I could transmit the compressed image!
Again, it isn't the decompression that is slow, nor was it the reading of the compressed image off of the server or the transmission speed (local Intranet witha fast network). The problem was somewhere in the applet reading the file. The code for that looked like this:
// Read the compressed geometry.
CompressedGeometry cg = null ;
System.out.println("Creating InputStreamConverter");
RandomAccessFile rafUpper = InputStreamConverter.toRandomAccessFile(urlUpper.openStream());
System.out.println("Creating buffer");
byte[] rafBuffer = new byte[(int)rafUpper.length()];
System.out.println("Reading buffer");
rafUpper.readFully(rafBuffer);
CompressedGeometryFile cgf = new CompressedGeometryFile(rafUpper) ;
if (cgf.getObjectCount() == 0)
{
System.out.println("no objects were found in " + upperArch) ;
System.exit(0) ;
}
cg = cgf.read(0) ;
cgf.close() ;
rafUpper.close();
Shape3D upperShape = new Shape3D(cg);
The support class looked like this:
public class InputStreamConverter
{
public static RandomAccessFile toRandomAccessFile(InputStream is) throws IOException
{
RandomAccessFile raf = new RandomAccessFile(File.createTempFile("isc", "tmp"), "rwd");
byte[] buffer = new byte[2048];
int tmp = 0;
while ((tmp = is.read(buffer)) != -1)
{
raf.write(buffer, 0, tmp);
}
raf.seek(0);
return raf;
}
}
Thanks.
Laurent wrote:
Hello
> Using the Java3D compression mechanism (objtocg) works VERY well as the
> files get down to around 400K to 600K, but the CompressedGeometryFile was
> not written to allow the use of URLs.
Why do you use CompressedGeometryFile at all ?
Create the compressed data as usual. On the client-side use
CompressedGeometry(CompressedGeometryHeader hdr, byte[] compressedGeometry)
to get your data back (CompressedGeometry.decompress(), anyone ?)
> Note that I have tried to create a RandomAccessFile as a temporary File on
> the applet side (using a signed applet) to receive the InputStream from my
> servlet, but the results were slower than sending the uncompressed images
> (much slower in fact).
Uncompressing is not for free. The algo is slow, even with normal
non-temp-files.
cu
-------------- Original message from Laurent Gilson <[EMAIL PROTECTED]>: --------------=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
> Hello
>
> > Using the Java3D compression mechanism (objtocg) works VERY well as the
> > files get down to around 400K to 600K, but the CompressedGeometryFile was
> > not written to allow the use of URLs.
>
> Why do you use CompressedGeometryFile at all ?
>
> Create the compressed data as usual. On the client-side use
> CompressedGeometry(CompressedGeometryHeader hdr, byte[] compressedGeometry)
> to get your data back (CompressedGeometry.decompress(), anyone ?)
>
> > Note that I have tried to create a RandomAccessFile as a temporary File on
> > the applet side (using a signed applet) to receive the InputStream from my
> > servlet, but the results were slower than sending the uncompressed images
> > (much slower in fact).
>
> Uncompressing is not for free. The algo is slow, even with normal
> non-temp-files.
>
> cu
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JAVA3D-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".