[cig-commits] commit: Adding in a little bit of a hacky modification

Mercurial hg at geodynamics.org
Mon Nov 24 11:29:32 PST 2008


changeset:   72:9e0442863086
user:        LukeHodkinson
date:        Mon Aug 18 13:55:47 2008 +0000
files:       DrawingObjects/src/ScalarField.c DrawingObjects/src/ScalarField.h
description:
Adding in a little bit of a hacky modification
to the scalar field class to properly draw
2D fields. Now they render with any kind of
distortion and they also make use of element
shape functions to interpolate colors.


diff -r e5000cde5896 -r 9e0442863086 DrawingObjects/src/ScalarField.c
--- a/DrawingObjects/src/ScalarField.c	Mon Aug 18 13:55:00 2008 +0000
+++ b/DrawingObjects/src/ScalarField.c	Mon Aug 18 13:55:47 2008 +0000
@@ -39,7 +39,7 @@
 *+		Patrick Sunter
 *+		Greg Watson
 *+
-** $Id: ScalarField.c 740 2007-10-11 08:05:31Z SteveQuenette $
+** $Id: ScalarField.c 786 2008-08-18 13:55:47Z LukeHodkinson $
 ** 
 **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
@@ -47,6 +47,7 @@
 #include <mpi.h>
 #include <StGermain/StGermain.h>
 #include <StgDomain/StgDomain.h>
+#include <StgFEM/StgFEM.h>
 
 #include <glucifer/Base/Base.h>
 #include <glucifer/RenderingEngines/RenderingEngines.h>
@@ -173,6 +174,8 @@ void _lucScalarField_Construct( void* dr
 	_lucScalarField_Init( 
 			self, 
 			Stg_ComponentFactory_GetBool( cf, self->name, "cullFace", True ) );
+
+        self->useMesh = Stg_ComponentFactory_GetBool( cf, self->name, "useMesh", False );
 }
 
 void _lucScalarField_Build( void* drawingObject, void* data ) {
@@ -227,7 +230,10 @@ void _lucScalarField_BuildDisplayList( v
 
 	
 	if (context->dim == 2) {
-		lucScalarFieldCrossSection_DrawCrossSection( self, 0.0, K_AXIS );
+           if( self->useMesh )
+              lucScalarField_DrawWithMesh( self );
+           else
+              lucScalarFieldCrossSection_DrawCrossSection( self, 0.0, K_AXIS );
 	}
 	else {
 		if ( self->cullFace ) 
@@ -247,3 +253,70 @@ void _lucScalarField_BuildDisplayList( v
 	}
 }
 
+void lucScalarField_DrawWithMesh( lucScalarField* self ) {
+   FeVariable* var = (FeVariable*)self->fieldVariable;
+   FeMesh* mesh = var->feMesh;
+   lucColourMap* cmap = self->colourMap;
+   IArray* inc;
+   double value;
+   int* nodes, nElements, curNode;
+   int nodeMap[4] = {0, 1, 3, 2};
+   double xi[3], vertex[3];
+   int ii, jj, kk;
+
+   lucOpenGLDrawingObject_SyncShadowValues( self, self->fieldVariable );
+   glDisable( GL_LIGHTING );
+   glNormal3f( 0.0, 0.0, 1.0 );
+   glBegin( GL_QUADS );
+   nElements = FeMesh_GetElementLocalSize( mesh );
+   inc = IArray_New();
+   for( ii = 0; ii < nElements; ii++ ) {
+      for( jj = 0; jj < 10; jj++ ) {
+         for( kk = 0; kk < 10; kk++ ) {
+
+            xi[0] = -1.0 + ((double)kk / 10.0) * 2.0;
+            xi[1] = -1.0 + ((double)jj / 10.0) * 2.0;
+            FeVariable_InterpolateWithinElement( var, ii, xi, &value );
+            lucColourMap_SetOpenGLColourFromValue( cmap, value );
+            FeMesh_CoordLocalToGlobal( mesh, ii, xi, vertex );
+            glVertex2dv( vertex );
+
+            xi[0] = -1.0 + ((double)(kk + 1) / 10.0) * 2.0;
+            xi[1] = -1.0 + ((double)jj / 10.0) * 2.0;
+            FeVariable_InterpolateWithinElement( var, ii, xi, &value );
+            lucColourMap_SetOpenGLColourFromValue( cmap, value );
+            FeMesh_CoordLocalToGlobal( mesh, ii, xi, vertex );
+            glVertex2dv( vertex );
+
+            xi[0] = -1.0 + ((double)(kk + 1) / 10.0) * 2.0;
+            xi[1] = -1.0 + ((double)(jj + 1) / 10.0) * 2.0;
+            FeVariable_InterpolateWithinElement( var, ii, xi, &value );
+            lucColourMap_SetOpenGLColourFromValue( cmap, value );
+            FeMesh_CoordLocalToGlobal( mesh, ii, xi, vertex );
+            glVertex2dv( vertex );
+
+            xi[0] = -1.0 + ((double)kk / 10.0) * 2.0;
+            xi[1] = -1.0 + ((double)(jj + 1) / 10.0) * 2.0;
+            FeVariable_InterpolateWithinElement( var, ii, xi, &value );
+            lucColourMap_SetOpenGLColourFromValue( cmap, value );
+            FeMesh_CoordLocalToGlobal( mesh, ii, xi, vertex );
+            glVertex2dv( vertex );
+         }
+      }
+
+#if 0
+      FeMesh_GetElementNodes( mesh, ii, inc );
+      assert( IArray_GetSize( inc ) == 4 );
+      nodes = IArray_GetPtr( inc );
+      for( jj = 0; jj < 4; jj++ ) {
+         curNode = nodes[nodeMap[jj]];
+         FeVariable_GetValueAtNode( var, curNode, &value );
+         lucColourMap_SetOpenGLColourFromValue( cmap, value );
+         glVertex2dv( Mesh_GetVertex( mesh, curNode ) );
+      }
+#endif
+   }
+   NewClass_Delete( inc );
+   glEnd();
+   glEnable(GL_LIGHTING);
+}
diff -r e5000cde5896 -r 9e0442863086 DrawingObjects/src/ScalarField.h
--- a/DrawingObjects/src/ScalarField.h	Mon Aug 18 13:55:00 2008 +0000
+++ b/DrawingObjects/src/ScalarField.h	Mon Aug 18 13:55:47 2008 +0000
@@ -39,7 +39,7 @@
 *+		Patrick Sunter
 *+		Greg Watson
 *+
-** $Id: ScalarField.h 628 2006-10-12 08:23:07Z SteveQuenette $
+** $Id: ScalarField.h 786 2008-08-18 13:55:47Z LukeHodkinson $
 ** 
 **~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
@@ -57,6 +57,7 @@
 		/* Virtual functions go here */ \
 		/* Other info */\
 		Bool                                               cullFace;               \
+                Bool useMesh;
 
 	struct lucScalarField { __lucScalarField };
 	
@@ -97,4 +98,6 @@
 
 	void _lucScalarField_BuildDisplayList( void* drawingObject, void* _context ) ;
 
+	void lucScalarField_DrawWithMesh( lucScalarField* self );
+
 #endif



More information about the CIG-COMMITS mailing list