Skip to content

Commit

Permalink
Add IOOCCT feature to VTK.
Browse files Browse the repository at this point in the history
  • Loading branch information
larshg committed May 24, 2024
1 parent 59aeb8f commit 212fe12
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 2 deletions.
83 changes: 83 additions & 0 deletions ports/vtk/opencascade-7.8.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
diff --git a/IO/OCCT/CMakeLists.txt b/IO/OCCT/CMakeLists.txt
index e81444eceb..4baddeb719 100644
--- a/IO/OCCT/CMakeLists.txt
+++ b/IO/OCCT/CMakeLists.txt
@@ -4,12 +4,25 @@ vtk_module_find_package(PRIVATE_IF_SHARED
VERSION_VAR "@OpenCASCADE_MAJOR_VERSION@.@OpenCASCADE_MINOR_VERSION@.@OpenCASCADE_MAINTENANCE_VERSION@"
)

-set(opencascade_req_targets
- TKSTEP
- TKIGES
- TKMesh
- TKXDESTEP
- TKXDEIGES)
+if (OpenCASCADE_VERSION VERSION_GREATER_EQUAL "7.8.0")
+ set(opencascade_req_targets
+ TKDESTEP
+ TKDEIGES
+ TKernel
+ TKMath
+ TKMesh
+ TKBRep
+ TKXSBase
+ TKLCAF
+ TKXCAF)
+else()
+ set(opencascade_req_targets
+ TKSTEP
+ TKIGES
+ TKMesh
+ TKXDESTEP
+ TKXDEIGES)
+endif()
set(opencascade_missing_targets)
foreach (opencascade_req_target IN LISTS opencascade_req_targets)
if (NOT TARGET "${opencascade_req_target}")
@@ -35,8 +48,7 @@ vtk_module_link(VTK::IOOCCT
${opencascade_req_targets})

# OpenCASCADE started putting include directory usage requirements in 7.7.0.
-set(OpenCASCADE_VERSION
- "${OpenCASCADE_MAJOR_VERSION}.${OpenCASCADE_MINOR_VERSION}.${OpenCASCADE_MAINTENANCE_VERSION}")
+
if (OpenCASCADE_VERSION VERSION_LESS "7.7.0")
vtk_module_include(VTK::IOOCCT PRIVATE "${OpenCASCADE_INCLUDE_DIR}")
endif ()
diff --git a/IO/OCCT/vtkOCCTReader.cxx b/IO/OCCT/vtkOCCTReader.cxx
index 52e76be72c..5aca5c93c8 100644
--- a/IO/OCCT/vtkOCCTReader.cxx
+++ b/IO/OCCT/vtkOCCTReader.cxx
@@ -345,11 +345,19 @@ public:
}

//----------------------------------------------------------------------------
+#if VTK_OCCT_VERSION(7, 8, 0) <= OCC_VERSION_HEX
+ size_t GetHash(const TDF_Label& label)
+ {
+ TopoDS_Shape aShape;
+ return this->ShapeTool->GetShape(label, aShape) ? std::hash<TopoDS_Shape>{}(aShape) : 0;
+ }
+#else
int GetHash(const TDF_Label& label)
{
TopoDS_Shape aShape;
return this->ShapeTool->GetShape(label, aShape) ? aShape.HashCode(INT_MAX) : 0;
}
+#endif

//----------------------------------------------------------------------------
static void GetMatrix(const TopLoc_Location& loc, vtkMatrix4x4* mat)
@@ -381,8 +389,11 @@ public:
GetMatrix(hLoc->Get(), location);
}
}
-
+#if VTK_OCCT_VERSION(7, 8, 0) <= OCC_VERSION_HEX
+ std::unordered_map<size_t, vtkSmartPointer<vtkPolyData>> ShapeMap;
+#else
std::unordered_map<int, vtkSmartPointer<vtkPolyData>> ShapeMap;
+#endif
Handle(XCAFDoc_ShapeTool) ShapeTool;
Handle(XCAFDoc_ColorTool) ColorTool;

2 changes: 2 additions & 0 deletions ports/vtk/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ vcpkg_from_github(
10945.diff
10972.diff
hdf5helper.patch
opencascade-7.8.0.patch
)

# =============================================================================
Expand Down Expand Up @@ -121,6 +122,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS VTK_FEATURE_OPTIONS
"openvr" VTK_MODULE_ENABLE_VTK_RenderingOpenVR
"gdal" VTK_MODULE_ENABLE_VTK_IOGDAL
"geojson" VTK_MODULE_ENABLE_VTK_IOGeoJSON
"ioocct" VTK_MODULE_ENABLE_VTK_IOOCCT
)

# Replace common value to vtk value
Expand Down
11 changes: 10 additions & 1 deletion ports/vtk/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vtk",
"version-semver": "9.3.0-pv5.12.0",
"port-version": 3,
"port-version": 4,
"description": "Software system for 3D computer graphics, image processing, and visualization",
"homepage": "https://github.com/Kitware/VTK",
"license": "BSD-3-Clause",
Expand Down Expand Up @@ -117,6 +117,15 @@
"geojson": {
"description": "Convert Geo JSON format to vtkPolyData"
},
"ioocct": {
"description": "Build with IOOCCT module",
"dependencies": [
{
"name": "opencascade",
"default-features": false
}
]
},
"mpi": {
"description": "MPI functionality for VTK",
"dependencies": [
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -9214,7 +9214,7 @@
},
"vtk": {
"baseline": "9.3.0-pv5.12.0",
"port-version": 3
"port-version": 4
},
"vtk-dicom": {
"baseline": "0.8.14",
Expand Down
5 changes: 5 additions & 0 deletions versions/v-/vtk.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "679af6f82484acf134c028480564699523c988ed",
"version-semver": "9.3.0-pv5.12.0",
"port-version": 4
},
{
"git-tree": "0bb2f77c2eeff358d3be93b1d5f0d006573137b7",
"version-semver": "9.3.0-pv5.12.0",
Expand Down

0 comments on commit 212fe12

Please sign in to comment.