Pointwise Plugin SDK
apiCAEPUtils.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Pointwise Plugin utility functions
4  *
5  * Proprietary software product of Pointwise, Inc.
6  * Copyright (c) 1995-2018 Pointwise, Inc.
7  * All rights reserved.
8  *
9  ***************************************************************************/
10 
11 #ifndef _APICAEPUTILS_H_
12 #define _APICAEPUTILS_H_
13 
14 #include <stdio.h>
15 #include <time.h>
16 
17 #include "apiCAEP.h"
18 #include "apiPWP.h"
19 #include "apiPWPUtils.h"
20 #include "apiGridModel.h"
21 
22 extern "C" {
23 
24 /************************************************************************/
51 // include impl-defined cae instance runtime data types.
52 // Must also define the macro CAEP_RUNTIME_INSTDATADECL
53 #include "rtCaepInstanceData.h"
54 
64 #if !defined(CAEP_RUNTIME_INSTDATADECL)
65 # define CAEP_RUNTIME_INSTDATADECL
66 #endif
67 
68 
69 /***********************************************************/
70 /***********************************************************/
82 //***************************************************************************
83 //***************************************************************************
111  /* add new group enum values before this line */
112 
116  CAEPU_CLKS_SIZE,
117  CAEPU_CLKS_LAST = CAEPU_CLKS_SIZE-1
118  /* @} */ // sdkINTERNALS
120 };
121 
122 
123 /************************************************************************/
126 struct CAEP_RTITEM {
132 
136 
143 
149 
156 
163 
169  const char **pFileExt;
170 
176 
182  PWP_BOOL elemType[PWGM_ELEMTYPE_SIZE];
183 
201  FILE *fp;
202 
213 
219 
225 
233  PWP_UINT32 progTotal;
234 
240  PWP_UINT32 progComplete;
241 
247  clock_t clocks[CAEPU_CLKS_SIZE];
248 
254  PWP_BOOL opAborted;
255  // sdkINTERNALS
257 
267 };
268 
269 
270 /************************************************************************/
284 extern CAEP_RTITEM caepRtItem[];
285 
286 
287 /************************************************************************/
294  /* DOXGRP_APICAEP_UTILS_DATA */
296 
297 
298 
299 //***************************************************************************
300 //***************************************************************************
308 /************************************************************************/
319 
320 
321 /************************************************************************/
331 CAEP_RTITEM* caeuFindFormatByName (const char name[]);
332  /* DOXGRP_APICAEP_UTILS_SDKCAEP */
334 
335 
336 
337 //***************************************************************************
338 //***************************************************************************
350 /************************************************************************/
396 
397 
398 /************************************************************************/
412 
413 
414 /************************************************************************/
425 
426 
427 /************************************************************************/
438 
439 
440 /************************************************************************/
454 void caeuProgressEnd(CAEP_RTITEM *pRti, PWP_BOOL ok);
455  /* DOXGRP_APICAEP_UTILS_PROGRESS */
457 
458 
459 
460 //***************************************************************************
461 //***************************************************************************
470 /************************************************************************/
485 int caeuFileClose(CAEP_RTITEM* pRti, const CAEP_WRITEINFO *pWriteInfo);
486 
487 /************************************************************************/
509 int caeuFileOpen(CAEP_RTITEM* pRti, const CAEP_WRITEINFO *pWriteInfo);
510  /* DOXGRP_APICAEP_UTILS_FILEIO */
512 
513 
514 //***************************************************************************
515 //***************************************************************************
524 /************************************************************************/
533 const char * caeuEncodeToText(PWP_ENUM_ENCODING enc);
534 
535 /************************************************************************/
544 const char * caeuPrecisionToText(PWP_ENUM_PRECISION prec);
545 
546 /************************************************************************/
555 const char * caeuDimensionToText(PWP_ENUM_DIMENSION dim);
556  /* DOXGRP_APICAEP_UTILS_TOTEXT */
558 
559 
560 //***************************************************************************
561 //***************************************************************************
574 //-------------------------------------------------------------------------
581 void caeuSendDebugMsg (CAEP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
582 
583 //-------------------------------------------------------------------------
590 void caeuSendInfoMsg (CAEP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
591 
592 //-------------------------------------------------------------------------
599 void caeuSendWarningMsg (CAEP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
600 
601 //-------------------------------------------------------------------------
608 void caeuSendErrorMsg (CAEP_RTITEM* pRti, const char txt[], PWP_UINT32 code);
609  /* DOXGRP_APICAEP_UTILS_MSGS */
611 
612 
613 //***************************************************************************
614 //***************************************************************************
624 //-------------------------------------------------------------------------
651  const char value[], const char access[], const char desc[],
652  const char range[]);
653 
654 //-------------------------------------------------------------------------
669 PWP_BOOL caeuAssignInfoValue(const char key[], const char value[],
670  bool createIfNotExists = true);
671 
681 
690 PWP_BOOL
692 
702 
712 
720 PWP_BOOL
722 
731 PWP_BOOL
733  /* DOXGRP_APICAEP_UTILS_VARS */
735 
736 
737 
738 //***************************************************************************
739 //***************************************************************************
747 /************************************************************************/
750 #define CAEPU_RT_DIM(rti) (rti)->pWriteInfo->dimension
751 
752 /************************************************************************/
756 #define CAEPU_RT_DIM_TEXT(rti) \
757  caeuDimensionToText((rti)->pWriteInfo->dimension)
758 
759 /************************************************************************/
762 #define CAEPU_RT_DIM_IS(rti, d) PWP_CAST_BOOL((d) == CAEPU_RT_DIM(rti))
763 
764 /************************************************************************/
767 #define CAEPU_RT_DIM_3D(rti) CAEPU_RT_DIM_IS(rti, PWP_DIMENSION_3D)
768 
769 /************************************************************************/
772 #define CAEPU_RT_DIM_2D(rti) CAEPU_RT_DIM_IS(rti, PWP_DIMENSION_2D)
773 
774 
775 /************************************************************************/
778 #define CAEPU_RT_PREC(rti) (rti)->pWriteInfo->precision
779 
780 /************************************************************************/
784 #define CAEPU_RT_PREC_TEXT(rti) \
785  caeuPrecisionToText((rti)->pWriteInfo->precision)
786 
787 /************************************************************************/
790 #define CAEPU_RT_PREC_IS(rti, prec) PWP_CAST_BOOL((prec) == CAEPU_RT_PREC(rti))
791 
792 /************************************************************************/
795 #define CAEPU_RT_PREC_SINGLE(rti) CAEPU_RT_PREC_IS(rti, PWP_PRECISION_SINGLE)
796 
797 /************************************************************************/
800 #define CAEPU_RT_PREC_DOUBLE(rti) CAEPU_RT_PREC_IS(rti, PWP_PRECISION_DOUBLE)
801 
802 
803 /************************************************************************/
806 #define CAEPU_RT_ENCODING(rti) (rti)->pWriteInfo->encoding
807 
808 /************************************************************************/
812 #define CAEPU_RT_ENCODING_TEXT(rti) \
813  caeuEncodeToText((rti)->pWriteInfo->encoding)
814 
815 /************************************************************************/
818 #define CAEPU_RT_ENC_IS(rti, e) PWP_CAST_BOOL((e) == CAEPU_RT_ENCODING(rti))
819 
820 /************************************************************************/
823 #define CAEPU_RT_ENC_ASCII(rti) CAEPU_RT_ENC_IS(rti, PWP_ENCODING_ASCII)
824 
825 /************************************************************************/
828 #define CAEPU_RT_ENC_BINARY(rti) CAEPU_RT_ENC_IS(rti, PWP_ENCODING_BINARY)
829 
830 /************************************************************************/
833 #define CAEPU_RT_ENC_UNFORMATTED(rti) \
834  CAEPU_RT_ENC_IS(rti, PWP_ENCODING_UNFORMATTED)
835 
836 
837 /************************************************************************/
841 #define CAEPU_RT_IS_ABORTED(rti) PWP_CAST_BOOL((rti)->opAborted)
842 
843 /************************************************************************/
846 #define CAEPU_RT_ABORT(rti) ((rti)->opAborted = PWP_TRUE)
847 
848 /************************************************************************/
888 #define CAEPU_RT_TRY(rti, theOp) \
889  ((rti)->opAborted ? PWP_FALSE : \
890  (((rti)->opAborted = !(theOp)), !CAEPU_RT_IS_ABORTED(rti)))
891 
892 
893 /************************************************************************/
896 #define CAEPU_IS_CLKS_ID(id) \
897  PWP_CAST_BOOL(((id) >= 0) && ((id) <= CAEPU_CLKS_LAST))
898 
899 /************************************************************************/
902 #define CAEPU_RT_CLKS_ID(rti, id) (CAEPU_IS_CLKS_ID(id)? (rti)->clocks[id]: 0)
903 
904 /************************************************************************/
908 #define CAEPU_RT_CLKS_DIFF(rti, startId, endId) \
909  ((CAEPU_IS_CLKS_ID(startId) && CAEPU_IS_CLKS_ID(endId)) ? \
910  ((rti)->clocks[endId] - (rti)->clocks[startId]) : 0)
911 
912 /************************************************************************/
916 #define CAEPU_RT_CLKS_POLL(rti, id) \
917  CAEPU_RT_CLKS_DIFF(rti, id, CAEPU_CLKS_PROGINCR)
918 
919 /************************************************************************/
923 #define CAEPU_RT_CLKS_POLL_STEP(rti) \
924  CAEPU_RT_CLKS_POLL(rti, CAEPU_CLKS_BEGSTEP)
925 
926 /************************************************************************/
930 #define CAEPU_RT_CLKS_DIFF_STEP(rti) \
931  CAEPU_RT_CLKS_DIFF(rti, CAEPU_CLKS_BEGSTEP, CAEPU_CLKS_ENDSTEP)
932 
933 /************************************************************************/
937 #define CAEPU_RT_CLKS_POLL_TOTAL(rti) \
938  CAEPU_RT_CLKS_POLL(rti, CAEPU_CLKS_PROGINIT)
939 
940 /************************************************************************/
944 #define CAEPU_RT_CLKS_DIFF_TOTAL(rti) \
945  CAEPU_RT_CLKS_DIFF(rti, CAEPU_CLKS_PROGINIT, CAEPU_CLKS_PROGEND)
946 
947 /************************************************************************/
951 #define CAEPU_CLKS_TO_MSECS(c) ((PWP_INT32)((c) * 1000) / CLOCKS_PER_SEC)
952 
953 /************************************************************************/
957 #define CAEPU_CLKS_TO_SECS(c) ((PWP_INT32)(c) / CLOCKS_PER_SEC)
958 
959 /************************************************************************/
963 #define CAEPU_CLKS_TO_MINS(c) (CAEPU_CLKS_TO_SECS(c) / 60)
964 
965 /************************************************************************/
969 #define CAEPU_CLKS_TO_HOURS(c) (CAEPU_CLKS_TO_MINS(c) / 60)
970 
971 /************************************************************************/
976 #define CAEPU_CLKS_TO_HMS(c, h, m, s) \
977  (s = CAEPU_CLKS_TO_SECS(c)), \
978  (h = s / 3600), (s -= h * 3600), \
979  (m = s / 60), \
980  (s -= m * 60)
981 
982 /************************************************************************/
985 #define CAEPU_CLKS_TO_FSECS(c) ((PWP_FLOAT)(c) / (PWP_FLOAT)CLOCKS_PER_SEC)
986 
993 } /* extern "C" */
994 
995 #endif /* _APICAEPUTILS_H_ */
PWP_ENUM_VALTYPE
Supported PWP-API getValue() transfer types.
Definition: apiPWP.h:612
#define CAEP_RUNTIME_INSTDATADECL
Implementation defined CAE runtime instance data macro.
Definition: apiCAEPUtils.h:65
unsigned int PWP_UINT32
32-bit unsigned integer
Definition: apiPWP.h:194
CAEP_RTITEM * caeuFindFormatById(PWP_UINT32 id)
Find an item in caepRtItem[] by it&#39;s id.
PWU_RTITEM * pApiData
Pointer to the associated PWU_RTITEM structure.
Definition: apiCAEPUtils.h:135
Pointwise Plugin API (PWP-API)
PWU_UNFDATA unfData
Unformatted file I/O data.
Definition: apiCAEPUtils.h:212
The information returned for each supported CAEP exporter.
Definition: apiCAEP.h:100
const char * caeuEncodeToText(PWP_ENUM_ENCODING enc)
Converts a PWP_ENUM_ENCODING value to a text string representation.
int caeuFileOpen(CAEP_RTITEM *pRti, const CAEP_WRITEINFO *pWriteInfo)
Prepare pRti for file I/O as specified by pWriteInfo.
PWP_UINT32 BCCnt
The number of BC definitions.
Definition: apiCAEPUtils.h:148
Pointwise Grid Model API Specification (PWGM-API)
PWP_ENUM_PRECISION
File precision values.
Definition: apiPWP.h:718
CAEP_FORMATINFO FormatInfo
The CAE Plugin format data.
Definition: apiCAEPUtils.h:131
const char * caeuDimensionToText(PWP_ENUM_DIMENSION dim)
Converts a PWP_ENUM_DIMENSION value to a text string representation.
CAEPU_ENUM_CLOCKS
Supported CAEPU clock id values.
Definition: apiCAEPUtils.h:104
Customizes the typedef CAEP_RTITEM declaration.
void caeuSendErrorMsg(CAEP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send an error text message (PWP_MSGID_ERROR) to the framework.
PWP_BOOL caeuProgressIncr(CAEP_RTITEM *pRti)
Completes a progress tracking sub-step.
PWP_BOOL caeuProgressEndStep(CAEP_RTITEM *pRti)
Completes a progress tracking major step.
CAEP_VCINFO * pVCInfo
Pointer to an array of supported VC definitions.
Definition: apiCAEPUtils.h:155
void caeuSendWarningMsg(CAEP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send a warning text message (PWP_MSGID_WARNING) to the framework.
PWP_BOOL caeuProgressBeginStep(CAEP_RTITEM *pRti, PWP_UINT32 total)
Begins a progress tracking step.
PWP_UINT32 caepFormatCnt
The number of entries in caepRtItem[] array.
Definition: apiCAEP.cxx:38
Unformatted file data block.
Definition: apiPWPUtils.h:346
CAEP_RTITEM caepRtItem[]
The runtime array of CAEP_RTITEM items.
Definition: apiCAEP.cxx:32
FILE * fp
Runtime FILE pointer.
Definition: apiCAEPUtils.h:201
const CAEP_WRITEINFO * pWriteInfo
Runtime export CAEP_WRITEINFO data.
Definition: apiCAEPUtils.h:224
int caeuFileClose(CAEP_RTITEM *pRti, const CAEP_WRITEINFO *pWriteInfo)
Closes pRti for file I/O as specified by pWriteInfo.
Volume condition definition information.
Definition: apiCAEP.h:168
PWP_ENUM_DIMENSION
Supported dimensionality values.
Definition: apiPWP.h:679
PWP_BOOL caeuProgressInit(CAEP_RTITEM *pRti, PWP_UINT32 cnt)
Initializes a progress tracking session.
PWP_BOOL caeuAssignInfoValue(const char key[], const char value[], bool createIfNotExists=true)
Creates a key/value pair that defines a CAE info attribute.
int PWP_BOOL
logical value
Definition: apiPWP.h:221
PWP_ENUM_ENCODING caeuFileEncoding(PWGM_HGRIDMODEL model)
Get the user-requested file encoding.
PWP_ENUM_ENCODING
File encoding values.
Definition: apiPWP.h:698
CAE export write control information.
Definition: apiCAEP.h:186
void caeuSendDebugMsg(CAEP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send a debug text message (PWP_MSGID_DEBUG) to the framework.
Pointwise CAE Plugin API (CAEP-API)
The runtime data representing a PWP-API suported by a plugin.
Definition: apiPWPUtils.h:44
Boundary condition definition information.
Definition: apiCAEP.h:69
PWP_UINT32 VCCnt
The number of VC definitions.
Definition: apiCAEPUtils.h:162
const char ** pFileExt
Pointer to an array of valid file extensions.
Definition: apiCAEPUtils.h:169
CAEP_RTITEM * caeuFindFormatByName(const char name[])
Find an item in caepRtItem[] by it&#39;s name.
const char * caeuPrecisionToText(PWP_ENUM_PRECISION prec)
Converts a PWP_ENUM_PRECISION value to a text string representation.
CAEP_BCINFO * pBCInfo
Pointer to an array of supported BC definitions.
Definition: apiCAEPUtils.h:142
PWP_ENDIANNESS caeuFileByteOrder(PWGM_HGRIDMODEL model)
Get the user-requested file byte order.
PWP_BOOL caeuPublishValueDefinition(const char key[], PWP_ENUM_VALTYPE type, const char value[], const char access[], const char desc[], const char range[])
Creates a collection of key/value pairs that represent a published CAE attribute definition.
void caeuSendInfoMsg(CAEP_RTITEM *pRti, const char txt[], PWP_UINT32 code)
Send an info text message (PWP_MSGID_INFO) to the framework.
PWP_ENUM_PRECISION caeuFilePrecision(PWGM_HGRIDMODEL model)
Get the user-requested file precision.
PWP_ENDIANNESS
Flags used to indicate endianness or control endian behaviors in functions.
Definition: apiPWP.h:738
The data representing a CAE exporter instance.
Definition: apiCAEPUtils.h:126
PWP_BOOL caeuCombineAnisotropic(PWGM_HGRIDMODEL model)
Get the user-requested recombine setting.
void caeuProgressEnd(CAEP_RTITEM *pRti, PWP_BOOL ok)
Ends all progress tracking.
PWP_UINT32 ExtCnt
The number of valid file extensions.
Definition: apiCAEPUtils.h:175
An opaque handle to a grid model.
Definition: apiGridModel.h:327
PWP_BOOL caeuExportStructuredAsUnstructured(PWGM_HGRIDMODEL model)
Get the user-requested structured grid handling.
PWGM_HGRIDMODEL model
Runtime grid model handle to export.
Definition: apiCAEPUtils.h:218
PWP_BOOL caeuExportBndryConditionsOnly(PWGM_HGRIDMODEL model)
Get the user-requested bc export option.
PWP_BOOL elemType[PWGM_ELEMTYPE_SIZE]
Array of supported element-type flags.
Definition: apiCAEPUtils.h:182
Data and functions useful to PWP-API compliant plugins.