Skip to content

Commit

Permalink
ast: Add new method astGetRegionFrameSet.
Browse files Browse the repository at this point in the history
This returns the FrameSet that connects the Frame that a Region was
originally defined in, to the Frame that the Region is currently mapped
into.
  • Loading branch information
David Berry committed Nov 7, 2013
1 parent b804391 commit c8cc3c4
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libraries/ast/fregion.c
Expand Up @@ -19,6 +19,7 @@
* AST_MAPREGION
* AST_GETREGIONBOUNDS
* AST_GETREGIONFRAME
* AST_GETREGIONFRAMESET
* AST_OVERLAP
* AST_SETUNC
* AST_GETUNC
Expand Down Expand Up @@ -116,6 +117,18 @@ F77_INTEGER_FUNCTION(ast_getregionframe)( INTEGER(THIS),
return RESULT;
}

F77_INTEGER_FUNCTION(ast_getregionframeset)( INTEGER(THIS),
INTEGER(STATUS) ) {
GENPTR_INTEGER(THIS)
F77_INTEGER_TYPE(RESULT);

astAt( "AST_GETREGIONFRAMESET", NULL, 0 );
astWatchSTATUS(
RESULT = astP2I( astGetRegionFrameSet( astI2P( *THIS ) ) );
)
return RESULT;
}

F77_INTEGER_FUNCTION(ast_getunc)( INTEGER(THIS),
LOGICAL(DEF),
INTEGER(STATUS) ) {
Expand Down
68 changes: 68 additions & 0 deletions libraries/ast/region.c
Expand Up @@ -111,6 +111,8 @@ c - astGetRegionBounds: Get the bounds of a Region
f - AST_GETREGIONBOUNDS: Get the bounds of a Region
c - astGetRegionFrame: Get a copy of the Frame represent by a Region
f - AST_GETREGIONFRAME: Get a copy of the Frame represent by a Region
f - astGetRegionFrameSet: Get a copy of the Frameset encapsulated by a Region
f - AST_GETREGIONFRAMESET: Get a copy of the Frameset encapsulated by a Region
c - astGetRegionMesh: Get a mesh of points covering a Region
f - AST_GETREGIONMESH: Get a mesh of points covering a Region
c - astGetRegionPoints: Get the positions that define a Region
Expand Down Expand Up @@ -213,6 +215,8 @@ f - AST_SHOWMESH: Display a mesh of points on the surface of a Region
* component regions.
* 15-JUN-2012 (DSB):
* Guard against division by zero in RegBase Grid if "ipr" is zero.
* 7-NOV-2013 (DSB):
* Added method astGetRegionFrameSet.
*class--
* Implementation Notes:
Expand Down Expand Up @@ -879,6 +883,7 @@ static int MaskUS( AstRegion *, AstMapping *, int, int, const int[], const int[]

static AstAxis *GetAxis( AstFrame *, int, int * );
static AstFrame *GetRegionFrame( AstRegion *, int * );
static AstFrameSet *GetRegionFrameSet( AstRegion *, int * );
static AstFrame *PickAxes( AstFrame *, int, const int[], AstMapping **, int * );
static AstFrame *RegFrame( AstRegion *, int * );
static AstFrameSet *Conv( AstFrameSet *, AstFrameSet *, int * );
Expand Down Expand Up @@ -4228,6 +4233,64 @@ f function is invoked with STATUS set to an error value, or if it
return result;
}

static AstFrameSet *GetRegionFrameSet( AstRegion *this, int *status ) {
/*
*++
* Name:
c astGetRegionFrameSet
f AST_GETREGIONFRAMESET
* Purpose:
* Obtain a pointer to the encapsulated FrameSet within a Region.
* Type:
* Public virtual function.
* Synopsis:
c #include "region.h"
c AstFrame *astGetRegionFrameSet( AstRegion *this )
f RESULT = AST_GETREGIONFRAMESET( THIS, STATUS )
* Class Membership:
* Region method.
* Description:
* This function returns a pointer to the FrameSet encapsulated by a
* Region. The base Frame is the Frame in which the box was originally
* defined, and the current Frame is the Frame into which the Region
* is currently mapped (i.e. it will be the same as the Frame returned
c by astGetRegionFrame).
f by AST_GETREGIONFRAME).
* Parameters:
c this
f THIS = INTEGER (Given)
* Pointer to the Region.
f STATUS = INTEGER (Given and Returned)
f The global status.
* Returned Value:
c astGetRegionFrameSet()
f AST_GETREGIONFRAMESET = INTEGER
* A pointer to a deep copy of the FrameSet represented by the Region.
* Using this pointer to modify the FrameSet will have no effect on
* the Region.
* Notes:
* - A null Object pointer (AST__NULL) will be returned if this
c function is invoked with the AST error status set, or if it
f function is invoked with STATUS set to an error value, or if it
* should fail for any reason.
*--
*/

/* Check the global error status. */
if ( !astOK ) return NULL;

/* Return a deep copy of the encapsulated FrameSet. */
return astCopy( this->frameset );
}

void astInitRegionVtab_( AstRegionVtab *vtab, const char *name, int *status ) {
/*
*+
Expand Down Expand Up @@ -4328,6 +4391,7 @@ void astInitRegionVtab_( AstRegionVtab *vtab, const char *name, int *status ) {
vtab->TestUnc = TestUnc;
vtab->ClearUnc = ClearUnc;
vtab->GetRegionFrame = GetRegionFrame;
vtab->GetRegionFrameSet = GetRegionFrameSet;
vtab->MapRegion = MapRegion;
vtab->Overlap = Overlap;
vtab->OverlapX = OverlapX;
Expand Down Expand Up @@ -12753,6 +12817,10 @@ AstFrame *astGetRegionFrame_( AstRegion *this, int *status ){
if ( !astOK ) return NULL;
return (**astMEMBER(this,Region,GetRegionFrame))( this, status );
}
AstFrameSet *astGetRegionFrameSet_( AstRegion *this, int *status ){
if ( !astOK ) return NULL;
return (**astMEMBER(this,Region,GetRegionFrameSet))( this, status );
}
AstRegion *astMapRegion_( AstRegion *this, AstMapping *map, AstFrame *frame, int *status ){
if ( !astOK ) return NULL;
return (**astMEMBER(this,Region,MapRegion))( this, map, frame, status );
Expand Down
4 changes: 4 additions & 0 deletions libraries/ast/region.h
Expand Up @@ -122,6 +122,7 @@ typedef struct AstRegionVtab {
int (* OverlapX)( AstRegion *, AstRegion *, int * );
AstRegion *(* MapRegion)( AstRegion *, AstMapping *, AstFrame *, int * );
AstFrame *(* GetRegionFrame)( AstRegion *, int * );
AstFrameSet *(* GetRegionFrameSet)( AstRegion *, int * );
AstFrame *(* RegFrame)( AstRegion *, int * );
AstFrameSet *(* GetRegFS)( AstRegion *, int * );
AstPointSet *(* RegTransform)( AstRegion *, AstPointSet *, int, AstPointSet *, AstFrame **, int * );
Expand Down Expand Up @@ -250,6 +251,7 @@ void astInitRegionGlobals_( AstRegionGlobals * );
/* -------------------------------- */

AstFrame *astGetRegionFrame_( AstRegion *, int * );
AstFrameSet *astGetRegionFrameSet_( AstRegion *, int * );
int astOverlap_( AstRegion *, AstRegion *, int * );
void astNegate_( AstRegion *, int * );

Expand Down Expand Up @@ -383,6 +385,8 @@ astINVOKE(O,astLoadRegion_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PT
of object is supplied. */
#define astGetRegionFrame(this) \
astINVOKE(O,astGetRegionFrame_(astCheckRegion(this),STATUS_PTR))
#define astGetRegionFrameSet(this) \
astINVOKE(O,astGetRegionFrameSet_(astCheckRegion(this),STATUS_PTR))
#define astNegate(this) \
astINVOKE(V,astNegate_(astCheckRegion(this),STATUS_PTR))
#define astOverlap(this,that) \
Expand Down

0 comments on commit c8cc3c4

Please sign in to comment.