Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r720 - branches/itanium2/Model/Groups


Chronological Thread 
  • From: rocky@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r720 - branches/itanium2/Model/Groups
  • Date: Wed, 23 Nov 2005 09:55:49 -0700 (MST)

Author: rocky
Date: Wed Nov 23 09:55:47 2005
New Revision: 720

Modified:
   branches/itanium2/Model/Groups/KDTree.h
   branches/itanium2/Model/Groups/KDTreeLoader.cc
   branches/itanium2/Model/Groups/TransparentKDTree.h
Log:
Few changes to allow compilation and large model reading on Opteron systems.



Modified: branches/itanium2/Model/Groups/KDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/KDTree.h     (original)
+++ branches/itanium2/Model/Groups/KDTree.h     Wed Nov 23 09:55:47 2005
@@ -302,7 +302,7 @@
 
                        VArray<int> *triToGroupMap;
                        VArray<int> *groupToNameMap;
-                       VArray<unsigned char> *groupNames;
+                       VArray<char> *groupNames;
                        bool __pickingEnabled;
                        bool pickingEnabled;
                        mutable long long pickedTri;

Modified: branches/itanium2/Model/Groups/KDTreeLoader.cc
==============================================================================
--- branches/itanium2/Model/Groups/KDTreeLoader.cc      (original)
+++ branches/itanium2/Model/Groups/KDTreeLoader.cc      Wed Nov 23 09:55:47 
2005
@@ -28,6 +28,12 @@
  DEALINGS IN THE SOFTWARE.
  */
 
+/*
+#define _GNU_SOURCE
+#define _FILE_OFFSET_BITS 64
+#define _LARGEFILE64_SOURCE
+*/
+
 #include <iostream>
 
 
@@ -49,6 +55,23 @@
 using std::cerr;
 using std::endl;
 
+size_t fread_64(void *ptr, size_t size, size_t nitems, FILE *stream)
+{
+       long long chunkSize = 0x7fffffff;
+       long long remaining = size*nitems;
+       while (remaining > 0) {
+               long long toRead = remaining>chunkSize?chunkSize:remaining;
+               long long result;
+               if ((result = fread(ptr, toRead, 1, stream)) != 1) {
+                       fprintf(stderr, "read error: %ld != %ld",
+                                       toRead, result);
+                       return 0;
+               }
+               remaining -= toRead;
+               ptr = (char*)ptr + toRead;
+       }
+       return nitems;
+}
 
 
///////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////
@@ -302,13 +325,13 @@
        // Read in the data.
        double time_begin = Time::currentSeconds();
        
-       long trisRead = fread(rawVertColData, 48, fileSize/48, f);
+       long trisRead = fread_64(rawVertColData, 48, fileSize/48, f);
        if (trisRead != nTris) {
                fprintf(stderr, "Error reading file: %s Tris read: %ld; 
expected: %ld\n", filename, trisRead, nTris);
        }
        
        if(rawNormData) {
-               trisRead = fread(rawNormData, 36, fileSize2/36, f2);
+               trisRead = fread_64(rawNormData, 36, fileSize2/36, f2);
                if (trisRead != nTris) {
                        fprintf(stderr, "Error reading file: %s Tris read: 
%ld; expected: %ld\n", fn, trisRead, nTris);
                }
@@ -428,7 +451,7 @@
        time_begin = Time::currentSeconds();
        
        // Read in the whole tree.
-       long long nread = fread(buffer, 1, fileSize, f);
+       long long nread = fread_64(buffer, 1, fileSize, f);
        if (nread != fileSize) {
                fprintf(stderr, "error reading file %s (size: %lld read: 
%lld)\n",
                                                filename, fileSize, nread);
@@ -489,7 +512,7 @@
        
        // Read in the data.
        time_begin = Time::currentSeconds();
-       nread = fread(indices->getArray(), sizeof(int), nInt, f);
+       nread = fread_64(indices->getArray(), sizeof(int), nInt, f);
        if (nread != nInt) {
                fprintf(stderr, "error reading file %s (size: %lld read: 
%lld)\n",
                                                filename, fileSize, nread);
@@ -547,7 +570,7 @@
        long long nTris = kdtree->tris->getLen(); 
        kdtree->triToGroupMap = new VArray<int>(nTris);
        kdtree->triToGroupMap->setLen(nTris);
-       nread = fread(kdtree->triToGroupMap->getArray(), sizeof(int), nTris, 
f);
+       nread = fread_64(kdtree->triToGroupMap->getArray(), sizeof(int), 
nTris, f);
        if (nread != nTris) {
                fprintf(stderr, "ERROR: error reading .grp file; picking 
disabled\n");
                kdtree->__setPicking(false);
@@ -568,9 +591,9 @@
        fseek(f, 0, SEEK_END);
        fileSize = ftell(f);
        fseek(f, 0, SEEK_SET);
-       kdtree->groupNames = new VArray<unsigned char>(fileSize);
+       kdtree->groupNames = new VArray<char>(fileSize);
        kdtree->groupNames->setLen(fileSize);
-       nread = fread(kdtree->groupNames->getArray(), sizeof(unsigned char), 
fileSize, f);
+       nread = fread_64(kdtree->groupNames->getArray(), sizeof(unsigned 
char), fileSize, f);
 
        kdtree->groupToNameMap = new VArray<int>;
        int groupNum = 0;

Modified: branches/itanium2/Model/Groups/TransparentKDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/TransparentKDTree.h  (original)
+++ branches/itanium2/Model/Groups/TransparentKDTree.h  Wed Nov 23 09:55:47 
2005
@@ -70,7 +70,7 @@
 
       VArray<int> *triToGroupMap;
       VArray<int> *groupToNameMap;
-      VArray<unsigned char> *groupNames;
+      VArray<char> *groupNames;
       bool __pickingEnabled;
       bool pickingEnabled;
       mutable long long pickedTri;
@@ -80,9 +80,9 @@
       unsigned char pickedFlag;
 
     public:
-      const unsigned char *getPickedName() { 
+      const char *getPickedName() { 
        if (pickedTri >= 0) return 
&(groupNames->get(groupToNameMap->get(triToGroupMap->get( pickedTri ))));
-       return (unsigned char *)"No selection";
+       return (char *)"No selection";
       }
       void enablePicking() {
        if (__pickingEnabled)




  • [MANTA] r720 - branches/itanium2/Model/Groups, rocky, 11/23/2005

Archive powered by MHonArc 2.6.16.

Top of page