void _ParticleLayout_AssignFromXML( void* particleLayout, Stg_ComponentFactory *cf, void* data ) {
   ParticleLayout* self = (ParticleLayout*) particleLayout;
   AbstractContext* context=NULL;

   context = Stg_ComponentFactory_ConstructByKey( cf, self->name, (Dictionary_Entry_Key)"Context", AbstractContext, False, data );
   if( !context  )
      context = Stg_ComponentFactory_ConstructByName( cf, (Name)"context", AbstractContext, True, data  );

   _ParticleLayout_Init( self, context, GlobalCoordSystem, False );

}
ManualParticleLayout* ManualParticleLayout_New( Name name,
      AbstractContext* context, 
      CoordSystem      coordSystem,
      Bool             weightsInitialisedAtStartup,
      unsigned int     totalInitialParticles, 
      double           averageInitialParticlesPerCell,
      Dictionary*      dictionary ) 
{
	ManualParticleLayout* self = (ManualParticleLayout*) _ManualParticleLayout_DefaultNew( name );

   _ParticleLayout_Init( self, context, coordSystem, weightsInitialisedAtStartup );
   _GlobalParticleLayout_Init( self, totalInitialParticles, averageInitialParticlesPerCell );
	_ManualParticleLayout_Init( self, dictionary );
	return self;
}
TriGaussParticleLayout* TriGaussParticleLayout_New( 
   Name name, 
   AbstractContext* context,
   CoordSystem      coordSystem,
   Bool             weightsInitialisedAtStartup,
   unsigned int dim, unsigned int particlesPerCell ) 
{
	TriGaussParticleLayout* self = (TriGaussParticleLayout*)_TriGaussParticleLayout_DefaultNew( name );

   _ParticleLayout_Init( self, context, coordSystem, weightsInitialisedAtStartup );
   _PerCellParticleLayout_Init( self );
	_TriGaussParticleLayout_Init( self, dim, particlesPerCell );

	return self;
}
MeshParticleLayout* MeshParticleLayout_New( 
   Name                 name, 
   AbstractContext* context,
   CoordSystem      coordSystem,
   Bool             weightsInitialisedAtStartup,
   Mesh*            mesh,
   Particle_InCellIndex cellParticleCount, 
   unsigned int         seed,
   unsigned int         filltype )
{
	MeshParticleLayout* self = (MeshParticleLayout*) _MeshParticleLayout_DefaultNew( name );

   _ParticleLayout_Init( self, context, coordSystem, weightsInitialisedAtStartup );
   _PerCellParticleLayout_Init( self );
	_MeshParticleLayout_Init( self, mesh, cellParticleCount, seed, filltype );

	return self;
}
void _GlobalParticleLayout_Init(
		void*                                               particleLayout,
		CoordSystem                                         coordSystem,
		Bool                                                weightsInitialisedAtStartup,
		Particle_Index                                      totalInitialParticles,
		double                                              averageInitialParticlesPerCell )
{
	GlobalParticleLayout* self = (GlobalParticleLayout*)particleLayout;

	self->isConstructed = True;

	/* Note the total and average particles per cell need to be set in child
	classes, as they may be worked out differently (eg the ManualParticleLayout
	specifies the particles directly, so the total is implicit) */

	self->totalInitialParticles = totalInitialParticles;
	self->averageInitialParticlesPerCell = averageInitialParticlesPerCell;

	_ParticleLayout_Init( self, coordSystem, weightsInitialisedAtStartup );
}