[cig-commits] r4067 - in long/3D/Gale/trunk/src/gLucifer: . DrawingObjects/src

walter at geodynamics.org walter at geodynamics.org
Thu Jul 20 20:08:40 PDT 2006


Author: walter
Date: 2006-07-20 20:08:39 -0700 (Thu, 20 Jul 2006)
New Revision: 4067

Modified:
   long/3D/Gale/trunk/src/gLucifer/
   long/3D/Gale/trunk/src/gLucifer/DrawingObjects/src/SwarmViewer.c
Log:
 r63 at earth (orig r595):  LukeHodkinson | 2006-07-17 23:53:06 -0700
 Fixed a bug causing gLucifer to ignore all the particles
 in a swarm regardless of location.
 



Property changes on: long/3D/Gale/trunk/src/gLucifer
___________________________________________________________________
Name: svk:merge
   - 3433ad49-13df-0310-980d-a6a68cf0952a:/trunk:594
d11c8794-cf10-0410-8271-cb625e597d60:/cig:218
   + 3433ad49-13df-0310-980d-a6a68cf0952a:/trunk:595
d11c8794-cf10-0410-8271-cb625e597d60:/cig:218

Modified: long/3D/Gale/trunk/src/gLucifer/DrawingObjects/src/SwarmViewer.c
===================================================================
--- long/3D/Gale/trunk/src/gLucifer/DrawingObjects/src/SwarmViewer.c	2006-07-21 03:08:34 UTC (rev 4066)
+++ long/3D/Gale/trunk/src/gLucifer/DrawingObjects/src/SwarmViewer.c	2006-07-21 03:08:39 UTC (rev 4067)
@@ -47,8 +47,8 @@
 #include <mpi.h>
 #include <StGermain/StGermain.h>
 #ifdef GLUCIFER_USE_PICELLERATOR
-	#include <StG_FEM/StG_FEM.h>
-	#include <PICellerator/PICellerator.h>
+#include <StG_FEM/StG_FEM.h>
+#include <PICellerator/PICellerator.h>
 #endif
 
 #include <glucifer/Base/Base.h>
@@ -68,46 +68,46 @@
 
 /* Private Constructor: This will accept all the virtual functions for this class as arguments. */
 lucSwarmViewer* _lucSwarmViewer_New( 
-		SizeT                                              sizeOfSelf,
-		Type                                               type,
-		Stg_Class_DeleteFunction*                          _delete,
-		Stg_Class_PrintFunction*                           _print,
-		Stg_Class_CopyFunction*                            _copy, 
-		Stg_Component_DefaultConstructorFunction*          _defaultConstructor,
-		Stg_Component_ConstructFunction*                   _construct,
-		Stg_Component_BuildFunction*                       _build,
-		Stg_Component_InitialiseFunction*                  _initialise,
-		Stg_Component_ExecuteFunction*                     _execute,
-		Stg_Component_DestroyFunction*                     _destroy,
-		lucDrawingObject_SetupFunction*                    _setup,
-		lucDrawingObject_DrawFunction*                     _draw,
-		lucDrawingObject_CleanUpFunction*                  _cleanUp,
-		lucOpenGLDrawingObject_BuildDisplayListFunction*   _buildDisplayList,
-		lucSwarmViewer_PlotParticleFunction*               _plotParticle,
-		lucSwarmViewer_PlotParticleNumberFunction*         _plotParticleNumber,
-		Name                                               name ) 
+	SizeT                                              sizeOfSelf,
+	Type                                               type,
+	Stg_Class_DeleteFunction*                          _delete,
+	Stg_Class_PrintFunction*                           _print,
+	Stg_Class_CopyFunction*                            _copy, 
+	Stg_Component_DefaultConstructorFunction*          _defaultConstructor,
+	Stg_Component_ConstructFunction*                   _construct,
+	Stg_Component_BuildFunction*                       _build,
+	Stg_Component_InitialiseFunction*                  _initialise,
+	Stg_Component_ExecuteFunction*                     _execute,
+	Stg_Component_DestroyFunction*                     _destroy,
+	lucDrawingObject_SetupFunction*                    _setup,
+	lucDrawingObject_DrawFunction*                     _draw,
+	lucDrawingObject_CleanUpFunction*                  _cleanUp,
+	lucOpenGLDrawingObject_BuildDisplayListFunction*   _buildDisplayList,
+	lucSwarmViewer_PlotParticleFunction*               _plotParticle,
+	lucSwarmViewer_PlotParticleNumberFunction*         _plotParticleNumber,
+	Name                                               name ) 
 {
 	lucSwarmViewer*					self;
 
 	/* Call private constructor of parent - this will set virtual functions of parent and continue up the hierarchy tree. At the beginning of the tree it will allocate memory of the size of object and initialise all the memory to zero. */
 	assert( sizeOfSelf >= sizeof(lucSwarmViewer) );
 	self = (lucSwarmViewer*) _lucOpenGLDrawingObject_New( 
-			sizeOfSelf,
-			type, 
-			_delete,
-			_print,
-			_copy,
-			_defaultConstructor,
-			_construct,
-			_build,
-			_initialise,
-			_execute,
-			_destroy,
-			_setup,
-			_draw,
-			_cleanUp,
-			_buildDisplayList,
-			name );
+		sizeOfSelf,
+		type, 
+		_delete,
+		_print,
+		_copy,
+		_defaultConstructor,
+		_construct,
+		_build,
+		_initialise,
+		_execute,
+		_destroy,
+		_setup,
+		_draw,
+		_cleanUp,
+		_buildDisplayList,
+		name );
 
 	self->_plotParticle = _plotParticle;
 	self->_plotParticleNumber = _plotParticleNumber;
@@ -116,22 +116,22 @@
 }
 
 void _lucSwarmViewer_Init( 
-		lucSwarmViewer*                                              self,
-		Swarm*                                                       swarm,
-		Name                                                         colourVariableName,
-		lucColourMap*                                                colourMap,
-		Name                                                         colourName,
-		Name                                                         opacityVariableName,
-		float                                                        pointSize,
-		Name                                                         maskVariableName,
-		lucDrawingObjectMask*                                        mask,
-		Bool                                                         drawParticleNumber,
-		Bool                                                         particleColour,
-		int                                                          subSetEvery,
-		Bool                                                         positionRange,
-		Coord                                                        minPosition,
-		Coord                                                        maxPosition
-)
+	lucSwarmViewer*                                              self,
+	Swarm*                                                       swarm,
+	Name                                                         colourVariableName,
+	lucColourMap*                                                colourMap,
+	Name                                                         colourName,
+	Name                                                         opacityVariableName,
+	float                                                        pointSize,
+	Name                                                         maskVariableName,
+	lucDrawingObjectMask*                                        mask,
+	Bool                                                         drawParticleNumber,
+	Bool                                                         particleColour,
+	int                                                          subSetEvery,
+	Bool                                                         positionRange,
+	Coord                                                        minPosition,
+	Coord                                                        maxPosition
+	)
 {
 	self->swarm               = swarm;
 	self->colourMap           = colourMap;
@@ -219,15 +219,15 @@
 	swarm         =  Stg_ComponentFactory_ConstructByKey(  cf,  self->name,  "Swarm",     Swarm,             True  ) ;
 	
 	/* This drawing object will only work for swarms with Global Particle Layouts 
-	*  HACK - Adding in check for Gauss particle Layout here because this can be global too */
+	 *  HACK - Adding in check for Gauss particle Layout here because this can be global too */
 	Journal_Firewall(
-			swarm->particleLayout->coordSystem == GlobalCoordSystem || Stg_Class_IsInstance( swarm->particleLayout, GaussParticleLayout_Type ),
-			Journal_MyStream( Error_Type, self ),
-			"In func %s, unable to visualise swarm %s because it uses a local coord system layout %s of type %s.\n",
-			__func__,
-			swarm->name,
-			swarm->particleLayout->name,
-			swarm->particleLayout->type );
+		swarm->particleLayout->coordSystem == GlobalCoordSystem || Stg_Class_IsInstance( swarm->particleLayout, GaussParticleLayout_Type ),
+		Journal_MyStream( Error_Type, self ),
+		"In func %s, unable to visualise swarm %s because it uses a local coord system layout %s of type %s.\n",
+		__func__,
+		swarm->name,
+		swarm->particleLayout->name,
+		swarm->particleLayout->type );
 	
 	colourMap     =  Stg_ComponentFactory_ConstructByKey(  cf,  self->name,  "ColourMap", lucColourMap,      False  ) ;
 
@@ -266,21 +266,21 @@
 #endif
 
 	_lucSwarmViewer_Init( 
-			self, 
-			swarm,
-			colourVariableName,
-			colourMap,
-			Stg_ComponentFactory_GetString( cf, self->name, "colour", "black" ),
-			opacityVariableName,
-			(float) Stg_ComponentFactory_GetDouble( cf, self->name, "pointSize", 1.0 ),
-			maskVariableName,
-			&mask,
-			drawParticleNumber,
-			sameParticleColour, 
-			subSetEvery,
-			positionRange,
-		        minPosition,
-			maxPosition);
+		self, 
+		swarm,
+		colourVariableName,
+		colourMap,
+		Stg_ComponentFactory_GetString( cf, self->name, "colour", "black" ),
+		opacityVariableName,
+		(float) Stg_ComponentFactory_GetDouble( cf, self->name, "pointSize", 1.0 ),
+		maskVariableName,
+		&mask,
+		drawParticleNumber,
+		sameParticleColour, 
+		subSetEvery,
+		positionRange,
+		minPosition,
+		maxPosition);
 }
 
 void _lucSwarmViewer_Build( void* drawingObject, void* data ) {}
@@ -293,9 +293,9 @@
 	if ( 0 != strcmp( self->colourVariableName, "" ) ) {
 		self->colourVariable  = SwarmVariable_Register_GetByName( swarmVariable_Register, self->colourVariableName );
 		Journal_Firewall( self->colourVariable != NULL, errorStr,
-					"Error - for gLucifer drawing object \"%s\" - in %s(): colour Variable name given was \"%s\", "
-					"but no corresponding SwarmVariable found in the register for swarm \"%s\".\n",
-					self->name, __func__, self->colourVariableName, self->swarm->name );
+				  "Error - for gLucifer drawing object \"%s\" - in %s(): colour Variable name given was \"%s\", "
+				  "but no corresponding SwarmVariable found in the register for swarm \"%s\".\n",
+				  self->name, __func__, self->colourVariableName, self->swarm->name );
 	}
 	/* TODO : all to fail if no useful value returned, AND a non-zero name given */
 	self->opacityVariable = SwarmVariable_Register_GetByName( swarmVariable_Register, self->opacityVariableName );
@@ -379,7 +379,7 @@
 	glDisable(GL_LIGHTING);
 
 	
- 	 /* Take one of subSetEvery particle */
+	/* Take one of subSetEvery particle */
 		
       	for ( lParticle_I = 0 ; lParticle_I < particleLocalCount ; lParticle_I+=subSetEvery ){
 
@@ -411,32 +411,35 @@
 			particle            = (GlobalParticle*)Swarm_ParticleAt( self->swarm, lParticle_I );
 			coord               = particle->coord;
 
-			if( (coord[0] >= minPosition[I_AXIS] ) && (coord[1] >= minPosition[J_AXIS]) && (coord[0] <= maxPosition[I_AXIS] ) && (coord[1] <= maxPosition[J_AXIS]) )
+			if( (coord[0] < minPosition[I_AXIS] ) || (coord[1] < minPosition[J_AXIS]) || 
+			    (coord[0] > maxPosition[I_AXIS] ) || (coord[1] > maxPosition[J_AXIS]) )
 			{
-				if( ((DiscretisationContext*)_context)->dim == 3){
-					/* check on the third dimension as well */
-					if ( (coord[2] >= minPosition[K_AXIS]) && (coord[2] <= maxPosition[K_AXIS]) ){
-						
-						/* Plot the particle as a point */
-						glBegin(GL_POINTS);
-							lucSwarmViewer_PlotParticle( self, _context, lParticle_I );
-						glEnd();
+				continue;
+			}
 
-						/* Draw the particle number if desired */
-						if( drawParticleNumber ){	
-							if( sameParticleColour ) { /*if the colour is the same than the particle one */
-								lucSwarmViewer_PlotParticleNumber( self, _context, lParticle_I, colour );
-							}
-							else{
-								 lucColour_FromString( &colour, "black" );
-								 lucSwarmViewer_PlotParticleNumber( self, _context, lParticle_I, colour );
-							}
-						}
-					}
-				}
-			}	
-		}		
-	}
+			if( ((DiscretisationContext*)_context)->dim == 3 ) {
+				if( (coord[2] < minPosition[K_AXIS]) || (coord[2] > maxPosition[K_AXIS]) )
+					continue;
+			}
+		}
+
+		/* Plot the particle as a point */
+		glBegin(GL_POINTS);
+		lucSwarmViewer_PlotParticle( self, _context, lParticle_I );
+		glEnd();
+
+		/* Draw the particle number if desired */
+		if( drawParticleNumber ){	
+			if( sameParticleColour ) { /*if the colour is the same than the particle one */
+				lucSwarmViewer_PlotParticleNumber( self, _context, lParticle_I, colour );
+			}
+			else{
+				lucColour_FromString( &colour, "black" );
+				lucSwarmViewer_PlotParticleNumber( self, _context, lParticle_I, colour );
+			}
+		}
+	}	
+
 	/* Put back lighting settings */
 	glEnable(GL_LIGHTING);
 }
@@ -495,7 +498,7 @@
 	/* Find cell this coordinate is in */
 	memcpy( testParticle.coord, coord, sizeof(Coord) );
 	/* First specify the particle doesn't have an owning cell yet, so as
-	not to confuse the search algorithm */
+	   not to confuse the search algorithm */
 	testParticle.owningCell = swarm->cellDomainCount;
 	lCell_I = CellLayout_CellOf( swarm->cellLayout, &testParticle );
 



More information about the cig-commits mailing list