Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
xDataTOM_interpolation.cc
이 파일의 문서화 페이지로 가기
1 /*
2 # <<BEGIN-copyright>>
3 # <<END-copyright>>
4 */
5 
6 #include <string.h>
7 #include "xDataTOM_private.h"
8 
9 #if defined __cplusplus
10 namespace GIDI {
11 using namespace GIDI;
12 #endif
13 
14 #define dependentAxis 1
15 #define allowByRegion 2
16 
18  char const *str, int flag );
19 /*
20 ************************************************************
21 */
23  enum xDataTOM_interpolationFlag dependent, enum xDataTOM_interpolationQualifier qualifier ) {
24 
25  if( ( independent < xDataTOM_interpolationFlag_linear ) || ( independent > xDataTOM_interpolationFlag_byRegion ) ) {
26  smr_setReportError2( smr, xDataTOM_smrLibraryID, -1, "invalid independent interpolation = %d", independent );
27  return( 1 );
28  }
29  if( ( dependent < xDataTOM_interpolationFlag_linear ) || ( dependent > xDataTOM_interpolationFlag_flat ) ) {
30  smr_setReportError2( smr, xDataTOM_smrLibraryID, -1, "invalid dependent interpolation = %d", dependent );
31  return( 1 );
32  }
34  smr_setReportError2( smr, xDataTOM_smrLibraryID, -1, "invalid interpolation qualifier = %d", qualifier );
35  return( 1 );
36  }
37 
38  interpolation->independent = independent;
39  interpolation->dependent = dependent;
40  interpolation->qualifier = qualifier;
41  return( 0 );
42 }
43 /*
44 ************************************************************
45 */
47 
48  int flag = 0;
49  char const *c, *e;
51  enum xDataTOM_interpolationFlag independent, dependent;
52 
53  if( ( c = strchr( str, ':' ) ) != NULL ) {
54  if( strncmp( "unitBase:", str, 9 ) == 0 ) {
56  else if( strncmp( "correspondingPoints:", str, 20 ) == 0 ) {
58  else {
59  smr_setReportError2( smr, xDataTOM_smrLibraryID, -1, "invalid interpolation string qualifier '%s'", str );
60  return( 1 );
61  }
62  c++; }
63  else {
64  c = str;
65  }
66  if( ( independent = xDataTOM_interpolation_getFromString( smr, c, &e, str, flag ) ) == xDataTOM_interpolationFlag_invalid ) return( 1 );
67  if( *e != ',' ) {
68  smr_setReportError2( smr, xDataTOM_smrLibraryID, -1, "missing ',' separator in interpolation string'%s'", str );
69  return( 1 );
70  }
71  c = ++e;
72  flag |= dependentAxis;
73  if( ( dependent = xDataTOM_interpolation_getFromString( smr, c, &e, str, flag ) ) == xDataTOM_interpolationFlag_invalid ) return( 1 );
74  xDataTOM_interpolation_set( smr, interpolation, independent, dependent, qualifier );
75  return( 0 );
76 }
77 /*
78 ************************************************************
79 */
81  char const *str, int flag ) {
82 
83  if( strncmp( "linear", s, 6 ) == 0 ) { *e = &(s[6]); return( xDataTOM_interpolationFlag_linear ); }
84  if( strncmp( "log", s, 3 ) == 0 ) { *e = &(s[3]); return( xDataTOM_interpolationFlag_log ); }
85  if( flag | allowByRegion ) {
86  if( strncmp( "byRegion", s, 8 ) == 0 ) { *e = &(s[8]); return( xDataTOM_interpolationFlag_byRegion ); }
87  }
88  if( flag | dependentAxis ) {
89  if( strncmp( "flat", s, 4 ) == 0 ) { *e = &(s[4]); return( xDataTOM_interpolationFlag_flat ); }
90  }
91  smr_setReportError2( smr, xDataTOM_smrLibraryID, -1, "invalid interpolation component '%s' in string '%s'", s, str );
93 
94 /* Currently not supported.
95  otherToken = 'other'
96  chargedParticleToken = 'charged-particle'
97 */
98 }
99 /*
100 ************************************************************
101 */
103 
104  return( xDataTOM_interpolation_set( smr, desc, src->independent, src->dependent, src->qualifier ) );
105 }
106 
107 #if defined __cplusplus
108 }
109 #endif
int xDataTOM_interpolation_set(statusMessageReporting *smr, xDataTOM_interpolation *interpolation, enum xDataTOM_interpolationFlag independent, enum xDataTOM_interpolationFlag dependent, enum xDataTOM_interpolationQualifier qualifier)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
static enum xDataTOM_interpolationFlag xDataTOM_interpolation_getFromString(statusMessageReporting *smr, char const *s, char const **e, char const *str, int flag)
xDataTOM_interpolationQualifier
Definition: xDataTOM.h:21
enum xDataTOM_interpolationFlag independent dependent
Definition: xDataTOM.h:57
const XML_Char * s
Definition: expat.h:262
#define dependentAxis
int xDataTOM_interpolation_copy(statusMessageReporting *smr, xDataTOM_interpolation *desc, xDataTOM_interpolation *src)
#define allowByRegion
int xDataTOM_interpolation_setFromString(statusMessageReporting *smr, xDataTOM_interpolation *interpolation, char const *str)
xDataTOM_interpolationFlag
Definition: xDataTOM.h:19
int xDataTOM_smrLibraryID
Definition: xDataTOM.cc:34
enum xDataTOM_interpolationQualifier qualifier
Definition: xDataTOM.h:58