Pointwise Plugin SDK
Public Member Functions | Protected Attributes | List of all members

The structured block to block connection class. More...

#include <CaeStrConnection.h>

+ Collaboration diagram for CaeStrConnection:

Public Member Functions

 CaeStrConnection ()
 Default constructor. More...
 
 CaeStrConnection (const CaeStrConnection &src)
 Copy constructor. More...
 
 CaeStrConnection (const CaeStrConnectionGroup &group, PWP_UINT32 ndx=0)
 Group and connection index constructor. More...
 
bool data (PWGM_CNXNDATA &data) const
 Get information about the connection. More...
 
PWP_UINT32 index () const
 Get the connection's index in the group. More...
 
bool isValid () const
 Determines a connection's validity. More...
 
CaeStrGridModel model () const
 Gets the structured grid model of which this connection is a member. More...
 
PWP_UINT32 modelIndex () const
 Get the connection's model index. More...
 
CaeStrConnectionmoveFirst ()
 Rebinds an instance to the first connection in the current group. More...
 
CaeStrConnectionmoveFirst (const CaeStrConnectionGroup &group)
 Rebinds an instance to the first connection in the group. More...
 
CaeStrConnectionmoveNext ()
 Rebinds an instance to the next connection in the group. More...
 
CaeStrConnectionmovePrev ()
 Rebinds an instance to the previous connection in the group. More...
 
CaeStrConnectionmoveTo (const CaeStrConnectionGroup &group, PWP_UINT32 ndx)
 Rebinds an instance to a specific group and connection. More...
 
CaeStrConnectionmoveTo (PWP_UINT32 ndx)
 Rebinds an instance to a specific connection within the current group. More...
 
 operator PWGM_HCNXN () const
 The PWGM_HCNXN cast operator. More...
 
bool operator!= (const CaeStrConnection &rhs) const
 Compares two CaeStrConnection instances for inequality. More...
 
CaeStrConnectionoperator++ ()
 Prefix increment to the next connection in the group. More...
 
CaeStrConnection operator++ (int)
 Postfix increment to the next connection in the group. More...
 
CaeStrConnectionoperator-- ()
 Prefix decrement to the previous connection in the group. More...
 
CaeStrConnection operator-- (int)
 Postfix decrement to the previous connection in the group. More...
 
bool operator< (const CaeStrConnection &rhs) const
 Compares the relative order of two CaeStrConnection instances. More...
 
CaeStrConnectionoperator= (const CaeStrConnection &rhs)
 Assignment operator. More...
 
bool operator== (const CaeStrConnection &rhs) const
 Compares two CaeStrConnection instances for equality. More...
 
bool operator> (const PWGM_HCNXN &rhs)
 Compares the relative order of two CaeStrConnection instances. More...
 
 ~CaeStrConnection ()
 Destructor. More...
 

Protected Attributes

const CaeStrConnectionGroupgroup_
 The owning connection group. More...
 
PWP_UINT32 groupNdx_
 The current index in the group's index space. More...
 
PWGM_HCNXN h_
 The bound PWGM_HCNXN. More...
 

Detailed Description

The structured block to block connection class.

The CaeStrConnection class represents a single, ijk-structured grid model connection. The connections are indexed starting from 0 to CaeStrConnectionGroup::elementCount() - 1.

A CaeStrConnection object is aware of its relative position in its connection group. As a result, a given connection object can be moved (iterated) to its previous or next neighbor connection. It can also be moved to the first connection or to a connection at a given index. After being moved, a CaeStrConnection object will return information about the grid connection at its current position.

Sample Usage:

The following snippets are extracted from the structured XML sample plugin (CaeStrXMLCPP).

During the execution of the CaeStrXMLCPP::writeBlock() method, the CaeStrXMLCPP plugin writes a block's connections with a call to the CaeStrXMLCPP::writeBlkConnections() method. First, it writes an XML <connections> tag. Then it moves through the connections one by one and calls the CaeStrXMLCPP::writeConnectionData() method. Finally, a closing </connections> tag is written.

bool
CaeStrXMLCPP::writeBlkConnections(const CaeStrBlock &block)
{
PWP_UINT32 cnt = block.connectionCount();
fprintf(fp(), "%s<connections cnt='%lu'>\n", tabs(),
(unsigned long)cnt);
++tabs_;
CaeStrConnection cnxn(block);
while (cnxn.data(data)) {
writeConnectionData(cnxn.modelIndex(), data);
++cnxn;
}
--tabs_;
fprintf(fp(), "%s</connections>\n", tabs());
return true;
}

CaeStrXMLCPP::writeConnectionData() writes an XML <cnxn> tag. Next, the connection's forward and reverse block to block links are written with two calls to CaeStrXMLCPP::writeLink(). Finally, a closing </cnxn> tag is written.

void
CaeStrXMLCPP::writeConnectionData(PWP_UINT32 cnxnId, const PWGM_CNXNDATA &data)
{
const char *name = (data.name ? data.name : "");
fprintf(fp(), "%s<cnxn name='%s' id='%lu'>\n", tabs(), name,
(unsigned long)cnxnId);
++tabs_;
writeLink(true, data.block1, data.face1, data.range1, data.from1to2);
writeLink(false, data.block2, data.face2, data.range2, data.from2to1);
--tabs_;
fprintf(fp(), "%s</cnxn>\n", tabs());
}

CaeStrXMLCPP::writeLink() writes an XML <link> tag. Next, the link's ijk range and transform are written with calls to the CaeStrXMLCPP::writeRange() and CaeStrXMLCPP::writeTransform() methods. Finally, a closing </link> tag is written.

void
CaeStrXMLCPP::writeLink(bool fwd, const CaeStrBlock &block, PWGM_FACE_ID face,
const PWGM_STR_RANGE &range, const PWGM_INDEX_XFORM &xform)
{
fprintf(fp(), "%s<link dir='%s' blk='%lu' face='%s'>\n", tabs(),
(fwd ? "fwd" : "rev"), (unsigned long)block.index(), faceIdStr[face]);
++tabs_;
writeRange(range);
writeTransform(xform);
--tabs_;
fprintf(fp(), "%s</link>\n", tabs());
}

CaeStrXMLCPP::writeRange() writes a self-closed XML <range /> tag.

void
CaeStrXMLCPP::writeRange(const PWGM_STR_RANGE &range)
{
if (isDimension3D()) {
fprintf(fp(), "%s<range ijkmin='%lu %lu %lu' ijkmax='%lu %lu %lu' />\n",
tabs(), (unsigned long)range.beg.i, (unsigned long)range.beg.j,
(unsigned long)range.beg.k, (unsigned long)range.end.i,
(unsigned long)range.end.j, (unsigned long)range.end.k);
}
else {
fprintf(fp(),
"%s<range ijmin='%lu %lu' ijmax='%lu %lu' />\n",
tabs(), (unsigned long)range.beg.i, (unsigned long)range.beg.j,
(unsigned long)range.end.i, (unsigned long)range.end.j);
}
}

CaeStrXMLCPP::writeTransform() writes a self-closed XML <xform> tag.

void
CaeStrXMLCPP::writeTransform(const PWGM_INDEX_XFORM &xform)
{
// PWP_INT m[3][4]; m[row][col]
int row;
int col;
fprintf(fp(), "%s<xform", tabs());
if (isDimension3D()) {
for (row = 0; row < 3; ++row) {
if (row) {
fprintf(fp(), "\n%s ", tabs());
}
for (col = 0; col < 4; ++col) {
fprintf(fp(), " m%u%u='%d'", row, col, xform.m[row][col]);
}
}
}
else if (model_.xform3to2(xform, x2)) {
for (row = 0; row < 2; ++row) {
if (row) {
fprintf(fp(), "\n%s ", tabs());
}
for (col = 0; col < 3; ++col) {
fprintf(fp(), " m%u%u='%d'", row, col, x2.m[row][col]);
}
}
}
fprintf(fp(), " />\n");
}

Definition at line 66 of file CaeStrConnection.h.

Constructor & Destructor Documentation

◆ CaeStrConnection() [1/3]

CaeStrConnection::CaeStrConnection ( )
inline

Default constructor.

Constructs an invalid connection.

Note
The connection can be made valid using moveTo() or moveFirst().
See also
moveTo(), moveFirst(), moveNext(), movePrev()

Definition at line 75 of file CaeStrConnection.h.

References h_.

◆ CaeStrConnection() [2/3]

CaeStrConnection::CaeStrConnection ( const CaeStrConnectionGroup group,
PWP_UINT32  ndx = 0 
)
inline

Group and connection index constructor.

Constructs an structured connection object bound to the connection at the specified index.

Parameters
groupThe owning structured connection group.
ndxThe connection's index within the group.
See also
CaeStrGridModel, CaeStrBlock

Definition at line 87 of file CaeStrConnection.h.

References h_, and moveTo().

◆ CaeStrConnection() [3/3]

CaeStrConnection::CaeStrConnection ( const CaeStrConnection src)
inline

Copy constructor.

Binds this connection to the same connection as src.

Parameters
srcAn connection instance.

Definition at line 97 of file CaeStrConnection.h.

References group_, groupNdx_, and h_.

◆ ~CaeStrConnection()

CaeStrConnection::~CaeStrConnection ( )
inline

Destructor.

Definition at line 104 of file CaeStrConnection.h.

Member Function Documentation

◆ data()

bool CaeStrConnection::data ( PWGM_CNXNDATA data) const
inline

Get information about the connection.

Parameters
dataThe PWGM_BNDRYDATA buffer.
Returns
true if successful.

Definition at line 138 of file CaeStrConnection.h.

References h_, and PwConnection().

◆ index()

PWP_UINT32 CaeStrConnection::index ( ) const
inline

Get the connection's index in the group.

Returns
The connection's index in the group's index space.
Note
The values returned will be contiguous in the range of 0 to CaeStrConnectionGroup::connectionCount() - 1.

Definition at line 118 of file CaeStrConnection.h.

References groupNdx_.

◆ isValid()

bool CaeStrConnection::isValid ( ) const
inline

Determines a connection's validity.

Returns
true if the connection is valid.

Definition at line 144 of file CaeStrConnection.h.

References h_, and PWGM_HCNXN_ISVALID.

◆ model()

CaeStrGridModel CaeStrConnection::model ( ) const
inline

Gets the structured grid model of which this connection is a member.

Definition at line 108 of file CaeStrConnection.h.

References h_, and PWGM_HCNXN_MODEL.

◆ modelIndex()

PWP_UINT32 CaeStrConnection::modelIndex ( ) const
inline

Get the connection's model index.

Returns
The connection's index in the grid model's index space.
Note
The values returned are in the range of 0 to CaeStrGridModel::connectionCount() - 1. If the grid model contains 2 or more blocks, the values will be a subset of the full range.

Definition at line 129 of file CaeStrConnection.h.

References h_, and PWGM_HCNXN_ID.

◆ moveFirst() [1/2]

CaeStrConnection& CaeStrConnection::moveFirst ( )
inline

Rebinds an instance to the first connection in the current group.

Returns
A self reference.
Note
If isValid() is false, the returned connection will be invalid.
See also
moveTo(), movePrev(), moveNext()

Definition at line 208 of file CaeStrConnection.h.

References CaeStrConnectionGroup::enumConnections(), group_, groupNdx_, and h_.

◆ moveFirst() [2/2]

CaeStrConnection& CaeStrConnection::moveFirst ( const CaeStrConnectionGroup group)
inline

Rebinds an instance to the first connection in the group.

Parameters
groupThe connection group.
Returns
A self reference.
Note
Equivalent to calling moveTo(group, 0).
See also
moveTo(), movePrev(), moveNext()

Definition at line 197 of file CaeStrConnection.h.

References group_, and moveTo().

◆ moveNext()

CaeStrConnection& CaeStrConnection::moveNext ( )
inline

Rebinds an instance to the next connection in the group.

Returns
A self reference.
Note
If already on the last connection, the connection will become invalid.
See also
moveTo(), moveFirst(), movePrev(), isValid()

Definition at line 223 of file CaeStrConnection.h.

References groupNdx_, and moveTo().

◆ movePrev()

CaeStrConnection& CaeStrConnection::movePrev ( )
inline

Rebinds an instance to the previous connection in the group.

Returns
A self reference.
Note
If already on the first connection, the connection will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 259 of file CaeStrConnection.h.

References groupNdx_, and moveTo().

◆ moveTo() [1/2]

CaeStrConnection& CaeStrConnection::moveTo ( const CaeStrConnectionGroup group,
PWP_UINT32  ndx 
)
inline

Rebinds an instance to a specific group and connection.

Parameters
groupThe connection group.
ndxThe connection's index in the group's index space.
Returns
A self reference.
Note
If ndx is not a valid index, the connection will become invalid.
See also
moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 169 of file CaeStrConnection.h.

References group_.

Referenced by CaeStrConnection(), moveFirst(), moveNext(), movePrev(), operator++(), and operator--().

◆ moveTo() [2/2]

CaeStrConnection& CaeStrConnection::moveTo ( PWP_UINT32  ndx)
inline

Rebinds an instance to a specific connection within the current group.

Parameters
ndxThe connection's index in the group's index space.
Returns
A self reference.
Note
If isValid() is false, the returned connection will be invalid.
If ndx is not a valid index, the connection will become invalid.
See also
moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 182 of file CaeStrConnection.h.

References CaeStrConnectionGroup::enumConnections(), group_, groupNdx_, and h_.

◆ operator PWGM_HCNXN()

CaeStrConnection::operator PWGM_HCNXN ( ) const
inline

The PWGM_HCNXN cast operator.

Definition at line 338 of file CaeStrConnection.h.

References h_.

◆ operator!=()

bool CaeStrConnection::operator!= ( const CaeStrConnection rhs) const
inline

Compares two CaeStrConnection instances for inequality.

Returns
true if each instance is bound to a different grid connection or only one of the connections is invalid.

Definition at line 306 of file CaeStrConnection.h.

◆ operator++() [1/2]

CaeStrConnection& CaeStrConnection::operator++ ( )
inline

Prefix increment to the next connection in the group.

Returns
A self reference.
Note
Equivalent to calling moveNext().
If already on the last connection, the connection will become invalid.
See also
moveTo(), moveFirst(), movePrev(), isValid()

Definition at line 235 of file CaeStrConnection.h.

References groupNdx_, and moveTo().

◆ operator++() [2/2]

CaeStrConnection CaeStrConnection::operator++ ( int  )
inline

Postfix increment to the next connection in the group.

Returns
A copy of the connection before it was moved.
Note
If already on the last connection, the connection will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 246 of file CaeStrConnection.h.

References groupNdx_, and moveTo().

◆ operator--() [1/2]

CaeStrConnection& CaeStrConnection::operator-- ( )
inline

Prefix decrement to the previous connection in the group.

Returns
A self reference.
Note
Equivalent to calling movePrev().
If already on the first connection, the connection will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 271 of file CaeStrConnection.h.

References groupNdx_, and moveTo().

◆ operator--() [2/2]

CaeStrConnection CaeStrConnection::operator-- ( int  )
inline

Postfix decrement to the previous connection in the group.

Returns
A copy of the connection before it was moved.
Note
If already on the first connection, the connection will become invalid.
See also
moveTo(), moveFirst(), movePrev(), moveNext(), isValid()

Definition at line 282 of file CaeStrConnection.h.

References groupNdx_, and moveTo().

◆ operator<()

bool CaeStrConnection::operator< ( const CaeStrConnection rhs) const
inline

Compares the relative order of two CaeStrConnection instances.

Returns
true if *this is ordered less than rhs.

Definition at line 318 of file CaeStrConnection.h.

References group_, and h_.

◆ operator=()

CaeStrConnection& CaeStrConnection::operator= ( const CaeStrConnection rhs)
inline

Assignment operator.

Rebind this connection to the same connection as rhs.

Parameters
rhsA connection instance.
Returns
A self reference.

Definition at line 154 of file CaeStrConnection.h.

References group_, groupNdx_, and h_.

◆ operator==()

bool CaeStrConnection::operator== ( const CaeStrConnection rhs) const
inline

Compares two CaeStrConnection instances for equality.

Returns
true if both instances are bound to the same grid connection or both connections are invalid.

Definition at line 297 of file CaeStrConnection.h.

References group_, and h_.

◆ operator>()

bool CaeStrConnection::operator> ( const PWGM_HCNXN rhs)
inline

Compares the relative order of two CaeStrConnection instances.

Returns
true if *this is ordered greater than rhs.

Definition at line 332 of file CaeStrConnection.h.

Member Data Documentation

◆ group_

const CaeStrConnectionGroup* CaeStrConnection::group_
protected

The owning connection group.

Definition at line 344 of file CaeStrConnection.h.

Referenced by CaeStrConnection(), moveFirst(), moveTo(), operator<(), operator=(), and operator==().

◆ groupNdx_

PWP_UINT32 CaeStrConnection::groupNdx_
protected

The current index in the group's index space.

Definition at line 346 of file CaeStrConnection.h.

Referenced by CaeStrConnection(), index(), moveFirst(), moveNext(), movePrev(), moveTo(), operator++(), operator--(), and operator=().

◆ h_

PWGM_HCNXN CaeStrConnection::h_
protected

The documentation for this class was generated from the following file:
PWGM_INDEX3::j
PWP_INT32 j
j-coordinate used for 3D and 2D grids
Definition: apiGridModel.h:890
CaeStrConnectionGroup::connectionCount
PWP_UINT32 connectionCount() const
Get the number of connections in the group.
Definition: CaeStrConnectionGroup.h:57
PWP_UINT32
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:210
PWGM_INDEX_XFORM2::m
PWP_INT32 m[2][3]
m[row][col]
Definition: apiGridModel.h:933
PWGM_INDEX_XFORM2
The 2D transform matrix data type.
Definition: apiGridModel.h:932
PWGM_INDEX3::i
PWP_INT32 i
i-coordinate used for 3D and 2D grids
Definition: apiGridModel.h:889
CaeStrBlock
The structured block class.
Definition: CaeStrBlock.h:72
PWGM_FACE_ID
PWGM_FACE_ID
Structured grid block-face ids.
Definition: apiGridModel.h:939
PWGM_STR_RANGE::end
PWGM_INDEX3 end
ending index
Definition: apiGridModel.h:911
PWGM_INDEX3::k
PWP_INT32 k
k-coordinate used for 3D grids only
Definition: apiGridModel.h:891
PWGM_STR_RANGE::beg
PWGM_INDEX3 beg
begining index
Definition: apiGridModel.h:910
PWGM_INDEX_XFORM
The 3D transform matrix data type.
Definition: apiGridModel.h:921
CaeStrConnection::data
bool data(PWGM_CNXNDATA &data) const
Get information about the connection.
Definition: CaeStrConnection.h:138
PWGM_CNXNDATA
Structured grid, inter-block, connection data type.
Definition: apiGridModel.h:990
CaeBlock::index
PWP_UINT32 index() const
Get a block's index.
Definition: CaeGridModel.h:197
CaeStrConnection
The structured block to block connection class.
Definition: CaeStrConnection.h:66
PWGM_STR_RANGE
Structured grid ijk range data type.
Definition: apiGridModel.h:909
PWGM_INDEX_XFORM::m
PWP_INT32 m[3][4]
m[row][col]
Definition: apiGridModel.h:922