-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit - Kotlin sample converted from original Java JNI sample
- Loading branch information
0 parents
commit 8fd4d8a
Showing
42 changed files
with
2,867 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
.gitattributes eol=lf | ||
.gitignore eol=lf | ||
*.gradle eol=lf | ||
*.txt eol=lf | ||
*.h eol=lf | ||
*.c eol=lf | ||
*.cpp eol=lf | ||
*.cxx eol=lf | ||
*.hxx eol=lf | ||
*.lxx eol=lf | ||
*.pxx eol=lf | ||
*.cl eol=lf | ||
*.mm eol=lf | ||
*.i eol=lf | ||
*.el eol=lf | ||
*.sh eol=lf | ||
*.csh eol=lf | ||
*.tcl eol=lf | ||
*.cbp eol=lf | ||
*.svg eol=lf | ||
*.xib eol=lf | ||
*.plist eol=lf | ||
*.java eol=lf | ||
*.igs eol=lf | ||
*.iges eol=lf | ||
*.stp eol=lf | ||
*.step eol=lf | ||
*.brep eol=lf | ||
*.md eol=lf | ||
*.fs eol=lf | ||
*.vs eol=lf | ||
*.glsl eol=lf | ||
*.bat eol=crlf | ||
*.cmd eol=crlf | ||
*.rc eol=crlf | ||
*.cs eol=crlf | ||
*.def eol=crlf | ||
*.ini eol=crlf | ||
*.so binary | ||
*.dylib binary | ||
*.7z binary | ||
*.pdf binary | ||
*.png binary | ||
*.jpg binary | ||
*.bmp binary | ||
*.gif binary | ||
*.xwd binary | ||
*.ico binary | ||
*.icns binary | ||
*.std binary | ||
*.gz binary | ||
*.doc binary | ||
*.mft binary | ||
*.stl binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/.gradle | ||
/.idea | ||
/build | ||
/gradle | ||
gradlew | ||
gradlew.bat | ||
/app/.cxx | ||
/app/build | ||
gradle.properties | ||
local.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Copyright (c) 2021 OPEN CASCADE SAS | ||
|
||
This project is part of the examples of the Open CASCADE Technology software library. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE | ||
include required OCCT headers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
OCCT JniViewer Kotlin sample for Android | ||
================== | ||
|
||
This sample demonstrates simple way of using OCCT libraries in Android application written using Kotlin. | ||
The project has been converted from original Java JNI sample. | ||
|
||
The connection between Kotlin and OCCT (C++) level is provided by proxy library, libTKJniSample.so, written in C++ with exported JNI methods of Kotlin class OcctJniRenderer. | ||
The proxy library contains single C++ class OcctJni_Viewer encapsulating OCCT viewer and providing functionality to manipulate this viewer | ||
and to import OCCT shapes from several supported formats of CAD files (IGES, STEP, BREP). | ||
|
||
This sample demonstrates indirect method of wrapping C++ to Kotlin using manually created proxy library. | ||
|
||
Install Android Studio 4.0+ and building tools (check Tools -> SDK Manager): | ||
- Android SDK (API level 21 or higher). | ||
- Android SDK build tools. | ||
- Android NDK r16 or higher (coming with CMake toolchain). | ||
Using NDK r18 or newer will require changing ANDROID_STL in project settings. | ||
- CMake 3.10+. | ||
|
||
Specify this folder location in Android Studio for opening project. | ||
You might need re-entering Android SDK explicitly in File -> Project Structure -> SDK Location settings (SDK, NDK, JDK locations). | ||
|
||
This sample expects OCCT to be already build - please refer to appropriate CMake building instructions in OCCT documentation. | ||
The following variables should be added into file gradle.properties (see gradle.properties.template as template): | ||
- `OCCT_ROOT` - path to OCCT installation folder. | ||
- `FREETYPE_ROOT` - path to FreeType installation folder. | ||
|
||
FreeImage is optional and does not required for this sample, however you should include all extra libraries used for OCCT building | ||
and load the explicitly from Java code within OcctJniActivity::loadNatives() method, including toolkits from OCCT itself in proper order: | ||
~~~~ | ||
if (!loadLibVerbose ("TKernel", aLoaded, aFailed) | ||
|| !loadLibVerbose ("TKMath", aLoaded, aFailed) | ||
|| !loadLibVerbose ("TKG2d", aLoaded, aFailed) | ||
~~~~ | ||
Note that C++ STL library is not part of Android system, and application must package this library as well as extra component ("gnustl_shared" by default - see also `ANDROID_STL`). | ||
|
||
After successful build via Build -> Rebuild Project, the application can be packaged to Android: | ||
- Deploy and run application on connected device or emulator directly from Android Studio using adb interface by menu items "Run" and "Debug". This would sign package with debug certificate. | ||
- Prepare signed end-user package using wizard Build -> Generate signed APK. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion 21 | ||
buildToolsVersion "30.0.0" | ||
|
||
defaultConfig { | ||
applicationId "com.opencascade.jnisample" | ||
minSdkVersion 21 | ||
targetSdkVersion 26 | ||
|
||
ndk { | ||
abiFilters "arm64-v8a" | ||
} | ||
|
||
externalNativeBuild { | ||
cmake { | ||
arguments "-DOCCT_ROOT=" + OCCT_ROOT, | ||
"-DFREETYPE_ROOT=" + FREETYPE_ROOT, | ||
"-DANDROID_STL=gnustl_shared" | ||
} | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' | ||
} | ||
} | ||
|
||
sourceSets { | ||
main { | ||
manifest.srcFile 'src/main/AndroidManifest.xml' | ||
assets.srcDirs = [OCCT_ROOT + "/src"] | ||
} | ||
} | ||
|
||
externalNativeBuild { | ||
cmake { | ||
path "src/main/jni/CMakeLists.txt" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'java/com/opencascade/jnisample', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
} | ||
repositories { | ||
mavenCentral() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.opencascade.jnisample"> | ||
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher"> | ||
<activity android:name="OcctJniActivity" | ||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" | ||
android:launchMode="singleTask" | ||
android:configChanges="orientation|keyboardHidden|screenSize"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<data android:scheme="" /> | ||
<data android:scheme="file" /> | ||
<data android:scheme="content" /> | ||
<data android:host="*" /> | ||
|
||
<data android:pathPattern=".*\\.brep" /> | ||
<data android:pathPattern=".*\\.rle" /> | ||
<data android:pathPattern=".*\\.step" /> | ||
<data android:pathPattern=".*\\.stp" /> | ||
<data android:pathPattern=".*\\.iges" /> | ||
<data android:pathPattern=".*\\.igs" /> | ||
<data android:pathPattern=".*\\.stl" /> | ||
</intent-filter> | ||
<intent-filter> | ||
<action android:name="android.intent.action.VIEW" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.BROWSABLE" /> | ||
|
||
<data android:mimeType="model/iges"/> | ||
<data android:mimeType="application/vnd.ms-pki.stl"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
<uses-feature android:glEsVersion="0x00020000"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
</manifest> |
Oops, something went wrong.