[cig-commits] commit: Fixing the HistoricalSwarmTrajectory drawing object so that

Mercurial hg at geodynamics.org
Mon Nov 24 11:28:51 PST 2008


changeset:   14:75df473a4d08
user:        CatherineMeriaux
date:        Fri Jun 29 06:28:56 2007 +0000
files:       Base/src/ColourMap.c DrawingObjects/src/HistoricalSwarmTrajectory.c
description:
Fixing the HistoricalSwarmTrajectory drawing object so that
	* it works when you don't provide a colour map
	* it plots all the timesteps that it has recorded (previously it didn't continue to the current timestep)


Changed the function to set the min and max values for the colour map
	There is a tolerance defined that ensures that the max and the min values aren't too close so that you don't divide by zero when setting the colour later. This tolerance was defined in a weird way which didn't work with small max values. Now the tolerance is fixed at 1e-10


Catherine and Rob


diff -r 6b52e7055da8 -r 75df473a4d08 Base/src/ColourMap.c
--- a/Base/src/ColourMap.c	Fri Jun 29 00:43:14 2007 +0000
+++ b/Base/src/ColourMap.c	Fri Jun 29 06:28:56 2007 +0000
@@ -39,7 +39,7 @@
 *+		Patrick Sunter
 *+		Greg Watson
 *+
-** $Id: ColourMap.c 639 2006-11-15 05:29:51Z CecileDuboz $
+** $Id: ColourMap.c 703 2007-06-29 06:28:56Z CatherineMeriaux $
 ** 
 **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
@@ -347,10 +347,9 @@ void lucColourMap_GetColourFromValue_Exp
 
 void lucColourMap_SetMinMax( void* colourMap, double min, double max ) {
 	lucColourMap* self        = colourMap;
-	double        tolerance;
+	double        tolerance   = 1e-10;
 
 	/* Shift max and min if they are too close */
-	tolerance = 0.00005 * (fabs(max)+1);
 	if (fabs(min - max) < tolerance) {	
 		max += 0.5 * tolerance;
 		min -= 0.5 * tolerance;
diff -r 6b52e7055da8 -r 75df473a4d08 DrawingObjects/src/HistoricalSwarmTrajectory.c
--- a/DrawingObjects/src/HistoricalSwarmTrajectory.c	Fri Jun 29 00:43:14 2007 +0000
+++ b/DrawingObjects/src/HistoricalSwarmTrajectory.c	Fri Jun 29 06:28:56 2007 +0000
@@ -39,7 +39,7 @@
 *+		Patrick Sunter
 *+		Greg Watson
 *+
-** $Id: HistoricalSwarmTrajectory.c 628 2006-10-12 08:23:07Z SteveQuenette $
+** $Id: HistoricalSwarmTrajectory.c 703 2007-06-29 06:28:56Z CatherineMeriaux $
 ** 
 **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
@@ -220,9 +220,10 @@ void _lucHistoricalSwarmTrajectory_Setup
 	}
 	self->timeAtStep[ currentTimestep ] = context->currentTime;
 
-	/* Calibrate Colour Map */
-	lucColourMap_SetMinMax( colourMap, self->timeAtStep[ self->startTimestepIndex ], self->timeAtStep[ currentTimestep ] );
-
+ 	/* Calibrate Colour Map */
+	if ( colourMap )
+		lucColourMap_SetMinMax( colourMap, self->timeAtStep[ self->startTimestepIndex ], self->timeAtStep[ currentTimestep ] );
+		
 	/* Store Current position for each time step */
 	for ( lParticle_I = 0 ; lParticle_I < swarm->particleLocalCount ; lParticle_I++ ) {
 		particle    = (GlobalParticle*)Swarm_ParticleAt( swarm, lParticle_I );
@@ -259,6 +260,8 @@ void _lucHistoricalSwarmTrajectory_Build
 
 	lucColour_SetOpenGLColour( &self->colour );
 	glLineWidth( self->lineWidth );
+	
+	glDisable(GL_LIGHTING);
 
 	/* Loop over all particles and draw lines according to where each one has been */
 	for ( lParticle_I = 0 ; lParticle_I < swarm->particleLocalCount ; lParticle_I++ ) {
@@ -266,7 +269,8 @@ void _lucHistoricalSwarmTrajectory_Build
 		particleExt = ExtensionManager_Get( swarm->particleExtensionMgr, particle, self->particleExtHandle );
 
 		glBegin( GL_LINE_STRIP );
-		for ( timestep = self->startTimestepIndex ; timestep != currentTimestep ; ) {
+		timestep = self->startTimestepIndex ;
+		while (True) {
 			coord = particleExt->historyCoordList[ timestep ];
 
 			/* Set the colour from the colour map - if we've passed it in */
@@ -278,6 +282,10 @@ void _lucHistoricalSwarmTrajectory_Build
 				glVertex3f( (float)coord[0], (float)coord[1], offset );
 			else 
 				glVertex3dv( coord );
+				
+			/* Stop the loop when we have arrived a the current timestep */
+			if ( timestep == currentTimestep )
+				break;
 			
 			/* Adjust current timestep counter so that the list of stored coordinates loops over itself */
 			timestep++;
@@ -285,4 +293,5 @@ void _lucHistoricalSwarmTrajectory_Build
 		}
 		glEnd();
 	}
-}
+	glEnable(GL_LIGHTING);
+}



More information about the CIG-COMMITS mailing list