@@ -889,8 +889,8 @@ void serializeGrid(COMMON_NS::DataObjectRepository * repo, EML2_NS::AbstractHdfP
889889 ijkgrid432rh->setCellGeometryIsDefinedFlags (enabledCells32rh);
890890
891891 // 4*3*2 explicit grid with gap layer
892- bool kgap[ 1 ] = { true } ;
893- RESQML2_NS::IjkGridExplicitRepresentation* ijkgrid432gap = repo->createIjkGridExplicitRepresentation (" c14755a5-e3b3-4272-99e5-fc20993b79a0" , " Four by Three by Two with gap layer" , 4 , 3 , 2 , kgap);
892+ bool kgap = true ;
893+ RESQML2_NS::IjkGridExplicitRepresentation* ijkgrid432gap = repo->createIjkGridExplicitRepresentation (" c14755a5-e3b3-4272-99e5-fc20993b79a0" , " Four by Three by Two with gap layer" , 4 , 3 , 2 , & kgap);
894894 double nodes432gap[288 ] = {
895895 0 , 150 , 300 , 150 , 150 , 300 , 375 , 150 , 300 , 550 , 150 , 350 , 700 , 150 , 350 , // IJ0K0
896896 0 , 100 , 300 , 150 , 100 , 300 , 375 , 100 , 300 , 550 , 100 , 350 , 700 , 100 , 350 , // IJ1K0
@@ -904,11 +904,11 @@ void serializeGrid(COMMON_NS::DataObjectRepository * repo, EML2_NS::AbstractHdfP
904904 0 , 0 , 360 , 150 , 0 , 360 , 375 , 0 , 360 , 550 , 0 , 410 , 700 , 0 , 410 , // IJ3K1
905905 375 , 0 , 410 , 375 , 50 , 410 , 375 , 100 , 410 , 375 , 150 , 410 , // SPLIT K1
906906 // K Gap Layer
907- 0 , 150 , 400 , 150 , 150 , 400 , 375 , 150 , 400 , 550 , 150 , 450 , 700 , 150 , 450 , // IJ0K1
908- 0 , 100 , 400 , 150 , 100 , 400 , 375 , 100 , 400 , 550 , 100 , 450 , 700 , 100 , 450 , // IJ1K1
909- 0 , 50 , 400 , 150 , 50 , 400 , 375 , 50 , 400 , 550 , 50 , 450 , 700 , 50 , 450 , // IJ2K1
910- 0 , 0 , 400 , 150 , 0 , 400 , 375 , 0 , 400 , 550 , 0 , 450 , 700 , 0 , 450 , // IJ3K1
911- 375 , 0 , 450 , 375 , 50 , 450 , 375 , 100 , 450 , 375 , 150 , 450 , // SPLIT K1
907+ 0 , 150 , 400 , 150 , 150 , 400 , 375 , 150 , 400 , 550 , 150 , 450 , 700 , 150 , 450 , // IJ0K2
908+ 0 , 100 , 400 , 150 , 100 , 400 , 375 , 100 , 400 , 550 , 100 , 450 , 700 , 100 , 450 , // IJ1K2
909+ 0 , 50 , 400 , 150 , 50 , 400 , 375 , 50 , 400 , 550 , 50 , 450 , 700 , 50 , 450 , // IJ2K2
910+ 0 , 0 , 400 , 150 , 0 , 400 , 375 , 0 , 400 , 550 , 0 , 450 , 700 , 0 , 450 , // IJ3K2
911+ 375 , 0 , 450 , 375 , 50 , 450 , 375 , 100 , 450 , 375 , 150 , 450 , // SPLIT K2
912912
913913 0 , 150 , 500 , 150 , 150 , 500 , 375 , 150 , 500 , 550 , 150 , 550 , 700 , 150 , 550 , // IJ0K3
914914 0 , 100 , 500 , 150 , 100 , 500 , 375 , 100 , 500 , 550 , 100 , 550 , 700 , 100 , 550 , // IJ1K3
@@ -921,11 +921,11 @@ void serializeGrid(COMMON_NS::DataObjectRepository * repo, EML2_NS::AbstractHdfP
921921 unsigned int splitCoordinateLineColumns432gap[6 ] = { 10 , 10 , 6 , 6 , 2 , 2 };
922922 ijkgrid432gap->setGeometryAsCoordinateLineNodes (gsoap_resqml2_0_1::resqml20__PillarShape::vertical, gsoap_resqml2_0_1::resqml20__KDirection::down, true , nodes432gap, hdfProxy,
923923 4 , pillarOfCoordinateLine432gap, splitCoordinateLineColumnCumulativeCount432gap, splitCoordinateLineColumns432gap);
924- unsigned char enabledCells32gap [24 ] = {
924+ uint8_t enabledCells432gap [24 ] = {
925925 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 ,
926926 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0
927927 };
928- ijkgrid432gap->setCellGeometryIsDefinedFlags (enabledCells32gap );
928+ ijkgrid432gap->setCellGeometryIsDefinedFlags (enabledCells432gap );
929929
930930 /* *************
931931 Subrepresentations
@@ -3139,19 +3139,21 @@ void deserializeGridHyperslabbingInterfaceSequence(const COMMON_NS::DataObjectRe
31393139
31403140 ijkGrid->loadSplitInformation ();
31413141
3142- if (ijkGrid->getKGapsCount () > 0 ) {
3142+ const uint64_t kGapsCount = ijkGrid->getKGapsCount ();
3143+ const size_t kCellCount = ijkGrid->getKCellCount ();
3144+ if (kGapsCount > 0 && kCellCount > 1 ) {
31433145
31443146 // here, we read a grid interface by interface. Each interface is read
31453147 // in i then j direction
31463148 cout << " INTERFACE BY INTERFACE" << std::endl;
31473149
3148- std::unique_ptr<bool []> gapAfterLayer (new bool [ijkGrid-> getKCellCount () - 1 ]);
3150+ std::unique_ptr<bool []> gapAfterLayer (new bool [kCellCount - 1 ]);
31493151 ijkGrid->getKGaps (gapAfterLayer.get ());
31503152
31513153 unsigned int kLayer = 0 ;
31523154 unsigned int cornerShift = 0 ;
31533155
3154- for (unsigned int kInterface = 0 ; kInterface < ijkGrid-> getKCellCount () + 1 + ijkGrid-> getKGapsCount () ; kInterface ++) {
3156+ for (unsigned int kInterface = 0 ; kInterface < kCellCount + 1 + kGapsCount ; kInterface ++) {
31553157 cout << " INTERFACE: " << kInterface << std::endl;
31563158
31573159 std::unique_ptr<double []> interfaceXyzPoints (new double [ijkGrid->getXyzPointCountOfKInterface () * 3 ]);
@@ -3191,7 +3193,7 @@ void deserializeGridHyperslabbingInterfaceSequence(const COMMON_NS::DataObjectRe
31913193 }
31923194 }
31933195
3194- if (cornerShift == 4 || (!gapAfterLayer[ kLayer ] && kInterface != ijkGrid-> getKCellCount () + ijkGrid-> getKGapsCount () - 1 )) {
3196+ if (cornerShift == 4 || (kInterface != kCellCount + kGapsCount - 1 && !gapAfterLayer[ kLayer ] )) {
31953197 kLayer ++;
31963198 cornerShift = 0 ;
31973199 }
@@ -3207,7 +3209,7 @@ void deserializeGridHyperslabbingInterfaceSequence(const COMMON_NS::DataObjectRe
32073209
32083210 int kInterface = 0 ;
32093211
3210- for (unsigned int kLayer = 0 ; kLayer < ijkGrid-> getKCellCount () ; kLayer ++)
3212+ for (unsigned int kLayer = 0 ; kLayer < kCellCount ; kLayer ++)
32113213 {
32123214 cout << " LAYER: " << kLayer << std::endl;
32133215
@@ -3283,15 +3285,20 @@ void deserializeGridHyperslabbingInterfaceSequence(const COMMON_NS::DataObjectRe
32833285 }
32843286 }
32853287
3286- kInterface = gapAfterLayer[kLayer ] ? kInterface + 2 : kInterface + 1 ;
3288+ if (kLayer < kCellCount - 1 ) {
3289+ kInterface = gapAfterLayer[kLayer ] ? kInterface + 2 : kInterface + 1 ;
3290+ }
32873291 }
32883292 }
3293+ else if (kGapsCount > 0 ) {
3294+ std::cout << " Not enough K Layer (" << kCellCount << " ) to have K Gaps (" << kGapsCount << " )" << std::endl;
3295+ }
32893296 else { // no K gap
32903297 // here, we read a grid interface by interface. Each interface is read
32913298 // in i then j direction
32923299 cout << " INTERFACE BY INTERFACE" << std::endl;
32933300
3294- for (unsigned int kInterface = 0 ; kInterface < ijkGrid-> getKCellCount () ; kInterface ++) {
3301+ for (unsigned int kInterface = 0 ; kInterface < kCellCount ; kInterface ++) {
32953302 cout << " INTERFACE: " << kInterface << std::endl;
32963303
32973304 std::unique_ptr<double []> interfaceXyzPoints (new double [ijkGrid->getXyzPointCountOfKInterface () * 3 ]);
@@ -3338,44 +3345,44 @@ void deserializeGridHyperslabbingInterfaceSequence(const COMMON_NS::DataObjectRe
33383345 }
33393346
33403347 // last interface differs from the other because of getXyzPointIndexFromCellCorner usage
3341- cout << " INTERFACE: " << ijkGrid-> getKCellCount () << std::endl;
3348+ cout << " INTERFACE: " << kCellCount << std::endl;
33423349
33433350 std::unique_ptr<double []> interfaceXyzPoints (new double [ijkGrid->getXyzPointCountOfKInterface () * 3 ]);
3344- ijkGrid->getXyzPointsOfKInterface (ijkGrid-> getKCellCount () , interfaceXyzPoints.get ());
3351+ ijkGrid->getXyzPointsOfKInterface (kCellCount , interfaceXyzPoints.get ());
33453352
33463353 for (unsigned int i = 0 ; i < ijkGrid->getICellCount (); i++)
33473354 {
33483355 for (unsigned int j = 0 ; j < ijkGrid->getJCellCount (); j++)
33493356 {
3350- cout << " CELL (" << i << " , " << j << " , " << ijkGrid-> getKCellCount () - 1 << " )" << std::endl;
3357+ cout << " CELL (" << i << " , " << j << " , " << kCellCount - 1 << " )" << std::endl;
33513358
33523359 uint64_t xyzPointIndex;
33533360 double x, y, z;
3354- uint64_t indexShift = ijkGrid-> getKCellCount () * ijkGrid->getXyzPointCountOfKInterface () * 3 ;
3361+ uint64_t indexShift = kCellCount * ijkGrid->getXyzPointCountOfKInterface () * 3 ;
33553362
33563363 // Corner (0, 0, 1)
3357- xyzPointIndex = ijkGrid->getXyzPointIndexFromCellCorner (i, j, ijkGrid-> getKCellCount () - 1 , 4 ) * 3 - indexShift;
3364+ xyzPointIndex = ijkGrid->getXyzPointIndexFromCellCorner (i, j, kCellCount - 1 , 4 ) * 3 - indexShift;
33583365 x = interfaceXyzPoints[xyzPointIndex];
33593366 y = interfaceXyzPoints[xyzPointIndex + 1 ];
33603367 z = interfaceXyzPoints[xyzPointIndex + 2 ];
33613368 cout << " CORNER (0, 0, 1): " << x << " " << y << " " << z << std::endl;
33623369
33633370 // Corner (1, 0, 1)
3364- xyzPointIndex = ijkGrid->getXyzPointIndexFromCellCorner (i, j, ijkGrid-> getKCellCount () - 1 , 5 ) * 3 - indexShift;
3371+ xyzPointIndex = ijkGrid->getXyzPointIndexFromCellCorner (i, j, kCellCount - 1 , 5 ) * 3 - indexShift;
33653372 x = interfaceXyzPoints[xyzPointIndex];
33663373 y = interfaceXyzPoints[xyzPointIndex + 1 ];
33673374 z = interfaceXyzPoints[xyzPointIndex + 2 ];
33683375 cout << " CORNER (1, 0, 1): " << x << " " << y << " " << z << std::endl;
33693376
33703377 // Corner (1, 1, 1)
3371- xyzPointIndex = ijkGrid->getXyzPointIndexFromCellCorner (i, j, ijkGrid-> getKCellCount () - 1 , 6 ) * 3 - indexShift;
3378+ xyzPointIndex = ijkGrid->getXyzPointIndexFromCellCorner (i, j, kCellCount - 1 , 6 ) * 3 - indexShift;
33723379 x = interfaceXyzPoints[xyzPointIndex];
33733380 y = interfaceXyzPoints[xyzPointIndex + 1 ];
33743381 z = interfaceXyzPoints[xyzPointIndex + 2 ];
33753382 cout << " CORNER (1, 1, 1): " << x << " " << y << " " << z << std::endl;
33763383
33773384 // Corner (0, 1, 1)
3378- xyzPointIndex = ijkGrid->getXyzPointIndexFromCellCorner (i, j, ijkGrid-> getKCellCount () - 1 , 7 ) * 3 - indexShift;
3385+ xyzPointIndex = ijkGrid->getXyzPointIndexFromCellCorner (i, j, kCellCount - 1 , 7 ) * 3 - indexShift;
33793386 x = interfaceXyzPoints[xyzPointIndex];
33803387 y = interfaceXyzPoints[xyzPointIndex + 1 ];
33813388 z = interfaceXyzPoints[xyzPointIndex + 2 ];
@@ -3388,7 +3395,7 @@ void deserializeGridHyperslabbingInterfaceSequence(const COMMON_NS::DataObjectRe
33883395 cout << " --------------------------------------------------" << std::endl;
33893396 cout << " LAYER BY LAYER" << std::endl;
33903397
3391- for (unsigned int kInterface = 0 ; kInterface < ijkGrid-> getKCellCount () ; kInterface ++)
3398+ for (unsigned int kInterface = 0 ; kInterface < kCellCount ; kInterface ++)
33923399 {
33933400 cout << " LAYER: " << kInterface << std::endl;
33943401
@@ -4820,13 +4827,20 @@ void deserializeIjkGrid(const COMMON_NS::DataObjectRepository & repo)
48204827 auto kGapCount = ijkGrid->getKGapsCount ();
48214828 std::cout << " K Gap Count" << kGapCount << std::endl;
48224829 if (kGapCount > 0 ) {
4823- std::unique_ptr<bool []> kGapAfterLayer (new bool [ijkGrid->getKCellCount () - 1 ]);
4824- for (size_t kIndex = 0 ; kIndex < ijkGrid->getKCellCount () - 1 ; ++kIndex ) {
4825- std::cout << " There is " ;
4826- if (!kGapAfterLayer [kIndex ]) {
4827- std::cout << " NOT " ;
4830+ const size_t kCellCount = ijkGrid->getKCellCount ();
4831+ if (kCellCount > 1 ) {
4832+ std::unique_ptr<bool []> kGapAfterLayer (new bool [kCellCount - 1 ]);
4833+ ijkGrid->getKGaps (kGapAfterLayer .get ());
4834+ for (size_t kIndex = 0 ; kIndex < kCellCount - 1 ; ++kIndex ) {
4835+ std::cout << " There is " ;
4836+ if (!kGapAfterLayer [kIndex ]) {
4837+ std::cout << " NOT " ;
4838+ }
4839+ std::cout << " a K gap after K layer " << kIndex << std::endl;
48284840 }
4829- std::cout << " a K gap after K layer " << kIndex << std::endl;
4841+ }
4842+ else {
4843+ std::cout << " Not enough K Layer (" << kCellCount << " ) to have K Gaps" << std::endl;
48304844 }
48314845 }
48324846
0 commit comments