Extension of Java samples

Hi,

I need an application to view a java-based product model using an OPEN CASCADE Viewer. Obviously, this will need a substantial number of OPEN CASCADE's classes to be mapped to java native methods via JNI, as in the java examples.

Has anybody done any of this already?

Does a tutorial exist describing how to write these methods?

Paolo Mosna's picture

Hi,

I'm trying to do somthing very similar to what you are doing (java-OpenCASCADE co-operation).
Clearly I have your problems too.
I would like to start reviwing the samples provided with OpenCASCADE, mainly reusing them inside my code (software re-use).

I would be very thankfull if you can update me if you will find somthing about this topics.

Thanks.
Paolo.

KuanLinLiu's picture

Hello,
I have the same problem too, I found the animation part of java example has some problems when loading animation files.
Once I tried to use JNI call for java3D(trangulation facets), I met rendering problems as well. I know OCC can trangulate facets from geometry&topology model, but I thought the normal vector of every trangle should be calculated by myself. it's no so convenient.
Also, I have no idea how to pass array object to OCC by JNI. Any information or suggestion would be helpful. thank you.

Albert Liu

479@ec.csd.org.tw

Paolo Mosna's picture

Hi,

I don't have a deep experience with JNI but in java a vector is a normal object, this means that you should be able to pass the java vector to a c JNI function as you do for any other java object, then you can call the appropriate methods of the vector class from within c functions. Let me use an example:

// java class
public class myClass {
native public takeThisVector(Vector vect);
}

if you process this class with javah you will get:

JNIEXPORT jboolean JNICALL Java_jcas_Object_IsNullObj (JNIEnv *, jobject, jobject);

taht you can implement in this way:

JNIEXPORT jboolean JNICALL Java_jcas_Object_IsNullObj (JNIEnv * env, jobject class_instance, jobject vector){

// here you can use the JNI interface to
// call all the methods for the Vectro class
// You can find a good description
// of such operation at the java.sun.com
// web-site.
}

Good luck,
Paolo.

Software Engineer