Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r359 - in branches/itanium2: Model/Groups Model/Materials SCIRun/Core
- Date: Tue, 31 May 2005 15:15:25 -0600 (MDT)
Author: abe
Date: Tue May 31 15:15:23 2005
New Revision: 359
Modified:
branches/itanium2/Model/Groups/kdtree.cc
branches/itanium2/Model/Materials/LambertianAlt.cc
branches/itanium2/SCIRun/Core/CMakeLists.txt
Log:
Changes for lighting and performance timers on boeing demo
Modified: branches/itanium2/Model/Groups/kdtree.cc
==============================================================================
--- branches/itanium2/Model/Groups/kdtree.cc (original)
+++ branches/itanium2/Model/Groups/kdtree.cc Tue May 31 15:15:23 2005
@@ -7,9 +7,11 @@
#include "kdtree.h"
#include <Model/Intersections/AxisAlignedBox.h>
+#include <SCIRun/Core/Thread/Time.h>
using namespace Manta;
using namespace Manta::Kdtree;
+using namespace SCIRun;
using std::cerr;
using std::endl;
@@ -51,6 +53,12 @@
int line = 0;
char line_buffer[128];
+ // Begin timer.
+ // Timer timer;
+ // double time;
+
+ // timer.start();
+
// Read in the file.
while (fgets( line_buffer, 127, f ) != NULL) {
@@ -73,6 +81,11 @@
++line;
+ // Done reading in triangles.
+ // time = timer.get_time();
+
+ // std::cout << "Input triangles per second: " <<
(double)triangles / (double)time << std::endl;
+
#if 0
// Get rid of degenerate polygons
if ( SAME_TOL_VEC3V(tri[0], tri[1], 1e-5) ||
@@ -136,11 +149,8 @@
return 1;
}
-int LoadBin_V3C1(const char *filename, VArray<Triangle> **tris,
- // Vec3f **perVertNormals,
- Vectorf **perVertNormals,
- BBox &bounds )
-{
+int LoadBin_V3C1(const char *filename, VArray<Triangle> **tris, /*Vec3f
**perVertNormals,*/ Vectorf **perVertNormals, BBox &bounds ) {
+
FILE *f;
if ((f=fopen(filename, "r")) == NULL) {
fprintf(stderr, "Cannot open file: %s\n", filename);
@@ -149,10 +159,12 @@
fseek(f, 0, SEEK_END);
long fileSize = ftell(f);
+
// One normal followed by 3 vertices
long nTris = fileSize / (12*sizeof(float));
int nFloats = fileSize/4;
float *rawData = new float [fileSize / 4];
+
//
// touch data for good distribution
//
@@ -162,13 +174,24 @@
for (i=0; i<nFloats; i+=1024*4) {
rawData[i] = 0;
}
-
+
fseek(f, 0, SEEK_SET);
+
+ double time_begin = Time::currentSeconds();
+
+ // Read in the data.
long trisRead = fread(rawData, 48, fileSize/48, f);
if (trisRead != nTris) {
fprintf(stderr, "Error reading file: %s Tris read: %ld;
expected: %ld\n", filename, trisRead, nTris);
}
+
+ double time_end = Time::currentSeconds();
+
+ std::cout << "Time to input triangles: " << (time_end-time_begin) <<
" seconds. " << std::endl;
+
+ time_begin = Time::currentSeconds();
+ // Allocate a new array for the triangles.
*tris = new VArray<Triangle> (nTris);
(*tris)->setLen(nTris);
*perVertNormals = new Vectorf [nTris*3];
@@ -184,18 +207,49 @@
Vec3f(_rawData[0], _rawData[1], _rawData[2]);
*/
+ // Check to see if we are on a big endian system
+ // Data was generate on Altix (little endian)
+ if (is_big_endian()) {
+ for (int j=0; j<3; ++j) {
+ (**tris)[i][j] = Pointf( endian_swap(
_rawData[0] ),
+ endian_swap(
_rawData[1] ),
+
endian_swap( _rawData[2]
));
+ _rawData += 3;
+ }
+ }
+ // Otherwise don't swap.
+ else {
+ for (int j=0; j<3; ++j) {
+ (**tris)[i][j] = Pointf( _rawData[0],
_rawData[1], _rawData[2] );
+ _rawData += 3;
+ }
+ }
+
+#if 0
(**tris)[i][0] = Pointf(_rawData[0], _rawData[1],
_rawData[2]);
_rawData += 3;
(**tris)[i][1] = Pointf(_rawData[0], _rawData[1],
_rawData[2]);
_rawData += 3;
(**tris)[i][2] = Pointf(_rawData[0], _rawData[1],
_rawData[2]);
_rawData += 3;
+#endif
+
long r, g, b;
- r = int(_rawData[0] * 255 + .5f);
- g = int(_rawData[1] * 255 + .5f);
- b = int(_rawData[2] * 255 + .5f);
- _rawData += 3;
-
+
+ // Check for big endian data.
+ if (is_big_endian()) {
+ r = int(endian_swap(_rawData[0]) * 255 + .5f);
+ g = int(endian_swap(_rawData[1]) * 255 + .5f);
+ b = int(endian_swap(_rawData[2]) * 255 + .5f);
+ _rawData += 3;
+ }
+ else {
+ r = int(_rawData[0] * 255 + .5f);
+ g = int(_rawData[1] * 255 + .5f);
+ b = int(_rawData[2] * 255 + .5f);
+ _rawData += 3;
+ }
+
(**tris)[i].edge1 = (**tris)[i][1] - (**tris)[i][0];
(**tris)[i].edge2 = (**tris)[i][2] - (**tris)[i][0];
(**tris)[i].payload = ((r<<16)+(g<<8)+b);
@@ -205,10 +259,8 @@
v02 = (**tris)[i][2] - (**tris)[i][0];
(*perVertNormals)[3*i] = Cross(v01, v02).normal();
- (*perVertNormals)[3*i+1] =
- (*perVertNormals)[3*i+2] = (*perVertNormals)[3*i];
+ (*perVertNormals)[3*i+1] = (*perVertNormals)[3*i+2] =
(*perVertNormals)[3*i];
- //
// Update the bounding box of the whole scene
for (long j=0; j<3; j++) {
Triangle &tri = (**tris)[i];
@@ -218,6 +270,10 @@
}
}
+
+ time_end = Time::currentSeconds();
+
+ std::cout << "Time to parse triangles: " << (time_end - time_begin)
<< " seconds." << std::endl;
fprintf(stderr, "Triangles loaded: %d\n", nTris);
delete [] rawData;
Modified: branches/itanium2/Model/Materials/LambertianAlt.cc
==============================================================================
--- branches/itanium2/Model/Materials/LambertianAlt.cc (original)
+++ branches/itanium2/Model/Materials/LambertianAlt.cc Tue May 31 15:15:23
2005
@@ -54,7 +54,7 @@
RayPacket shadowRays(data, 0, rays.getDepth(), 0);
// Send the shadow ray.
- int end = context.shadowAlgorithm->computeShadows(context,
scene->getLights(), rays, start, shadowRays);
+ int end = context.shadowAlgorithm->computeShadows( context,
scene->getLights(), rays, start, shadowRays );
// Normalize the shadow ray directions.
shadowRays.normalizeDirections();
@@ -64,7 +64,7 @@
RayPacket::Element& e = rays.get(i);
Color totalLight(e.ambientLight);
-
+
// Iterate over the shadow ray packet for this ray
(Is this usually one??)
for(int j=e.shadowBegin;j<e.shadowEnd;j++){
RayPacket::Element& s = shadowRays.get(j);
@@ -73,12 +73,13 @@
if(!s.hitInfo.wasHit()){
double cos_theta =
Dot(s.ray.direction(), e.normal);
totalLight += s.light*cos_theta;
+ // totalLight += Color(RGB(1,1,1));
}
}
// Set the result..
- rays.setResult(i, colors[i]*totalLight);
+ rays.setResult( i, colors[i]*totalLight );
}
start = end;
Modified: branches/itanium2/SCIRun/Core/CMakeLists.txt
==============================================================================
--- branches/itanium2/SCIRun/Core/CMakeLists.txt (original)
+++ branches/itanium2/SCIRun/Core/CMakeLists.txt Tue May 31 15:15:23
2005
@@ -23,12 +23,20 @@
)
SET (SCIRUN_SOURCES ${SCIRUN_SOURCES}
+ Thread/CleanupManager.h
Thread/CleanupManager.cc
- Thread/Runnable.cc
+ Thread/Runnable.h
+ Thread/Runnable.cc
+ Thread/Thread.h
Thread/Thread.cc
+ Thread/ThreadError.h
Thread/ThreadError.cc
+ Thread/ThreadGroup.h
Thread/ThreadGroup.cc
+ Thread/WorkQueue.h
Thread/WorkQueue.cc
+ Thread/Time.h
+
)
# If we are using SPROC on IRIX then add these files
@@ -53,6 +61,8 @@
SET (SCIRUN_SOURCES ${SCIRUN_SOURCES}
Util/DebugStream.cc
+ Util/Timer.h
+ Util/Timer.cc
)
ADD_LIBRARY (SCIRun_Core ${SCIRUN_SOURCES})
- [MANTA] r359 - in branches/itanium2: Model/Groups Model/Materials SCIRun/Core, abe, 05/31/2005
Archive powered by MHonArc 2.6.16.