Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r1834 - in trunk: Model/Readers include


Chronological Thread 
  • From: brownlee@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [Manta] r1834 - in trunk: Model/Readers include
  • Date: Wed, 7 Nov 2007 17:37:09 -0700 (MST)

Author: brownlee
Date: Wed Nov  7 17:37:09 2007
New Revision: 1834

Added:
   trunk/include/TeemConfig.h.CMakeTemplate
Removed:
   trunk/Model/Readers/VolumeNRRD-stub.cc
   trunk/Model/Readers/VolumeNRRD.cc
Modified:
   trunk/Model/Readers/CMakeLists.txt
   trunk/Model/Readers/VolumeNRRD.h
   trunk/include/CMakeLists.txt
Log:
fixed volume code not compiling correctly on Macs

Modified: trunk/Model/Readers/CMakeLists.txt
==============================================================================
--- trunk/Model/Readers/CMakeLists.txt  (original)
+++ trunk/Model/Readers/CMakeLists.txt  Wed Nov  7 17:37:09 2007
@@ -7,6 +7,7 @@
   Readers/PlyReader.cc
   Readers/V3C1.h
   Readers/V3C1.cc
+  Readers/VolumeNRRD.h
   )
 
 
@@ -14,25 +15,6 @@
 IF (APPLE)
   INCLUDE_DIRECTORIES(/usr/include/malloc/)
 ENDIF (APPLE)
-
-IF(FOUND_TEEM)
-  SET(Manta_Readers_SRCS
-    ${Manta_Readers_SRCS}
-    Readers/VolumeNRRD.h
-    Readers/VolumeNRRD.cc
-    )
-  INCLUDE_DIRECTORIES(${TEEM_INCLUDE_DIRS})
-  SET(Manta_Model_extra_libs ${Manta_Model_extra_libs}
-    ${TEEM_LIBRARY}                                   
-    )
-ELSE (FOUND_TEEM)
-  SET(Manta_Readers_SRCS
-    ${Manta_Readers_SRCS}
-    Readers/VolumeNRRD.h
-    Readers/VolumeNRRD-stub.cc
-    )
-ENDIF(FOUND_TEEM)
-
 
 # Reader for NRRD particle data
 IF(BUILD_NRRDPARTICLES)

Modified: trunk/Model/Readers/VolumeNRRD.h
==============================================================================
--- trunk/Model/Readers/VolumeNRRD.h    (original)
+++ trunk/Model/Readers/VolumeNRRD.h    Wed Nov  7 17:37:09 2007
@@ -7,14 +7,105 @@
 #ifndef VOLUMENRRD_H
 #define VOLUMENRRD_H
 
+#include <TeemConfig.h>
 #include <Model/Groups/GriddedGroup.h>
 #include <iostream>
+#if HAVE_TEEM
+#include <teem/nrrd.h>
+#endif
 using namespace std;
 
 namespace Manta
 {
+#if HAVE_TEEM
 template<class T>
-GridArray3<T>* loadNRRDToGrid(string file);
+               GridArray3<T>* loadNRRDToGrid(string file)
+{
+       GridArray3<T>* grid = new GridArray3<T>();
+       cout << "READING NRRD: " << file << " ";
+       Nrrd *new_nrrd = nrrdNew();
+       
////////////////////////////////////////////////////////////////////////////
+    // Attempt to open the nrrd
+       if (nrrdLoad( new_nrrd, file.c_str(), 0 )) {
+               char *reason = biffGetDone( NRRD );
+               std::cout << "WARNING Loading Nrrd Failed: " << reason << 
std::endl;
+               exit(__LINE__);
+       }
+
+    // Check to make sure the nrrd is the proper dimensions.
+       if (new_nrrd->dim != 3) {
+               std::cout << "WARNING Nrrd must three dimension RGB" << 
std::endl;
+               exit(__LINE__);
+       }
+        
+    // Check that the nrrd is the correct type.
+    //  if (new_nrrd->type != nrrdTypeFloat) {
+    //          std::cout << "WARNING Nrrd must be type nrrdTypeDouble" << 
std::endl;
+    //          exit(__LINE__);
+    //  }
+        
+    // Check that the nrrd could be a RGBA volume.
+    //  if (new_nrrd->axis[0].size != 3) {
+    //          std::cout << "WARNING Nrrd first axis must be RGB size 3." 
<< std::endl;
+    //          exit(__LINE__);
+    //  }
+
+    //Determine scaling for the volume.
+       Vector size( new_nrrd->axis[0].size * new_nrrd->axis[0].spacing,
+                                        new_nrrd->axis[1].size * 
new_nrrd->axis[1].spacing,
+                                        new_nrrd->axis[2].size * 
new_nrrd->axis[2].spacing );
+       size = Vector(new_nrrd->axis[0].size, new_nrrd->axis[1].size, 
new_nrrd->axis[2].size);
+       cout << "size: " << size.x() << " " << size.y() << " " << size.z() << 
endl;
+    // Rescale.
+       float max_dim = max( size.x(), max( size.y(), size.z() ) );
+       cout << "resizing\n";
+       size /= max_dim;
+        
+    //_minBound = -size/2.0;
+    //_maxBound = size/2.0;
+       cout << "resizing grid\n";      
+       grid->resize(new_nrrd->axis[0].size, new_nrrd->axis[1].size, 
new_nrrd->axis[2].size);
+       cout << "copying nrrd data\n";
+       for(int i=0; i<grid->getNz(); i++)
+               for(int j=0; j<grid->getNy(); j++)
+                       for(int k=0; k<grid->getNx(); k++)
+       {
+            //(*grid)(k,j,i) = 0.0;
+            //(*grid)(k,j,i) = (*dataPtr)++;
+            //void* vd = (void *) (&(idata[((i*ny + j)*nx + k) * 
formatSize]));
+               if (new_nrrd->type == nrrdTypeFloat)
+                       (*grid)(k,j,i) = 
((float*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+               else if (new_nrrd->type == nrrdTypeChar)
+                       (*grid)(k,j,i) = 
((char*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+               else if (new_nrrd->type == nrrdTypeDouble)
+                       (*grid)(k,j,i) = 
((double*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+               else if (new_nrrd->type == nrrdTypeUChar)
+                       (*grid)(k,j,i) = ((unsigned 
char*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+               else if (new_nrrd->type == nrrdTypeShort)
+                       (*grid)(k,j,i) = 
((short*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+               else if (new_nrrd->type == nrrdTypeUShort)
+                       (*grid)(k,j,i) = ((unsigned 
short*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+               else if (new_nrrd->type == nrrdTypeInt)
+                       (*grid)(k,j,i) = 
((int*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+               else if (new_nrrd->type == nrrdTypeUInt)
+                       (*grid)(k,j,i) = ((unsigned 
int*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+            //                          if (new_nrrd->type == nrrdTypeLong)
+            //                                  (*grid)(k,j,i) = 
((long*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+            //                          if (new_nrrd->type == nrrdTypeULong)
+            //                                  (*grid)(k,j,i) = ((unsigned 
long*)new_nrrd->data)[(int)(((i*grid->getNy() + j)*grid->getNx() + k))];
+       }
+       cout << "done\n";
+       return grid;
+}
+#else
+template<class T>
+               GridArray3<T>* loadNRRDToGrid(string file)
+{
+       cerr << "Error: " << __FILE__ << ": please link Manta with TEEM\n";   
  
+       return new GridArray3<T>();
+}
+#endif
+
 }
 
 #endif

Modified: trunk/include/CMakeLists.txt
==============================================================================
--- trunk/include/CMakeLists.txt        (original)
+++ trunk/include/CMakeLists.txt        Wed Nov  7 17:37:09 2007
@@ -52,6 +52,20 @@
   ${CMAKE_BINARY_DIR}/include/MantaSSE.h
   )
 
+###############################################################################
+## Configure TeemConfig.h
+
+IF(FOUND_TEEM)
+  SET(FOUND_TEEM_DEF "1" CACHE INTERNAL "Turn on Teem code")
+ELSE(FOUND_TEEM)
+  SET(FOUND_TEEM_DEF "0" CACHE INTERNAL "Turn off Teem code")
+ENDIF(FOUND_TEEM)
+
+CONFIGURE_FILE(
+  ${CMAKE_CURRENT_SOURCE_DIR}/TeemConfig.h.CMakeTemplate
+  ${CMAKE_BINARY_DIR}/include/TeemConfig.h
+  )
+
 
 
###############################################################################
 ## Configure UseStatsCollector.h
@@ -128,4 +142,4 @@
 CONFIGURE_FILE(
   ${CMAKE_CURRENT_SOURCE_DIR}/MachineParameters.h.CmakeTemplate
   ${CMAKE_BINARY_DIR}/include/MachineParameters.h
-  )
\ No newline at end of file
+  )

Added: trunk/include/TeemConfig.h.CMakeTemplate
==============================================================================
--- (empty file)
+++ trunk/include/TeemConfig.h.CMakeTemplate    Wed Nov  7 17:37:09 2007
@@ -0,0 +1,38 @@
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef TEEMCONFIG_H
+#define TEEMCONFIG_H
+
+#if ${FOUND_TEEM_DEF}
+#define HAVE_TEEM 1
+#else
+#define HAVE_TEEM 0
+#endif
+
+#endif




  • [Manta] r1834 - in trunk: Model/Readers include, brownlee, 11/07/2007

Archive powered by MHonArc 2.6.16.

Top of page