From a50f27287113222f8ed16583bfc0f5cb5a55dbf9 Mon Sep 17 00:00:00 2001 From: cedricRobert <38067772+cedricRobert@users.noreply.github.com> Date: Thu, 4 Jan 2024 10:39:30 +0100 Subject: [PATCH] V3.1.0 (#37) functionnality: * WITSML2.1 Completions/Perforations * Property collection * Well collection BugFix: * link between vtkDataAssembly & vtkPartitionedDataSetCollection --- CMakeLists.txt | 4 +- Plugin/CMakeLists.txt | 23 +- Plugin/Energistics/CMakeLists.txt | 4 +- Plugin/Energistics/Energistics.xml | 4 +- ...actObjectSetToVtkPartitionedDataSetSet.cxx | 85 + ...tractObjectSetToVtkPartitionedDataSetSet.h | 70 + ...nAbstractObjectToVtkPartitionedDataSet.cxx | 30 + ...monAbstractObjectToVtkPartitionedDataSet.h | 78 + ...tRepresentationToVtkPartitionedDataSet.cxx | 128 ++ ...actRepresentationToVtkPartitionedDataSet.h | 57 +- ...itoryToVtkPartitionedDataSetCollection.cxx | 1415 +++++++++++++++++ ...ositoryToVtkPartitionedDataSetCollection.h | 165 ++ .../ResqmlGrid2dToVtkStructuredGrid.cxx | 41 +- .../ResqmlGrid2dToVtkStructuredGrid.h | 16 +- ...GridSubRepToVtkExplicitStructuredGrid.cxx} | 52 +- ...jkGridSubRepToVtkExplicitStructuredGrid.h} | 22 +- ...sqmlIjkGridToVtkExplicitStructuredGrid.cxx | 269 ++++ ...esqmlIjkGridToVtkExplicitStructuredGrid.h} | 16 +- .../ResqmlPolylineToVtkPolyData.cxx | 35 +- .../ResqmlPolylineToVtkPolyData.h | 4 +- .../ResqmlPropertyToVtkDataArray.cxx | 35 +- .../ResqmlPropertyToVtkDataArray.h | 12 +- ...TriangulatedSetToVtkPartitionedDataSet.cxx | 39 +- ...mlTriangulatedSetToVtkPartitionedDataSet.h | 18 +- .../ResqmlTriangulatedToVtkPolyData.cxx | 30 +- .../ResqmlTriangulatedToVtkPolyData.h | 21 +- ...ucturedGridSubRepToVtkUnstructuredGrid.cxx | 49 +- ...tructuredGridSubRepToVtkUnstructuredGrid.h | 11 +- ...lUnstructuredGridToVtkUnstructuredGrid.cxx | 175 +- ...qmlUnstructuredGridToVtkUnstructuredGrid.h | 51 +- .../ResqmlWellboreChannelToVtkPolyData.cxx | 52 +- .../ResqmlWellboreChannelToVtkPolyData.h | 8 +- ...mlWellboreFrameToVtkPartitionedDataSet.cxx | 44 + ...sqmlWellboreFrameToVtkPartitionedDataSet.h | 22 +- ...boreMarkerFrameToVtkPartitionedDataSet.cxx | 65 + ...llboreMarkerFrameToVtkPartitionedDataSet.h | 20 +- .../ResqmlWellboreMarkerToVtkPolyData.cxx | 123 +- .../ResqmlWellboreMarkerToVtkPolyData.h | 31 +- .../ResqmlWellboreTrajectoryToVtkPolyData.cxx | 32 +- .../ResqmlWellboreTrajectoryToVtkPolyData.h | 15 +- ...boreCompletionPerforationToVtkPolyData.cxx | 205 +++ ...llboreCompletionPerforationToVtkPolyData.h | 55 + ...lboreCompletionToVtkPartitionedDataSet.cxx | 54 + ...ellboreCompletionToVtkPartitionedDataSet.h | 50 + ...tRepresentationToVtkPartitionedDataSet.cxx | 141 -- ...itoryToVtkPartitionedDataSetCollection.cxx | 867 ---------- ...ositoryToVtkPartitionedDataSetCollection.h | 122 -- .../ResqmlIjkGridToVtkUnstructuredGrid.cxx | 255 --- ...mlWellboreFrameToVtkPartitionedDataSet.cxx | 74 - ...boreMarkerFrameToVtkPartitionedDataSet.cxx | 102 -- Plugin/Energistics/Tools/enum.h | 51 + Plugin/Energistics/vtk.module | 3 + Plugin/Energistics/vtkEPCReader.cxx | 89 +- Plugin/Energistics/vtkEPCReader.h | 3 +- Plugin/Energistics/vtkETPSource.cxx | 3 +- Plugin/Energistics/vtkETPSource.h | 2 +- Plugin/paraview.plugin | 14 +- README.md | 19 +- cmake/modules/FindAVRO.cmake | 108 ++ cmake/modules/FindFESAPI.cmake | 118 ++ 60 files changed, 3538 insertions(+), 2168 deletions(-) create mode 100644 Plugin/Energistics/Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.cxx create mode 100644 Plugin/Energistics/Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.h create mode 100644 Plugin/Energistics/Mapping/CommonAbstractObjectToVtkPartitionedDataSet.cxx create mode 100644 Plugin/Energistics/Mapping/CommonAbstractObjectToVtkPartitionedDataSet.h create mode 100644 Plugin/Energistics/Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.cxx rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h (62%) create mode 100644 Plugin/Energistics/Mapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.cxx create mode 100644 Plugin/Energistics/Mapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlGrid2dToVtkStructuredGrid.cxx (73%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlGrid2dToVtkStructuredGrid.h (81%) rename Plugin/Energistics/{ResqmlMapping/ResqmlIjkGridSubRepToVtkUnstructuredGrid.cxx => Mapping/ResqmlIjkGridSubRepToVtkExplicitStructuredGrid.cxx} (68%) rename Plugin/Energistics/{ResqmlMapping/ResqmlIjkGridSubRepToVtkUnstructuredGrid.h => Mapping/ResqmlIjkGridSubRepToVtkExplicitStructuredGrid.h} (69%) create mode 100644 Plugin/Energistics/Mapping/ResqmlIjkGridToVtkExplicitStructuredGrid.cxx rename Plugin/Energistics/{ResqmlMapping/ResqmlIjkGridToVtkUnstructuredGrid.h => Mapping/ResqmlIjkGridToVtkExplicitStructuredGrid.h} (71%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlPolylineToVtkPolyData.cxx (77%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlPolylineToVtkPolyData.h (87%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlPropertyToVtkDataArray.cxx (84%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlPropertyToVtkDataArray.h (88%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlTriangulatedSetToVtkPartitionedDataSet.cxx (73%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlTriangulatedSetToVtkPartitionedDataSet.h (76%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlTriangulatedToVtkPolyData.cxx (81%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlTriangulatedToVtkPolyData.h (76%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.cxx (83%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h (83%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlUnstructuredGridToVtkUnstructuredGrid.cxx (79%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlUnstructuredGridToVtkUnstructuredGrid.h (77%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlWellboreChannelToVtkPolyData.cxx (68%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlWellboreChannelToVtkPolyData.h (78%) create mode 100644 Plugin/Energistics/Mapping/ResqmlWellboreFrameToVtkPartitionedDataSet.cxx rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlWellboreFrameToVtkPartitionedDataSet.h (60%) create mode 100644 Plugin/Energistics/Mapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.cxx rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h (67%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlWellboreMarkerToVtkPolyData.cxx (56%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlWellboreMarkerToVtkPolyData.h (64%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlWellboreTrajectoryToVtkPolyData.cxx (77%) rename Plugin/Energistics/{ResqmlMapping => Mapping}/ResqmlWellboreTrajectoryToVtkPolyData.h (82%) create mode 100644 Plugin/Energistics/Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.cxx create mode 100644 Plugin/Energistics/Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.h create mode 100644 Plugin/Energistics/Mapping/WitsmlWellboreCompletionToVtkPartitionedDataSet.cxx create mode 100644 Plugin/Energistics/Mapping/WitsmlWellboreCompletionToVtkPartitionedDataSet.h delete mode 100644 Plugin/Energistics/ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.cxx delete mode 100644 Plugin/Energistics/ResqmlMapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.cxx delete mode 100644 Plugin/Energistics/ResqmlMapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h delete mode 100644 Plugin/Energistics/ResqmlMapping/ResqmlIjkGridToVtkUnstructuredGrid.cxx delete mode 100644 Plugin/Energistics/ResqmlMapping/ResqmlWellboreFrameToVtkPartitionedDataSet.cxx delete mode 100644 Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.cxx create mode 100644 Plugin/Energistics/Tools/enum.h create mode 100644 cmake/modules/FindAVRO.cmake create mode 100644 cmake/modules/FindFESAPI.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 8117da7..04e4874 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,14 @@ cmake_minimum_required(VERSION 3.14.0) cmake_policy(SET CMP0048 NEW) project(Fespp - VERSION 3.0.0 + VERSION 3.1.0 DESCRIPTION "Paraview plugin for importing EPC documents" HOMEPAGE_URL "https://github.com/F2I-Consulting/fespp" LANGUAGES C CXX ) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/modules) + # These five lines are required in order to set up installation directories # (which also control build directory locations) and enable shared builds # (CMake's default is for a static build). diff --git a/Plugin/CMakeLists.txt b/Plugin/CMakeLists.txt index 5cc13b3..020403f 100644 --- a/Plugin/CMakeLists.txt +++ b/Plugin/CMakeLists.txt @@ -11,14 +11,16 @@ endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # DEPENDENCIES # ----------------------------------------------------------------------------- -set (FESAPI_INCLUDE_DIR FESAPI_INCLUDE_DIR-NOTFOUND CACHE PATH "Path to the directory which contains the FESAPI header files") -set (FESAPI_LIBRARY_RELEASE FESAPI_LIBRARY_RELEASE-NOTFOUND CACHE FILEPATH "Path to the FESAPI release library") -set (FESAPI_LIBRARY_DEBUG FESAPI_LIBRARY_DEBUG-NOTFOUND CACHE FILEPATH "Path to the FESAPI debug library") +find_package(FESAPI REQUIRED) set (WITH_ETP_SSL OFF CACHE BOOL "Only if FESAPI build with ETP support... for building Fespp with ETP support.") if (WITH_ETP_SSL) - find_package(Boost 1.66.0 REQUIRED system) + find_package(Boost 1.70) + if (NOT Boost_FOUND) + # Boost system is required for Beast untill version 1.70 : https://www.boost.org/doc/libs/1_69_0/libs/beast/doc/html/beast/introduction.html + find_package(Boost 1.66 REQUIRED system) + endif() find_package( Threads ) if (NOT TARGET OpenSSL::SSL OR NOT TARGET OpenSSL::Crypto) find_package(OpenSSL REQUIRED) @@ -39,18 +41,7 @@ if (WITH_ETP_SSL) endif () #AVRO - set (AVRO_INCLUDE_DIR AVRO_INCLUDE_DIR-NOTFOUND CACHE PATH "Path to the directory which contains the avro header files") - if (NOT IS_DIRECTORY ${AVRO_INCLUDE_DIR}) - message(SEND_ERROR "The Avro include dir (AVRO_INCLUDE_DIR variable) does not look to be a valid directory. Please modify it.") - endif () - set (AVRO_LIBRARY_RELEASE AVRO_LIBRARY_RELEASE-NOTFOUND CACHE FILEPATH "Path to the file which contains the avro library release") - if (NOT EXISTS ${AVRO_LIBRARY_RELEASE}) - message(WARNING "The avro library (AVRO_LIBRARY_RELEASE variable) does not look to be a valid file. Please modify it.") - endif () - set (AVRO_LIBRARY_DEBUG AVRO_LIBRARY_DEBUG-NOTFOUND CACHE FILEPATH "Path to the file which contains the AVRO library DEBUG") - if (NOT EXISTS ${AVRO_LIBRARY_DEBUG}) - message(WARNING "The AVRO library (AVRO_LIBRARY_DEBUG variable) does not look to be a valid file. Please modify it.") - endif () + find_package(AVRO REQUIRED) endif (WITH_ETP_SSL) # ----------------------------------------------------------------------------- diff --git a/Plugin/Energistics/CMakeLists.txt b/Plugin/Energistics/CMakeLists.txt index d732f86..547365a 100644 --- a/Plugin/Energistics/CMakeLists.txt +++ b/Plugin/Energistics/CMakeLists.txt @@ -3,8 +3,8 @@ set(classes vtkETPSource ) -FILE (GLOB FESPP_MAPPING_SOURCES ResqmlMapping/*.cxx) -FILE (GLOB FESPP_MAPPING_HEADERS ResqmlMapping/*.h) +FILE (GLOB FESPP_MAPPING_SOURCES Mapping/*.cxx) +FILE (GLOB FESPP_MAPPING_HEADERS Mapping/*.h Tools/*.h) set (ENERGISTICS_SOURCES ${FESPP_MAPPING_SOURCES} ) diff --git a/Plugin/Energistics/Energistics.xml b/Plugin/Energistics/Energistics.xml index 77890f7..77d0a83 100644 --- a/Plugin/Energistics/Energistics.xml +++ b/Plugin/Energistics/Energistics.xml @@ -76,7 +76,7 @@ - + This property specifies the string used to describe the ETP Url @@ -89,7 +89,7 @@ - + diff --git a/Plugin/Energistics/Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.cxx b/Plugin/Energistics/Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.cxx new file mode 100644 index 0000000..4d43e07 --- /dev/null +++ b/Plugin/Energistics/Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.cxx @@ -0,0 +1,85 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#include "Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.h" + +//---------------------------------------------------------------------------- +CommonAbstractObjectSetToVtkPartitionedDataSetSet::CommonAbstractObjectSetToVtkPartitionedDataSetSet(const COMMON_NS::AbstractObject *p_abstractObject, int p_procNumber, int p_maxProc) + : _procNumber(p_procNumber), + _maxProc(p_maxProc), + _resqmlData(p_abstractObject), + _mapperSet() +{ + _uuid = p_abstractObject->getUuid(); + _title = p_abstractObject->getTitle(); +} + +CommonAbstractObjectSetToVtkPartitionedDataSetSet::~CommonAbstractObjectSetToVtkPartitionedDataSetSet() +{ + for (auto &w_item : _mapperSet) + { + delete w_item; + } + _mapperSet.clear(); +} + +void CommonAbstractObjectSetToVtkPartitionedDataSetSet::loadVtkObject() +{ + for (int w_i = _procNumber; w_i < _mapperSet.size(); w_i += _maxProc) + { + _mapperSet[w_i]->loadVtkObject(); + } +} + +//---------------------------------------------------------------------------- +void CommonAbstractObjectSetToVtkPartitionedDataSetSet::removeCommonAbstractObjectToVtkPartitionedDataSet(const std::string &p_id) +{ + for (auto w_it = _mapperSet.begin(); w_it != _mapperSet.end();) + { + CommonAbstractObjectToVtkPartitionedDataSet *w_mapper = *w_it; + if (w_mapper->getUuid() == p_id) + { + delete w_mapper; + w_it = _mapperSet.erase(w_it); + + return; + } + else + { + ++w_it; + } + } +} + +//---------------------------------------------------------------------------- +bool CommonAbstractObjectSetToVtkPartitionedDataSetSet::existUuid(const std::string &p_id) +{ + for (auto w_it = _mapperSet.begin(); w_it != _mapperSet.end();) + { + CommonAbstractObjectToVtkPartitionedDataSet *w_mapper = *w_it; + if (w_mapper->getUuid() == p_id) + { + return true; + } + else + { + ++w_it; + } + } + return false; +} diff --git a/Plugin/Energistics/Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.h b/Plugin/Energistics/Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.h new file mode 100644 index 0000000..be9cbe1 --- /dev/null +++ b/Plugin/Energistics/Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.h @@ -0,0 +1,70 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#ifndef __CommonAbstractObjectSetToVtkPartitionedDataSetSet__h__ +#define __CommonAbstractObjectSetToVtkPartitionedDataSetSet__h__ + +// include system +#include + +// include VTK library +#include +#include + +// include F2i-consulting Energistics Standards API +#include + +// include F2i-consulting Energistics ParaView Plugin +#include "Mapping/CommonAbstractObjectToVtkPartitionedDataSet.h" + +/** @brief transform a RESQML abstract object set to vtkPartitionedDataSet set + */ +class CommonAbstractObjectSetToVtkPartitionedDataSetSet +{ +public: + // Constructor + CommonAbstractObjectSetToVtkPartitionedDataSetSet(const COMMON_NS::AbstractObject *p_abstractObject, int p_procNumber = 0, int p_maxProc = 1); + + // destructor + ~CommonAbstractObjectSetToVtkPartitionedDataSetSet(); + + /** + * + */ + std::string getUuid() const { return _uuid; }; + std::string getTitle() const { return _title; }; + + void loadVtkObject(); + void removeCommonAbstractObjectToVtkPartitionedDataSet(const std::string &p_id); + std::vector getMapperSet() { return _mapperSet; } + + bool existUuid(const std::string &p_id); + +protected: + const COMMON_NS::AbstractObject *_resqmlData; + + // for Multithreading + int _procNumber; + int _maxProc; + + std::string _uuid; + std::string _title; + + std::vector _mapperSet; +}; +#endif diff --git a/Plugin/Energistics/Mapping/CommonAbstractObjectToVtkPartitionedDataSet.cxx b/Plugin/Energistics/Mapping/CommonAbstractObjectToVtkPartitionedDataSet.cxx new file mode 100644 index 0000000..a48b5a4 --- /dev/null +++ b/Plugin/Energistics/Mapping/CommonAbstractObjectToVtkPartitionedDataSet.cxx @@ -0,0 +1,30 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#include "Mapping/CommonAbstractObjectToVtkPartitionedDataSet.h" + +//---------------------------------------------------------------------------- +CommonAbstractObjectToVtkPartitionedDataSet::CommonAbstractObjectToVtkPartitionedDataSet(const COMMON_NS::AbstractObject *p_abstractObject, int p_procNumber, int p_maxProc) + : _procNumber(p_procNumber), + _maxProc(p_maxProc), + _resqmlData(p_abstractObject), + _vtkData(nullptr) +{ + _absUuid = getResqmlData()->getUuid(); + _absTitle = getResqmlData()->getTitle(); +} diff --git a/Plugin/Energistics/Mapping/CommonAbstractObjectToVtkPartitionedDataSet.h b/Plugin/Energistics/Mapping/CommonAbstractObjectToVtkPartitionedDataSet.h new file mode 100644 index 0000000..778db30 --- /dev/null +++ b/Plugin/Energistics/Mapping/CommonAbstractObjectToVtkPartitionedDataSet.h @@ -0,0 +1,78 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#ifndef __CommonAbstractObjectTovtkPartitionedDataSet__h__ +#define __CommonAbstractObjectTovtkPartitionedDataSet__h__ + +// include system +#include + +// include VTK library +#include +#include + +// include F2i-consulting Energistics Standards API +#include + +/** @brief transform a RESQML abstract object to vtkPartitionedDataSet + */ +class CommonAbstractObjectToVtkPartitionedDataSet +{ +public: + /** + * Constructor + */ + CommonAbstractObjectToVtkPartitionedDataSet(const COMMON_NS::AbstractObject *p_abstractObject, int p_procNumber = 0, int p_maxProc = 1); + + /** + * Destructor + */ + virtual ~CommonAbstractObjectToVtkPartitionedDataSet() = default; + + /** + * load VtkPartitionedDataSet with resqml data + */ + virtual void loadVtkObject() = 0; + + /** + * return the vtkPartitionedDataSet of resqml object + */ + vtkSmartPointer getOutput() const { return _vtkData; } + + /** + * + */ + std::string getUuid() const { return _absUuid; }; + std::string getTitle() const { return _absTitle; }; + void setUuid(std::string p_newUuid) { _absUuid = p_newUuid; } + void setTitle(std::string p_newTitle) { _absTitle = p_newTitle; } + +protected: + const COMMON_NS::AbstractObject *getResqmlData() const { return _resqmlData; } + + int _procNumber; + int _maxProc; + + const COMMON_NS::AbstractObject *_resqmlData; + + vtkSmartPointer _vtkData; + + std::string _absUuid; + std::string _absTitle; +}; +#endif diff --git a/Plugin/Energistics/Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.cxx b/Plugin/Energistics/Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.cxx new file mode 100644 index 0000000..7f0156d --- /dev/null +++ b/Plugin/Energistics/Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.cxx @@ -0,0 +1,128 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#include "Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" + +#include +#include + +// include VTK library +#include +#include +#include + +// FESAPI +#include +#include + +// include F2i-consulting Energistics Paraview Plugin +#include "Mapping/ResqmlPropertyToVtkDataArray.h" + +//---------------------------------------------------------------------------- +ResqmlAbstractRepresentationToVtkPartitionedDataSet::ResqmlAbstractRepresentationToVtkPartitionedDataSet(const RESQML2_NS::AbstractRepresentation *p_abstractRepresentation, int p_procNumber, int p_maxProc) + : CommonAbstractObjectToVtkPartitionedDataSet(p_abstractRepresentation, + p_procNumber, + p_maxProc), + _subrepPointerOnPointsCount(0), + _resqmlData(p_abstractRepresentation), + _uuidToVtkDataArray() +{ +} + +void ResqmlAbstractRepresentationToVtkPartitionedDataSet::addDataArray(const std::string &p_uuid, int p_patchIndex) +{ + std::vector w_valuesPropertySet = getResqmlData()->getValuesPropertySet(); + std::vector::iterator w_it = std::find_if(w_valuesPropertySet.begin(), w_valuesPropertySet.end(), + [&p_uuid](RESQML2_NS::AbstractValuesProperty const *w_property) + { return w_property->getUuid() == p_uuid; }); + if (w_it != std::end(w_valuesPropertySet)) + { + auto const *const w_resqmlProp = *w_it; + ResqmlPropertyToVtkDataArray *w_fesppProperty = _isHyperslabed + ? new ResqmlPropertyToVtkDataArray(w_resqmlProp, + _iCellCount * _jCellCount * (_maxKIndex - _initKIndex), + _pointCount, + _iCellCount, + _jCellCount, + _maxKIndex - _initKIndex, + _initKIndex, + p_patchIndex) + : new ResqmlPropertyToVtkDataArray(w_resqmlProp, + _iCellCount * _jCellCount * _kCellCount, + _pointCount, + p_patchIndex); + switch (w_resqmlProp->getAttachmentKind()) + { + case gsoap_eml2_3::eml23__IndexableElement::cells: + case gsoap_eml2_3::eml23__IndexableElement::triangles: + _vtkData->GetPartition(0)->GetCellData()->AddArray(w_fesppProperty->getVtkData()); + break; + case gsoap_eml2_3::eml23__IndexableElement::nodes: + _vtkData->GetPartition(0)->GetPointData()->AddArray(w_fesppProperty->getVtkData()); + break; + default: + throw std::invalid_argument("The property " + p_uuid + " is attached on a non supported topological element i.e. not cell, not point."); + } + _uuidToVtkDataArray[p_uuid] = w_fesppProperty; + _vtkData->Modified(); + } + else + { + throw std::invalid_argument("The property " + p_uuid + "cannot be added since it is not contained in the representation " + getResqmlData()->getUuid()); + } +} + +void ResqmlAbstractRepresentationToVtkPartitionedDataSet::deleteDataArray(const std::string &p_uuid) +{ + ResqmlPropertyToVtkDataArray *w_vtkDataArray = _uuidToVtkDataArray[p_uuid]; + if (w_vtkDataArray != nullptr) + { + char *w_dataArrayName = w_vtkDataArray->getVtkData()->GetName(); + if (_vtkData->GetPartition(0)->GetCellData()->HasArray(w_dataArrayName)) + { + _vtkData->GetPartition(0)->GetCellData()->RemoveArray(w_dataArrayName); + } + if (_vtkData->GetPartition(0)->GetPointData()->HasArray(w_dataArrayName)) + { + _vtkData->GetPartition(0)->GetPointData()->RemoveArray(w_dataArrayName); + } + + // Cleaning + delete w_vtkDataArray; + _uuidToVtkDataArray.erase(p_uuid); + } + else + { + throw std::invalid_argument("The property " + p_uuid + "cannot be deleted from representation " + getResqmlData()->getUuid() + " since it has never been added"); + } +} + +void ResqmlAbstractRepresentationToVtkPartitionedDataSet::registerSubRep() +{ + ++_subrepPointerOnPointsCount; +} + +void ResqmlAbstractRepresentationToVtkPartitionedDataSet::unregisterSubRep() +{ + --_subrepPointerOnPointsCount; +} + +unsigned int ResqmlAbstractRepresentationToVtkPartitionedDataSet::subRepLinkedCount() +{ + return _subrepPointerOnPointsCount; +} diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h b/Plugin/Energistics/Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h similarity index 62% rename from Plugin/Energistics/ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h rename to Plugin/Energistics/Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h index ced225c..c193bbb 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h +++ b/Plugin/Energistics/Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h @@ -29,15 +29,18 @@ under the License. // include F2i-consulting Energistics Standards API #include +// include F2i-consulting Energistics Standards Paraview Plugin +#include "CommonAbstractObjectToVtkPartitionedDataSet.h" + /** @brief transform a RESQML abstract representation to vtkPartitionedDataSet */ -class ResqmlAbstractRepresentationToVtkPartitionedDataSet +class ResqmlAbstractRepresentationToVtkPartitionedDataSet : public CommonAbstractObjectToVtkPartitionedDataSet { public: /** * Constructor */ - ResqmlAbstractRepresentationToVtkPartitionedDataSet(RESQML2_NS::AbstractRepresentation *abstract_representation, int proc_number = 0, int max_proc = 1); + ResqmlAbstractRepresentationToVtkPartitionedDataSet(const RESQML2_NS::AbstractRepresentation *p_abstractRepresentation, int p_procNumber = 0, int p_maxProc = 1); /** * Destructor @@ -48,62 +51,40 @@ class ResqmlAbstractRepresentationToVtkPartitionedDataSet * load VtkPartitionedDataSet with resqml data */ virtual void loadVtkObject() = 0; - /** - * unload VtkPartitionedDataSet - */ - void unloadVtkObject(); /** * add a resqml property to VtkPartitionedDataSet */ - void addDataArray(const std::string &uuid, int patch_index = 0); + void addDataArray(const std::string &p_uuid, int p_patchIndex = 0); /** * remove a resqml property to VtkPartitionedDataSet */ - void deleteDataArray(const std::string &uuid); + void deleteDataArray(const std::string &p_uuid); /** - * return the vtkPartitionedDataSet of resqml representation + * */ - vtkSmartPointer getOutput() const { return vtkData; } - - /** - * - */ void registerSubRep(); void unregisterSubRep(); unsigned int subRepLinkedCount(); - /** - * - */ - std::string getUuid() const; - std::string getTitle() const; - - protected: + const RESQML2_NS::AbstractRepresentation *getResqmlData() const { return _resqmlData; } - RESQML2_NS::AbstractRepresentation * getResqmlData() const { return resqmlData; } - - unsigned int subrep_pointer_on_points_count; - - uint64_t pointCount = 0; - uint32_t iCellCount = 0; // = cellcount if not ijkGrid - uint32_t jCellCount = 1; - uint32_t kCellCount = 1; - uint32_t initKIndex = 0; - uint32_t maxKIndex = 0; - - bool isHyperslabed = false; + unsigned int _subrepPointerOnPointsCount; - int procNumber; - int maxProc; + uint64_t _pointCount = 0; + uint32_t _iCellCount = 0; // = cellcount if not ijkGrid + uint32_t _jCellCount = 1; + uint32_t _kCellCount = 1; + uint32_t _initKIndex = 0; + uint32_t _maxKIndex = 0; - RESQML2_NS::AbstractRepresentation * resqmlData; + bool _isHyperslabed = false; - vtkSmartPointer vtkData; - std::unordered_map uuidToVtkDataArray; + const RESQML2_NS::AbstractRepresentation *_resqmlData; + std::unordered_map _uuidToVtkDataArray; }; #endif diff --git a/Plugin/Energistics/Mapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.cxx b/Plugin/Energistics/Mapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.cxx new file mode 100644 index 0000000..356455a --- /dev/null +++ b/Plugin/Energistics/Mapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.cxx @@ -0,0 +1,1415 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ + +/* +Documentation: +============== + +VtkAssembly => TreeView: + - each node required 3 attributes: + - id = uuid of resqml/witsml object + - label = name to display in TreeView + - type = type +*/ +#include "ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +// VTK includes +#include +#include +#include +#include +#include + +// FESAPI includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WITH_ETP_SSL +#include + +#include + +#include +#include +#include +#include +#endif + +#include "Mapping/ResqmlIjkGridToVtkExplicitStructuredGrid.h" +#include "Mapping/ResqmlIjkGridSubRepToVtkExplicitStructuredGrid.h" +#include "Mapping/ResqmlGrid2dToVtkStructuredGrid.h" +#include "Mapping/ResqmlPolylineToVtkPolyData.h" +#include "Mapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.h" +#include "Mapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.h" +#include "Mapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h" +#include "Mapping/ResqmlWellboreTrajectoryToVtkPolyData.h" +#include "Mapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h" +#include "Mapping/ResqmlWellboreFrameToVtkPartitionedDataSet.h" +#include "Mapping/WitsmlWellboreCompletionToVtkPartitionedDataSet.h" +#include "Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.h" +#include "Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.h" + +ResqmlDataRepositoryToVtkPartitionedDataSetCollection::ResqmlDataRepositoryToVtkPartitionedDataSetCollection() + : _markerOrientation(false), + _markerSize(10), + _repository(new common::DataObjectRepository()), + _output(vtkSmartPointer::New()), + _nodeIdToMapper(), + _currentSelection(), + _oldSelection() +{ + auto w_assembly = vtkSmartPointer::New(); + w_assembly->SetRootNodeName("data"); + + _output->SetDataAssembly(w_assembly); + _timesStep.clear(); +} + +ResqmlDataRepositoryToVtkPartitionedDataSetCollection::~ResqmlDataRepositoryToVtkPartitionedDataSetCollection() +{ + delete _repository; + for (const auto &w_keyVal : _nodeIdToMapper) + { + delete w_keyVal.second; + } +} + +MapperType getMapperType(TreeViewNodeType p_type) +{ + switch (p_type) { + case TreeViewNodeType::Properties: + case TreeViewNodeType::Perforation: + case TreeViewNodeType::WellboreChannel: + case TreeViewNodeType::WellboreMarker: + case TreeViewNodeType::TimeSeries: + return MapperType::Data; + case TreeViewNodeType::Unknown: + case TreeViewNodeType::Collection: + case TreeViewNodeType::Wellbore: + return MapperType::Folder; + case TreeViewNodeType::Representation: + case TreeViewNodeType::SubRepresentation: + case TreeViewNodeType::WellboreTrajectory: + return MapperType::Mapper; + case TreeViewNodeType::WellboreMarkerFrame: + case TreeViewNodeType::WellboreFrame: + case TreeViewNodeType::WellboreCompletion: + return MapperType::MapperSet; + default: + return MapperType::Folder; + } +} + +// This function replaces the VTK function this->MakeValidNodeName(), +// which has a bug in the sorted_valid_chars array. The '.' character is placed +// before the '-' character, which is incorrect. This function uses a valid_chars +// array that correctly sorts the characters. The function checks if each character +// in the input string is valid, and adds it to the output string if it is valid. +// If the first character of the output string is not valid, an underscore is added +// to the beginning of the output string. This function is designed to create a valid +// node name from a given string. +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::MakeValidNodeName(const char *p_name) +{ + if (p_name == nullptr || p_name[0] == '\0') + { + return std::string(); + } + + const char w_sortedValidChars[] = + "-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; + const auto w_sortedValidCharsLen = strlen(w_sortedValidChars); + + std::string w_result; + w_result.reserve(strlen(p_name)); + for (size_t w_cc = 0, max = strlen(p_name); w_cc < max; ++w_cc) + { + if (std::binary_search( + w_sortedValidChars, w_sortedValidChars + w_sortedValidCharsLen, p_name[w_cc])) + { + w_result += p_name[w_cc]; + } + } + + if (w_result.empty() || + ((w_result[0] < 'a' || w_result[0] > 'z') && (w_result[0] < 'A' || w_result[0] > 'Z') && + w_result[0] != '_')) + { + return "_" + w_result; + } + return w_result; +} + +std::string SimplifyXmlTag(std::string p_typeRepresentation) +{ + std::string w_suffix = "Representation"; + std::string w_prefix = "Wellbore"; + + if (p_typeRepresentation.size() >= w_suffix.size() && p_typeRepresentation.substr(p_typeRepresentation.size() - w_suffix.size()) == w_suffix) + { + p_typeRepresentation = p_typeRepresentation.substr(0, p_typeRepresentation.size() - w_suffix.size()); + } + + if (p_typeRepresentation.size() >= w_prefix.size() && p_typeRepresentation.substr(0, w_prefix.size()) == w_prefix) + { + p_typeRepresentation = p_typeRepresentation.substr(w_prefix.size()); + } + return p_typeRepresentation; +} + +//---------------------------------------------------------------------------- +std::vector ResqmlDataRepositoryToVtkPartitionedDataSetCollection::connect(const std::string &p_etpUrl, const std::string &p_dataPartition, const std::string &p_authConnection) +{ + std::vector w_result; +#ifdef WITH_ETP_SSL + boost::uuids::random_generator w_gen; + ETP_NS::InitializationParameters w_initializationParams(w_gen(), p_etpUrl); + + std::map w_additionalHandshakeHeaderFields = {{"data-partition-id", p_dataPartition}}; + if (p_etpUrl.find("ws://") == 0) + { + _session = ETP_NS::ClientSessionLaunchers::createWsClientSession(&w_initializationParams, p_authConnection, w_additionalHandshakeHeaderFields); + } + else + { + _session = ETP_NS::ClientSessionLaunchers::createWssClientSession(&w_initializationParams, p_authConnection, w_additionalHandshakeHeaderFields); + } + try + { + _session->setDataspaceProtocolHandlers(std::make_shared(_session.get())); + } + catch (const std::exception &e) + { + vtkOutputWindowDisplayErrorText((std::string("fesapi error > ") + e.what()).c_str()); + } + try + { + _session->setDiscoveryProtocolHandlers(std::make_shared(_session.get())); + } + catch (const std::exception &e) + { + vtkOutputWindowDisplayErrorText((std::string("fesapi error > ") + e.what()).c_str()); + } + try + { + _session->setStoreProtocolHandlers(std::make_shared(_session.get())); + } + catch (const std::exception &e) + { + vtkOutputWindowDisplayErrorText((std::string("fesapi error > ") + e.what()).c_str()); + } + try + { + _session->setDataArrayProtocolHandlers(std::make_shared(_session.get())); + } + catch (const std::exception &e) + { + vtkOutputWindowDisplayErrorText((std::string("fesapi error > ") + e.what()).c_str()); + } + + _repository->setHdfProxyFactory(new ETP_NS::FesapiHdfProxyFactory(_session.get())); + + // + if (p_etpUrl.find("ws://") == 0) + { + auto w_plainSession = std::dynamic_pointer_cast(_session); + std::thread w_sessionThread(&ETP_NS::PlainClientSession::run, w_plainSession); + w_sessionThread.detach(); + } + else + { + auto w_sslSession = std::dynamic_pointer_cast(_session); + std::thread w_sessionThread(&ETP_NS::SslClientSession::run, w_sslSession); + w_sessionThread.detach(); + } + + // Wait for the ETP session to be opened + auto w_tStart = std::chrono::high_resolution_clock::now(); + while (_session->isEtpSessionClosed()) + { + if (std::chrono::duration(std::chrono::high_resolution_clock::now() - w_tStart).count() > 5000) + { + throw std::invalid_argument("Did you forget to click apply button before to connect? Time out for websocket connection" + + std::to_string(std::chrono::duration(std::chrono::high_resolution_clock::now() - w_tStart).count()) + "ms.\n"); + } + } + + //************ LIST DATASPACES ************ + const auto w_dataspaces = _session->getDataspaces(); + + std::transform(w_dataspaces.begin(), w_dataspaces.end(), std::back_inserter(w_result), + [](const Energistics::Etp::v12::Datatypes::Object::Dataspace &w_ds) + { return w_ds.uri; }); + +#endif + return w_result; +} + +//---------------------------------------------------------------------------- +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::disconnect() +{ +#ifdef WITH_ETP_SSL + _session->close(); +#endif +} + +//---------------------------------------------------------------------------- +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::addFile(const char *p_fileName) +{ + COMMON_NS::EpcDocument w_pck(p_fileName); + std::string w_message = w_pck.deserializeInto(*_repository); + w_pck.close(); + + w_message += buildDataAssemblyFromDataObjectRepo(p_fileName); + return w_message; +} + +//---------------------------------------------------------------------------- +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::addDataspace(const char *p_dataspace) +{ +#ifdef WITH_ETP_SSL + //************ LIST RESOURCES ************ + Energistics::Etp::v12::Datatypes::Object::ContextInfo w_ctxInfo; + w_ctxInfo.uri = p_dataspace; + w_ctxInfo.depth = 0; + w_ctxInfo.navigableEdges = Energistics::Etp::v12::Datatypes::Object::RelationshipKind::Both; + w_ctxInfo.includeSecondaryTargets = false; + w_ctxInfo.includeSecondarySources = false; + const auto w_resources = _session->getResources(w_ctxInfo, Energistics::Etp::v12::Datatypes::Object::ContextScopeKind::targets); + + //************ GET ALL DATAOBJECTS ************ + _repository->setHdfProxyFactory(new ETP_NS::FesapiHdfProxyFactory(_session.get())); + if (!w_resources.empty()) + { + std::map w_query; + for (size_t w_i = 0; w_i < w_resources.size(); ++w_i) + { + w_query[std::to_string(w_i)] = w_resources[w_i].uri; + } + const auto w_dataobjects = _session->getDataObjects(w_query); + for (auto &w_datoObject : w_dataobjects) + { + _repository->addOrReplaceGsoapProxy(w_datoObject.second.data, + ETP_NS::EtpHelpers::getDataObjectType(w_datoObject.second.resource.uri), + ETP_NS::EtpHelpers::getDataspaceUri(w_datoObject.second.resource.uri)); + } + } + else + { + vtkOutputWindowDisplayWarningText(("There is no dataobject in the dataspace : " + std::string(p_dataspace) + "\n").c_str()); + } +#endif + return buildDataAssemblyFromDataObjectRepo(""); +} + +namespace +{ + auto lexicographicalComparison = [](const COMMON_NS::AbstractObject *p_a, const COMMON_NS::AbstractObject *p_b) -> bool + { + return p_a->getTitle().compare(p_b->getTitle()) < 0; + }; + + template + void sortAndAdd(std::vector p_source, std::vector &p_dest) + { + std::sort(p_source.begin(), p_source.end(), lexicographicalComparison); + std::move(p_source.begin(), p_source.end(), std::inserter(p_dest, p_dest.end())); + } +} + +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::buildDataAssemblyFromDataObjectRepo(const char *p_fileName) +{ + std::vector w_allReps; + + // create vtkDataAssembly: create treeView in property panel + sortAndAdd(_repository->getHorizonGrid2dRepresentationSet(), w_allReps); + sortAndAdd(_repository->getIjkGridRepresentationSet(), w_allReps); + sortAndAdd(_repository->getAllPolylineSetRepresentationSet(), w_allReps); + sortAndAdd(_repository->getAllTriangulatedSetRepresentationSet(), w_allReps); + sortAndAdd(_repository->getUnstructuredGridRepresentationSet(), w_allReps); + + // See https://stackoverflow.com/questions/15347123/how-to-construct-a-stdstring-from-a-stdvectorstring + std::string w_message = std::accumulate(std::begin(w_allReps), std::end(w_allReps), std::string{}, + [&](std::string &message, RESQML2_NS::AbstractRepresentation const *rep) + { + return message += searchRepresentations(rep); + }); + // get WellboreTrajectory + w_message += searchWellboreTrajectory(p_fileName); + + // get TimeSeries + w_message += searchTimeSeries(p_fileName); + + return w_message; +} + +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchRepresentations(resqml2::AbstractRepresentation const *p_representation, int p_NodeId) +{ + std::string w_result; + + if (p_representation->isPartial()) + { + // check if it has already been added + // not exist => not loaded + if (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + p_representation->getUuid()).c_str()) == -1) + { + return "Partial representation with UUID \"" + p_representation->getUuid() + "\" is not loaded.\n"; + } /******* TODO ********/ // exist but not the same type ? + } + else + { + // The leading underscore is forced by VTK which does not support a node name starting with a digit (probably because it is a QNAME). + const std::string w_nodeName = "_" + p_representation->getUuid(); + const int w_existingNodeId = _output->GetDataAssembly()->FindFirstNodeWithName(w_nodeName.c_str()); + if (w_existingNodeId == -1) + { + p_NodeId = _output->GetDataAssembly()->AddNode(w_nodeName.c_str(), p_NodeId); + + auto const *w_subrep = dynamic_cast(p_representation); + // To shorten the xmlTag by removing �Representation� from the end. + + std::string w_typeRepresentation = SimplifyXmlTag(p_representation->getXmlTag()); + + const std::string w_representationVtkValidName = w_subrep == nullptr + ? this->MakeValidNodeName((w_typeRepresentation + "_" + p_representation->getTitle()).c_str()) + : this->MakeValidNodeName((w_typeRepresentation + "_" + w_subrep->getSupportingRepresentation(0)->getTitle() + "_" + p_representation->getTitle()).c_str()); + + const TreeViewNodeType w_type = w_subrep == nullptr + ? TreeViewNodeType::Representation + : TreeViewNodeType::SubRepresentation; + + _output->GetDataAssembly()->SetAttribute(p_NodeId, "label", w_representationVtkValidName.c_str()); + _output->GetDataAssembly()->SetAttribute(p_NodeId, "type", std::to_string(static_cast(TreeViewNodeType::Representation)).c_str()); + } + else + { + p_NodeId = w_existingNodeId; + } + } + + // add sub representation with properties (only for ijkGrid and unstructured grid) + if (dynamic_cast(p_representation) != nullptr || + dynamic_cast(p_representation) != nullptr) + { + w_result += searchSubRepresentation(p_representation, p_NodeId); + } + + // add properties to representation + w_result += searchProperties(p_representation, p_NodeId); + + return w_result; +} + +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchSubRepresentation(RESQML2_NS::AbstractRepresentation const *p_representation, int p_nodeParent) +{ + std::string w_message = ""; + try + { + auto w_subRepresentationSet = p_representation->getSubRepresentationSet(); + std::sort(w_subRepresentationSet.begin(), w_subRepresentationSet.end(), lexicographicalComparison); + + w_message = std::accumulate(std::begin(w_subRepresentationSet), std::end(w_subRepresentationSet), std::string{}, + [&](std::string &message, RESQML2_NS::SubRepresentation *b) + { + return message += searchRepresentations(b, _output->GetDataAssembly()->GetParent(p_nodeParent)); + }); + } + catch (const std::exception &e) + { + return "Exception in FESAPI when calling getSubRepresentationSet for uuid : " + p_representation->getUuid() + " : " + e.what() + ".\n"; + } + + return w_message; +} + +int ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchPropertySet(resqml2_0_1::PropertySet const *p_propSet, int p_nodeId) +{ + if (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + p_propSet->getUuid()).c_str()) == -1) + { // verify uuid exist in treeview + // To shorten the xmlTag by removing �Representation� from the end. + resqml2_0_1::PropertySet *w_parent = p_propSet->getParent(); + if (w_parent != nullptr) + { + p_nodeId = searchPropertySet(w_parent, p_nodeId); + } + if (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + p_propSet->getUuid()).c_str()) == -1) + { + const std::string w_vtkValidName = MakeValidNodeName(("Collection_" + p_propSet->getTitle()).c_str()); + p_nodeId = _output->GetDataAssembly()->AddNode(("_" + p_propSet->getUuid()).c_str(), p_nodeId); + _output->GetDataAssembly()->SetAttribute(p_nodeId, "label", w_vtkValidName.c_str()); + _output->GetDataAssembly()->SetAttribute(p_nodeId, "type", std::to_string(static_cast(TreeViewNodeType::Collection)).c_str()); + } + } + else + { + return _output->GetDataAssembly()->FindFirstNodeWithName(("_" + p_propSet->getUuid()).c_str()); + } + + return p_nodeId; +} + +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchProperties(RESQML2_NS::AbstractRepresentation const *p_representation, int p_nodeParent) +{ + try + { + auto w_valuesPropertySet = p_representation->getValuesPropertySet(); + std::sort(w_valuesPropertySet.begin(), w_valuesPropertySet.end(), lexicographicalComparison); + + int w_propertySetNodeId = p_nodeParent; + // property + for (auto const *w_property : w_valuesPropertySet) + { + for (resqml2_0_1::PropertySet const *w_propertySet : w_property->getPropertySets()) + { + w_propertySetNodeId = searchPropertySet(w_propertySet, p_nodeParent); + } + + const std::string w_vtkValidName = MakeValidNodeName((w_property->getXmlTag() + '_' + w_property->getTitle()).c_str()); + + if (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_property->getUuid()).c_str()) == -1) + { // verify uuid exist in treeview + int w_propertyNodeId = _output->GetDataAssembly()->AddNode(("_" + w_property->getUuid()).c_str(), w_propertySetNodeId); + _output->GetDataAssembly()->SetAttribute(w_propertyNodeId, "label", w_vtkValidName.c_str()); + _output->GetDataAssembly()->SetAttribute(w_propertyNodeId, "type", std::to_string(static_cast(TreeViewNodeType::Properties)).c_str()); + } + } + } + catch (const std::exception &e) + { + return "Exception in FESAPI when calling getValuesPropertySet with representation uuid: " + p_representation->getUuid() + " : " + e.what() + ".\n"; + } + + return ""; +} + +int ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchRepresentationSetRepresentation(resqml2::RepresentationSetRepresentation const *p_rsr, int p_nodeId) +{ + if (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + p_rsr->getUuid()).c_str()) == -1) + { // verify uuid exist in treeview + // To shorten the xmlTag by removing �Representation� from the end. + for (resqml2::RepresentationSetRepresentation *w_rsr : p_rsr->getRepresentationSetRepresentationSet()) + { + p_nodeId = searchRepresentationSetRepresentation(w_rsr, p_nodeId); + } + if (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + p_rsr->getUuid()).c_str()) == -1) + { + const std::string w_vtkValidName = this->MakeValidNodeName(("Collection_" + p_rsr->getTitle()).c_str()); + p_nodeId = _output->GetDataAssembly()->AddNode(("_" + p_rsr->getUuid()).c_str(), p_nodeId); + _output->GetDataAssembly()->SetAttribute(p_nodeId, "label", w_vtkValidName.c_str()); + _output->GetDataAssembly()->SetAttribute(p_nodeId, "type", std::to_string(static_cast(TreeViewNodeType::Collection)).c_str()); + } + } + else + { + return _output->GetDataAssembly()->FindFirstNodeWithName(("_" + p_rsr->getUuid()).c_str()); + } + return p_nodeId; +} + +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchWellboreTrajectory(const std::string &p_fileName) +{ + std::string w_result; + + int w_nodeId = 0; + for (auto *w_wellboreTrajectory : _repository->getWellboreTrajectoryRepresentationSet()) + { + const auto *w_wellboreFeature = dynamic_cast(w_wellboreTrajectory->getInterpretation()->getInterpretedFeature()); + + int w_nodeId = 0; + int w_initNodeId = 0; + if (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_wellboreTrajectory->getUuid()).c_str()) == -1) + { // verify uuid exist in treeview + // To shorten the xmlTag by removing �Representation� from the end. + for (resqml2::RepresentationSetRepresentation *w_rsr : w_wellboreTrajectory->getRepresentationSetRepresentationSet()) + { + w_initNodeId = searchRepresentationSetRepresentation(w_rsr); + } + + if (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_wellboreFeature->getUuid()).c_str()) == -1) + { + const std::string w_vtkValidName = "Wellbore_" + MakeValidNodeName(w_wellboreFeature->getTitle().c_str()); + w_initNodeId = _output->GetDataAssembly()->AddNode(("_" + w_wellboreFeature->getUuid()).c_str(), w_initNodeId); + _output->GetDataAssembly()->SetAttribute(w_initNodeId, "label", w_vtkValidName.c_str()); + _output->GetDataAssembly()->SetAttribute(w_initNodeId, "type", std::to_string(static_cast(TreeViewNodeType::Wellbore)).c_str()); + } + + if (w_wellboreTrajectory->isPartial()) + { + // check if it has already been added + + const std::string w_vtkValidName = MakeValidNodeName((SimplifyXmlTag(w_wellboreTrajectory->getXmlTag()) + "_" + w_wellboreTrajectory->getTitle()).c_str()); + // not exist => not loaded + if (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_vtkValidName).c_str()) == -1) + { + w_result = w_result + " Partial UUID: (" + w_wellboreTrajectory->getUuid() + ") is not loaded \n"; + continue; + } /******* TODO ********/ // exist but not the same type ? + } + else + { + const std::string w_vtkValidName = MakeValidNodeName((SimplifyXmlTag(w_wellboreTrajectory->getXmlTag()) + '_' + w_wellboreTrajectory->getTitle()).c_str()); + w_nodeId = _output->GetDataAssembly()->AddNode(("_" + w_wellboreTrajectory->getUuid()).c_str(), w_initNodeId); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "label", w_vtkValidName.c_str()); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "type", std::to_string(static_cast(TreeViewNodeType::WellboreTrajectory)).c_str()); + } + } + w_result += searchWellboreFrame(w_wellboreTrajectory, w_initNodeId); + w_result += searchWellboreCompletion(w_wellboreFeature, w_initNodeId); + } + return w_result; +} + +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchWellboreFrame(const resqml2::WellboreTrajectoryRepresentation *p_wellboreTrajectory, int p_nodeId) +{ + std::string w_result = ""; + for (auto *w_wellboreFrame : p_wellboreTrajectory->getWellboreFrameRepresentationSet()) + { + if (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_wellboreFrame->getUuid()).c_str()) == -1) + { // verify uuid exist in treeview + // common with wellboreMarkerFrame & WellboreFrame + const std::string w_vtkValidName = MakeValidNodeName((SimplifyXmlTag(w_wellboreFrame->getXmlTag()) + '_' + w_wellboreFrame->getTitle()).c_str()); + int w_frameNodeId = _output->GetDataAssembly()->AddNode(("_" + w_wellboreFrame->getUuid()).c_str(), p_nodeId); + _output->GetDataAssembly()->SetAttribute(w_frameNodeId, "label", w_vtkValidName.c_str()); + + auto *w_wellboreMarkerFrame = dynamic_cast(w_wellboreFrame); + if (w_wellboreMarkerFrame == nullptr) + { // WellboreFrame + _output->GetDataAssembly()->SetAttribute(w_frameNodeId, "type", std::to_string(static_cast(TreeViewNodeType::WellboreFrame)).c_str()); + // chanel + for (auto *w_property : w_wellboreFrame->getValuesPropertySet()) + { + const std::string w_vtkValidName = MakeValidNodeName((w_property->getXmlTag() + '_' + w_property->getTitle()).c_str()); + int w_nodeId = _output->GetDataAssembly()->AddNode(("_" + w_property->getUuid()).c_str(), w_frameNodeId); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "label", w_vtkValidName.c_str()); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "type", std::to_string(static_cast(TreeViewNodeType::WellboreChannel)).c_str()); + } + } + else + { // WellboreMarkerFrame + _output->GetDataAssembly()->SetAttribute(w_frameNodeId, "type", std::to_string(static_cast(TreeViewNodeType::WellboreMarkerFrame)).c_str()); + // marker + for (auto *w_wellboreMarker : w_wellboreMarkerFrame->getWellboreMarkerSet()) + { + const std::string w_vtkValidName = MakeValidNodeName((w_wellboreMarker->getXmlTag() + '_' + w_wellboreMarker->getTitle()).c_str()); + int w_nodeId = _output->GetDataAssembly()->AddNode(("_" + w_wellboreMarker->getUuid()).c_str(), w_frameNodeId); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "label", w_vtkValidName.c_str()); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "type", std::to_string(static_cast(TreeViewNodeType::WellboreMarker)).c_str()); + } + } + } + } + return w_result; +} + +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchWellboreCompletion(const RESQML2_NS::WellboreFeature *p_wellboreFeature, int p_nodeId) +{ + std::string w_result = ""; + // witsml2::Wellbore *witsmlWellbore = nullptr; + if (!p_wellboreFeature->isPartial()) + { + if (const witsml2::Wellbore *w_witsmlWellbore = dynamic_cast(p_wellboreFeature->getWitsmlWellbore())) + { + for (const auto *w_wellboreCompletion : w_witsmlWellbore->getWellboreCompletionSet()) + { + const std::string w_vtkValidName = MakeValidNodeName((SimplifyXmlTag(w_wellboreCompletion->getXmlTag()) + '_' + w_wellboreCompletion->getTitle()).c_str()); + int w_completionNodeId = _output->GetDataAssembly()->AddNode(("_" + w_wellboreCompletion->getUuid()).c_str(), p_nodeId); + _output->GetDataAssembly()->SetAttribute(w_completionNodeId, "label", w_vtkValidName.c_str()); + _output->GetDataAssembly()->SetAttribute(w_completionNodeId, "type", std::to_string(static_cast(TreeViewNodeType::WellboreCompletion)).c_str()); + // Iterate over the perforations. + for (uint64_t w_perforationIndex = 0; w_perforationIndex < w_wellboreCompletion->getConnectionCount(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION); ++w_perforationIndex) + { + // init + std::string w_perforationName = "Perfo"; + std::string w_perforationSkin = ""; + std::string w_perforationDiameter = ""; + + // Test with Petrel rules + auto w_petrelName = w_wellboreCompletion->getConnectionExtraMetadata(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, w_perforationIndex, "Petrel:Name0"); + // arbitrarily select the first event name as perforation name + if (w_petrelName.size() > 0) + { + w_perforationName += "_" + w_petrelName[0]; + // skin + auto w_petrelSkin = w_wellboreCompletion->getConnectionExtraMetadata(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, w_perforationIndex, "Petrel:Skin0"); + if (w_petrelSkin.size() > 0) + { + w_perforationSkin = w_petrelSkin[0]; + } + // diameter + auto w_petrelDiam = w_wellboreCompletion->getConnectionExtraMetadata(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, w_perforationIndex, "Petrel:BoreholePerforatedSection0"); + if (w_petrelDiam.size() > 0) + { + w_perforationDiameter = w_petrelDiam[0]; + } + } + else + { + // Test with Sismage rules + auto w_sismageName = w_wellboreCompletion->getConnectionExtraMetadata(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, w_perforationIndex, "Sismage-CIG:Name"); + if (w_sismageName.size() > 0) + { + w_perforationName += "_" + w_sismageName[0]; + // skin + auto w_sismageSkin = w_wellboreCompletion->getConnectionExtraMetadata(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, w_perforationIndex, "Sismage-CIG:Skin"); + if (w_sismageSkin.size() > 0) + { + w_perforationSkin = w_sismageSkin[0]; + } + // diameter + auto w_sismageDiam = w_wellboreCompletion->getConnectionExtraMetadata(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, w_perforationIndex, "Petrel:CompletionDiameter"); + if (w_sismageDiam.size() > 0) + { + w_perforationDiameter = w_sismageDiam[0]; + } + } + else + { + // default + w_perforationName += "_" + w_wellboreCompletion->getConnectionUid(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, w_perforationIndex); + } + } + w_perforationName += "__Skin_" + w_perforationSkin + "__Diam_" + w_perforationDiameter; + + int w_nodeId = _output->GetDataAssembly()->AddNode(this->MakeValidNodeName(("_" + w_wellboreCompletion->getUuid() + "_" + w_wellboreCompletion->getConnectionUid(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, w_perforationIndex)).c_str()).c_str(), w_completionNodeId); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "label", MakeValidNodeName((w_perforationName).c_str()).c_str()); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "type", std::to_string(static_cast(TreeViewNodeType::Perforation)).c_str()); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "connection", w_wellboreCompletion->getConnectionUid(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, w_perforationIndex).c_str()); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "skin", w_perforationSkin.c_str()); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "diameter", w_perforationDiameter.c_str()); + } + } + } + } + return w_result; +} +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchTimeSeries(const std::string &p_fileName) +{ + _timesStep.clear(); + + std::string w_message = ""; + std::vector w_timeSeriesSet; + try + { + w_timeSeriesSet = _repository->getTimeSeriesSet(); + } + catch (const std::exception &e) + { + w_message = w_message + "Exception in FESAPI when calling getTimeSeriesSet with file: " + p_fileName + " : " + e.what(); + } + + /**** + * change property parent to times serie parent + ****/ + for (auto const *w_timeSeries : w_timeSeriesSet) + { + // get properties link to Times series + try + { + std::map> w_propertyNameToNodeIdSet; + for (auto const *w_prop : w_timeSeries->getPropertySet()) + { + if (w_prop->getXmlTag() == RESQML2_NS::ContinuousProperty::XML_TAG || + w_prop->getXmlTag() == RESQML2_NS::DiscreteProperty::XML_TAG) + { + auto w_nodeId = (_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_prop->getUuid()).c_str())); + if (w_nodeId == -1) + { + w_message = w_message + "The property " + w_prop->getUuid() + " is not supported and consequently cannot be associated to its time series.\n"; + continue; + } + else + { + // same node parent else not supported + const int w_parentNodeId = _output->GetDataAssembly()->GetParent(w_nodeId); + if (w_parentNodeId != -1) + { + w_propertyNameToNodeIdSet[w_prop->getTitle()].push_back(w_nodeId); + const size_t w_timeIndexInTimeSeries = w_timeSeries->getTimestampIndex(w_prop->getSingleTimestamp()); + _timesStep.push_back(w_timeIndexInTimeSeries); + _timeSeriesUuidAndTitleToIndexAndPropertiesUuid[w_timeSeries->getUuid()][MakeValidNodeName((w_timeSeries->getXmlTag() + '_' + w_prop->getTitle()).c_str())][w_timeIndexInTimeSeries] = w_prop->getUuid(); + } + else + { + w_message = w_message + "The properties of time series " + w_timeSeries->getUuid() + " aren't parent and is not supported.\n"; + continue; + } + } + } + } + // erase duplicate Index + sort(_timesStep.begin(), _timesStep.end()); + _timesStep.erase(unique(_timesStep.begin(), _timesStep.end()), _timesStep.end()); + + for (const auto &w_myPair : w_propertyNameToNodeIdSet) + { + std::vector w_propertyNodeSet = w_myPair.second; + + int w_parentNodeId = -1; + // erase property add to treeview for group by TimeSerie + for (auto node : w_propertyNodeSet) + { + w_parentNodeId = _output->GetDataAssembly()->GetParent(node); + _output->GetDataAssembly()->RemoveNode(node); + } + std::string w_vtkValidName = MakeValidNodeName((w_timeSeries->getXmlTag() + '_' + w_myPair.first).c_str()); + auto w_nodeId = _output->GetDataAssembly()->AddNode(("_" + w_timeSeries->getUuid() + w_vtkValidName).c_str(), w_parentNodeId); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "label", w_vtkValidName.c_str()); + _output->GetDataAssembly()->SetAttribute(w_nodeId, "type", std::to_string(static_cast(TreeViewNodeType::TimeSeries)).c_str()); + } + } + catch (const std::exception &e) + { + w_message = w_message + "Exception in FESAPI when calling getPropertySet with file: " + p_fileName + " : " + e.what(); + } + } + + return w_message; +} + +std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::selectNodeId(int p_node) +{ + if (p_node != 0) + { + selectNodeIdParent(p_node); + + _currentSelection.insert(p_node); + _oldSelection.erase(p_node); + } + selectNodeIdChildren(p_node); + + return ""; +} + +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::selectNodeIdParent(int p_node) +{ + if (_output->GetDataAssembly()->GetParent(p_node) > 0) + { + _currentSelection.insert(_output->GetDataAssembly()->GetParent(p_node)); + _oldSelection.erase(_output->GetDataAssembly()->GetParent(p_node)); + selectNodeIdParent(_output->GetDataAssembly()->GetParent(p_node)); + } +} +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::selectNodeIdChildren(int p_node) +{ + for (int w_nodeChild : _output->GetDataAssembly()->GetChildNodes(p_node)) + { + _currentSelection.insert(w_nodeChild); + _oldSelection.erase(w_nodeChild); + selectNodeIdChildren(w_nodeChild); + } +} + +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::clearSelection() +{ + _oldSelection = _currentSelection; + _currentSelection.clear(); +} + +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::initMapperSet(const TreeViewNodeType p_type, const int p_nodeId, const int p_nbProcess, const int p_processId) +{ + CommonAbstractObjectToVtkPartitionedDataSet *w_caotvpds = nullptr; + const std::string w_uuid = std::string(_output->GetDataAssembly()->GetNodeName(p_nodeId)).substr(1); + + COMMON_NS::AbstractObject* const w_abstractObject = _repository->getDataObjectByUuid(w_uuid); + + if (p_type == TreeViewNodeType::WellboreCompletion) + { + try + { + if (dynamic_cast(w_abstractObject) != nullptr) + { + _nodeIdToMapperSet[p_nodeId] = new WitsmlWellboreCompletionToVtkPartitionedDataSet(static_cast(w_abstractObject), p_processId, p_nbProcess); + } + else + { + vtkOutputWindowDisplayErrorText(("Error object type in vtkDataAssembly for uuid: " + w_uuid + "\n").c_str()); + } + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Error when initialize uuid: " + w_uuid + "\n" + e.what()).c_str()); + } + } + else if (p_type == TreeViewNodeType::WellboreMarkerFrame) + { + try + { + if (dynamic_cast(w_abstractObject) != nullptr) + { + _nodeIdToMapperSet[p_nodeId] = new ResqmlWellboreMarkerFrameToVtkPartitionedDataSet(static_cast(w_abstractObject), p_processId, p_nbProcess); + } + else + { + vtkOutputWindowDisplayErrorText(("Error object type in vtkDataAssembly for uuid: " + w_uuid + "\n").c_str()); + } + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Error when initialize uuid: " + w_uuid + "\n" + e.what()).c_str()); + } + } + else if (p_type == TreeViewNodeType::WellboreFrame) + { + try + { + if (dynamic_cast(w_abstractObject) != nullptr) + { + _nodeIdToMapperSet[p_nodeId] = new ResqmlWellboreFrameToVtkPartitionedDataSet(static_cast(w_abstractObject), p_processId, p_nbProcess); + } + else + { + vtkOutputWindowDisplayErrorText(("Error object type in vtkDataAssembly for uuid: " + w_uuid + "\n").c_str()); + } + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Error when initialize uuid: " + w_uuid + "\n" + e.what()).c_str()); + } + } + +} + +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::loadMapper(const TreeViewNodeType p_type, const int p_nodeId, const int p_nbProcess, const int p_processId) +{ + if (TreeViewNodeType::Representation == p_type) + { + loadRepresentationMapper(p_nodeId, p_nbProcess, p_processId); + } + else if (TreeViewNodeType::WellboreTrajectory == p_type) + { + loadWellboreTrajectoryMapper(p_nodeId); + } + else if (TreeViewNodeType::SubRepresentation == p_type) + { + loadWellboreTrajectoryMapper(p_nodeId); + } +} + +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::loadRepresentationMapper(const int p_nodeId, const int p_nbProcess, const int p_processId) +{ + CommonAbstractObjectToVtkPartitionedDataSet* w_caotvpds = nullptr; + const std::string w_uuid = std::string(_output->GetDataAssembly()->GetNodeName(p_nodeId)).substr(1); + COMMON_NS::AbstractObject* const w_abstractObject = _repository->getDataObjectByUuid(w_uuid); + + if (dynamic_cast(w_abstractObject) != nullptr) + { + w_caotvpds = new ResqmlIjkGridToVtkExplicitStructuredGrid(static_cast(w_abstractObject), p_processId, p_nbProcess); + } + else if (dynamic_cast(w_abstractObject) != nullptr) + { + w_caotvpds = new ResqmlGrid2dToVtkStructuredGrid(static_cast(w_abstractObject)); + } + else if (dynamic_cast(w_abstractObject) != nullptr) + { + w_caotvpds = new ResqmlTriangulatedSetToVtkPartitionedDataSet(static_cast(w_abstractObject)); + } + else if (dynamic_cast(w_abstractObject) != nullptr) + { + w_caotvpds = new ResqmlPolylineToVtkPolyData(static_cast(w_abstractObject)); + } + else if (dynamic_cast(w_abstractObject) != nullptr) + { + w_caotvpds = new ResqmlUnstructuredGridToVtkUnstructuredGrid(static_cast(w_abstractObject)); + } + else if (dynamic_cast(w_abstractObject) != nullptr) + { + RESQML2_NS::SubRepresentation* w_subRep = static_cast(w_abstractObject); + + if (dynamic_cast(w_subRep->getSupportingRepresentation(0)) != nullptr) + { + auto* w_supportingGrid = static_cast(w_subRep->getSupportingRepresentation(0)); + if (_nodeIdToMapper.find(_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_supportingGrid->getUuid()).c_str())) == _nodeIdToMapper.end()) + { + _nodeIdToMapper[_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_supportingGrid->getUuid()).c_str())] = new ResqmlIjkGridToVtkExplicitStructuredGrid(w_supportingGrid); + } + w_caotvpds = new ResqmlIjkGridSubRepToVtkExplicitStructuredGrid(w_subRep, dynamic_cast(_nodeIdToMapper[_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_supportingGrid->getUuid()).c_str())])); + } + else if (dynamic_cast(w_subRep->getSupportingRepresentation(0)) != nullptr) + { + auto* w_supportingGrid = static_cast(w_subRep->getSupportingRepresentation(0)); + if (_nodeIdToMapper.find(_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_supportingGrid->getUuid()).c_str())) == _nodeIdToMapper.end()) + { + _nodeIdToMapper[_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_supportingGrid->getUuid()).c_str())] = new ResqmlUnstructuredGridToVtkUnstructuredGrid(w_supportingGrid); + } + w_caotvpds = new ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid(w_subRep, dynamic_cast(_nodeIdToMapper[_output->GetDataAssembly()->FindFirstNodeWithName(("_" + w_supportingGrid->getUuid()).c_str())])); + } + } + _nodeIdToMapper[p_nodeId] = w_caotvpds; + try + { // load representation + _nodeIdToMapper[p_nodeId]->loadVtkObject(); + return; + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Error when rendering uuid: " + w_uuid + "\n" + e.what()).c_str()); + return; + } +} + +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::loadWellboreTrajectoryMapper(const int p_nodeId) +{ + const std::string w_uuid = std::string(_output->GetDataAssembly()->GetNodeName(p_nodeId)).substr(1); + COMMON_NS::AbstractObject* const w_abstractObject = _repository->getDataObjectByUuid(w_uuid); + + + if (dynamic_cast(w_abstractObject) != nullptr) + { + _nodeIdToMapper[p_nodeId] = new ResqmlWellboreTrajectoryToVtkPolyData(static_cast(w_abstractObject)); + } else { + vtkOutputWindowDisplayErrorText(("Error object type in vtkDataAssembly for uuid: " + w_uuid + "\n").c_str()); + return; + } + try + { // load representation + _nodeIdToMapper[p_nodeId]->loadVtkObject(); + return; + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Error when rendering uuid: " + w_uuid + "\n" + e.what()).c_str()); + return; + } +} + +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::addDataToParent(const TreeViewNodeType p_type, const int p_nodeId, const int p_nbProcess, const int p_processId, const double p_time) +{ + const std::string w_uuid = std::string(_output->GetDataAssembly()->GetNodeName(p_nodeId)).substr(1); + + // search representation NodeId + int w_nodeParent = _output->GetDataAssembly()->GetParent(p_nodeId); + int value_type; + _output->GetDataAssembly()->GetAttribute(w_nodeParent, "type", value_type); + TreeViewNodeType w_typeParent = static_cast(value_type); + while (w_typeParent == TreeViewNodeType::Collection) + { + w_nodeParent = _output->GetDataAssembly()->GetParent(w_nodeParent); + value_type; + _output->GetDataAssembly()->GetAttribute(w_nodeParent, "type", value_type); + w_typeParent = static_cast(value_type); + } + + if (TreeViewNodeType::Perforation == p_type) + { + try + { + if (static_cast(_nodeIdToMapperSet[w_nodeParent])) + { + const char* w_connection; + _output->GetDataAssembly()->GetAttribute(p_nodeId, "connection", w_connection); + const char* w_name; + _output->GetDataAssembly()->GetAttribute(p_nodeId, "label", w_name); + const char* w_skin_s; + _output->GetDataAssembly()->GetAttribute(p_nodeId, "skin", w_skin_s); + const double w_skin = std::strtod(w_skin_s, nullptr); + if (!_nodeIdToMapperSet[w_nodeParent]->existUuid(w_connection)) + { + (static_cast(_nodeIdToMapperSet[w_nodeParent]))->addPerforation(w_connection, w_name, w_skin); + } + else + { + vtkOutputWindowDisplayErrorText(("Error object type in vtkDataAssembly for uuid: " + w_uuid + "\n").c_str()); + } + } + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Error when initialize uuid: " + w_uuid + "\n" + e.what()).c_str()); + } + return; + } + else if (TreeViewNodeType::WellboreChannel == p_type) + { + try + { + COMMON_NS::AbstractObject *const w_result = _repository->getDataObjectByUuid(w_uuid); + if (static_cast(_nodeIdToMapperSet[w_nodeParent])) + { + if (!_nodeIdToMapperSet[w_nodeParent]->existUuid(w_uuid)) + { + if (dynamic_cast(w_result) != nullptr) + { + (static_cast(_nodeIdToMapperSet[w_nodeParent]))->addChannel(w_uuid, static_cast(w_result)); + } + } + } + else + { + vtkOutputWindowDisplayErrorText(("Error object type in vtkDataAssembly for uuid: " + w_uuid + "\n").c_str()); + } + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Error when initialize uuid: " + w_uuid + "\n" + e.what()).c_str()); + } + return; + } + else if (TreeViewNodeType::WellboreMarker == p_type) + { + try + { + if (static_cast(_nodeIdToMapperSet[w_nodeParent])) + { + const std::string w_uuidParent = std::string(_output->GetDataAssembly()->GetNodeName(w_nodeParent)).substr(1); + resqml2::WellboreMarkerFrameRepresentation* w_markerFrame = _repository->getDataObjectByUuid(w_uuidParent); + if (!_nodeIdToMapperSet[w_nodeParent]->existUuid(w_uuid)) + { + resqml2::WellboreMarker* const w_marker = _repository->getDataObjectByUuid(w_uuid); + (static_cast(_nodeIdToMapperSet[w_nodeParent]))->addMarker(w_markerFrame, w_uuid, _markerOrientation, _markerSize); + } + else + { + (static_cast(_nodeIdToMapperSet[w_nodeParent]))->changeOrientationAndSize(w_uuid, _markerOrientation, _markerSize); + } + } + else + { + vtkOutputWindowDisplayErrorText(("Error object type in vtkDataAssembly for uuid: " + w_uuid + "\n").c_str()); + } + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Error when initialize uuid: " + w_uuid + "\n" + e.what()).c_str()); + } + return; + } + else if (TreeViewNodeType::Properties == p_type) + { + try + { + if (static_cast(_nodeIdToMapper[w_nodeParent])) + { + static_cast(_nodeIdToMapper[w_nodeParent])->addDataArray(w_uuid); + } + else + { + vtkOutputWindowDisplayErrorText(("Error representation for property uuid: " + w_uuid + " not exist\n").c_str()); + } + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Error when initialize uuid: " + w_uuid + "\n" + e.what()).c_str()); + } + } + else if (TreeViewNodeType::TimeSeries == p_type) + { + try + { + std::string w_tsUuid = w_uuid.substr(0, 36); + std::string w_nodeName = w_uuid.substr(36); + + auto const* assembly = _output->GetDataAssembly(); + if (_nodeIdToMapper[w_nodeParent]) + { + static_cast(_nodeIdToMapper[w_nodeParent])->addDataArray(_timeSeriesUuidAndTitleToIndexAndPropertiesUuid[w_tsUuid][w_nodeName][p_time]); + } + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Error when load Time Series property marker uuid: " + w_uuid + "\n" + e.what()).c_str()); + } + return; + } +} + +/** + * delete oldSelection mapper + */ +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::deleteMapper(double p_time) +{ + // initialization the output (VtkPartitionedDatasSetCollection) with same vtkDataAssembly + vtkSmartPointer w_Assembly = vtkSmartPointer::New(); + w_Assembly->DeepCopy(_output->GetDataAssembly()); + _output = vtkSmartPointer::New(); + _output->SetDataAssembly(w_Assembly); + + // delete unchecked object + for (const int w_nodeId : _oldSelection) + { + // retrieval of object type for nodeid + int w_valueType; + w_Assembly->GetAttribute(w_nodeId, "type", w_valueType); + TreeViewNodeType valueType = static_cast(w_valueType); + + // retrieval of object UUID for nodeId + const std::string uuid_unselect = std::string(w_Assembly->GetNodeName(w_nodeId)).substr(1); + + if (valueType == TreeViewNodeType::TimeSeries) + { // TimeSerie properties deselection + std::string w_timeSeriesuuid = uuid_unselect.substr(0, 36); + std::string w_nodeName = uuid_unselect.substr(36); + + const int w_nodeParent = w_Assembly->GetParent(w_Assembly->FindFirstNodeWithName(("_" + uuid_unselect).c_str())); + if (_nodeIdToMapper.find(w_nodeParent) != _nodeIdToMapper.end()) + { + static_cast(_nodeIdToMapper[w_nodeParent])->deleteDataArray(_timeSeriesUuidAndTitleToIndexAndPropertiesUuid[w_timeSeriesuuid][w_nodeName][p_time]); + } + } + else if (valueType == TreeViewNodeType::Properties) + { + int w_nodeParent = _output->GetDataAssembly()->GetParent(w_nodeId); + int w_typeValue; + _output->GetDataAssembly()->GetAttribute(w_nodeParent, "type", w_typeValue); + TreeViewNodeType w_typeParent = static_cast(w_typeValue); + while (w_typeParent == TreeViewNodeType::Collection) + { + w_nodeParent = _output->GetDataAssembly()->GetParent(w_nodeParent); + w_typeValue; + _output->GetDataAssembly()->GetAttribute(w_nodeParent, "type", w_typeValue); + w_typeParent = static_cast(w_typeValue); + } + + try + { + if (_nodeIdToMapper.find(w_nodeParent) != _nodeIdToMapper.end()) + { + static_cast(_nodeIdToMapper[w_nodeParent])->deleteDataArray(std::string(w_Assembly->GetNodeName(w_nodeId)).substr(1)); + } + } + catch (const std::exception &e) + { + vtkOutputWindowDisplayErrorText(("Error in property unload for uuid: " + uuid_unselect + "\n" + e.what()).c_str()); + } + } + else if (valueType == TreeViewNodeType::WellboreMarker || + valueType == TreeViewNodeType::WellboreChannel) + { + const int w_nodeParent = w_Assembly->GetParent(w_nodeId); + try + { + if (_nodeIdToMapperSet.find(w_nodeParent) != _nodeIdToMapperSet.end()) + { + _nodeIdToMapperSet[w_nodeParent]->removeCommonAbstractObjectToVtkPartitionedDataSet(std::string(w_Assembly->GetNodeName(w_nodeId)).substr(1)); + } + } + catch (const std::exception &e) + { + vtkOutputWindowDisplayErrorText(("Error in property unload for uuid: " + uuid_unselect + "\n" + e.what()).c_str()); + } + } + else if (valueType == TreeViewNodeType::SubRepresentation) + { + try + { + if (_nodeIdToMapper.find(w_nodeId) != _nodeIdToMapper.end()) + { + std::string uuid_supporting_grid = ""; + if (dynamic_cast(_nodeIdToMapper[w_nodeId]) != nullptr) + { + uuid_supporting_grid = static_cast(_nodeIdToMapper[w_nodeId])->unregisterToMapperSupportingGrid(); + } + else if (dynamic_cast(_nodeIdToMapper[w_nodeId]) != nullptr) + { + uuid_supporting_grid = static_cast(_nodeIdToMapper[w_nodeId])->unregisterToMapperSupportingGrid(); + } + delete _nodeIdToMapper[w_nodeId]; + _nodeIdToMapper.erase(w_nodeId); + } + else + { + vtkOutputWindowDisplayErrorText(("Error in deselection for uuid: " + uuid_unselect + "\n").c_str()); + } + } + catch (const std::exception &e) + { + vtkOutputWindowDisplayErrorText(("Error in subrepresentation unload for uuid: " + uuid_unselect + "\n" + e.what()).c_str()); + } + } + else if (valueType == TreeViewNodeType::Representation || + valueType == TreeViewNodeType::WellboreTrajectory) + { + try + { + if (_nodeIdToMapper.find(w_nodeId) != _nodeIdToMapper.end()) + { + delete _nodeIdToMapper[w_nodeId]; + _nodeIdToMapper.erase(w_nodeId); + } + } + catch (const std::exception &e) + { + vtkOutputWindowDisplayErrorText(("Error for unload uuid: " + uuid_unselect + "\n" + e.what()).c_str()); + } + } + else if (valueType == TreeViewNodeType::Perforation) + // delete child of CommonAbstractObjectSetToVtkPartitionedDataSetSet + { + const int w_nodeParent = w_Assembly->GetParent(w_nodeId); + try + { + if (_nodeIdToMapperSet.find(w_nodeParent) != _nodeIdToMapperSet.end()) + { + const char *w_connection; + _output->GetDataAssembly()->GetAttribute(w_nodeId, "connection", w_connection); + _nodeIdToMapperSet[w_nodeParent]->removeCommonAbstractObjectToVtkPartitionedDataSet(w_connection); + } + } + catch (const std::exception &e) + { + vtkOutputWindowDisplayErrorText(("Error in WellboreCompletion unload for uuid: " + uuid_unselect + "\n" + e.what()).c_str()); + } + } + else if (valueType == TreeViewNodeType::WellboreCompletion || + valueType == TreeViewNodeType::WellboreMarkerFrame || + valueType == TreeViewNodeType::WellboreFrame) + { + try + { + if (_nodeIdToMapperSet.find(w_nodeId) != _nodeIdToMapperSet.end()) + { + delete _nodeIdToMapperSet[w_nodeId]; + _nodeIdToMapperSet.erase(w_nodeId); + } + } + catch (const std::exception &e) + { + vtkOutputWindowDisplayErrorText(("Error in WellboreCompletion unload for uuid: " + uuid_unselect + "\n" + e.what()).c_str()); + } + } + } +} + +vtkPartitionedDataSetCollection *ResqmlDataRepositoryToVtkPartitionedDataSetCollection::getVtkPartitionedDatasSetCollection(const double p_time, const int p_nbProcess, const int p_processId) +{ + deleteMapper(p_time); + + // vtkParitionedDataSetCollection - hierarchy - build + // foreach selection node init object + auto w_it = _currentSelection.begin(); + while (w_it != _currentSelection.end()) + { + int w_typeValue; + _output->GetDataAssembly()->GetAttribute(*w_it, "type", w_typeValue); + TreeViewNodeType w_type = static_cast(w_typeValue); + + // init MapperSet && save nodeId for attach to vtkPartitionedDataSetcollection + if (getMapperType(w_type) == MapperType::MapperSet) + { + // initialize mapperSet with nodeId + if (_nodeIdToMapperSet.find(*w_it) == _nodeIdToMapperSet.end()) + { + initMapperSet(w_type, *w_it, p_nbProcess, p_processId); + } + ++w_it; + } + else if (getMapperType(w_type) == MapperType::Mapper) + { + // load mapper with nodeId + if (_nodeIdToMapper.find(*w_it) == _nodeIdToMapper.end()) + { + loadMapper(w_type, *w_it, p_nbProcess, p_processId); + } + ++w_it; + } + else if (getMapperType(w_type) == MapperType::Folder) + { + ++w_it; + } + else if (getMapperType(w_type) == MapperType::Data) + { + addDataToParent(w_type, *w_it, p_nbProcess, p_processId, p_time); + ++w_it; + } + } + + unsigned int w_PartitionIndex = 0; + // foreach selection node load object + for (const int w_nodeSelection : _currentSelection) + { + int w_typeValue; + _output->GetDataAssembly()->GetAttribute(w_nodeSelection, "type", w_typeValue); + TreeViewNodeType w_type = static_cast(w_typeValue); + + if (getMapperType(w_type) == MapperType::MapperSet) + { + // load mapper representation + if (_nodeIdToMapperSet.find(w_nodeSelection) != _nodeIdToMapperSet.end()) + { + try + { + _nodeIdToMapperSet[w_nodeSelection]->loadVtkObject(); + } + catch (const std::exception& e) + { + vtkOutputWindowDisplayErrorText(("Fesapi Error for uuid : " + std::string(_output->GetDataAssembly()->GetNodeName(w_nodeSelection)).substr(1) + "\n" + e.what()).c_str()); + } + for (auto partition : _nodeIdToMapperSet[w_nodeSelection]->getMapperSet()) + { + _output->SetPartitionedDataSet(w_PartitionIndex, partition->getOutput()); + _output->GetMetaData(w_PartitionIndex)->Set(vtkCompositeDataSet::NAME(), partition->getTitle() + '(' + partition->getUuid() + ')'); + GetAssembly()->AddDataSetIndex(w_nodeSelection, w_PartitionIndex + 1); // attach hierarchy to assembly + w_PartitionIndex++; + } + } + } + else if (getMapperType(w_type) == MapperType::Mapper) + { + // load mapper representation + if (_nodeIdToMapper.find(w_nodeSelection) != _nodeIdToMapper.end()) + { + _output->SetPartitionedDataSet(w_PartitionIndex, _nodeIdToMapper[w_nodeSelection]->getOutput()); + _output->GetMetaData(w_PartitionIndex)->Set(vtkCompositeDataSet::NAME(), _nodeIdToMapper[w_nodeSelection]->getTitle() + '(' + _nodeIdToMapper[w_nodeSelection]->getUuid() + ')'); + GetAssembly()->AddDataSetIndex(w_nodeSelection, w_PartitionIndex + 1); // attach hierarchy to assembly + w_PartitionIndex++; + } + } + } + + _output->Modified(); + return _output; +} + +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::setMarkerOrientation(bool orientation) +{ + _markerOrientation = orientation; +} + +void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::setMarkerSize(int size) +{ + _markerSize = size; +} diff --git a/Plugin/Energistics/Mapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h b/Plugin/Energistics/Mapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h new file mode 100644 index 0000000..163d663 --- /dev/null +++ b/Plugin/Energistics/Mapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h @@ -0,0 +1,165 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#ifndef __ResqmlDataRepositoryToVtkPartitionedDataSetCollection_h +#define __ResqmlDataRepositoryToVtkPartitionedDataSetCollection_h + +// include system +#include +#include +#include + +#include +#include +#include + +#ifdef WITH_ETP_SSL +#include +#endif + +#include "../Tools/enum.h" + +namespace common +{ + class DataObjectRepository; +} + +namespace resqml2 +{ + class AbstractRepresentation; + class RepresentationSetRepresentation; + class AbstractObject; + class PropertySet; + class WellboreTrajectoryRepresentation; + class WellboreFeature; +} + +namespace resqml2_0_1 +{ + class PropertySet; +} + +class ResqmlAbstractRepresentationToVtkPartitionedDataSet; +class CommonAbstractObjectSetToVtkPartitionedDataSetSet; +class CommonAbstractObjectToVtkPartitionedDataSet; + +/** + * @brief transform a fesapi data repository to VtkPartitionedDataSetCollection + */ +class ResqmlDataRepositoryToVtkPartitionedDataSetCollection +{ +public: + ResqmlDataRepositoryToVtkPartitionedDataSetCollection(); + ~ResqmlDataRepositoryToVtkPartitionedDataSetCollection(); + // --------------- PART: TreeView --------------------- + vtkDataAssembly* GetAssembly() { return _output->GetDataAssembly(); }; + + //--------------------------------- + + // for EPC reader + std::string addFile(const char *p_file); + + // for ETP source + std::string addDataspace(const char *p_dataspace); + + // for ETP connection + std::vector connect(const std::string &p_etpUrl, const std::string &p_dataPartition, const std::string &p_authConnection); + void disconnect(); + + // Wellbore Options + void setMarkerOrientation(bool p_orientation); + void setMarkerSize(int p_size); + + vtkPartitionedDataSetCollection *getVtkPartitionedDatasSetCollection(const double p_time, const int p_nbProcess = 1, const int p_processId = 0); + + std::vector getTimes() { return _timesStep; }; + + /** + * @return selection parent + */ + std::string selectNodeId(int p_nodeId); + void clearSelection(); + +private: + std::string buildDataAssemblyFromDataObjectRepo(const char *p_fileName); + + std::string searchWellboreTrajectory(const std::string &p_fileName); // traj + std::string searchWellboreFrame(const resqml2::WellboreTrajectoryRepresentation *w_wellboreTrajectory, int p_nodeId); // frame/markerFrame + chanel + marker + std::string searchWellboreCompletion(const resqml2::WellboreFeature *w_wellboreTrajectory, int p_nodeId); // completion + perforation + std::string searchRepresentations(resqml2::AbstractRepresentation const *p_representation, int p_nodeId = 0 /* 0 is root's id*/); + int searchRepresentationSetRepresentation(resqml2::RepresentationSetRepresentation const *p_rsr, int p_nodeId = 0 /* 0 is root's id*/); + std::string searchSubRepresentation(resqml2::AbstractRepresentation const *p_representation, int p_nodeParent); + std::string searchTimeSeries(const std::string &p_fileName); + int searchPropertySet(resqml2_0_1::PropertySet const *p_propSet, int p_nodeId); + std::string searchProperties(resqml2::AbstractRepresentation const *p_representation, int p_nodeParent); + + void selectNodeIdParent(int p_nodeId); + void selectNodeIdChildren(int p_nodeId); + + /** + * delete _oldSelection mapper + */ + void deleteMapper(double p_time); + /** + * initialize _nodeIdToMapperSet + */ + void initMapperSet(const TreeViewNodeType p_type, const int p_nodeId, const int p_nbProcess, const int p_processId); + /** + * initialize and load _nodeIdToMapper + */ + void loadMapper(const TreeViewNodeType p_type, const int p_nodeId,const int p_nbProcess, const int p_processId); + void loadRepresentationMapper(const int p_nodeId, const int p_nbProcess, const int p_processId); + void loadWellboreTrajectoryMapper(const int p_nodeId); + /** + * add data to parent nodeId + */ + void addDataToParent(const TreeViewNodeType p_type, const int p_nodeId, const int p_nbProcess, const int p_processId, const double p_time); + + // This function replaces the VTK function vtkDataAssembly::MakeValidNodeName(), + // which has a bug in the sorted_valid_chars array. The '.' character is placed + // before the '-' character, which is incorrect. This function uses a valid_chars + // array that correctly sorts the characters. The function checks if each character + // in the input string is valid, and adds it to the _output string if it is valid. + // If the first character of the _output string is not valid, an underscore is added + // to the beginning of the _output string. This function is designed to create a valid + // node name from a given string. + std::string MakeValidNodeName(const char *p_name); + + bool _markerOrientation; + int _markerSize; + + common::DataObjectRepository *_repository; + + vtkSmartPointer _output; + + std::map _nodeIdToMapper; // index of VtkDataAssembly to CommonAbstractObjectToVtkPartitionedDataSet + std::map _nodeIdToMapperSet; // index of VtkDataAssembly to CommonAbstractObjectSetToVtkPartitionedDataSetSet + + //\/ uuid title index prop_uuid + std::map>> _timeSeriesUuidAndTitleToIndexAndPropertiesUuid; + + std::set _currentSelection; + std::set _oldSelection; + + // time step values + std::vector _timesStep; +#ifdef WITH_ETP_SSL + std::shared_ptr _session; +#endif +}; +#endif diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlGrid2dToVtkStructuredGrid.cxx b/Plugin/Energistics/Mapping/ResqmlGrid2dToVtkStructuredGrid.cxx similarity index 73% rename from Plugin/Energistics/ResqmlMapping/ResqmlGrid2dToVtkStructuredGrid.cxx rename to Plugin/Energistics/Mapping/ResqmlGrid2dToVtkStructuredGrid.cxx index 1e25fd2..1f7bf1e 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlGrid2dToVtkStructuredGrid.cxx +++ b/Plugin/Energistics/Mapping/ResqmlGrid2dToVtkStructuredGrid.cxx @@ -16,7 +16,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlGrid2dToVtkStructuredGrid.h" +#include "Mapping/ResqmlGrid2dToVtkStructuredGrid.h" // include VTK library #include @@ -28,25 +28,25 @@ under the License. #include // include F2i-consulting Energistics Paraview Plugin -#include "ResqmlMapping/ResqmlPropertyToVtkDataArray.h" +#include "Mapping/ResqmlPropertyToVtkDataArray.h" //---------------------------------------------------------------------------- -ResqmlGrid2dToVtkStructuredGrid::ResqmlGrid2dToVtkStructuredGrid(RESQML2_NS::Grid2dRepresentation *grid2D, int proc_number, int max_proc) +ResqmlGrid2dToVtkStructuredGrid::ResqmlGrid2dToVtkStructuredGrid(const RESQML2_NS::Grid2dRepresentation *grid2D, int p_procNumber, int p_maxProc) : ResqmlAbstractRepresentationToVtkPartitionedDataSet(grid2D, - proc_number, - max_proc) + p_procNumber, + p_maxProc) { - this->pointCount = grid2D->getNodeCountAlongIAxis() * grid2D->getNodeCountAlongJAxis(); + _pointCount = grid2D->getNodeCountAlongIAxis() * grid2D->getNodeCountAlongJAxis(); - this->vtkData = vtkSmartPointer::New(); + _vtkData = vtkSmartPointer::New(); - this->vtkData->Modified(); + _vtkData->Modified(); } //---------------------------------------------------------------------------- -RESQML2_NS::Grid2dRepresentation const* ResqmlGrid2dToVtkStructuredGrid::getResqmlData() const +const RESQML2_NS::Grid2dRepresentation *ResqmlGrid2dToVtkStructuredGrid::getResqmlData() const { - return static_cast(resqmlData); + return static_cast(_resqmlData); } //---------------------------------------------------------------------------- @@ -54,7 +54,7 @@ void ResqmlGrid2dToVtkStructuredGrid::loadVtkObject() { vtkSmartPointer structuredGrid = vtkSmartPointer::New(); - RESQML2_NS::Grid2dRepresentation const* grid2D = getResqmlData(); + RESQML2_NS::Grid2dRepresentation const *grid2D = getResqmlData(); const double originX = grid2D->getXOriginInGlobalCrs(); const double originY = grid2D->getYOriginInGlobalCrs(); @@ -68,7 +68,7 @@ void ResqmlGrid2dToVtkStructuredGrid::loadVtkObject() structuredGrid->SetDimensions(nbNodeI, nbNodeJ, 1); // POINT - this->pointCount = nbNodeI * nbNodeJ; + _pointCount = nbNodeI * nbNodeJ; std::unique_ptr z(new double[nbNodeI * nbNodeJ]); grid2D->getZValuesInGlobalCrs(z.get()); @@ -80,20 +80,15 @@ void ResqmlGrid2dToVtkStructuredGrid::loadVtkObject() for (ULONG64 i = 0; i < nbNodeI; ++i) { const size_t ptId = i + j * nbNodeI; - //if (!isnan(z[ptId])) - //{ - vtkIdType pid = points->InsertNextPoint( - originX + i * XIOffset + j * XJOffset, - originY + i * YIOffset + j * YJOffset, - z[ptId] * zIndice); - //vertices->InsertNextCell(1, &pid); - //} + vtkIdType pid = points->InsertNextPoint( + originX + i * XIOffset + j * XJOffset, + originY + i * YIOffset + j * YJOffset, + z[ptId] * zIndice); } } structuredGrid->SetPoints(points); - //structuredGrid->SetVerts(vertices); - this->vtkData->SetPartition(0, structuredGrid); - this->vtkData->Modified(); + _vtkData->SetPartition(0, structuredGrid); + _vtkData->Modified(); } diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlGrid2dToVtkStructuredGrid.h b/Plugin/Energistics/Mapping/ResqmlGrid2dToVtkStructuredGrid.h similarity index 81% rename from Plugin/Energistics/ResqmlMapping/ResqmlGrid2dToVtkStructuredGrid.h rename to Plugin/Energistics/Mapping/ResqmlGrid2dToVtkStructuredGrid.h index 9d1a323..2d95c6a 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlGrid2dToVtkStructuredGrid.h +++ b/Plugin/Energistics/Mapping/ResqmlGrid2dToVtkStructuredGrid.h @@ -27,7 +27,7 @@ under the License. #include // include VTK -#include +#include #include #include "ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" @@ -37,20 +37,20 @@ namespace RESQML2_NS class Grid2dRepresentation; } -class ResqmlGrid2dToVtkStructuredGrid : public ResqmlAbstractRepresentationToVtkPartitionedDataSet +class ResqmlGrid2dToVtkStructuredGrid : public ResqmlAbstractRepresentationToVtkPartitionedDataSet { public: /** - * Constructor - */ - explicit ResqmlGrid2dToVtkStructuredGrid(RESQML2_NS::Grid2dRepresentation * grid2D, int proc_number = 0, int max_proc = 1); + * Constructor + */ + explicit ResqmlGrid2dToVtkStructuredGrid(const RESQML2_NS::Grid2dRepresentation *grid2D, int p_procNumber = 0, int p_maxProc = 1); /** - * load vtkDataSet with resqml data - */ + * load vtkDataSet with resqml data + */ void loadVtkObject() override; protected: - RESQML2_NS::Grid2dRepresentation const* getResqmlData() const; + const RESQML2_NS::Grid2dRepresentation *getResqmlData() const; }; #endif diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlIjkGridSubRepToVtkUnstructuredGrid.cxx b/Plugin/Energistics/Mapping/ResqmlIjkGridSubRepToVtkExplicitStructuredGrid.cxx similarity index 68% rename from Plugin/Energistics/ResqmlMapping/ResqmlIjkGridSubRepToVtkUnstructuredGrid.cxx rename to Plugin/Energistics/Mapping/ResqmlIjkGridSubRepToVtkExplicitStructuredGrid.cxx index c319ff3..41a346a 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlIjkGridSubRepToVtkUnstructuredGrid.cxx +++ b/Plugin/Energistics/Mapping/ResqmlIjkGridSubRepToVtkExplicitStructuredGrid.cxx @@ -16,7 +16,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlIjkGridSubRepToVtkUnstructuredGrid.h" +#include "Mapping/ResqmlIjkGridSubRepToVtkExplicitStructuredGrid.h" #include @@ -35,31 +35,31 @@ under the License. #include // include FESPP -#include "ResqmlIjkGridToVtkUnstructuredGrid.h" +#include "ResqmlIjkGridToVtkExplicitStructuredGrid.h" //---------------------------------------------------------------------------- -ResqmlIjkGridSubRepToVtkUnstructuredGrid::ResqmlIjkGridSubRepToVtkUnstructuredGrid(RESQML2_NS::SubRepresentation *subRep, ResqmlIjkGridToVtkUnstructuredGrid *support, int proc_number, int max_proc) +ResqmlIjkGridSubRepToVtkExplicitStructuredGrid::ResqmlIjkGridSubRepToVtkExplicitStructuredGrid(const RESQML2_NS::SubRepresentation *subRep, ResqmlIjkGridToVtkExplicitStructuredGrid *support, int p_procNumber, int p_maxProc) : ResqmlAbstractRepresentationToVtkPartitionedDataSet(subRep, - proc_number, - max_proc), + p_procNumber, + p_maxProc), mapperIjkGrid(support) { - this->iCellCount = subRep->getElementCountOfPatch(0); - this->pointCount = subRep->getSupportingRepresentation(0)->getXyzPointCountOfAllPatches(); + _iCellCount = subRep->getElementCountOfPatch(0); + _pointCount = subRep->getSupportingRepresentation(0)->getXyzPointCountOfAllPatches(); - this->vtkData = vtkSmartPointer::New(); + _vtkData = vtkSmartPointer::New(); } //---------------------------------------------------------------------------- -RESQML2_NS::SubRepresentation const* ResqmlIjkGridSubRepToVtkUnstructuredGrid::getResqmlData() const +const RESQML2_NS::SubRepresentation *ResqmlIjkGridSubRepToVtkExplicitStructuredGrid::getResqmlData() const { - return static_cast(resqmlData); + return static_cast(_resqmlData); } //---------------------------------------------------------------------------- -void ResqmlIjkGridSubRepToVtkUnstructuredGrid::loadVtkObject() +void ResqmlIjkGridSubRepToVtkExplicitStructuredGrid::loadVtkObject() { - RESQML2_NS::SubRepresentation const* subRep = getResqmlData(); + RESQML2_NS::SubRepresentation const *subRep = getResqmlData(); auto *supportingGrid = dynamic_cast(subRep->getSupportingRepresentation(0)); if (supportingGrid != nullptr) { @@ -84,26 +84,26 @@ void ResqmlIjkGridSubRepToVtkUnstructuredGrid::loadVtkObject() std::unique_ptr elementIndices(new uint64_t[elementCountOfPatch]); subRep->getElementIndicesOfPatch(0, 0, elementIndices.get()); - iCellCount = supportingGrid->getICellCount(); - jCellCount = supportingGrid->getJCellCount(); - kCellCount = supportingGrid->getKCellCount(); + _iCellCount = supportingGrid->getICellCount(); + _jCellCount = supportingGrid->getJCellCount(); + _kCellCount = supportingGrid->getKCellCount(); - initKIndex = 0; - maxKIndex = kCellCount; + _initKIndex = 0; + _maxKIndex = _kCellCount; size_t indice = 0; - for (uint_fast32_t vtkKCellIndex = initKIndex; vtkKCellIndex < maxKIndex; ++vtkKCellIndex) + for (uint_fast32_t vtkKCellIndex = _initKIndex; vtkKCellIndex < _maxKIndex; ++vtkKCellIndex) { - for (uint_fast32_t vtkJCellIndex = 0; vtkJCellIndex < jCellCount; ++vtkJCellIndex) + for (uint_fast32_t vtkJCellIndex = 0; vtkJCellIndex < _jCellCount; ++vtkJCellIndex) { - for (uint_fast32_t vtkICellIndex = 0; vtkICellIndex < iCellCount; ++vtkICellIndex) + for (uint_fast32_t vtkICellIndex = 0; vtkICellIndex < _iCellCount; ++vtkICellIndex) { if (elementIndices[indice] == cellIndex) { vtkSmartPointer hex = vtkSmartPointer::New(); - for (uint_fast8_t cornerId = 0; cornerId < 8; ++cornerId) + for (uint_fast8_t cornerId = 0; cornerId < 8; ++cornerId) { hex->GetPointIds()->SetId(cornerId, supportingGrid->getXyzPointIndexFromCellCorner(vtkICellIndex, vtkJCellIndex, vtkKCellIndex, correspondingResqmlCornerId[cornerId])); @@ -117,24 +117,24 @@ void ResqmlIjkGridSubRepToVtkUnstructuredGrid::loadVtkObject() } supportingGrid->unloadSplitInformation(); - this->vtkData->SetPartition(0, vtk_unstructuredGrid); - this->vtkData->Modified(); + _vtkData->SetPartition(0, vtk_unstructuredGrid); + _vtkData->Modified(); } else { - // TODO msg d'erreur + vtkOutputWindowDisplayWarningText(("SubRepresentation (" + subRep->getUuid() + ") has no suuport grid").c_str()); } } //---------------------------------------------------------------------------- -std::string ResqmlIjkGridSubRepToVtkUnstructuredGrid::unregisterToMapperSupportingGrid() +std::string ResqmlIjkGridSubRepToVtkExplicitStructuredGrid::unregisterToMapperSupportingGrid() { this->mapperIjkGrid->unregisterSubRep(); return this->mapperIjkGrid->getUuid(); } //---------------------------------------------------------------------------- -vtkSmartPointer ResqmlIjkGridSubRepToVtkUnstructuredGrid::getMapperVtkPoint() +vtkSmartPointer ResqmlIjkGridSubRepToVtkExplicitStructuredGrid::getMapperVtkPoint() { this->mapperIjkGrid->registerSubRep(); return this->mapperIjkGrid->getVtkPoints(); diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlIjkGridSubRepToVtkUnstructuredGrid.h b/Plugin/Energistics/Mapping/ResqmlIjkGridSubRepToVtkExplicitStructuredGrid.h similarity index 69% rename from Plugin/Energistics/ResqmlMapping/ResqmlIjkGridSubRepToVtkUnstructuredGrid.h rename to Plugin/Energistics/Mapping/ResqmlIjkGridSubRepToVtkExplicitStructuredGrid.h index aa1652b..1d9c23f 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlIjkGridSubRepToVtkUnstructuredGrid.h +++ b/Plugin/Energistics/Mapping/ResqmlIjkGridSubRepToVtkExplicitStructuredGrid.h @@ -16,15 +16,15 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ -#ifndef __ResqmlIjkGridSubRepToVtkUnstructuredGrid__h__ -#define __ResqmlIjkGridSubRepToVtkUnstructuredGrid__h__ +#ifndef __ResqmlIjkGridSubRepToVtkExplicitStructuredGrid__h__ +#define __ResqmlIjkGridSubRepToVtkExplicitStructuredGrid__h__ /** @brief transform a resqml ijkGrid Subrepresentation to vtkUnstructuredGrid */ #include "ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" - // include VTK +// include VTK #include #include @@ -33,15 +33,15 @@ namespace RESQML2_NS class SubRepresentation; } -class ResqmlIjkGridToVtkUnstructuredGrid; +class ResqmlIjkGridToVtkExplicitStructuredGrid; -class ResqmlIjkGridSubRepToVtkUnstructuredGrid : public ResqmlAbstractRepresentationToVtkPartitionedDataSet +class ResqmlIjkGridSubRepToVtkExplicitStructuredGrid : public ResqmlAbstractRepresentationToVtkPartitionedDataSet { public: /** * Constructor */ - ResqmlIjkGridSubRepToVtkUnstructuredGrid(RESQML2_NS::SubRepresentation *ijkGridSubRep, ResqmlIjkGridToVtkUnstructuredGrid* support, int proc_number = 0, int max_proc = 1); + ResqmlIjkGridSubRepToVtkExplicitStructuredGrid(const RESQML2_NS::SubRepresentation *ijkGridSubRep, ResqmlIjkGridToVtkExplicitStructuredGrid *support, int p_procNumber = 0, int p_maxProc = 1); /** * load vtkDataSet with resqml data @@ -49,18 +49,16 @@ class ResqmlIjkGridSubRepToVtkUnstructuredGrid : public ResqmlAbstractRepresenta void loadVtkObject() override; /** - * - */ + * + */ std::string unregisterToMapperSupportingGrid(); protected: - RESQML2_NS::SubRepresentation const* getResqmlData() const; + const RESQML2_NS::SubRepresentation *getResqmlData() const; - ResqmlIjkGridToVtkUnstructuredGrid* mapperIjkGrid; + ResqmlIjkGridToVtkExplicitStructuredGrid *mapperIjkGrid; private: - vtkSmartPointer getMapperVtkPoint(); - }; #endif diff --git a/Plugin/Energistics/Mapping/ResqmlIjkGridToVtkExplicitStructuredGrid.cxx b/Plugin/Energistics/Mapping/ResqmlIjkGridToVtkExplicitStructuredGrid.cxx new file mode 100644 index 0000000..a936c66 --- /dev/null +++ b/Plugin/Energistics/Mapping/ResqmlIjkGridToVtkExplicitStructuredGrid.cxx @@ -0,0 +1,269 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#include "Mapping/ResqmlIjkGridToVtkExplicitStructuredGrid.h" + +#include + +// include VTK library +#include +#include +#include +#include +#include +#include +#include +#include "vtkPointData.h" + +// include FESAPI +#include +#include + +// include FESPP +#include "ResqmlPropertyToVtkDataArray.h" + +//---------------------------------------------------------------------------- +ResqmlIjkGridToVtkExplicitStructuredGrid::ResqmlIjkGridToVtkExplicitStructuredGrid(const RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid, int p_procNumber, int p_maxProc) + : ResqmlAbstractRepresentationToVtkPartitionedDataSet(ijkGrid, + p_procNumber, + p_maxProc), + points(vtkSmartPointer::New()), + pointer_on_points(0) +{ + _iCellCount = ijkGrid->getICellCount(); + _jCellCount = ijkGrid->getJCellCount(); + _kCellCount = ijkGrid->getKCellCount(); + _pointCount = ijkGrid->getXyzPointCountOfAllPatches(); + checkHyperslabingCapacity(ijkGrid); + + if (_isHyperslabed) + { + const auto optim = (_kCellCount % p_maxProc) > 0 ? (_kCellCount / p_maxProc) + 1 : _kCellCount / p_maxProc; + _initKIndex = _procNumber * optim; + if (_initKIndex >= _kCellCount) + { + _initKIndex = 0; + _maxKIndex = 0; + } + else + { + _maxKIndex = _procNumber == _maxProc - 1 + ? _kCellCount + : _initKIndex + optim; + } + } + else + { + _initKIndex = 0; + _maxKIndex = _kCellCount; + } + + _vtkData = vtkSmartPointer::New(); +} + +//---------------------------------------------------------------------------- +const RESQML2_NS::AbstractIjkGridRepresentation *ResqmlIjkGridToVtkExplicitStructuredGrid::getResqmlData() const +{ + return static_cast(_resqmlData); +} + +//---------------------------------------------------------------------------- +void ResqmlIjkGridToVtkExplicitStructuredGrid::checkHyperslabingCapacity(const RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid) +{ + try + { + const RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid = getResqmlData(); + const auto kInterfaceNodeCount = ijkGrid->getXyzPointCountOfKInterface(); + std::unique_ptr allXyzPoints(new double[kInterfaceNodeCount * 3]); + const_cast(ijkGrid)->getXyzPointsOfKInterface(0, allXyzPoints.get()); + _isHyperslabed = true; + } + catch (const std::exception &) + { + _isHyperslabed = false; + } +} + +//---------------------------------------------------------------------------- +void ResqmlIjkGridToVtkExplicitStructuredGrid::loadVtkObject() +{ + const RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid = getResqmlData(); + + vtkExplicitStructuredGrid *vtk_explicitStructuredGrid = vtkExplicitStructuredGrid::New(); + + int extent[6] = {0, _iCellCount, 0, _jCellCount, _initKIndex, _maxKIndex}; + vtk_explicitStructuredGrid->SetExtent(extent); + + vtk_explicitStructuredGrid->SetPoints(getVtkPoints()); + + // Check which cells have no geometry + const uint64_t cellCount = ijkGrid->getCellCount(); + std::unique_ptr enabledCells(new bool[cellCount]); + if (ijkGrid->hasCellGeometryIsDefinedFlags()) + { + ijkGrid->getCellGeometryIsDefinedFlags(enabledCells.get()); + } + else + { + std::fill_n(enabledCells.get(), cellCount, true); + } + + const uint64_t translatePoint = ijkGrid->getXyzPointCountOfKInterface() * _initKIndex; + + const_cast(ijkGrid)->loadSplitInformation(); + + uint64_t cellIndex = 0; + vtkSmartPointer nodes = vtkSmartPointer::New(); + nodes->SetNumberOfIds(8); + + for (uint_fast32_t vtkKCellIndex = _initKIndex; vtkKCellIndex < _maxKIndex; ++vtkKCellIndex) + { + for (uint_fast32_t vtkJCellIndex = 0; vtkJCellIndex < _jCellCount; ++vtkJCellIndex) + { + for (uint_fast32_t vtkICellIndex = 0; vtkICellIndex < _iCellCount; ++vtkICellIndex) + { + vtkIdType cellId = vtk_explicitStructuredGrid->ComputeCellId(vtkICellIndex, vtkJCellIndex, vtkKCellIndex); + if (enabledCells[cellIndex++]) + { + vtkIdType *indice = vtk_explicitStructuredGrid->GetCellPoints(cellId); + indice[0] = ijkGrid->getXyzPointIndexFromCellCorner(vtkICellIndex, vtkJCellIndex, vtkKCellIndex, 0) - translatePoint; + indice[1] = ijkGrid->getXyzPointIndexFromCellCorner(vtkICellIndex, vtkJCellIndex, vtkKCellIndex, 1) - translatePoint; + indice[2] = ijkGrid->getXyzPointIndexFromCellCorner(vtkICellIndex, vtkJCellIndex, vtkKCellIndex, 2) - translatePoint; + indice[3] = ijkGrid->getXyzPointIndexFromCellCorner(vtkICellIndex, vtkJCellIndex, vtkKCellIndex, 3) - translatePoint; + indice[4] = ijkGrid->getXyzPointIndexFromCellCorner(vtkICellIndex, vtkJCellIndex, vtkKCellIndex, 4) - translatePoint; + indice[5] = ijkGrid->getXyzPointIndexFromCellCorner(vtkICellIndex, vtkJCellIndex, vtkKCellIndex, 5) - translatePoint; + indice[6] = ijkGrid->getXyzPointIndexFromCellCorner(vtkICellIndex, vtkJCellIndex, vtkKCellIndex, 6) - translatePoint; + indice[7] = ijkGrid->getXyzPointIndexFromCellCorner(vtkICellIndex, vtkJCellIndex, vtkKCellIndex, 7) - translatePoint; + } + else + { + vtk_explicitStructuredGrid->BlankCell(cellId); + } + } + } + } + + const_cast(ijkGrid)->unloadSplitInformation(); + + vtk_explicitStructuredGrid->CheckAndReorderFaces(); + vtk_explicitStructuredGrid->ComputeFacesConnectivityFlagsArray(); + + _vtkData->SetPartition(0, vtk_explicitStructuredGrid); + _vtkData->Modified(); +} + +//---------------------------------------------------------------------------- +vtkSmartPointer ResqmlIjkGridToVtkExplicitStructuredGrid::getVtkPoints() +{ + if (this->points->GetNumberOfPoints() < 1) + { + createPoints(); + } + + return this->points; +} + +//---------------------------------------------------------------------------- +void ResqmlIjkGridToVtkExplicitStructuredGrid::createPoints() +{ + const RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid = getResqmlData(); + + this->points->SetNumberOfPoints(_pointCount); + size_t point_id = 0; + + if (_isHyperslabed && !ijkGrid->isNodeGeometryCompressed()) + { + // Take into account K gaps + const uint32_t kGapCount = ijkGrid->getKGapsCount(); + uint32_t initKInterfaceIndex = _initKIndex; + uint32_t maxKInterfaceIndex = _maxKIndex; + if (kGapCount > 0) + { + std::unique_ptr gapAfterLayer(new bool[_kCellCount - 1]); // gap after each layer except for the last k cell + ijkGrid->getKGaps(gapAfterLayer.get()); + uint32_t kLayer = 0; + for (; kLayer < _initKIndex; ++kLayer) + { + if (gapAfterLayer[kLayer]) + { + ++initKInterfaceIndex; + ++maxKInterfaceIndex; + } + } + for (; kLayer < _kCellCount - 1 && kLayer < _maxKIndex; ++kLayer) + { + if (gapAfterLayer[kLayer]) + { + ++maxKInterfaceIndex; + } + } + } + + const uint64_t kInterfaceNodeCount = ijkGrid->getXyzPointCountOfKInterface(); + std::unique_ptr allXyzPoints(new double[kInterfaceNodeCount * 3]); + + for (uint_fast32_t kInterface = initKInterfaceIndex; kInterface <= maxKInterfaceIndex; ++kInterface) + { + const_cast(ijkGrid)->getXyzPointsOfKInterface(kInterface, allXyzPoints.get()); + auto const *crs = ijkGrid->getLocalCrs(0); + double xOffset = .0; + double yOffset = .0; + double zOffset = .0; + double zIndice = allXyzPoints[2] > 0 ? -1. : 1.; + if (crs != nullptr && !crs->isPartial()) + { + xOffset = crs->getOriginOrdinal1(); + yOffset = crs->getOriginOrdinal2(); + auto const *depthCrs = dynamic_cast(crs); + zOffset = depthCrs != nullptr ? depthCrs->getOriginDepthOrElevation() : 0; + zIndice = crs->isDepthOriented() ? -1. : 1.; + } + else + { + vtkOutputWindowDisplayWarningText("The CRS doesn't exist or is partial"); + } + for (uint_fast64_t nodeIndex = 0; nodeIndex < kInterfaceNodeCount * 3; nodeIndex += 3) + { + this->points->SetPoint(point_id++, allXyzPoints[nodeIndex] + xOffset, allXyzPoints[nodeIndex + 1] + yOffset, (allXyzPoints[nodeIndex + 2] + zOffset) * zIndice); + } + } + } + else + { + _initKIndex = 0; + _maxKIndex = _kCellCount; + + std::unique_ptr allXyzPoints(new double[_pointCount * 3]); + auto const *crs = ijkGrid->getLocalCrs(0); + if (crs != nullptr && !crs->isPartial()) + { + ijkGrid->getXyzPointsOfAllPatchesInGlobalCrs(allXyzPoints.get()); + const size_t coordCount = _pointCount * 3; + + const double zIndice = ijkGrid->getLocalCrs(0)->isDepthOriented() ? -1 : 1; + for (uint_fast64_t pointIndex = 0; pointIndex < coordCount; pointIndex += 3) + { + this->points->SetPoint(point_id++, allXyzPoints[pointIndex], allXyzPoints[pointIndex + 1], -allXyzPoints[pointIndex + 2] * zIndice); + } + } + else + { + vtkOutputWindowDisplayWarningText("The CRS doesn't exist or is partial"); + } + } +} diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlIjkGridToVtkUnstructuredGrid.h b/Plugin/Energistics/Mapping/ResqmlIjkGridToVtkExplicitStructuredGrid.h similarity index 71% rename from Plugin/Energistics/ResqmlMapping/ResqmlIjkGridToVtkUnstructuredGrid.h rename to Plugin/Energistics/Mapping/ResqmlIjkGridToVtkExplicitStructuredGrid.h index 7404e7d..7142720 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlIjkGridToVtkUnstructuredGrid.h +++ b/Plugin/Energistics/Mapping/ResqmlIjkGridToVtkExplicitStructuredGrid.h @@ -16,10 +16,10 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ -#ifndef __ResqmlIjkGridToVtkUnstructuredGrid__h__ -#define __ResqmlIjkGridToVtkUnstructuredGrid__h__ +#ifndef __ResqmlIjkGridToVtkExplicitStructuredGrid__h__ +#define __ResqmlIjkGridToVtkExplicitStructuredGrid__h__ -/** @brief transform a resqml ijkGrid representation to vtkUnstructuredGrid +/** @brief transform a resqml ijkGrid representation to vtkExplicitStructuredGrid */ // include system @@ -36,13 +36,13 @@ namespace RESQML2_NS class AbstractIjkGridRepresentation; } -class ResqmlIjkGridToVtkUnstructuredGrid : public ResqmlAbstractRepresentationToVtkPartitionedDataSet +class ResqmlIjkGridToVtkExplicitStructuredGrid : public ResqmlAbstractRepresentationToVtkPartitionedDataSet { public: /** * Constructor */ - explicit ResqmlIjkGridToVtkUnstructuredGrid(RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid, int proc_number = 0, int max_proc = 1); + explicit ResqmlIjkGridToVtkExplicitStructuredGrid(const RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid, int p_procNumber = 0, int p_maxProc = 1); /** * load vtkDataSet with resqml data @@ -52,7 +52,7 @@ class ResqmlIjkGridToVtkUnstructuredGrid : public ResqmlAbstractRepresentationTo /** * Create the VTK points from the RESQML points of the RESQML IJK grid representation. */ - void createPoints(/* RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid */); + void createPoints(); /** * Return The vtkPoints @@ -60,7 +60,7 @@ class ResqmlIjkGridToVtkUnstructuredGrid : public ResqmlAbstractRepresentationTo vtkSmartPointer getVtkPoints(); protected: - RESQML2_NS::AbstractIjkGridRepresentation * getResqmlData() const; + const RESQML2_NS::AbstractIjkGridRepresentation *getResqmlData() const; vtkSmartPointer points; unsigned int pointer_on_points; @@ -70,6 +70,6 @@ class ResqmlIjkGridToVtkUnstructuredGrid : public ResqmlAbstractRepresentationTo * variable : ijkGridRepresentation * check if an ijkgrid is Hyperslabed */ - void checkHyperslabingCapacity(RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid); + void checkHyperslabingCapacity(const RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid); }; #endif diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlPolylineToVtkPolyData.cxx b/Plugin/Energistics/Mapping/ResqmlPolylineToVtkPolyData.cxx similarity index 77% rename from Plugin/Energistics/ResqmlMapping/ResqmlPolylineToVtkPolyData.cxx rename to Plugin/Energistics/Mapping/ResqmlPolylineToVtkPolyData.cxx index 8c3fd77..d2280d3 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlPolylineToVtkPolyData.cxx +++ b/Plugin/Energistics/Mapping/ResqmlPolylineToVtkPolyData.cxx @@ -16,7 +16,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlPolylineToVtkPolyData.h" +#include "Mapping/ResqmlPolylineToVtkPolyData.h" // include VTK library #include @@ -31,44 +31,43 @@ under the License. #include // include F2i-consulting Energistics Standards ParaView Plugin -#include "ResqmlMapping/ResqmlPropertyToVtkDataArray.h" +#include "Mapping/ResqmlPropertyToVtkDataArray.h" //---------------------------------------------------------------------------- -ResqmlPolylineToVtkPolyData::ResqmlPolylineToVtkPolyData(RESQML2_NS::PolylineSetRepresentation *polyline, int proc_number, int max_proc) +ResqmlPolylineToVtkPolyData::ResqmlPolylineToVtkPolyData(const RESQML2_NS::PolylineSetRepresentation *polyline, int p_procNumber, int p_maxProc) : ResqmlAbstractRepresentationToVtkPartitionedDataSet(polyline, - proc_number, - max_proc) + p_procNumber, + p_maxProc) { - this->pointCount = polyline->getXyzPointCountOfPatch(0); + _pointCount = polyline->getXyzPointCountOfPatch(0); - this->vtkData = vtkSmartPointer::New(); + _vtkData = vtkSmartPointer::New(); - this->vtkData->Modified(); + _vtkData->Modified(); } //---------------------------------------------------------------------------- -RESQML2_NS::PolylineSetRepresentation const* ResqmlPolylineToVtkPolyData::getResqmlData() const +const RESQML2_NS::PolylineSetRepresentation *ResqmlPolylineToVtkPolyData::getResqmlData() const { - return static_cast(resqmlData); + return static_cast(_resqmlData); } - //---------------------------------------------------------------------------- void ResqmlPolylineToVtkPolyData::loadVtkObject() { - RESQML2_NS::PolylineSetRepresentation const* polyline = getResqmlData(); + RESQML2_NS::PolylineSetRepresentation const *polyline = getResqmlData(); // Create and set the list of points of the vtkPolyData vtkSmartPointer vtk_polydata = vtkSmartPointer::New(); // POINT - double *allXyzPoints = new double[this->pointCount * 3]; // Will be deleted by VTK - this->resqmlData->getXyzPointsOfPatchInGlobalCrs(0, allXyzPoints); + double *allXyzPoints = new double[_pointCount * 3]; // Will be deleted by VTK + polyline->getXyzPointsOfPatchInGlobalCrs(0, allXyzPoints); vtkSmartPointer vtkPts = vtkSmartPointer::New(); - const size_t coordCount = this->pointCount * 3; - if (this->resqmlData->getLocalCrs(0)->isDepthOriented()) + const size_t coordCount = _pointCount * 3; + if (polyline->getLocalCrs(0)->isDepthOriented()) { for (size_t zCoordIndex = 2; zCoordIndex < coordCount; zCoordIndex += 3) { @@ -104,6 +103,6 @@ void ResqmlPolylineToVtkPolyData::loadVtkObject() vtk_polydata->SetLines(setPolylineRepresentationLines); } - this->vtkData->SetPartition(0, vtk_polydata); - this->vtkData->Modified(); + _vtkData->SetPartition(0, vtk_polydata); + _vtkData->Modified(); } diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlPolylineToVtkPolyData.h b/Plugin/Energistics/Mapping/ResqmlPolylineToVtkPolyData.h similarity index 87% rename from Plugin/Energistics/ResqmlMapping/ResqmlPolylineToVtkPolyData.h rename to Plugin/Energistics/Mapping/ResqmlPolylineToVtkPolyData.h index 6e65f1c..0bab142 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlPolylineToVtkPolyData.h +++ b/Plugin/Energistics/Mapping/ResqmlPolylineToVtkPolyData.h @@ -35,7 +35,7 @@ class ResqmlPolylineToVtkPolyData : public ResqmlAbstractRepresentationToVtkPart /** * Constructor */ - explicit ResqmlPolylineToVtkPolyData(RESQML2_NS::PolylineSetRepresentation *polyline, int proc_number = 0, int max_proc = 1); + explicit ResqmlPolylineToVtkPolyData(const RESQML2_NS::PolylineSetRepresentation *polyline, int p_procNumber = 0, int p_maxProc = 1); /** * load vtkDataSet with resqml data @@ -43,6 +43,6 @@ class ResqmlPolylineToVtkPolyData : public ResqmlAbstractRepresentationToVtkPart void loadVtkObject() override; protected: - RESQML2_NS::PolylineSetRepresentation const* getResqmlData() const; + const RESQML2_NS::PolylineSetRepresentation *getResqmlData() const; }; #endif diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlPropertyToVtkDataArray.cxx b/Plugin/Energistics/Mapping/ResqmlPropertyToVtkDataArray.cxx similarity index 84% rename from Plugin/Energistics/ResqmlMapping/ResqmlPropertyToVtkDataArray.cxx rename to Plugin/Energistics/Mapping/ResqmlPropertyToVtkDataArray.cxx index dc86e62..3b5450f 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlPropertyToVtkDataArray.cxx +++ b/Plugin/Energistics/Mapping/ResqmlPropertyToVtkDataArray.cxx @@ -16,7 +16,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlPropertyToVtkDataArray.h" +#include "Mapping/ResqmlPropertyToVtkDataArray.h" #include "vtkMath.h" // FESAPI @@ -37,24 +37,24 @@ under the License. #include //---------------------------------------------------------------------------- -ResqmlPropertyToVtkDataArray::ResqmlPropertyToVtkDataArray(RESQML2_NS::AbstractValuesProperty const *valuesProperty, - uint32_t cellCount, +ResqmlPropertyToVtkDataArray::ResqmlPropertyToVtkDataArray(const RESQML2_NS::AbstractValuesProperty *valuesProperty, + uint64_t cellCount, uint64_t pointCount, uint32_t iCellCount, uint32_t jCellCount, uint32_t kCellCount, uint32_t initKIndex, - int patch_index) + int patch_index) { int nbElement = 0; - const gsoap_eml2_3::resqml22__IndexableElement element = valuesProperty->getAttachmentKind(); - if (element == gsoap_eml2_3::resqml22__IndexableElement::cells || - element == gsoap_eml2_3::resqml22__IndexableElement::triangles) + const gsoap_eml2_3::eml23__IndexableElement element = valuesProperty->getAttachmentKind(); + if (element == gsoap_eml2_3::eml23__IndexableElement::cells || + element == gsoap_eml2_3::eml23__IndexableElement::triangles) { nbElement = cellCount; } - else if (element == gsoap_eml2_3::resqml22__IndexableElement::nodes) + else if (element == gsoap_eml2_3::eml23__IndexableElement::nodes) { nbElement = pointCount; } @@ -69,8 +69,8 @@ ResqmlPropertyToVtkDataArray::ResqmlPropertyToVtkDataArray(RESQML2_NS::AbstractV vtkOutputWindowDisplayErrorText("does not support vectorial property yet\n"); } - unsigned long long numValuesInEachDimension = cellCount; // cellCount/kCellCount; //3834;//iCellCount*jCellCount*kCellCount; - unsigned long long offsetInEachDimension = iCellCount * jCellCount * initKIndex; // initKIndex;//iCellCount*jCellCount*initKIndex; + const uint64_t numValuesInEachDimension = cellCount; // cellCount/kCellCount; //3834;//iCellCount*jCellCount*kCellCount; + const uint64_t offsetInEachDimension = iCellCount * jCellCount * initKIndex; // initKIndex;//iCellCount*jCellCount*initKIndex; std::string typeProperty = valuesProperty->getXmlTag(); if (typeProperty == RESQML2_NS::ContinuousProperty::XML_TAG) @@ -143,17 +143,17 @@ ResqmlPropertyToVtkDataArray::ResqmlPropertyToVtkDataArray(RESQML2_NS::AbstractV ResqmlPropertyToVtkDataArray::ResqmlPropertyToVtkDataArray(resqml2::AbstractValuesProperty const *valuesProperty, long cellCount, long pointCount, - int patch_index) + int patch_index) { int nbElement = 0; - const gsoap_eml2_3::resqml22__IndexableElement element = valuesProperty->getAttachmentKind(); - if (element == gsoap_eml2_3::resqml22__IndexableElement::cells || - element == gsoap_eml2_3::resqml22__IndexableElement::triangles) + const gsoap_eml2_3::eml23__IndexableElement element = valuesProperty->getAttachmentKind(); + if (element == gsoap_eml2_3::eml23__IndexableElement::cells || + element == gsoap_eml2_3::eml23__IndexableElement::triangles) { nbElement = cellCount; } - else if (element == gsoap_eml2_3::resqml22__IndexableElement::nodes) + else if (element == gsoap_eml2_3::eml23__IndexableElement::nodes) { nbElement = pointCount; } @@ -170,8 +170,7 @@ ResqmlPropertyToVtkDataArray::ResqmlPropertyToVtkDataArray(resqml2::AbstractValu const unsigned int totalHDFElementcount = nbElement * elementCountPerValue; if (totalHDFElementcount != valuesProperty->getValuesCountOfPatch(patch_index)) { - throw std::invalid_argument("Property values count of hdfDataset \"" + std::to_string(valuesProperty->getValuesCountOfPatch(patch_index)) - + "\" does not match the indexable element count in the supporting representation\"" + std::to_string(totalHDFElementcount) + "\""); + throw std::invalid_argument("Property values count of hdfDataset \"" + std::to_string(valuesProperty->getValuesCountOfPatch(patch_index)) + "\" does not match the indexable element count in the supporting representation\"" + std::to_string(totalHDFElementcount) + "\""); } double *valuesDoubleSet = new double[totalHDFElementcount]; // deleted by VTK data vtkSmartPointer @@ -188,7 +187,7 @@ ResqmlPropertyToVtkDataArray::ResqmlPropertyToVtkDataArray(resqml2::AbstractValu static_cast(valuesProperty)->getStringLookup() != nullptr)) { int *values = new int[nbElement * elementCountPerValue]; // deleted by VTK data vtkSmartPointer - valuesProperty->getIntValuesOfPatch(patch_index, values); + valuesProperty->getInt32ValuesOfPatch(patch_index, values); vtkSmartPointer cellDataInt = vtkSmartPointer::New(); cellDataInt->SetNumberOfComponents(elementCountPerValue); diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlPropertyToVtkDataArray.h b/Plugin/Energistics/Mapping/ResqmlPropertyToVtkDataArray.h similarity index 88% rename from Plugin/Energistics/ResqmlMapping/ResqmlPropertyToVtkDataArray.h rename to Plugin/Energistics/Mapping/ResqmlPropertyToVtkDataArray.h index ff212ea..e146ff5 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlPropertyToVtkDataArray.h +++ b/Plugin/Energistics/Mapping/ResqmlPropertyToVtkDataArray.h @@ -39,22 +39,22 @@ class ResqmlPropertyToVtkDataArray /** * Constructor for multi-processor */ - ResqmlPropertyToVtkDataArray(RESQML2_NS::AbstractValuesProperty const *resqmlProperty, - uint32_t cellCount, + ResqmlPropertyToVtkDataArray(const RESQML2_NS::AbstractValuesProperty *resqmlProperty, + uint64_t cellCount, uint64_t pointCount, uint32_t iCellCount, uint32_t jCellCount, uint32_t kCellCount, uint32_t initKIndex, - int patch_index); + int patch_index); /** * Constructor */ ResqmlPropertyToVtkDataArray(RESQML2_NS::AbstractValuesProperty const *resqmlProperty, - long cellCount, - long pointCount, - int patch_index); + long cellCount, + long pointCount, + int patch_index); ~ResqmlPropertyToVtkDataArray() = default; diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.cxx b/Plugin/Energistics/Mapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.cxx similarity index 73% rename from Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.cxx rename to Plugin/Energistics/Mapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.cxx index 7b435d2..fd8e4b4 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.cxx +++ b/Plugin/Energistics/Mapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.cxx @@ -31,24 +31,24 @@ under the License. #include // include F2i-consulting Energistics Paraview Plugin -#include "ResqmlMapping/ResqmlPropertyToVtkDataArray.h" -#include "ResqmlMapping/ResqmlTriangulatedToVtkPolyData.h" +#include "Mapping/ResqmlPropertyToVtkDataArray.h" +#include "Mapping/ResqmlTriangulatedToVtkPolyData.h" //---------------------------------------------------------------------------- -ResqmlTriangulatedSetToVtkPartitionedDataSet::ResqmlTriangulatedSetToVtkPartitionedDataSet(RESQML2_NS::TriangulatedSetRepresentation *triangulated, int proc_number, int max_proc) +ResqmlTriangulatedSetToVtkPartitionedDataSet::ResqmlTriangulatedSetToVtkPartitionedDataSet(const RESQML2_NS::TriangulatedSetRepresentation *triangulated, int p_procNumber, int p_maxProc) : ResqmlAbstractRepresentationToVtkPartitionedDataSet(triangulated, - proc_number, - max_proc) + p_procNumber, + p_maxProc) { - this->vtkData = vtkSmartPointer::New(); - this->pointCount = resqmlData->getXyzPointCountOfAllPatches(); - this->vtkData->Modified(); + _vtkData = vtkSmartPointer::New(); + _pointCount = triangulated->getXyzPointCountOfAllPatches(); + _vtkData->Modified(); } //---------------------------------------------------------------------------- -RESQML2_NS::TriangulatedSetRepresentation * ResqmlTriangulatedSetToVtkPartitionedDataSet::getResqmlData() const +const RESQML2_NS::TriangulatedSetRepresentation *ResqmlTriangulatedSetToVtkPartitionedDataSet::getResqmlData() const { - return static_cast(resqmlData); + return static_cast(_resqmlData); } //---------------------------------------------------------------------------- @@ -56,33 +56,32 @@ void ResqmlTriangulatedSetToVtkPartitionedDataSet::loadVtkObject() { vtkSmartPointer partition = vtkSmartPointer::New(); - RESQML2_NS::TriangulatedSetRepresentation * triangulatedSet = getResqmlData(); + const RESQML2_NS::TriangulatedSetRepresentation *triangulatedSet = getResqmlData(); const unsigned int patchCount = triangulatedSet->getPatchCount(); for (unsigned int patchIndex = 0; patchIndex < patchCount; ++patchIndex) { - auto rep = new ResqmlTriangulatedToVtkPolyData(triangulatedSet, patchIndex, this->procNumber, this->maxProc); + auto rep = new ResqmlTriangulatedToVtkPolyData(triangulatedSet, patchIndex, _procNumber, _maxProc); partition->SetPartition(patchIndex, rep->getOutput()->GetPartitionAsDataObject(0)); partition->GetMetaData(patchIndex)->Set(vtkCompositeDataSet::NAME(), ("Patch " + std::to_string(patchIndex)).c_str()); patchIndex_to_ResqmlTriangulated[patchIndex] = rep; } - this->vtkData = partition; - this->vtkData->Modified(); + _vtkData = partition; + _vtkData->Modified(); } -void ResqmlTriangulatedSetToVtkPartitionedDataSet::addDataArray(const std::string& uuid) +void ResqmlTriangulatedSetToVtkPartitionedDataSet::addDataArray(const std::string &p_uuid) { vtkSmartPointer partition = vtkSmartPointer::New(); - for (auto& map : patchIndex_to_ResqmlTriangulated) + for (auto &map : patchIndex_to_ResqmlTriangulated) { - map.second->addDataArray(uuid, map.first); + map.second->addDataArray(p_uuid, map.first); partition->SetPartition(map.first, map.second->getOutput()->GetPartitionAsDataObject(0)); partition->GetMetaData(map.first)->Set(vtkCompositeDataSet::NAME(), ("Patch " + std::to_string(map.first)).c_str()); } - this->vtkData = partition; - this->vtkData->Modified(); - + _vtkData = partition; + _vtkData->Modified(); } diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.h b/Plugin/Energistics/Mapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.h similarity index 76% rename from Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.h rename to Plugin/Energistics/Mapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.h index 36b951c..cd21d99 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.h +++ b/Plugin/Energistics/Mapping/ResqmlTriangulatedSetToVtkPartitionedDataSet.h @@ -39,23 +39,23 @@ class ResqmlTriangulatedSetToVtkPartitionedDataSet : public ResqmlAbstractRepres { public: /** - * Constructor - */ - explicit ResqmlTriangulatedSetToVtkPartitionedDataSet(RESQML2_NS::TriangulatedSetRepresentation *triangulated, int proc_number = 0, int max_proc = 1); - + * Constructor + */ + explicit ResqmlTriangulatedSetToVtkPartitionedDataSet(const RESQML2_NS::TriangulatedSetRepresentation *triangulated, int p_procNumber = 0, int p_maxProc = 1); + /** - * load vtkDataSet with RESQML data - */ + * load vtkDataSet with RESQML data + */ void loadVtkObject() override; /** * add a RESQML property to vtkDataSet */ - void addDataArray(const std::string& uuid); + void addDataArray(const std::string &p_uuid); protected: - RESQML2_NS::TriangulatedSetRepresentation * getResqmlData() const; + const RESQML2_NS::TriangulatedSetRepresentation *getResqmlData() const; - std::map patchIndex_to_ResqmlTriangulated; // index of VtkDataAssembly to RESQML UUID + std::map patchIndex_to_ResqmlTriangulated; // index of VtkDataAssembly to RESQML UUID }; #endif diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedToVtkPolyData.cxx b/Plugin/Energistics/Mapping/ResqmlTriangulatedToVtkPolyData.cxx similarity index 81% rename from Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedToVtkPolyData.cxx rename to Plugin/Energistics/Mapping/ResqmlTriangulatedToVtkPolyData.cxx index bc7e424..6432fbb 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedToVtkPolyData.cxx +++ b/Plugin/Energistics/Mapping/ResqmlTriangulatedToVtkPolyData.cxx @@ -32,34 +32,34 @@ under the License. #include // include F2i-consulting Energistics Paraview Plugin -#include "ResqmlMapping/ResqmlPropertyToVtkDataArray.h" +#include "Mapping/ResqmlPropertyToVtkDataArray.h" //---------------------------------------------------------------------------- -ResqmlTriangulatedToVtkPolyData::ResqmlTriangulatedToVtkPolyData(RESQML2_NS::TriangulatedSetRepresentation * triangulated, uint32_t patch_index, int proc_number, int max_proc) +ResqmlTriangulatedToVtkPolyData::ResqmlTriangulatedToVtkPolyData(const RESQML2_NS::TriangulatedSetRepresentation *triangulated, uint32_t patch_index, int p_procNumber, int p_maxProc) : ResqmlAbstractRepresentationToVtkPartitionedDataSet(triangulated, - proc_number, - max_proc), + p_procNumber, + p_maxProc), patch_index(patch_index) { - this->pointCount = triangulated->getXyzPointCountOfPatch(patch_index); + _pointCount = triangulated->getXyzPointCountOfPatch(patch_index); - this->vtkData = vtkSmartPointer::New(); + _vtkData = vtkSmartPointer::New(); this->loadVtkObject(); } //---------------------------------------------------------------------------- -RESQML2_NS::TriangulatedSetRepresentation const* ResqmlTriangulatedToVtkPolyData::getResqmlData() const +const RESQML2_NS::TriangulatedSetRepresentation *ResqmlTriangulatedToVtkPolyData::getResqmlData() const { - return static_cast(resqmlData); + return static_cast(_resqmlData); } uint32_t ResqmlTriangulatedToVtkPolyData::getPreviousPatchesNodeCount() const { uint32_t result = 0; - RESQML2_NS::TriangulatedSetRepresentation const* triangulated = getResqmlData(); + RESQML2_NS::TriangulatedSetRepresentation const *triangulated = getResqmlData(); - for (uint_fast32_t previousPatchIndex = 0; previousPatchIndex < patch_index; ++previousPatchIndex) + for (uint_fast32_t previousPatchIndex = 0; previousPatchIndex < patch_index; ++previousPatchIndex) { result += triangulated->getXyzPointCountOfPatch(previousPatchIndex); } @@ -72,14 +72,14 @@ void ResqmlTriangulatedToVtkPolyData::loadVtkObject() { vtkSmartPointer vtk_polydata = vtkSmartPointer::New(); - RESQML2_NS::TriangulatedSetRepresentation const* triangulated = getResqmlData(); + RESQML2_NS::TriangulatedSetRepresentation const *triangulated = getResqmlData(); - double *allXyzPoints = new double[this->pointCount * 3]; // Will be deleted by VTK + double *allXyzPoints = new double[_pointCount * 3]; // Will be deleted by VTK triangulated->getXyzPointsOfPatchInGlobalCrs(this->patch_index, allXyzPoints); vtkSmartPointer vtkPts = vtkSmartPointer::New(); - const size_t coordCount = this->pointCount * 3; + const size_t coordCount = _pointCount * 3; if (triangulated->getLocalCrs(0)->isDepthOriented()) { for (size_t zCoordIndex = 2; zCoordIndex < coordCount; zCoordIndex += 3) @@ -110,6 +110,6 @@ void ResqmlTriangulatedToVtkPolyData::loadVtkObject() } vtk_polydata->SetPolys(triangulatedRepresentationTriangles); - this->vtkData->SetPartition(0, vtk_polydata); - this->vtkData->Modified(); + _vtkData->SetPartition(0, vtk_polydata); + _vtkData->Modified(); } diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedToVtkPolyData.h b/Plugin/Energistics/Mapping/ResqmlTriangulatedToVtkPolyData.h similarity index 76% rename from Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedToVtkPolyData.h rename to Plugin/Energistics/Mapping/ResqmlTriangulatedToVtkPolyData.h index 6351a9c..2235465 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlTriangulatedToVtkPolyData.h +++ b/Plugin/Energistics/Mapping/ResqmlTriangulatedToVtkPolyData.h @@ -25,7 +25,7 @@ under the License. // include system #include -#include "ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" +#include "Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" namespace RESQML2_NS { @@ -36,23 +36,22 @@ class ResqmlTriangulatedToVtkPolyData : public ResqmlAbstractRepresentationToVtk { public: /** - * Constructor - */ - ResqmlTriangulatedToVtkPolyData(RESQML2_NS::TriangulatedSetRepresentation * triangulated, uint32_t patch_index, int proc_number = 0, int max_proc = 1); - + * Constructor + */ + ResqmlTriangulatedToVtkPolyData(const RESQML2_NS::TriangulatedSetRepresentation *triangulated, uint32_t patch_index, int p_procNumber = 0, int p_maxProc = 1); + /** - * load vtkDataSet with RESQML data - */ + * load vtkDataSet with RESQML data + */ void loadVtkObject(); protected: - /** - * Get the node count of all patches which are before than the current patch index - */ + * Get the node count of all patches which are before than the current patch index + */ uint32_t getPreviousPatchesNodeCount() const; - RESQML2_NS::TriangulatedSetRepresentation const* getResqmlData() const; + const RESQML2_NS::TriangulatedSetRepresentation *getResqmlData() const; uint32_t patch_index; }; #endif diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.cxx b/Plugin/Energistics/Mapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.cxx similarity index 83% rename from Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.cxx rename to Plugin/Energistics/Mapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.cxx index 3c7b76c..5a8fdf7 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.cxx +++ b/Plugin/Energistics/Mapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.cxx @@ -16,7 +16,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h" +#include "Mapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h" #include @@ -48,28 +48,28 @@ under the License. #include "ResqmlUnstructuredGridToVtkUnstructuredGrid.h" //---------------------------------------------------------------------------- -ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid(RESQML2_NS::SubRepresentation *subRep, ResqmlUnstructuredGridToVtkUnstructuredGrid *support, int proc_number, int max_proc) +ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid(const RESQML2_NS::SubRepresentation *subRep, ResqmlUnstructuredGridToVtkUnstructuredGrid *support, int p_procNumber, int p_maxProc) : ResqmlAbstractRepresentationToVtkPartitionedDataSet(subRep, - proc_number, - max_proc), + p_procNumber, + p_maxProc), mapperUnstructuredGrid(support) { - this->iCellCount = subRep->getElementCountOfPatch(0); - this->pointCount = subRep->getSupportingRepresentation(0)->getXyzPointCountOfAllPatches(); + _iCellCount = subRep->getElementCountOfPatch(0); + _pointCount = subRep->getSupportingRepresentation(0)->getXyzPointCountOfAllPatches(); - this->vtkData = vtkSmartPointer::New(); + _vtkData = vtkSmartPointer::New(); } //---------------------------------------------------------------------------- -RESQML2_NS::SubRepresentation const* ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::getResqmlData() const +const RESQML2_NS::SubRepresentation *ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::getResqmlData() const { - return static_cast(resqmlData); + return static_cast(_resqmlData); } //---------------------------------------------------------------------------- void ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::loadVtkObject() { - RESQML2_NS::SubRepresentation const* subRep = getResqmlData(); + RESQML2_NS::SubRepresentation const *subRep = getResqmlData(); if (subRep->areElementIndicesPairwise(0)) { @@ -80,8 +80,8 @@ void ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::loadVtkObject() auto *supportingGrid = dynamic_cast(subRep->getSupportingRepresentation(0)); if (supportingGrid != nullptr) { - gsoap_eml2_3::resqml22__IndexableElement indexable_element = subRep->getElementKindOfPatch(0, 0); - if (indexable_element == gsoap_eml2_3::resqml22__IndexableElement::cells) + gsoap_eml2_3::eml23__IndexableElement indexable_element = subRep->getElementKindOfPatch(0, 0); + if (indexable_element == gsoap_eml2_3::eml23__IndexableElement::cells) { vtkSmartPointer vtk_unstructuredGrid = vtkSmartPointer::New(); vtk_unstructuredGrid->Allocate(subRep->getElementCountOfPatch(0)); @@ -98,12 +98,12 @@ void ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::loadVtkObject() : cumulativeFaceCountPerCell[supportingGrid->getCellCount() - 1]]); supportingGrid->getCellFaceIsRightHanded(cellFaceNormalOutwardlyDirected.get()); - auto maxCellIndex = (this->procNumber + 1) * cellCount / this->maxProc; + auto maxCellIndex = (_procNumber + 1) * cellCount / _maxProc; std::unique_ptr elementIndices(new uint64_t[cellCount]); subRep->getElementIndicesOfPatch(0, 0, elementIndices.get()); - for (ULONG64 cellIndex = this->procNumber * cellCount / this->maxProc; cellIndex < maxCellIndex; ++cellIndex) + for (ULONG64 cellIndex = _procNumber * cellCount / _maxProc; cellIndex < maxCellIndex; ++cellIndex) { bool isOptimizedCell = false; @@ -156,10 +156,10 @@ void ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::loadVtkObject() supportingGrid->unloadGeometry(); - this->vtkData->SetPartition(0, vtk_unstructuredGrid); - this->vtkData->Modified(); + _vtkData->SetPartition(0, vtk_unstructuredGrid); + _vtkData->Modified(); } - else if (indexable_element == gsoap_eml2_3::resqml22__IndexableElement::faces) + else if (indexable_element == gsoap_eml2_3::eml23__IndexableElement::faces) { vtkSmartPointer vtk_polydata = vtkSmartPointer::New(); vtk_polydata->SetPoints(this->getMapperVtkPoint()); @@ -168,8 +168,8 @@ void ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::loadVtkObject() const ULONG64 gridFaceCount = supportingGrid->getFaceCount(); std::unique_ptr nodeCountOfFaces(new uint64_t[gridFaceCount]); supportingGrid->getCumulativeNodeCountPerFace(nodeCountOfFaces.get()); - - std::unique_ptr nodeIndices(new uint64_t[nodeCountOfFaces[gridFaceCount-1]]); + + std::unique_ptr nodeIndices(new uint64_t[nodeCountOfFaces[gridFaceCount - 1]]); supportingGrid->getNodeIndicesOfFaces(nodeIndices.get()); const ULONG64 subFaceCount = subRep->getElementCountOfPatch(0); @@ -179,7 +179,7 @@ void ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::loadVtkObject() vtkSmartPointer polys = vtkSmartPointer::New(); polys->AllocateEstimate(subFaceCount, 4); - for (ULONG64 subFaceIndex =0; subFaceIndex < subFaceCount; ++subFaceIndex) + for (ULONG64 subFaceIndex = 0; subFaceIndex < subFaceCount; ++subFaceIndex) { ULONG64 faceIndex = elementIndices[subFaceIndex]; auto first_indiceValue = faceIndex == 0 ? 0 : nodeCountOfFaces[faceIndex - 1]; @@ -195,17 +195,17 @@ void ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::loadVtkObject() vtk_polydata->SetPolys(polys); - this->vtkData->SetPartition(0, vtk_polydata); - this->vtkData->Modified(); + _vtkData->SetPartition(0, vtk_polydata); + _vtkData->Modified(); } else { - vtkOutputWindowDisplayErrorText(("not supported: SubRepresentation (" + subRep->getUuid() + ") with indexable element different from cell or nodes").c_str()); + vtkOutputWindowDisplayWarningText(("not supported: SubRepresentation (" + subRep->getUuid() + ") with indexable element different from cell or nodes").c_str()); } } else { - // TODO msg d'erreur + vtkOutputWindowDisplayWarningText(("SubRepresentation (" + subRep->getUuid() + ") has no suuport grid").c_str()); } } } @@ -223,4 +223,3 @@ vtkSmartPointer ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid::ge this->mapperUnstructuredGrid->registerSubRep(); return this->mapperUnstructuredGrid->getVtkPoints(); } - diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h b/Plugin/Energistics/Mapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h similarity index 83% rename from Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h rename to Plugin/Energistics/Mapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h index 116bd1e..e1a105b 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h +++ b/Plugin/Energistics/Mapping/ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h @@ -22,10 +22,9 @@ under the License. /** @brief transform a resqml unstructured Subrepresentation to vtkUnstructuredGrid */ - #include "ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" - // include VTK +// include VTK #include #include @@ -43,7 +42,7 @@ class ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid : public ResqmlAbstractR /** * Constructor */ - ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid(RESQML2_NS::SubRepresentation *unstructuredGridSubRep, ResqmlUnstructuredGridToVtkUnstructuredGrid *support, int proc_number = 0, int max_proc = 1); + ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid(const RESQML2_NS::SubRepresentation *unstructuredGridSubRep, ResqmlUnstructuredGridToVtkUnstructuredGrid *support, int p_procNumber = 0, int p_maxProc = 1); /** * load vtkDataSet with resqml data @@ -56,12 +55,10 @@ class ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid : public ResqmlAbstractR std::string unregisterToMapperSupportingGrid(); protected: - RESQML2_NS::SubRepresentation const* getResqmlData() const; - ResqmlUnstructuredGridToVtkUnstructuredGrid* mapperUnstructuredGrid; + const RESQML2_NS::SubRepresentation *getResqmlData() const; + ResqmlUnstructuredGridToVtkUnstructuredGrid *mapperUnstructuredGrid; private: - vtkSmartPointer getMapperVtkPoint(); - }; #endif diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.cxx b/Plugin/Energistics/Mapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.cxx similarity index 79% rename from Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.cxx rename to Plugin/Energistics/Mapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.cxx index 0605be4..dc1f46c 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.cxx +++ b/Plugin/Energistics/Mapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.cxx @@ -16,7 +16,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.h" +#include "Mapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.h" // VTK #include @@ -39,60 +39,61 @@ under the License. #include //---------------------------------------------------------------------------- -ResqmlUnstructuredGridToVtkUnstructuredGrid::ResqmlUnstructuredGridToVtkUnstructuredGrid(RESQML2_NS::UnstructuredGridRepresentation *unstructuredGrid, int proc_number, int max_proc) +ResqmlUnstructuredGridToVtkUnstructuredGrid::ResqmlUnstructuredGridToVtkUnstructuredGrid(const RESQML2_NS::UnstructuredGridRepresentation *unstructuredGrid, int p_procNumber, int p_maxProc) : ResqmlAbstractRepresentationToVtkPartitionedDataSet(unstructuredGrid, - proc_number, - max_proc), - points(vtkSmartPointer::New()) + p_procNumber, + p_maxProc), + points(vtkSmartPointer::New()) { - this->pointCount = unstructuredGrid->getXyzPointCountOfAllPatches(); - this->iCellCount = unstructuredGrid->getCellCount(); + _pointCount = unstructuredGrid->getXyzPointCountOfAllPatches(); + _iCellCount = unstructuredGrid->getCellCount(); - this->vtkData = vtkSmartPointer::New(); + _vtkData = vtkSmartPointer::New(); - this->vtkData->Modified(); + _vtkData->Modified(); } //---------------------------------------------------------------------------- -RESQML2_NS::UnstructuredGridRepresentation * ResqmlUnstructuredGridToVtkUnstructuredGrid::getResqmlData() const +const RESQML2_NS::UnstructuredGridRepresentation *ResqmlUnstructuredGridToVtkUnstructuredGrid::getResqmlData() const { - return static_cast(resqmlData); + return static_cast(_resqmlData); } //---------------------------------------------------------------------------- void ResqmlUnstructuredGridToVtkUnstructuredGrid::loadVtkObject() { vtkSmartPointer vtk_unstructuredGrid = vtkSmartPointer::New(); - RESQML2_NS::UnstructuredGridRepresentation * unstructuredGrid = getResqmlData(); + const RESQML2_NS::UnstructuredGridRepresentation *unstructuredGrid = getResqmlData(); vtk_unstructuredGrid->AllocateExact(unstructuredGrid->getCellCount(), unstructuredGrid->getXyzPointCountOfAllPatches()); // POINTS vtk_unstructuredGrid->SetPoints(this->getVtkPoints()); - unstructuredGrid->loadGeometry(); + const_cast(unstructuredGrid)->loadGeometry(); const uint64_t cellCount = unstructuredGrid->getCellCount(); - uint64_t const* cumulativeFaceCountPerCell = unstructuredGrid->isFaceCountOfCellsConstant() - ? nullptr - : unstructuredGrid->getCumulativeFaceCountPerCell(); // This pointer is owned and managed by FESAPI + uint64_t const *cumulativeFaceCountPerCell = unstructuredGrid->isFaceCountOfCellsConstant() + ? nullptr + : unstructuredGrid->getCumulativeFaceCountPerCell(); // This pointer is owned and managed by FESAPI const uint64_t faceCount = cumulativeFaceCountPerCell == nullptr - ? cellCount * unstructuredGrid->getConstantFaceCountOfCells() - : cumulativeFaceCountPerCell[cellCount - 1]; + ? cellCount * unstructuredGrid->getConstantFaceCountOfCells() + : cumulativeFaceCountPerCell[cellCount - 1]; std::unique_ptr cellFaceNormalOutwardlyDirected(new unsigned char[faceCount]); unstructuredGrid->getCellFaceIsRightHanded(cellFaceNormalOutwardlyDirected.get()); - auto* crs = unstructuredGrid->getLocalCrs(0); + auto *crs = unstructuredGrid->getLocalCrs(0); if (!crs->isPartial() && crs->isDepthOriented()) { - for (size_t i = 0; i < faceCount; ++i) { + for (size_t i = 0; i < faceCount; ++i) + { cellFaceNormalOutwardlyDirected[i] = !cellFaceNormalOutwardlyDirected[i]; } } - auto maxCellIndex = (this->procNumber + 1) * cellCount / this->maxProc; + auto maxCellIndex = (_procNumber + 1) * cellCount / _maxProc; - for (uint64_t cellIndex = this->procNumber * cellCount / this->maxProc; cellIndex < maxCellIndex; ++cellIndex) + for (uint64_t cellIndex = _procNumber * cellCount / _maxProc; cellIndex < maxCellIndex; ++cellIndex) { bool isOptimizedCell = false; @@ -143,10 +144,10 @@ void ResqmlUnstructuredGridToVtkUnstructuredGrid::loadVtkObject() } } - unstructuredGrid->unloadGeometry(); + const_cast(unstructuredGrid)->unloadGeometry(); - this->vtkData->SetPartition(0, vtk_unstructuredGrid); - this->vtkData->Modified(); + _vtkData->SetPartition(0, vtk_unstructuredGrid); + _vtkData->Modified(); } //---------------------------------------------------------------------------- vtkSmartPointer ResqmlUnstructuredGridToVtkUnstructuredGrid::getVtkPoints() @@ -161,30 +162,34 @@ vtkSmartPointer ResqmlUnstructuredGridToVtkUnstructuredGrid::getVtkPo //---------------------------------------------------------------------------- void ResqmlUnstructuredGridToVtkUnstructuredGrid::createPoints() { - RESQML2_NS::UnstructuredGridRepresentation * unstructuredGrid = getResqmlData(); + const RESQML2_NS::UnstructuredGridRepresentation *unstructuredGrid = getResqmlData(); // POINTS - double *allXyzPoints = new double[this->pointCount * 3]; // Will be deleted by VTK; + double *allXyzPoints = new double[_pointCount * 3]; // Will be deleted by VTK; bool partialCRS = false; const uint64_t patchCount = unstructuredGrid->getPatchCount(); - for (uint_fast64_t patchIndex = 0; patchIndex < patchCount; ++patchIndex) { - if (unstructuredGrid->getLocalCrs(patchIndex)->isPartial()) { + for (uint_fast64_t patchIndex = 0; patchIndex < patchCount; ++patchIndex) + { + if (unstructuredGrid->getLocalCrs(patchIndex)->isPartial()) + { partialCRS = true; break; } } - if (partialCRS) { + if (partialCRS) + { vtkOutputWindowDisplayWarningText(("At least one of the local CRS of : " + unstructuredGrid->getUuid() + " is partial. Get coordinates in local CRS instead.\n").c_str()); unstructuredGrid->getXyzPointsOfAllPatches(allXyzPoints); } - else { + else + { unstructuredGrid->getXyzPointsOfAllPatchesInGlobalCrs(allXyzPoints); } - const uint64_t coordCount = pointCount * 3; + const uint64_t coordCount =_pointCount * 3; if (!partialCRS && unstructuredGrid->getLocalCrs(0)->isDepthOriented()) { - for (uint_fast64_t zCoordIndex = 2; zCoordIndex < coordCount; zCoordIndex += 3) + for (uint_fast64_t zCoordIndex = 2; zCoordIndex < coordCount; zCoordIndex += 3) { allXyzPoints[zCoordIndex] *= -1; } @@ -201,7 +206,7 @@ void ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkTetra(vtkSmartPointergetNodeIndicesOfFaceOfCell(cellIndex, 0); @@ -238,15 +243,15 @@ void ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkTetra(vtkSmartPointer vtk_unstructuredGrid, - uint64_t const* cumulativeFaceCountPerCell, unsigned char const* cellFaceNormalOutwardlyDirected, - uint64_t cellIndex) + uint64_t const *cumulativeFaceCountPerCell, unsigned char const *cellFaceNormalOutwardlyDirected, + uint64_t cellIndex) { - RESQML2_NS::UnstructuredGridRepresentation const* unstructuredGrid = getResqmlData(); + RESQML2_NS::UnstructuredGridRepresentation const *unstructuredGrid = getResqmlData(); // The global index of the first face of the polyhedron in the cellFaceNormalOutwardlyDirected array const size_t globalFirstFaceIndex = unstructuredGrid->isFaceCountOfCellsConstant() || cellIndex == 0 - ? cellIndex * 5 - : cumulativeFaceCountPerCell[cellIndex - 1]; + ? cellIndex * 5 + : cumulativeFaceCountPerCell[cellIndex - 1]; std::vector localFaceIndexWith4Nodes; for (unsigned int localFaceIndex = 0; localFaceIndex < 5; ++localFaceIndex) @@ -265,7 +270,7 @@ void ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkWedgeOrPyramid(vtkSmart const unsigned int localNodeCount = unstructuredGrid->getNodeCountOfFaceOfCell(cellIndex, triangleIndex); if (localNodeCount == 3) { - uint64_t const* nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, triangleIndex); + uint64_t const *nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, triangleIndex); if (cellFaceNormalOutwardlyDirected[globalFirstFaceIndex + triangleIndex] == 0) { for (size_t i = 0; i < 3; ++i) @@ -291,25 +296,33 @@ void ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkWedgeOrPyramid(vtkSmart const unsigned int localNodeCount = unstructuredGrid->getNodeCountOfFaceOfCell(cellIndex, localFaceIndex); if (localNodeCount == 4) { - uint64_t const* nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, localFaceIndex); - if (nodeIndices[0] == nodes[0]) { + uint64_t const *nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, localFaceIndex); + if (nodeIndices[0] == nodes[0]) + { nodes[3] = nodeIndices[1] == nodes[1] || nodeIndices[1] == nodes[2] - ? nodeIndices[3] : nodeIndices[1]; + ? nodeIndices[3] + : nodeIndices[1]; break; } - else if (nodeIndices[1] == nodes[0]) { + else if (nodeIndices[1] == nodes[0]) + { nodes[3] = nodeIndices[2] == nodes[1] || nodeIndices[2] == nodes[2] - ? nodeIndices[0] : nodeIndices[2]; + ? nodeIndices[0] + : nodeIndices[2]; break; } - else if (nodeIndices[2] == nodes[0]) { + else if (nodeIndices[2] == nodes[0]) + { nodes[3] = nodeIndices[3] == nodes[1] || nodeIndices[3] == nodes[2] - ? nodeIndices[1] : nodeIndices[3]; + ? nodeIndices[1] + : nodeIndices[3]; break; } - else if (nodeIndices[3] == nodes[0]) { + else if (nodeIndices[3] == nodes[0]) + { nodes[3] = nodeIndices[0] == nodes[1] || nodeIndices[0] == nodes[2] - ? nodeIndices[2] : nodeIndices[0]; + ? nodeIndices[2] + : nodeIndices[0]; break; } } @@ -320,7 +333,7 @@ void ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkWedgeOrPyramid(vtkSmart const unsigned int localNodeCount = unstructuredGrid->getNodeCountOfFaceOfCell(cellIndex, triangleIndex); if (localNodeCount == 3) { - uint64_t const* nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, triangleIndex); + uint64_t const *nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, triangleIndex); if (nodeIndices[0] == nodes[3]) { if (cellFaceNormalOutwardlyDirected[globalFirstFaceIndex + triangleIndex] == 0) @@ -368,11 +381,11 @@ void ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkWedgeOrPyramid(vtkSmart } else if (localFaceIndexWith4Nodes.size() == 1) { // VTK_PYRAMID - uint64_t const* nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, localFaceIndexWith4Nodes[0]); + uint64_t const *nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, localFaceIndexWith4Nodes[0]); size_t cellFaceIndex = (unstructuredGrid->isFaceCountOfCellsConstant() || cellIndex == 0 - ? cellIndex * 5 - : cumulativeFaceCountPerCell[cellIndex - 1]) + - localFaceIndexWith4Nodes[0]; + ? cellIndex * 5 + : cumulativeFaceCountPerCell[cellIndex - 1]) + + localFaceIndexWith4Nodes[0]; if (cellFaceNormalOutwardlyDirected[cellFaceIndex] == 0) { // The RESQML orientation of the face honors the VTK orientation of face 0 i.e. the face 0 normal defined using a right hand rule is inwardly directed. nodes[0] = nodeIndices[0]; @@ -410,10 +423,10 @@ void ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkWedgeOrPyramid(vtkSmart //---------------------------------------------------------------------------- bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkHexahedron(vtkSmartPointer vtk_unstructuredGrid, - uint64_t const *cumulativeFaceCountPerCell, unsigned char const *cellFaceNormalOutwardlyDirected, - uint64_t cellIndex) + uint64_t const *cumulativeFaceCountPerCell, unsigned char const *cellFaceNormalOutwardlyDirected, + uint64_t cellIndex) { - RESQML2_NS::UnstructuredGridRepresentation const* unstructuredGrid = getResqmlData(); + RESQML2_NS::UnstructuredGridRepresentation const *unstructuredGrid = getResqmlData(); for (unsigned int localFaceIndex = 0; localFaceIndex < 6; ++localFaceIndex) { @@ -448,8 +461,8 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkHexahedron(vtkSmartPoin { nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, localFaceIndex); for (size_t index = 0; index < 4; ++index) - { // Loop on face nodes - vtkIdType* itr = std::find(nodes.data(), nodes.data() + 4, nodeIndices[index]); // Locate a node on face 0 + { // Loop on face nodes + vtkIdType *itr = std::find(nodes.data(), nodes.data() + 4, nodeIndices[index]); // Locate a node on face 0 if (itr != nodes.data() + 4) { // A top neighbor node can be found @@ -458,8 +471,8 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkHexahedron(vtkSmartPoin { const size_t previousIndex = index == 0 ? 3 : index - 1; nodes[topNeigborIdx + 4] = std::find(nodes.data(), nodes.data() + 4, nodeIndices[previousIndex]) != nodes.data() + 4 // If previous index is also in face 0 - ? nodeIndices[index == 3 ? 0 : index + 1] // Put next index - : nodeIndices[previousIndex]; // Put previous index + ? nodeIndices[index == 3 ? 0 : index + 1] // Put next index + : nodeIndices[previousIndex]; // Put previous index alreadyTreated[topNeigborIdx] = true; } } @@ -472,9 +485,9 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkHexahedron(vtkSmartPoin //---------------------------------------------------------------------------- bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkPentagonalPrism(vtkSmartPointer vtk_unstructuredGrid, - uint64_t const *cumulativeFaceCountPerCell, unsigned char const *cellFaceNormalOutwardlyDirected, uint64_t cellIndex) + uint64_t const *cumulativeFaceCountPerCell, unsigned char const *cellFaceNormalOutwardlyDirected, uint64_t cellIndex) { - RESQML2_NS::UnstructuredGridRepresentation const* unstructuredGrid = getResqmlData(); + RESQML2_NS::UnstructuredGridRepresentation const *unstructuredGrid = getResqmlData(); // Found the base 5 nodes face for (uint32_t localFaceIndex = 0; localFaceIndex < 7; ++localFaceIndex) @@ -483,8 +496,9 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkPentagonalPrism(vtkSmar if (localNodeCount == 5) { const size_t cellFaceIndex = (unstructuredGrid->isFaceCountOfCellsConstant() || cellIndex == 0 - ? cellIndex * 7 - : cumulativeFaceCountPerCell[cellIndex - 1]) + localFaceIndex; + ? cellIndex * 7 + : cumulativeFaceCountPerCell[cellIndex - 1]) + + localFaceIndex; uint64_t const *nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, localFaceIndex); if (cellFaceNormalOutwardlyDirected[cellFaceIndex] == 0) @@ -502,7 +516,7 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkPentagonalPrism(vtkSmar // Find the other nodes from the 4 nodes faces uint_fast8_t faceWith5Nodes = 0; uint_fast8_t faceWith4Nodes = 0; - std::array alreadyTreated = { false, false, false, false, false }; + std::array alreadyTreated = {false, false, false, false, false}; for (uint32_t localFaceIndex = 0; localFaceIndex < 7; ++localFaceIndex) { const uint64_t localNodeCount = unstructuredGrid->getNodeCountOfFaceOfCell(cellIndex, localFaceIndex); @@ -511,7 +525,7 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkPentagonalPrism(vtkSmar uint64_t const *nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, localFaceIndex); for (size_t index = 0; index < 4; ++index) // Loop on face nodes { - vtkIdType* itr = std::find(nodes.data(), nodes.data() + 5, nodeIndices[index]); // Locate a node on base face + vtkIdType *itr = std::find(nodes.data(), nodes.data() + 5, nodeIndices[index]); // Locate a node on base face if (itr != nodes.data() + 5) { // A top neighbor node can be found @@ -520,15 +534,16 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkPentagonalPrism(vtkSmar { const size_t previousIndex = index == 0 ? 3 : index - 1; nodes[topNeigborIdx + 5] = std::find(nodes.data(), nodes.data() + 5, nodeIndices[previousIndex]) != nodes.data() + 5 // If previous index is also in face 0 - ? nodeIndices[index == 3 ? 0 : index + 1] // Put next index - : nodeIndices[previousIndex]; // Put previous index + ? nodeIndices[index == 3 ? 0 : index + 1] // Put next index + : nodeIndices[previousIndex]; // Put previous index alreadyTreated[topNeigborIdx] = true; } } } ++faceWith4Nodes; } - else if (localNodeCount == 5) { + else if (localNodeCount == 5) + { ++faceWith5Nodes; } } @@ -543,9 +558,9 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkPentagonalPrism(vtkSmar //---------------------------------------------------------------------------- bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkHexagonalPrism(vtkSmartPointer vtk_unstructuredGrid, - uint64_t const *cumulativeFaceCountPerCell, unsigned char const *cellFaceNormalOutwardlyDirected, uint64_t cellIndex) + uint64_t const *cumulativeFaceCountPerCell, unsigned char const *cellFaceNormalOutwardlyDirected, uint64_t cellIndex) { - RESQML2_NS::UnstructuredGridRepresentation * unstructuredGrid = getResqmlData(); + const RESQML2_NS::UnstructuredGridRepresentation *unstructuredGrid = getResqmlData(); // Found the base 5 nodes face for (uint32_t localFaceIndex = 0; localFaceIndex < 8; ++localFaceIndex) @@ -554,8 +569,9 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkHexagonalPrism(vtkSmart if (localNodeCount == 6) { const size_t cellFaceIndex = (unstructuredGrid->isFaceCountOfCellsConstant() || cellIndex == 0 - ? cellIndex * 7 - : cumulativeFaceCountPerCell[cellIndex - 1]) + localFaceIndex; + ? cellIndex * 7 + : cumulativeFaceCountPerCell[cellIndex - 1]) + + localFaceIndex; uint64_t const *nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, localFaceIndex); if (cellFaceNormalOutwardlyDirected[cellFaceIndex] == 0) @@ -573,7 +589,7 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkHexagonalPrism(vtkSmart // Find the other nodes from the 4 nodes faces uint_fast8_t faceWith6Nodes = 0; uint_fast8_t faceWith4Nodes = 0; - std::array alreadyTreated = { false, false, false, false, false, false }; + std::array alreadyTreated = {false, false, false, false, false, false}; for (uint32_t localFaceIndex = 0; localFaceIndex < 8; ++localFaceIndex) { const uint64_t localNodeCount = unstructuredGrid->getNodeCountOfFaceOfCell(cellIndex, localFaceIndex); @@ -582,7 +598,7 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkHexagonalPrism(vtkSmart uint64_t const *nodeIndices = unstructuredGrid->getNodeIndicesOfFaceOfCell(cellIndex, localFaceIndex); for (size_t index = 0; index < 4; ++index) // Loop on face nodes { - vtkIdType* itr = std::find(nodes.data(), nodes.data() + 6, nodeIndices[index]); // Locate a node on base face + vtkIdType *itr = std::find(nodes.data(), nodes.data() + 6, nodeIndices[index]); // Locate a node on base face if (itr != nodes.data() + 6) { // A top neighbor node can be found @@ -591,15 +607,16 @@ bool ResqmlUnstructuredGridToVtkUnstructuredGrid::cellVtkHexagonalPrism(vtkSmart { const size_t previousIndex = index == 0 ? 3 : index - 1; nodes[topNeigborIdx + 6] = std::find(nodes.data(), nodes.data() + 6, nodeIndices[previousIndex]) != nodes.data() + 6 // If previous index is also in face 0 - ? nodeIndices[index == 3 ? 0 : index + 1] // Put next index - : nodeIndices[previousIndex]; // Put previous index + ? nodeIndices[index == 3 ? 0 : index + 1] // Put next index + : nodeIndices[previousIndex]; // Put previous index alreadyTreated[topNeigborIdx] = true; } } } ++faceWith4Nodes; } - else if (localNodeCount == 6) { + else if (localNodeCount == 6) + { ++faceWith6Nodes; } } diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.h b/Plugin/Energistics/Mapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.h similarity index 77% rename from Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.h rename to Plugin/Energistics/Mapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.h index 4aa4e01..2095be9 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.h +++ b/Plugin/Energistics/Mapping/ResqmlUnstructuredGridToVtkUnstructuredGrid.h @@ -39,7 +39,7 @@ class ResqmlUnstructuredGridToVtkUnstructuredGrid : public ResqmlAbstractReprese /** * Constructor */ - explicit ResqmlUnstructuredGridToVtkUnstructuredGrid(RESQML2_NS::UnstructuredGridRepresentation *unstructuredGrid, int proc_number = 0, int max_proc = 1); + explicit ResqmlUnstructuredGridToVtkUnstructuredGrid(const RESQML2_NS::UnstructuredGridRepresentation *unstructuredGrid, int p_procNumber = 0, int p_maxProc = 1); /** * load vtkDataSet with resqml data @@ -51,9 +51,8 @@ class ResqmlUnstructuredGridToVtkUnstructuredGrid : public ResqmlAbstractReprese */ void createPoints(); - protected: - RESQML2_NS::UnstructuredGridRepresentation * getResqmlData() const; + const RESQML2_NS::UnstructuredGridRepresentation *getResqmlData() const; vtkSmartPointer points; // Index of the nodes constituting a single VTK optimized cell // The VTK HEXAGONALN PRISM is the VTK optimized cell containing the maximum number of nodes which is 12 as the size of this array. @@ -61,8 +60,8 @@ class ResqmlUnstructuredGridToVtkUnstructuredGrid : public ResqmlAbstractReprese private: /** - * Return The vtkPoints - */ + * Return The vtkPoints + */ vtkSmartPointer getVtkPoints(); /** @@ -74,21 +73,21 @@ class ResqmlUnstructuredGridToVtkUnstructuredGrid : public ResqmlAbstractReprese * @param cellIndex The index of the RESQML cell in the RESQML UnstructuredGridRepresentation to be mapped and inserted in the VTK UnstructuredGrid. */ void cellVtkTetra(vtkSmartPointer vtk_unstructuredGrid, - uint64_t const *cumulativeFaceCountPerCell, - unsigned char const *cellFaceNormalOutwardlyDirected, - uint64_t cellIndex); + uint64_t const *cumulativeFaceCountPerCell, + unsigned char const *cellFaceNormalOutwardlyDirected, + uint64_t cellIndex); /** - * Insert a new VTK wedge or pyramid corresponding to a particular RESQML cell - * - * @param unstructuredGridRep The RESQML UnstructuredGridRepresentation which contains the cell to map and to insert in the VTK UnstructuredGrid - * @param cumulativeFaceCountPerCell The cumulative count of faces for each cell of the RESQML UnstructuredGridRepresentation. - * @param cellFaceNormalOutwardlyDirected Indicates for each cell face of the RESQML UnstructuredGridRepresentation if its normal using the right hand rule is outwardly directed. - * @param cellIndex The index of the RESQML cell in the RESQML UnstructuredGridRepresentation to be mapped and inserted in the VTK UnstructuredGrid. - */ + * Insert a new VTK wedge or pyramid corresponding to a particular RESQML cell + * + * @param unstructuredGridRep The RESQML UnstructuredGridRepresentation which contains the cell to map and to insert in the VTK UnstructuredGrid + * @param cumulativeFaceCountPerCell The cumulative count of faces for each cell of the RESQML UnstructuredGridRepresentation. + * @param cellFaceNormalOutwardlyDirected Indicates for each cell face of the RESQML UnstructuredGridRepresentation if its normal using the right hand rule is outwardly directed. + * @param cellIndex The index of the RESQML cell in the RESQML UnstructuredGridRepresentation to be mapped and inserted in the VTK UnstructuredGrid. + */ void cellVtkWedgeOrPyramid(vtkSmartPointer vtk_unstructuredGrid, - uint64_t const* cumulativeFaceCountPerCell, unsigned char const* cellFaceNormalOutwardlyDirected, - uint64_t cellIndex); + uint64_t const *cumulativeFaceCountPerCell, unsigned char const *cellFaceNormalOutwardlyDirected, + uint64_t cellIndex); /** * Insert a new VTK hexahedron corresponding to a particular RESQML cell only if the RESQML cell is Quadrilaterally-faced hexahedron. @@ -101,9 +100,9 @@ class ResqmlUnstructuredGridToVtkUnstructuredGrid : public ResqmlAbstractReprese * @return true if the hexahedron is a Quadrilaterally-faced one, false otherwise */ bool cellVtkHexahedron(vtkSmartPointer vtk_unstructuredGrid, - uint64_t const *cumulativeFaceCountPerCell, - unsigned char const *cellFaceNormalOutwardlyDirected, - uint64_t cellIndex); + uint64_t const *cumulativeFaceCountPerCell, + unsigned char const *cellFaceNormalOutwardlyDirected, + uint64_t cellIndex); /** * Insert a new VTK_PENTAGONAL_PRISM corresponding to a particular RESQML cell only if the RESQML cell contains two faces with 5 nodes. @@ -116,9 +115,9 @@ class ResqmlUnstructuredGridToVtkUnstructuredGrid : public ResqmlAbstractReprese * @return true if the RESQML cell contains two faces with 5 nodes, false otherwise */ bool cellVtkPentagonalPrism(vtkSmartPointer vtk_unstructuredGrid, - uint64_t const *cumulativeFaceCountPerCell, - unsigned char const *cellFaceNormalOutwardlyDirected, - uint64_t cellIndex); + uint64_t const *cumulativeFaceCountPerCell, + unsigned char const *cellFaceNormalOutwardlyDirected, + uint64_t cellIndex); /** * Insert a new VTK_HEXAGONAL_PRISM corresponding to a particular RESQML cell only if the RESQML cell contains two faces with 5 nodes. @@ -131,9 +130,9 @@ class ResqmlUnstructuredGridToVtkUnstructuredGrid : public ResqmlAbstractReprese * @return true if the RESQML cell contains two faces with 5 nodes, false otherwise */ bool cellVtkHexagonalPrism(vtkSmartPointer vtk_unstructuredGrid, - uint64_t const *cumulativeFaceCountPerCell, - unsigned char const *cellFaceNormalOutwardlyDirected, - uint64_t cellIndex); + uint64_t const *cumulativeFaceCountPerCell, + unsigned char const *cellFaceNormalOutwardlyDirected, + uint64_t cellIndex); friend class ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid; }; diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreChannelToVtkPolyData.cxx b/Plugin/Energistics/Mapping/ResqmlWellboreChannelToVtkPolyData.cxx similarity index 68% rename from Plugin/Energistics/ResqmlMapping/ResqmlWellboreChannelToVtkPolyData.cxx rename to Plugin/Energistics/Mapping/ResqmlWellboreChannelToVtkPolyData.cxx index 4a731f0..a6e0399 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreChannelToVtkPolyData.cxx +++ b/Plugin/Energistics/Mapping/ResqmlWellboreChannelToVtkPolyData.cxx @@ -22,6 +22,7 @@ under the License. #include #include #include +#include #include #include @@ -31,37 +32,39 @@ under the License. #include //---------------------------------------------------------------------------- -ResqmlWellboreChannelToVtkPolyData::ResqmlWellboreChannelToVtkPolyData(RESQML2_NS::WellboreFrameRepresentation *frame, RESQML2_NS::AbstractValuesProperty *property, const std::string &uuid, int proc_number, int max_proc) +ResqmlWellboreChannelToVtkPolyData::ResqmlWellboreChannelToVtkPolyData(const RESQML2_NS::WellboreFrameRepresentation *frame, const RESQML2_NS::AbstractValuesProperty *property, const std::string &p_uuid, int p_procNumber, int p_maxProc) : ResqmlAbstractRepresentationToVtkPartitionedDataSet(frame, - proc_number, - max_proc), + p_procNumber, + p_maxProc), abstractProperty(property), uuid(uuid), title(property->getTitle()) { - this->vtkData = vtkSmartPointer::New(); - this->loadVtkObject(); - this->vtkData->Modified(); + _vtkData = vtkSmartPointer::New(); + _vtkData->Modified(); + + setUuid(property->getUuid()); + setTitle("Channel_"+property->getTitle()); } //---------------------------------------------------------------------------- -RESQML2_NS::WellboreFrameRepresentation const* ResqmlWellboreChannelToVtkPolyData::getResqmlData() const +const RESQML2_NS::WellboreFrameRepresentation *ResqmlWellboreChannelToVtkPolyData::getResqmlData() const { - return static_cast(resqmlData); + return static_cast(_resqmlData); } //---------------------------------------------------------------------------- void ResqmlWellboreChannelToVtkPolyData::loadVtkObject() { - RESQML2_NS::WellboreFrameRepresentation const* frame = getResqmlData(); + RESQML2_NS::WellboreFrameRepresentation const *frame = getResqmlData(); // We need to build first a polyline for the channel to support the vtk tube. - this->pointCount = frame->getXyzPointCountOfPatch(0); - double *allXyzPoints = new double[this->pointCount * 3]; // Will be deleted by VTK + _pointCount = frame->getXyzPointCountOfPatch(0); + double *allXyzPoints = new double[_pointCount * 3]; // Will be deleted by VTK frame->getXyzPointsOfAllPatchesInGlobalCrs(allXyzPoints); vtkSmartPointer vtkPts = vtkSmartPointer::New(); - const size_t coordCount = pointCount * 3; + const size_t coordCount =_pointCount * 3; if (frame->getLocalCrs(0)->isDepthOriented()) { for (size_t zCoordIndex = 2; zCoordIndex < coordCount; zCoordIndex += 3) @@ -77,8 +80,8 @@ void ResqmlWellboreChannelToVtkPolyData::loadVtkObject() vtkPts->SetData(vtkUnderlyingArray); auto lines = vtkSmartPointer::New(); - lines->InsertNextCell(pointCount); - for (unsigned int i = 0; i < pointCount; ++i) + lines->InsertNextCell(_pointCount); + for (unsigned int i = 0; i < _pointCount; ++i) { lines->InsertCellPoint(i); } @@ -90,21 +93,21 @@ void ResqmlWellboreChannelToVtkPolyData::loadVtkObject() // Varying tube radius auto tubeRadius = vtkSmartPointer::New(); tubeRadius->SetName(this->abstractProperty->getTitle().c_str()); - tubeRadius->SetNumberOfTuples(pointCount); - if (dynamic_cast(this->abstractProperty) != nullptr) + tubeRadius->SetNumberOfTuples(_pointCount); + if (dynamic_cast(this->abstractProperty) != nullptr) { - std::unique_ptr values(new double[pointCount]); + std::unique_ptr values(new double[_pointCount]); this->abstractProperty->getDoubleValuesOfPatch(0, values.get()); - for (unsigned int i = 0; i < pointCount; ++i) + for (unsigned int i = 0; i < _pointCount; ++i) { tubeRadius->SetTuple1(i, values[i]); } } - else if (dynamic_cast(this->abstractProperty) != nullptr || dynamic_cast(this->abstractProperty) != nullptr) + else if (dynamic_cast(this->abstractProperty) != nullptr || dynamic_cast(this->abstractProperty) != nullptr) { - std::unique_ptr values(new int[pointCount]); - this->abstractProperty->getIntValuesOfPatch(0, values.get()); - for (unsigned int i = 0; i < pointCount; ++i) + std::unique_ptr values(new int[_pointCount]); + this->abstractProperty->getInt32ValuesOfPatch(0, values.get()); + for (unsigned int i = 0; i < _pointCount; ++i) { tubeRadius->SetTuple1(i, values[i]); } @@ -126,6 +129,7 @@ void ResqmlWellboreChannelToVtkPolyData::loadVtkObject() tubeFilter->SetVaryRadiusToVaryRadiusByScalar(); tubeFilter->Update(); - this->vtkData->SetPartition(0, tubeFilter->GetOutput()); - this->vtkData->Modified(); + _vtkData->SetPartition(0, tubeFilter->GetOutput()); + _vtkData->GetMetaData((unsigned int)0)->Set(vtkCompositeDataSet::NAME(), (const char*)(title+"("+uuid + ")").c_str()); + _vtkData->Modified(); } diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreChannelToVtkPolyData.h b/Plugin/Energistics/Mapping/ResqmlWellboreChannelToVtkPolyData.h similarity index 78% rename from Plugin/Energistics/ResqmlMapping/ResqmlWellboreChannelToVtkPolyData.h rename to Plugin/Energistics/Mapping/ResqmlWellboreChannelToVtkPolyData.h index 0863b34..2bde39f 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreChannelToVtkPolyData.h +++ b/Plugin/Energistics/Mapping/ResqmlWellboreChannelToVtkPolyData.h @@ -19,7 +19,7 @@ under the License. #ifndef __ResqmlWellboreChannelToVtkPolyData_H_ #define __ResqmlWellboreChannelToVtkPolyData__H_ -#include "ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" +#include "Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" namespace RESQML2_NS { @@ -33,7 +33,7 @@ class ResqmlWellboreChannelToVtkPolyData : public ResqmlAbstractRepresentationTo /** * Constructor */ - ResqmlWellboreChannelToVtkPolyData(RESQML2_NS::WellboreFrameRepresentation *frame, RESQML2_NS::AbstractValuesProperty *property, const std::string &uuid, int proc_number = 0, int max_proc = 1); + ResqmlWellboreChannelToVtkPolyData(const RESQML2_NS::WellboreFrameRepresentation *frame, const RESQML2_NS::AbstractValuesProperty *property, const std::string &p_uuid, int p_procNumber = 0, int p_maxProc = 1); /** * load vtkDataSet with resqml data @@ -44,10 +44,10 @@ class ResqmlWellboreChannelToVtkPolyData : public ResqmlAbstractRepresentationTo std::string getTitle() const { return this->title; } protected: - RESQML2_NS::WellboreFrameRepresentation const* getResqmlData() const; + const RESQML2_NS::WellboreFrameRepresentation *getResqmlData() const; private: - RESQML2_NS::AbstractValuesProperty *abstractProperty; + const RESQML2_NS::AbstractValuesProperty *abstractProperty; std::string uuid; std::string title; diff --git a/Plugin/Energistics/Mapping/ResqmlWellboreFrameToVtkPartitionedDataSet.cxx b/Plugin/Energistics/Mapping/ResqmlWellboreFrameToVtkPartitionedDataSet.cxx new file mode 100644 index 0000000..961d2ef --- /dev/null +++ b/Plugin/Energistics/Mapping/ResqmlWellboreFrameToVtkPartitionedDataSet.cxx @@ -0,0 +1,44 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#include "Mapping/ResqmlWellboreFrameToVtkPartitionedDataSet.h" + +#include + +#include + +#include +#include + +// include F2i-consulting Energistics Paraview Plugin +#include "Mapping/ResqmlWellboreChannelToVtkPolyData.h" + +//---------------------------------------------------------------------------- +ResqmlWellboreFrameToVtkPartitionedDataSet::ResqmlWellboreFrameToVtkPartitionedDataSet(const resqml2::WellboreFrameRepresentation *p_frame, int p_procNumber, int p_maxProc) + : CommonAbstractObjectSetToVtkPartitionedDataSetSet(p_frame, + p_procNumber, + p_maxProc) +{ +} + +//---------------------------------------------------------------------------- +void ResqmlWellboreFrameToVtkPartitionedDataSet::addChannel(const std::string& p_uuid, resqml2::AbstractValuesProperty* p_property) +{ + const resqml2::WellboreFrameRepresentation* w_wellFrame = dynamic_cast(_resqmlData); + _mapperSet.push_back(new ResqmlWellboreChannelToVtkPolyData(w_wellFrame, p_property, p_uuid)); +} \ No newline at end of file diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreFrameToVtkPartitionedDataSet.h b/Plugin/Energistics/Mapping/ResqmlWellboreFrameToVtkPartitionedDataSet.h similarity index 60% rename from Plugin/Energistics/ResqmlMapping/ResqmlWellboreFrameToVtkPartitionedDataSet.h rename to Plugin/Energistics/Mapping/ResqmlWellboreFrameToVtkPartitionedDataSet.h index 5c50519..cde4f22 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreFrameToVtkPartitionedDataSet.h +++ b/Plugin/Energistics/Mapping/ResqmlWellboreFrameToVtkPartitionedDataSet.h @@ -19,7 +19,7 @@ under the License. #ifndef __ResqmlWellboreFrameToVtkPartitionedDataSet_H_ #define __ResqmlWellboreFrameToVtkPartitionedDataSet_H_ -#include "ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" +#include "Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.h" namespace RESQML2_NS { @@ -27,28 +27,14 @@ namespace RESQML2_NS class AbstractValuesProperty; } -class ResqmlWellboreChannelToVtkPolyData; - -class ResqmlWellboreFrameToVtkPartitionedDataSet : public ResqmlAbstractRepresentationToVtkPartitionedDataSet +class ResqmlWellboreFrameToVtkPartitionedDataSet : public CommonAbstractObjectSetToVtkPartitionedDataSetSet { public: /** * Constructor */ - explicit ResqmlWellboreFrameToVtkPartitionedDataSet(RESQML2_NS::WellboreFrameRepresentation *frame, int proc_number = 0, int max_proc = 1); - - /** - * load vtkDataSet with resqml data - */ - void loadVtkObject() override; - - void addChannel(const std::string &channel_uuid, RESQML2_NS::AbstractValuesProperty *property); - void removeChannel(const std::string &channel_uuid); - -protected: - RESQML2_NS::WellboreFrameRepresentation * getResqmlData() const; + ResqmlWellboreFrameToVtkPartitionedDataSet(const RESQML2_NS::WellboreFrameRepresentation *frame, int p_procNumber = 0, int p_maxProc = 1); -private: - std::vector list_channel; + void addChannel(const std::string& uuid, RESQML2_NS::AbstractValuesProperty* property); }; #endif diff --git a/Plugin/Energistics/Mapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.cxx b/Plugin/Energistics/Mapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.cxx new file mode 100644 index 0000000..651d638 --- /dev/null +++ b/Plugin/Energistics/Mapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.cxx @@ -0,0 +1,65 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#include "Mapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h" + +#include +#include + +// include VTK library +#include + +#include +#include +#include + +#include "Mapping/ResqmlWellboreMarkerToVtkPolyData.h" + +//---------------------------------------------------------------------------- +ResqmlWellboreMarkerFrameToVtkPartitionedDataSet::ResqmlWellboreMarkerFrameToVtkPartitionedDataSet(const RESQML2_NS::WellboreMarkerFrameRepresentation* p_markerFrame, int p_procNumber, int p_maxProc) + : CommonAbstractObjectSetToVtkPartitionedDataSetSet(p_markerFrame, + p_procNumber, + p_maxProc) +{ +} + +//---------------------------------------------------------------------------- +void ResqmlWellboreMarkerFrameToVtkPartitionedDataSet::addMarker(const RESQML2_NS::WellboreMarkerFrameRepresentation* p_marker, const std::string & p_uuid, bool p_orientation, int p_size) +{ + _mapperSet.push_back(new ResqmlWellboreMarkerToVtkPolyData(p_marker, p_uuid, p_orientation, p_size)); +} + +void ResqmlWellboreMarkerFrameToVtkPartitionedDataSet::changeOrientationAndSize(const std::string& p_uuid, bool p_orientation, int p_size) +{ + + for (auto* mapper : _mapperSet) + { + + if (mapper->getUuid() == p_uuid) + { + ResqmlWellboreMarkerToVtkPolyData* marker = static_cast(mapper); + if (marker->getMarkerOrientation() != p_orientation || + marker->getMarkerSize() != p_size) + { + marker->setMarkerOrientation(p_orientation); + marker->setMarkerSize(p_size); + marker->loadVtkObject(); + } + } + } +} \ No newline at end of file diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h b/Plugin/Energistics/Mapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h similarity index 67% rename from Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h rename to Plugin/Energistics/Mapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h index d76e007..f813ed5 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h +++ b/Plugin/Energistics/Mapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h @@ -19,8 +19,7 @@ under the License. #ifndef _ResqmlWellboreMarkerFrameToVtkPartitionedDataSet_H_ #define _ResqmlWellboreMarkerFrameToVtkPartitionedDataSet_H_ -#include "ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" -#include "ResqmlWellboreMarkerToVtkPolyData.h" +#include "Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.h" #include @@ -32,29 +31,20 @@ namespace RESQML2_NS class ResqmlWellboreMarkerToVtkPolyData; -class ResqmlWellboreMarkerFrameToVtkPartitionedDataSet : public ResqmlAbstractRepresentationToVtkPartitionedDataSet +class ResqmlWellboreMarkerFrameToVtkPartitionedDataSet : public CommonAbstractObjectSetToVtkPartitionedDataSetSet { public: /** * Constructor */ - explicit ResqmlWellboreMarkerFrameToVtkPartitionedDataSet(RESQML2_NS::WellboreMarkerFrameRepresentation *marker, int proc_number = 0, int max_proc = 1); + explicit ResqmlWellboreMarkerFrameToVtkPartitionedDataSet(const RESQML2_NS::WellboreMarkerFrameRepresentation *marker, int p_procNumber = 0, int p_maxProc = 1); - /** - * load vtkDataSet with resqml data - */ - void loadVtkObject() override; + void addMarker(const RESQML2_NS::WellboreMarkerFrameRepresentation* marker, const std::string & p_uuid, bool orientation, int size); - void addMarker(std::string marker_uuid, bool orientation, int size); - void removeMarker(std::string marker_uuid); - -protected: - resqml2::WellboreMarkerFrameRepresentation * getResqmlData() const; + void changeOrientationAndSize(const std::string& p_uuid, bool orientation, int size); private: bool orientation; int size; - - std::vector list_marker; }; #endif diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerToVtkPolyData.cxx b/Plugin/Energistics/Mapping/ResqmlWellboreMarkerToVtkPolyData.cxx similarity index 56% rename from Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerToVtkPolyData.cxx rename to Plugin/Energistics/Mapping/ResqmlWellboreMarkerToVtkPolyData.cxx index 3eae37e..42bf41d 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerToVtkPolyData.cxx +++ b/Plugin/Energistics/Mapping/ResqmlWellboreMarkerToVtkPolyData.cxx @@ -16,7 +16,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlWellboreMarkerToVtkPolyData.h" +#include "Mapping/ResqmlWellboreMarkerToVtkPolyData.h" #include @@ -33,106 +33,93 @@ under the License. #include //---------------------------------------------------------------------------- -ResqmlWellboreMarkerToVtkPolyData::ResqmlWellboreMarkerToVtkPolyData(RESQML2_NS::WellboreMarkerFrameRepresentation *marker_frame, std::string uuid, bool orientation, int size, int proc_number, int max_proc) - : ResqmlAbstractRepresentationToVtkPartitionedDataSet(marker_frame, - proc_number, - max_proc), - orientation(orientation), - size(size), - uuid(uuid), - title("") +ResqmlWellboreMarkerToVtkPolyData::ResqmlWellboreMarkerToVtkPolyData(const resqml2::WellboreMarkerFrameRepresentation *p_markerFrame, std::string p_uuid, bool p_orientation, int p_size, int p_procNumber, int p_maxProc) + : ResqmlAbstractRepresentationToVtkPartitionedDataSet(p_markerFrame, + p_procNumber, + p_maxProc), + _orientation(p_orientation), + _size(p_size) { - this->vtkData = vtkSmartPointer::New(); - this->loadVtkObject(); - this->vtkData->Modified(); + _vtkData = vtkSmartPointer::New(); + _vtkData->Modified(); + + setUuid(p_uuid); } //---------------------------------------------------------------------------- -RESQML2_NS::WellboreMarkerFrameRepresentation const* ResqmlWellboreMarkerToVtkPolyData::getResqmlData() const +const RESQML2_NS::WellboreMarkerFrameRepresentation *ResqmlWellboreMarkerToVtkPolyData::getResqmlData() const { - return static_cast(resqmlData); + return static_cast(_resqmlData); } //---------------------------------------------------------------------------- void ResqmlWellboreMarkerToVtkPolyData::loadVtkObject() { - RESQML2_NS::WellboreMarkerFrameRepresentation const* marker_frame = getResqmlData(); - - std::vector markerSet = marker_frame->getWellboreMarkerSet(); + std::vector w_markerSet = getResqmlData()->getWellboreMarkerSet(); // search Marker - for (unsigned int mIndex = 0; mIndex < markerSet.size(); ++mIndex) + for (unsigned int w_mIndex = 0; w_mIndex < w_markerSet.size(); ++w_mIndex) { - if (markerSet[mIndex]->getUuid() == this->uuid) + if (w_markerSet[w_mIndex]->getUuid() == getUuid()) { - this->title = markerSet[mIndex]->getTitle(); - std::unique_ptr doublePositions(new double[marker_frame->getMdValuesCount() * 3]); - marker_frame->getXyzPointsOfPatch(0, doublePositions.get()); + setTitle("Marker_"+ w_markerSet[w_mIndex]->getTitle()); + std::unique_ptr w_doublePositions(new double[getResqmlData()->getMdValuesCount() * 3]); + getResqmlData()->getXyzPointsOfPatch(0, w_doublePositions.get()); - if (orientation) + if (_orientation) { - if (!std::isnan(doublePositions[3 * mIndex]) && - !std::isnan(doublePositions[3 * mIndex + 1]) && - !std::isnan(doublePositions[3 * mIndex + 2])) + if (!std::isnan(w_doublePositions[3 * w_mIndex]) && + !std::isnan(w_doublePositions[3 * w_mIndex + 1]) && + !std::isnan(w_doublePositions[3 * w_mIndex + 2])) { // no NaN Value - if (markerSet[mIndex]->hasDipAngle() && - markerSet[mIndex]->hasDipDirection()) + if (w_markerSet[w_mIndex]->hasDipAngle() && + w_markerSet[w_mIndex]->hasDipDirection()) { // dips & direction exist - createDisk(mIndex); + createDisk(w_mIndex); } else { - createSphere(mIndex); + createSphere(w_mIndex); } } } else { - createSphere(mIndex); + createSphere(w_mIndex); } } } } -//---------------------------------------------------------------------------- -void ResqmlWellboreMarkerToVtkPolyData::displayOption(bool orientation, int size) -{ - this->orientation = orientation; - this->size = size; - this->vtkData = vtkSmartPointer::New(); - this->loadVtkObject(); -} - namespace { - double convertToDegree(double value, gsoap_eml2_1::eml21__PlaneAngleUom uom) + double convertToDegree(double value, gsoap_eml2_3::eml23__PlaneAngleUom uom) { switch (uom) { - // case gsoap_eml2_1::eml21__PlaneAngleUom::0_x002e001_x0020seca: - case gsoap_eml2_1::eml21__PlaneAngleUom::ccgr: - case gsoap_eml2_1::eml21__PlaneAngleUom::cgr: + case gsoap_eml2_3::eml23__PlaneAngleUom::ccgr: + case gsoap_eml2_3::eml23__PlaneAngleUom::cgr: break; - case gsoap_eml2_1::eml21__PlaneAngleUom::dega: + case gsoap_eml2_3::eml23__PlaneAngleUom::dega: return value; - case gsoap_eml2_1::eml21__PlaneAngleUom::gon: + case gsoap_eml2_3::eml23__PlaneAngleUom::gon: return value * 0.9; - case gsoap_eml2_1::eml21__PlaneAngleUom::krad: + case gsoap_eml2_3::eml23__PlaneAngleUom::krad: return value * 1e3 * 180 / vtkMath::Pi(); - case gsoap_eml2_1::eml21__PlaneAngleUom::mila: + case gsoap_eml2_3::eml23__PlaneAngleUom::mila: return value * 0.0573; - case gsoap_eml2_1::eml21__PlaneAngleUom::mina: + case gsoap_eml2_3::eml23__PlaneAngleUom::mina: return value * 0.01666667; - case gsoap_eml2_1::eml21__PlaneAngleUom::Mrad: + case gsoap_eml2_3::eml23__PlaneAngleUom::Mrad: return value * 1e6 * 180 / vtkMath::Pi(); - case gsoap_eml2_1::eml21__PlaneAngleUom::mrad: + case gsoap_eml2_3::eml23__PlaneAngleUom::mrad: return value * 1e-3 * 180 / vtkMath::Pi(); - case gsoap_eml2_1::eml21__PlaneAngleUom::rad: + case gsoap_eml2_3::eml23__PlaneAngleUom::rad: return value * 180 / vtkMath::Pi(); - case gsoap_eml2_1::eml21__PlaneAngleUom::rev: + case gsoap_eml2_3::eml23__PlaneAngleUom::rev: return value * 360; - case gsoap_eml2_1::eml21__PlaneAngleUom::seca: + case gsoap_eml2_3::eml23__PlaneAngleUom::seca: return value * 0.0002777778; - case gsoap_eml2_1::eml21__PlaneAngleUom::urad: + case gsoap_eml2_3::eml23__PlaneAngleUom::urad: return value * 1e-6 * 180 / vtkMath::Pi(); } @@ -144,21 +131,19 @@ namespace //---------------------------------------------------------------------------- void ResqmlWellboreMarkerToVtkPolyData::createDisk(unsigned int markerIndex) { - RESQML2_NS::WellboreMarkerFrameRepresentation const* marker_frame = getResqmlData(); - - std::unique_ptr doublePositions(new double[marker_frame->getMdValuesCount() * 3]); - marker_frame->getXyzPointsOfPatch(0, doublePositions.get()); + std::unique_ptr doublePositions(new double[getResqmlData()->getMdValuesCount() * 3]); + getResqmlData()->getXyzPointsOfPatch(0, doublePositions.get()); // initialize a disk vtkSmartPointer diskSource = vtkSmartPointer::New(); diskSource->SetInnerRadius(0); - diskSource->SetOuterRadius(this->size); + diskSource->SetOuterRadius(_size); diskSource->Update(); vtkSmartPointer vtkPolydata = diskSource->GetOutput(); // get markerSet - std::vector markerSet = marker_frame->getWellboreMarkerSet(); + std::vector markerSet = getResqmlData()->getWellboreMarkerSet(); // disk orientation with dipAngle & dip Direction vtkSmartPointer rotation = vtkSmartPointer::New(); @@ -175,7 +160,7 @@ void ResqmlWellboreMarkerToVtkPolyData::createDisk(unsigned int markerIndex) vtkPolydata = transformFilter->GetOutput(); // disk translation with marker position - const double zIndice = marker_frame->getLocalCrs(0)->isDepthOriented() ? -1 : 1; + const double zIndice = getResqmlData()->getLocalCrs(0)->isDepthOriented() ? -1 : 1; vtkSmartPointer translation = vtkSmartPointer::New(); translation->Translate(doublePositions[3 * markerIndex], doublePositions[3 * markerIndex + 1], zIndice * doublePositions[3 * markerIndex + 2]); @@ -184,25 +169,23 @@ void ResqmlWellboreMarkerToVtkPolyData::createDisk(unsigned int markerIndex) transformFilter->SetTransform(translation); transformFilter->Update(); - this->vtkData->SetPartition(0, transformFilter->GetOutput()); + _vtkData->SetPartition(0, transformFilter->GetOutput()); } //---------------------------------------------------------------------------- void ResqmlWellboreMarkerToVtkPolyData::createSphere(unsigned int markerIndex) { - RESQML2_NS::WellboreMarkerFrameRepresentation const* marker_frame = getResqmlData(); - - std::unique_ptr doublePositions(new double[marker_frame->getMdValuesCount() * 3]); - marker_frame->getXyzPointsOfPatch(0, doublePositions.get()); + std::unique_ptr doublePositions(new double[getResqmlData()->getMdValuesCount() * 3]); + getResqmlData()->getXyzPointsOfPatch(0, doublePositions.get()); // get markerSet - const double zIndice = marker_frame->getLocalCrs(0)->isDepthOriented() ? -1 : 1; + const double zIndice = getResqmlData()->getLocalCrs(0)->isDepthOriented() ? -1 : 1; // create sphere vtkSmartPointer sphereSource = vtkSmartPointer::New(); sphereSource->SetCenter(doublePositions[3 * markerIndex], doublePositions[3 * markerIndex + 1], zIndice * doublePositions[3 * markerIndex + 2]); - sphereSource->SetRadius(size); + sphereSource->SetRadius(_size); sphereSource->Update(); - this->vtkData->SetPartition(0, sphereSource->GetOutput()); + _vtkData->SetPartition(0, sphereSource->GetOutput()); } diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerToVtkPolyData.h b/Plugin/Energistics/Mapping/ResqmlWellboreMarkerToVtkPolyData.h similarity index 64% rename from Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerToVtkPolyData.h rename to Plugin/Energistics/Mapping/ResqmlWellboreMarkerToVtkPolyData.h index 41e0741..4c08ac8 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerToVtkPolyData.h +++ b/Plugin/Energistics/Mapping/ResqmlWellboreMarkerToVtkPolyData.h @@ -19,7 +19,7 @@ under the License. #ifndef _ResqmlWellboreMarkerToVtkPolyData_H_ #define _ResqmlWellboreMarkerToVtkPolyData_H_ -#include "ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" +#include "Mapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" #include @@ -34,40 +34,27 @@ class ResqmlWellboreMarkerToVtkPolyData : public ResqmlAbstractRepresentationToV /** * Constructor */ - ResqmlWellboreMarkerToVtkPolyData(RESQML2_NS::WellboreMarkerFrameRepresentation *marker, std::string uuid, bool orientation, int size, int proc_number = 0, int max_proc = 1); + ResqmlWellboreMarkerToVtkPolyData(const RESQML2_NS::WellboreMarkerFrameRepresentation *p_marker, std::string p_uuid, bool p_orientation, int p_size, int p_procNumber = 0, int p_maxProc = 1); /** * load vtkDataSet with resqml data */ void loadVtkObject() override; - /** - * @brief modify orientation & size + representation reload - * - * @param orientation - * @param size - */ - void displayOption(bool orientation, int size); + bool getMarkerOrientation() { return _orientation; } + int getMarkerSize() { return _size; } - /** - * get uuid for verify - */ - std::string getUuid() { return this->uuid; } - std::string getTitle() { return this->title; } - bool getMarkerOrientation() { return this->orientation; } - int getMarkerSize() { return this->size; } + void setMarkerOrientation(bool p_orientation) { _orientation = p_orientation; } + void setMarkerSize(int p_size) { _size = p_size; } protected: - resqml2::WellboreMarkerFrameRepresentation const* getResqmlData() const; + const resqml2::WellboreMarkerFrameRepresentation *getResqmlData() const; private: void createDisk(unsigned int markerIndex); void createSphere(unsigned int markerIndex); - bool orientation; - int size; - - std::string uuid; - std::string title; + bool _orientation; + int _size; }; #endif diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreTrajectoryToVtkPolyData.cxx b/Plugin/Energistics/Mapping/ResqmlWellboreTrajectoryToVtkPolyData.cxx similarity index 77% rename from Plugin/Energistics/ResqmlMapping/ResqmlWellboreTrajectoryToVtkPolyData.cxx rename to Plugin/Energistics/Mapping/ResqmlWellboreTrajectoryToVtkPolyData.cxx index 0f90dea..7173389 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreTrajectoryToVtkPolyData.cxx +++ b/Plugin/Energistics/Mapping/ResqmlWellboreTrajectoryToVtkPolyData.cxx @@ -16,7 +16,7 @@ KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlWellboreTrajectoryToVtkPolyData.h" +#include "Mapping/ResqmlWellboreTrajectoryToVtkPolyData.h" // include VTK library #include @@ -31,22 +31,22 @@ under the License. #include //---------------------------------------------------------------------------- -ResqmlWellboreTrajectoryToVtkPolyData::ResqmlWellboreTrajectoryToVtkPolyData(resqml2::WellboreTrajectoryRepresentation *wellbore, int proc_number, int max_proc) +ResqmlWellboreTrajectoryToVtkPolyData::ResqmlWellboreTrajectoryToVtkPolyData(const resqml2::WellboreTrajectoryRepresentation *wellbore, int p_procNumber, int p_maxProc) : ResqmlAbstractRepresentationToVtkPartitionedDataSet(wellbore, - proc_number, - max_proc) + p_procNumber, + p_maxProc) { - this->pointCount = wellbore->getXyzPointCountOfPatch(0); + _pointCount = wellbore->getXyzPointCountOfPatch(0); - this->vtkData = vtkSmartPointer::New(); + _vtkData = vtkSmartPointer::New(); - this->vtkData->Modified(); + _vtkData->Modified(); } //---------------------------------------------------------------------------- -RESQML2_NS::WellboreTrajectoryRepresentation const* ResqmlWellboreTrajectoryToVtkPolyData::getResqmlData() const +const RESQML2_NS::WellboreTrajectoryRepresentation *ResqmlWellboreTrajectoryToVtkPolyData::getResqmlData() const { - return static_cast(resqmlData); + return static_cast(_resqmlData); } //---------------------------------------------------------------------------- @@ -56,14 +56,14 @@ void ResqmlWellboreTrajectoryToVtkPolyData::loadVtkObject() { // GEOMETRY vtkSmartPointer vtk_polydata = vtkSmartPointer::New(); - RESQML2_NS::WellboreTrajectoryRepresentation const* wellbore = getResqmlData(); + RESQML2_NS::WellboreTrajectoryRepresentation const *wellbore = getResqmlData(); // POINT - double *allXyzPoints = new double[pointCount * 3]; // Will be deleted by VTK + double *allXyzPoints = new double[_pointCount * 3]; // Will be deleted by VTK wellbore->getXyzPointsOfAllPatchesInGlobalCrs(allXyzPoints); vtkSmartPointer vtkPts = vtkSmartPointer::New(); - const size_t coordCount = pointCount * 3; + const size_t coordCount =_pointCount * 3; if (wellbore->getLocalCrs(0)->isDepthOriented()) { for (size_t zCoordIndex = 2; zCoordIndex < coordCount; zCoordIndex += 3) @@ -81,8 +81,8 @@ void ResqmlWellboreTrajectoryToVtkPolyData::loadVtkObject() // POLYLINE vtkSmartPointer polylineRepresentation = vtkSmartPointer::New(); - polylineRepresentation->GetPointIds()->SetNumberOfIds(pointCount); - for (unsigned int nodeIndex = 0; nodeIndex < pointCount; ++nodeIndex) + polylineRepresentation->GetPointIds()->SetNumberOfIds(_pointCount); + for (unsigned int nodeIndex = 0; nodeIndex < _pointCount; ++nodeIndex) { polylineRepresentation->GetPointIds()->SetId(nodeIndex, nodeIndex); } @@ -92,8 +92,8 @@ void ResqmlWellboreTrajectoryToVtkPolyData::loadVtkObject() vtk_polydata->SetLines(setPolylineRepresentationLines); - this->vtkData->SetPartition(0, vtk_polydata); - this->vtkData->Modified(); + _vtkData->SetPartition(0, vtk_polydata); + _vtkData->Modified(); } catch (const std::exception &) { diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreTrajectoryToVtkPolyData.h b/Plugin/Energistics/Mapping/ResqmlWellboreTrajectoryToVtkPolyData.h similarity index 82% rename from Plugin/Energistics/ResqmlMapping/ResqmlWellboreTrajectoryToVtkPolyData.h rename to Plugin/Energistics/Mapping/ResqmlWellboreTrajectoryToVtkPolyData.h index 3bfb039..2ffde1c 100644 --- a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreTrajectoryToVtkPolyData.h +++ b/Plugin/Energistics/Mapping/ResqmlWellboreTrajectoryToVtkPolyData.h @@ -30,18 +30,17 @@ class ResqmlWellboreTrajectoryToVtkPolyData : public ResqmlAbstractRepresentatio { public: /** - * Constructor - */ - explicit ResqmlWellboreTrajectoryToVtkPolyData(resqml2::WellboreTrajectoryRepresentation *wellbore, int proc_number = 0, int max_proc = 1); - + * Constructor + */ + explicit ResqmlWellboreTrajectoryToVtkPolyData(const resqml2::WellboreTrajectoryRepresentation *wellbore, int p_procNumber = 0, int p_maxProc = 1); + /** - * load vtkDataSet with resqml data - */ + * load vtkDataSet with resqml data + */ void loadVtkObject() override; - protected: - resqml2::WellboreTrajectoryRepresentation const* getResqmlData() const; + const resqml2::WellboreTrajectoryRepresentation *getResqmlData() const; private: }; diff --git a/Plugin/Energistics/Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.cxx b/Plugin/Energistics/Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.cxx new file mode 100644 index 0000000..11b76a0 --- /dev/null +++ b/Plugin/Energistics/Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.cxx @@ -0,0 +1,205 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#include "Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +WitsmlWellboreCompletionPerforationToVtkPolyData::WitsmlWellboreCompletionPerforationToVtkPolyData(const resqml2::WellboreTrajectoryRepresentation *wellboreTrajectory, const WITSML2_1_NS::WellboreCompletion *wellboreCompletion, const std::string &connectionuid, const std::string &title, const double skin, int p_procNumber, int p_maxProc) + : CommonAbstractObjectToVtkPartitionedDataSet(wellboreCompletion, + p_procNumber, + p_maxProc), + wellboreCompletion(wellboreCompletion), + wellboreTrajectory(wellboreTrajectory), + title(title), + connectionuid(connectionuid), + skin(skin) +{ + // Check that the completion is valid. + if (wellboreCompletion == nullptr) + { + vtkOutputWindowDisplayErrorText("Cannot compute the XYZ points of the frame without a valid wellbore completion."); + return; + } + + // Iterate over the perforations. + for (uint64_t perforationIndex = 0; perforationIndex < wellboreCompletion->getConnectionCount(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION); ++perforationIndex) + { + if (connectionuid == wellboreCompletion->getConnectionUid(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, perforationIndex)) + { + this->index = perforationIndex; + } + } + + _vtkData = vtkSmartPointer::New(); + _vtkData->Modified(); + + setUuid(connectionuid); + setTitle(title); + + // this->loadVtkObject(); +} + +void WitsmlWellboreCompletionPerforationToVtkPolyData::loadVtkObject() +{ + + // Check that the trajectory is valid. + if (this->wellboreTrajectory == nullptr) + { + vtkOutputWindowDisplayErrorText("Cannot compute the XYZ points of the frame without a valid wellbore trajectory."); + return; + } + + // Check that the completion is valid. + if (this->wellboreCompletion == nullptr) + { + vtkOutputWindowDisplayErrorText("Cannot compute the XYZ points of the frame without a valid wellbore completion."); + return; + } + + // Get the MD datum. + auto mdDatum = this->wellboreTrajectory->getMdDatum(); + if (mdDatum == nullptr || mdDatum->isPartial()) + { + vtkOutputWindowDisplayErrorText("Cannot compute the XYZ points of the frame without the MD datum."); + return; + } + + // Check that the wellbore completion has any perforations. + if (this->wellboreCompletion->getConnectionCount(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION) == 0) + { + vtkOutputWindowDisplayErrorText("There are no perforations on the wellbore completion."); + return; + } + + // Check that the perforation has an MD interval. + if (!this->wellboreCompletion->hasConnectionMdInterval(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, this->index)) + { + return; + } + + // Get the MD values for the top and bottom of the perforation. + const double top = this->wellboreCompletion->getConnectionTopMd(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, this->index); + const double base = this->wellboreCompletion->getConnectionBaseMd(WITSML2_1_NS::WellboreCompletion::WellReservoirConnectionType::PERFORATION, this->index); + + // Convert the MD values to XYZ values. + std::array mdTrajValues = {top, base}; + std::array xyzTrajValues; + this->wellboreTrajectory->convertMdValuesToXyzValues(mdTrajValues.data(), mdTrajValues.size(), xyzTrajValues.data()); + + // Get the MD and XYZ values for all the patches in the wellbore trajectory. + const uint64_t w_pointCount = this->wellboreTrajectory->getXyzPointCountOfAllPatches(); // std::vector mdValues(wellboreTrajectory->getXyzPointCountOfAllPatches()); + std::unique_ptr mdValues(new double[w_pointCount]); + this->wellboreTrajectory->getMdValues(mdValues.get()); + + std::unique_ptr xyzPoints(new double[w_pointCount * 3]); + this->wellboreTrajectory->getXyzPointsOfAllPatchesInGlobalCrs(xyzPoints.get()); + + // Create a list of intermediate MD points. + std::vector> intermediateMdPoints; + for (size_t i = 0; i < w_pointCount; ++i) + { + if (top <= mdValues[i] && mdValues[i] <= base) + { + intermediateMdPoints.push_back({{xyzPoints[i * 3], xyzPoints[i * 3 + 1], xyzPoints[i * 3 + 2]}}); + } + } + + const double depthOriented = wellboreTrajectory->getLocalCrs(0)->isDepthOriented() ? -1 : 1; + // Create a vtkPoints object. + vtkSmartPointer vtkPts = vtkSmartPointer::New(); + + // Add the top point. + vtkPts->InsertNextPoint(xyzTrajValues[0], xyzTrajValues[1], xyzTrajValues[2] * depthOriented); + + // Add the intermediate points. + for (auto const &point : intermediateMdPoints) + { + vtkPts->InsertNextPoint(point[0], point[1], point[2] * depthOriented); + } + + // Add the base point. + vtkPts->InsertNextPoint(xyzTrajValues[3], xyzTrajValues[4], xyzTrajValues[5] * depthOriented); + + // Create a vtkCellArray object. + vtkSmartPointer lines = vtkSmartPointer::New(); + lines->InsertNextCell(2 + intermediateMdPoints.size()); + for (size_t i = 0; i < 2 + intermediateMdPoints.size(); ++i) + { + lines->InsertCellPoint(i); + } + + // Create a vtkPolyData object for the perforation. + vtkSmartPointer perforationPolyData = vtkSmartPointer::New(); + perforationPolyData->SetPoints(vtkPts); + perforationPolyData->SetLines(lines); + + // Create a vtkTubeFilter object. + vtkSmartPointer tubeFilter = vtkSmartPointer::New(); + tubeFilter->SetInputData(perforationPolyData); + tubeFilter->SetNumberOfSides(10); + tubeFilter->SetRadius(10); + tubeFilter->SetVaryRadiusToVaryRadiusByScalar(); + tubeFilter->Update(); + + // Add the perforationPolyData to the vector. + _vtkData->SetPartition(0, tubeFilter->GetOutput()); + _vtkData->GetMetaData((unsigned int)0)->Set(vtkCompositeDataSet::NAME(), (const char *)(this->connectionuid + "_" + this->title).c_str()); + _vtkData->Modified(); + + this->addSkin(); +} + +void WitsmlWellboreCompletionPerforationToVtkPolyData::addSkin() +{ + + vtkSmartPointer array = vtkSmartPointer::New(); + array->SetName("Skin"); + array->InsertNextValue(this->skin); + + _vtkData->GetPartition(0)->GetFieldData()->AddArray(array); +} diff --git a/Plugin/Energistics/Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.h b/Plugin/Energistics/Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.h new file mode 100644 index 0000000..e19ef2e --- /dev/null +++ b/Plugin/Energistics/Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.h @@ -0,0 +1,55 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#ifndef __WitsmlWellboreCompletionPerforationToVtkPolyData_H_ +#define __WitsmlWellboreCompletionPerforationToVtkPolyData_H_ + +#include + +#include "Mapping/CommonAbstractObjectToVtkPartitionedDataSet.h" + +#include + +class WitsmlWellboreCompletionPerforationToVtkPolyData : public CommonAbstractObjectToVtkPartitionedDataSet +{ +public: + /** + * Constructor + */ + WitsmlWellboreCompletionPerforationToVtkPolyData(const resqml2::WellboreTrajectoryRepresentation *wellboreTrajectory, const WITSML2_1_NS::WellboreCompletion *WellboreCompletion, const std::string &connectionuid, const std::string &title, const double skin, const int p_procNumber = 0, int p_maxProc = 1); + + /** + * load vtkDataSet with resqml data + */ + void loadVtkObject(); + + std::string getTitle() const { return title; } + std::string getConnectionuid() const { return connectionuid; } + +private: + void addSkin(); + +protected: + const WITSML2_1_NS::WellboreCompletion *wellboreCompletion; + const resqml2::WellboreTrajectoryRepresentation *wellboreTrajectory; + std::string title; + std::string connectionuid; + double skin; + uint64_t index; +}; +#endif diff --git a/Plugin/Energistics/Mapping/WitsmlWellboreCompletionToVtkPartitionedDataSet.cxx b/Plugin/Energistics/Mapping/WitsmlWellboreCompletionToVtkPartitionedDataSet.cxx new file mode 100644 index 0000000..fe19552 --- /dev/null +++ b/Plugin/Energistics/Mapping/WitsmlWellboreCompletionToVtkPartitionedDataSet.cxx @@ -0,0 +1,54 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#include "Mapping/WitsmlWellboreCompletionToVtkPartitionedDataSet.h" + +#include + +#include + +#include +#include +#include +#include +#include + +#include "Mapping/WitsmlWellboreCompletionPerforationToVtkPolyData.h" + +//---------------------------------------------------------------------------- +WitsmlWellboreCompletionToVtkPartitionedDataSet::WitsmlWellboreCompletionToVtkPartitionedDataSet(const WITSML2_1_NS::WellboreCompletion *p_completion, int p_procNumber, int p_maxProc) + : CommonAbstractObjectSetToVtkPartitionedDataSetSet(p_completion, + p_procNumber, + p_maxProc) +{ + for (auto *interpretation : p_completion->getWellbore()->getResqmlWellboreFeature(0)->getInterpretationSet()) + { + if (dynamic_cast(interpretation) != nullptr) + { + auto *wellbore_interpretation = static_cast(interpretation); + _wellboreTrajectory = wellbore_interpretation->getWellboreTrajectoryRepresentation(0); + continue; + } + } +} + +void WitsmlWellboreCompletionToVtkPartitionedDataSet::addPerforation(const std::string &p_connectionuid, const std::string &p_name, const double p_skin) +{ + const WITSML2_1_NS::WellboreCompletion *w_wellCompletion = dynamic_cast(_resqmlData); + _mapperSet.push_back(new WitsmlWellboreCompletionPerforationToVtkPolyData(_wellboreTrajectory, w_wellCompletion, p_connectionuid, p_name, p_skin)); +} diff --git a/Plugin/Energistics/Mapping/WitsmlWellboreCompletionToVtkPartitionedDataSet.h b/Plugin/Energistics/Mapping/WitsmlWellboreCompletionToVtkPartitionedDataSet.h new file mode 100644 index 0000000..055605d --- /dev/null +++ b/Plugin/Energistics/Mapping/WitsmlWellboreCompletionToVtkPartitionedDataSet.h @@ -0,0 +1,50 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ +#ifndef __WitsmlWellboreCompletionToVtkPartitionedDataSet_H_ +#define __WitsmlWellboreCompletionToVtkPartitionedDataSet_H_ + +#include + +#include "Mapping/CommonAbstractObjectSetToVtkPartitionedDataSetSet.h" + +namespace WITSML2_1_NS +{ + class WellboreCompletion; +} + +namespace resqml +{ + class WellboreTrajectoryRepresentation; +} + +class WitsmlWellboreCompletionToVtkPartitionedDataSet : public CommonAbstractObjectSetToVtkPartitionedDataSetSet +{ +public: + /** + * Constructor + */ + WitsmlWellboreCompletionToVtkPartitionedDataSet(const WITSML2_1_NS::WellboreCompletion *p_completion, int p_procNumber = 0, int p_maxProc = 1); + + void addPerforation(const std::string &p_connectionuid, const std::string &p_name, const double p_skin); + +protected: + const resqml2::WellboreTrajectoryRepresentation *_wellboreTrajectory; + +}; +#endif diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.cxx b/Plugin/Energistics/ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.cxx deleted file mode 100644 index e503399..0000000 --- a/Plugin/Energistics/ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.cxx +++ /dev/null @@ -1,141 +0,0 @@ -/*----------------------------------------------------------------------- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"; you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ------------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlAbstractRepresentationToVtkPartitionedDataSet.h" - -#include -#include - -// include VTK library -#include -#include -#include - -// FESAPI -#include -#include - -// include F2i-consulting Energistics Paraview Plugin -#include "ResqmlMapping/ResqmlPropertyToVtkDataArray.h" - -//---------------------------------------------------------------------------- -ResqmlAbstractRepresentationToVtkPartitionedDataSet::ResqmlAbstractRepresentationToVtkPartitionedDataSet(RESQML2_NS::AbstractRepresentation *abstract_representation, int proc_number, int max_proc): - subrep_pointer_on_points_count(0), - procNumber(proc_number), - maxProc(max_proc), - resqmlData(abstract_representation), - vtkData(nullptr), - uuidToVtkDataArray() -{ -} - -void ResqmlAbstractRepresentationToVtkPartitionedDataSet::addDataArray(const std::string &uuid, int patch_index) -{ - std::vector valuesPropertySet = this->getResqmlData()->getValuesPropertySet(); - std::vector::iterator it = std::find_if(valuesPropertySet.begin(), valuesPropertySet.end(), - [&uuid](RESQML2_NS::AbstractValuesProperty const *property) - { return property->getUuid() == uuid; }); - if (it != std::end(valuesPropertySet)) - { - auto const* const resqmlProp = *it; - ResqmlPropertyToVtkDataArray* fesppProperty = isHyperslabed - ? new ResqmlPropertyToVtkDataArray(resqmlProp, - this->iCellCount * this->jCellCount * (this->maxKIndex - this->initKIndex), - this->pointCount, - this->iCellCount, - this->jCellCount, - this->maxKIndex - this->initKIndex, - this->initKIndex, - patch_index) - : new ResqmlPropertyToVtkDataArray(resqmlProp, - this->iCellCount * this->jCellCount * this->kCellCount, - this->pointCount, - patch_index); - switch (resqmlProp->getAttachmentKind()) - { - case gsoap_eml2_3::resqml22__IndexableElement::cells: - case gsoap_eml2_3::resqml22__IndexableElement::triangles: - this->vtkData->GetPartition(0)->GetCellData()->AddArray(fesppProperty->getVtkData()); - break; - case gsoap_eml2_3::resqml22__IndexableElement::nodes: - this->vtkData->GetPartition(0)->GetPointData()->AddArray(fesppProperty->getVtkData()); - break; - default: - throw std::invalid_argument("The property " + uuid + " is attached on a non supported topological element i.e. not cell, not point."); - } - uuidToVtkDataArray[uuid] = fesppProperty; - this->vtkData->Modified(); - } - else - { - throw std::invalid_argument("The property " + uuid + "cannot be added since it is not contained in the representation " + this->getResqmlData()->getUuid()); - } -} - -void ResqmlAbstractRepresentationToVtkPartitionedDataSet::deleteDataArray(const std::string &uuid) -{ - ResqmlPropertyToVtkDataArray* vtkDataArray = uuidToVtkDataArray[uuid]; - if (vtkDataArray != nullptr) - { - char* dataArrayName = vtkDataArray->getVtkData()->GetName(); - if (vtkData->GetPartition(0)->GetCellData()->HasArray(dataArrayName)) { - vtkData->GetPartition(0)->GetCellData()->RemoveArray(dataArrayName); - } - if (vtkData->GetPartition(0)->GetPointData()->HasArray(dataArrayName)) { - vtkData->GetPartition(0)->GetPointData()->RemoveArray(dataArrayName); - } - - // Cleaning - delete vtkDataArray; - uuidToVtkDataArray.erase(uuid); - } - else - { - throw std::invalid_argument("The property " + uuid + "cannot be deleted from representation " + this->getResqmlData()->getUuid() + " since it has never been added"); - } -} - -void ResqmlAbstractRepresentationToVtkPartitionedDataSet::unloadVtkObject() -{ - this->vtkData = vtkSmartPointer::New(); -} - -void ResqmlAbstractRepresentationToVtkPartitionedDataSet::registerSubRep() -{ - ++subrep_pointer_on_points_count; -} - -void ResqmlAbstractRepresentationToVtkPartitionedDataSet::unregisterSubRep() -{ - --subrep_pointer_on_points_count; -} - -unsigned int ResqmlAbstractRepresentationToVtkPartitionedDataSet::subRepLinkedCount() -{ - return subrep_pointer_on_points_count; -} - -std::string ResqmlAbstractRepresentationToVtkPartitionedDataSet::getUuid() const -{ - return this->getResqmlData()->getUuid(); -} - -std::string ResqmlAbstractRepresentationToVtkPartitionedDataSet::getTitle() const -{ - return this->getResqmlData()->getTitle(); -} diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.cxx b/Plugin/Energistics/ResqmlMapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.cxx deleted file mode 100644 index 30e96c8..0000000 --- a/Plugin/Energistics/ResqmlMapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.cxx +++ /dev/null @@ -1,867 +0,0 @@ -/*----------------------------------------------------------------------- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"; you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ------------------------------------------------------------------------*/ -#include "ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h" - -#include -#include -#include -#include -#include -#include - -// VTK includes -#include -#include -#include -#include -#include - -// FESAPI includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef WITH_ETP_SSL -#include - -#include - -#include -#include -#include -#include -#endif -#include - -#include "ResqmlIjkGridToVtkUnstructuredGrid.h" -#include "ResqmlIjkGridSubRepToVtkUnstructuredGrid.h" -#include "ResqmlGrid2dToVtkStructuredGrid.h" -#include "ResqmlPolylineToVtkPolyData.h" -#include "ResqmlTriangulatedSetToVtkPartitionedDataSet.h" -#include "ResqmlUnstructuredGridToVtkUnstructuredGrid.h" -#include "ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid.h" -#include "ResqmlWellboreTrajectoryToVtkPolyData.h" -#include "ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h" -#include "ResqmlWellboreFrameToVtkPartitionedDataSet.h" - -ResqmlDataRepositoryToVtkPartitionedDataSetCollection::ResqmlDataRepositoryToVtkPartitionedDataSetCollection() : markerOrientation(false), - markerSize(10), - repository(new common::DataObjectRepository()), - output(vtkSmartPointer::New()), - nodeId_to_resqml(), - current_selection(), - old_selection() -{ - auto assembly = vtkSmartPointer::New(); - assembly->SetRootNodeName("data"); - output->SetDataAssembly(assembly); - times_step.clear(); -} - -ResqmlDataRepositoryToVtkPartitionedDataSetCollection::~ResqmlDataRepositoryToVtkPartitionedDataSetCollection() -{ - delete repository; - for (const auto &keyVal : nodeId_to_resqml) - { - delete keyVal.second; - } -} - -//---------------------------------------------------------------------------- -std::vector ResqmlDataRepositoryToVtkPartitionedDataSetCollection::connect(const std::string& etp_url, const std::string& data_partition, const std::string& auth_connection) -{ - std::vector result; -#ifdef WITH_ETP_SSL - boost::uuids::random_generator gen; - ETP_NS::InitializationParameters initializationParams(gen(), etp_url); - - std::map additionalHandshakeHeaderFields = {{"data-partition-id", data_partition}}; - if (etp_url.find("ws://") == 0) - { - session = ETP_NS::ClientSessionLaunchers::createWsClientSession(&initializationParams, auth_connection, additionalHandshakeHeaderFields); - } - else - { - session = ETP_NS::ClientSessionLaunchers::createWssClientSession(&initializationParams, auth_connection, additionalHandshakeHeaderFields); - } - session->setDataspaceProtocolHandlers(std::make_shared(session.get())); - session->setDiscoveryProtocolHandlers(std::make_shared(session.get())); - session->setStoreProtocolHandlers(std::make_shared(session.get())); - session->setDataArrayProtocolHandlers(std::make_shared(session.get())); - - repository->setHdfProxyFactory(new ETP_NS::FesapiHdfProxyFactory(session.get())); - - // - if (etp_url.find("ws://") == 0) - { - auto plainSession = std::dynamic_pointer_cast(session); - std::thread sessionThread(&ETP_NS::PlainClientSession::run, plainSession); - sessionThread.detach(); - } - else - { - auto sslSession = std::dynamic_pointer_cast(session); - std::thread sessionThread(&ETP_NS::SslClientSession::run, sslSession); - sessionThread.detach(); - } - - // Wait for the ETP session to be opened - auto t_start = std::chrono::high_resolution_clock::now(); - while (session->isEtpSessionClosed()) - { - if (std::chrono::duration(std::chrono::high_resolution_clock::now() - t_start).count() > 5000) - { - throw std::invalid_argument("Did you forget to click apply button before to connect? Time out for websocket connection" + - std::to_string(std::chrono::duration(std::chrono::high_resolution_clock::now() - t_start).count()) + "ms.\n"); - } - } - - //************ LIST DATASPACES ************ - const auto dataspaces = session->getDataspaces(); - - std::transform(dataspaces.begin(), dataspaces.end(), std::back_inserter(result), - [](const auto& ds) { return ds.uri; }); - -#endif - return result; -} - -//---------------------------------------------------------------------------- -void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::disconnect() -{ -#ifdef WITH_ETP_SSL - session->close(); -#endif -} - -//---------------------------------------------------------------------------- -std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::addFile(const char *fileName) -{ - COMMON_NS::EpcDocument pck(fileName); - std::string message = pck.deserializeInto(*repository); - pck.close(); - - message += buildDataAssemblyFromDataObjectRepo(fileName); - return message; -} - -//---------------------------------------------------------------------------- -std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::addDataspace(const char *dataspace) -{ -#ifdef WITH_ETP_SSL - //************ LIST RESOURCES ************ - Energistics::Etp::v12::Datatypes::Object::ContextInfo ctxInfo; - ctxInfo.uri = dataspace; - ctxInfo.depth = 0; - ctxInfo.navigableEdges = Energistics::Etp::v12::Datatypes::Object::RelationshipKind::Both; - ctxInfo.includeSecondaryTargets = false; - ctxInfo.includeSecondarySources = false; - const auto resources = session->getResources(ctxInfo, Energistics::Etp::v12::Datatypes::Object::ContextScopeKind::targets); - - //************ GET ALL DATAOBJECTS ************ - repository->setHdfProxyFactory(new ETP_NS::FesapiHdfProxyFactory(session.get())); - if (!resources.empty()) - { - std::map query; - for (size_t i = 0; i < resources.size(); ++i) - { - query[std::to_string(i)] = resources[i].uri; - } - const auto dataobjects = session->getDataObjects(query); - for (auto &datoObject : dataobjects) - { - repository->addOrReplaceGsoapProxy(datoObject.second.data, - ETP_NS::EtpHelpers::getDataObjectType(datoObject.second.resource.uri), - ETP_NS::EtpHelpers::getDataspaceUri(datoObject.second.resource.uri)); - } - } - else - { - vtkOutputWindowDisplayWarningText(("There is no dataobject in the dataspace : " + std::string(dataspace) + "\n").c_str()); - } -#endif - return buildDataAssemblyFromDataObjectRepo(""); -} - -namespace -{ - auto lexicographicalComparison = [](const COMMON_NS::AbstractObject *a, const COMMON_NS::AbstractObject *b) -> bool - { - return a->getTitle().compare(b->getTitle()) < 0; - }; - - template - void sortAndAdd(std::vector source, std::vector &dest) - { - std::sort(source.begin(), source.end(), lexicographicalComparison); - std::move(source.begin(), source.end(), std::inserter(dest, dest.end())); - } -} - -std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::buildDataAssemblyFromDataObjectRepo(const char *fileName) -{ - std::vector allReps; - - // create vtkDataAssembly: create treeView in property panel - sortAndAdd(repository->getHorizonGrid2dRepresentationSet(), allReps); - sortAndAdd(repository->getIjkGridRepresentationSet(), allReps); - sortAndAdd(repository->getAllPolylineSetRepresentationSet(), allReps); - sortAndAdd(repository->getAllTriangulatedSetRepresentationSet(), allReps); - sortAndAdd(repository->getUnstructuredGridRepresentationSet(), allReps); - - // See https://stackoverflow.com/questions/15347123/how-to-construct-a-stdstring-from-a-stdvectorstring - std::string message = std::accumulate(std::begin(allReps), std::end(allReps), std::string{}, - [&](std::string& message, RESQML2_NS::AbstractRepresentation const * rep) { - return message += searchRepresentations(rep); - }); - - // get WellboreTrajectory + subrepresentation + property - message += searchWellboreTrajectory(fileName); - - // get TimeSeries - message += searchTimeSeries(fileName); - - return message; -} - -std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchRepresentations(resqml2::AbstractRepresentation const *representation, int idNode) -{ - std::string result; - vtkDataAssembly *data_assembly = output->GetDataAssembly(); - - if (representation->isPartial()) - { - // check if it has already been added - // not exist => not loaded - if (data_assembly->FindFirstNodeWithName(("_" + representation->getUuid()).c_str()) == -1) - { - return "Partial representation with UUID \"" + representation->getUuid() + "\" is not loaded.\n"; - } /******* TODO ********/ // exist but not the same type ? - } - else - { - // The leading underscore is forced by VTK which does not support a node name starting with a digit (probably because it is a QNAME). - const std::string nodeName = "_" + representation->getUuid(); - const int existingNodeId = output->GetDataAssembly()->FindFirstNodeWithName(nodeName.c_str()); - if (existingNodeId == -1) - { - idNode = data_assembly->AddNode(nodeName.c_str(), idNode); - - auto const *subrep = dynamic_cast(representation); - const std::string representationVtkValidName = subrep == nullptr - ? vtkDataAssembly::MakeValidNodeName((representation->getXmlTag() + "_" + representation->getTitle()).c_str()) - : vtkDataAssembly::MakeValidNodeName((representation->getXmlTag() + "_" + subrep->getSupportingRepresentation(0)->getTitle() + "_" + representation->getTitle()).c_str()); - data_assembly->SetAttribute(idNode, "label", representationVtkValidName.c_str()); - } - else - { - idNode = existingNodeId; - } - } - - // add sub representation with properties (only for ijkGrid and unstructured grid) - if (dynamic_cast(representation) != nullptr || - dynamic_cast(representation) != nullptr) - { - result += searchSubRepresentation(representation, data_assembly, idNode); - } - - // add properties to representation - result += searchProperties(representation, data_assembly, idNode); - - return result; -} - -std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchSubRepresentation(RESQML2_NS::AbstractRepresentation const *representation, vtkDataAssembly *data_assembly, int node_parent) -{ - try - { - auto subRepresentationSet = representation->getSubRepresentationSet(); - std::sort(subRepresentationSet.begin(), subRepresentationSet.end(), lexicographicalComparison); - - std::string message = std::accumulate(std::begin(subRepresentationSet), std::end(subRepresentationSet), std::string{}, - [&](std::string& message, RESQML2_NS::SubRepresentation* b) { - return message += searchRepresentations(b, data_assembly->GetParent(node_parent)); - }); - } - catch (const std::exception &e) - { - return "Exception in FESAPI when calling getSubRepresentationSet for uuid : " + representation->getUuid() + " : " + e.what() + ".\n"; - } - - return ""; -} - -std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchProperties(RESQML2_NS::AbstractRepresentation const *representation, vtkDataAssembly *data_assembly, int node_parent) -{ - try - { - auto valuesPropertySet = representation->getValuesPropertySet(); - std::sort(valuesPropertySet.begin(), valuesPropertySet.end(), lexicographicalComparison); - // property - for (auto const *property : valuesPropertySet) - { - const std::string propertyVtkValidName = vtkDataAssembly::MakeValidNodeName((property->getXmlTag() + '_' + property->getTitle()).c_str()); - - if (output->GetDataAssembly()->FindFirstNodeWithName(("_" + property->getUuid()).c_str()) == -1) - { // verify uuid exist in treeview - int property_idNode = data_assembly->AddNode(("_" + property->getUuid()).c_str(), node_parent); - data_assembly->SetAttribute(property_idNode, "label", propertyVtkValidName.c_str()); - } - } - } - catch (const std::exception &e) - { - return "Exception in FESAPI when calling getValuesPropertySet with representation uuid: " + representation->getUuid() + " : " + e.what() + ".\n"; - } - - return ""; -} - -std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchWellboreTrajectory(const std::string &fileName) -{ - std::string result; - - vtkDataAssembly *data_assembly = output->GetDataAssembly(); - - int idNode = 0; // 0 is root's id - - for (auto *wellboreTrajectory : repository->getWellboreTrajectoryRepresentationSet()) - { - if (output->GetDataAssembly()->FindFirstNodeWithName(("_" + wellboreTrajectory->getUuid()).c_str()) == -1) - { // verify uuid exist in treeview - if (wellboreTrajectory->isPartial()) - { - // check if it has already been added - const std::string name_partial_representation = vtkDataAssembly::MakeValidNodeName((wellboreTrajectory->getXmlTag() + "_" + wellboreTrajectory->getTitle()).c_str()); - bool uuid_exist = data_assembly->FindFirstNodeWithName(("_" + name_partial_representation).c_str()) != -1; - // not exist => not loaded - if (!uuid_exist) - { - result = result + " Partial UUID: (" + wellboreTrajectory->getUuid() + ") is not loaded \n"; - continue; - } /******* TODO ********/ // exist but not the same type ? - } - else - { - // wellboreTrajectory->setTitle(vtkDataAssembly::MakeValidNodeName((wellboreTrajectory->getXmlTag() + '_' + wellboreTrajectory->getTitle()).c_str())); - const std::string wellboreTrajectoryVtkValidName = vtkDataAssembly::MakeValidNodeName((wellboreTrajectory->getXmlTag() + '_' + wellboreTrajectory->getTitle()).c_str()); - idNode = data_assembly->AddNode(("_" + wellboreTrajectory->getUuid()).c_str(), 0 /* add to root*/); - data_assembly->SetAttribute(idNode, "label", wellboreTrajectoryVtkValidName.c_str()); - data_assembly->SetAttribute(idNode, "is_checkable", 0); - } - } - // wellboreFrame - for (auto *wellboreFrame : wellboreTrajectory->getWellboreFrameRepresentationSet()) - { - if (output->GetDataAssembly()->FindFirstNodeWithName(("_" + wellboreFrame->getUuid()).c_str()) == -1) - { // verify uuid exist in treeview - auto *wellboreMarkerFrame = dynamic_cast(wellboreFrame); - if (wellboreMarkerFrame == nullptr) - { // WellboreFrame - wellboreFrame->setTitle(vtkDataAssembly::MakeValidNodeName((wellboreFrame->getXmlTag() + '_' + wellboreFrame->getTitle()).c_str())); - const std::string wellboreFrameVtkValidName = vtkDataAssembly::MakeValidNodeName((wellboreFrame->getXmlTag() + '_' + wellboreFrame->getTitle()).c_str()); - int frame_idNode = data_assembly->AddNode(("_" + wellboreFrame->getUuid()).c_str(), 0 /* add to root*/); - data_assembly->SetAttribute(frame_idNode, "label", wellboreFrameVtkValidName.c_str()); - data_assembly->SetAttribute(frame_idNode, "traj", idNode); - for (auto *property : wellboreFrame->getValuesPropertySet()) - { - const std::string propertyVtkValidName = vtkDataAssembly::MakeValidNodeName((property->getXmlTag() + '_' + property->getTitle()).c_str()); - int property_idNode = data_assembly->AddNode(("_" + property->getUuid()).c_str(), frame_idNode); - data_assembly->SetAttribute(property_idNode, "label", propertyVtkValidName.c_str()); - data_assembly->SetAttribute(property_idNode, "traj", idNode); - } - } - else - { // WellboreMarkerFrame - const std::string wellboreFrameVtkValidName = vtkDataAssembly::MakeValidNodeName((wellboreFrame->getXmlTag() + '_' + wellboreFrame->getTitle()).c_str()); - int markerFrame_idNode = data_assembly->AddNode(("_" + wellboreFrame->getUuid()).c_str(), 0 /* add to root*/); - data_assembly->SetAttribute(markerFrame_idNode, "label", wellboreFrameVtkValidName.c_str()); - data_assembly->SetAttribute(markerFrame_idNode, "traj", idNode); - for (auto *wellboreMarker : wellboreMarkerFrame->getWellboreMarkerSet()) - { - const std::string wellboreMarkerVtkValidName = vtkDataAssembly::MakeValidNodeName((wellboreMarker->getXmlTag() + '_' + wellboreMarker->getTitle()).c_str()); - int marker_idNode = data_assembly->AddNode(("_" + wellboreMarker->getUuid()).c_str(), markerFrame_idNode); - data_assembly->SetAttribute(marker_idNode, "label", wellboreMarkerVtkValidName.c_str()); - data_assembly->SetAttribute(marker_idNode, "traj", idNode); - } - } - } - } - } - return result; -} - -std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::searchTimeSeries(const std::string &fileName) -{ - times_step.clear(); - - std::string return_message = ""; - auto *assembly = output->GetDataAssembly(); - std::vector timeSeriesSet; - try - { - timeSeriesSet = repository->getTimeSeriesSet(); - } - catch (const std::exception &e) - { - return_message = return_message + "Exception in FESAPI when calling getTimeSeriesSet with file: " + fileName + " : " + e.what(); - } - - /**** - * change property parent to times serie parent - ****/ - for (auto const *timeSeries : timeSeriesSet) - { - // get properties link to Times series - try - { - auto propSeries = timeSeries->getPropertySet(); - - std::map> propertyName_to_nodeSet; - for (auto const *prop : propSeries) - { - if (prop->getXmlTag() == RESQML2_NS::ContinuousProperty::XML_TAG || - prop->getXmlTag() == RESQML2_NS::DiscreteProperty::XML_TAG) - { - auto node_id = (output->GetDataAssembly()->FindFirstNodeWithName(("_" + prop->getUuid()).c_str())); - if (node_id == -1) - { - return_message = return_message + "The property " + prop->getUuid() + " is not supported and consequently cannot be associated to its time series.\n"; - continue; - } - else - { - // same node parent else not supported - const int nodeParent = assembly->GetParent(node_id); - if (nodeParent != -1) - { - propertyName_to_nodeSet[prop->getTitle()].push_back(node_id); - const size_t timeIndexInTimeSeries = timeSeries->getTimestampIndex(prop->getSingleTimestamp()); - times_step.push_back(timeIndexInTimeSeries); - timeSeries_uuid_and_title_to_index_and_properties_uuid[timeSeries->getUuid()][vtkDataAssembly::MakeValidNodeName((timeSeries->getXmlTag() + '_' + prop->getTitle()).c_str())][timeIndexInTimeSeries] = prop->getUuid(); - } - else - { - return_message = return_message + "The properties of time series " + timeSeries->getUuid() + " aren't parent and is not supported.\n"; - continue; - } - } - } - } - // erase duplicate Index - sort(times_step.begin(), times_step.end()); - times_step.erase(unique(times_step.begin(), times_step.end()), times_step.end()); - - for (const auto &myPair : propertyName_to_nodeSet) - { - std::vector property_node_set = myPair.second; - - int nodeParent = -1; - // erase property add to treeview for group by TimeSerie - for (auto node : property_node_set) - { - nodeParent = output->GetDataAssembly()->GetParent(node); - output->GetDataAssembly()->RemoveNode(node); - } - std::string name = vtkDataAssembly::MakeValidNodeName((timeSeries->getXmlTag() + '_' + myPair.first).c_str()); - auto times_serie_node_id = output->GetDataAssembly()->AddNode(("_" + timeSeries->getUuid() + name).c_str(), nodeParent); - output->GetDataAssembly()->SetAttribute(times_serie_node_id, "label", name.c_str()); - } - } - catch (const std::exception &e) - { - return_message = return_message + "Exception in FESAPI when calling getPropertySet with file: " + fileName + " : " + e.what(); - } - } - - return return_message; -} - -std::string ResqmlDataRepositoryToVtkPartitionedDataSetCollection::selectNodeId(int node) -{ - if (node != 0) - { - this->selectNodeIdParent(node); - - this->current_selection.insert(node); - this->old_selection.erase(node); - } - this->selectNodeIdChildren(node); - - return ""; -} - -void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::selectNodeIdParent(int node) -{ - auto const *assembly = this->output->GetDataAssembly(); - - if (assembly->GetParent(node) > 0) - { - this->current_selection.insert(assembly->GetParent(node)); - this->old_selection.erase(assembly->GetParent(node)); - this->selectNodeIdParent(assembly->GetParent(node)); - } -} -void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::selectNodeIdChildren(int node) -{ - auto const *assembly = this->output->GetDataAssembly(); - - for (int index_child : assembly->GetChildNodes(node)) - { - this->current_selection.insert(index_child); - this->old_selection.erase(index_child); - this->selectNodeIdChildren(index_child); - } -} - -void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::clearSelection() -{ - this->old_selection = this->current_selection; - this->current_selection.clear(); -} - -void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::initMapper(const std::string &uuid, const int nbProcess, const int processId) -{ - ResqmlAbstractRepresentationToVtkPartitionedDataSet *rep = nullptr; - if (uuid.length() == 36) - { - - COMMON_NS::AbstractObject *const result = repository->getDataObjectByUuid(uuid); - - try - { - if (dynamic_cast(result) != nullptr) - { - rep = new ResqmlIjkGridToVtkUnstructuredGrid(static_cast(result), processId, nbProcess); - } - else if (dynamic_cast(result) != nullptr) - { - rep = new ResqmlGrid2dToVtkStructuredGrid(static_cast(result)); - } - else if (dynamic_cast(result) != nullptr) - { - rep = new ResqmlTriangulatedSetToVtkPartitionedDataSet(static_cast(result)); - } - else if (dynamic_cast(result) != nullptr) - { - rep = new ResqmlPolylineToVtkPolyData(static_cast(result)); - } - else if (dynamic_cast(result) != nullptr) - { - rep = new ResqmlUnstructuredGridToVtkUnstructuredGrid(static_cast(result)); - } - else if (dynamic_cast(result) != nullptr) - { - RESQML2_NS::SubRepresentation *subRep = static_cast(result); - - if (dynamic_cast(subRep->getSupportingRepresentation(0)) != nullptr) - { - auto *supportingGrid = static_cast(subRep->getSupportingRepresentation(0)); - if (this->nodeId_to_resqml.find(output->GetDataAssembly()->FindFirstNodeWithName(("_" + supportingGrid->getUuid()).c_str())) == this->nodeId_to_resqml.end()) - { - this->nodeId_to_resqml[output->GetDataAssembly()->FindFirstNodeWithName(("_" + supportingGrid->getUuid()).c_str())] = new ResqmlIjkGridToVtkUnstructuredGrid(supportingGrid); - } - rep = new ResqmlIjkGridSubRepToVtkUnstructuredGrid(subRep, dynamic_cast(this->nodeId_to_resqml[output->GetDataAssembly()->FindFirstNodeWithName(("_" + supportingGrid->getUuid()).c_str())])); - } - else if (dynamic_cast(subRep->getSupportingRepresentation(0)) != nullptr) - { - auto *supportingGrid = static_cast(subRep->getSupportingRepresentation(0)); - if (this->nodeId_to_resqml.find(output->GetDataAssembly()->FindFirstNodeWithName(("_" + supportingGrid->getUuid()).c_str())) == this->nodeId_to_resqml.end()) - { - this->nodeId_to_resqml[output->GetDataAssembly()->FindFirstNodeWithName(("_" + supportingGrid->getUuid()).c_str())] = new ResqmlUnstructuredGridToVtkUnstructuredGrid(supportingGrid); - } - rep = new ResqmlUnstructuredGridSubRepToVtkUnstructuredGrid(subRep, dynamic_cast(this->nodeId_to_resqml[output->GetDataAssembly()->FindFirstNodeWithName(("_" + supportingGrid->getUuid()).c_str())])); - } - } - else if (dynamic_cast(result) != nullptr) - { - rep = new ResqmlWellboreTrajectoryToVtkPolyData(static_cast(result)); - } - else if (dynamic_cast(result) != nullptr) - { - rep = new ResqmlWellboreMarkerFrameToVtkPartitionedDataSet(static_cast(result)); - } - else if (dynamic_cast(result) != nullptr) - { - rep = new ResqmlWellboreFrameToVtkPartitionedDataSet(static_cast(result)); - } - else - { - return; - } - this->nodeId_to_resqml[output->GetDataAssembly()->FindFirstNodeWithName(("_" + uuid).c_str())] = rep; - } - catch (const std::exception &e) - { - vtkOutputWindowDisplayErrorText(("Error when initialize uuid: " + uuid + "\n" + e.what()).c_str()); - } - } -} - -void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::loadMapper(const std::string &uuid, double time) -{ - try - { // load Time Series Properties - if (uuid.length() > 36) - { - std::string ts_uuid = uuid.substr(0, 36); - std::string node_name = uuid.substr(36); - - auto const *assembly = this->output->GetDataAssembly(); - const int node_parent = assembly->GetParent(output->GetDataAssembly()->FindFirstNodeWithName(("_" + uuid).c_str())); - if (nodeId_to_resqml[node_parent]) - { - nodeId_to_resqml[node_parent]->addDataArray(timeSeries_uuid_and_title_to_index_and_properties_uuid[ts_uuid][node_name][time]); - } - return; - } - } - catch (const std::exception &e) - { - vtkOutputWindowDisplayErrorText(("Error when load Time Series property marker uuid: " + uuid + "\n" + e.what()).c_str()); - return; - } - - COMMON_NS::AbstractObject *const result = repository->getDataObjectByUuid(uuid); - - try - { // load Wellbore Marker - if (dynamic_cast(result) != nullptr) - { - auto const *assembly = this->output->GetDataAssembly(); - const int node_parent = assembly->GetParent(output->GetDataAssembly()->FindFirstNodeWithName(("_" + uuid).c_str())); - static_cast(nodeId_to_resqml[node_parent])->addMarker(uuid, markerOrientation, markerSize); - return; - } - } - catch (const std::exception &e) - { - vtkOutputWindowDisplayErrorText(("Error when load wellbore marker uuid: " + uuid + "\n" + e.what()).c_str()); - return; - } - try - { // load property - if (dynamic_cast(result) != nullptr) - { - auto const *assembly = this->output->GetDataAssembly(); - const int node_parent = assembly->GetParent(output->GetDataAssembly()->FindFirstNodeWithName(("_" + uuid).c_str())); - if (dynamic_cast(nodeId_to_resqml[node_parent]) != nullptr) - { - static_cast(nodeId_to_resqml[node_parent])->addChannel(uuid, static_cast(result)); - } - else if (dynamic_cast(nodeId_to_resqml[node_parent]) != nullptr) - { - static_cast(nodeId_to_resqml[node_parent])->addDataArray(uuid); - } - else - { - static_cast(nodeId_to_resqml[node_parent])->addDataArray(uuid); - } - return; - } - } - catch (const std::exception &e) - { - vtkOutputWindowDisplayErrorText(("Error when load property uuid: " + uuid + "\n" + e.what()).c_str()); - return; - } - - try - { // load representation - - nodeId_to_resqml[output->GetDataAssembly()->FindFirstNodeWithName(("_" + uuid).c_str())]->loadVtkObject(); - - return; - } - catch (const std::exception &e) - { - vtkOutputWindowDisplayErrorText(("Error when rendering uuid: " + uuid + "\n" + e.what()).c_str()); - return; - } -} - -vtkPartitionedDataSetCollection *ResqmlDataRepositoryToVtkPartitionedDataSetCollection::getVtkPartitionedDatasSetCollection(const double time, const int nbProcess, const int processId) -{ - // initialization the output (VtkPartitionedDatasSetCollection) - vtkSmartPointer tmp_assembly = vtkSmartPointer::New(); - tmp_assembly->DeepCopy(this->output->GetDataAssembly()); - this->output = vtkSmartPointer::New(); - this->output->SetDataAssembly(tmp_assembly); - - unsigned int index = 0; // index for PartionedDatasSet - - // delete unchecked object - for (const int selection : this->old_selection) - { - const std::string uuid_unselect = std::string(tmp_assembly->GetNodeName(selection)).substr(1); - if (uuid_unselect.length() > 36) // uncheck Time Series - { // TimeSerie properties deselection - std::string ts_uuid = uuid_unselect.substr(0, 36); - std::string node_name = uuid_unselect.substr(36); - - const int node_parent = tmp_assembly->GetParent(tmp_assembly->FindFirstNodeWithName(("_" + uuid_unselect).c_str())); - if (this->nodeId_to_resqml.find(node_parent) != this->nodeId_to_resqml.end()) - { - nodeId_to_resqml[node_parent]->deleteDataArray(timeSeries_uuid_and_title_to_index_and_properties_uuid[ts_uuid][node_name][time]); - } - } - else - { // other deselection - COMMON_NS::AbstractObject *const result = repository->getDataObjectByUuid(uuid_unselect); - - if (result == nullptr) - { - vtkOutputWindowDisplayErrorText(("Error in deselection for uuid: " + uuid_unselect + "\n").c_str()); - } - else - { - if (dynamic_cast(result) != nullptr) - { - const int node_parent = tmp_assembly->GetParent(selection); - try - { - if (this->nodeId_to_resqml.find(node_parent) != this->nodeId_to_resqml.end()) - { - ResqmlAbstractRepresentationToVtkPartitionedDataSet *rep = this->nodeId_to_resqml[node_parent]; - rep->deleteDataArray(std::string(tmp_assembly->GetNodeName(selection)).substr(1)); - } - } - catch (const std::exception &e) - { - vtkOutputWindowDisplayErrorText(("Error in property unload for uuid: " + uuid_unselect + "\n" + e.what()).c_str()); - } - } - else if (dynamic_cast(result) != nullptr) - { - try - { - const int node_parent = tmp_assembly->GetParent(selection); - if (this->nodeId_to_resqml.find(node_parent) != this->nodeId_to_resqml.end()) - { - ResqmlWellboreMarkerFrameToVtkPartitionedDataSet *rep = dynamic_cast(this->nodeId_to_resqml[node_parent]); - rep->removeMarker(uuid_unselect); - } - } - catch (const std::exception &e) - { - vtkOutputWindowDisplayErrorText(("Error in wellboremarker unload for uuid: " + uuid_unselect + "\n" + e.what()).c_str()); - } - } - else if (dynamic_cast(result) != nullptr) - { - try - { - if (this->nodeId_to_resqml.find(selection) != this->nodeId_to_resqml.end()) - { - std::string uuid_supporting_grid = ""; - if (dynamic_cast(this->nodeId_to_resqml[selection]) != nullptr) - { - uuid_supporting_grid = static_cast(this->nodeId_to_resqml[selection])->unregisterToMapperSupportingGrid(); - } - else if (dynamic_cast(this->nodeId_to_resqml[selection]) != nullptr) - { - uuid_supporting_grid = static_cast(this->nodeId_to_resqml[selection])->unregisterToMapperSupportingGrid(); - } - // erase representation - this->nodeId_to_resqml.erase(selection); - // erase supporting grid ?? - const int node_parent = tmp_assembly->FindFirstNodeWithName(("_" + uuid_supporting_grid).c_str()); - if ((this->nodeId_to_resqml.find(node_parent) != this->nodeId_to_resqml.end())) - { - if (this->current_selection.find(node_parent) == this->current_selection.end()) - { - if (this->nodeId_to_resqml[node_parent]->subRepLinkedCount() == 0) - { - this->nodeId_to_resqml.erase(node_parent); - } - } - } - } - else - { - vtkOutputWindowDisplayErrorText(("Error in deselection for uuid: " + uuid_unselect + "\n").c_str()); - } - } - catch (const std::exception &e) - { - vtkOutputWindowDisplayErrorText(("Error in subrepresentation unload for uuid: " + uuid_unselect + "\n" + e.what()).c_str()); - } - } - else - { - if (this->nodeId_to_resqml.find(selection) != this->nodeId_to_resqml.end()) - { - if (this->nodeId_to_resqml[selection]->subRepLinkedCount() == 0) - { - this->nodeId_to_resqml.erase(selection); - } - } - } - } - } - } - - // foreach selection node - for (const int node_selection : this->current_selection) - { - if (this->nodeId_to_resqml.find(node_selection) == this->nodeId_to_resqml.end()) - { - initMapper(std::string(tmp_assembly->GetNodeName(node_selection)).substr(1), nbProcess, processId); - } - - if (this->nodeId_to_resqml.find(node_selection) != this->nodeId_to_resqml.end()) - { - if (this->nodeId_to_resqml[node_selection]->getOutput()->GetNumberOfPartitions() < 1) - { - loadMapper(std::string(tmp_assembly->GetNodeName(node_selection)).substr(1), time); - } - this->output->SetPartitionedDataSet(index, this->nodeId_to_resqml[node_selection]->getOutput()); - this->output->GetMetaData(index++)->Set(vtkCompositeDataSet::NAME(), this->nodeId_to_resqml[node_selection]->getTitle()+'('+this->nodeId_to_resqml[node_selection]->getUuid()+')'); -// this->output->GetMetaData(index++)->Set(vtkCompositeDataSet::NAME(), this->output->GetDataAssembly()->GetNodeName(node_selection)); - } - else - { - loadMapper(std::string(tmp_assembly->GetNodeName(node_selection)).substr(1), time); - } - } - - this->output->Modified(); - return this->output; -} - -void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::setMarkerOrientation(bool orientation) -{ - markerOrientation = orientation; -} - -void ResqmlDataRepositoryToVtkPartitionedDataSetCollection::setMarkerSize(int size) -{ - markerSize = size; -} diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h b/Plugin/Energistics/ResqmlMapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h deleted file mode 100644 index 3cccfeb..0000000 --- a/Plugin/Energistics/ResqmlMapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h +++ /dev/null @@ -1,122 +0,0 @@ -/*----------------------------------------------------------------------- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"; you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ------------------------------------------------------------------------*/ -#ifndef __ResqmlDataRepositoryToVtkPartitionedDataSetCollection_h -#define __ResqmlDataRepositoryToVtkPartitionedDataSetCollection_h - -// include system -#include -#include -#include - -#include -#include -#include - -#ifdef WITH_ETP_SSL -#include -#endif - -namespace common -{ - class DataObjectRepository; -} - -namespace resqml2 -{ - class AbstractRepresentation; -} - -class ResqmlAbstractRepresentationToVtkPartitionedDataSet; - -/** - * @brief class description. - */ -class ResqmlDataRepositoryToVtkPartitionedDataSetCollection -{ -public: - ResqmlDataRepositoryToVtkPartitionedDataSetCollection(); - ~ResqmlDataRepositoryToVtkPartitionedDataSetCollection(); - // --------------- PART: TreeView --------------------- - vtkDataAssembly *GetAssembly() { return output->GetDataAssembly(); } - - //--------------------------------- - - // for EPC reader - std::string addFile(const char *file); - - // for ETP source - std::string addDataspace(const char *dataspace); - - // for ETP connection - std::vector connect(const std::string& etp_url, const std::string& data_partition, const std::string& auth_connection); - void disconnect(); - - // Wellbore Options - void setMarkerOrientation(bool orientation); - void setMarkerSize(int size); - - vtkPartitionedDataSetCollection *getVtkPartitionedDatasSetCollection(const double time, const int nbProcess = 1, const int processId = 0); - - std::vector getTimes() { return times_step; } - - /** - * @return selection parent - */ - std::string selectNodeId(int node); - void clearSelection(); - -private: - std::string buildDataAssemblyFromDataObjectRepo(const char *fileName); - - std::string searchWellboreTrajectory(const std::string &fileName); - std::string searchRepresentations(resqml2::AbstractRepresentation const *representation, int idNode = 0 /* 0 is root's id*/); - - std::string searchSubRepresentation(resqml2::AbstractRepresentation const *representation, vtkDataAssembly *assembly, int node_parent); - std::string searchTimeSeries(const std::string &fileName); - - std::string searchProperties(resqml2::AbstractRepresentation const *representation, vtkDataAssembly *assembly, int node_parent); - - void selectNodeIdParent(int node); - void selectNodeIdChildren(int node); - - void initMapper(const std::string &uuid, const int nbProcess, const int processId); - void loadMapper(const std::string &uuid, double time); - - bool markerOrientation; - int markerSize; - - common::DataObjectRepository *repository; - - vtkSmartPointer output; - - std::map nodeId_to_resqml; // index of VtkDataAssembly to ResqmlAbstractRepresentationToVtkPartitionedDataSet - - //\/ uuid title index prop_uuid - std::map>> timeSeries_uuid_and_title_to_index_and_properties_uuid; - - std::set current_selection; - std::set old_selection; - - // time step values - std::vector times_step; -#ifdef WITH_ETP_SSL - std::shared_ptr session; -#endif -}; -#endif \ No newline at end of file diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlIjkGridToVtkUnstructuredGrid.cxx b/Plugin/Energistics/ResqmlMapping/ResqmlIjkGridToVtkUnstructuredGrid.cxx deleted file mode 100644 index c023860..0000000 --- a/Plugin/Energistics/ResqmlMapping/ResqmlIjkGridToVtkUnstructuredGrid.cxx +++ /dev/null @@ -1,255 +0,0 @@ -/*----------------------------------------------------------------------- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"; you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ------------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlIjkGridToVtkUnstructuredGrid.h" - -#include - -// include VTK library -#include -#include -#include -#include -#include -#include -#include - -// include FESAPI -#include -#include - -// include FESPP -#include "ResqmlPropertyToVtkDataArray.h" - -//---------------------------------------------------------------------------- -ResqmlIjkGridToVtkUnstructuredGrid::ResqmlIjkGridToVtkUnstructuredGrid(RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid, int proc_number, int max_proc) - : ResqmlAbstractRepresentationToVtkPartitionedDataSet(ijkGrid, - proc_number, - max_proc), - points(vtkSmartPointer::New()), - pointer_on_points(0) -{ - this->iCellCount = ijkGrid->getICellCount(); - this->jCellCount = ijkGrid->getJCellCount(); - this->kCellCount = ijkGrid->getKCellCount(); - this->pointCount = ijkGrid->getXyzPointCountOfAllPatches(); - this->checkHyperslabingCapacity(ijkGrid); - - if (this->isHyperslabed) - { - const auto optim = (this->kCellCount % max_proc) > 0 ? (this->kCellCount / max_proc) + 1 : this->kCellCount / max_proc; - this->initKIndex = this->procNumber * optim; - if (this->initKIndex >= this->kCellCount) - { - this->initKIndex = 0; - this->maxKIndex = 0; - } - else - { - this->maxKIndex = this->procNumber == this->maxProc - 1 - ? this->kCellCount - : this->initKIndex + optim; - } - } - else - { - this->initKIndex = 0; - this->maxKIndex = this->kCellCount; - } - - this->vtkData = vtkSmartPointer::New(); -} - -//---------------------------------------------------------------------------- -RESQML2_NS::AbstractIjkGridRepresentation * ResqmlIjkGridToVtkUnstructuredGrid::getResqmlData() const -{ - return static_cast(resqmlData); -} - -//---------------------------------------------------------------------------- -void ResqmlIjkGridToVtkUnstructuredGrid::checkHyperslabingCapacity(RESQML2_NS::AbstractIjkGridRepresentation *ijkGrid) -{ - try - { - RESQML2_NS::AbstractIjkGridRepresentation * ijkGrid = getResqmlData(); - const auto kInterfaceNodeCount = ijkGrid->getXyzPointCountOfKInterface(); - std::unique_ptr allXyzPoints(new double[kInterfaceNodeCount * 3]); - ijkGrid->getXyzPointsOfKInterface(0, allXyzPoints.get()); - this->isHyperslabed = true; - } - catch (const std::exception &) - { - this->isHyperslabed = false; - } -} - -//---------------------------------------------------------------------------- -// Create and set the list of hexahedra of the vtkUnstructuredGrid based on the list of points already set -void ResqmlIjkGridToVtkUnstructuredGrid::loadVtkObject() -{ - RESQML2_NS::AbstractIjkGridRepresentation * ijkGrid = getResqmlData(); - - // Create and set the list of points of the vtkUnstructuredGrid - vtkSmartPointer vtk_unstructuredGrid = vtkSmartPointer::New(); - vtk_unstructuredGrid->SetPoints(this->getVtkPoints()); - - // Define hexahedron node ordering according to Paraview convention : https://lorensen.github.io/VTKExamples/site/VTKBook/05Chapter5/#Figure%205-3 - std::array correspondingResqmlCornerId = {0, 1, 2, 3, 4, 5, 6, 7}; - if (!ijkGrid->isRightHanded()) - { - correspondingResqmlCornerId = {4, 5, 6, 7, 0, 1, 2, 3}; - } - - // Check which cells have no geometry - const uint64_t cellCount = ijkGrid->getCellCount(); - std::unique_ptr enabledCells(new bool[cellCount]); - if (ijkGrid->hasCellGeometryIsDefinedFlags()) - { - ijkGrid->getCellGeometryIsDefinedFlags(enabledCells.get()); - } - else - { - std::fill_n(enabledCells.get(), cellCount, true); - } - - const uint64_t translatePoint = ijkGrid->getXyzPointCountOfKInterface() * this->initKIndex; - - uint64_t cellIndex = 0; - vtk_unstructuredGrid->Allocate(this->iCellCount * this->jCellCount * (this->maxKIndex- this->initKIndex)); - ijkGrid->loadSplitInformation(); - vtkSmartPointer nodes = vtkSmartPointer::New(); - nodes->SetNumberOfIds(8); - for (uint_fast32_t vtkKCellIndex = this->initKIndex; vtkKCellIndex < this->maxKIndex; ++vtkKCellIndex) - { - for (uint_fast32_t vtkJCellIndex = 0; vtkJCellIndex < this->jCellCount; ++vtkJCellIndex) - { - for (uint_fast32_t vtkICellIndex = 0; vtkICellIndex < this->iCellCount; ++vtkICellIndex) - { - if (enabledCells[cellIndex++]) - { - for (uint_fast8_t cornerId = 0; cornerId < 8; ++cornerId) - { - nodes->SetId(cornerId, - ijkGrid->getXyzPointIndexFromCellCorner(vtkICellIndex, vtkJCellIndex, vtkKCellIndex, correspondingResqmlCornerId[cornerId]) - translatePoint); - } - vtk_unstructuredGrid->InsertNextCell(VTK_HEXAHEDRON, nodes); - } - else - { - vtk_unstructuredGrid->InsertNextCell(VTK_EMPTY_CELL, 0, nullptr); - } - } - } - } - ijkGrid->unloadSplitInformation(); - - this->vtkData->SetPartition(0, vtk_unstructuredGrid); - this->vtkData->Modified(); -} - -vtkSmartPointer ResqmlIjkGridToVtkUnstructuredGrid::getVtkPoints() -{ - if (this->points->GetNumberOfPoints() < 1) - { - createPoints(); - } - - return this->points; -} - -//---------------------------------------------------------------------------- -void ResqmlIjkGridToVtkUnstructuredGrid::createPoints() -{ - RESQML2_NS::AbstractIjkGridRepresentation * ijkGrid = getResqmlData(); - - this->points->SetNumberOfPoints(this->pointCount); - size_t point_id = 0; - - if (this->isHyperslabed && !ijkGrid->isNodeGeometryCompressed()) - { - // Take into account K gaps - const uint32_t kGapCount = ijkGrid->getKGapsCount(); - uint32_t initKInterfaceIndex = this->initKIndex; - uint32_t maxKInterfaceIndex = this->maxKIndex; - if (kGapCount > 0) - { - std::unique_ptr gapAfterLayer(new bool[this->kCellCount - 1]); // gap after each layer except for the last k cell - ijkGrid->getKGaps(gapAfterLayer.get()); - uint32_t kLayer = 0; - for (; kLayer < this->initKIndex; ++kLayer) - { - if (gapAfterLayer[kLayer]) - { - ++initKInterfaceIndex; - ++maxKInterfaceIndex; - } - } - for (; kLayer < this->kCellCount - 1 && kLayer < this->maxKIndex; ++kLayer) - { - if (gapAfterLayer[kLayer]) - { - ++maxKInterfaceIndex; - } - } - } - - const uint64_t kInterfaceNodeCount = ijkGrid->getXyzPointCountOfKInterface(); - std::unique_ptr allXyzPoints(new double[kInterfaceNodeCount * 3]); - - for (uint_fast32_t kInterface = initKInterfaceIndex; kInterface <= maxKInterfaceIndex; ++kInterface) - { - ijkGrid->getXyzPointsOfKInterface(kInterface, allXyzPoints.get()); - auto const *crs = ijkGrid->getLocalCrs(0); - double xOffset = .0; - double yOffset = .0; - double zOffset = .0; - double zIndice = allXyzPoints[2]>0?-1.:1.; - if (crs != nullptr && !crs->isPartial()) - { - xOffset = crs->getOriginOrdinal1(); - yOffset = crs->getOriginOrdinal2(); - auto const* depthCrs = dynamic_cast(crs); - zOffset = depthCrs != nullptr ? depthCrs->getOriginDepthOrElevation() : 0; - zIndice = crs->isDepthOriented() ? -1. : 1.; - } - else - { - vtkOutputWindowDisplayWarningText("The CRS doesn't exist or is partial"); - } - for (uint_fast64_t nodeIndex = 0; nodeIndex < kInterfaceNodeCount * 3; nodeIndex += 3) - { - this->points->SetPoint(point_id++, allXyzPoints[nodeIndex] + xOffset, allXyzPoints[nodeIndex + 1] + yOffset, (allXyzPoints[nodeIndex + 2] + zOffset) * zIndice); - } - } - } - else - { - this->initKIndex = 0; - this->maxKIndex = this->kCellCount; - - std::unique_ptr allXyzPoints(new double[this->pointCount * 3]); - ijkGrid->getXyzPointsOfAllPatchesInGlobalCrs(allXyzPoints.get()); - const size_t coordCount = this->pointCount * 3; - - const double zIndice = ijkGrid->getLocalCrs(0)->isDepthOriented() ? -1 : 1; - for (uint_fast64_t pointIndex = 0; pointIndex < coordCount; pointIndex += 3) - { - this->points->SetPoint(point_id++, allXyzPoints[pointIndex], allXyzPoints[pointIndex + 1], -allXyzPoints[pointIndex + 2] * zIndice); - } - } -} diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreFrameToVtkPartitionedDataSet.cxx b/Plugin/Energistics/ResqmlMapping/ResqmlWellboreFrameToVtkPartitionedDataSet.cxx deleted file mode 100644 index 9bc6a20..0000000 --- a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreFrameToVtkPartitionedDataSet.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/*----------------------------------------------------------------------- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"; you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ------------------------------------------------------------------------*/ -#include "ResqmlWellboreFrameToVtkPartitionedDataSet.h" - -#include - -#include - -#include -#include - -// include F2i-consulting Energistics Paraview Plugin -#include "ResqmlWellboreChannelToVtkPolyData.h" - -//---------------------------------------------------------------------------- -ResqmlWellboreFrameToVtkPartitionedDataSet::ResqmlWellboreFrameToVtkPartitionedDataSet(resqml2::WellboreFrameRepresentation *frame, int proc_number, int max_proc) - : ResqmlAbstractRepresentationToVtkPartitionedDataSet(frame, - proc_number, - max_proc) -{ - this->vtkData = vtkSmartPointer::New(); - this->loadVtkObject(); -} - -//---------------------------------------------------------------------------- -RESQML2_NS::WellboreFrameRepresentation * ResqmlWellboreFrameToVtkPartitionedDataSet::getResqmlData() const -{ - return static_cast(resqmlData); -} - -//---------------------------------------------------------------------------- -void ResqmlWellboreFrameToVtkPartitionedDataSet::loadVtkObject() -{ - for (int idx = 0; idx < this->list_channel.size(); ++idx) - { - this->vtkData->SetPartition(idx, this->list_channel[idx]->getOutput()->GetPartitionAsDataObject(0)); - this->vtkData->GetMetaData(idx)->Set(vtkCompositeDataSet::NAME(), this->list_channel[idx]->getTitle().c_str()); - } -} - -//---------------------------------------------------------------------------- -void ResqmlWellboreFrameToVtkPartitionedDataSet::addChannel(const std::string &uuid, resqml2::AbstractValuesProperty *property) -{ - if (std::find_if(list_channel.begin(), list_channel.end(), [uuid](ResqmlWellboreChannelToVtkPolyData const *channel) { return channel->getUuid() == uuid; }) == list_channel.end()) - { - this->list_channel.push_back(new ResqmlWellboreChannelToVtkPolyData(getResqmlData(), property, uuid)); - this->loadVtkObject(); - } -} - -//---------------------------------------------------------------------------- -void ResqmlWellboreFrameToVtkPartitionedDataSet::removeChannel(const std::string &uuid) -{ - list_channel.erase( - std::remove_if(list_channel.begin(), list_channel.end(), [uuid](ResqmlWellboreChannelToVtkPolyData const *channel) { return channel->getUuid() == uuid; }), - list_channel.end()); - this->loadVtkObject(); -} diff --git a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.cxx b/Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.cxx deleted file mode 100644 index ff19c2f..0000000 --- a/Plugin/Energistics/ResqmlMapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.cxx +++ /dev/null @@ -1,102 +0,0 @@ -/*----------------------------------------------------------------------- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"; you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ------------------------------------------------------------------------*/ -#include "ResqmlMapping/ResqmlWellboreMarkerFrameToVtkPartitionedDataSet.h" - -#include -#include - -// include VTK library -#include - -#include -#include -#include - -#include "ResqmlMapping/ResqmlWellboreMarkerToVtkPolyData.h" - -//---------------------------------------------------------------------------- -ResqmlWellboreMarkerFrameToVtkPartitionedDataSet::ResqmlWellboreMarkerFrameToVtkPartitionedDataSet(RESQML2_NS::WellboreMarkerFrameRepresentation *marker_frame, int proc_number, int max_proc) - : ResqmlAbstractRepresentationToVtkPartitionedDataSet(marker_frame, - proc_number, - max_proc) -{ - this->vtkData = vtkSmartPointer::New(); - this->vtkData->Modified(); -} - -//---------------------------------------------------------------------------- -RESQML2_NS::WellboreMarkerFrameRepresentation * ResqmlWellboreMarkerFrameToVtkPartitionedDataSet::getResqmlData() const -{ - return static_cast(resqmlData); -} - -//---------------------------------------------------------------------------- -void ResqmlWellboreMarkerFrameToVtkPartitionedDataSet::loadVtkObject() -{ - for (int idx = 0; idx < this->list_marker.size(); ++idx) - { - this->vtkData->SetPartition(idx, this->list_marker[idx]->getOutput()->GetPartitionAsDataObject(0)); - this->vtkData->GetMetaData(idx)->Set(vtkCompositeDataSet::NAME(), this->list_marker[idx]->getTitle().c_str()); - } -} - -//---------------------------------------------------------------------------- -void ResqmlWellboreMarkerFrameToVtkPartitionedDataSet::addMarker(std::string marker_uuid, bool orientation, int size) -{ - bool exist = false; - for (int idx = 0; idx < this->list_marker.size(); ++idx) - { - if (this->list_marker[idx]->getUuid() == marker_uuid) - { - auto old_size = this->list_marker[idx]->getMarkerSize(); - auto old_orientation = this->list_marker[idx]->getMarkerOrientation(); - if (this->list_marker[idx]->getMarkerOrientation() != orientation || this->list_marker[idx]->getMarkerSize() != size) - { - this->list_marker[idx]->displayOption(orientation, size); - this->loadVtkObject(); - } - exist = true; - } - } - if (!exist) - { - this->list_marker.push_back(new ResqmlWellboreMarkerToVtkPolyData(getResqmlData(), marker_uuid, orientation, size)); - this->loadVtkObject(); - } -} - -//---------------------------------------------------------------------------- -void ResqmlWellboreMarkerFrameToVtkPartitionedDataSet::removeMarker(std::string marker_uuid) -{ - this->vtkData = vtkSmartPointer::New(); - for (auto it = this->list_marker.begin(); it != this->list_marker.end();) - { - ResqmlWellboreMarkerToVtkPolyData *marker = *it; - if (marker->getUuid() == marker_uuid) - { - this->vtkData = vtkSmartPointer::New(); - it = this->list_marker.erase(it); - } - else - { - ++it; - } - } - this->loadVtkObject(); -} diff --git a/Plugin/Energistics/Tools/enum.h b/Plugin/Energistics/Tools/enum.h new file mode 100644 index 0000000..cfa0450 --- /dev/null +++ b/Plugin/Energistics/Tools/enum.h @@ -0,0 +1,51 @@ +/*----------------------------------------------------------------------- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"; you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +-----------------------------------------------------------------------*/ + +#ifndef ENUM_H +#define ENUM_H + +#include + +enum class MapperType +{ + Folder, + Data, + Mapper, + MapperSet +}; + +enum class TreeViewNodeType +{ + Unknown, + Collection, + Representation, + SubRepresentation, + Properties, + Wellbore, + WellboreTrajectory, + WellboreFrame, + WellboreChannel, + WellboreMarkerFrame, + WellboreMarker, + WellboreCompletion, + TimeSeries, + Perforation +}; + +#endif // ENUM_H diff --git a/Plugin/Energistics/vtk.module b/Plugin/Energistics/vtk.module index e3c4a55..84f8910 100644 --- a/Plugin/Energistics/vtk.module +++ b/Plugin/Energistics/vtk.module @@ -3,12 +3,15 @@ NAME LIBRARY_NAME Energistics DEPENDS + ParaView::RemotingServerManager VTK::CommonCore VTK::CommonDataModel VTK::CommonExecutionModel VTK::CommonTransforms + VTK::CommonSystem VTK::FiltersGeneral VTK::FiltersSources VTK::ParallelCore + VTK::RenderingCore PRIVATE_DEPENDS VTK::vtksys diff --git a/Plugin/Energistics/vtkEPCReader.cxx b/Plugin/Energistics/vtkEPCReader.cxx index 0620d71..735849f 100644 --- a/Plugin/Energistics/vtkEPCReader.cxx +++ b/Plugin/Energistics/vtkEPCReader.cxx @@ -21,6 +21,7 @@ under the License. #include #include #include +#include #include #include @@ -45,7 +46,7 @@ vtkEPCReader::vtkEPCReader() : Files(vtkStringArray::New()), SetNumberOfInputPorts(0); SetNumberOfOutputPorts(1); - this->SetController(vtkMultiProcessController::GetGlobalController()); + SetController(vtkMultiProcessController::GetGlobalController()); } //---------------------------------------------------------------------------- @@ -53,7 +54,7 @@ void vtkEPCReader::AddFileNameToFiles(const char *fname) { if (fname != nullptr) { - this->Files->InsertNextValue(fname); + Files->InsertNextValue(fname); } } @@ -65,9 +66,9 @@ void vtkEPCReader::ClearFileName() //---------------------------------------------------------------------------- const char *vtkEPCReader::GetFileName(int index) const { - if (this->Files->GetNumberOfValues() > index) + if (Files->GetNumberOfValues() > index) { - return this->Files->GetValue(index).c_str(); + return Files->GetValue(index).c_str(); } return nullptr; } @@ -75,22 +76,22 @@ const char *vtkEPCReader::GetFileName(int index) const //---------------------------------------------------------------------------- size_t vtkEPCReader::GetNumberOfFileNames() const { - return this->Files->GetNumberOfValues(); + return Files->GetNumberOfValues(); } //------------------------------------------------------------------------------ vtkStringArray *vtkEPCReader::GetAllFiles() // call only by GUI { - if (this->Files->GetNumberOfValues() > 0) + if (Files->GetNumberOfValues() > 0) { - for (auto index = 0; index < this->Files->GetNumberOfValues(); index++) + for (auto index = 0; index < Files->GetNumberOfValues(); index++) { - auto file_property = this->Files->GetValue(index); - auto search = this->FileNamesLoaded.find(file_property); - if (search == this->FileNamesLoaded.end()) + auto file_property = Files->GetValue(index); + auto search = FileNamesLoaded.find(file_property); + if (search == FileNamesLoaded.end()) { - std::string msg = this->repository.addFile(file_property.c_str()); - this->FileNamesLoaded.insert(file_property); + std::string msg = repository.addFile(file_property.c_str()); + FileNamesLoaded.insert(file_property); // add selector for (auto selector : selectorNotLoaded) { @@ -100,17 +101,17 @@ vtkStringArray *vtkEPCReader::GetAllFiles() // call only by GUI } } - if (this->Controller->GetLocalProcessId() == 0 && !msg.empty()) + if (Controller->GetLocalProcessId() == 0 && !msg.empty()) { vtkWarningMacro(<< msg); } - this->AssemblyTag++; - this->Modified(); - this->Update(); + AssemblyTag++; + Modified(); + Update(); } } } - return this->Files; + return Files; } //------------------------------------------------------------------------------ @@ -120,9 +121,9 @@ void vtkEPCReader::SetFiles(const std::string &file) if (file != "0") { bool exist = false; - for (auto index = 0; index < this->Files->GetNumberOfValues(); ++index) + for (auto index = 0; index < Files->GetNumberOfValues(); ++index) { - auto file_property = this->Files->GetValue(index); + auto file_property = Files->GetValue(index); if (file_property == file) { exist = true; @@ -130,19 +131,19 @@ void vtkEPCReader::SetFiles(const std::string &file) } if (!exist) { - this->Files->InsertNextValue(file); + Files->InsertNextValue(file); } } - if (this->Controller->GetLocalProcessId() > 0) // pvserver without GUI + if (Controller->GetLocalProcessId() > 0) // pvserver without GUI { - this->GetAllFiles(); + GetAllFiles(); } } //---------------------------------------------------------------------------- bool vtkEPCReader::AddSelector(const char *path) { - if (path != nullptr && this->selectors.insert(path).second) + if (path != nullptr && selectors.insert(path).second) { int node_id = GetAssembly()->GetFirstNodeByPath(path); @@ -152,7 +153,7 @@ bool vtkEPCReader::AddSelector(const char *path) } else { - this->repository.selectNodeId(node_id); + repository.selectNodeId(node_id); /* if (GetAssembly()->HasAttribute(node_id, "traj")) { @@ -169,11 +170,11 @@ bool vtkEPCReader::AddSelector(const char *path) //---------------------------------------------------------------------------- void vtkEPCReader::ClearSelectors() { - this->repository.clearSelection(); - if (!this->selectors.empty()) + repository.clearSelection(); + if (!selectors.empty()) { - this->selectors.clear(); - this->Modified(); + selectors.clear(); + Modified(); } } @@ -190,8 +191,8 @@ int vtkEPCReader::GetNumberOfSelectors() const //---------------------------------------------------------------------------- void vtkEPCReader::SetSelector(const char *selector) { - this->ClearSelectors(); - this->AddSelector(selector); + ClearSelectors(); + AddSelector(selector); Modified(); } @@ -199,9 +200,9 @@ void vtkEPCReader::SetSelector(const char *selector) //---------------------------------------------------------------------------- const char *vtkEPCReader::GetSelector(int index) const { - if (index >= 0 && index < this->GetNumberOfSelectors()) + if (index >= 0 && index < GetNumberOfSelectors()) { - auto iter = std::next(this->selectors.begin(), index); + auto iter = std::next(selectors.begin(), index); return iter->c_str(); } return nullptr; @@ -210,15 +211,15 @@ const char *vtkEPCReader::GetSelector(int index) const //---------------------------------------------------------------------------- void vtkEPCReader::setMarkerOrientation(bool orientation) { - this->repository.setMarkerOrientation(orientation); - this->Modified(); + repository.setMarkerOrientation(orientation); + Modified(); } //---------------------------------------------------------------------------- void vtkEPCReader::setMarkerSize(int size) { - this->repository.setMarkerSize(size); - this->Modified(); + repository.setMarkerSize(size); + Modified(); } //---------------------------------------------------------------------------- @@ -227,22 +228,22 @@ int vtkEPCReader::RequestData(vtkInformation *, vtkInformationVector *outputVector) { // Load state (load selection in wait) - if (this->selectorNotLoaded.size() > 0) + if (selectorNotLoaded.size() > 0) { - for (auto path : this->selectorNotLoaded) + for (auto path : selectorNotLoaded) { int node_id = GetAssembly()->GetFirstNodeByPath(path.c_str()); if (node_id > -1) { - this->repository.selectNodeId(node_id); - this->selectorNotLoaded.erase(path); + repository.selectNodeId(node_id); + selectorNotLoaded.erase(path); } } } auto *outInfo = outputVector->GetInformationObject(0); outInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); - const std::vector times = this->repository.getTimes(); + const std::vector times = repository.getTimes(); if (times.size() > (std::numeric_limits::max)()) { @@ -262,7 +263,7 @@ int vtkEPCReader::RequestData(vtkInformation *, try { - vtkPartitionedDataSetCollection::GetData(outInfo)->DeepCopy(this->repository.getVtkPartitionedDatasSetCollection(requestedTimeStep, this->Controller->GetNumberOfProcesses(), this->Controller->GetLocalProcessId())); + vtkPartitionedDataSetCollection::GetData(outInfo)->DeepCopy(repository.getVtkPartitionedDatasSetCollection(requestedTimeStep, Controller->GetNumberOfProcesses(), Controller->GetLocalProcessId())); } catch (const std::exception &e) { @@ -275,7 +276,7 @@ int vtkEPCReader::RequestData(vtkInformation *, //---------------------------------------------------------------------------- void vtkEPCReader::PrintSelf(ostream &os, vtkIndent indent) { - this->Superclass::PrintSelf(os, indent); + Superclass::PrintSelf(os, indent); } //---------------------------------------------------------------------------- @@ -283,7 +284,7 @@ vtkDataAssembly *vtkEPCReader::GetAssembly() { try { - return this->repository.GetAssembly(); + return repository.GetAssembly(); } catch (const std::exception &e) { diff --git a/Plugin/Energistics/vtkEPCReader.h b/Plugin/Energistics/vtkEPCReader.h index 9c44017..0dd7ba0 100644 --- a/Plugin/Energistics/vtkEPCReader.h +++ b/Plugin/Energistics/vtkEPCReader.h @@ -28,7 +28,7 @@ under the License. #include #include "EnergisticsModule.h" -#include "ResqmlMapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h" +#include "Mapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h" class vtkDataAssembly; class vtkProperty; @@ -143,6 +143,7 @@ class ENERGISTICS_EXPORT vtkEPCReader : public vtkPartitionedDataSetCollectionA // files vtkSmartPointer Files; + char* FileName; std::set FilesList; std::set FileNamesLoaded; diff --git a/Plugin/Energistics/vtkETPSource.cxx b/Plugin/Energistics/vtkETPSource.cxx index fc2f470..fcc622a 100644 --- a/Plugin/Energistics/vtkETPSource.cxx +++ b/Plugin/Energistics/vtkETPSource.cxx @@ -21,6 +21,7 @@ under the License. #include #include #include +#include #include #include @@ -104,11 +105,11 @@ void vtkETPSource::confirmConnectionClicked() try { const auto dataspaces = this->repository.connect(this->ETPUrl, this->DataPartition, this->Authentification + " " + this->AuthPwd); - this->AllDataspaces->InsertNextValue(vtkStdString("")); for (const std::string dataspace : dataspaces) { this->AllDataspaces->InsertNextValue(vtkStdString(dataspace)); } + this->AllDataspaces->InsertNextValue(vtkStdString("eml:///")); this->ConnectionTag = 0; this->DisconnectionTag = 1; diff --git a/Plugin/Energistics/vtkETPSource.h b/Plugin/Energistics/vtkETPSource.h index 58d37a0..f9d9bc1 100644 --- a/Plugin/Energistics/vtkETPSource.h +++ b/Plugin/Energistics/vtkETPSource.h @@ -28,7 +28,7 @@ under the License. #include #include "EnergisticsModule.h" -#include "ResqmlMapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h" +#include "Mapping/ResqmlDataRepositoryToVtkPartitionedDataSetCollection.h" class vtkDataAssembly; class vtkMultiProcessController; diff --git a/Plugin/paraview.plugin b/Plugin/paraview.plugin index 273e355..8bc3f78 100644 --- a/Plugin/paraview.plugin +++ b/Plugin/paraview.plugin @@ -3,8 +3,14 @@ NAME DESCRIPTION F2i-consulting Energistics Standard Paraview Plugin Reader REQUIRES_MODULES - ParaView::pqComponents - ParaView::pqCore - VTK::CommonSystem + ParaView::RemotingServerManager VTK::CommonCore - \ No newline at end of file + VTK::CommonDataModel + VTK::CommonExecutionModel + VTK::CommonTransforms + VTK::CommonSystem + VTK::FiltersGeneral + VTK::FiltersSources + VTK::ParallelCore + VTK::RenderingCore + VTK::vtksys \ No newline at end of file diff --git a/README.md b/README.md index cff4b78..cf247b1 100644 --- a/README.md +++ b/README.md @@ -3,27 +3,32 @@ - If you want to build Fespp by your own, look below for instructions. ## BUILD dependencies -- [FESAPI v2.5.0.0](https://github.com/F2I-Consulting/fesapi/releases/tag/v2.5.0.0) +- [FESAPI v2.9.0.0](https://github.com/F2I-Consulting/fesapi/releases/tag/v2.9.0.0) - ParaView with same HDF5 libraries used by FESAPI > known to work on Linux and Windows starting from ParaView 5.10.0 ## BUILD & INSTALL Fespp 1. **CONFIGURE** Fespp with CMAKE You should fill in the following variables - * FESAPI_INCLUDE_DIR = path_to_FESAPI_install/include - * FESAPI_LIBRARY_RELEASE = path_to_FESAPI_install/lib/libFesapiCpp.so - * ParaView_DIR = path_to_paraview_build + - FESAPI_ROOT : The path to the folder containing include and lib folders of FESAPI v2.9.0.0 as a minimal version (using [our own cmake find module](./cmake/modules/FindFESAPI.cmake)) + - ParaView_DIR = path_to_paraview_build + - OPTIONALLY, for (experimental) ETP support, you will need FETPAPI (v0.1.0.0 as a minimal version) support (see [here](https://github.com/F2I-Consulting/fetpapi) for documentation on how to build fetpapi). Please enable the WITH_ETP_SSL variable and usually set the following variables : + - FETPAPI_INCLUDE_DIR = path_to_FETPAPI_install/include + - FETPAPI_LIBRARY_RELEASE = path_to_FETPAPI_install/lib/libFetpapiCpp.so + - FETPAPI_LIBRARY_DEBUG = path_to_FETPAPI_install/lib/libFeetpapiCppd.so + - (ONLY IF NOT AUTOMATICALLY FOUND) Boost_INCLUDE_DIR : the directory where you can find the directory named "boost" which contain all BOOST headers + - (ONLY IF NOT AUTOMATICALLY FOUND) AVRO_ROOT : The path to the folder containing include and lib folders of AVRO (we use [our own cmake find module](./cmake/modules/FindAVRO.cmake)) 2. **GENERATE** the build solution with CMAKE once the CONFIGURE step is OK 3. **BUILD** and **INSTALL** the solution generated by CMAKE 4. **COPY** fespp_install_lib/paraview-5.11/plugins/Fespp directory into paraview_install/Plugins/Fespp plus - in the paraview_install/Plugins/Fespp folder on Linux: - libFesapiCpp.so (from FESAPI install lib directory) - - libFesapiCpp.so.2.5 (from FESAPI install lib directory) - - libFesapiCpp.so.2.5.0.0 (from FESAPI install lib directory) + - libFesapiCpp.so.2.9 (from FESAPI install lib directory) + - libFesapiCpp.so.2.9.0.0 (from FESAPI install lib directory) - in the paraview_install\Plugins\Fespp folder on Windows: - - FesapiCpp.2.5.0.0.dll (from FESAPI install) + - FesapiCpp.2.9.0.0.dll (from FESAPI install) - **Note 1** : If they exist (which probably not), you also need to copy FESAPI dependencies in this paraview_install\Plugins\Fespp folder. Or to put them in the (LD_LIBRARY_)PATH. - **Note 2** : On Linux at least, you need to build Paraview with VTK_MODULE_USE_EXTERNAL_VTK_hdf5=ON and VTK_MODULE_USE_EXTERNAL_VTK_zlib=ON for using the same HDF5 libraries in PV and Fespp. We use statically link HDF5 with FESAPI for our Windows build. diff --git a/cmake/modules/FindAVRO.cmake b/cmake/modules/FindAVRO.cmake new file mode 100644 index 0000000..fafa406 --- /dev/null +++ b/cmake/modules/FindAVRO.cmake @@ -0,0 +1,108 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +AVRO +-------- + +Find the native AVRO includes and library. +Heavily inspired by the official FindZLIB cmake module v3.27. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``AVRO::AVRO``, if +AVRO has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + AVRO_INCLUDE_DIRS - where to find zip.h, unzip.h, etc. + AVRO_LIBRARIES - List of libraries when using avro. + AVRO_FOUND - True if avro found. + +Hints +^^^^^ + +A user may set ``AVRO_ROOT`` to a avro installation root to tell this +module where to look. +#]=======================================================================] +include(SelectLibraryConfigurations) + +set(_AVRO_SEARCHES) + +# Search AVRO_ROOT first if it is set. +if(AVRO_ROOT) + set(_AVRO_SEARCH_ROOT PATHS ${AVRO_ROOT} NO_DEFAULT_PATH) + list(APPEND _AVRO_SEARCHES _AVRO_SEARCH_ROOT) +endif() + +# Normal search. +set(_AVRO_x86 "(x86)") +set(_AVRO_SEARCH_NORMAL + PATHS "$ENV{ProgramFiles}/avro" + "$ENV{ProgramFiles${_AVRO_x86}}/avro") +unset(_AVRO_x86) +list(APPEND _AVRO_SEARCHES _AVRO_SEARCH_NORMAL) + +set(AVRO_NAMES avrocpp avrocpp_s) +set(AVRO_NAMES_DEBUG avrod avrocpp_d avrocpp_s_d) + +# Try each search configuration. +foreach(search ${_AVRO_SEARCHES}) + find_path(AVRO_INCLUDE_DIR NAMES avro/AvroParse.hh ${${search}} PATH_SUFFIXES include) +endforeach() + +# Allow AVRO_LIBRARY to be set manually, as the location of the zlib library +if(NOT AVRO_LIBRARY) + foreach(search ${_AVRO_SEARCHES}) + find_library(AVRO_LIBRARY_RELEASE NAMES ${AVRO_NAMES} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib) + find_library(AVRO_LIBRARY_DEBUG NAMES ${AVRO_NAMES_DEBUG} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib) + endforeach() + + select_library_configurations(AVRO) +endif() + +unset(AVRO_NAMES) +unset(AVRO_NAMES_DEBUG) + +mark_as_advanced(AVRO_INCLUDE_DIR) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(AVRO REQUIRED_VARS AVRO_LIBRARY AVRO_INCLUDE_DIR) + +if(AVRO_FOUND) + set(AVRO_INCLUDE_DIRS ${AVRO_INCLUDE_DIR}) + + if(NOT AVRO_LIBRARIES) + set(AVRO_LIBRARIES ${AVRO_LIBRARY}) + endif() + + if(NOT TARGET AVRO::AVRO) + add_library(AVRO::AVRO UNKNOWN IMPORTED) + set_target_properties(AVRO::AVRO PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${AVRO_INCLUDE_DIRS}") + + if(AVRO_LIBRARY_RELEASE) + set_property(TARGET AVRO::AVRO APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(AVRO::AVRO PROPERTIES + IMPORTED_LOCATION_RELEASE "${AVRO_LIBRARY_RELEASE}") + endif() + + if(AVRO_LIBRARY_DEBUG) + set_property(TARGET AVRO::AVRO APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(AVRO::AVRO PROPERTIES + IMPORTED_LOCATION_DEBUG "${AVRO_LIBRARY_DEBUG}") + endif() + + if(NOT AVRO_LIBRARY_RELEASE AND NOT AVRO_LIBRARY_DEBUG) + set_property(TARGET AVRO::AVRO APPEND PROPERTY + IMPORTED_LOCATION "${AVRO_LIBRARY}") + endif() + endif() +endif() diff --git a/cmake/modules/FindFESAPI.cmake b/cmake/modules/FindFESAPI.cmake new file mode 100644 index 0000000..8fab65c --- /dev/null +++ b/cmake/modules/FindFESAPI.cmake @@ -0,0 +1,118 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FESAPI +-------- + +Find the native FESAPI includes and library. +Heavily inspired by the official FindZLIB cmake module v3.27. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``FESAPI::FESAPI``, if +FESAPI has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +:: + + FESAPI_INCLUDE_DIRS - where to find zip.h, unzip.h, etc. + FESAPI_LIBRARIES - List of libraries when using fesapi. + FESAPI_FOUND - True if fesapi found. + +Hints +^^^^^ + +A user may set ``FESAPI_ROOT`` to a fesapi installation root to tell this +module where to look. +#]=======================================================================] +include(SelectLibraryConfigurations) + +set(_FESAPI_SEARCHES) + +# Search FESAPI_ROOT first if it is set. +if(FESAPI_ROOT) + set(_FESAPI_SEARCH_ROOT PATHS ${FESAPI_ROOT} NO_DEFAULT_PATH) + list(APPEND _FESAPI_SEARCHES _FESAPI_SEARCH_ROOT) +endif() + +# Normal search. +set(_FESAPI_x86 "(x86)") +set(_FESAPI_SEARCH_NORMAL + PATHS "$ENV{ProgramFiles}/fesapi" + "$ENV{ProgramFiles${_FESAPI_x86}}/fesapi") +unset(_FESAPI_x86) +list(APPEND _FESAPI_SEARCHES _FESAPI_SEARCH_NORMAL) + +# On Windows, library names contain the version +# The maximum of ranges are defined totally arbitrarily +set(FESAPI_NAMES FesapiCpp) +set(FESAPI_NAMES_DEBUG FesapiCppd) +foreach(minorVer RANGE 9 17) + foreach(patchVer RANGE 0 5) + foreach(tweakVer RANGE 0 5) + list(APPEND FESAPI_NAMES FesapiCpp.2.${minorVer}.${patchVer}.${tweakVer}) + list(APPEND FESAPI_NAMES_DEBUG FesapiCppd.2.${minorVer}.${patchVer}.${tweakVer}) + endforeach() + endforeach() +endforeach() + +# Try each search configuration. +foreach(search ${_FESAPI_SEARCHES}) + find_path(FESAPI_INCLUDE_DIR NAMES fesapi/common/DataObjectRepository.h ${${search}} PATH_SUFFIXES include) +endforeach() + +# Allow FESAPI_LIBRARY to be set manually, as the location of the zlib library +if(NOT FESAPI_LIBRARY) + foreach(search ${_FESAPI_SEARCHES}) + find_library(FESAPI_LIBRARY_RELEASE NAMES ${FESAPI_NAMES} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib) + find_library(FESAPI_LIBRARY_DEBUG NAMES ${FESAPI_NAMES_DEBUG} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib) + endforeach() + + select_library_configurations(FESAPI) +endif() + +unset(FESAPI_NAMES) +unset(FESAPI_NAMES_DEBUG) + +mark_as_advanced(FESAPI_INCLUDE_DIR) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(FESAPI REQUIRED_VARS FESAPI_LIBRARY FESAPI_INCLUDE_DIR) + +if(FESAPI_FOUND) + set(FESAPI_INCLUDE_DIRS ${FESAPI_INCLUDE_DIR}) + + if(NOT FESAPI_LIBRARIES) + set(FESAPI_LIBRARIES ${FESAPI_LIBRARY}) + endif() + + if(NOT TARGET FESAPI::FESAPI) + add_library(FESAPI::FESAPI UNKNOWN IMPORTED) + set_target_properties(FESAPI::FESAPI PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${FESAPI_INCLUDE_DIRS}") + + if(FESAPI_LIBRARY_RELEASE) + set_property(TARGET FESAPI::FESAPI APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(FESAPI::FESAPI PROPERTIES + IMPORTED_LOCATION_RELEASE "${FESAPI_LIBRARY_RELEASE}") + endif() + + if(FESAPI_LIBRARY_DEBUG) + set_property(TARGET FESAPI::FESAPI APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(FESAPI::FESAPI PROPERTIES + IMPORTED_LOCATION_DEBUG "${FESAPI_LIBRARY_DEBUG}") + endif() + + if(NOT FESAPI_LIBRARY_RELEASE AND NOT FESAPI_LIBRARY_DEBUG) + set_property(TARGET FESAPI::FESAPI APPEND PROPERTY + IMPORTED_LOCATION "${FESAPI_LIBRARY}") + endif() + endif() +endif()