Revision: 41150
http://brlcad.svn.sourceforge.net/brlcad/?rev=41150&view=rev
Author: indianlarry
Date: 2010-10-28 13:10:14 +0000 (Thu, 28 Oct 2010)
Log Message:
-----------
Bit shifting to get index into fieldlength array having problems when sign bit
set. Turned up as an issue with geometry containing large body sizes(large
BOT). Since a "byte" is cast to an "int" for the bit operation the sign bit was
getting extended into the leading three bytes. To resolve I forced all byte
related right bit shifts with the header[] byte array to mask out all but lower
byte of 'int' before shifting. In some places the sign bit was already being
masked out but wanted to apply generally without knowledge of the defined mask.
Modified Paths:
--------------
jbrlcad/trunk/src/org/brlcad/geometry/DbExternalObject.java
Modified: jbrlcad/trunk/src/org/brlcad/geometry/DbExternalObject.java
===================================================================
--- jbrlcad/trunk/src/org/brlcad/geometry/DbExternalObject.java 2010-10-28
02:00:36 UTC (rev 41149)
+++ jbrlcad/trunk/src/org/brlcad/geometry/DbExternalObject.java 2010-10-28
13:10:14 UTC (rev 41150)
@@ -90,7 +90,7 @@
used += 6;
// get the index into the fieldLength array for the object
length
- int objectWidIndex = (byte)(header[1] & OBJECT_WID_MASK) >> 6;
+ int objectWidIndex = (byte)((header[1] & OBJECT_WID_MASK &
0xFF) >> 6);
// get the number of bytes used to store the object length
int objectLengthWidth = fieldLength[objectWidIndex];
@@ -108,7 +108,7 @@
if( (header[1] & NAME_PRESENT) != 0 )
{
// get the index into the fieldLength array for the
name length
- int nameWidIndex = (byte)(header[1] & NAME_WID_MASK) >>
3;
+ int nameWidIndex = (byte)((header[1] & NAME_WID_MASK &
0xFF) >> 3);
// get the number of bytes used to store the name length
int nameLengthWidth = fieldLength[nameWidIndex];
// read the name length
@@ -131,7 +131,7 @@
if( (header[2] & AFLAGS_PRESENT) != 0 )
{
// get the index into the fieldLength array for the
attributes length
- int attWidIndex = (byte)(header[2] & AFLAGS_WID_MASK)
>> 6;
+ int attWidIndex = (byte)((header[2] & AFLAGS_WID_MASK &
0xFF) >> 6);
// get the number of bytes used to store the attribute
length
int attLengthWidth = fieldLength[attWidIndex];
// read the attribute length
@@ -150,7 +150,7 @@
if( (header[3] & BFLAGS_PRESENT) != 0 )
{
// get the index into the fieldLength array for the
body length
- int bodyWidIndex = (byte)(header[3] & BFLAGS_WID_MASK)
>> 6;
+ int bodyWidIndex = (byte)((header[3] & BFLAGS_WID_MASK
& 0xFF) >> 6);
// get the number of bytes used to store the body length
int bodyLengthWidth = fieldLength[bodyWidIndex];
// read the body length
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits