[cig-commits] commit: initial commit of OutputVECTOR

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


changeset:   53:d287d3173f35
user:        JohnMansour
date:        Mon Apr 21 03:17:44 2008 +0000
files:       OutputFormats/src/OutputVECTOR.c OutputFormats/src/OutputVECTOR.h OutputFormats/src/OutputVECTOR.meta
description:
initial commit of OutputVECTOR


diff -r 01954931d565 -r d287d3173f35 OutputFormats/src/OutputVECTOR.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OutputFormats/src/OutputVECTOR.c	Mon Apr 21 03:17:44 2008 +0000
@@ -0,0 +1,241 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+** Copyright (c) 2005, Monash Cluster Computing 
+** All rights reserved.
+** Redistribution and use in source and binary forms, with or without modification,
+** are permitted provided that the following conditions are met:
+**
+** 		* Redistributions of source code must retain the above copyright notice, 
+** 			this list of conditions and the following disclaimer.
+** 		* Redistributions in binary form must reproduce the above copyright 
+**			notice, this list of conditions and the following disclaimer in the 
+**			documentation and/or other materials provided with the distribution.
+** 		* Neither the name of the Monash University nor the names of its contributors 
+**			may be used to endorse or promote products derived from this software 
+**			without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
+** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
+** BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
+** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+**
+** Contact:
+*%		Cecile Duboz - Cecile.Duboz at sci.monash.edu.au
+*%
+** Contributors:
+*+		Cecile Duboz
+*+		Robert Turnbull
+*+		Alan Lo
+*+		Louis Moresi
+*+		David Stegman
+*+		David May
+*+		Stevan Quenette
+*+		Patrick Sunter
+*+		Greg Watson
+*+
+** 
+** 
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+#ifdef HAVE_GL2PS
+
+#include <gl2ps.h>
+#include <mpi.h>
+
+#include <StGermain/StGermain.h>
+#include <StgDomain/StgDomain.h>
+
+#include <glucifer/Base/Base.h>
+
+#include "types.h"
+#include "OutputVECTOR.h"
+
+#include <assert.h>
+#include <string.h>
+
+
+/* Textual name of this class - This is a global pointer which is used for times when you need to refer to class and not a particular instance of a class */
+const Type lucOutputVECTOR_Type = "lucOutputVECTOR";
+
+/* Private Constructor: This will accept all the virtual functions for this class as arguments. */
+lucOutputVECTOR* _lucOutputVECTOR_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,
+		lucOutputFormat_OutputFunction*                    _output,
+		Name                                               name ) 
+{
+	lucOutputVECTOR*					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(lucOutputVECTOR) );
+	self = (lucOutputVECTOR*) _lucOutputFormat_New( 
+			sizeOfSelf,
+			type, 
+			_delete,
+			_print,
+			_copy,
+			_defaultConstructor,
+			_construct,
+			_build,
+			_initialise,
+			_execute,
+			_destroy,
+			_output,
+			name );
+	
+	return self;
+}
+
+void _lucOutputVECTOR_Init( lucOutputVECTOR* self, Stg_ComponentFactory* cf ){
+	Name		 formatName;
+	Index		 buffersize;
+
+	formatName = Stg_ComponentFactory_GetString( cf, self->name, "Format", "ps" );
+
+	if ( strcasecmp( formatName, "ps" ) == 0 ) {
+		self->format            = "ps";
+		self->gl2psFormatIndex = GL2PS_PS;
+	}
+	else if ( strcasecmp( formatName, "eps" ) == 0 ) {
+		self->format            = "eps";
+		self->gl2psFormatIndex = GL2PS_EPS;
+	}
+	else if ( strcasecmp( formatName, "svg" ) == 0 ) {
+		self->format            = "svg";
+		self->gl2psFormatIndex = GL2PS_SVG;
+	}
+	else if ( strcasecmp( formatName, "pdf" ) == 0 ) {
+		self->format            = "pdf";
+		self->gl2psFormatIndex = GL2PS_PDF;
+	}
+	else
+	Journal_Firewall( 
+			False,
+			Journal_MyStream( Error_Type, self ),
+			"\n Error:  Vector image output format '%s' appears to be incorrect or is unsupported. \n \n \
+			 Supported formats are: \n \
+			    svg  -  scalable vector graphics\n \
+			    ps   -  postscript \n \
+			    eps  -  encapsulated postscript \n \
+			    pdf  -  portable document format \n \n", \
+			formatName);	
+
+	buffersize = Stg_ComponentFactory_GetInt( cf, self->name, "Buffersize", 4096*4096 );
+	self->buffersize = buffersize;
+}
+
+void _lucOutputVECTOR_Delete( void* outputFormat ) {
+	lucOutputVECTOR*  self = (lucOutputVECTOR*)outputFormat;
+
+	_lucOutputFormat_Delete( self );
+}
+
+void _lucOutputVECTOR_Print( void* outputFormat, Stream* stream ) {
+	lucOutputVECTOR*  self = (lucOutputVECTOR*)outputFormat;
+
+	_lucOutputFormat_Print( self, stream );
+}
+
+void* _lucOutputVECTOR_Copy( void* outputFormat, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap) {
+	lucOutputVECTOR*  self = (lucOutputVECTOR*)outputFormat;
+	lucOutputVECTOR* newOutputFormat;
+
+	newOutputFormat = _lucOutputFormat_Copy( self, dest, deep, nameExt, ptrMap );
+
+	/* TODO */
+	abort();
+
+	return (void*) newOutputFormat;
+}
+
+
+void* _lucOutputVECTOR_DefaultNew( Name name ) {
+	return (void*) _lucOutputVECTOR_New(
+		sizeof(lucOutputVECTOR),
+		lucOutputVECTOR_Type,
+		_lucOutputVECTOR_Delete,
+		_lucOutputVECTOR_Print,
+		NULL,
+		_lucOutputVECTOR_DefaultNew,
+		_lucOutputVECTOR_Construct,
+		_lucOutputVECTOR_Build,
+		_lucOutputVECTOR_Initialise,
+		_lucOutputVECTOR_Execute,
+		_lucOutputVECTOR_Destroy,
+		_lucOutputVECTOR_Output,
+		name );
+}
+
+void _lucOutputVECTOR_Construct( void* outputFormat, Stg_ComponentFactory* cf, void* data ){
+	lucOutputVECTOR*  self = (lucOutputVECTOR*)outputFormat;
+
+	_lucOutputVECTOR_Init( self, cf );
+	
+	/* Construct Parent */
+	lucOutputFormat_InitAll( self, self->format);
+	
+}
+
+void _lucOutputVECTOR_Build( void* outputFormat, void* data ) {}
+void _lucOutputVECTOR_Initialise( void* outputFormat, void* data ) {}
+void _lucOutputVECTOR_Execute( void* outputFormat, void* data ) {}
+void _lucOutputVECTOR_Destroy( void* outputFormat, void* data ) {}
+
+void _lucOutputVECTOR_Output( void* outputFormat, lucWindow* window, AbstractContext* context, lucPixel* pixelData ) {
+	lucOutputVECTOR* self       = (lucOutputVECTOR*) outputFormat;
+	Pixel_Index   width        = window->width;
+	Pixel_Index   height       = window->height;
+	/*FILE*         file         = fopen("test", "wb"); */
+	FILE*         file         = lucOutputFormat_OpenFile( self, window, context, "wb");
+	GLint         viewport[4];
+	GLint         state;
+	Name          filename;
+
+	viewport[0] = 0;
+	viewport[1] = 0;
+	viewport[2] = width;
+	viewport[3] = height;
+	
+	/* get filename for file headers */	
+	filename = lucOutputFormat_GetImageFilename( self, window, context );
+	/* remove directory from output filename */
+	filename = (filename + strlen(context->outputPath) + 1);
+
+	/* call to gl2ps which sets up glRenderMode(GL_FEEDBACK) and parses feedback to required format */
+	gl2psBeginPage(filename, "gLucifer", viewport, self->gl2psFormatIndex, GL2PS_SIMPLE_SORT,GL2PS_NONE,  
+		 GL_RGBA, 0, NULL, 0, 0, 0, self->buffersize, file, NULL);
+	
+	/* cleanup pre-existing scene (which was possibly used for current timestep raster images) */
+	lucWindow_CleanUp( window, context );
+	/* setup scene to be rendered again now that feedback mode is enabled */
+	lucWindow_SetViewportNeedsToSetupFlag( window, True );
+	lucWindow_SetViewportNeedsToDrawFlag( window, True );
+	lucWindow_Draw( window, context );
+
+	/* return to glRenderMode(GL_RENDER), and complete writing output file */
+	state = gl2psEndPage();
+	if(state == 5)
+		Journal_Printf( Journal_MyStream( Error_Type, self ), "\nError. Insufficient GL feedback buffer size. \ 
+								       \nConsider increasing the OutputVECTOR buffersize. \
+								      \nVector image will not be created correctly.\n\n" );
+
+	/* Clean Up */
+	fclose(file);	
+
+}
+
+#endif /* HAVE_GL2PS */
diff -r 01954931d565 -r d287d3173f35 OutputFormats/src/OutputVECTOR.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OutputFormats/src/OutputVECTOR.h	Mon Apr 21 03:17:44 2008 +0000
@@ -0,0 +1,95 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+** Copyright (c) 2005, Monash Cluster Computing 
+** All rights reserved.
+** Redistribution and use in source and binary forms, with or without modification,
+** are permitted provided that the following conditions are met:
+**
+** 		* Redistributions of source code must retain the above copyright notice, 
+** 			this list of conditions and the following disclaimer.
+** 		* Redistributions in binary form must reproduce the above copyright 
+**			notice, this list of conditions and the following disclaimer in the 
+**			documentation and/or other materials provided with the distribution.
+** 		* Neither the name of the Monash University nor the names of its contributors 
+**			may be used to endorse or promote products derived from this software 
+**			without specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
+** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
+** BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
+** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+**
+**
+** Contact:
+*%		Cecile Duboz - Cecile.Duboz at sci.monash.edu.au
+*%
+** Contributors:
+*+		Cecile Duboz
+*+		Robert Turnbull
+*+		Alan Lo
+*+		Louis Moresi
+*+		David Stegman
+*+		David May
+*+		Stevan Quenette
+*+		Patrick Sunter
+*+		Greg Watson
+*+
+**
+** 
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+
+#ifndef __lucOutputVECTOR_h__
+#define __lucOutputVECTOR_h__
+
+	/** Textual name of this class - This is a global pointer which is used for times when you need to refer to class and not a particular instance of a class */
+	extern const Type lucOutputVECTOR_Type;
+		
+	/** Class contents - this is defined as a macro so that sub-classes of this class can use this macro at the start of the definition of their struct */
+	#define __lucOutputVECTOR \
+		/* Macro defining parent goes here - This means you can cast this class as its parent */ \
+		__lucOutputFormat \
+		/* Virtual functions go here */ \
+		/* Other info */\
+                 Name                              format;                   \
+                 Index                             gl2psFormatIndex;         \
+                 Index                             buffersize;               \
+
+	struct lucOutputVECTOR { __lucOutputVECTOR };
+	
+	/** Private Constructor: This will accept all the virtual functions for this class as arguments. */
+	lucOutputVECTOR* _lucOutputVECTOR_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,
+		lucOutputFormat_OutputFunction*                    _output,
+		Name                                               name );
+
+	void _lucOutputVECTOR_Delete( void* outputFormat ) ;
+	void _lucOutputVECTOR_Print( void* outputFormat, Stream* stream ) ;
+	void* _lucOutputVECTOR_Copy( void* outputFormat, void* dest, Bool deep, Name nameExt, PtrMap* ptrMap) ;
+
+	/* 'Stg_Component' implementations */
+	void* _lucOutputVECTOR_DefaultNew( Name name ) ;
+	void _lucOutputVECTOR_Construct( void* outputFormat, Stg_ComponentFactory* cf, void* data );
+	void _lucOutputVECTOR_Build( void* outputFormat, void* data ) ;
+	void _lucOutputVECTOR_Initialise( void* outputFormat, void* data ) ;
+	void _lucOutputVECTOR_Execute( void* outputFormat, void* data );
+	void _lucOutputVECTOR_Destroy( void* outputFormat, void* data ) ;
+	
+	void _lucOutputVECTOR_Output( void* outputFormat, lucWindow* window, AbstractContext* context, lucPixel* pixelData ) ;
+
+#endif
diff -r 01954931d565 -r d287d3173f35 OutputFormats/src/OutputVECTOR.meta
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OutputFormats/src/OutputVECTOR.meta	Mon Apr 21 03:17:44 2008 +0000
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<!DOCTYPE StGermainData SYSTEM "stgermain.dtd">
+<StGermainData xmlns="http://www.vpac.org/StGermain/XML_IO_Handler/Jun2003">
+
+<param name="Name">lucOutputVECTOR</param>
+<param name="Author">...</param>
+<param name="Organisation">MCC</param>
+<param name="Project">gLucifer</param>
+<param name="Location">./gLucifer/OutputFormats/src/</param>
+<param name="Project Web">http://mcc.monash.edu.au/gLucifer</param>
+<param name="Copyright">Copyright (c) 2005, Monash Cluster Computing</param>
+<param name="License">http://www.opensource.org/licenses/bsd-license.php</param>
+<param name="Parent">lucOutputFormat</param>
+<param name="Reference">...</param>
+<param name="Summary">Vector image outputting routine</param>
+<param name="Description">output format which utilises GL2PS library to capture the openGL feedback buffer, and convert to a vector image of you specification.</param>
+
+<!--Now the interesting stuff-->
+
+
+<list name="Params">
+	<struct>
+		<param name="Name">Format</param>
+		<param name="Type">String</param>
+		<param name="Default">ps</param>
+		<param name="Description">Format for output file.  Currently supported formats are svg, ps, eps, pdf.</param>
+	</struct>
+	<struct>
+		<param name="Name">Buffersize</param>
+		<param name="Type">UnsignedInt</param>
+		<param name="Default">16777216</param>
+		<param name="Description">Buffersize for openGL feedback buffer.  Current set at rather arbitrary value, that should be sufficient.</param>
+	</struct>
+</list>
+
+<list name="Dependencies">
+
+</list>
+<!-- Add an exmaple XML if possible -->
+<param name="Example">...</param>
+
+</StGermainData>



More information about the CIG-COMMITS mailing list