// // Copyright (C) 1991 - 2000 by // Matra Datavision SA. All rights reserved. // // Copyright (C) 2001 - 2004 by // Open CASCADE SA. All rights reserved. // // This file is part of the Open CASCADE Technology software. // // This software may be distributed and/or modified under the terms and // conditions of the Open CASCADE Public License as defined by Open CASCADE SA // and appearing in the file LICENSE included in the packaging of this file. // // This software is distributed on an "AS IS" basis, without warranty of any // kind, and Open CASCADE SA hereby disclaims all such warranties, // including without limitation, any warranties of merchantability, fitness // for a particular purpose or non-infringement. Please see the License for // the specific terms and conditions governing rights and limitations under the // License. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern "C" { JNIEXPORT jobject JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_CreateViewer (JNIEnv *env, jclass, jstring aName) { jobject thejret; jcas_Locking alock(env); { try { Standard_ExtString the_aName = jcas_ConvertToExtString(env,aName); Handle(V3d_Viewer)* theret = new Handle(V3d_Viewer); *theret = SampleAISSelectPackage::CreateViewer(the_aName); thejret = jcas_CreateObject(env,"CASCADESamplesJni/V3d_Viewer",theret); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); return thejret; } JNIEXPORT void JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_SetWindow (JNIEnv *env, jclass, jobject aView, jint hiwin, jint lowin) { jcas_Locking alock(env); { try { Handle( V3d_View ) the_aView; void* ptr_aView = jcas_GetHandle(env,aView); if ( ptr_aView != NULL ) the_aView = *( ( Handle( V3d_View )* )ptr_aView ); SampleAISSelectPackage::SetWindow(the_aView,(Standard_Integer) hiwin,(Standard_Integer) lowin); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); } JNIEXPORT void JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_DisplayBox (JNIEnv *env, jclass, jobject aContext, jobject Message) { jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message); if ( the_Message == NULL ) { // The following assumes availability of the default constructor (what may not // always be the case). Therefore explicit exception is thrown if the null // object has been passed. // the_Message = new TCollection_AsciiString (); // jcas_SetHandle ( env, Message, the_Message ); jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); } // end if SampleAISSelectPackage::DisplayBox(the_aContext,*the_Message); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); } JNIEXPORT void JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_DisplayCylinder (JNIEnv *env, jclass, jobject aContext, jobject Message) { jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message); if ( the_Message == NULL ) { // The following assumes availability of the default constructor (what may not // always be the case). Therefore explicit exception is thrown if the null // object has been passed. // the_Message = new TCollection_AsciiString (); // jcas_SetHandle ( env, Message, the_Message ); jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); } // end if SampleAISSelectPackage::DisplayCylinder(the_aContext,*the_Message); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); } JNIEXPORT void JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_SelectVertices (JNIEnv *env, jclass, jobject aContext, jobject Message) { jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message); if ( the_Message == NULL ) { // The following assumes availability of the default constructor (what may not // always be the case). Therefore explicit exception is thrown if the null // object has been passed. // the_Message = new TCollection_AsciiString (); // jcas_SetHandle ( env, Message, the_Message ); jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); } // end if SampleAISSelectPackage::SelectVertices(the_aContext,*the_Message); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); } JNIEXPORT void JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_SelectEdges (JNIEnv *env, jclass, jobject aContext, jobject Message) { jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message); if ( the_Message == NULL ) { // The following assumes availability of the default constructor (what may not // always be the case). Therefore explicit exception is thrown if the null // object has been passed. // the_Message = new TCollection_AsciiString (); // jcas_SetHandle ( env, Message, the_Message ); jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); } // end if SampleAISSelectPackage::SelectEdges(the_aContext,*the_Message); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); } JNIEXPORT void JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_SelectFaces (JNIEnv *env, jclass, jobject aContext, jobject Message) { jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message); if ( the_Message == NULL ) { // The following assumes availability of the default constructor (what may not // always be the case). Therefore explicit exception is thrown if the null // object has been passed. // the_Message = new TCollection_AsciiString (); // jcas_SetHandle ( env, Message, the_Message ); jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); } // end if SampleAISSelectPackage::SelectFaces(the_aContext,*the_Message); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); } JNIEXPORT void JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_SelectNeutral (JNIEnv *env, jclass, jobject aContext, jobject Message) { jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message); if ( the_Message == NULL ) { // The following assumes availability of the default constructor (what may not // always be the case). Therefore explicit exception is thrown if the null // object has been passed. // the_Message = new TCollection_AsciiString (); // jcas_SetHandle ( env, Message, the_Message ); jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); } // end if SampleAISSelectPackage::SelectNeutral(the_aContext,*the_Message); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); } JNIEXPORT jint JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_MakeFillet (JNIEnv *env, jclass, jobject aContext, jdouble aValue, jobject Message) { jint thejret; jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message); if ( the_Message == NULL ) { // The following assumes availability of the default constructor (what may not // always be the case). Therefore explicit exception is thrown if the null // object has been passed. // the_Message = new TCollection_AsciiString (); // jcas_SetHandle ( env, Message, the_Message ); jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); } // end if thejret = SampleAISSelectPackage::MakeFillet(the_aContext,(Standard_Real) aValue,*the_Message); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); return thejret; } JNIEXPORT jboolean JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_IsCylinderSelected (JNIEnv *env, jclass, jobject aContext) { jboolean thejret; jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); thejret = SampleAISSelectPackage::IsCylinderSelected(the_aContext); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); return thejret; } JNIEXPORT void JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_StartSelectFace (JNIEnv *env, jclass, jobject aContext) { jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); SampleAISSelectPackage::StartSelectFace(the_aContext); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); } JNIEXPORT jobject JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_GetFaceColor (JNIEnv *env, jclass, jobject aContext) { jobject thejret; jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); Quantity_Color* theret = new Quantity_Color(SampleAISSelectPackage::GetFaceColor(the_aContext)); thejret = jcas_CreateObject(env,"CASCADESamplesJni/Quantity_Color",theret); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); return thejret; } JNIEXPORT void JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_SetFaceColor (JNIEnv *env, jclass, jobject aContext, jobject aColor, jobject Message) { jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); Quantity_Color* the_aColor = (Quantity_Color*) jcas_GetHandle(env,aColor); if ( the_aColor == NULL ) { // The following assumes availability of the default constructor (what may not // always be the case). Therefore explicit exception is thrown if the null // object has been passed. // the_aColor = new Quantity_Color (); // jcas_SetHandle ( env, aColor, the_aColor ); jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); } // end if TCollection_AsciiString* the_Message = (TCollection_AsciiString*) jcas_GetHandle(env,Message); if ( the_Message == NULL ) { // The following assumes availability of the default constructor (what may not // always be the case). Therefore explicit exception is thrown if the null // object has been passed. // the_Message = new TCollection_AsciiString (); // jcas_SetHandle ( env, Message, the_Message ); jcas_ThrowException (env, "NULL object has been passed while expecting an object manipulated by value"); } // end if SampleAISSelectPackage::SetFaceColor(the_aContext,*the_aColor,*the_Message); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); } JNIEXPORT void JNICALL Java_SampleAISSelectJni_SampleAISSelectPackage_EndSelectFace (JNIEnv *env, jclass, jobject aContext) { jcas_Locking alock(env); { try { Handle( AIS_InteractiveContext ) the_aContext; void* ptr_aContext = jcas_GetHandle(env,aContext); if ( ptr_aContext != NULL ) the_aContext = *( ( Handle( AIS_InteractiveContext )* )ptr_aContext ); SampleAISSelectPackage::EndSelectFace(the_aContext); } catch (Standard_Failure) { Standard_SStream Err; Err << Standard_Failure::Caught(); Err << (char) 0; jcas_ThrowException(env,Err.str().c_str()); } } alock.Release(); } }