Skip to content

Commit

Permalink
V0.13 (#77)
Browse files Browse the repository at this point in the history
* Can list all UUIDs
* Remove warning for partial objects
* Automatically compute K Direction for parametric IJK grid
  • Loading branch information
philippeVerney authored Oct 16, 2018
1 parent 6f0730d commit 2b6502a
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 28 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ SET (FESAPI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})

# version mechanism
set (Fesapi_VERSION_MAJOR 0)
set (Fesapi_VERSION_MINOR 12)
set (Fesapi_VERSION_PATCH 1)
set (Fesapi_VERSION_MINOR 13)
set (Fesapi_VERSION_PATCH 0)
set (Fesapi_VERSION_TWEAK 0)

set (Fesapi_VERSION ${Fesapi_VERSION_MAJOR}.${Fesapi_VERSION_MINOR}.${Fesapi_VERSION_PATCH}.${Fesapi_VERSION_TWEAK})
Expand Down
12 changes: 9 additions & 3 deletions example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ void serializeGrid(COMMON_NS::EpcDocument * pck, COMMON_NS::AbstractHdfProxy* hd
400, 400, 450, 400, 400, 450, /* SPLIT*/ 450, 450,
500, 500, 550, 500, 500, 550, /* SPLIT*/ 550, 550 };
double controlPoints[18] = { 0, 0, 300, 375, 0, 300, 700, 0, 350, 0, 150, 300, 375, 150, 300, 700, 150, 350 };
ijkgridParametric->setGeometryAsParametricSplittedPillarNodes(gsoap_resqml2_0_1::resqml2__KDirection__down, false, parameters, controlPoints, NULL, 1, 0, hdfProxy,
ijkgridParametric->setGeometryAsParametricSplittedPillarNodes(false, parameters, controlPoints, NULL, 1, 0, hdfProxy,
2, pillarOfCoordinateLine, splitCoordinateLineColumnCumulativeCount, splitCoordinateLineColumns);

// FOUR SUGARS PARAMETRIC STRAIGHT
Expand All @@ -472,7 +472,7 @@ void serializeGrid(COMMON_NS::EpcDocument * pck, COMMON_NS::AbstractHdfProxy* hd
0, 0, 500, 375, 0, 500, 700, 0, 550, 0, 150, 500, 375, 150, 500, 700, 150, 550 };
double controlPointsParameters[12] = { 300, 300, 350, 300, 300, 350,
500, 500, 550, 500, 500, 550 };
ijkgridParametricStraight->setGeometryAsParametricSplittedPillarNodes(gsoap_resqml2_0_1::resqml2__KDirection__down, false, parameters, controlPointsParametricStraight, controlPointsParameters, 2, 1, hdfProxy,
ijkgridParametricStraight->setGeometryAsParametricSplittedPillarNodes(false, parameters, controlPointsParametricStraight, controlPointsParameters, 2, 1, hdfProxy,
2, pillarOfCoordinateLine, splitCoordinateLineColumnCumulativeCount, splitCoordinateLineColumns);

// FOUR SUGARS PARAMETRIC different line kind and one cubic pillar
Expand All @@ -485,7 +485,7 @@ void serializeGrid(COMMON_NS::EpcDocument * pck, COMMON_NS::AbstractHdfProxy* hd
1000, 400, nan, nan, nan, nan,
nan, 600, nan, nan, nan, nan };
short pillarKind[6] = { 1, 4, 0, 0, 0, 0 };
ijkgridParametricNotSameLineKind->setGeometryAsParametricSplittedPillarNodes(gsoap_resqml2_0_1::resqml2__PillarShape__straight, gsoap_resqml2_0_1::resqml2__KDirection__down, false, parameters, controlPointsNotSameLineKind, controlPointParametersNotSameLineKind, 3, pillarKind, hdfProxy,
ijkgridParametricNotSameLineKind->setGeometryAsParametricSplittedPillarNodes(gsoap_resqml2_0_1::resqml2__PillarShape__straight, false, parameters, controlPointsNotSameLineKind, controlPointParametersNotSameLineKind, 3, pillarKind, hdfProxy,
2, pillarOfCoordinateLine, splitCoordinateLineColumnCumulativeCount, splitCoordinateLineColumns);

// FOUR SUGARS PARAMETRIC different line kind an one cubic pillar : A copy
Expand Down Expand Up @@ -2565,6 +2565,12 @@ void deserialize(const string & inputFile)
cout << "Press enter to continue..." << endl;
cin.get();
}
std::vector<std::string> allUuids = pck.getAllUuids();
std::cout << "********************** UUIDS **********************" << std::endl;
for (size_t index = 0; index < allUuids.size(); ++index) {
std::cout << allUuids[index] << std::endl;
}
std::cout << "***************************************************" << std::endl;

unsigned int hdfProxyCount = pck.getHdfProxyCount();
cout << "There are " << pck.getHdfProxyCount() << " hdf files associated to this epc document." << endl;
Expand Down
18 changes: 16 additions & 2 deletions src/common/EpcDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,22 @@ const std::unordered_map< std::string, COMMON_NS::AbstractObject* > & EpcDocumen
const std::tr1::unordered_map< std::string, COMMON_NS::AbstractObject* > & EpcDocument::getResqmlAbstractObjectSet() const { return resqmlAbstractObjectSet; }
#endif

std::vector<std::string> EpcDocument::getAllUuids() const
{
std::vector<std::string> keys;
keys.reserve(resqmlAbstractObjectSet.size());

#if (defined(_WIN32) && _MSC_VER >= 1600) || defined(__APPLE__)
for (std::unordered_map< std::string, COMMON_NS::AbstractObject* >::const_iterator it = resqmlAbstractObjectSet.begin(); it != resqmlAbstractObjectSet.end(); ++it) {
#else
for (std::tr1::unordered_map< std::string, COMMON_NS::AbstractObject* >::const_iterator it = resqmlAbstractObjectSet.begin(); it != resqmlAbstractObjectSet.end(); ++it) {
#endif
keys.push_back(it->first);
}

return keys;
}

std::vector<PRODML2_0_NS::DasAcquisition*> EpcDocument::getDasAcquisitionSet() const
{
std::vector<PRODML2_0_NS::DasAcquisition*> result;
Expand Down Expand Up @@ -1509,8 +1525,6 @@ std::string EpcDocument::getExtendedCoreProperty(const std::string & key)

COMMON_NS::AbstractObject* EpcDocument::createPartial(gsoap_resqml2_0_1::eml20__DataObjectReference* dor)
{
addWarning("Create a partial object for object \"" + dor->Title + "\" with UUID " + dor->UUID + " and content type " + dor->ContentType);

const size_t lastEqualCharPos = dor->ContentType.find_last_of('_'); // The XML tag is after "obj_"
const string resqmlContentType = dor->ContentType.substr(lastEqualCharPos + 1);

Expand Down
9 changes: 7 additions & 2 deletions src/common/EpcDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,12 @@ namespace COMMON_NS
#endif

/**
* Get the Gsoap type by means of its uuid
* Get all UUIDs of the objects contained in the EPC document
*/
std::vector<std::string> getAllUuids() const;

/**
* Get the Gsoap type by means of its uuid
*/
COMMON_NS::AbstractObject* getResqmlAbstractObjectByUuid(const std::string & uuid, int & gsoapType) const;

Expand Down Expand Up @@ -1223,7 +1228,7 @@ namespace COMMON_NS
std::vector<RESQML2_NS::RepresentationSetRepresentation*> representationSetRepresentationSet;
std::vector<WITSML1_4_1_1_NS::Trajectory*> witsmlTrajectorySet;
std::vector<RESQML2_0_1_NS::TriangulatedSetRepresentation*> triangulatedSetRepresentationSet;
std::vector<resqml2_0_1::Grid2dRepresentation*> grid2dRepresentationSet;
std::vector<RESQML2_0_1_NS::Grid2dRepresentation*> grid2dRepresentationSet;
std::vector<RESQML2_0_1_NS::PolylineRepresentation*> polylineRepresentationSet;
std::vector<RESQML2_0_1_NS::AbstractIjkGridRepresentation*> ijkGridRepresentationSet;
std::vector<RESQML2_0_1_NS::UnstructuredGridRepresentation*> unstructuredGridRepresentationSet;
Expand Down
97 changes: 91 additions & 6 deletions src/resqml2_0_1/IjkGridParametricRepresentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,10 +1162,10 @@ void IjkGridParametricRepresentation::getXyzPointsOfPatch(const unsigned int & p
}

void IjkGridParametricRepresentation::setGeometryAsParametricNonSplittedPillarNodes(
const gsoap_resqml2_0_1::resqml2__PillarShape & mostComplexPillarGeometry, const gsoap_resqml2_0_1::resqml2__KDirection & kDirectionKind, const bool & isRightHanded,
const gsoap_resqml2_0_1::resqml2__PillarShape & mostComplexPillarGeometry, const bool & isRightHanded,
double * parameters, double * controlPoints, double * controlPointParameters, const unsigned int & controlPointMaxCountPerPillar, short * pillarKind, COMMON_NS::AbstractHdfProxy* proxy)
{
setGeometryAsParametricSplittedPillarNodes(mostComplexPillarGeometry, kDirectionKind, isRightHanded, parameters, controlPoints, controlPointParameters, controlPointMaxCountPerPillar, pillarKind, proxy,
setGeometryAsParametricSplittedPillarNodes(mostComplexPillarGeometry, isRightHanded, parameters, controlPoints, controlPointParameters, controlPointMaxCountPerPillar, pillarKind, proxy,
0, nullptr, nullptr, nullptr);
}

Expand All @@ -1178,7 +1178,7 @@ void IjkGridParametricRepresentation::setGeometryAsParametricNonSplittedPillarNo
}

void IjkGridParametricRepresentation::setGeometryAsParametricSplittedPillarNodes(
const gsoap_resqml2_0_1::resqml2__PillarShape & mostComplexPillarGeometry, const gsoap_resqml2_0_1::resqml2__KDirection & kDirectionKind, const bool & isRightHanded,
const gsoap_resqml2_0_1::resqml2__PillarShape & mostComplexPillarGeometry, const bool & isRightHanded,
double * parameters, double * controlPoints, double * controlPointParameters, const unsigned int & controlPointMaxCountPerPillar, short * pillarKind, COMMON_NS::AbstractHdfProxy * proxy,
const unsigned long & splitCoordinateLineCount, unsigned int * pillarOfCoordinateLine,
unsigned int * splitCoordinateLineColumnCumulativeCount, unsigned int * splitCoordinateLineColumns)
Expand All @@ -1187,7 +1187,7 @@ void IjkGridParametricRepresentation::setGeometryAsParametricSplittedPillarNodes
throw invalid_argument("The kind of the coordinate lines cannot be null.");
}

setGeometryAsParametricSplittedPillarNodes(kDirectionKind, isRightHanded, parameters, controlPoints, controlPointParameters, controlPointMaxCountPerPillar, 2, proxy,
setGeometryAsParametricSplittedPillarNodes(isRightHanded, parameters, controlPoints, controlPointParameters, controlPointMaxCountPerPillar, 2, proxy,
splitCoordinateLineCount, pillarOfCoordinateLine, splitCoordinateLineColumnCumulativeCount, splitCoordinateLineColumns);

gsoap_resqml2_0_1::resqml2__IjkGridGeometry* geom = static_cast<gsoap_resqml2_0_1::resqml2__IjkGridGeometry*>(getPointGeometry2_0_1(0));
Expand Down Expand Up @@ -1282,8 +1282,7 @@ void IjkGridParametricRepresentation::setGeometryAsParametricSplittedPillarNodes
xmlLineKinds->Values->PathInHdfFile = pillarKind;
}

void IjkGridParametricRepresentation::setGeometryAsParametricSplittedPillarNodes(
const gsoap_resqml2_0_1::resqml2__KDirection & kDirectionKind, const bool & isRightHanded,
void IjkGridParametricRepresentation::setGeometryAsParametricSplittedPillarNodes(const bool & isRightHanded,
double * parameters, double * controlPoints, double * controlPointParameters, const unsigned int & controlPointCountPerPillar, short pillarKind, COMMON_NS::AbstractHdfProxy * proxy,
const unsigned long & splitCoordinateLineCount, unsigned int * pillarOfCoordinateLine,
unsigned int * splitCoordinateLineColumnCumulativeCount, unsigned int * splitCoordinateLineColumns)
Expand All @@ -1298,6 +1297,8 @@ void IjkGridParametricRepresentation::setGeometryAsParametricSplittedPillarNodes
throw invalid_argument("The definition of the split coordinate lines is incomplete.");
}

gsoap_resqml2_0_1::resqml2__KDirection kDirectionKind = computeKDirection(controlPoints, controlPointCountPerPillar);

const std::string hdfDatasetPrefix = "/RESQML/" + gsoapProxy2_0_1->uuid;
setGeometryAsParametricSplittedPillarNodesUsingExistingDatasets(kDirectionKind, isRightHanded,
hdfDatasetPrefix + "/PointParameters", hdfDatasetPrefix + "/ControlPoints", controlPointParameters != nullptr ? hdfDatasetPrefix + "/controlPointParameters" : "", controlPointCountPerPillar, pillarKind, proxy,
Expand Down Expand Up @@ -1764,3 +1765,87 @@ AbstractIjkGridRepresentation::geometryKind IjkGridParametricRepresentation::get
return PARAMETRIC;
}

namespace {
/**
* @param controlPointIndex The index of the first control point of the studied pillar in the controlPoints array
*/
short computeKDirectionOnASinglePillar(unsigned int pillarIndex, unsigned int pillarCount, double * controlPoints, const unsigned int & controlPointCountOnPillar, bool isCrsDepthOriented) {
short result = -1;

size_t controlPointIndex = pillarIndex * 3 + 2;
double firstZ = controlPoints[controlPointIndex];
if (firstZ != firstZ) { // The pillar is undefined
return -1;
}
unsigned int pillarCountTimes3 = pillarCount * 3; // optim
controlPointIndex += pillarCountTimes3;

for (; controlPointIndex < controlPointCountOnPillar * pillarCountTimes3; controlPointIndex += pillarCountTimes3) {
if (controlPoints[controlPointIndex] != controlPoints[controlPointIndex]) { // The pillar definition is already complete
break;
}
if (controlPoints[controlPointIndex] == firstZ) { // The K Direction cannot be deduced
continue;
}

gsoap_resqml2_0_1::resqml2__KDirection tmp = gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__not_x0020monotonic;
if (isCrsDepthOriented) {
tmp = controlPoints[controlPointIndex] > firstZ
? gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__down
: gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__up;
}
else {
tmp = controlPoints[controlPointIndex] > firstZ
? gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__up
: gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__down;
}

if (result == -1) {
result = tmp;
}
else if (result != tmp) {
return gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__not_x0020monotonic;
}
}

return result;
}
}

gsoap_resqml2_0_1::resqml2__KDirection IjkGridParametricRepresentation::computeKDirection(double * controlPoints, const unsigned int & controlPointCountPerPillar) {
if (controlPoints == nullptr) {
throw invalid_argument("The control points cannot be null.");
}
if (controlPointCountPerPillar < 1) {
throw invalid_argument("The max count of control points per coordinate line of the ijk grid cannot be less than one.");
}

if (controlPointCountPerPillar == 1) {
return gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__down; // arbitrary default
}

// CRS
const bool isCrsDepthOriented = getLocalCrs()->isDepthOriented();

// Initialization
short result = -1;
unsigned int pillarIndex = 0;
for (; pillarIndex < getPillarCount() && result == -1; ++pillarIndex) {
result = computeKDirectionOnASinglePillar(pillarIndex, getPillarCount(), controlPoints, controlPointCountPerPillar, isCrsDepthOriented);
}
if (result == gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__not_x0020monotonic)
return gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__not_x0020monotonic;

// Loop
for (; pillarIndex < getPillarCount(); ++pillarIndex) {
size_t controlPointIndex = pillarIndex * controlPointCountPerPillar * 3 + 2;
short tmp = computeKDirectionOnASinglePillar(pillarIndex, getPillarCount(), controlPoints, controlPointCountPerPillar, isCrsDepthOriented);
if (tmp != -1 && tmp != result) {
return gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__not_x0020monotonic;
}
}

return result < 0
? gsoap_resqml2_0_1::resqml2__KDirection::resqml2__KDirection__down // arbitrary default
: static_cast<gsoap_resqml2_0_1::resqml2__KDirection>(result);
}
15 changes: 8 additions & 7 deletions src/resqml2_0_1/IjkGridParametricRepresentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ namespace RESQML2_0_1_NS
* It allows to accelerate getter of xyz points when reading them by K interface
*/
void loadPillarInformation(PillarInformation & pillarInfo) const;

/**
* Compute the K Direction of the gid according to its contorl points.
*/
gsoap_resqml2_0_1::resqml2__KDirection computeKDirection(double * controlPoints, const unsigned int & controlPointCountPerPillar);
protected:
PillarInformation* pillarInformation;

Expand Down Expand Up @@ -175,7 +180,6 @@ namespace RESQML2_0_1_NS
* Set the geometry of the IJK grid as parametric pillar nodes where no pillar is splitted.
* Defined pillars are deduced from pillarKind == -1;
* @param mostComplexPillarGeometry The most complex pillar shape which we can find on this ijk grid.
* @param kDirectionKind Indicates if the K direction always go up, dow or is not monotonic.
* @param isRightHanded Indicates that the IJK grid is right handed, as determined by the triple product of tangent vectors in the I, J, and K directions.
* @param parameters The parameter values (regarding the pillars) of each node of the grid.
* @param controlPoints The control points of the pillars of the grid. They are ordered first (quickest) by pillar and then (slowest) by control point : cp0 of pillar0, cp0 of pillar1, cp0 of pillar3, ..., cp0 of pillarCount-1, cp1 of pillar0, cp1 of pillar1, etc... Pad with nan values if necessary.
Expand All @@ -186,7 +190,7 @@ namespace RESQML2_0_1_NS
* @param splitCoordinateLineCount The count of split coordinate line in this grid. A pillar being splitted by a maximum of 3 split coordinate lines (one coordinate line is always non splitted)
*/
void setGeometryAsParametricNonSplittedPillarNodes(
const gsoap_resqml2_0_1::resqml2__PillarShape & mostComplexPillarGeometry, const gsoap_resqml2_0_1::resqml2__KDirection & kDirectionKind, const bool & isRightHanded,
const gsoap_resqml2_0_1::resqml2__PillarShape & mostComplexPillarGeometry, const bool & isRightHanded,
double * parameters, double * controlPoints, double * controlPointParameters, const unsigned int & controlPointMaxCountPerPillar, short * pillarKind, COMMON_NS::AbstractHdfProxy* proxy);

/**
Expand All @@ -201,7 +205,6 @@ namespace RESQML2_0_1_NS
* Set the geometry of the IJK grid as parametric pillar nodes where at least one pillar is supposed to be splitted
* Defined pillars are deduced from pillarKind == -1;
* @param mostComplexPillarGeometry The most complex pillar shape which we can find on this ijk grid.
* @param kDirectionKind Indicates if the K direction always go up, dow or is not monotonic.
* @param isRightHanded Indicates that the IJK grid is right handed, as determined by the triple product of tangent vectors in the I, J, and K directions.
* @param parameters The parameter values (regarding the pillars) of each node of the grid.
* @param controlPoints The control points of the pillars of the grid. They are ordered first (quickest) by pillar and then (slowest) by control point : cp0 of pillar0, cp0 of pillar1, cp0 of pillar3, ..., cp0 of pillarCount-1, cp1 of pillar0, cp1 of pillar1, etc... Pad with nan values if necessary.
Expand All @@ -215,7 +218,7 @@ namespace RESQML2_0_1_NS
* @param splitCoordinateLineColumns For each split coordinate line, indicates the grid columns which are splitted by this coordinate line.
*/
void setGeometryAsParametricSplittedPillarNodes(
const gsoap_resqml2_0_1::resqml2__PillarShape & mostComplexPillarGeometry, const gsoap_resqml2_0_1::resqml2__KDirection & kDirectionKind, const bool & isRightHanded,
const gsoap_resqml2_0_1::resqml2__PillarShape & mostComplexPillarGeometry, const bool & isRightHanded,
double * parameters, double * controlPoints, double * controlPointParameters, const unsigned int & controlPointMaxCountPerPillar, short * pillarKind, COMMON_NS::AbstractHdfProxy* proxy,
const unsigned long & splitCoordinateLineCount, unsigned int * pillarOfCoordinateLine,
unsigned int * splitCoordinateLineColumnCumulativeCount, unsigned int * splitCoordinateLineColumns);
Expand All @@ -233,7 +236,6 @@ namespace RESQML2_0_1_NS
/**
* Set the geometry of the IJK grid as parametric pillar nodes where at least one pillar is supposed to be splitted and where all pillars are of the same kind.
* All pillars are assumed to be defined using this method.
* @param kDirectionKind Indicates if the K direction always go up, dow or is not monotonic.
* @param isRightHanded Indicates that the IJK grid is right handed, as determined by the triple product of tangent vectors in the I, J, and K directions.
* @param parameters The parameter values (regarding the pillars) of each node of the grid.
* @param controlPoints The control points of the pillars of the grid. They are ordered first (quickest) by pillar and then (slowest) by control point : cp0 of pillar0, cp0 of pillar1, cp0 of pillar3, ..., cp0 of pillarCount-1, cp1 of pillar0, cp1 of pillar1, etc... Pad with nan values if necessary.
Expand All @@ -246,8 +248,7 @@ namespace RESQML2_0_1_NS
* @param splitCoordinateLineColumnCumulativeCount For each split coordinate line, indicates the count of grid column which are splitted by this coordinate line.
* @param splitCoordinateLineColumns For each split coordinate line, indicates the grid columns which are splitted by this coordinate line.
*/
void setGeometryAsParametricSplittedPillarNodes(
const gsoap_resqml2_0_1::resqml2__KDirection & kDirectionKind, const bool & isRightHanded,
void setGeometryAsParametricSplittedPillarNodes(const bool & isRightHanded,
double * parameters, double * controlPoints, double * controlPointParameters, const unsigned int & controlPointCountPerPillar, short pillarKind, COMMON_NS::AbstractHdfProxy* proxy,
const unsigned long & splitCoordinateLineCount, unsigned int * pillarOfCoordinateLine,
unsigned int * splitCoordinateLineColumnCumulativeCount, unsigned int * splitCoordinateLineColumns);
Expand Down
Loading

0 comments on commit 2b6502a

Please sign in to comment.