Open CASCADE Technology
7.4.0
|
|
This sample demonstrates simple way of using OCCT libraries in Android application written using Java.
The connection between Java and OCCT (C++) level is provided by proxy library, libTKJniSample.so, written in C++ with exported JNI methods of Java 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 Java using manually created proxy library. Alternative method is available, wrapping individual OCCT classes to Java equivalents so that their full API is available to Java user and the code can be programmed on Java level similarly to C++ one. See description of OCCT Java Wrapper in Advanced Samples and Tools on OCCT web site at http://www.opencascade.org/support/products/advsamples
Run Eclipse from ADT (Android Developer Tools) for building the sample. To import sample project perform
and specify this directory. The project re-build will be started immediately right after importation if "Build automatically" option is turned on (default in Eclipse). Proxy library compilation and packaging is performed by NDK build script, called by "C++ Builder" configured within Eclipse project. The path to "ndk-build" tool from Android NDK (Native Development Kit) should be specified in Eclipse project properties:
Now paths to OCCT C++ libraries and additional components should be specified in "jni/Android.mk" file:
The list of extra components (Freetype, FreeImage) depends on OCCT configuration. Variable is used within this script to refer to active architecture. E.g. for 32-bit ARM build (see variable APP_ABI in "jni/Application.mk") the folder OCCT_LIBS should contain sub-folder "armeabi-v7a" with OCCT libraries.
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:
Note that C++ STL library is not part of Android system. Thus application must package this library as well as extra component. "gnustl_shared" STL implementation is expected within this sample.
After successful build, the application can be packaged to Android: