0029368: Incorrect intersection state of the intersection point of two 2d curves
[occt.git] / samples / java / jniviewer / ReadMe.md
1 OCCT JniViewer sample for Android {#samples_java_android_occt}
2 ================== 
3
4 This sample demonstrates simple way of using OCCT libraries in Android application written using Java.
5
6 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.
7 The proxy library contains single C++ class OcctJni_Viewer encapsulating OCCT viewer and providing functionality to manipulate this viewer
8 and to import OCCT shapes from several supported formats of CAD files (IGES, STEP, BREP).
9
10 This sample demonstrates indirect method of wrapping C++ to Java using manually created proxy library.
11 Alternative method is available, wrapping individual OCCT classes to Java equivalents so that their full API is available to Java user
12 and the code can be programmed on Java level similarly to C++ one.
13 See description of OCCT Java Wrapper in Advanced Samples and Tools on OCCT web site at 
14 http://www.opencascade.org/support/products/advsamples
15
16 Run Eclipse from ADT (Android Developer Tools) for building the sample. To import sample project perform
17 ~~~~
18   File -> Import... -> Android -> Existing Android code into Workspace
19 ~~~~
20 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).  
21 Proxy library compilation and packaging is performed by NDK build script, called by "C++ Builder" configured within Eclipse project.
22 The path to "ndk-build" tool from Android NDK (Native Development Kit) should be specified in Eclipse project properties:
23 ~~~~
24   Project -> Properties -> Builders -> C++ Builder -> Edit -> Location
25 ~~~~
26
27 Now paths to OCCT C++ libraries and additional components should be specified in "jni/Android.mk" file:
28 ~~~~
29 OCCT_ROOT := $(LOCAL_PATH)/../../../..
30
31 FREETYPE_INC  := $(OCCT_ROOT)/../freetype/include/freetype2
32 FREETYPE_LIBS := $(OCCT_ROOT)/../freetype/libs
33
34 FREEIMAGE_INC  := $(OCCT_ROOT)/../FreeImage/include
35 FREEIMAGE_LIBS := $(OCCT_ROOT)/../FreeImage/libs
36
37 OCCT_INC  := $(OCCT_ROOT)/inc
38 OCCT_LIBS := $(OCCT_ROOT)/and/libs
39 ~~~~
40 The list of extra components (Freetype, FreeImage) depends on OCCT configuration.
41 Variable $(TARGET_ARCH_ABI) is used within this script to refer to active architecture.
42 E.g. for 32-bit ARM build (see variable *APP_ABI* in "jni/Application.mk")
43 the folder *OCCT_LIBS* should contain sub-folder "armeabi-v7a" with OCCT libraries.
44
45 FreeImage is optional and does not required for this sample, however you should include all extra libraries used for OCCT building
46 and load the explicitly from Java code within OcctJniActivity::loadNatives() method, including toolkits from OCCT itself in proper order:
47 ~~~~
48     if (!loadLibVerbose ("TKernel", aLoaded, aFailed)
49      || !loadLibVerbose ("TKMath",  aLoaded, aFailed)
50      || !loadLibVerbose ("TKG2d",   aLoaded, aFailed)
51 ~~~~
52 Note that C++ STL library is not part of Android system.
53 Thus application must package this library as well as extra component.
54 "gnustl_shared" STL implementation is expected within this sample.
55
56 After successful build, the application can be packaged to Android:
57 - Deploy and run application on connected device or emulator directly from Eclipse using adb interface by menu items "Run" and "Debug". This would sign package with debug certificate.
58 - Prepare signed end-user package using wizard File -> Export -> Android -> Export Android Application.