Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r686 - in branches/itanium2: Core/Shm Engine/Display Model/Groups Model/Materials StandAlone fox
- Date: Tue, 1 Nov 2005 18:44:01 -0700 (MST)
Author: abe
Date: Tue Nov 1 18:43:57 2005
New Revision: 686
Modified:
branches/itanium2/Core/Shm/MFStreamData.cc
branches/itanium2/Core/Shm/MFStreamData.h
branches/itanium2/Core/Shm/ShmSemaphore.cc
branches/itanium2/Engine/Display/SHMImageDisplay.cc
branches/itanium2/Model/Groups/KDTree.h
branches/itanium2/Model/Materials/CMakeLists.txt
branches/itanium2/StandAlone/v3c1_tools.cc
branches/itanium2/fox/FMantaWindow.cc
branches/itanium2/fox/MediaFusionBridge.cc
branches/itanium2/fox/sc_demo.cc
Log:
Added support for group files during clipping.
M StandAlone/v3c1_tools.cc
Rocky has declared mfe integration "pretty stable".
M Core/Shm/ShmSemaphore.cc
M Core/Shm/MFStreamData.cc
M Core/Shm/MFStreamData.h
M fox/sc_demo.cc
M fox/MediaFusionBridge.cc
M Model/Materials/CMakeLists.txt
M Engine/Display/SHMImageDisplay.cc
Disabled the traverser and sampler menus.
M fox/FMantaWindow.cc
M Model/Groups/KDTree.h
Modified: branches/itanium2/Core/Shm/MFStreamData.cc
==============================================================================
--- branches/itanium2/Core/Shm/MFStreamData.cc (original)
+++ branches/itanium2/Core/Shm/MFStreamData.cc Tue Nov 1 18:43:57 2005
@@ -51,6 +51,40 @@
#define PERM_FILE ( S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
S_IWOTH )
+void MFStreamData::write_lock( int index ) {
+
+ int val = semaphore.get_value( index );
+ while (val != LOCK_OPEN) {
+ Time::waitUntil( Time::currentSeconds() + 0.0001 );
+ val = semaphore.get_value( index );
+ }
+
+ semaphore.wait( index );
+}
+
+void MFStreamData::write_unlock( int index ) {
+
+ semaphore.post( index );
+}
+
+void MFStreamData::read_lock( int index ) {
+
+ int val = semaphore.get_value( index );
+ while (val == LOCK_WRITING) {
+ Time::waitUntil( Time::currentSeconds() + 0.0001 );
+ val = semaphore.get_value( index );
+ }
+
+ semaphore.post( index );
+}
+
+void MFStreamData::read_unlock( int index ) {
+
+ semaphore.try_wait( index );
+}
+
+
+
void *MFStreamData::operator new( size_t /*bytes*/, int key_, int flag ) {
int id;
@@ -150,15 +184,7 @@
void MFStreamData::swap_buffers() {
- // Wait for the memory to be open for writting and then lock it.
- int val = semaphore.get_value( SEMAPHORE_PIXEL );
- while (val == 1) {
- usleep( 1000 );
- val = semaphore.get_value( SEMAPHORE_PIXEL );
- }
-
- // Decrement the semaphore to 0.
- semaphore.post( SEMAPHORE_PIXEL );
+ write_lock( SEMAPHORE_PIXEL );
// Switch the back and front buffers.
backBuffer = !backBuffer;
@@ -167,8 +193,7 @@
// Increment the counter variable.
counter++;
- // Increment the semaphore to 1, unlock the shm.
- semaphore.wait( SEMAPHORE_PIXEL );
+ write_unlock( SEMAPHORE_PIXEL );
}
void MFStreamData::draw_pixels( const Image *image ) {
@@ -201,14 +226,7 @@
void MFStreamData::read_commands( MFSPacket &packet ) {
- // Wait until the semaphore is available
- int val = semaphore.get_value( SEMAPHORE_CMD );
- while( val == 1 ) {
- usleep( 1000 );
- val = semaphore.get_value( SEMAPHORE_CMD );
- }
-
- semaphore.post( SEMAPHORE_CMD );
+ write_lock( SEMAPHORE_CMD );
// Copy the current commands out of the shm segment.
// Nigel: what locking is necessary.
@@ -224,7 +242,7 @@
// Set the internal counter back to zero.
numSSCMD = 0;
- semaphore.wait( SEMAPHORE_CMD );
+ write_unlock( SEMAPHORE_CMD );
}
Modified: branches/itanium2/Core/Shm/MFStreamData.h
==============================================================================
--- branches/itanium2/Core/Shm/MFStreamData.h (original)
+++ branches/itanium2/Core/Shm/MFStreamData.h Tue Nov 1 18:43:57 2005
@@ -104,6 +104,14 @@
/////////////////////////////////////////////////////////////////////////////
+ // Helper functions.
+ void write_lock ( int index );
+ void write_unlock( int index );
+ void read_lock ( int index ); // Appear not to be used by mfe example
code.
+ void read_unlock ( int index );
+
+
/////////////////////////////////////////////////////////////////////////////
+
struct MFSPacket {
public:
enum {
Modified: branches/itanium2/Core/Shm/ShmSemaphore.cc
==============================================================================
--- branches/itanium2/Core/Shm/ShmSemaphore.cc (original)
+++ branches/itanium2/Core/Shm/ShmSemaphore.cc Tue Nov 1 18:43:57 2005
@@ -39,6 +39,7 @@
#include <sys/sem.h>
#include <errno.h>
+#include <iostream>
#define PERM_FILE ( S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
S_IWOTH )
@@ -63,11 +64,10 @@
// Set the semaphore value.
for (int i=0;i<set_size_;++i) {
arg.val = init_val_;
- if (semctl( id, 0, SETVAL, arg ) == -1) {
+ if (semctl( id, i, SETVAL, arg ) == -1) {
throw new ErrnoException( "Cannot set shm semaphore value ", errno,
__FILE__, __LINE__ );
}
}
-
}
void ShmSemaphore::operator delete( void *this_ptr ) {
Modified: branches/itanium2/Engine/Display/SHMImageDisplay.cc
==============================================================================
--- branches/itanium2/Engine/Display/SHMImageDisplay.cc (original)
+++ branches/itanium2/Engine/Display/SHMImageDisplay.cc Tue Nov 1 18:43:57
2005
@@ -102,11 +102,15 @@
// Check to see if this processor should display the image.
if (context.proc == 0) {
+ // std::cerr << "Before swap buffers" << std::endl;
+
// Copy the image to shared memory.
stream_data->draw_pixels( image );
// Swap the shm buffer.
stream_data->swap_buffers();
+
+ // std::cerr << "After swap buffers" << std::endl;
}
}
Modified: branches/itanium2/Model/Groups/KDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/KDTree.h (original)
+++ branches/itanium2/Model/Groups/KDTree.h Tue Nov 1 18:43:57 2005
@@ -374,6 +374,7 @@
struct ScratchPadInfo {
Vector normal; // Normal of the intersected face.
Color payload; // Payload of the intersected face.
+ Real a, b, c;
};
virtual ~KDTree() {}
Modified: branches/itanium2/Model/Materials/CMakeLists.txt
==============================================================================
--- branches/itanium2/Model/Materials/CMakeLists.txt (original)
+++ branches/itanium2/Model/Materials/CMakeLists.txt Tue Nov 1 18:43:57
2005
@@ -24,4 +24,6 @@
Materials/NormalMaterial.cc # Shade the material using it's normal.
Materials/AmbientOcclusion.h
Materials/AmbientOcclusion.cc
+ # Materials/WireframeMaterial.h
+ # Materials/WireframeMaterial.cc
)
Modified: branches/itanium2/StandAlone/v3c1_tools.cc
==============================================================================
--- branches/itanium2/StandAlone/v3c1_tools.cc (original)
+++ branches/itanium2/StandAlone/v3c1_tools.cc Tue Nov 1 18:43:57 2005
@@ -113,6 +113,7 @@
vector<nv3_face> in_buffer;
vector<v3c1_face> out_buffer;
vector<vertex_normals> normal_buffer;
+vector<int> group_buffer;
// Objects containing global results
BBox bounds;
@@ -690,30 +691,65 @@
void v3c1_clip( const char *file_name, const Point &plane_point, const
Vector &plane_normal ) {
- // Open the data file.
- FILE *in_file = fopen( file_name, "r" );
- if (!in_file) {
- perror( "Could not open data file." );
- return;
- }
-
- // Determine the file size.
- fseek( in_file, 0, SEEK_END );
- long file_size = ftell( in_file );
- fseek( in_file, 0, SEEK_SET );
-
- // Determine the total number of faces in this file.
- long file_faces = file_size / (sizeof(v3c1_face));
-
- // Output number of faces.
- if ((file_size % sizeof(v3c1_face)) != 0) {
- printf( "%s size %d is not a multiple of sizeof(v3c1_face)
(%d)\n",
- file_name, (int)file_size,
(int)sizeof(v3c1_face) );
- }
- else {
- printf( "%s faces: %d\n", file_name, (int)file_faces );
- }
-
+ // Open the data file.
+ FILE *in_file = fopen( file_name, "r" );
+ if (!in_file) {
+ perror( "Could not open data file." );
+ return;
+ }
+
+ // Determine the file size.
+ fseek( in_file, 0, SEEK_END );
+ long file_size = ftell( in_file );
+ fseek( in_file, 0, SEEK_SET );
+
+ // Determine the total number of faces in this file.
+ long file_faces = file_size / (sizeof(v3c1_face));
+
+ // Output number of faces.
+ if ((file_size % sizeof(v3c1_face)) != 0) {
+ printf( "%s size %d is not a multiple of sizeof(v3c1_face) (%d)\n",
+ file_name, (int)file_size, (int)sizeof(v3c1_face) );
+ }
+ else {
+ printf( "%s faces: %d\n", file_name, (int)file_faces );
+ }
+
+
////////////////////////////////////////////////////////////////////////////
+ // Determine group file name.
+ char group_file_name[64];
+ sprintf( group_file_name, "%s.grp", file_name );
+ printf( "Checking for group file: %s\n", group_file_name );
+
+ FILE *group_file = 0;
+ bool use_groups = true;
+ if ((group_file = fopen( group_file_name, "r" )) == 0) {
+ perror( "Could not find group file." );
+ use_groups = false;
+ }
+
+ // Check to make sure the group file is the correct size.
+ int file_groups = 0;
+ if (use_groups) {
+ fseek( group_file, 0, SEEK_END );
+ file_size = ftell( group_file );
+ fseek( group_file, 0, SEEK_SET );
+
+ // Check for incomplete data.
+ if ((file_size % (sizeof(int))) != 0) {
+ printf( "%s size %d is not a multiple of sizeof(int) (%d)\n",
+ group_file_name, (int)file_size, (int)(sizeof(int)) );
+ }
+
+ // Check for matching number of groups.
+ file_groups = file_size / sizeof(int);
+ if ((file_faces) != file_groups) {
+ printf( "%s contains %d groups which does not match %d faces\n",
+ group_file_name, file_groups, (int)file_faces );
+ }
+ }
+
+
////////////////////////////////////////////////////////////////////////////
// Determine normal file name.
char normal_file_name[64];
sprintf( normal_file_name, "%s.nor", file_name );
@@ -726,40 +762,60 @@
perror( "Could not find normal file.");
use_normals = false;
}
-
+
// Check to make sure there are the correct number of normals.
int file_normals = 0;
if (use_normals) {
fseek( normal_file, 0, SEEK_END );
file_size = ftell( normal_file );
fseek( normal_file, 0, SEEK_SET );
-
+
// Check for incomplete data.
if ((file_size % (sizeof(Vectorf)*3)) != 0) {
printf( "%s size %d is not a multiple of 3*sizeof(Vectorf) (%d)\n",
- normal_file_name, (int)file_size, (int)(3*sizeof(Vectorf)) );
+ normal_file_name, (int)file_size, (int)(3*sizeof(Vectorf)) );
}
-
+
// Check for matching number of normals.
file_normals = file_size / sizeof(Vectorf);
if ((file_faces*3) != file_normals) {
printf( "%s contains %d normals which does not match %d faces *3\n",
- normal_file_name, file_normals, (int)file_faces );
+ normal_file_name, file_normals, (int)file_faces );
}
}
-
- // Read in the data.
- out_buffer.resize( file_faces );
- fread( &out_buffer[0], sizeof(v3c1_face), file_faces, in_file );
- fclose( in_file );
-
+
+ ////////////////////////////////////////////////////////////////////
+ // Read in the data.
+
+ // Faces
+ out_buffer.resize( file_faces );
+ fread( &out_buffer[0], sizeof(v3c1_face), file_faces, in_file );
+ fclose( in_file );
+
+ // Groups
+ FILE *out_group_file;
+ if (use_groups) {
+ // Read in the groups.
+ group_buffer.resize( file_faces );
+ fread( &group_buffer[0], sizeof(int), file_faces, group_file );
+ fclose( group_file );
+
+ sprintf( group_file_name, "%s.grp", output_file_name );
+
+ // Open group output file.
+ if ((out_group_file = fopen( group_file_name, "w" )) == 0) {
+ perror( "Could not open group output file for writing\n" );
+ }
+ }
+
+ // Normals
FILE *out_normal_file;
if (use_normals) {
// Read in the normals.
normal_buffer.resize( file_faces );
fread( &normal_buffer[0], sizeof(vertex_normals), file_faces,
normal_file );
fclose( normal_file );
-
+
sprintf( normal_file_name, "%s.nor", output_file_name );
// Open normal output file.
@@ -768,47 +824,61 @@
}
}
- // Copy the faces into the output buffer.
- for (int i=0;i<file_faces;++i) {
-
- bool not_clipped = true;
-
- // Compare the face to the cutting plane.
- for (int f=0;f<3;++f) {
-
- // Check to see if this vertex is on the back side of
the plane.
- Point vertex( out_buffer[i].vertex(f)[0],
- out_buffer[i].vertex(f)[1],
-
out_buffer[i].vertex(f)[2] );
-
- // Determine if the triangle should be added.
- not_clipped = not_clipped &&
(Dot((vertex-plane_point),plane_normal) < 0.0);
-
- }
-
- // Output the face if it is not clipped.
- if (not_clipped) {
-
- // Compare the face to the cutting plane.
- for (int f=0;f<3;++f) {
-
- // Check to see if this vertex is on the back
side of the plane.
- Point vertex( out_buffer[i].vertex(f)[0],
-
out_buffer[i].vertex(f)[1],
-
out_buffer[i].vertex(f)[2] );
-
- bounds.extendByPoint( vertex );
- }
-
+ /////////////////////////////////////////////////////////////////////
+ // Copy the faces into the output buffer.
+ for (int i=0;i<file_faces;++i) {
+
+ bool not_clipped = true;
+
+ // Compare the face to the cutting plane.
+ for (int f=0;f<3;++f) {
+
+ // Check to see if this vertex is on the back side of the plane.
+ Point vertex( out_buffer[i].vertex(f)[0],
+ out_buffer[i].vertex(f)[1],
+ out_buffer[i].vertex(f)[2] );
+
+ // Determine if the triangle should be added.
+ not_clipped = not_clipped && (Dot((vertex-plane_point),plane_normal) <
0.0);
+
+ }
+
+ // Output the face if it is not clipped.
+ if (not_clipped) {
+
+ // Compare the face to the cutting plane.
+ for (int f=0;f<3;++f) {
+
+ // Check to see if this vertex is on the back side of the plane.
+ Point vertex( out_buffer[i].vertex(f)[0],
+ out_buffer[i].vertex(f)[1],
+ out_buffer[i].vertex(f)[2] );
+
+ bounds.extendByPoint( vertex );
+ }
+
// Output the face.
- ++total_faces;
- fwrite( &out_buffer[i], sizeof( v3c1_face ), 1,
out_file );
-
+ ++total_faces;
+ fwrite( &out_buffer[i], sizeof( v3c1_face ), 1, out_file );
+
if (use_normals) {
- // Output the normals.
- fwrite( &normal_buffer[i], sizeof(vertex_normals), 1,
out_normal_file );
+ // Output the normals.
+ fwrite( &normal_buffer[i], sizeof(vertex_normals), 1, out_normal_file
);
}
- }
- }
+
+ if (use_groups) {
+ // Output the group.
+ fwrite( &group_buffer[i], sizeof(int), 1, out_group_file );
+ }
+ }
+ }
+
+ if (use_normals) {
+ fclose( out_normal_file );
+ }
+
+ if (use_groups) {
+ fclose( out_group_file );
+ }
}
Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc (original)
+++ branches/itanium2/fox/FMantaWindow.cc Tue Nov 1 18:43:57 2005
@@ -116,7 +116,7 @@
new FXMenuCommand( shadow_menu, "Hard Shadows", 0, this,
ID_HARD_SHADOWS );
new FXMenuCommand( shadow_menu, "No Shadows", 0, this, ID_NO_SHADOWS
);
new FXMenuCommand( shadow_menu, "Enter Text...", 0, this,
ID_TEXT_SHADOWS );
- new FXMenuTitle ( menu_bar, "Shadows", 0, shadow_menu );
+ // new FXMenuTitle ( menu_bar, "Shadows", 0, shadow_menu );
// Sampler menu.
sampler_menu = new FXMenuPane( this );
@@ -125,7 +125,7 @@
new FXMenuCommand( sampler_menu, "Jitter 4 Samples", 0, this,
ID_JITTER4_SAMPLER );
new FXMenuCommand( sampler_menu, "Jitter 8 Samples", 0, this,
ID_JITTER8_SAMPLER );
new FXMenuCommand( sampler_menu, "Enter Text...", 0, this,
ID_TEXT_SAMPLER );
- new FXMenuTitle( menu_bar, "Samplers", 0, sampler_menu );
+ // new FXMenuTitle( menu_bar, "Samplers", 0, sampler_menu );
// Traverser Menu.
traverser_menu = new FXMenuPane( this );
@@ -133,7 +133,7 @@
new FXMenuCommand( traverser_menu, "Frameless", 0, this,
ID_FRAMELESS_TRAVERSER );
new FXMenuCommand( traverser_menu, "Dissolve Tiled", 0, this,
ID_DISSOLVETILED_TRAVERSER );
new FXMenuCommand( traverser_menu, "Enter Text...", 0, this,
ID_TEXT_TRAVERSER );
- new FXMenuTitle( menu_bar, "Traversers", 0, traverser_menu );
+ // new FXMenuTitle( menu_bar, "Traversers", 0, traverser_menu );
// Options menu.
options_menu = new FXMenuPane( this );
@@ -731,8 +731,10 @@
std::cout << "Could not select pixel sampler " <<
text << std::endl;
}
}
- catch (IllegalArgument e) {
- std::cout << "Caught IllegalArgument exception" <<
std::endl;
+ catch (SCIRun::Exception &e) {
+ std::cout << "Caught exception:"
+ << e.message()
+ << std::endl;
};
}
@@ -749,6 +751,11 @@
}
catch (IllegalArgument e) {
std::cout << "Caught IllegalArgument exception" <<
e.message() << std::endl;
+ }
+ catch (SCIRun::Exception &e) {
+ std::cout << "Caught exception:"
+ << e.message()
+ << std::endl;
};
}
Modified: branches/itanium2/fox/MediaFusionBridge.cc
==============================================================================
--- branches/itanium2/fox/MediaFusionBridge.cc (original)
+++ branches/itanium2/fox/MediaFusionBridge.cc Tue Nov 1 18:43:57 2005
@@ -99,28 +99,35 @@
// Begin polling the shm segment.
for (;;) {
+ // std::cerr << "Before read commands" << std::endl;
+
// Read commands from the stream.
stream_data->read_commands( packet );
+ // std::cerr << "After read commands" << std::endl;
+
+
// Find the next command that we have not processed in the packet.
int i = 0;
- while ((packet.index[i] <= last_index) && (i < packet.size)) {
-
+ // while ((packet.index[i] <= last_index) && (i < packet.size)) {
+#if 0
std::cerr << "Stale command in packet: " << packet.index[i]
<< " last index: " << last_index
<< std::endl;
-
- ++i;
- }
+#endif
+ // ++i;
+ // }
// Process the command.
- for (int i=0;i<packet.size;++i) {
+ for (;i<packet.size;++i) {
// Check to see if we have missed any commands.
+#if 0
if (packet.index[i] != (last_index+1)) {
std::cerr << "Warning missed command: " << last_index
<< " -> " << packet.index[i] << std::endl;
}
+#endif
last_index = packet.index[i];
// std::cerr << "Received command from media fusion" << std::endl;
Modified: branches/itanium2/fox/sc_demo.cc
==============================================================================
--- branches/itanium2/fox/sc_demo.cc (original)
+++ branches/itanium2/fox/sc_demo.cc Tue Nov 1 18:43:57 2005
@@ -201,6 +201,29 @@
manta_interface->setScene( createDefaultScene() );
}
+ Object *root_object = manta_interface->getScene()->getObject();
+
+ // Check to see if the camera should be automatically positioned.
+ if (default_camera == "auto") {
+
+ // Find the bounds of the model.
+ BBox bounds;
+ PreprocessContext context;
+ root_object->computeBounds( context, bounds );
+
+ Point lookat = bounds[0] + (bounds[1] - bounds[0]) * 0.5;
+ Point eye = lookat + Vector( 0, bounds.diagonal().length(), 0 );
+ Vector up( 0, 0, 1 );
+
+ ostringstream oss;
+ oss << "pinhole( -eye " << eye << " -lookat " << lookat << " -up " << up
<< " -fov 60 )";
+
+ default_camera = oss.str();
+
+ std::cerr << "Auto camera: " << default_camera << std::endl;
+ }
+
+
// Check to see if a bookmark file was specified.
if (bookmark_file_name.size() > 0) {
@@ -266,10 +289,7 @@
if (use_stereo) {
manta_window.addExtraOptionsDialog( "Stereo", new FMantaStereoDialog(
&manta_window, "Stereo" ));
}
-
- // Check to see if the default scene was a kdtree.
- Object *root_object = manta_interface->getScene()->getObject();
-
+
/////////////////////////////////////////////////////////////////////////////
// Create any necessary dialogs now since everything else should be
initialized.
KDTree *kdtree = 0;
- [MANTA] r686 - in branches/itanium2: Core/Shm Engine/Display Model/Groups Model/Materials StandAlone fox, abe, 11/01/2005
Archive powered by MHonArc 2.6.16.