Skip to content

Commit

Permalink
Added initial project.
Browse files Browse the repository at this point in the history
  • Loading branch information
acdemiralp committed Dec 25, 2021
1 parent b1b8f6d commit b3aa6ca
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Binaries/*
Intermediate/*
Source/ThirdParty/VTK/Public/*
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

Binary file added Resources/Icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions Source/ThirdParty/VTK/VTK.Build.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.IO;
using UnrealBuildTool;

public class VTK : ModuleRules
{
public VTK(ReadOnlyTargetRules target) : base(target)
{
Type = ModuleType.External;

PublicIncludePaths.Add(Path.Combine(PluginDirectory, "Source", "ThirdParty", "VTK", "Public"));

if (target.Platform == UnrealTargetPlatform.Win64)
{
foreach (var value in Directory.EnumerateFiles(Path.Combine(PluginDirectory, "Intermediate", "ThirdParty", "VTK", "Win64"), "*.lib" , SearchOption.AllDirectories))
{
PublicAdditionalLibraries.Add(value);
}
foreach (var value in Directory.EnumerateFiles(Path.Combine(PluginDirectory, "Binaries" , "ThirdParty", "VTK", "Win64"), "*.dll" , SearchOption.AllDirectories))
{
PublicDelayLoadDLLs .Add(value);
RuntimeDependencies .Add(value);
}
}
else if (target.Platform == UnrealTargetPlatform.Mac )
{
foreach (var value in Directory.EnumerateFiles(Path.Combine(PluginDirectory, "Intermediate", "ThirdParty", "VTK", "Mac" ), "*.dylib", SearchOption.AllDirectories))
{
PublicDelayLoadDLLs .Add(value);
RuntimeDependencies .Add(value);
}
}
else if (target.Platform == UnrealTargetPlatform.Linux)
{
foreach (var value in Directory.EnumerateFiles(Path.Combine(PluginDirectory, "Intermediate", "ThirdParty", "VTK", "Linux"), "*.so" , SearchOption.AllDirectories))
{
PublicAdditionalLibraries.Add(value);
PublicDelayLoadDLLs .Add(value);
RuntimeDependencies .Add(value);
}
}
}
}
40 changes: 40 additions & 0 deletions Source/VTKPlugin/Private/VTKPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "VTKPlugin.h"
#include "Core.h"
#include "Modules/ModuleManager.h"
#include "Interfaces/IPluginManager.h"

#include "vtkPolyData.h"

#define LOCTEXT_NAMESPACE "FVTKPluginModule"

void FVTKPluginModule::StartupModule ()
{
#if PLATFORM_WINDOWS
const FString BaseDir = IPluginManager::Get().FindPlugin("VTKPlugin")->GetBaseDir();
const FString AbsoluteBaseDir = IFileManager ::Get().ConvertToAbsolutePathForExternalAppForRead(*BaseDir);
const FString VTKDir = FPaths::Combine(*AbsoluteBaseDir, TEXT("/Binaries/ThirdParty/VTK/Win64/"));
const FString Filter = FPaths::Combine(VTKDir, TEXT("*.dll"));

TArray<FString> Files;
IFileManager::Get().FindFiles(Files, *Filter, true, false);
while (Files.Num() != DynamicLinkLibraries.Num()) // Since the order of DLLs are unknown, try repeatedly until all are loaded.
{
for (auto& File : Files)
{
const FString Path = FPaths::Combine(VTKDir, File);
auto Dll = FPlatformProcess::GetDllHandle(*Path);
if (Dll && !DynamicLinkLibraries.Contains(Dll))
DynamicLinkLibraries.Add(Dll);
}
}
#endif
}
void FVTKPluginModule::ShutdownModule()
{
for (const auto& Library : DynamicLinkLibraries)
FPlatformProcess::FreeDllHandle(Library);
}

#undef LOCTEXT_NAMESPACE

IMPLEMENT_MODULE(FVTKPluginModule, VTKPlugin)
14 changes: 14 additions & 0 deletions Source/VTKPlugin/Public/VTKPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "Modules/ModuleManager.h"
#include "Runtime/Core/Public/Containers/Array.h"

class FVTKPluginModule : public IModuleInterface
{
public:
virtual void StartupModule () override;
virtual void ShutdownModule() override;

private:
TArray<void*> DynamicLinkLibraries;
};
11 changes: 11 additions & 0 deletions Source/VTKPlugin/VTKPlugin.Build.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnrealBuildTool;

public class VTKPlugin : ModuleRules
{
public VTKPlugin(ReadOnlyTargetRules target) : base(target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

PublicDependencyModuleNames.AddRange(new[] {"Core", "Projects", "VTK"});
}
}
25 changes: 25 additions & 0 deletions VTKPlugin.uplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"FileVersion" : 3,
"Version" : 1,
"VersionName" : "1.0",
"FriendlyName" : "VTKPlugin",
"Description" : "A plugin that downloads, builds, installs and links VTK to UE.",
"Category" : "Other",
"CreatedBy" : "acdemiralp",
"CreatedByURL" : "",
"DocsURL" : "",
"MarketplaceURL" : "",
"SupportURL" : "",
"CanContainContent" : true ,
"IsBetaVersion" : false,
"IsExperimentalVersion": false,
"Installed" : false,
"Modules":
[
{
"Name" : "VTKPlugin",
"Type" : "Runtime" ,
"LoadingPhase": "Default"
}
]
}
36 changes: 36 additions & 0 deletions install_vtk.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@echo off
setlocal enabledelayedexpansion

set INITIAL_DIR=%CD%
cd /d "%~dp0"

mkdir Temporary
cd Temporary

curl -L "https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-windows-x86_64.zip" -o download.zip
tar -xf download.zip
del download.zip
move cmake-3.22.1-windows-x86_64 CMake

curl -L "https://github.com/Kitware/VTK/archive/refs/tags/v9.1.0.zip" -o download.zip
tar -xf download.zip
del download.zip
move VTK-9.1.0 VTK

cd VTK
mkdir Build
mkdir Install
cd Build
..\..\CMake\bin\cmake .. -DVTK_GROUP_ENABLE_Rendering=NO
..\..\CMake\bin\cmake --build . --config Release --parallel 32
..\..\CMake\bin\cmake --install . --prefix ..\Install

cd ..
xcopy /s Install\include\vtk-9.1 ..\..\Source\ThirdParty\VTK\Public\
xcopy /s Install\lib ..\..\Intermediate\ThirdParty\VTK\Win64\
xcopy /s Install\bin ..\..\Binaries\ThirdParty\VTK\Win64\

cd ..\..
rmdir /s /q Temporary

cd /d %INITIAL_DIR%
36 changes: 36 additions & 0 deletions install_vtk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash


INITIAL_DIR=$PWD
cd "${0%/*}"

mkdir Temporary
cd Temporary

wget -O download.tar.gz "https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-linux-x86_64.tar.gz"
tar -xf download.tar.gz
rm download.tar.gz
mv cmake-3.22.1-linux-x86_64 CMake

wget -O download.tar.gz "https://github.com/Kitware/VTK/archive/refs/tags/v9.1.0.tar.gz"
tar -xf download.tar.gz
rm download.tar.gz
mv VTK-9.1.0 VTK

cd VTK
mkdir Build
mkdir Install
cd Build
../../CMake/bin/cmake .. -DVTK_GROUP_ENABLE_Rendering=NO
../../CMake/bin/cmake --build . --config Release --parallel 32
../../CMake/bin/cmake --install . --prefix ../Install

cd ..
mkdir -p ../../Source/ThirdParty/VTK/Public && cp -a ./Install/include/vtk-9.1/. "$_"
mkdir -p ../../Intermediate/ThirdParty/VTK/Linux && cp -a ./Install/lib/. "$_"
mkdir -p ../../Binaries/ThirdParty/VTK/Linux && cp -a ./Install/bin/. "$_"

cd ../..
rm -rf Temporary

cd %INITIAL_DIR%
File renamed without changes.
2 changes: 0 additions & 2 deletions readme

This file was deleted.

0 comments on commit b3aa6ca

Please sign in to comment.