0026837: SameParameter algorithm throws an exception
[occt.git] / samples / java / jniviewer / jni / OcctJni_Viewer.cxx
CommitLineData
7f2debb2 1// Copyright (c) 2014 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#include <OcctJni_Viewer.hxx>
15#include <OcctJni_MsgPrinter.hxx>
16
17#include <AIS_Shape.hxx>
18#include <Image_AlienPixMap.hxx>
19#include <BRepTools.hxx>
20#include <Message_Messenger.hxx>
21#include <Message_MsgFile.hxx>
22#include <OpenGl_GraphicDriver.hxx>
23#include <OSD_Environment.hxx>
24#include <OSD_Timer.hxx>
25#include <Standard_Version.hxx>
26
27#include <BRepPrimAPI_MakeBox.hxx>
28
29#include <STEPControl_Reader.hxx>
30#include <IGESControl_Reader.hxx>
31#include <XSControl_WorkSession.hxx>
32
33#include <EGL/egl.h>
34
35#include <sys/types.h>
36#include <sys/stat.h>
37
38#include <jni.h>
39
40//! @return true if file exists
41static bool isFileExist (const TCollection_AsciiString& thePath)
42{
43 struct stat64 aStatBuffer;
44 return stat64 (thePath.ToCString(), &aStatBuffer) == 0;
45}
46
47//! Cut-off the last split character from the path and everything after it.
48static TCollection_AsciiString getParentDir (const TCollection_AsciiString& thePath)
49{
50 TCollection_AsciiString aPath = thePath;
51 char* aSplitter = (char* )aPath.ToCString();
52 for (char* anIter = aSplitter; *anIter != '\0'; ++anIter)
53 {
54 if (*anIter == '\\'
55 || *anIter == '/')
56 {
57 aSplitter = anIter;
58 }
59 }
60 *aSplitter = '\0'; // cut off file name or trailing folder
61 return TCollection_AsciiString (aPath.ToCString());
62}
63
64//! Set environment variable theVarName indicating location of resource
65//! file theFile so as to correspond to actual location of this file.
66//!
67//! The resource file is searched in directory where Test.Draw.dll is located,
68//! and if not found - also in subdirectory ../res from there.
69//! If file is found, environment variable is set for C subsystem.
70//! Otherwise, environment is not changed.
71//!
72//! If theToAddFileName is true, complete file name is set as value of the variable,
73//! if theToAddFileName is false, only path is set.
74Standard_Boolean setResourceEnv (const TCollection_AsciiString& theVarName,
75 const TCollection_AsciiString& theRoot,
76 const TCollection_AsciiString& theFile,
77 const Standard_Boolean theToAddFileName)
78{
79 // use location of current assembly to figure out possible location of resource
80 TCollection_AsciiString aBaseDir = theRoot;
81
82 // check the same directory where binary is located
83 if (!isFileExist (aBaseDir + "/" + theFile))
84 {
85 // check subdirectory ../res
86 aBaseDir = getParentDir (aBaseDir) + "/res";
87 if (!isFileExist (aBaseDir + "/" + theFile))
88 {
89 return Standard_False;
90 }
91 }
92
93 // set C library environment
94 if (theToAddFileName)
95 {
96 aBaseDir = aBaseDir + "/" + theFile;
97 }
98
99 OSD_Environment anEnv (theVarName, aBaseDir);
100 anEnv.Build();
101 return Standard_True;
102}
103
104// =======================================================================
105// function : OcctJni_Viewer
106// purpose :
107// =======================================================================
108OcctJni_Viewer::OcctJni_Viewer()
109{
110 // prepare necessary environment
111 TCollection_AsciiString aResRoot = "/data/data/com.opencascade.jnisample/files";
112
113 setResourceEnv ("CSF_TObjMessage", aResRoot + "/TObj", "TObj.msg", Standard_False);
114 setResourceEnv ("CSF_UnitsLexicon", aResRoot + "/UnitsAPI", "Lexi_Expr.dat", Standard_True);
115 setResourceEnv ("CSF_UnitsDefinition", aResRoot + "/UnitsAPI", "Units.dat", Standard_True);
116 setResourceEnv ("CSF_ShadersDirectory", aResRoot + "/Shaders", "Declarations.glsl", Standard_False);
117 setResourceEnv ("CSF_XSMessage", aResRoot + "/XSMessage", "XSTEP.us", Standard_False);
118 setResourceEnv ("CSF_SHMessage", aResRoot + "/XSMessage", "SHAPE.us", Standard_False);
119 //setResourceEnv ("CSF_PluginDefaults", "Plugin", Standard_False);
120
121 // make sure OCCT loads the dictionary
122 //UnitsAPI::SetLocalSystem (UnitsAPI_SI);
123
124 // load messages for TObj
125 Message_MsgFile::LoadFromEnv ("CSF_TObjMessage", "TObj", "msg");
126}
127
128// =======================================================================
129// function : init
130// purpose :
131// =======================================================================
132bool OcctJni_Viewer::init()
133{
134 EGLint aCfgId = 0;
135 int aWidth = 0, aHeight = 0;
136 EGLDisplay anEglDisplay = eglGetCurrentDisplay();
137 EGLContext anEglContext = eglGetCurrentContext();
138 EGLSurface anEglSurf = eglGetCurrentSurface (EGL_DRAW);
139 if (anEglDisplay == EGL_NO_DISPLAY
140 || anEglContext == EGL_NO_CONTEXT
141 || anEglSurf == EGL_NO_SURFACE)
142 {
143 Message::DefaultMessenger()->Send ("Error: No active EGL context!", Message_Fail);
144 release();
145 return false;
146 }
147
148 eglQuerySurface (anEglDisplay, anEglSurf, EGL_WIDTH, &aWidth);
149 eglQuerySurface (anEglDisplay, anEglSurf, EGL_HEIGHT, &aHeight);
150 eglQuerySurface (anEglDisplay, anEglSurf, EGL_CONFIG_ID, &aCfgId);
151 const EGLint aConfigAttribs[] = { EGL_CONFIG_ID, aCfgId, EGL_NONE };
152 EGLint aNbConfigs = 0;
153 void* anEglConfig = NULL;
154 if (eglChooseConfig (anEglDisplay, aConfigAttribs, &anEglConfig, 1, &aNbConfigs) != EGL_TRUE)
155 {
156 Message::DefaultMessenger()->Send ("Error: EGL does not provide compatible configurations!", Message_Fail);
157 release();
158 return false;
159 }
160
161 TCollection_AsciiString anEglInfo = TCollection_AsciiString()
162 + "\n EGLVersion: " + eglQueryString (anEglDisplay, EGL_VERSION)
163 + "\n EGLVendor: " + eglQueryString (anEglDisplay, EGL_VENDOR)
164 + "\n EGLClient APIs: " + eglQueryString (anEglDisplay, EGL_CLIENT_APIS)
165 + "\n GLvendor: " + (const char* )glGetString (GL_VENDOR)
166 + "\n GLdevice: " + (const char* )glGetString (GL_RENDERER)
167 + "\n GLversion: " + (const char* )glGetString (GL_VERSION) + " [GLSL: " + (const char* )glGetString (GL_SHADING_LANGUAGE_VERSION) + "]";
168 ::Message::DefaultMessenger()->Send (anEglInfo, Message_Info);
169
170 if (!myViewer.IsNull())
171 {
172 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myViewer->Driver());
173 Handle(OcctJni_Window) aWindow = Handle(OcctJni_Window)::DownCast (myView->Window());
174 if (!aDriver->InitEglContext (anEglDisplay, anEglContext, anEglConfig))
175 {
176 Message::DefaultMessenger()->Send ("Error: OpenGl_GraphicDriver can not be initialized!", Message_Fail);
177 release();
178 return false;
179 }
180
181 aWindow->SetSize (aWidth, aHeight);
182 myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext, NULL, NULL);
183 return true;
184 }
185
186 Handle(OpenGl_GraphicDriver) aDriver = new OpenGl_GraphicDriver (NULL, Standard_False);
187 aDriver->ChangeOptions().buffersNoSwap = Standard_True;
188//aDriver->ChangeOptions().glslWarnings = Standard_True; /// for debug only!
189 if (!aDriver->InitEglContext (anEglDisplay, anEglContext, anEglConfig))
190 {
191 Message::DefaultMessenger()->Send ("Error: OpenGl_GraphicDriver can not be initialized!", Message_Fail);
192 release();
193 return false;
194 }
195
196 // create viewer
197 myViewer = new V3d_Viewer (aDriver, TCollection_ExtendedString("Viewer").ToExtString(), "", 1000.0,
198 V3d_XposYnegZpos, Quantity_NOC_BLACK, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
199 Standard_True, Standard_False);
200 myViewer->SetDefaultLights();
201 myViewer->SetLightOn();
202
203 // create AIS context
204 myContext = new AIS_InteractiveContext (myViewer);
205 //myContext->SetDisplayMode (AIS_WireFrame);
206 myContext->SetDisplayMode (AIS_Shaded);
207
208 Handle(OcctJni_Window) aWindow = new OcctJni_Window (aWidth, aHeight);
209 myView = myViewer->CreateView();
210
211 myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext, NULL, NULL);
212 myView->TriedronDisplay (Aspect_TOTP_RIGHT_LOWER, Quantity_NOC_WHITE, 0.08, V3d_ZBUFFER);
213
214 initContent();
215 return true;
216}
217
218// =======================================================================
219// function : release
220// purpose :
221// =======================================================================
222void OcctJni_Viewer::release()
223{
224 myContext.Nullify();
225 myView.Nullify();
226 myViewer.Nullify();
227}
228
229// =======================================================================
230// function : resize
231// purpose :
232// =======================================================================
233void OcctJni_Viewer::resize (int theWidth,
234 int theHeight)
235{
236 if (myContext.IsNull())
237 {
238 Message::DefaultMessenger()->Send ("Resize failed - view is unavailable", Message_Fail);
239 return;
240 }
241
242 Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myViewer->Driver());
243 Handle(OcctJni_Window) aWindow = Handle(OcctJni_Window)::DownCast (myView->Window());
244 aWindow->SetSize (theWidth, theHeight);
245 //myView->MustBeResized(); // can be used instead of SetWindow() when EGLsurface has not been changed
246
247 EGLContext anEglContext = eglGetCurrentContext();
248 myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext, NULL, NULL);
249 //saveSnapshot ("/sdcard/Download/tt.png", theWidth, theHeight);
250}
251
252// =======================================================================
253// function : initContent
254// purpose :
255// =======================================================================
256void OcctJni_Viewer::initContent()
257{
258 myContext->RemoveAll (Standard_False);
259
260 OSD_Timer aTimer;
261 aTimer.Start();
262 if (!myShape.IsNull())
263 {
264 Handle(AIS_Shape) aShapePrs = new AIS_Shape (myShape);
265 myContext->Display (aShapePrs, Standard_False);
266 }
267 else
268 {
269 BRepPrimAPI_MakeBox aBuilder (1.0, 2.0, 3.0);
270 Handle(AIS_Shape) aShapePrs = new AIS_Shape (aBuilder.Shape());
271 myContext->Display (aShapePrs, Standard_False);
272 }
273 myView->FitAll();
274
275 aTimer.Stop();
276 Message::DefaultMessenger()->Send (TCollection_AsciiString() + "Presentation computed in " + aTimer.ElapsedTime() + " seconds", Message_Info);
277}
278
279//! Load shape from IGES file
280static TopoDS_Shape loadIGES (const TCollection_AsciiString& thePath)
281{
282 TopoDS_Shape aShape;
283 IGESControl_Reader aReader;
284 IFSelect_ReturnStatus aReadStatus = IFSelect_RetFail;
285 try
286 {
287 aReadStatus = aReader.ReadFile (thePath.ToCString());
288 }
289 catch (Standard_Failure)
290 {
291 Message::DefaultMessenger()->Send ("Error: IGES reader, computation error", Message_Fail);
292 return aShape;
293 }
294
295 if (aReadStatus != IFSelect_RetDone)
296 {
297 Message::DefaultMessenger()->Send ("Error: IGES reader, bad file format", Message_Fail);
298 return aShape;
299 }
300
301 // now perform the translation
302 aReader.TransferRoots();
303 if (aReader.NbShapes() <= 0)
304 {
305 Handle(XSControl_WorkSession) aWorkSession = new XSControl_WorkSession();
306 aWorkSession->SelectNorm ("IGES");
307 aReader.SetWS (aWorkSession, Standard_True);
308 aReader.SetReadVisible (Standard_False);
309 aReader.TransferRoots();
310 }
311 if (aReader.NbShapes() <= 0)
312 {
313 Message::DefaultMessenger()->Send ("Error: IGES reader, no shapes has been found", Message_Fail);
314 return aShape;
315 }
316 return aReader.OneShape();
317 /*TopoDS_Shape anImportedShape = aReader.OneShape();
318
319 // apply sewing on the imported shape
320 BRepBuilderAPI_Sewing aTool (0.0);
321 aTool.SetNonManifoldMode (Standard_False);
322 aTool.SetFloatingEdgesMode(Standard_True);
323 aTool.Load (anImportedShape);
324 aTool.Perform();
325 TopoDS_Shape aSewedShape = aTool.SewedShape();
326
327 if (aSewedShape.IsNull())
328 {
329 Message::DefaultMessenger()->Send ("Error: Sewing result is empty", Message_Fail);
330 return aShape;
331 }
332 if (aSewedShape.IsSame(anImportedShape))
333 {
334 aShape = anImportedShape;
335 }
336 else
337 {
338 // apply shape healing
339 ShapeFix_Shape aShapeFixer(aSewedShape);
340 aShapeFixer.FixSolidMode() = 1;
341 aShapeFixer.FixFreeShellMode() = 1;
342 aShapeFixer.FixFreeFaceMode() = 1;
343 aShapeFixer.FixFreeWireMode() = 0;
344 aShapeFixer.FixSameParameterMode() = 0;
345 aShapeFixer.FixVertexPositionMode() = 0;
346 aShape = aShapeFixer.Perform() ? aShapeFixer.Shape() : aSewedShape;
347 }
348 return aShape;*/
349}
350
351//! Load shape from STEP file
352static TopoDS_Shape loadSTEP (const TCollection_AsciiString& thePath)
353{
354 STEPControl_Reader aReader;
355 IFSelect_ReturnStatus aReadStatus = IFSelect_RetFail;
356 try
357 {
358 aReadStatus = aReader.ReadFile (thePath.ToCString());
359 }
360 catch (Standard_Failure)
361 {
362 Message::DefaultMessenger()->Send ("Error: STEP reader, computation error", Message_Fail);
363 return TopoDS_Shape();
364 }
365
366 if (aReadStatus != IFSelect_RetDone)
367 {
368 Message::DefaultMessenger()->Send ("Error: STEP reader, bad file format", Message_Fail);
369 return TopoDS_Shape();
370 }
371 else if (aReader.NbRootsForTransfer() <= 0)
372 {
373 Message::DefaultMessenger()->Send ("Error: STEP reader, shape is empty", Message_Fail);
374 return TopoDS_Shape();
375 }
376
377 // now perform the translation
378 aReader.TransferRoots();
379 return aReader.OneShape();
380}
381
382// =======================================================================
383// function : open
384// purpose :
385// =======================================================================
386bool OcctJni_Viewer::open (const TCollection_AsciiString& thePath)
387{
388 myShape.Nullify();
389 if (!myContext.IsNull())
390 {
391 myContext->RemoveAll (Standard_False);
392 }
393 if (thePath.IsEmpty())
394 {
395 return false;
396 }
397
398 OSD_Timer aTimer;
399 aTimer.Start();
400 TCollection_AsciiString aFormatStr;
401 const Standard_Integer aLen = thePath.Length();
402 if (aLen >= 5
403 && thePath.Value (aLen - 4) == '.')
404 {
405 aFormatStr = thePath.SubString (aLen - 3, aLen);
406 }
407 else if (aLen >= 4
408 && thePath.Value (aLen - 3) == '.')
409 {
410 aFormatStr = thePath.SubString (aLen - 2, aLen);
411 }
412 else if (aLen >= 3
413 && thePath.Value (aLen - 2) == '.')
414 {
415 aFormatStr = thePath.SubString (aLen - 1, aLen);
416 }
417 aFormatStr.LowerCase();
418
419 TopoDS_Shape aShape;
420 if (aFormatStr == "stp"
421 || aFormatStr == "step")
422 {
423 aShape = loadSTEP (thePath);
424 }
425 else if (aFormatStr == "igs"
426 || aFormatStr == "iges")
427 {
428 aShape = loadIGES (thePath);
429 }
430 else
431 // if (aFormatStr == "brep"
432 // || aFormatStr == "rle")
433 {
434 BRep_Builder aBuilder;
435 if (!BRepTools::Read (aShape, thePath.ToCString(), aBuilder))
436 {
437 Message::DefaultMessenger()->Send (TCollection_AsciiString() + "Error: file '" + thePath + "' can not be opened!", Message_Info);
438 return false;
439 }
440 }
441 if (aShape.IsNull())
442 {
443 return false;
444 }
445 aTimer.Stop();
446 Message::DefaultMessenger()->Send (TCollection_AsciiString() + "File '" + thePath + "' loaded in " + aTimer.ElapsedTime() + " seconds", Message_Info);
447
448 myShape = aShape;
449 if (myContext.IsNull())
450 {
451 return true;
452 }
453
454 aTimer.Reset();
455 aTimer.Start();
456
457 Handle(AIS_Shape) aShapePrs = new AIS_Shape (aShape);
458 myContext->Display (aShapePrs, Standard_False);
459 myView->FitAll();
460
461 aTimer.Stop();
462 Message::DefaultMessenger()->Send (TCollection_AsciiString() + "Presentation computed in " + aTimer.ElapsedTime() + " seconds", Message_Info);
463 return true;
464}
465
466// =======================================================================
467// function : saveSnapshot
468// purpose :
469// =======================================================================
470bool OcctJni_Viewer::saveSnapshot (const TCollection_AsciiString& thePath,
471 int theWidth,
472 int theHeight)
473{
474 if (myContext.IsNull()
475 || thePath.IsEmpty())
476 {
477 Message::DefaultMessenger()->Send ("Image dump failed - view is unavailable", Message_Fail);
478 return false;
479 }
480
481 if (theWidth < 1
482 || theHeight < 1)
483 {
484 myView->Window()->Size (theWidth, theHeight);
485 }
486 if (theWidth < 1
487 || theHeight < 1)
488 {
489 Message::DefaultMessenger()->Send ("Image dump failed - view is unavailable", Message_Fail);
490 return false;
491 }
492
493 Image_AlienPixMap anAlienImage;
494 if (!anAlienImage.InitTrash (Image_PixMap::ImgBGRA, theWidth, theHeight))
495 {
496 Message::DefaultMessenger()->Send (TCollection_AsciiString() + "RGBA image " + theWidth + "x" + theHeight + " allocation failed", Message_Fail);
497 return false;
498 }
499
500 // OpenGL ES does not support fetching data in BGRA format
501 // while FreeImage does not support RGBA format.
502 Image_PixMap anImage;
503 anImage.InitWrapper (Image_PixMap::ImgRGBA,
504 anAlienImage.ChangeData(),
505 anAlienImage.SizeX(),
506 anAlienImage.SizeY(),
507 anAlienImage.SizeRowBytes());
508 if (!myView->ToPixMap (anImage, theWidth, theHeight, Graphic3d_BT_RGBA))
509 {
510 Message::DefaultMessenger()->Send (TCollection_AsciiString() + "View dump to the image " + theWidth + "x" + theHeight + " failed", Message_Fail);
511 }
512
513 for (Standard_Size aRow = 0; aRow < anAlienImage.SizeY(); ++aRow)
514 {
515 for (Standard_Size aCol = 0; aCol < anAlienImage.SizeX(); ++aCol)
516 {
517 Image_ColorRGBA& aPixel = anAlienImage.ChangeValue<Image_ColorRGBA> (aRow, aCol);
518 std::swap (aPixel.r(), aPixel.b());
519 //aPixel.a() = 1.0;
520 }
521 }
522
523 if (!anAlienImage.Save (thePath))
524 {
525 Message::DefaultMessenger()->Send (TCollection_AsciiString() + "Image saving to path '" + thePath + "' failed", Message_Fail);
526 return false;
527 }
528 Message::DefaultMessenger()->Send (TCollection_AsciiString() + "View " + theWidth + "x" + theHeight + " dumped to image '" + thePath + "'", Message_Info);
529 return true;
530}
531
532// =======================================================================
533// function : redraw
534// purpose :
535// =======================================================================
536void OcctJni_Viewer::redraw()
537{
538 if (myView.IsNull())
539 {
540 return;
541 }
542
543 myView->Redraw();
544}
545
546// =======================================================================
547// function : fitAll
548// purpose :
549// =======================================================================
550void OcctJni_Viewer::fitAll()
551{
552 if (myView.IsNull())
553 {
554 return;
555 }
556
557 myView->FitAll();
558}
559
560// =======================================================================
561// function : startRotation
562// purpose :
563// =======================================================================
564void OcctJni_Viewer::startRotation (int theStartX,
565 int theStartY)
566{
567 if (myView.IsNull())
568 {
569 return;
570 }
571
572 myView->StartRotation (theStartX, theStartY, 0.45);
573}
574
575// =======================================================================
576// function : onRotation
577// purpose :
578// =======================================================================
579void OcctJni_Viewer::onRotation (int theX,
580 int theY)
581{
582 if (myView.IsNull())
583 {
584 return;
585 }
586
587 myView->Rotation (theX, theY);
588}
589
590// =======================================================================
591// function : onPanning
592// purpose :
593// =======================================================================
594void OcctJni_Viewer::onPanning (int theDX,
595 int theDY)
596{
597 if (myView.IsNull())
598 {
599 return;
600 }
601
602 myView->Pan (theDX, theDY);
603}
604
605// =======================================================================
606// function : onClick
607// purpose :
608// =======================================================================
609void OcctJni_Viewer::onClick (int theX,
610 int theY)
611{
612 if (myView.IsNull())
613 {
614 return;
615 }
616
617 myContext->MoveTo (theX, theY, myView, Standard_False);
618 myContext->Select (Standard_True);
619}
620
621// =======================================================================
622// function : stopAction
623// purpose :
624// =======================================================================
625void OcctJni_Viewer::stopAction()
626{
627 if (myView.IsNull())
628 {
629 return;
630 }
631}
632
633#define jexp extern "C" JNIEXPORT
634
635jexp jlong JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppCreate (JNIEnv* theEnv,
636 jobject theObj)
637{
638 return jlong(new OcctJni_Viewer());
639}
640
641jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppDestroy (JNIEnv* theEnv,
642 jobject theObj,
643 jlong theCppPtr)
644{
645 delete (OcctJni_Viewer* )theCppPtr;
646
647 Handle(Message_Messenger) aMsgMgr = Message::DefaultMessenger();
648 aMsgMgr->RemovePrinters (STANDARD_TYPE (OcctJni_MsgPrinter));
649}
650
651jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppRelease (JNIEnv* theEnv,
652 jobject theObj,
653 jlong theCppPtr)
654{
655 ((OcctJni_Viewer* )theCppPtr)->release();
656}
657
658jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppInit (JNIEnv* theEnv,
659 jobject theObj,
660 jlong theCppPtr)
661{
662 Handle(Message_Messenger) aMsgMgr = Message::DefaultMessenger();
663 aMsgMgr->RemovePrinters (STANDARD_TYPE (OcctJni_MsgPrinter));
664 aMsgMgr->AddPrinter (new OcctJni_MsgPrinter (theEnv, theObj));
665 ((OcctJni_Viewer* )theCppPtr)->init();
666}
667
668jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppResize (JNIEnv* theEnv,
669 jobject theObj,
670 jlong theCppPtr,
671 jint theWidth,
672 jint theHeight)
673{
674 ((OcctJni_Viewer* )theCppPtr)->resize (theWidth, theHeight);
675}
676
677jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppOpen (JNIEnv* theEnv,
678 jobject theObj,
679 jlong theCppPtr,
680 jstring thePath)
681{
682 const char* aPathPtr = theEnv->GetStringUTFChars (thePath, 0);
683 const TCollection_AsciiString aPath (aPathPtr);
684 theEnv->ReleaseStringUTFChars (thePath, aPathPtr);
685 ((OcctJni_Viewer* )theCppPtr)->open (aPath);
686}
687
688jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppRedraw (JNIEnv* theEnv,
689 jobject theObj,
690 jlong theCppPtr)
691{
692 ((OcctJni_Viewer* )theCppPtr)->redraw();
693}
694
695jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppSetAxoProj (JNIEnv* theEnv,
696 jobject theObj,
697 jlong theCppPtr)
698{
699 ((OcctJni_Viewer* )theCppPtr)->setProj (V3d_XposYnegZpos);
700}
701
702jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppSetXposProj (JNIEnv* theEnv,
703 jobject theObj,
704 jlong theCppPtr)
705{
706 ((OcctJni_Viewer* )theCppPtr)->setProj (V3d_Xpos);
707}
708
709jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppSetYposProj (JNIEnv* theEnv,
710 jobject theObj,
711 jlong theCppPtr)
712{
713 ((OcctJni_Viewer* )theCppPtr)->setProj (V3d_Ypos);
714}
715
716jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppSetZposProj (JNIEnv* theEnv,
717 jobject theObj,
718 jlong theCppPtr)
719{
720 ((OcctJni_Viewer* )theCppPtr)->setProj (V3d_Zpos);
721}
722
723jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppSetXnegProj (JNIEnv* theEnv,
724 jobject theObj,
725 jlong theCppPtr)
726{
727 ((OcctJni_Viewer* )theCppPtr)->setProj (V3d_Xneg);
728}
729
730jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppSetYnegProj (JNIEnv* theEnv,
731 jobject theObj,
732 jlong theCppPtr)
733{
734 ((OcctJni_Viewer* )theCppPtr)->setProj (V3d_Yneg);
735}
736
737jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppSetZnegProj (JNIEnv* theEnv,
738 jobject theObj,
739 jlong theCppPtr)
740{
741 ((OcctJni_Viewer* )theCppPtr)->setProj (V3d_Zneg);
742}
743
744jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppFitAll (JNIEnv* theEnv,
745 jobject theObj,
746 jlong theCppPtr)
747{
748 ((OcctJni_Viewer* )theCppPtr)->fitAll();
749}
750
751jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppStartRotation (JNIEnv* theEnv,
752 jobject theObj,
753 jlong theCppPtr,
754 jint theStartX,
755 jint theStartY)
756{
757 ((OcctJni_Viewer* )theCppPtr)->startRotation (theStartX, theStartY);
758}
759
760jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppOnRotation (JNIEnv* theEnv,
761 jobject theObj,
762 jlong theCppPtr,
763 jint theX,
764 jint theY)
765{
766 ((OcctJni_Viewer* )theCppPtr)->onRotation (theX, theY);
767}
768
769jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppOnPanning (JNIEnv* theEnv,
770 jobject theObj,
771 jlong theCppPtr,
772 jint theDX,
773 jint theDY)
774{
775 ((OcctJni_Viewer* )theCppPtr)->onPanning (theDX, theDY);
776}
777
778jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppOnClick (JNIEnv* theEnv,
779 jobject theObj,
780 jlong theCppPtr,
781 jint theX,
782 jint theY)
783{
784 ((OcctJni_Viewer* )theCppPtr)->onClick (theX, theY);
785}
786
787jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppStopAction (JNIEnv* theEnv,
788 jobject theObj,
789 jlong theCppPtr)
790{
791 ((OcctJni_Viewer* )theCppPtr)->stopAction();
792}
793
794jexp jlong JNICALL Java_com_opencascade_jnisample_OcctJniActivity_cppOcctMajorVersion (JNIEnv* theEnv,
795 jobject theObj)
796{
797 return OCC_VERSION_MAJOR;
798}
799
800jexp jlong JNICALL Java_com_opencascade_jnisample_OcctJniActivity_cppOcctMinorVersion (JNIEnv* theEnv,
801 jobject theObj)
802{
803 return OCC_VERSION_MINOR;
804}
805
806jexp jlong JNICALL Java_com_opencascade_jnisample_OcctJniActivity_cppOcctMicroVersion (JNIEnv* theEnv,
807 jobject theObj)
808{
809 return OCC_VERSION_MAINTENANCE;
810}