1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Compare commits

..

248 Commits

Author SHA1 Message Date
jgv
8b03694546 0026907: ChFi3d_Builder algorithm uses old Boolean operations: wrong processing of shapes with seam and degenerated edges 2020-08-31 16:41:44 +03:00
kgv
68a2329305 0031369: Foundation Classes, Standard_ReadBuffer - access violation on second ::ReadChunk() call after read failure
Standard_ReadBuffer::readRawDataChunk() - do not increment NULL pointer and return invalid address.
2020-08-28 18:13:36 +03:00
kgv
90bc1adb77 0031086: Coding Rules - STEPCAFControl_Reader has virtual functions, but no virtual destructor
Added missing virtual destructor.
2020-08-28 18:11:58 +03:00
kgv
af7fa1438e 0031706: Data Exchange, RWGltf_CafReader - imports model with incorrect transformation
RWGltf_GltfJsonParser::bindNamedShape() - shape location is now multiplied not just overridden.
2020-08-28 18:00:22 +03:00
emv
6f04cbb1fb 0031734: Modeling Algorithms - Incorrect result of offset operation in mode "Complete" join type "Intersection"
BRepOffset_MakeOffset_1::IntersectFaces - Build intersection pairs for rebuilding process basing on the intersection results and removed faces.
2020-08-28 17:53:40 +03:00
kgv
d99f0355e3 0031731: Draw Harness - colorize errors and exception messages
Draw_Interpretor, CommandCmd() - catched exceptions and messages put into Tcl string result
before throwing a Tcl exception (return 1) are now print in intense red (using Message::SendFail()).
Duplication of exception message in std::cout and Tcl output has been removed.

Draw Harness plugins have been updated to use either Message::SendFail() or theDI instead of std::cout/std::cerr
for printing colored error message before throwing a Tcl exception.
2020-08-25 09:44:15 +03:00
kgv
1d99a2baaa 0031720: Visualization, Font_FontMgr - register one more CJK fallback font available on newer Android devices 2020-08-22 12:13:14 +03:00
kgv
4c99a1f80a 0031727: Samples, JNI Sample - JNI DETECTED ERROR on calling OcctJniRenderer.postMessage()
Use CallVoidMethod() instead of CallObjectMethod().
2020-08-22 12:13:13 +03:00
osa
fe3dbc63fc 0031715: Visualization - add access to proxy shader program 2020-08-22 12:13:12 +03:00
kgv
8e16477b50 0031582: Configuration, CMake - OCCT fails to build with VTK 9.0
Handle "VTK::" prefix instead of "vtk" used by previous VTK versions for targets.
Corrected unexpected location of endif() and broken indentation.
Obsolete $VTK_USE_FILE is no more included (basing on VTK version check).

Standard_WarningsDisable.hxx/Standard_WarningsRestore.hxx pair is now used to suppress VTK warnings instead of partial disabling.
2020-08-22 12:13:11 +03:00
ifv
ce9aefc8aa 0026568: Modeling Algorithms - Exception when creating pipe
BRepFill_Pipe.cxx:  protection against wrong shape type is added
GeomFill_Sweep.cxx:  protection against using 0-vector to create Direction is added

bug26568: test script is corrected: "TODO ..." is removed
2020-08-22 12:13:10 +03:00
age
f3269ef5f1 0031716: Visualization, Select3D_SensitiveSet::matches() - avoid building BVH in case of full overlapping by the volume 2020-08-22 12:13:10 +03:00
kgv
63e5cfcaab 0031714: Draw Harness - print command name with intense within help output
Added command "dputs" similar to "puts" but with extra arguments modifying text color/intensity.
Command "help" now prints the name of command with intense style.
2020-08-22 12:13:09 +03:00
mpv
0fb210edbf 0031681: Foundation Classes - Shared Libraries Cannot Be Loaded
Standard_ErrorHandler now accesses global mutex via proxy function
instead of a global variable to avoid initialization order issues.
2020-08-22 12:13:08 +03:00
kgv
4254e74196 0031324: Data Exchange - Cannot read BinOcaf document with colour
BinMDataXtd_PresentationDriver and XmlMDataXtd_PresentationDriver have been corrected
to convert old (OCCT 7.4.0) Quantity_NameOfColor enumeration values to new ones.
2020-08-22 12:13:08 +03:00
kgv
12e6d49993 0031713: Draw Harness, IVtkDraw - add commands ivtksetcolor, ivtkaxo, ivtkclose, ivtksettransparency
Added missing NULL checks before accessing GetInteractor().
Errors are now reported using Message::SendFail().
Not found actor names are now reported as syntax error instead of silently skipping them.

ivtkinit now accepts aguments -srgb and -msaa for overriding defaults.
Default MSAA settings have been changed from 8 to 0 to match vinit behavior.
Added command ivtkclose closing a Vtk view.

Added commands ivtkaxo, ivtkfront, ivtkback, ivtkleft, ivtkright,
ivtktop and ivtkbottom assigning view projection similar to sonamed commands in ViewerTest.

Added commands ivtksetcolor and ivtksettransparency assigning
color properties to shaded presentation.
2020-08-14 13:30:05 +03:00
kgv
dae2a92241 0031709: Draw Harness - move methods ViewerTest::ParseOnOff()/ParseColor() to package Draw
Methods ParseOnOff()/ParseColor() have been moved from package ViewerTest to Draw.
Command "vlight -color" now accepts RGB values, not only name.
Implementation of pload command has been cleaned up.
2020-08-14 13:30:04 +03:00
kgv
76fada6839 0031702: Visualization, TKOpenGl - hatching interior is ignored in second View within the Viewer
Current state variables have been moved out from OpenGl_LineAttributes to OpenGl_Context.
2020-08-14 12:46:34 +03:00
szy
5980a9fb23 0031049: OCAF - Error message during Ascii file (std) opening. 2020-08-14 12:44:54 +03:00
ifv
1bf23e5bb6 0031697: Foundation Classes - Expr_GeneralExpression::Derivative does not seem to work (691 & 720)
Expr_NamedUnknown.cxx - wrong comparing of named unknown is fixed

QABugs_20.cxx - new QAcommand is created
QABugs_11.cxx - wrong command is corrected
bug902 - wrong test is corrected
bug31697 - new test is added
2020-08-07 18:49:38 +03:00
kgv
e0b2443737 0031698: Visualization, Graphic3d_Aspects - provide stipple line factor parameter
Added Graphic3d_Aspects::LineStippleFactor() property.
Adjusted help for vaspects command suggesting a shorter syntax.
2020-08-07 15:17:53 +03:00
kgv
148820b2a9 0031689: Coding Rules - including STEPCAFControl_Writer.hxx produces compilation error
Added missing #include <NCollection_Vector.hxx>.
2020-08-07 15:08:55 +03:00
ifv
9c4214b416 0030944: [Regression to 7.0.0] Modeling Algorithms - Intersection curves between pair of faces are not found
IntPatch_ImpPrmIntersection.cxx: treatment of coinciding lines is improved
IntWalk_IWalking_1.gxx: bug correction
bug30944 : test case added
2020-08-03 10:52:59 +03:00
kgv
4c7a3faef5 0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating viewer defaults
SelectMgr_ViewerSelector3d::ClearSensitive() - fixed crash on removing presentations (via command vsensera).

Added new parameters -sync and -reset to vrenderparams command synchronizing parameters across Views.
Parameters -raster and -rayTrace now accept optional on|off values.
Improved command description.
2020-07-24 19:20:33 +03:00
kgv
9f013fee98 0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with Graphic3d_TOSM_UNLIT shading model
Prs3d_ShadingAspect::SetTransparency() now sets transparency also to interior color.
AIS_RubberBand now uses Graphic3d_TOSM_UNLIT.
2020-07-23 16:14:57 +03:00
akaftasev
6d8f9f4a49 0031353: TDocStd_Application does not have api to set progress indicator
Add support of Message_ProgressIndicator in BinTools classes.

Add support of Message_ProgressIndicator with possibility of user break in methods of opening and saving TDocStd_Application.

Add tests of ProgressIndicator in TDocStd_Applacation.
2020-07-23 16:08:23 +03:00
Benjamin Bihler
d27293d9bf 0031677: Configuration - Allow Optimization Level O3 When Compiling With G++
Removed suppression of optimization level O3 with using Mingw64.
2020-07-23 16:08:22 +03:00
mkrylova
b011420f28 0031618: Data Exchange, RWGltf_CafWriter - exporting some models produces glTF files not passing validation
Added a check for non-empty mesh and new warning
that notifies about skipping an empty node
2020-07-23 16:08:22 +03:00
mkrylova
d533dafb56 0031035: Coding - uninitialized class fields reported by Visual Studio Code Analysis
Added initialization of fields that had not initialization
Added default constructors to classes without constructors
2020-07-23 16:08:20 +03:00
dpasukhi
078f916446 0028345: Data Exchange - Reading STEP model using STEPCAF crashes
# Add test to verify import
* Note: Each layer contains a valid name, but only one contains a link to the shape, so .step file contains only one valid Layer.
2020-07-23 16:08:19 +03:00
jgv
c28d4a89d4 0031617: Export STEP in nonmanifold mode corrupts the shape
Modify method XSControl_TransferWriter::TransferWriteShape: add removal of locations before writing the shape.
2020-07-23 16:08:19 +03:00
Benjamin Bihler
6531dfeacd 0031680: Configuration - Compilation Fails With G++ 10.1, LD 2.34 and Link-Time Optimization
Added a non-inline empty virtual destructor to LDOM_OSStream to force vtable generation in one
translation unit only.
2020-07-23 16:08:18 +03:00
kgv
dbc8becff4 0031673: Draw Harness, ViewerTest - command vlocation applies transformation in opposite order
gp_Trsf::SetRotationPart() - added method replacing rotation matrix without reseting other components,
similar to existing SetTraslationPart() and SetScaleFactor().

Transformation multiplication order has been fixed
for vlocation arguments -rotate, -translate, -mirror and -scale.
Added -prerotate, -pretranslate, -premirror and -prescale options following previous behavior.

vlocation -setRotation now uses new method gp_Trsf::SetRotationPart()
for consistency with methods -setLocation and -setScale.
2020-07-23 16:08:17 +03:00
kgv
99ee8f1a83 0031671: Coding Rules - eliminate warnings issued by clang 11
Fixed -Wdeprecated-copy warning by removing trivial operator=.
Fixed formatting issues in places producing -Wmisleading-indentation warning.
2020-07-23 16:08:17 +03:00
kgv
7465bfa65e 0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
OpenGl_Context now skips loading functions related to mapping buffer,
which are required by OpenGL ES 3.0 specs but not provided by WebGL 2.0.
Message_PrinterSystemLog does not use a broken emscripten_log() anymore, which corrupted UNICODE strings.

WasmOcctView::initWindow() - callbacks now set using EMSCRIPTEN_EVENT_TARGET_WINDOW
instead of 0 used by older Emscripten API.

Mouse callbacks now track canvas element and use
EmscriptenMouseEvent::targetX/targetY instead of ::canvasX/canvasY
as the latter was broken.

Added emscripten_set_main_loop() setup to shut up eglSwapInterval() error message.
Fixed missing \0 at the end of string converted by toUtf8Array().
2020-07-22 19:24:38 +03:00
azv
b939a13923 0031016: Projection of an ellipse is a B-spline in some cases
Improve projection of ellipse and circle on a plane in case of the same parametrization of the original curve and the projected one is not necessary. Now the projection is a canonical curve instead of B-spline.
2020-07-20 16:57:29 +03:00
emv
41ccce129d 0031662: Modeling Algorithms - Incomplete result of section operation
Integrating test case for the issue as the problem is not reproduced.
2020-07-11 11:35:18 +03:00
emv
529444be92 0031655: Modeling Algorithms - Invalid result of General Fuse operation
IntTools_BeanFaceIntersector: Perform exact intersection range search in case there are few intersection points.
2020-07-11 11:26:31 +03:00
mkrylova
210914d562 0030277: Coding Rules - avoid extremely long class names in STEP packages
Has changed the names of classes that are too long
and fixed names in files where these classes are used
2020-07-11 11:26:30 +03:00
akaftasev
3e85dfc5e5 0026555: Modeling Algorithms - Exception-safe status reporting in BRepOffset_MakeOffset
Set safe exit status for:
Standard_NullObject exception,
Standard_NullObject: BRep_Tool:: TopoDS_Vertex hasn't gp_Pnt,
BRep_Tool: no parameter on edge,
BRepOffset_MakeOffset::TrimEdge no projection
2020-07-11 11:26:29 +03:00
kgv
453103d191 0031637: Documentation - minor clean-up of User Guide for Visualization module
Fixed a couple of misprints, usage of changed classes / methods.
Added references to other supported 3d displays.
Added reference to PBR metallic-roughness material properties in addition to Common.

Cosmetics: removed numerous trailing spaces, double spaces.
Added missing {.cpp} language qualifier to code quotations.
Sentences within paragraphs have been split into multiple lines in source file.
2020-07-10 15:22:15 +03:00
akaftasev
3f54cc41a8 0027909: Modeling Algorithms - Exception during offset computation
Added function ChFi3d::IsTangentFaces for more accurate definition of connection type.
Test cases have been changed according to the current behavior.
2020-07-08 16:03:42 +03:00
ifv
e8e8b273bb 0029839: Modeling Algorithms - Unexpected Circle to BSpline surface extrema behavior
Extrema_ExtCS.cxx: treatment of small line segments is added;
Extrema_GenExtCS.cxx: treatment of particular cases curve-quadric and conic-surface are added
Extrema_GlobOptFuncCQuadric, Extrema_GlobOptFuncConicS: new distance functions for particular cases are added

BOPAlgo_PaveFiller_5.cxx : treatment of large common parts edge-face is improved
ElSLib.cxx : method TorusParameters(...) is modified to avoid divide by zero
math_PSOParticlesPool.cxx : initialization of array is added
2020-07-08 16:03:10 +03:00
emv
2a6b7c2306 0031604: Wrong result of Boolean Operation Cut
BOPAlgo_WireSplitter::Path - continue building the next loop with the last edge not included into found loop.
2020-07-08 16:03:10 +03:00
kgv
cdc54fb017 0031649: Visualization, TKOpenGL - broken skybox in VR output
OpenGl_ShaderManager::GetBgCubeMapProgram() and OpenGl_BackgroundArray::createCubeMapArray()
have been corrected to draw cube in straightforward way instead of a screen-quad.

Graphic3d_Camera::SetCustomStereoProjection() now recieves decomposed projection + head-to-eye matrices.
Added method Graphic3d_Camera::StereoProjection() returning projection matrix without translation part.
OpenGl_BackgroundArray::Render() now applies stereoscopic projection matrix in case of VR output,
but keeps using mono projection matrix in case of common 3D displays.
2020-07-08 15:53:32 +03:00
kgv
6d1d35e4b8 0031652: Visualization - crash on highlighting HLR Computed presentation displayed with Shaded display mode
PrsMgr_PresentationManager::displayImmediate() now uses proper ZLayer for a shadow presentation
of computed presentation (fixes dynamic highlighting on mouse move).
Graphic3d_CView::SetComputedMode() - added invalidation of bounding box on turning OFF compute mode.
AIS_ViewController::contextLazyMoveTo() now ignores MoveTo() while rotating
view with temporary disabled compute mode (leading to undefined results and crashes).

Graphic3d_Structure::Graphic3d_Structure() - do not copy Graphic3d_TOS_COMPUTED visual
from linked structure, as Graphic3d_CView::SetComputedMode() does not compute such structures.
2020-07-08 15:53:31 +03:00
kgv
72e9e86732 0031650: Visualization - invalid picking of object with local transformation and per-object clipping plane
SelectMgr_SelectingVolumeManager::SetViewClipping() now updates clipping range
using picking ray in world coordinates, as clipping planes are always defined in world space.
2020-07-06 18:31:14 +03:00
mzernova
3e9c1d1e5a 0029993: Visualization - AIS_TextLabel computes selection primitive only for attachment point
The text label is selected as a rectangle (adds a sensitive object - Select3D_SensitiveFace).
The bounding box has been resized to fit the sensitive rectangle.
Transform persistent has been added to AIS_TextLabel to correctly position the sensitive rectangle.
The findConnectedObject function has also been changed to correctly set transform persistence.
2020-07-06 18:31:13 +03:00
kgv
8f5760bc16 0031588: Visualization, TKOpenGl - display immediate updates in brackets within frame stats 2020-07-03 17:34:54 +03:00
kgv
6bd5d0a26d 0031647: Samples - do not enable floating point exceptions in MFC samples 2020-07-03 11:03:09 +03:00
emv
bea1065693 0031639: Modeling Algorithms - Offset algorithm incorrectly fills one of the holes
Check if unclassified edge may be added as neutral (invalid in one split, valid in other) by checking the SD faces in which the edge was classified.
2020-07-03 11:03:08 +03:00
kgv
8b742dc132 0031635: Documentation - minor clean-up of User Guide for Foundation Classes module
Changes in Technical Overview:
Corrected reference of "Mesh" as dedicated module, which is actually a Toolkit within "Modeling Algorithms" module.
Reduced references to "Configurable optimized memory manager",
which has not been updated for a long time and no more encouraged to be used as replacement of standard memory allocator of C library.
VRML/STL converters have been moved from section Mesh to Data Exchange.
Visualization chapter has been slightly reworded and reordered;
added references to PBR metallic-roughness material model.
Data Exchange chapter - reworded sentence "The exchanges run smoothly regardless of the quality of external data..."
to "This module handles various problems of interoperability between CAD systems...";
added AP242 to the list of STEP capabilities.

Changes in User Guide for Foundation Classes:
Removed references to "physical quantities" in package Quanity, deprecated since #0028799 and not actually used anywhere.
Adjusted description of string classes to avoid duplicated statements.
Collections section has been refactored to replace obsolete TCollection references by NCollection.
Remove obsolete statement "furthermore *catch()* statement does not allow passing exception object as argument".

Fixed broken nested enumeration in a couple of places.
Fixed usage of inappropriate quote symbols in code snippets.
Fixed references to non-existing classes like ZeroDivide instead of Standard_DivideByZero.
Removed suggested usage of Standard_Failure::Raise() instead of "throw Standard_Failure()" following #0026937.
Code snippets now suggest "catch(const Standard_Failure& )" instead of "catch(Standard_Failure )" (#0026937).
Fixed broken code snippets with lost symbols like <<.

Cosmetics: removed numerous trailing spaces, double spaces.
Added missing {.cpp} language qualifier to code quotations.
Sentences within paragraphs have been split into multiple lines in source file.
2020-07-03 11:03:07 +03:00
kgv
dad7fede39 0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying edge in AIS_Shape
Fixed unexpected calling of PrsMgr_Presentation::Erase() from Graphic3d_Structure::SetVisual().
2020-07-03 11:03:07 +03:00
kgv
7e251883e1 0031643: Visualization - Graphic3d_Camera::Copy() raises exception on copying ZNear < 0.0
Graphic3d_Camera::CopyMappingData() now copies ProjectionType at first.
2020-07-03 11:03:06 +03:00
kgv
d6fbb2aba4 0031632: Draw Harness - handle 3d mouse Raw HID input on Windows
WNT_HIDSpaceMouse - added auxiliary class for processing 3d mouse Raw HID input.
AIS_ViewController::Update3dMouse() - added default processor for 3d mouse input event.
ViewerTest now redirects WM_INPUT to AIS_ViewController::Update3dMouse().
Aspect_VKey enumeration has been extended by 3D view buttons.
WNT_Window::RegisterRawInputDevices() has beend added as a small wrapper
over WinAPI RegisterRawInputDevices() for common HID input devices.

AIS_ViewCube now stores animation duration within AIS_AnimationCamera instead of dedicated duplicating class property.
2020-07-03 11:03:05 +03:00
ifv
79e9ba31d2 0031616: Modeling algorithm - Section between two shells returns wire with gaps (720)
Adaptor3d_TopolTool.cxx, IntTools_TopolTool.cxx:

Anisotropy of BSpline surface along U and V direction is taken in account for calculation of numbers of sample points;

bug31616: test case added
2020-07-01 17:50:56 +03:00
mzernova
832a6f4412 0031279: Visualization, TKOpenGl - environment background is misplaced within Ray-Tracing
Fixed problem with misplacing background texture in Ray-Tracing.

An environment background is always drawn using a perspective matrix.
2020-06-26 15:07:40 +03:00
iko
4e8371cb1f 0031370: Documentation - provide information about PBR implementation
PBR documentation (math) has been added as developer guide.
2020-06-25 19:25:52 +03:00
kgv
d22962e4e0 0031621: Draw Harness - handle navigation keys
AIS_ViewController::handleNavigationKeys() - added an interface for processing navigation keys.
ViewerTest_EventManager now maps WASD+Arrows navigation keys.
Axonometric view hotkey A has been replaced by Backspace.
Shaded/Wireframe are now mapped with hotkeys W+Ctrl/S+Ctrl.
Hotkey D (reset view to undefined default state) has been removed.
2020-06-25 19:24:58 +03:00
mzernova
2ff1d580f1 0031412: Visualization - entity behind is returned as topmost at the edges
SelectMgr_RectangularFrustum now handles degenerated triangle as a segment or a point.
Triangle orthogonal to view direction is now handled as a segment.
myViewRayDir field is now defined as normalized vector to avoid confusing math.

For the case when the segment and myViewRayDir are almost parallel,
the segmentSegmentDistance function may set the depth to zero, although this will not
be the correct value, therefore it is better to pass a segment that will not
be parallel to myViewRayDir as an argument to the function.

vpoint command has been extended by arguments -2d and -nosel
for displaying picking mouse position as on-screen point in pixels.
Fixed double-binding-map error in case of displaying point with already used name.

bugs/vis/bug31412: test case added.
2020-06-25 19:09:04 +03:00
kgv
64f128c111 0031622: Samples - update MFC Animation sample with proper frame updates
Animation sample has been updated to:
- use reuse AIS_ViewController for general viewer manipulations;
- update animation using elapsed time;
- do not block camera manipilations;
- get rid of redundant controls.
2020-06-25 19:09:03 +03:00
kgv
08b7a39f75 0030939: Draw Harness, ViewerTest - AIS_ViewCube animation does not work on Linux and macOS
ViewerTest_EventManager::handleViewRedraw() now starts ViewerTest_ContinuousRedrawer
working thread to workaround Tcl event loop invalidation issue.
2020-06-25 19:09:02 +03:00
kgv
ceddb5ca9a 0031620: Samples - update Android JNI sample to use AIS_ViewController
Multi-touch input is now redirected to AIS_ViewController.
GLSurfaceView.RENDERMODE_WHEN_DIRTY is now used by 3D Viewer.
AIS_ViewCube is now displayed instead of trihedron.
2020-06-22 11:53:57 +03:00
kgv
bbe85f2b40 0031619: Samples - update JNI sample to use Android Studio
Project structure and project files have been updated to use Android Studio 4.0, gradle and CMake.
Redundant OcctJni_Window has been replaced by Aspect_NeutralWindow.
SD Card permissions are not dynamically requested for compatibility with Android API level 26+.
2020-06-22 09:19:06 +03:00
mpv
ef779ae0da 0031075: Application Framework - reading STEP file into TDocStd_Document leads to memory leaks
In the TDocStd_Owner keep simple pointer to TDocStd_Document instead of Handle. This causes automatic destruction of the document without explicit call of Close.
In Standard_Type added a static variable theType that initializes theRegistry map earlier. Otherwise exit from Draw interpreter crashes in many test-cases because not-closed transactions are aborted on document handle release from Draw theVariables map.

Corrected method for test OCC159bug due to the fact that Owner does not add a ref count now
Close the document in the end of bugs xde bug22776 otherwise double remove of visualization objects (on library exit and on visualization attributes remove from the document) causes crash on exit from draw
Added a new test bugs caf bug31075
2020-06-19 19:08:46 +03:00
ifv
003c363cf4 0031615: Coding - New warnings after integration fix for 0031552 2020-06-18 20:00:39 +03:00
ifv
dccf867561 0031602: [Regression vs 7.0.0] Modeling Algorithms - Invalid result of boolean operation
IntPatch/IntPatch_ImpImpIntersection_4.gxx : adding tolerance in comparison surface range and surface period
bug31602: test case added
2020-06-18 19:59:49 +03:00
ifv
5d904c3454 0031611: Modeling Algorithms - BRepOffsetAPI_NormalProjection - can't build wire in 720 but it was possible in 691
BRepLib_MakeWire.cxx:
in method BRepLib_BndBoxVertexSelector::Accept() accepting tolerance criterion is changed

BRepLib_MakeWire.hxx:
correctionof class field name

bug31611: test case added
2020-06-18 19:57:46 +03:00
mzernova
9a31c01064 0030922: Visualization - OpenGl_Text wrong local transformation if text has not own attach point
bugs/vis/bug30922: test case added
2020-06-16 14:29:41 +03:00
kgv
32b723d5c6 0031606: Configuration, CMake - build fails with Android NDK + CLang compiler + MinGW Makefiles
CLang is now checked before MINGW within occt_defs_flags.cmake.
Added "-Wl,-s" linker flag when using CLang for stripping symbols consistently to GCC builds.
2020-06-13 17:17:53 +03:00
jgv
36cc58f85d 0031485: Data Exchange - Export STEP in nonmanifold mode looses all faces except one
Small correction in STEPControl_ActorWrite::TransferCompound - take into account the case when a subshape has type TopAbs_FACE.
2020-06-10 20:41:40 +03:00
emv
09543c2d99 0031587: Modeling Data - add BRepTools::RemoveInternals() removing internal sub-shapes from the shape 2020-06-09 20:01:06 +03:00
kgv
a7400019ce 0031599: Visualization - when using AIS_Manipulator, the scene rotates at the same time
AIS_ViewController::HandleViewEvents() - reverted order of handleMoveTo() and handleCameraActions() events.
2020-06-09 19:53:08 +03:00
akaftasev
1fc1a207b0 0031504: Data Exchange - Wrong output of progress indicator when writing to stl
Added new condition for first indicated element at Draw_ProgressIndicator::Show(),
because it’s more logical that at start progress starts at 0
Changed usage of Next() to Next(step) for increment progress to IND_THRESHOLD in RWStl::writeASCII() and RWStl::writeBinary()
Changed condition for continuation of writing and add interrupt to this function
Added possibility to use Progress indicator in writestl
Changed paremeter in constructor Message_ProgressSentry aPS() IND_THRESHOLD to 1
Changed test
2020-06-09 19:53:08 +03:00
kgv
59ec2ccec9 0031596: Visualization, OpenGl_Context - take GL_OES_texture_float extension into account for arbTexFloat flag 2020-06-09 19:53:07 +03:00
kgv
d4cefcc0da 0031477: Visualization, TKOpenGl - fetch/wrap getBufferSubData() function from WebGL 2.0
Added OpenGl_Context::GetBufferSubData() implementing getBufferSubData() based on capabilities of various APIs.
Added OpenGl_VertexBuffer::GetSubData() similar to OpenGl_VertexBuffer::SubData().
2020-05-29 19:40:57 +03:00
kgv
872f98d9ef 0031583: Visualization, OpenGl_Context - load OpenGL ES 3.0 functions
OpenGl_Context now retrieves complete functions sets of OpenGL ES 3.0, 3.1 and 3.2.
2020-05-28 10:24:35 +03:00
vsv
2ba1172b73 0031573: Visualization - Do not show seam edge for shading presentation with boundary edges in VTK 2020-05-28 10:22:54 +03:00
kgv
e4e3254a35 0031580: Visualization, TKOpenGl - cubemap initialization error on OpenGL ES 2.0
OpenGl_Texture::InitCubeMap() now avoids using sized internal format in case of GLES2.
OpenGl_Sampler::applySamplerParams() now checks OpenGL version before setting GL_TEXTURE_WRAP_R.
2020-05-28 10:21:03 +03:00
mkrylova
04c5a696e4 0029917: Foundation Classes - OSD_FileNode AccessMoment and CreationMoment return the same date on Windows
fAccess in CreationMoment() function for Windows has been modified from TRUE to FALSE
2020-05-28 10:18:56 +03:00
ika
ae58f70718 0031568: Data Exchange - invalid model produced after STEP import
Add protection against reference to reference in STEP import.
2020-05-22 19:32:21 +03:00
kgv
faff37677c 0031478: Visualization, TKOpenGl - allow uploading Cubemap in compressed DDS format when supported by GPU
Graphic3d_TextureRoot::GetCompressedImage() - added new interface for fetching compressed texture image.
Default implementation detects DDS image files using Image_DDSParser parser.

Graphic3d_TextureRoot::GetImage() has been extended with new parameter
- the list of image formats supported by OpenGL driver.
Graphic3d_TextureRoot::convertToCompatible() implicitly converts
BGRA image to RGBA on OpenGL ES, which normally does not support BGR formats.

OpenGl_Caps::isTopDownTextureUV - new property defines how application defines
UV texture coordinates in primitive arrays.
OpenGl_Context::SetTextureMatrix() compares this flag with OpenGl_Texture::IsTopDown()
and automatically flips V coordinate in case of mismatch.

OpenGl_Texture now holds exact number of mipmap levels
instead of Boolean flag indicating that they are defined.
This allows loading DDS files with incomplete mipmap level set
by setting GL_TEXTURE_MAX_LEVEL to appropriate value instead of default 1000
(causing black textures in case if mipmap levels are not defined till 1x1).

Fixed order of texture coordinates transformation within GLSL program to match FFP matrix:
Rotate -> Translate -> Scale (previously Rotation was applied afterwards).
2020-05-22 11:08:34 +03:00
Igor Khozhanov
691711cd3e 0031550: Data Exchange, STEP Import - surface transparency is ignored (SURFACE_STYLE_TRANSPARENT)
Implemented reading and writing transparency to/from step files
2020-05-22 11:07:37 +03:00
ifv
8189cc72d0 0028229: BRep_Builder::Transfert must not raise exception if the input edge is Locked
BRep/BRep_Builder.cxx : raising exception is removed
2020-05-22 11:07:36 +03:00
jgv
c6f14a5213 0031558: BRepOffsetAPI_MakeFilling algorithm makes turned inside out face
1. Modification in method BRepFill_Filling::Build - correction of building the wire.
2. Create new subgroup "filling" in the group "bugs".
2020-05-22 11:07:35 +03:00
vsv
4db6748cc5 0031544: Visualization - show boundaries of faces in shading mode of VTK presentation 2020-05-15 18:39:31 +03:00
kgv
158f2931a7 0031004: Coding - eliminate warnings issued by gcc 9.1.0
Fixed -Wrestrict warning within OSD::SetSignal().

Fixed -Wdeprecated-copy warning by adding missing counterpart
in pair copy constructor / assignment operator or by removing trivial constructor.

AdvApp2Var_Node, AdvApp2Var_Patch are now declared as Handle.
AdvApp2Var_Iso is now passed by Handle.

Disabled operator= for TDF_Transaction and TDF_IDFilter.

Standard.cxx - fixed GCC version mischeck causing building failure with experimental GCC versions.

TopOpeBRepDS_EXPORT.cxx - fixed -Wmaybe-uninitialized warnings.
2020-05-15 18:08:07 +03:00
emv
4b59685af1 0031542: Modeling Algorithms - Offset algorithm produces incomplete result in mode "Complete" join type "Intersection"
Mark unchecked edges originated from vertices as invalid if they are contained in invalid faces.
2020-05-15 18:05:59 +03:00
emv
9e9b826aa1 0031307: Modeling Algorithms - Offset algorithm produces incorrect result in mode "Complete" join type "Intersection"
Do not classify edges originated from combination of edges and vertices as the classification will likely be unstable.
Mark faces containing valid inverted edges as invalid but do not remove them from valid splits.

Extend the debug command DBRep_SetComp to allow different containers for creating the TopoDS_Compound.
2020-05-15 18:05:58 +03:00
ifv
64e8b010af 0031552: Bad performance of intersection of cylindrical surfaces
Adjusting parameters of algorithm depending on axes and parameters of cylinders is added in order to reduce computation time

Test case added: tests/lowalgos/intss/bug31552

tests/perf/modalg/bug26310_1: test case corrected according to current state of algorithm
2020-05-15 18:00:48 +03:00
jfa
1b6e8b9f09 0031565: Visualization - SIGFPE, Arithmetic exception if SelectMgr_TriangularFrustumSet::Build() is called with single point 2020-05-15 18:00:47 +03:00
dpasukhi
b04decfaae 0029240: Data Exchange - Crash during reading STEP file
- Issue is done in previous version OCCT
- Add test to verify import
2020-05-14 20:28:22 +03:00
ifv
79aa9b5cf6 0027087: [Regression to OCCT 6.7.1] BRepExtrema_DistShapeShape gives wrong result
Extrema_ExtCs.cxx: number of subdivision is incresed for curve;

Modifications to fix regressions of some tests
IntTools_BeanFaceIntersector.cxx: restriction of curve, which is used in Extrema_ExtCS
ProjLib_CompProjectedCurve.cxx: tolerance is reduced for Extrema_ExtCS
BRepOffset_Tool.cxx: checking common vertex if it is Null

tests/bugs/modalg_7/bug27087 : test case added.

tests/bugs/modalg_5/bug25232_8 : test is modified according to new behavior of algorithms
2020-05-14 20:24:45 +03:00
dpasukhi
72e6020d50 0026925: Data Exchange - Exception can be raised if assembly is empty
- Issue is done in previous version OCCT
- Add test to verify the creating of the label structure using plain OCAF/XDE API
- Situation when the assembly label has no shape attached is correct
2020-05-12 19:51:12 +03:00
kgv
a87b1b3738 0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument -- use shortcuts
Message::DefaultMessenger()->Send() have been replaced by shortcuts Message::Send().
2020-05-09 17:22:15 +03:00
kgv
fa8a462827 0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument
The argument putEndl has been removed from Message_Messenger::Send() and Message_Printer::Send() methods.

Message_Printer interface has been changed, so that sub-classes have to implement new method
Message_Printer::send() accepting TCollection_AsciiString.
Old three Message_Printer::Send() methods remain available without putEndl argument
and redirecting to new send() method by default.

Removed dummy Message_PrinterOStream::GetUseUtf8() property.
Message_PrinterOStream, Message_PrinterSystemLog and Draw_Printer
now implement single method Message_Printer::send() instead of triplet.
2020-05-09 17:22:14 +03:00
abv
0ebe5b0a7f 0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument -- preparation
Operators << for Handle(Message_Messenger) are removed; their use is replaced by use of Message_Messenger::StreamBuffer
Message_Messenger has been replaced by Standard_OStream within Interface_InterfaceModel,IFSelect,IGES,STEP dump interfaces.
2020-05-09 17:22:13 +03:00
abv
39c8dc708f 0031546: Application Framework - Memory leak (100 bytes) on Load / Close OCAF document
Class Standard_BaseDriver is inherited from Standard_Transient, its descendants are updated accordingly.
Handle is used to manipulate objects of this class and its descendants (instead of references or raw pointers) to ensure automatic destruction.

Added test bugs caf bug31546

Related:
- Standard_OVERRIDE is added in declarations of virtual methods in descendants of Storage_BaseDriver
- Methods operator << and operator >> are removed in descendants of Storage_BaseDriver (they repeat the same methods inherited from the base class)
- Typedef PCDM_BaseDriverPointer is marked as deprecated
- Unused class DDI_Ostream is removed
- Private field Standard_Transient::count is renamed to myRefCount_ to avoid compiler warnings if the same name is used within the scope of a descendant class
- Output of meaningful error messages is restored in DRAW commands fsdread and fsdwrite
2020-05-07 21:24:46 +03:00
ifv
dcc4e908c2 0030185: Unify same domain algorithm corrupts the initial shape
ShapeUpgrade_UnifySameDomain.cxx: checking of surface domains and projection to get pcurves are added
tests/bugs/heal/bug30185: test case added
2020-05-07 21:23:16 +03:00
kgv
b40cdc2b55 0029384: Visualization, TKOpenGl - basic integration with OpenVR
V3d_View::AutoZFit() is now called only before redraw
within methods V3d_View::Redraw() and V3d_View::Update().

Graphic3d_CView now holds Aspect_ExtendedRealitySession object.
Aspect_OpenVRSession implements new interface via optional OpenVR library.
Graphic3d_CView::ProcessInput() - added new interface method
which should be called for processing positional input (head tracking).

Graphic3d_Camera now allows setting custom stereoscopic Projection matrices.

OpenGl_Context::Camera() - context now holds Camera object
in addition to active camera matrices.

genproj.tcl has been extended to handle optional CSF_OpenVR dependency.
2020-05-06 20:45:53 +03:00
kgv
2615c2d705 0031548: Visualization, SelectBasics_PickResult - include surface normal into picking details
SelectMgr_SortCriterion::Normal, SelectBasics_PickResult::SurfaceNormal() - added new property.
SelectMgr_RectangularFrustum::Overlaps() for triangle sets new normal property.
gp_GTrsf::GetMat4() - added conversion into NCollection_Mat4 similar to gp_Trsf::GetMat4().
2020-05-06 19:09:53 +03:00
kgv
23fe70ec52 0031189: Draw Harness, ViewerTest - send messages to Message::DefaultMessenger()
Added short-cuts methods in Message_Messenger for sending message with specified gravity,
and stream buffer class for using stream-like interface for that.
Similar short-cuts to DefaultMessenger() are added in Message package.

ViewerTest has been updated to send messages to Message::DefaultMessenger()
instead of direct output to std::cout/std::cerr.

Off-topic: spelling error (duplicate "and") is corrected in two places

Added test bugs fclasses bug31189
2020-04-30 19:42:44 +03:00
ika
331bcfc0d0 0031517: Data Exchange - wrong result of ShapeTool::UpdateAssemblies()
Get rid of problem with updating of parents shared one assembly.
2020-04-29 20:45:52 +03:00
kgv
7ff18fb9cc 0031521: Samples - update MFC ImportExport sample to use AIS_ViewController
The following MFC samples have been updated to use AIS_ViewController:
Geometry, HLR, ImportExport, Modeling, OCAF, Triangulation, Viewer2D.
2020-04-29 20:44:15 +03:00
nds
ab9e277f15 0031193: Visualization - OpenGl_Flipping wrong text position if local transformation set
Before the patch, if the values of the isReversedX/Y/Z variables were set to false, then the WorldView matrix did not change and local transformation was not applied, which caused errors.
In order to correctly set the local transformation in case the text does not have its own attach point, the local transformation is set in OpenGl_Text, and the ModelWorld matrix is changed in OpenGl_Flipper, instead of the WorldView matrix. In this case, local transformation will always be applied.

bugs/vis/bug31193: test case added
2020-04-29 16:36:23 +03:00
kgv
0439d1cf44 0031518: Samples - update QtWidget samples to use AIS_ViewController
Qt samples IESample and Tutorial have been updated to use AIS_ViewController for view manipulations.
2020-04-26 11:33:26 +03:00
kgv
e1c9a10311 0031519: Visualization, AIS_ViewController - add AIS_MouseGesture_ZoomWindow gesture
AIS_ViewController now supports AIS_MouseGesture_ZoomWindow gesture,
which displays zooming window via Rubber-Band rectangle.
2020-04-24 20:03:50 +03:00
kgv
9ad4ff93a0 0031511: Point Cloud Rendering, Volume Rendering - reuse Graphic3d_CullingTool
Graphic3d_CullingTool::IsCulled() has been extended with theIsInside argument for full inclusion test.
Graphic3d_Layer::UpdateCulling() now avoids frustum culling tests for BVH children for parent nodes completely included into frustum.
Graphic3d_CullingTool::SetViewVolume() has been extended by optional model-world matrix.
2020-04-24 20:03:50 +03:00
kgv
89fcfe1551 0031512: Foundation Classes - drop unused class NCollection_Comparator 2020-04-23 10:45:50 +03:00
mzernova
a24a782174 0031440: Visualization - Impossible to make common behaviour for multi-selection in viewer
A special mode for the selecting by polygon is added to select only completely overlapping objects.

In order to track the sensitives that were included completely by defined polygon, the boundary points of the polygonal frustrum are stored in the variable myBoundaryPoints.

If an sensitive intersects with at least one of the frustrums from myFrustums, then checking whether this object intersects with borders using the isIntersectBoundary method; if not, then the sensitive were included completely by defined polygon.

Because the polygon can be concave, then to check the sensitive were included completely by defined polygon, it is not enough to check of all its points, it is necessary that the edges of the sensitive do not intersect polygonal frustrum. To do this, for polygonal selection, a call to the Overlaps method for a point was replaced by a call to a segment where necessary.

bugs/vis/bug31440: test case added
2020-04-23 10:44:30 +03:00
jgv
5a2f31c887 0031492: BRepBuilderAPI_MakeFace crashes on a wire
Method BRepClass_Intersector::LocalGeometry is modified: check whether is tangent defined and check of infinite curvature is added.
2020-04-20 20:36:27 +03:00
akaftasev
67a843c0d4 0031318: Documentation, TopoDS.hxx - typo in the reference manual
change "onject" to "object" in description of TopoDS class
2020-04-17 18:45:50 +03:00
kgv
b9f43ad13b 0031505: Point Cloud Rendering - fix on-screen statistics about number of visible points
OpenGl_Element now provide methods ::UpdateMemStats() and ::UpdateDrawStats()
for unified request of statistics used by OpenGl_FrameStats instead of direct handling of OpenGl_PrimitiveArray.
Graphic3d_FrameStatsCounter counters list has been extended by Graphic3d_FrameStatsCounter_NbLinesNotCulled.
2020-04-17 18:36:43 +03:00
kgv
b8a00b410a 0031502: Coding - New warnings after integration fix for 0031456
Deprecated AIS class aliases have been moved from PrsDim to AIS package.
2020-04-17 17:43:00 +03:00
dpasukhi
e00b8ed948 0031435: Data Exchange - Problem importing STEP files
- Fix recursion in EntityCluster's methods :
  -  Value
  -  SetValue
  -  Append
- Add destructor in the EntityCluster
- Add check null grade in the STEPCAFControl_GDTProperty::GetDimClassOfTolerance
2020-04-16 20:43:51 +03:00
emv
590b3f0416 0031499: Boolean Operations - Custom fuzzy value corrupts the result of CUT
IntPatch_ImpImpIntersection::CyCyNoGeometric - Use the provided 3D tolerance to compare the points.
2020-04-16 10:01:55 +03:00
emv
62fbfa9856 0031207: Regression in Boolean Operations: fuse gives wrong result
ForceInterfEE, ForceInterfEF - Use normalized vectors for angle computation. Increase the criteria angle.
2020-04-16 10:00:54 +03:00
ifv
1f9cb9f999 0031496: Modeling Algorithms - BRepAlgo::ConcatenateWireC0() crashes
BRepAlgo.cxx: fixing of wrong treatment of reversed edges
bug31496: test case added
2020-04-16 09:59:25 +03:00
jgv
13dd311c9b 0031470: Modeling Algorithms - Regression: BOP common produces empty result (box and holed sphere)
Approx_ComputeCLine.gxx : new class field is added to manage hang checking.
ProjLib/ProjLib_ComputeApprox.cxx : unset hang checking for analytical surfaces and curves
2020-04-16 09:58:15 +03:00
gka
1e1b83c07b 0031472: Exception raised during translation of the STEP entity Constructive Geometry Representation containing one representation
Modification number of the representation items are considered for STEP entity "Constructive Geometry Representation"
2020-04-10 17:43:52 +03:00
kgv
8f08e231fa 0031490: Foundation Classes, Poly_Connect - speed up temporary allocations
Poly_Connect::Load() now uses NCollection_IncAllocator instead of new/delete
for allocation temporary sequence elements.

StdPrs_ShadedShape, fillFaceBoundaries() now uses NCollection_IncAllocator for temporary points.
2020-04-10 17:41:40 +03:00
ifv
f0ada3e8d4 0031469: BRepFeat_MakePrism failed
BRepFeat_Form.cxx: methods IsDeleted, Modified, Generated are corrected
BRepTest_FeatureCommands.cxx: history treatment is added in methods DEFIN and PERF
bugs/modalg_7/bug31469: test case added
2020-04-10 17:41:39 +03:00
jgv
9171cefaad 0031464: BRepOffsetAPI_MakeFilling algorithm increases tolerances of vertices in input edges
Modify history in BRepFill_Filling: now vertices are also stored in the map.
2020-04-10 17:41:39 +03:00
kgv
247ecf1b16 0031483: Configuration - __asm keyword not supported on ARM within Windows target
_M_IX86 is now checked before using _asm fot TBB workaround.
2020-04-10 17:41:38 +03:00
emv
3f7e5e99d5 0031462: Modeling Algorithms - BOP result depends on the arguments order
Eliminate numerical instability by ensuring that the tolerance of intersection entities is slightly grater than the actual distance to the shapes creating the entity.
2020-04-01 20:44:23 +03:00
kgv
6d43db4f74 0031471: Confuguration, genproj - unable to build OCC Products
Restored parsing of src/VAS/Products.tcl.
2020-04-01 13:42:12 +03:00
emv
128654b60b 0031461: Mesh - Add possibility to force the meshing of the shape
BRepMesh: Add new mesh parameter *AllowQualityDecrease* which affects the criteria used for checking of the consistency of the existing mesh to new meshing parameters.
So if set to true it will force the meshing of the shape if current deflection strongly vary from the new one, no matter in which side.

BRepTools::Clean: Keep triangulation on non-geometric shapes (faces with no surface or edges with no curves).
2020-04-01 13:36:29 +03:00
osa
21095f2dc2 0031468: Visualization - add public interface to return embedding a single fallback font 2020-04-01 13:34:08 +03:00
kgv
420f5c8682 0031467: Foundation Classes, OSD_MemInfo - disable reading /proc/%d/status with Emscripten
OSD_MemInfo::Update() no more uses procfs with Emscripten.
OSD_MemInfo::MemVirtual counter is now set to WebAssembly module heap length.
2020-03-27 18:03:20 +03:00
kgv
85b147584e 0031465: Data Exchange, RWObj_Reader - skip duplicating smooth groups
RWObj_Reader::pushSmoothGroup() now ignores smooth groups statements pointing to the same group.
2020-03-27 18:01:01 +03:00
kgv
7f24b768c3 0031458: Visualization - refine classes across Prs3d and StdPrs packages
Prs3d::GetDeflection() has been moved to StdPrs_ToolTriangulatedShape::GetDeflection().
Prs3d_ShapeTool has been moved to StdPrs_ShapeTool.
Code collecting free edges on Poly_Triangulation
has been moved out from StdPrs_WFShape to Prs3d::AddFreeEdges().
StdPrs_BndBox has been moved to Prs3d_BndBox.
Geom_Transformation has been replaced by TopLoc_Datum3D within visualization classes.

Select3D_SensitiveCircle constructor now takes gp_Circ instead of Geom_Circle.
StdSelect_ViewerSelector3d has been moved to SelectMgr_ViewerSelector3d.
Methods ::GetPoint3d() and ::ArrayBounds() has been moved
from subclass Select3D_SensitiveCircle to the base class Select3D_SensitiveCurve.
StdSelect_ViewerSelector3d::computeSensitivePrs() has been moved to SelectMgr::ComputeSensitivePrs().

Removed unused declarations StdSelect_Prs, StdSelect_DisplayMode,
StdSelect_SensitivityMode, StdSelect_TypeOfResult, SelectMgr_SOPtr, TColQuantity.

Package Graphic3d has been moved from TKV3d to TKService.
2020-03-27 17:58:02 +03:00
kgv
787ff2408c 0031456: Visualization - move out Dimensions and Relations from package AIS to PrsDims
The following classes and their subclasses within AIS package
have been moved to new package PrsDim and renamed:
- AIS_Relation  -> PrsDim_Relation;
- AIS_Dimension -> PrsDim_Dimension,
2020-03-27 17:58:00 +03:00
mzernova
64943a5187 0031459: Visualization, AIS_TextLabel - add missing getters
Add getters for Text, FontName and FontAspect
Remove duplicate properties: Font and FontAspect
2020-03-26 19:59:16 +03:00
jgv
486ad71287 0031441: UnifySameDomain corrupts the shape
Local function TransformPCurves is modified to process correctly same-domain elementary surfaces with different local coordinate systems.
2020-03-26 19:57:52 +03:00
oan
c9125b6232 0031378: Modeling algorithms - brep incremental mesh is frozen during STEP file loading
Refactoring of BRepMesh_Delaun::isBoundToFrontier() to unwind the recursion loop.
2020-03-26 19:56:21 +03:00
ifv
87c7d55469 0031415: Modeling Algorithms - Solid classifier works incorrectly on a cylinder
BRepClass3d_SClassifier.cxx : revert integration for CR29712

Test case added
2020-03-26 19:54:58 +03:00
abv
14b741b0ef 0031454: Visualization - perceptually uniform color scale
Support of CIE Lab and Lch color spaces is introduced in Quantity_Color:
- Enumeration Quantity_TypeOfColor is extended by new values representing CIE Lab and Lch color spaces (with D65 2 deg illuminant).
- Conversion of RGB color to and from these color spaces is implemented in Quantity_Color class (within existing API).
- Color difference calculation using CIE Delta E 200 formula is implemented in method DeltaE2000().

New methods MakeUniformColors() and SetUniformColors() are added in class AIS_ColorScale, generating and setting color scale based on colors of the same lightness in CIE Lch color model.

DRAW commands vcolorconvert and vcolordiff are added to perform conversions and compute difference, respectively.
A new option -uniform is added in DRAW command vcolorscale, to set uniform color scale.

Added test grid v3d colors (color conversions and difference), test bugs vis bug31454 (uniform color scale)
2020-03-26 19:53:27 +03:00
gka
89180f9822 0029803: STEP Import: Units (inch) not applied to entity possessing GEOMETRIC_REPRESENTATION_CONTEXT
Translation of the entities AXIS2_PLACEMENT_3D including in the entity CONSTRUCTIVE_GEOMETRY_REPRESENTATION_RELATIONSHIP was added.
Entity  AXIS2_PLACEMENT_3D is translated to the planar face with axis equal to AXIS2_PLACEMENT_3D.
New parameter "read.step.constructivegeom.relationship" is added to enable this translation (by default it is OFF).

Added test bugs step bug29803
2020-03-25 19:52:12 +03:00
ifv
517ba7aa70 0031460: Modeling Algorithms - Regression: Revolution not done.
BRepPrimAPI_MakeRevol.cxx: check of intersection of edge with rotation axis is improved.
Test case added
2020-03-24 19:57:37 +03:00
antonavt
68064d7bc3 0028880: Modeling Algorithms - add missing BRepFeat_SplitShape::Right() getter
- Added Right() method to BRepFeat_SplitShape;
- Added an option in command buc60854, which allows to select Left() or Right() method;
- Modified method BUC60854 in QABugs_14.cxx;
- Added new option to the help of command buc60854;
- Modified test case buc60854. Now its state is "OK";
- Added check Right() in buc60854 test case.
2020-03-24 19:55:05 +03:00
abv
62afcbbb4a 0031455: Modeling Algorithms - useless pointer casts in BRepAlgoAPI classes
Useless casts are removed.

Off-topic: corrected description of constructor of TCollection_HAsciiString class from TCollection_HExtendedString for the case when input string contains non-Ascii character.
2020-03-23 09:51:39 +03:00
gka
7ef1f9b7c1 0031301: Data Exchange - Export to STEP corrupts the shape
For small edges fully covered by tolerances of vertices BSpline periodic curves are converted to not periodic BSpline curves by cutting segment before writing.
In the class TopoDSToStep_MakeStepEdge permute of edge vertices for closed curves was added for the case when the range obtained from the vertex projection contradicts the edge range in order to avoid computation of the invalid edge range after reading.

Second test script for bug 0031301
2020-03-20 10:24:10 +03:00
kgv
877fd611ac 0031442: Samples - remove unsupported sample mfc/occtdemo 2020-03-20 10:22:25 +03:00
kgv
dc9f1dbf69 0031445: Advanced wrappers, C# wrapper - provide device info in About dialog of WPF sample
D3DHost_View::DiagnosticInformation() now appends D3D device information to the map.
2020-03-19 19:08:10 +03:00
ifv
895a80d38a 0031404: Modeling Algorithms - BOP Fuse produces a self-interfering or a good shape depending on the order of arguments
Approx_ComputeCLine.gxx : number of possible cuttings is increased

tests/bugs/modalg_7/bug31404 : test case added
2020-03-19 19:00:58 +03:00
gka
6a9f983a16 0030052: Data Exchange - STEP import missing surfaces
Changes made for #31233 are reverted.

Correction in the ShapeFix_ComposeShell:
 Modification of the method SplitByLine in order to find all points of the intersection for case when initial curve shifts in the positive or negative direction
 to avoid splitting edge when split point lies in the limits of the tolerance of the vertex.
 to correct shift of the pcurves for case when initial shift is more than 1 in the method ShapeFix_ComposeShell::SplitByLine

In the method ShapeFix_Face::FixMissingSeam added removing small edges having length less than working precision and removing wires having area less than working precision

Modified test cases; added test for related issue: bugs step bug31301
2020-03-18 20:03:05 +03:00
mgn
22fa1da36e 0031439: Visualization - Access to the active axis of AIS Manipulator
A new method that returns the active axis of the manipulator has been added.
2020-03-18 19:39:38 +03:00
Roman Lygin
fb99177766 0031430: Offset surfaces on C1 surfaces (with multiplicity equal to degree) may still throw exception
In constructor of Geom_RectangularTrimmedSurface, skip check if an offset surface has insufficient continuity. The reason is that this surface has already passed the check once created. So, here we must not apply more strict check than that first time.
2020-03-18 19:38:12 +03:00
kgv
67441d0ca3 0031424: Visualization - stop using Prs3d_Drawer::HLRAngle() parameter
Prs3d_Drawer, AIS_Shape, AIS_InteractiveContext - removed properties HLRDeviationCoefficient() and HLRAngle().
Prs3d_Drawer::HLRAngle() is kept as alias to Prs3d_Drawer::DeviationAngle() with deprecated flag.
Prs3d_Drawer::DeviationAngle() default value is changed from 12 to 20 degrees
to match Prs3d_Drawer::HLRAngle() which has been previously used in majority of cases.
Removed unused property HLRBRep_PolyAlgo::Angle().
2020-03-16 16:56:30 +03:00
kgv
b5163d2f8d 0031431: Visualization, PrsMgr_PresentableObject - simplify HLR computing interface
Multiple PrsMgr_PresentableObject::Compute() methods have been replaced by single one
PrsMgr_PresentableObject::computeHLR().
Dummy implementations of previously declared methods have been removed
from AIS classes not implementng HLR presentation.
Class Prs3d_Projector has been removed and Graphic3d_Camera is now passed directly,
so that redundant dependency from HLRAlgo_Projector in Prs3d interfaces has been eliminated.
StdPrs_HLRShape and StdPrs_HLRPolyShape now implement common interface StdPrs_HLRShapeI.
2020-03-16 16:56:28 +03:00
kgv
29263c947e 0031425: Visualization - free Edge has selection sensitivity inconsistent to presentation
BRepTools::Triangulation() has been extended with a new parameter for checking Poly_Polygon3D presense within free Edges.
StdPrs_WFShape::Add() now performs auto-triangulation in the same way as StdPrs_ShadedShape::Add().
StdSelect_BRepSelectionTool::GetEdgeSensitive() now creates Select3D_SensitiveSegment instead of Select3D_SensitiveCurve for tessellated segment.
Select3D_SensitiveSegment default sensitivity factor has been changed to 3 pixels to match Select3D_SensitiveCurve.

Test case bug23625_1, added workaround for out-of-range crash in HLRBRep_PolyAlgo on re-triangulated shape.
2020-03-12 19:29:23 +03:00
kgv
08669adf1b 0031419: Visualization, TKOpenGl - per-object Graphic3d_TOSM_FACET is ignored within obsolete FFP
OpenGl_ShaderManager::PushState() now sets GL_SHADE_MODEL within FFP.
OpenGl_Context::SetShadeModel(), added property holding cached GL_SHADE_MODEL state.
2020-03-11 18:37:12 +03:00
ifv
68ad329c9d 0031303: Different calculation of offset direction in Adaptor2d_OffsetCurve and Geom2d_OffsetCurve
Calculations in Adaptor2d_OffsetCurve are unified with similar calculations in Geom2d_OffsetCurve using   methods extracted from Geom2dEvaluator_OffsetCurve to Geom2dEvaluator.cxx

BRepFill_OffsetWire.cxx, Geom2dGcc_Circ2d2TanRadGeo.cxx, Geom2dGcc_Circ2dTanOnRadGeo.cxx, MAT2d_Circuit.cxx are modified to satisfy changing offset direction.
2020-03-11 16:37:50 +03:00
azv
d6e18114eb 0031407: [Regression to 7.3.0] Extrema does not process parallel circles correctly
Use correct ranges of circles when processing the concentric case. Repeat the range comparison 3 times shifting each time for a half-period to process the extrema between boundary points of arcs.
2020-03-06 16:05:19 +03:00
kgv
e5c11edd7b 0031405: Advanced wrappers, C# wrapper - dark colors in WPF sample
D3DHost_FrameBuffer::IsSRGBReady() - added new propery defining if
D3D application handles FBO as sRGB-ready texture or not.
2020-03-06 16:03:33 +03:00
ifv
fffc249f21 0027531: Modeling Algorithms - Make the algorithm Approx_SameParameter more clear and robust
Approx/Approx_SameParameter.cxx,hxx:
Class Approx_SameParameter refactoring. Logic is changed in many places to unify usage, simplify maintenance.
Method Curve2d() is changed to return Geom2d_Curve instead of Geom2d_BSplineCurve. Corresponding message is added to the upgrade guide.
.lxx file is merged into .hxx.
Tangent computation is extracted into special method.
Comparing number of sample points after CheckSameParameter(...) is added to define cases with projection fails.
Undesirable behavior when curves are not same parameterized is fixed.

Geom2dAdaptor/Geom2dAdaptor.cxx: treatment of offset curve is added

Adaptor3d/Adaptor3d_TopolTool.cxx: minor improvement of performance for BSpline surfaces with huge number of knots

Tests were modified according to new behavior of sameparameter algorithm
2020-03-06 15:54:46 +03:00
emv
739c7e5968 0030386: Modeling Algorithms - Unable to perform Cut operation
Get rid of requirement for the arguments of Boolean operations of type CUT and COMMON to be one-dimensional shape. For FUSE operation this requirement is kept.
2020-03-04 19:17:16 +03:00
ifv
f732ea1ab5 0031381: Foundation Classes -wrong evaluations for rational BSpline curves using Adaptor curves
BSplCLib_Cache.cxx - it is forbidden zeroing derivatives for rational splines when derivative order more than degree

bug31381 - test case added
2020-03-03 17:49:09 +03:00
vro
ae87bb87d0 0031400: Application Framework, TPrsStd_AISPresentation - Ocaf selection mechanism doesn't allow multiple selection
TPrsStd_AISPresentation::ActivateSelectionMode() uses Multiple enumeration for definition of the selection mode instead of GlobalOrLocal.
2020-02-28 21:02:40 +03:00
kgv
3d60d73f76 0031394: Visualization, TKOpenGl - define OpenGl_Element::EstimatedDataSize() interface
OpenGl_FrameStats::updateStructures() now relies on OpenGl_Element inteface
instead of handling OpenGl_PrimitiveArray specifically
for collecting Graphic3d_FrameStatsCounter_EstimatedBytesGeom counter.
OpenGl_PrimitiveArray and OpenGl_Text implement new interface.
2020-02-28 21:02:40 +03:00
nds
0950253ca6 0031366: Documentation - Doxygen warnings in Standard_Dump.hxx 2020-02-22 13:01:25 +03:00
nds
f6d8ca74d5 0030749: Inspectors - compilation under tcl scripts
- 'Search Qt4' is renamed into 'Search Qt'. Configuration uses Qt5 from now. For Qt4 use CMake configuration.
- 'Build Inspector' check box is added. It causes 'tools' toolkits compilation. Activates automatically 'Search Qt' control.
- Many Tcl procedures are extended with additional parameter to giving a directory of processed toolkits. The default directory is 'src', inspector directory is 'tools'. This way is similar Inspector compilation implemented in Cmake build procedure.
- Dependency libraries in DEBUG are stored in __TKDEP_DEBUG__. Qt requires it as names of debug and release libraries are different.
2020-02-20 18:33:01 +03:00
vro
00cdefc7a2 0030101: Application Framework - A mistake reading a RealArray attribute with too small value
A case of reading of a very small value was skipped, for example: 2.1219957909652723e-314.
Fixed in XmlMDataStd_RealArrayDriver.cxx and XmlMDataStd_RealListDriver.cxx

// A test file bug29452.xml is extended to check this skipped case.
2020-02-19 19:34:10 +03:00
kgv
d850414af1 0031315: Visualization - marker texture is lost after multi-textured object
OpenGl_Context::BindTextures() now iterates over pair of texture sets
considering inconsistent texture unit ranges.
2020-02-19 19:31:58 +03:00
kgv
b380b06c5d 0031206: Foundation Classes, Message_PrinterSystemLog - log messages to Browser console within Emscripten
Message_PrinterOStream::SetConsoleTextColor() skips color tags in case of Emscripten.
Message_PrinterSystemLog now implements log via emscripten_log().
2020-02-17 14:35:46 +03:00
kgv
c64efd9e30 0031375: Visualization, TKOpenGl - suppress warning on WebGL 1.0
Check for WebGL version in advance.
2020-02-17 14:35:44 +03:00
kgv
cd43c08f2b 0031372: Visualization, TKOpenGl - failed to create texture on OpenGL ES 2.0 due to unknown GL_TEXTURE_BASE_LEVEL
OpenGl_Sampler::applySamplerParams() has been corrected to check for OpenGL ES 3.0
when applying GL_TEXTURE_BASE_LEVEL/GL_TEXTURE_MAX_LEVEL parameters.
2020-02-16 15:05:41 +03:00
nds
28b13b31aa 0031014: Inspectors - variables for Qt in CMake
It restores path to Qt binaries in 3RDPARTY_DLL_DIRS for correct start TInspectorEXE under VStudio.
2020-02-13 20:48:05 +03:00
sshutina
10ac040338 0031336: Modeling data - extend BRepPrimAPI_MakeBox with planar shape creation
-Create a new package BRepPreviewAPI, inherited from BRepPrimAPI to create both, valid and degenerative shapes
-Create a new class BRepPreviewAPI_MakeBox for working with a box
    Preview can be vertex, edge, rectangle or box
-BRepPrim_GWedge: in the case of non-valid data, the exception does not happen in the constructor, but at the moment of access to the shape
-BRepPrimAPI_MakeBox: myWedge is now not private, but protected, because used in  BRepPreviewAPI_MakeBox which inherits from BRepPrimAPI_MakeBox
-Add tests for checking of a creation a preview in tests/geometry/preview (vertex, edge, rectangle, box)
-Update a command "box": add new parameters
2020-02-12 18:00:37 +03:00
nds
7e1c1e4869 0030268: Inspectors - improvements in VInspector plugin
- Convert package creation. It is used to prepare some auxiliary presentations/methods to prepare variables for inspector based on occt classes.
- ViewControl package improvement:
  Classes for property view, table, table model are implemented to visualize view of properties.
  This view is filled by selection in tree if the selected object has implemented DumpJson functionality.
- TreeModel package improvements:
  Method InitColumn is implemented in TreeModel_TreeModel to fill default columns in base model. The default columns are:
    Name, Visibility, Rows. Additional columns should be added in successors.
  Container of root items is moved into the base class
- View package imrovements:
  Store preferences: display mode, fit all checked state and type of external context
  View_DisplayPreview is added to process preview for selected in tree view objects
  hide actions Clear, Multi, Single by default (as selection in tree view or Visibility state of item define which presentations should be displayed or erased)
- ShapeView plugin improvements:
  Property View content based on DumpJson (columns in tree view for properties are removed),
  Properties for TopoDS_Shape are displayed
  Explode shape action in tree view to see content of shape by selected shape type. Type of displayed shapes is only preview, it is not used in export action.
  Export shape into BREP. The previous implementation about BREP files in some directory and default view is removed.
- VInspector plugin imrovements:
  Property View content based on DumpJson (columns in tree view for properties are removed),
  Properties for AIS_InteractiveContext and AIS_InteractiveObject are displayed
  obsolete classes to provide properties are removed.
- DFBrowser plugin improvements:
  Property View content based on DumpJson is not used yet. But there is the USE_DUMPJSON macro. It's switch off by default.
  If switch ON, it creates a Property View filled with DumpJson. It's a way of DFBrowser moving on this property view.
  Init uses static variable CDF_Session::CurrentSession()->CurrentApplication to fill plugin if application in plugin is not set but OCAF application exists

- OCC_VERSION_HEX variable used for previous OCCT versions support (before 6.9.0 or 7.2.0) is removed
2020-02-12 18:00:36 +03:00
kgv
a2803f37e7 0031341: Visualization - Graphic3d_Layer::UpdateCulling() ignores Presentation range
Graphic3d_Layer::UpdateCulling() now takes into account BVH_Tree::EndPrimitive().
'vstatprofiler structs' now properly prints number of structures in case of no culling.
2020-02-11 18:42:13 +03:00
abv
18348b382e 0031364: Foundation Classes - unused enumerations in GeomAbs package
Files GeomAbs_CurveForm.hxx, GeomAbs_SurfaceForm.hxx, GeomAbs_UVSense.hxx are removed
2020-02-11 18:42:12 +03:00
abv
64e68ea690 0031363: Documentation - broken Doxygen documentation of header files in Standard package
Documentation is corrected
2020-02-11 18:42:12 +03:00
anv
bee13ef1cf 0031360: Modeling Algorithms - Removing redundant class
math_GaussPoints was removed.
2020-02-07 18:23:45 +03:00
kgv
e73ef9d219 0031356: Visualization - out of range within StdPrs_WFShape::AddEdgesOnTriangulation()
Removed unused code causing the issue.
2020-02-07 14:22:01 +03:00
anv
8b3fbdef34 0031233: Reading SAT files produces invalid shapes
Added removal of overlapping "tails" while splitting wires with a seam edge in ShapeFix_ComposeShell::SplitWire.
2020-02-06 18:01:21 +03:00
kgv
e2550e48f1 0031333: Data Exchange - RWGltf_TriangulationReader::readBuffer() fails to read interleaved buffer at the end of file
Standard_ReadBuffer has been extended with a flag for reading an interleaved data.
RWGltf_TriangulationReader::readBuffer() uses new flag for reading vertex attributes.
2020-02-06 17:45:05 +03:00
oan
62beabff7c 0025551: BRepMesh can produce internal nodes outside the face interior based on distorted BSpline surface
updated test script to see the difference on current version of OCCT
2020-02-06 17:41:07 +03:00
oan
5e06dfcb32 0028247: Effect of minSize parameter of BRepMesh_IncrementalMesh seems to be too strong Updated description of MinSize parameter of IMeshTools_Parameters 2020-02-06 17:41:06 +03:00
oan
35befde2ad 0026382: BRepMesh produces internal nodes outside the face interior
updated test script: clean up shape before meshing to see the difference
2020-02-06 17:41:06 +03:00
nds
bc73b00672 0031313: Foundation Classes - Dump improvement for classes
- Provide DumpJson for geometrical, ocaf and visualization classes;
- Change depth parameter of DumpJson (constant is not obligate here)
- Introduce a new macro for transient objects to be called as the first row in DumpJson: OCCT_DUMP_TRANSIENT_CLASS_BEGIN. We need not put the class name in the macro, using get_type_name of Standard_Transient for it.
- change implementation of OCCT_DUMP_CLASS_BEGIN and OCCT_DUMP_TRANSIENT_CLASS_BEGIN. It is not an sentry more and it does not create a new hierarchy level. It appends a new row into the output stream: "className": <className>
- OCCT_DUMP_* does not require semicolon
- class header is included first in source files of TDataStd, TDocStd, TCAFDoc
2020-01-31 17:13:40 +03:00
kgv
00ea7f2676 0031321: C# wrapper - wrap AIS_ViewController
Added missing virtual destructor for AIS_ViewController.
2020-01-31 16:54:16 +03:00
nds
fe758dbe2c 0031322: Visualization, Select3D_SensitiveEntity - method NbSubElements() should be const
Set constant state for the method NbSubElement to be able to call it from other constant methods (e.g. DumpJson of Select3D_SensitiveEntity).
2020-01-30 18:58:32 +03:00
kgv
8811d6f2aa 0031332: Data Exchange - RWGltf_CafReader ignores bufferView.byteStride within glTF 2.0
RWGltf_GltfJsonParser::gltfParseBufferView() now reads byteStride parameter within bufferView.
2020-01-30 18:55:55 +03:00
nds
1939cfd9cb 0030904: Visualization - OSD_MemInfo provide Update with parameter of computation kind
Added method OSD_MemInfo::SetActive() for disabling specific counter.
2020-01-28 18:02:35 +03:00
iko
7860770232 0031275: Visualization, TKOpenGl - handle normal-map texture with Path-Tracing
Base normal map support has been implemented in path tracing (just geometry normal replacement).
Smooth normal adaptation has been implemeneted in order to avoid black areas artefacts during path tracing.
Tangent normal space calcuation has been moved to separate unified function.
Tangent space orthogonalization algorithm has been changed in order to handle all orientations and combinations of UV coordinates.
2020-01-24 16:35:41 +03:00
kgv
6216ed573e 0031312: Data Exchange - RWGltf_CafReader fails reading texture embedded into base64 bufferView
RWGltf_GltfJsonParser::gltfParseTexture() now handles images embedded into bufferView of non-glb file.
2020-01-23 18:13:19 +03:00
oan
973f7d55bd 0031258: Mesh - OCCT 7.4.0 VIS get wrong render data
Check intervals for infinite value causing exception in GeomLib::NormEstim
2020-01-22 10:16:28 +03:00
emv
0c74168c42 0031306: Modeling Algorithms - Incomplete result of Cut operation
The problem is fixed by #0029323. Integrating test case only.
2020-01-22 10:15:21 +03:00
kgv
3eba1c72ef 0031309: Data Exchange - RWObj_Reader fails to read mh03.obj with multi-line syntax
Standard_ReadLineBuffer::SetMultilineMode() now accepts a flag to put gap space while joining lines, enabled by default.
2020-01-21 13:04:46 +03:00
kgv
e83d440f92 0031304: Configuration - TKACIS building failure due to duplicated symbol GeomFillFusInt()
Added missing "static" to internal methods of GeomFill package.
2020-01-18 12:30:59 +03:00
iko
6558400123 0031302: Visualization, TKOpenGl - wrong tangent space calculation for normal maps
The normal after tangent space calculation has been reverted in order to be in right orientation.
The tangent space calculation has been modified in order to handle back faces with inverted normal.
2020-01-16 18:48:56 +03:00
ifv
389f5b59dd 0031260: Geom2dGcc_Circ2d2TanRad fails in this case (720)
Adaptor2d/Adaptor2d_OffsetCurve.cxx:
Function nbPoints(...) is modified

Test case added
2020-01-16 18:20:01 +03:00
ifv
08353e37cf 0031294: Modeling Algorithms - Regression relatively 7.3.0. Crash in method BRepPrimAPI_MakePrism::Generated(...)
BRepSweep_NumLinearRegularSweep.cxx: raising exeption is removed

Test case is added

QABugs_20.cxx - test command is added
2020-01-14 18:26:50 +03:00
iko
c8bead4752 0031293: Visualization, TKOpenGl - broken capping when PBR shading is ON
Division by 'w' component has been added in texture coordinates calculations in PBR functions.
2020-01-13 16:21:56 +03:00
osa
9df71488b3 0031295: Foundation Classes, BVH_Tools - incorrect detection of ray-box intersection 2020-01-13 16:18:55 +03:00
msv
ef59b5e064 0031292: Data Exchange - SIGSEGV on reading STEP file with references to invalid entities
Changes:

- in StepData_StepReaderData::ReadEntity, make sure that entity handle is not null before calling IsKind() of it.

- in StepData_StepReaderData::SetEntityNumbers, do not invert the sign of entity number of referenced parameter if the second pass is not required. Otherwise, the number -1 (obviously invalid) becomes 1 (invalid, but not obviously) without further correction of it.

- in StepData_UndefinedEntity::ReadRecord, consider the case when the entity number is positive but refers to non-existing entity. In this case literal value will be used instead of null entity for the problematic parameter.
2020-01-13 16:16:48 +03:00
oan
0c061f3d9d 0025287: BRepMesh_IncrementalMesh produces (way) out of tolerance mesh Added test case 2020-01-13 16:13:24 +03:00
iko
88b312d3a4 0031099: Visualization, TKOpenGl - support Point light source with artistic full cut-off distance
"Range" parameter of point light sources (positional and spot) concidering in PBR has been added.
Angular attenuation parameter of spot light in PBR has been reimplemented based on existing "concentration" parameter.
2020-01-13 16:07:19 +03:00
kgv
0858125fd4 0031284: Visualization - XCAFDoc_VisMaterialPBR lacks Index of Refraction
Added missing parameter.
2019-12-27 16:35:31 +03:00
mzernova
89d855ba58 0031225: Visualization, TKOpenGl - support cubemap for environment texture within Ray-Tracing
Ray-Tracing now handles IBL and background cubemaps in similar way as PBR.
Ambient light source is handled by Ray-Tracing in similar way as PBR,
e.g. as coefficient for environment map (IBL) or as constant light source.

Test script generating PBR spheres has been moved to Samples
and now shared by PBR and Path-Tracing tests.
2019-12-27 16:26:48 +03:00
kgv
d415125a68 0031274: Data Exchange - RWObj_Reader ignores usemtl with empty name
Fixed out of range access within pushMaterial().
2019-12-26 17:19:31 +03:00
razmyslovich
0da2ecac41 0031251: Add a new meshing parameter to enforce face linear deflection
Parameter has been renamed to ForceFaceDeflection. Added test case.

New parameter -force_face_def has been added to incmesh command.
2019-12-25 15:25:43 +03:00
ifv
bdd09cfaf4 0031242: Scaling with different coefficients along axes produces invalid shape
GeomConvert_1.cxx:
Creation periodic BSpline surfaces from trimmed periodic surface if trim is boundaries of periodic domain is allowed

BRepTools_NurbsConvertModification.cxx:
Checking domain of 2dCurves if surfaces are periodic is added

Test case tests/bugs/mesh/bug30008_2 is modified according to current behavior

Test case tests/bugs/modalg_7/bug31242 is added
2019-12-23 11:49:04 +03:00
kgv
9504a30d15 0031253: Visualization, TKOpenGl - phong shading GLSL compilation fail on Adreno 308
Removed initialization of global Normal variable outside of main() block.
occLight_IsHeadlight() flag is now packed into occLight_Position().w
2019-12-19 16:55:21 +03:00
jgv
9a1701fbcb 0030597: Result of BRepOffsetAPI_MakePipeShell doesn't match the given profiles
Modify the local function EdgeToBSpline of BRepFill_NSections to build a BSpline curve of general type for each curve of profile.
2019-12-19 16:53:36 +03:00
mzernova
c68c346d2b 0030600: Visualization, TKOpenGl - include GLES3/gl3.h instead of GLES2/gl2.h
Changed GLES2/gl2.h to GLES3/gl3.h.

OpenGl_Window_1.mm has been updated, now it is trying to create kEAGLRenderingAPIOpenGLES3 before trying to create kEAGLRenderingAPIOpenGLES2.
2019-12-19 16:50:16 +03:00
ifv
e2447a80ea 0031203: Test harness command "bsection" on the planar faces return only one vertex instead edge representing intersection line
BRepClass/BRepClass_FaceExplorer.cxx:
Protection against intersection of test ray with almost parallel edges is added.

SWDRAW/SWDRAW_ShapeFix.cxx: add tolerance as parameter in command checkfclass2d

tests/bugs/modalg_7/bug31203:
test case is added
2019-12-19 16:45:54 +03:00
oan
936ce1f273 0031199: BRepMesh fails on thin faces
Use real tolerance of a face to define threshold for tolerance of discrete model instead of empirical values based on discrete model itself
2019-12-19 16:30:06 +03:00
jgv
6ef7a1f9e5 0031187: Modeling Algorithms - Regression relatively 7.3.0. Unify same domain algorithm produces invalid shape.
Modify the local function ReconstructMissedSeam to build new seam edges correctly.
2019-12-18 19:42:50 +03:00
msv
23c2ae55c7 0031120: Memory leak in BRepOffsetAPI_MakeOffset
Add destructor of MAT2d_Mat2d - full removal of edges and bisectors.
2019-12-17 15:51:06 +03:00
abk
8bfae263c1 0031168: JT Import - cannot see properties attached to objects
Draw command GetNDStrings was improved to sort the properties by the keys and
skip conversions of the strings to type TCollection_AsciiString.

Certain Draw commands were corrected to use the Draw interpreter instead of "std::cout".

A Tcl procedure was created to compare two multi-line strings.
2019-12-14 13:52:16 +03:00
ma haidong
1c2ddf5612 0031231: Samples - the command "donl" in ModelingDemo.tcl should be "donly"
Fixed misprint in Tcl sample script.
2019-12-14 13:51:03 +03:00
kgv
5a8d30b87b 0030945: JT Import, JtProperty_LateLoaded - expose type of Deferred object
RWMesh_NodeAttributes has been extended with NamedData property for passing Metadata.

RWMesh_CafReader::addShapeIntoDoc() has been corrected to avoid
adding calling XCAFDoc_ShapeTool::AddSubShape() for sub-shape labels.
Attributes for Products and Instances are now set independently to shape labels.
Sharing of Compounds (previously always duplicated) as sub-Components has been fixed.

TDataStd_NamedData has been extended with interface for deferred data loading.
Setters have been corrected to avoid duplicating lookups within map.
2019-12-06 19:38:01 +03:00
kgv
b7b22996bb 0031227: Tests - log number of compared images into report 2019-12-06 19:32:37 +03:00
anv
552a74d829 0030889: ACIS Import - Incorrect result reading SAT and SAB files
Adapting CR30932 fix for a GeomLib approximator.
2019-12-06 19:32:36 +03:00
mzernova
c37bd936c3 0031213: Coding Rules, RWStl_Reader - misnamed variable THE_BUFFER
Renamed THE_BUFFER variable.
2019-12-06 19:32:35 +03:00
anv
4e8c1d8666 0031202: Shape Healing - FixMissingSeam creates degenerated edge
Adding tolerance to prevent degenerated cuts in cases where all vertex tolerance is covered by distance of the edge curve from vertex point.
2019-12-06 19:32:34 +03:00
iko
72f6dc612c 0031096: Visualization, TKOpenGl - support metallic-roughness texture mapping
OpenGl_ShaderManager - metallic-roughness, emissive, occlusion
and normal texture maps are now supported by PBR.
Emissive, occlusion and normal texture maps are now supported by Phong shading model.
Path-Tracing now handles metallic-roughness and emissive texture maps.

Graphic3d_TextureUnit enumeration has been extended by
new values corresponding to supported texture maps.

OpenGl_TextureSet and OpenGl_ShaderProgram have been extended with
bitmask Graphic3d_TextureSetBits identifying texture slots read from GLSL Program
and slots defined within Texture Set to avoid undefined behavior by binding mock textures.

OpenGl_TextureSet now duplicates texture unit information to handle
textures shared across multiple slots (like Occlusion [R] + Metallic-Roughness [GB]).

OpenGl_Context::BindTextures() has been extended with active GLSL program paramter
to set mock textures to texture units used by program but undefined by texture set.
OpenGl_Workspace::ApplyAspects() has been extended with parameter to avoid bining texture set.
2019-11-29 20:36:23 +03:00
mzernova
f051908edc 0030982: Visualization, OpenGl_View::MinMaxValues() - do not add background quad into depth range
Deleted adding background quad into depth range. Background is drawn in 2D coordinates. Fixed problem with using gradient background in tiles.
2019-11-29 20:19:42 +03:00
emv
420b38fde9 0031148: Modeling Algorithms - Offset adjacent co-planar faces with different offset values
Extend the Offset operation (Join Type "Intersection", mode "Complete") to allow different offset values on adjacent co-planar faces.
The gap between adjacent faces is closed by creating artificial face perpendicular to the face.

Adding test cases.
2019-11-29 10:06:22 +03:00
emv
34e7ac6817 0031201: Modeling Algorithms - Result of a section operation is incomplete
Fixing misprint - use the boundaries of the cylinder for Plane/Cylinder intersection.
Test cases for the issue.
2019-11-29 09:59:01 +03:00
osa
2b5a58a33c 0031186: Foundation Classes - add additional useful methods to BVH_Box.
Add Transform() and Transformed() methods by Mat4 for BVH_Box (only for 3D dimension).
Add PointBoxProjection() method to project point to box and RayBoxIntersection() method to compute hit time of ray-box intersection to BVH_Tools.
Add BVH_Ray class to define ray object.
2019-11-26 18:36:55 +03:00
kgv
e513a6c538 0031188: Draw Harness - enable colorized messages output to console by default
Message_PrinterOStream now uses colorized output by default.
DRAWEXE has been corrected to disabled colorized output
when it is called with -f argument to avoid spoiling testgrid HTML logs.
2019-11-26 18:35:38 +03:00
kgv
8c2d331426 0031007: Coding - eliminate warnings issued while compiling with -pedantic flag
Removed duplicating semicolons ;;.
Removed redundant semicolon at namespace closure.
2019-11-26 18:29:13 +03:00
mzernova
caee80f39f 0030697: Draw Harness - Draw_Printer should not be set to Message::DefaultMessenger() by default
Fixed bugs that occurred when using the default std::cout from Message::DefaultMessenger() instead of Draw_Printer

A dedicated option was added to Draw_ProgressIndicator, for outputting data to the tcl when performing tests

Added -tclOutput parameter to XProgress command
2019-11-23 16:09:07 +03:00
kgv
01b2f506d6 0030953: Data Exchange - implement export of mesh data into glTF 2.0 format
Added new class RWGltf_CafWriter for exporting XCAF document into glTF file
as well as Draw Harness command WriteGltf.

Added auxiliary method OSD_Path::FileNameAndExtension() splitting file name into Name and Extension.
2019-11-23 16:03:19 +03:00
vsv
df8c7e3e18 0031153: Visualization - Non clear highlighting of selected trihedron elements
AIS_Trihedron - removed extra fields holding highlight styles; standard styles are now used instead;
fixed unexpected modification of global aspects;
fixed unhighligting of selected plane within Shaded trihedron.

AIS_InteractiveContext now sets highlight color to highlight aspects, not only base color to drawer itself.
2019-11-21 17:43:07 +03:00
kgv
3f1675c941 0031174: Visualization - support user-provided stipple line patterns 2019-11-21 17:40:58 +03:00
kgv
6a56fe9240 0031178: Configuration, genproj - fix searching for zlib on Linux platform
zlib library is called libz on Linux.
2019-11-21 17:24:12 +03:00
mzernova
51ee6a7dbb 0030964: Data Exchange - use Standard_ReadLineBuffer within OBJ reader
Standard_ReadLineBuffer now supports a processing of the special multi-line case with \ at the end of the line.

Standard_RedLineBuffer was used to load Stl files
2019-11-20 17:08:31 +03:00
kgv
14a356b178 0031015: Visualization, TKOpenGl - OpenGl_WorldViewState does not cache inverted matrix
Implementation has been fixed to proprely set myInverseNeedUpdate flag.
2019-11-19 18:58:54 +03:00
kgv
4eff0c0480 0031175: Visualization - support dumping RED channel as grayscale image
Graphic3d_BufferType has been extended by Graphic3d_BT_Red.
2019-11-19 10:37:54 +03:00
abv
8f00325d73 0031171: Draw - support Unicode input / output in console on Windows
System console is configured at DRAW start to use UTF-8 encoding, for cout and cin to deal correctly with Unicode symbols.
Use of std::wcout is avoided as it leads to corrupted output.

Command testgrid is improved to enforce UTF-8 encoding in child DRAW processes to preserve Unicode symbols in captured output.

Test bugs fclasses bug22125 is refactored:
- avoid dependency on external data file
- avoid producing snapshot
- check that Unicode name of the file created by OCCT procedure matches the name interpreted by Tcl functions
2019-11-17 17:52:38 +03:00
kgv
9a90a4524e 0031159: Visualization - Font_FontMgr skips sub-faces within .ttc font collections
Font_SystemFont now defines Face Id in addition to file path.
Font_FontMgr::CheckFont() has been extended to return the list of Faces from font collections.
2019-11-15 16:51:15 +03:00
abv
31a5a359bb 0031144: Shape Healing - ShapeAnalysis::OuterWire() infinite loop on solid obtained from IFC
Implementation of ShapeAnalysis::OuterWire() is revised to avoid infinite cycle if face contains internal vertex.
2019-11-15 16:37:25 +03:00
jgv
bf97419a18 0030958: BRepOffsetAPI_ThruSections operation raises an exception while building history
Correct methods Build and Generated:
use BRepTools_WireExplorer instead of TopExp_Explorer or TopoDS_Iterator, for compatibility with previous computations.
2019-11-14 22:40:01 +03:00
gka
4c26106f76 0031140: Draw command "cirtang" raises exception on the parallel curves
Exception in the algorithm Geom2dGcc_Circ2dTanOnRadGeo raised because the number of solutions exceeded the size of reserved array for solutions. A check has been added to forbid adding solutions outside of allocated place.

The similar protection has been done in other algorithms of this package.
2019-11-13 18:38:28 +03:00
kgv
15e4e6a23e 0031118: Visualization - Font_FontMgr skips fonts with unknown styles like Narrow or Black
Extended Style name is now appended to Family name for unique identification of the font.
vfont -find now accepts mask to search the font and returns family name.
2019-11-13 18:34:33 +03:00
kgv
6b467e52bb 0031137: Modeling Data, BinTools_ShapeSet - avoid allocation of temporary arrays
BinTools_ShapeSet now defines maps with proper types instead of Standard_Transient.
BinTools_ShapeSet now avoids allocation of temporary arrays while reading
triangulation and polygonal data.

Classes Poly_Triangle, Poly_PolygonOnTriangulation, Poly_Polygon3D and Poly_Polygon2D
have been cleared from .lxx files and extended by new methods for preallocating and filling array,
as alternative to passing arrays by copy.

wavefront command - export "f" instead of obsolete "fo" keys into file.
BinTools - added missing tools for reading/writing short reals.
2019-11-09 19:12:47 +03:00
kgv
08b438b076 0031138: Visualization - Image_AlienPixMap fails to load PNG image with palette
Added fallback code converting unsupported pixel format into RGB24 using FreeImage itself.
2019-11-07 20:19:38 +03:00
kgv
a14f2b4722 0031139: Data Exchange - fix misprint in RWObj_CafReader
RWObj_CafReader::BindNamedShape(), added missing bind to material map.
XCAFDoc_VisMaterial::ConvertToCommonMaterial()/::ConvertToPbrMaterial(), added copying of base color texture.
XCAFPrs_DocumentExplorer now properly fills XCAFDoc_VisMaterial property of XCAFPrs_Style.
2019-11-07 20:18:25 +03:00
kgv
a1a9b24952 0031135: Visualization, TKOpenGl - texture sRGB -> linear conversion is applied twice by Path Tracer
Removed from PathtraceBase.fs redundant gamma correction applied to texture.
2019-11-06 19:33:36 +03:00
abv
f979709590 0031038: Draw - adaptations for running tests with CLang address sanitizer
New optional environment variable CSF_CPULIMIT_FACTOR is introduced, allowing scaling the argument given to DRAW command cpulimit by specified factor.

Command testgrid is extended by two new options:
- -skipped: to re-run tests skipped in specified log
- -skip: to skip specified number of tests in the beginning of test sequence

Temporary Tcl scripts generated by test system are now removed from the test log directories immediately after the test execution, to save disk space.

Advises on use of CLang sanitizers are added in guide "Debugging hints and tips".
2019-11-06 19:22:33 +03:00
oan
e9d05765c2 0031131: [REGRESSION] Mesh - location of Wire affects Poly_Polygon3D
Use TopoDS_Edge without location in case of free edges to produce Poly_Polygon3D without offset.
2019-11-06 19:19:47 +03:00
oan
7756fc599d 0031125: BRepMesh_IncrementalMesh crash in constructor for empty compound shape
Added check for cases of empty shapes producing null models.
NoError status is returned as far as empty compounds are generally coorect shapes.
2019-11-06 19:17:24 +03:00
abv
b31fbc832d 0031124: Configuration - linker errors when building with CLang on Windows
Standard_EXPORT is added in declaration of virtual methods where it was missing, to allow creation of sub-classes in other DLLs.
In some classes in OpenGl package Standard_EXPORT is added for all methods to make these classes usable in other DLLs.
2019-11-04 14:08:18 +03:00
abv
1bd04b5a02 0031060: Configuration - Support building with CLang compiler under VS 2019
Build tools are updated to support building with Visual Studion 2019 toolset ClangCL (LLVM clang-cl):
- In CMake builds, use of unsupported option "-std=c++0x" is avoided
- Tool genconf recognizes availability of ClangCL toolset and proposes it in the list
- Tool genproj recognizes new compiler specification VCVER=vclang and generates VS 2019 projects for it

Note that vclang configuration puts binaries to folder "vc14" as it is compatible with vc14 CRT.

Code is updated to build with Clang for Windows without errors and warnings:
- In BVH classes, pure virtual destructors are replaced by empty ones, to avoid bogus compiler warning
- In .lex files, pragmas are added to disable warnings in parser code
- In OSD, signature of function _osd_wnt_set_error() is corrected to avoid warning on incorrect use of va_args (undefined behavior)
- In OSD_Host, OSD_Parallel_TBB, warnings on usage of deprecated function are disabled
- In Quantity_ColorRGBA and ViewerTest_CmdParser, incorrect use of predefined macro __FUNCTION__ assuming it was a string literal is avoided
- In Standard_Macro.hxx, code is reordered to handle Clang for Windows appropriately
- In AdvApp2Var_SysBase.hxx, inclusion of obsolete (MSVC-specific) header file is replaced by Standard_TypeDef.hxx
- In Standard_ErrorHandler.hxx, empty statements added to avoid warning on unused class fields
- In IVtkDraw and ViewerTest, interface is corrected to use actual type avoiding unnecessary type casts

Off-topic: corrections of some errors (uninitialized class fields) reported by VS Code Analysis in TKernel
2019-11-03 21:47:59 +03:00
3351 changed files with 77234 additions and 145558 deletions

View File

@@ -3,6 +3,7 @@ StdResource
SHMessage
Textures
Shaders
XRResources
XSMessage
XSTEPResource
XmlOcafResource

View File

@@ -108,6 +108,7 @@ n BRepMesh
n BRepMeshData
n BRepOffset
n BRepOffsetAPI
n BRepPreviewAPI
n BRepPrim
n BRepPrimAPI
n BRepProj
@@ -201,6 +202,7 @@ n InterfaceGraphic
n AIS
n Aspect
n DsgPrs
n PrsDim
n Graphic3d
n Image
n Media
@@ -214,13 +216,13 @@ n SelectBasics
n SelectMgr
n StdPrs
n StdSelect
n TColQuantity
n V3d
n WNT
n Xw
n Cocoa
r Textures
r Shaders
r XRResources
t TKMeshVS
t TKOpenGl
t TKD3DHost
@@ -443,3 +445,23 @@ t TKRWMesh
n RWGltf
n RWMesh
n RWObj
n DFBrowser
n DFBrowserPane
n DFBrowserPaneXDE
n ShapeView
n TInspector
n TInspectorAPI
x TInspectorEXE
t TKDFBrowser
t TKShapeView
t TKTInspector
t TKTInspectorAPI
t TKToolsDraw
t TKTreeModel
t TKView
t TKVInspector
n ToolsDraw
n TreeModel
n View
n ViewControl
n VInspector

View File

@@ -111,34 +111,31 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMP
endif()
endif()
if(MINGW)
# Set default release optimization option to O2 instead of O3, since in
# some OCCT related examples, this gives significantly smaller binaries
# at comparable performace with MinGW-w64.
string (REGEX MATCH "-O3" IS_O3_CXX "${CMAKE_CXX_FLAGS_RELEASE}")
if (IS_O3_CXX)
string (REGEX REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
else()
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
endif()
set (CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}")
add_definitions(-D_WIN32_WINNT=0x0501)
# workaround bugs in mingw with vtable export
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols")
elseif ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang")
if ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang")
if (APPLE)
# CLang can be used with both libstdc++ and libc++, however on OS X libstdc++ is outdated.
set (CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
else()
elseif(NOT WIN32)
# CLang for Windows (at least CLang 8.0 distributed with VS 2019)
# does not support option "-std=c++0x"
set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
endif()
elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)
set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
endif()
# Optimize size of binaries
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,-s ${CMAKE_SHARED_LINKER_FLAGS}")
elseif(MINGW)
add_definitions(-D_WIN32_WINNT=0x0501)
# workaround bugs in mingw with vtable export
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols")
# Optimize size of binaries
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR MINGW)
# Require C++11
set (CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}")
# Optimize size of binaries
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)
# Require C++11
set (CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
# Optimize size of binaries
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
endif()

View File

@@ -57,117 +57,110 @@ foreach (OCCT_PACKAGE ${USED_PACKAGES})
set (OCCT_PACKAGE_NAME "${OCCT_PACKAGE}")
endif()
# TKService contains platform-dependent packages: Xw and WNT
if ((WIN32 AND "${OCCT_PACKAGE}" STREQUAL "Xw") OR (NOT WIN32 AND "${OCCT_PACKAGE}" STREQUAL "WNT"))
# do nothing
else()
if (WIN32)
list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE_NAME}_DLL")
endif()
set (SOURCE_FILES)
set (HEADER_FILES)
# Generate Flex and Bison files
if (${BUILD_YACCLEX})
# flex files
OCCT_ORIGIN_AND_PATCHED_FILES ("${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX)
list (LENGTH SOURCE_FILES_FLEX SOURCE_FILES_FLEX_LEN)
# bison files
OCCT_ORIGIN_AND_PATCHED_FILES ("${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON)
list (LENGTH SOURCE_FILES_BISON SOURCE_FILES_BISON_LEN)
if (${SOURCE_FILES_FLEX_LEN} EQUAL ${SOURCE_FILES_BISON_LEN} AND NOT ${SOURCE_FILES_FLEX_LEN} EQUAL 0)
list (SORT SOURCE_FILES_FLEX)
list (SORT SOURCE_FILES_BISON)
math (EXPR SOURCE_FILES_FLEX_LEN "${SOURCE_FILES_FLEX_LEN} - 1")
foreach (FLEX_FILE_INDEX RANGE ${SOURCE_FILES_FLEX_LEN})
list (GET SOURCE_FILES_FLEX ${FLEX_FILE_INDEX} CURRENT_FLEX_FILE)
get_filename_component (CURRENT_FLEX_FILE_NAME ${CURRENT_FLEX_FILE} NAME_WE)
list (GET SOURCE_FILES_BISON ${FLEX_FILE_INDEX} CURRENT_BISON_FILE)
get_filename_component (CURRENT_BISON_FILE_NAME ${CURRENT_BISON_FILE} NAME_WE)
string (COMPARE EQUAL ${CURRENT_FLEX_FILE_NAME} ${CURRENT_BISON_FILE_NAME} ARE_FILES_EQUAL)
if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL})
set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c)
set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c)
BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}")
FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}")
ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME})
list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE})
endif()
endforeach()
endif()
endif()
# header files
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES")
file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
if(APPLE)
file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
endif()
else()
file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
if(APPLE)
file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
endif()
endif()
list (APPEND HEADER_FILES ${HEADER_FILES_M} ${HEADER_FILES_LXX} ${SOURCE_FILES_GXX})
list (APPEND SOURCE_FILES ${SOURCE_FILES_C})
if(APPLE)
list (APPEND SOURCE_FILES ${SOURCE_FILES_M})
endif()
foreach(HEADER_FILE ${HEADER_FILES})
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
list (APPEND USED_INCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
else()
list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
endif()
endforeach()
foreach(SOURCE_FILE ${SOURCE_FILES})
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
list (APPEND USED_SRCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
else()
list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
endif()
endforeach()
if (USE_QT)
FIND_AND_INSTALL_QT_RESOURCES (${OCCT_PACKAGE} RESOURCE_FILES)
#message("Qt Resource files are: ${QT_RESOURCE_FILES} in ${OCCT_PACKAGE}")
endif(USE_QT)
#message("Resource files are: ${RESOURCE_FILES} in ${OCCT_PACKAGE}")
foreach(RESOURCE_FILE ${RESOURCE_FILES})
SOURCE_GROUP ("Resource Files\\${OCCT_PACKAGE_NAME}" FILES "${RESOURCE_FILE}")
endforeach()
if (WIN32)
list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE_NAME}_DLL")
endif()
set (SOURCE_FILES)
set (HEADER_FILES)
# Generate Flex and Bison files
if (${BUILD_YACCLEX})
# flex files
OCCT_ORIGIN_AND_PATCHED_FILES ("${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX)
list (LENGTH SOURCE_FILES_FLEX SOURCE_FILES_FLEX_LEN)
# bison files
OCCT_ORIGIN_AND_PATCHED_FILES ("${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON)
list (LENGTH SOURCE_FILES_BISON SOURCE_FILES_BISON_LEN)
if (${SOURCE_FILES_FLEX_LEN} EQUAL ${SOURCE_FILES_BISON_LEN} AND NOT ${SOURCE_FILES_FLEX_LEN} EQUAL 0)
list (SORT SOURCE_FILES_FLEX)
list (SORT SOURCE_FILES_BISON)
math (EXPR SOURCE_FILES_FLEX_LEN "${SOURCE_FILES_FLEX_LEN} - 1")
foreach (FLEX_FILE_INDEX RANGE ${SOURCE_FILES_FLEX_LEN})
list (GET SOURCE_FILES_FLEX ${FLEX_FILE_INDEX} CURRENT_FLEX_FILE)
get_filename_component (CURRENT_FLEX_FILE_NAME ${CURRENT_FLEX_FILE} NAME_WE)
list (GET SOURCE_FILES_BISON ${FLEX_FILE_INDEX} CURRENT_BISON_FILE)
get_filename_component (CURRENT_BISON_FILE_NAME ${CURRENT_BISON_FILE} NAME_WE)
string (COMPARE EQUAL ${CURRENT_FLEX_FILE_NAME} ${CURRENT_BISON_FILE_NAME} ARE_FILES_EQUAL)
if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL})
set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c)
set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c)
BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}")
FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}")
ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME})
list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE})
endif()
endforeach()
endif()
endif()
# header files
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES")
file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
if(APPLE)
file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
endif()
else()
file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h")
file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
if(APPLE)
file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
endif()
endif()
list (APPEND HEADER_FILES ${HEADER_FILES_M} ${HEADER_FILES_LXX} ${SOURCE_FILES_GXX})
list (APPEND SOURCE_FILES ${SOURCE_FILES_C})
if(APPLE)
list (APPEND SOURCE_FILES ${SOURCE_FILES_M})
endif()
foreach(HEADER_FILE ${HEADER_FILES})
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
list (APPEND USED_INCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
else()
list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}")
endif()
endforeach()
foreach(SOURCE_FILE ${SOURCE_FILES})
if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
list (APPEND USED_SRCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
else()
list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}")
endif()
endforeach()
if (USE_QT)
FIND_AND_INSTALL_QT_RESOURCES (${OCCT_PACKAGE} RESOURCE_FILES)
#message("Qt Resource files are: ${QT_RESOURCE_FILES} in ${OCCT_PACKAGE}")
endif(USE_QT)
#message("Resource files are: ${RESOURCE_FILES} in ${OCCT_PACKAGE}")
foreach(RESOURCE_FILE ${RESOURCE_FILES})
SOURCE_GROUP ("Resource Files\\${OCCT_PACKAGE_NAME}" FILES "${RESOURCE_FILE}")
endforeach()
endforeach()
string (REGEX REPLACE ";" " " PRECOMPILED_DEFS "${PRECOMPILED_DEFS}")
@@ -330,7 +323,7 @@ endif()
# Update list of used VTK libraries if OpenGL2 Rendering BackEnd is used.
# Add VTK_OPENGL2_BACKEND definition.
if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2")
if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2" OR IS_VTK_9XX)
add_definitions(-DVTK_OPENGL2_BACKEND)
foreach (VTK_EXCLUDE_LIBRARY vtkRenderingOpenGL vtkRenderingFreeTypeOpenGL)
list (FIND USED_TOOLKITS_BY_CURRENT_PROJECT "${VTK_EXCLUDE_LIBRARY}" IS_VTK_OPENGL_FOUND)
@@ -354,6 +347,9 @@ else()
endif()
if (BUILD_SHARED_LIBS)
if(IS_VTK_9XX)
string (REGEX REPLACE "vtk" "VTK::" USED_TOOLKITS_BY_CURRENT_PROJECT "${USED_TOOLKITS_BY_CURRENT_PROJECT}")
endif()
target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT})
endif()

View File

@@ -7,7 +7,8 @@ if (NOT DEFINED ${3RDPARTY_QT_DIR} AND ${3RDPARTY_QT_DIR} STREQUAL "")
FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" Qt 3RDPARTY_QT_DIR_NAME)
if (NOT DEFINED ${3RDPARTY_QT_DIR_NAME} AND ${3RDPARTY_QT_DIR_NAME} STREQUAL "")
message (FATAL_ERROR "... Qt root directory was not found")
set (3RDPARTY_QT_DIR "" CACHE PATH "The directory containing qt")
message (FATAL_ERROR "Could not find used third-party product: 3RDPARTY_QT_DIR")
endif()
# Combine directory name with absolute path and show in GUI
@@ -32,3 +33,9 @@ if (NOT ${Qt5_FOUND})
else()
#message (STATUS "Qt5 cmake configuration")
endif()
if (3RDPARTY_QT_DIR OR EXISTS "${3RDPARTY_QT_DIR}")
list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_QT_DIR}/bin")
else()
list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_QT_DLL_DIR)
endif()

View File

@@ -66,10 +66,15 @@ if (3RDPARTY_VTK_DIR AND EXISTS "${3RDPARTY_VTK_DIR}")
set (ENV{VTK_DIR} ${CACHED_VTK_DIR})
endif()
unset (IS_VTK_9XX)
if (VTK_FOUND)
# add compiler flags, preprocessor definitions, include and link dirs
include (${VTK_USE_FILE})
message ("VTK version (${VTK_VERSION})")
if(VTK_MAJOR_VERSION EQUAL 8 AND VTK_MINOR_VERSION GREATER 9 OR VTK_MAJOR_VERSION GREATER 8)
set (IS_VTK_9XX 1)
else()
# add compiler flags, preprocessor definitions, include and link dirs
include (${VTK_USE_FILE})
endif()
if (VTK_LIBRARIES)
@@ -81,79 +86,83 @@ if (VTK_FOUND)
# endif()
foreach (VTK_LIBRARY ${VTK_LIBRARIES})
string (REGEX MATCH "^vtk" IS_VTK_LIBRARY ${VTK_LIBRARY})
if (IS_VTK_LIBRARY AND TARGET ${VTK_LIBRARY})
# get paths from corresponding variables
if (${VTK_LIBRARY}_INCLUDE_DIRS AND EXISTS "${${VTK_LIBRARY}_INCLUDE_DIRS}")
list (APPEND 3RDPARTY_VTK_INCLUDE_DIRS "${${VTK_LIBRARY}_INCLUDE_DIRS}")
if (IS_VTK_9XX)
string (REGEX MATCH "^VTK::" IS_VTK_LIBRARY ${VTK_LIBRARY})
else()
string (REGEX MATCH "^vtk" IS_VTK_LIBRARY ${VTK_LIBRARY})
endif()
if (NOT IS_VTK_LIBRARY OR NOT TARGET ${VTK_LIBRARY})
continue()
endif()
# get paths from corresponding variables
if (${VTK_LIBRARY}_INCLUDE_DIRS AND EXISTS "${${VTK_LIBRARY}_INCLUDE_DIRS}")
list (APPEND 3RDPARTY_VTK_INCLUDE_DIRS "${${VTK_LIBRARY}_INCLUDE_DIRS}")
endif()
if (${VTK_LIBRARY}_LIBRARY_DIRS AND EXISTS "${${VTK_LIBRARY}_LIBRARY_DIRS}")
list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${${VTK_LIBRARY}_LIBRARY_DIRS}")
endif()
if (${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS AND EXISTS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
list (APPEND 3RDPARTY_VTK_DLL_DIRS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
if (NOT WIN32)
list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
endif()
endif()
# get paths from corresponding properties
get_target_property (TARGET_VTK_IMPORT_CONFS ${VTK_LIBRARY} IMPORTED_CONFIGURATIONS)
if (TARGET_VTK_IMPORT_CONFS)
list (GET TARGET_VTK_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
# todo: choose configuration in connection with the build type
#if (CMAKE_BUILD_TYPE)
# foreach (IMPORT_CONF ${TARGET_VTK_IMPORT_CONFS})
# endforeach()
#endif()
# Work-around against link failure in case if VTK contains dependency
# on DirectX: its run-time is always present on Windows, but SDK can
# be absent on current workstation, while not actually needed for
# OCCT linking.
# VTK 6.1 for VC 10
get_target_property (TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${VTK_LIBRARY} IMPORTED_LINK_INTERFACE_LIBRARIES_${CHOSEN_IMPORT_CONF})
if(TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES)
string (REGEX MATCH "[^;]*d3d[0-9]+[.]lib" HARDCODED_D3D9_LIB "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
if (HARDCODED_D3D9_LIB)
message (STATUS "Warning: ${HARDCODED_D3D9_LIB} has been removed from imported dependencies of ${VTK_LIBRARY}")
list (REMOVE_ITEM TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${HARDCODED_D3D9_LIB})
set_target_properties (${VTK_LIBRARY} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES_${CHOSEN_IMPORT_CONF} "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
endif()
endif()
# VTK 6.1 for VC 12, 14
get_target_property (TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${VTK_LIBRARY} INTERFACE_LINK_LIBRARIES)
if(TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES)
string (REGEX MATCH "[^;]*d3d[0-9]+[.]lib" HARDCODED_D3D9_LIB "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
if (HARDCODED_D3D9_LIB)
message (STATUS "Warning: ${HARDCODED_D3D9_LIB} has been removed from imported dependencies of ${VTK_LIBRARY}")
list (REMOVE_ITEM TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${HARDCODED_D3D9_LIB})
set_target_properties (${VTK_LIBRARY} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
endif()
endif()
if (${VTK_LIBRARY}_LIBRARY_DIRS AND EXISTS "${${VTK_LIBRARY}_LIBRARY_DIRS}")
list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${${VTK_LIBRARY}_LIBRARY_DIRS}")
endif()
get_target_property (TARGET_PROPERTY_IMP_PATH ${VTK_LIBRARY} IMPORTED_IMPLIB_${CHOSEN_IMPORT_CONF})
if(TARGET_PROPERTY_IMP_PATH AND EXISTS "${TARGET_PROPERTY_IMP_PATH}")
get_filename_component (TARGET_PROPERTY_IMP_DIR "${TARGET_PROPERTY_IMP_PATH}" PATH)
list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${TARGET_PROPERTY_IMP_DIR}")
endif()
if (${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS AND EXISTS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
list (APPEND 3RDPARTY_VTK_DLL_DIRS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
if (NOT WIN32)
list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
endif()
endif()
get_target_property (TARGET_PROPERTY_LOCATION_PATH ${VTK_LIBRARY} IMPORTED_LOCATION_${CHOSEN_IMPORT_CONF})
if(TARGET_PROPERTY_LOCATION_PATH AND EXISTS "${TARGET_PROPERTY_LOCATION_PATH}")
get_filename_component (TARGET_PROPERTY_LOCATION_DIR "${TARGET_PROPERTY_LOCATION_PATH}" PATH)
# get paths from corresponding properties
get_target_property (TARGET_VTK_IMPORT_CONFS ${VTK_LIBRARY} IMPORTED_CONFIGURATIONS)
if (TARGET_VTK_IMPORT_CONFS)
list (GET TARGET_VTK_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
# todo: choose configuration in connection with the build type
#if (CMAKE_BUILD_TYPE)
# foreach (IMPORT_CONF ${TARGET_VTK_IMPORT_CONFS})
# endforeach()
#endif()
# Work-around against link failure in case if VTK contains dependency
# on DirectX: its run-time is always present on Windows, but SDK can
# be absent on current workstation, while not actually needed for
# OCCT linking.
# VTK 6.1 for VC 10
get_target_property (TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${VTK_LIBRARY} IMPORTED_LINK_INTERFACE_LIBRARIES_${CHOSEN_IMPORT_CONF})
if(TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES)
string (REGEX MATCH "[^;]*d3d[0-9]+[.]lib" HARDCODED_D3D9_LIB "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
if (HARDCODED_D3D9_LIB)
message (STATUS "Warning: ${HARDCODED_D3D9_LIB} has been removed from imported dependencies of ${VTK_LIBRARY}")
list (REMOVE_ITEM TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${HARDCODED_D3D9_LIB})
set_target_properties (${VTK_LIBRARY} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES_${CHOSEN_IMPORT_CONF} "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
endif()
endif()
# VTK 6.1 for VC 12, 14
get_target_property (TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${VTK_LIBRARY} INTERFACE_LINK_LIBRARIES)
if(TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES)
string (REGEX MATCH "[^;]*d3d[0-9]+[.]lib" HARDCODED_D3D9_LIB "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
if (HARDCODED_D3D9_LIB)
message (STATUS "Warning: ${HARDCODED_D3D9_LIB} has been removed from imported dependencies of ${VTK_LIBRARY}")
list (REMOVE_ITEM TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${HARDCODED_D3D9_LIB})
set_target_properties (${VTK_LIBRARY} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
endif()
endif()
get_target_property (TARGET_PROPERTY_IMP_PATH ${VTK_LIBRARY} IMPORTED_IMPLIB_${CHOSEN_IMPORT_CONF})
if(TARGET_PROPERTY_IMP_PATH AND EXISTS "${TARGET_PROPERTY_IMP_PATH}")
get_filename_component (TARGET_PROPERTY_IMP_DIR "${TARGET_PROPERTY_IMP_PATH}" PATH)
list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${TARGET_PROPERTY_IMP_DIR}")
endif()
get_target_property (TARGET_PROPERTY_LOCATION_PATH ${VTK_LIBRARY} IMPORTED_LOCATION_${CHOSEN_IMPORT_CONF})
if(TARGET_PROPERTY_LOCATION_PATH AND EXISTS "${TARGET_PROPERTY_LOCATION_PATH}")
get_filename_component (TARGET_PROPERTY_LOCATION_DIR "${TARGET_PROPERTY_LOCATION_PATH}" PATH)
if (WIN32)
list (APPEND 3RDPARTY_VTK_DLL_DIRS "${TARGET_PROPERTY_LOCATION_DIR}")
else()
list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${TARGET_PROPERTY_LOCATION_DIR}")
endif()
endif()
if (WIN32)
list (APPEND 3RDPARTY_VTK_DLL_DIRS "${TARGET_PROPERTY_LOCATION_DIR}")
else()
list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${TARGET_PROPERTY_LOCATION_DIR}")
endif()
endif()
endif()
@@ -187,6 +196,7 @@ if (VTK_FOUND)
endif()
endif()
# endif()
endif()
if (3RDPARTY_VTK_INCLUDE_DIR AND EXISTS "${3RDPARTY_VTK_INCLUDE_DIR}")
list (APPEND 3RDPARTY_INCLUDE_DIRS ${3RDPARTY_VTK_INCLUDE_DIR})

View File

@@ -82,6 +82,11 @@ if { ! [catch {exec vswhere.exe -version "\[16.0,16.99\]" -latest -requires Micr
lappend ::SYS_VC_LIST "vc142-uwp"
lappend ::SYS_VCVARS_LIST "$res\\VC\\vcvarsall.bat"
}
if { ! [catch {exec vswhere.exe -version "\[16.0,16.99\]" -latest -requires Microsoft.VisualStudio.Component.VC.ClangCL -property installationPath} res] } {
lappend ::SYS_VS_LIST "Visual Studio 2019 (16, toolset ClangCL)"
lappend ::SYS_VC_LIST "vclang"
lappend ::SYS_VCVARS_LIST "$res\\VC\\vcvarsall.bat"
}
# detect installed Visual Studio instances from global environment
if { [info exists ::env(VS140COMNTOOLS)] } {
@@ -182,6 +187,9 @@ proc wokdep:gui:UpdateList {} {
if { "$::HAVE_FFMPEG" == "true" } {
wokdep:SearchFFmpeg anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
}
if { "$::HAVE_OPENVR" == "true" } {
wokdep:SearchOpenVR anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
}
if { "$::HAVE_TBB" == "true" } {
wokdep:SearchTBB anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
}
@@ -193,7 +201,11 @@ proc wokdep:gui:UpdateList {} {
}
if { "$::HAVE_ZLIB" == "true" } {
wokdep:SearchStandardLibrary anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs "zlib" "zlib.h" "zlib" {"zlib"}
set aCheckLib "z"
if { "$::tcl_platform(platform)" == "windows" } {
set aCheckLib "zlib"
}
wokdep:SearchStandardLibrary anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs "zlib" "zlib.h" "$aCheckLib" {"zlib"}
}
if { "$::HAVE_LIBLZMA" == "true" } {
set aCheckLib "lzma"
@@ -214,9 +226,14 @@ proc wokdep:gui:UpdateList {} {
wokdep:SearchRapidJson anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
}
if { "$::CHECK_QT4" == "true" } {
wokdep:SearchQt4 anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
if {"$::BUILD_Inspector" == "true" } {
set ::CHECK_QT "true"
}
if { "$::CHECK_QT" == "true" } {
wokdep:SearchQt anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
}
if { "$::CHECK_JDK" == "true" } {
wokdep:SearchJDK anIncErrs anLib32Errs anLib64Errs anBin32Errs anBin64Errs
}
@@ -458,6 +475,8 @@ checkbutton .myFrame.myChecks.myFImageCheck -offvalue "false" -onvalue "true
ttk::label .myFrame.myChecks.myFImageLbl -text "Use FreeImage"
checkbutton .myFrame.myChecks.myTbbCheck -offvalue "false" -onvalue "true" -variable HAVE_TBB -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myTbbLbl -text "Use Intel TBB"
checkbutton .myFrame.myChecks.myOpenVrCheck -offvalue "false" -onvalue "true" -variable HAVE_OPENVR -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myOpenVrLbl -text "Use OpenVR"
if { "$::tcl_platform(os)" != "Darwin" } {
checkbutton .myFrame.myChecks.myGlesCheck -offvalue "false" -onvalue "true" -variable HAVE_GLES2 -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myGlesLbl -text "Use OpenGL ES"
@@ -485,11 +504,16 @@ ttk::label .myFrame.myChecks.myLzmaLbl -text "Use liblzma"
checkbutton .myFrame.myChecks.myE57Check -offvalue "false" -onvalue "true" -variable HAVE_E57 -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myE57Lbl -text "Use E57"
checkbutton .myFrame.myChecks.myQt4Check -offvalue "false" -onvalue "true" -variable CHECK_QT4 -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myQt4Lbl -text "Search Qt4"
checkbutton .myFrame.myChecks.myQtCheck -offvalue "false" -onvalue "true" -variable CHECK_QT -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myQtLbl -text "Search Qt"
checkbutton .myFrame.myChecks.myJDKCheck -offvalue "false" -onvalue "true" -variable CHECK_JDK -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myJDKLbl -text "Search JDK"
if { "$::tcl_platform(platform)" == "windows" } {
checkbutton .myFrame.myChecks.myInspectorBuild -offvalue "false" -onvalue "true" -variable BUILD_Inspector -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myInspectorLbl -text "Build Inspector"
}
# Additional headers search paths
ttk::label .myFrame.myIncLbl -text "Additional headers search paths:" -padding {5 5 80 5}
scrollbar .myFrame.myIncScrl -command ".myFrame.myIncList yview"
@@ -593,8 +617,8 @@ if { "$::tcl_platform(os)" != "Darwin" } {
grid .myFrame.myChecks.myZLibCheck -row $aCheckRowIter -column 6 -sticky e
grid .myFrame.myChecks.myZLibLbl -row $aCheckRowIter -column 7 -sticky w
grid .myFrame.myChecks.myQt4Check -row $aCheckRowIter -column 12 -sticky e
grid .myFrame.myChecks.myQt4Lbl -row $aCheckRowIter -column 13 -sticky w
grid .myFrame.myChecks.myQtCheck -row $aCheckRowIter -column 12 -sticky e
grid .myFrame.myChecks.myQtLbl -row $aCheckRowIter -column 13 -sticky w
incr aCheckRowIter
grid .myFrame.myChecks.myFFmpegCheck -row $aCheckRowIter -column 0 -sticky e
@@ -616,9 +640,16 @@ grid .myFrame.myChecks.myJDKLbl -row $aCheckRowIter -column 13 -sticky w
incr aCheckRowIter
grid .myFrame.myChecks.myRapidJsonCheck -row $aCheckRowIter -column 0 -sticky e
grid .myFrame.myChecks.myRapidJsonLbl -row $aCheckRowIter -column 1 -sticky w
grid .myFrame.myChecks.myOpenVrCheck -row $aCheckRowIter -column 4 -sticky e
grid .myFrame.myChecks.myOpenVrLbl -row $aCheckRowIter -column 5 -sticky w
grid .myFrame.myChecks.myE57Check -row $aCheckRowIter -column 6 -sticky e
grid .myFrame.myChecks.myE57Lbl -row $aCheckRowIter -column 7 -sticky w
if { "$::tcl_platform(platform)" == "windows" } {
grid .myFrame.myChecks.myInspectorBuild -row $aCheckRowIter -column 12 -sticky e
grid .myFrame.myChecks.myInspectorLbl -row $aCheckRowIter -column 13 -sticky w
}
incr aCheckRowIter
# Additional headers search paths

View File

@@ -68,7 +68,7 @@ if { [info exists ::env(SHORTCUT_HEADERS)] } {
}
# fetch environment variables (e.g. set by custom.sh or custom.bat) and set them as tcl variables with the same name
set THE_ENV_VARIABLES {HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_E57 HAVE_RAPIDJSON HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo}
set THE_ENV_VARIABLES {HAVE_FREEIMAGE HAVE_FFMPEG HAVE_TBB HAVE_GLES2 HAVE_D3D HAVE_VTK HAVE_ZLIB HAVE_LIBLZMA HAVE_E57 HAVE_RAPIDJSON HAVE_OPENVR HAVE_OPENCL CHECK_QT4 CHECK_JDK MACOSX_USE_GLX HAVE_RelWithDebInfo BUILD_Inspector}
foreach anEnvIter $THE_ENV_VARIABLES {
set ${anEnvIter} "false"
if { [info exists ::env(${anEnvIter})] } {
@@ -241,7 +241,11 @@ proc wokdep:Preferred {theList theCmpl theArch} {
# keep only two first digits in "vc141"
if { ! [regexp {^vc[0-9][0-9]} $theCmpl aCmpl] } {
set aCmpl $theCmpl
if { [regexp {^vclang} $theCmpl] } {
set aCmpl vc14
} else {
set aCmpl $theCmpl
}
}
set aShortList {}
@@ -621,6 +625,59 @@ proc wokdep:SearchFFmpeg {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBi
return "$isFound"
}
# Search OpenVR SDK placement
proc wokdep:SearchOpenVR {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
upvar $theErrInc anErrInc
upvar $theErrLib32 anErrLib32
upvar $theErrLib64 anErrLib64
upvar $theErrBin32 anErrBin32
upvar $theErrBin64 anErrBin64
set isFound "true"
set anOpenVrHPath [wokdep:SearchHeader "openvr.h"]
if { "$anOpenVrHPath" == "" } {
set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{openvr}*] "$::VCVER" "$::ARCH" ]
if { "$aPath" != "" && [file exists "$aPath/include/openvr.h"] } {
lappend ::CSF_OPT_INC "$aPath/include"
} elseif { "$aPath" != "" && [file exists "$aPath/headers/openvr.h"] } {
lappend ::CSF_OPT_INC "$aPath/headers"
} else {
lappend anErrInc "Error: 'openvr.h' not found (OpenVR)"
set isFound "false"
}
}
set aPlatform "unknown"
if { "$::tcl_platform(platform)" == "windows" } {
set aPlatform "win"
} elseif { "$::tcl_platform(os)" == "Darwin" } {
set aPlatform "osx"
} elseif { "$::tcl_platform(os)" == "Linux" } {
set aPlatform "linux"
}
foreach anArchIter {64 32} {
set anOpenVrLibPath [wokdep:SearchLib "openvr_api" "$anArchIter"]
if { "$anOpenVrLibPath" == "" } {
set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{openvr}*] "$::VCVER" "$anArchIter" ]
set anOpenVrLibPath [wokdep:SearchLib "openvr_api" "$anArchIter" "$aPath/lib/${aPlatform}${anArchIter}"]
set anOpenVrLibPath2 [wokdep:SearchLib "openvr_api" "$anArchIter" "$aPath/lib"]
if { "$anOpenVrLibPath" != "" } {
lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib/${aPlatform}${anArchIter}"
lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin/${aPlatform}${anArchIter}"
} elseif { "$anOpenVrLibPath2" != "" } {
lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
} else {
lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}openvr_api.${::SYS_LIB_SUFFIX}' not found (OpenVR)"
if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
}
}
}
return "$isFound"
}
# Search TBB library placement
proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
upvar $theErrInc anErrInc
@@ -631,7 +688,11 @@ proc wokdep:SearchTBB {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64
# keep only two first digits in "vc141"
if { ! [regexp {^vc[0-9][0-9]} ${::VCVER} aVcLib] } {
set aVcLib ${::VCVER}
if { [regexp {^vclang} ${::VCVER}] } {
set aVcLib vc14
} else {
set aVcLib ${::VCVER}
}
}
set isFound "true"
@@ -1014,8 +1075,8 @@ proc wokdep:SearchVTK {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64
return "$isFound"
}
# Search Qt4 libraries placement
proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
# Search Qt libraries placement
proc wokdep:SearchQt {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64} {
upvar $theErrInc anErrInc
upvar $theErrLib32 anErrLib32
upvar $theErrLib64 anErrLib64
@@ -1023,53 +1084,46 @@ proc wokdep:SearchQt4 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64
upvar $theErrBin64 anErrBin64
set isFound "true"
set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qmessagebox.h"]
set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt}*] "$::VCVER" "$::ARCH" ]
set aQMsgBoxHPath [wokdep:SearchHeader "QtGui/qguiapplication.h"]
if { "$aQMsgBoxHPath" == "" } {
set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$::ARCH" ]
if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qmessagebox.h"] } {
if { "$aPath" != "" && [file exists "$aPath/include/QtGui/qguiapplication.h"] } {
lappend ::CSF_OPT_INC "$aPath/include"
lappend ::CSF_OPT_INC "$aPath/include/Qt"
lappend ::CSF_OPT_INC "$aPath/include/QtGui"
lappend ::CSF_OPT_INC "$aPath/include/QtCore"
lappend ::CSF_OPT_INC "$aPath/include/QtWidgets"
lappend ::CSF_OPT_INC "$aPath/include/QtXml"
} else {
if { [file exists "/usr/include/qt4/QtGui/qmessagebox.h"] } {
lappend ::CSF_OPT_INC "/usr/include/qt4"
lappend ::CSF_OPT_INC "/usr/include/qt4/Qt"
lappend ::CSF_OPT_INC "/usr/include/qt4/QtGui"
lappend ::CSF_OPT_INC "/usr/include/qt4/QtCore"
} else {
lappend anErrInc "Error: 'QtGui/qmessagebox.h' not found (Qt4)"
lappend anErrInc "Error: 'QtGui/qguiapplication.h' not found"
set isFound "false"
}
}
}
set aQtGuiLibName "QtGui"
if { "$::tcl_platform(platform)" == "windows" } {
set aQtGuiLibName "QtGui4"
set aQtGuiLibName "Qt5Gui"
}
foreach anArchIter {64 32} {
set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter"]
if { "$aQMsgBoxLibPath" == "" } {
set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
set aQMsgBoxLibPath [wokdep:SearchLib "${aQtGuiLibName}" "$anArchIter" "$aPath/lib"]
if { "$aQMsgBoxLibPath" != "" } {
lappend ::CSF_OPT_LIB$anArchIter "$aPath/lib"
} else {
lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt4)"
lappend anErrLib$anArchIter "Error: '${::SYS_LIB_PREFIX}${aQtGuiLibName}.${::SYS_LIB_SUFFIX}' not found (Qt)"
if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
}
}
if { "$::tcl_platform(platform)" == "windows" } {
set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter"]
set aQMsgBoxDllPath [wokdep:SearchBin "${aQtGuiLibName}.dll" "$anArchIter"]
if { "$aQMsgBoxDllPath" == "" } {
set aPath [wokdep:Preferred [glob -nocomplain -directory "$::PRODUCTS_PATH" -type d *{qt4}*] "$::VCVER" "$anArchIter" ]
set aQMsgBoxDllPath [wokdep:SearchBin "QtGui4.dll" "$anArchIter" "$aPath/bin"]
set aQMsgBoxDllPath [wokdep:SearchBin "${aQtGuiLibName}.dll" "$anArchIter" "$aPath/bin"]
if { "$aQMsgBoxDllPath" != "" } {
lappend ::CSF_OPT_BIN$anArchIter "$aPath/bin"
} else {
lappend anErrBin$anArchIter "Error: 'QtGui4.dll' not found (Qt4)"
lappend anErrBin$anArchIter "Error: '${aQtGuiLibName}.dll' not found (Qt)"
if { "$::ARCH" == "$anArchIter"} { set isFound "false" }
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -25,6 +25,7 @@ set "HAVE_D3D=false"
set "HAVE_ZLIB=false"
set "HAVE_LIBLZMA=false"
set "HAVE_RAPIDJSON=false"
set "HAVE_OPENVR=false"
set "HAVE_E57=false"
set "CSF_OPT_INC="
set "CSF_OPT_LIB32="
@@ -77,6 +78,9 @@ if "%VCVER:~-4%" == "-uwp" (
set VCLIB=%VCLIB%-uwp
set VCPROP=Universal
)
if "%VCFMT%" == "vclang" (
set VCLIB=vc14
)
rem echo VCVER=%VCVER% VCFMT=%VCFMT% VCLIB=%VCLIB% VCPROP=%VCPROP%
rem ----- Parsing of Visual Studio platform -----
@@ -106,6 +110,10 @@ if not "%DevEnvDir%" == "" (
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
set "DevEnvDir=%%i\Common7\IDE\"
)
) else if /I "%VCFMT%" == "vclang" (
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
set "DevEnvDir=%%i\Common7\IDE\"
)
) else if /I "%VCFMT%" == "gcc" (
rem MinGW
) else (
@@ -118,6 +126,7 @@ if not "%DevEnvDir%" == "" (
echo vc14 = VS 2015
echo vc141 = VS 2017
echo vc142 = VS 2019
echo vclang = VS 2019 with ClangCL toolset
exit /B
)
@@ -147,6 +156,11 @@ if /I "%VCFMT%" == "vc9" (
set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
)
set "VCPlatformToolSet=v142"
) else if /I "%VCFMT%" == "vclang" (
for /f "usebackq delims=" %%i in (`vswhere.exe -version "[16.0,16.99]" -latest -requires Microsoft.VisualStudio.Workload.%VCPROP% -property installationPath`) do (
set "VCVARS=%%i\VC\Auxiliary\Build\vcvarsall.bat"
)
set "VCPlatformToolSet=ClangCL"
) else if /I "%VCFMT%" == "gcc" (
rem MinGW
) else (
@@ -176,6 +190,7 @@ if ["%HAVE_D3D%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DH
if ["%HAVE_ZLIB%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_ZLIB" & set "CSF_DEFINES=HAVE_ZLIB;%CSF_DEFINES%"
if ["%HAVE_LIBLZMA%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_LIBLZMA" & set "CSF_DEFINES=HAVE_LIBLZMA;%CSF_DEFINES%"
if ["%HAVE_RAPIDJSON%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_RAPIDJSON" & set "CSF_DEFINES=HAVE_RAPIDJSON;%CSF_DEFINES%"
if ["%HAVE_OPENVR%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_OPENVR" & set "CSF_DEFINES=HAVE_OPENVR;%CSF_DEFINES%"
if ["%HAVE_E57%"] == ["true"] set "PRODUCTS_DEFINES=%PRODUCTS_DEFINES% -DHAVE_E57" & set "CSF_DEFINES=HAVE_E57;%CSF_DEFINES%"
rem Eliminate VS warning

View File

@@ -16,6 +16,7 @@ export HAVE_GLES2="false";
export HAVE_ZLIB="false";
export HAVE_LIBLZMA="false";
export HAVE_RAPIDJSON="false";
export HAVE_OPENVR="false";
export HAVE_E57="false";
export MACOSX_USE_GLX="false";
export CSF_OPT_INC=""
@@ -106,6 +107,7 @@ if [ "$HAVE_VTK" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -D
if [ "$HAVE_ZLIB" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_ZLIB"; fi
if [ "$HAVE_LIBLZMA" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_LIBLZMA"; fi
if [ "$HAVE_RAPIDJSON" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_RAPIDJSON"; fi
if [ "$HAVE_OPENVR" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_OPENVR"; fi
if [ "$HAVE_E57" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_E57"; fi
# Option to compile OCCT with X11 libs on Mac OS X
if [ "$MACOSX_USE_GLX" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DMACOSX_USE_GLX"; fi

View File

@@ -159,7 +159,7 @@
<PreprocessorDefinitions>_DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP_DEBUG__</AdditionalDependencies>
<OutputFile>.\..\..\..\win32\__VCVER__\bind\__TKNAM__.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win32\__VCVER__\libd;$(CSF_OPT_LIB32D);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@@ -255,7 +255,7 @@
<PreprocessorDefinitions>_DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP_DEBUG__</AdditionalDependencies>
<OutputFile>.\..\..\..\win64\__VCVER__\bind\__TKNAM__.dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win64\__VCVER__\libd;$(CSF_OPT_LIB64D);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

View File

@@ -149,7 +149,7 @@
<PreprocessorDefinitions>_DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP_DEBUG__</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win32\__VCVER__\libd;$(CSF_OPT_LIB32D);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -238,7 +238,7 @@
<PreprocessorDefinitions>_DEBUG;$(CSF_DEFINES);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<AdditionalDependencies>__TKDEP__</AdditionalDependencies>
<AdditionalDependencies>__TKDEP_DEBUG__</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\win64\__VCVER__\libd;$(CSF_OPT_LIB64D);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>

View File

@@ -45,6 +45,7 @@ dev_guides/git_guide/git_guide.md
dev_guides/tests/tests.md
dev_guides/debug/debug.md
dev_guides/upgrade/upgrade.md
dev_guides/visualization/pbr_math.md
dev_guides/building/building.md
dev_guides/building/3rdparty/3rdparty_windows.md

View File

@@ -26,5 +26,6 @@ dev_guides/contribution/coding_rules.md
dev_guides/git_guide/git_guide.md
dev_guides/tests/tests.md
dev_guides/upgrade/upgrade.md
dev_guides/visualization/pbr_math.md
tutorial/tutorial.md

View File

@@ -64,7 +64,7 @@ Then makefiles will appear in the build folder (e.g. <i> D:/occt/build-android <
Alternatively one may specify the values without a toolchain file:
> cmake -G "MinGW Makefiles" -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=D:/DevTools/android-ndk-r13b -DCMAKE_ANDROID_STL_TYPE=gnustl_shared -DCMAKE_SYSTEM_VERSION=15 -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_MAKE_PROGRAM=D:/DevTools/MinGW/bin/mingw32-make.exe -D3RDPARTY_DIR=D:/occt-3rdparty D:/occt
> cmake -G "MinGW Makefiles" -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_NDK=D:/DevTools/android-ndk-r13b -DCMAKE_ANDROID_STL_TYPE=gnustl_shared -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_MAKE_PROGRAM=D:/DevTools/MinGW/bin/mingw32-make.exe -D3RDPARTY_DIR=D:/occt-3rdparty D:/occt
@figure{/dev_guides/building/android/images/android_image006.png}

View File

@@ -150,7 +150,8 @@ Steps to prepare dump of the object into json:
1. Create method <b>DumpJson</b>. The method should accept the output stream and the depth for the fields dump.
Depth, equal to zero means that only fields of this class should be dumped. Default value -1 means that whole tree of dump will be built recursively calling dump of all fields.
2. Put into the first row of the method <b>OCCT_DUMP_CLASS_BEGIN</b>. This macro creates a local variable, that will open Json structure on start, and close on exit from this method.
2. Put into the first row of the method <b>OCCT_DUMP_CLASS_BEGIN</b> or <b>OCCT_DUMP_TRANSIENT_CLASS_BEGIN</b> (for Standard_Transient objects).
This macro appends class name into output stream.
3. Add several macro to store field values.
@@ -368,3 +369,53 @@ Each counter has its name shown when the collected statistics are printed.
In DRAW, use command *dperf* to print all performance statistics.
Note that performance counters are not thread-safe.
@section occt_debug_sanitizers Use of compiler sanitizers
GCC and Clang compilers provide options for instrumenting the code with the tools intended for detection of run-time errors, called sanitizers.
This section provides some hints for using sanitizers for detecting possible errors in OCCT code.
@subsection occt_debug_sanitizers_linux Linux
Example of configuration steps for Ubuntu:
1. In CMake configuration:
- Use up-to-date version of the GCC or CLang compiler; make sure that if CMAKE_CXX_COMPILER is set to C++ compiler (e.g. "clang++-6.0") and CMAKE_C_COMPILER is set to C compiler (e.g. "clang-6.0")
- Ensure that CMAKE_LINKER is set to the C++ linker bundled with compiler (e.g. clang++-6.0); this is important to avoid linking problems
- For building with Address sanitizer, set CMAKE_CXX_FLAGS and CMAKE_C_FLAGS to "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls"
- For building with Undefined Behavior sanitizer, set CMAKE_CXX_FLAGS and CMAKE_C_FLAGS to "-fsanitize=undefined -fno-omit-frame-pointer -fno-optimize-sibling-calls"
- Set CMAKE_BUILD_TYPE to RelWithDebInfo to get more informative stack traces on errors
2. Build as usual (make)
Be prepared that it works much slower than normal build and consumes more disk space.
3. Before running executable, make sure that "llvm-symbolizer" is in PATH; this is necessary to get human-readable stack traces. The tool must have exactly that name.
If it is installed in common folder (/usr/bin or similar) with different name, one option is to create a symlink, for instance:
> sudo ln -s /usr/bin/llvm-symbolizer-6.0 /usr/bin/llvm-symbolizer
Alternatively, add directory where actual llvm-symbolizer is located (such as /usr/lib/llvm-6.0/bin) to the PATH variable.
4. Set environment variable to disable memory leaks detection (they seem to be reported for every global variable at exit, not much useful):
> export ASAN_OPTIONS=detect_leaks=0
5. Set environment variable CSF_CPULIMIT_FACTOR to reasonably large number to increase the time limits for program execution (used by OCCT tests) to compensate the performance penalty introduced by sanitizers:
> export CSF_CPULIMIT_FACTOR=20
6. When using UBSan, set environment variable UBSAN_OPTIONS to get stack traces:
> export UBSAN_OPTIONS=print_stacktrace=1
7. Run DRAW and perform tests as usual, keeping in mind that running with sanitizer is much heavier than normal build:
> ./draw.sh relwithdeb <br>
> Draw[]> testgrid -parallel 0
Note that when running tests under sanitizers, behavior may be different.
Known problems (as of CLang 6.0) are:
- Software signals (access violation etc.) are not handled
- Heap memory usage always reports zero
@subsection occt_debug_sanitizers_windows Windows
Though CLang toolset is available in Visual Studio 2015 and newer, sanitizer do not seem to be available out of the box (last tested with VS 2019 16.2.3).

View File

@@ -11,6 +11,10 @@ The following documents provide information on OCCT building, development and te
* @subpage occt_dev_guides__tests "Automatic Testing system"
* @subpage occt_dev_guides__debug "Debugging tools and hints"
The following documents provide information on OCCT algorithms background:
* @subpage occt_dev_guides__pbr_math "Physically-based Rendering math (PBR for rasterization)"
The following guide provides information relevant to upgrading applications developed with previous versions of OCCT, to recent one:
* @subpage occt_dev_guides__upgrade "Upgrade from previous OCCT versions"

View File

@@ -1888,3 +1888,100 @@ Unexpected const-ness of Aspect_Window::DoResize() method has been removed, so t
@subsection upgrade_750_rename Renaming of types
Enumeration BRepOffset_Type is renamed to ChFiDS_TypeOfConcavity.
@subsection upgrade_750_tkv3d TKV3d/TKService toolkits changes
The following changes could be highlighted while porting:
* *Prs3d::GetDeflection()* has been moved to *StdPrs_ToolTriangulatedShape::GetDeflection()*.
* *Prs3d_ShapeTool* has been moved to *StdPrs_ShapeTool*.
* *StdSelect_ViewerSelector3d* has been moved to *SelectMgr_ViewerSelector3d*.
* *Font_BRepFont* has been moved to *StdPrs_BRepFont*.
* Visualization classes now use *TopLoc_Datum3D* (from *TKMath*) instead of *Geom_Transformation* (from *TKG3d*) as smart pointer to *gp_Trsf*.
This is rather an internal change, but some applications might need to be updated.
@subsection upgrade_750_hlrangle Prs3d_Drawer deviation angle
Properties Prs3d_Drawer::HLRAngle() and Prs3d_Drawer::HLRDeviationCoefficient() have been removed from classes *Prs3d_Drawer*, *AIS_Shape* and *AIS_InteractiveContext*.
Prs3d_Drawer::DeviationAngle() should be now used instead of Prs3d_Drawer::HLRAngle() and Prs3d_Drawer::DeviationCoefficient() instead of Prs3d_Drawer::HLRDeviationCoefficient().
The default value of Prs3d_Drawer::DeviationAngle() property has been changed from 12 to 20 degrees to match removed Prs3d_Drawer::HLRAngle(), previously used as input for triangulation algorithm.
@subsection upgrade_750_hlrprs Changes in HLR presentation API
Methods computing HLR presentation within *PrsMgr_PresentableObject::Compute()* have been renamed to *PrsMgr_PresentableObject::computeHLR()*
and now accept *Graphic3d_Camera* object instead of removed *Prs3d_Projector*.
@subsection upgrade_750_dimensions Dimension and Relation presentations moved from AIS to PrsDim
Presentation classes displaying Dimensions and Relations have been moved from *AIS* package to *PrsDim*.
Corresponding classes should be renamed in application code (like *AIS_LengthDimension* -> *PrsDim_LengthDimension*).
@subsection upgrade_750_sensitiveEntity Select3D_SensitiveEntity interface change
The method Select3D_SensitiveEntity::NbSubElements() has been changed to be constant. Select3D_SensitiveEntity subclasses at application level should be updated accordingly.
@subsection upgrade_750_Booleans Changes in Boolean operations algorithm
* TreatCompound method has been moved from *BOPAlgo_Tools* to *BOPTools_AlgoTools*. Additionally, the map parameter became optional:
~~~~
void BOPTools_AlgoTools::TreatCompound (const TopoDS_Shape& theS,
TopTools_ListOfShape& theLS,
TopTools_MapOfShape* theMap = NULL);
~~~~
@subsection upgrade_750_Adaptor2d_OffsetCurve Offset direction change
Offset direction, which used in class Adaptor2d_OffsetCurve for evaluating values and derivatives of offset curve is unified for offset direction used in class Geom2d_OffsetCurve: now offset direction points to outer ("right") side of base curve instead of the previously used inner ("left") side. Old usage of class in any application should be changed something like that:
Adaptor2d_OffsetCurve aOC(BaseCurve, Offset) --> Adaptor2d_OffsetCurve aOC(BaseCurve, -Offset)
@subsection upgrade_750_message_messenger Message_Messenger interface change
Operators << with left argument *Handle(Message_Messenger)*, used to output messages with
a stream-like interface, have been removed.
This functionality is provided now by separate class *Message_Messenger::StreamBuffer*.
That class contains a stringstream buffer which can be filled using standard stream
operators. The string is sent to a messenger on destruction of the buffer object,
call of its method Flush(), or using operator << with one of ostream manipulators
(*std::endl, std::flush, std::ends*). Manipulator *Message_EndLine* has been removed,
*std::endl* should be used instead.
New methods *SendFail(), SendAlarm(), SendWarning(), SendInfo()*, and *SendTrace()* are
provided in both *Message_Messenger* class and as static functions in *Message* package
(short-cuts to default messenger), returning buffer object for the output of
corresponding type of the message.
The code that used operator << for messenger, should be ported as follows.
Before the change:
~~~~~
Handle(Message_Messenger) theMessenger = ...;
theMessenger << "Value = " << anInteger << Message_EndLine;
~~~~~
After the change, single-line variant:
~~~~~
Handle(Message_Messenger) theMessenger = ...;
theMessenger->SendInfo() << "Value = " << anInteger << std::endl;
~~~~~
After the change, extended variant:
~~~~~
Handle(Message_Messenger) theMessenger = ...;
Message_Messenger::StreamBuffer aSender = theMessenger->SendInfo();
aSender << "Array: [ ";
for (int i = 0; i < aNb; ++i) { aSender << anArray[i] << " "; }
aSender << "]" << std::endl; // aSender can be used further for other messages
~~~~~
@subsection upgrade_750_message_printer Message_Printer interface change
Previously, sub-classes of *Message_Printer* have to provide a triplet of *Message_Printer::Send()* methods accepting different string representations: TCollection_AsciiString, TCollection_ExtendedString and Standard_CString.
*Message_Printer* interface has been changed, so that sub-classes now have to implement only single method *Message_Printer::send()* accepting TCollection_AsciiString argument and having no Endl flag, which has been removed.
Old three Message_Printer::Send() methods remain defined virtual with unused last argument and redirecting to new send() method by default.
@subsection upgrade_750_draw_hotkeys Draw Harness hotkeys
Draw Harness hotkeys **W** (Wireframe) and **S** (Shaded) have been re-mapped to **Ctrl+W** and **Ctrl+S**.
Hotkey **A** has been remapped to **Backspace**.
Hotkeys WASD and Arrays are now mapped for walk-through navigation in 3D Viewer.

View File

@@ -0,0 +1,777 @@
PBR math (rasterization) {#occt_dev_guides__pbr_math}
========================
@tableofcontents
# Preface
**Empirical** illumination models like **Phong reflection model** have been used in real-time graphics for a long time due to their simplicity, convincing look and affordable performance.
Before programmable pipeline has been introduced, graphics cards implemented Gouraud shading as part of fixed-function Transformation & Lighting (T&L) hardware blocks.
Nowadays, however, numerous trade-offs of this simplicity (like lighting partially baked into object material properties and others) pushed developers to **Physically-Based Rendering** (**PBR**) illumination models.
PBR models try to fit surface shading formulas into constrains of physical laws of light propagation / absorption / reflection - hence, called "physically-based".
There are two main categories of PBR illumination:
1. Non-real-time renderer (cinematic).
2. Real-time renderer.
The main objective of cinematic renderer is uncompromised quality, so that it relies on ray-tracing (path-tracing) rendering pipeline.
Although performance of current graphics hardware does not make it possible using computationally-intensive path-tracing renderer in real-time graphics, it can be used in interactive fashion.
"Physically-based" does not necessarily mean physically-correct/precise.
The main objective of real-time PBR renderer is to be fast enough even on low-end graphics hardware.
So that in contrast, it hardly relies on rasterization rendering pipeline, various approximations and tricks making it applicable in real-time, while looking good enough and preserving some physical properties.
OCCT 3D Viewer provides both kinds of PBR renderers, and although they share some details in common, this article is devoted to real-time PBR metallic-roughness illumination model.
This article describes the math underneath PBR shading in OCCT 3D Viewer and its GLSL programs.
However, this article does not clarifies related high-level APIs nor PBR material creation pipelines, as this is another topic.
# Notation
| | | |
|-:|:-|:-|
| \f$n\f$ | normal (on surface) | \f$\|n\|=1\f$ |
| \f$v\f$ | view direction | \f$\|v\|=1\f$ |
| \f$l\f$ | light | \f$\|l\| = 1\f$ |
| \f$h=\frac{v+l}{\|v + l\|}\f$ | half vector | |
| \f$m\f$ | metallic factor | \f$[0, 1]\f$ |
| \f$r\f$ | roughness factor | \f$[0, 1]\f$ |
| \f$IOR\f$ | index of refraction | \f$[1, 3]\f$ |
| \f$c\f$ | albedo color | \f$(R, G, B)\f$ |
\f$\cos\theta_l=(n \cdot l)\f$
\f$\cos\theta_v=(n \cdot v)\f$
\f$\cos\theta_h=(n \cdot h)\f$
\f$\cos\theta_{vh}=(v \cdot h)\f$
# Illumination model
The main goal of illumination model is to calculate outgoing light radiance \f$L_o\f$ along the certain direction.
The starting point of calculation might be the view direction \f$v\f$ aimed from point on surface (or in more general case just in space) to viewer position.
Considering the point on opaque surface with normal \f$n\f$ the main equation of illumination can be defined as:
\f[L_o=\int\limits_H f(v, l) L_i(l) \cos\theta_l\, \mathrm{d}l\f]
Where \f$L_i(l)\f$ is light radiance coming from \f$l\f$ direction, \f$f(v,l)\f$ is **Bidirectional Reflectance Distribution Function** (**BRDF**) and \f$H\f$ is hemisphere which is oriented regarding to the surface normal \f$n\f$.
Opaqueness of the surface mentioned earlier is important because in that case hemisphere is enough.
More general model will require to consider directions all around a whole sphere and is not observed in this paper.
\f$\cos\theta_l\f$ factor appearing is caused by affection of surface area and light direction mutual orientation to the amount of radiance coming to this area.
This is mainly due to geometric laws. The rest part of integral is the key of the whole illumination model.
BRDF defines it's complexity and optical properties of material.
It has to model all light and material interactions and also has to satisfy some following criteria in order to be physical correct:
* Positivity: \f$f(v,l) \geq 0\f$
* Helmholtz reciprocity: \f$f(v,l) = f(l, v)\f$ (follows from 2<sup>nd</sup> Law of Thermodynamics)
* Energy conservation: \f$\displaystyle \forall v \, \int\limits_H f(v,l) \cos\theta_l \, \mathrm{d}l = 1\f$ (in order not to reflect more light than came)
It is worth to be mentioned that \f$f(v,l)\f$ depends on \f$n\f$ also but it is omitted to simplify notation. BRDF is usually split into two parts:
\f[f(v,l) = f_d(v,l)+f_s(v, l)\f]
Where \f$f_s(v, l)\f$ (specular BRDF) models reflection light interaction on surface and \f$f_d(v,l)\f$ (diffuse BRDF) models other processes happening depth in material (subsurface scattering for example).
So that illumination equation might be rewritten as:
\f[L_o=\int\limits_H (f_d(v,l)+f_s(v, l)) L_i(l) \cos\theta_l\, \mathrm{d}l\f]
PBR theory is based on **Cook-Torrance specular BRDF**. It imagines surface as set of perfectly reflected micro faces distributed on area in different ways which is pretty good model approximation of real world materials.
If this area is small enough not to be able to recognize separate micro surfaces the results becomes a sort of averaging or mixing of every micro plane illumination contribution.
In that level it allows to work with micro faces in statistical manner manipulating only probabilities distributions of micro surfaces parameters such as normals, height, pattern, orientation etc.
In computer graphics pixels are units of images and it usually covers a relatively large areas of surfaces so that micro planes can be considered to be unrecognizable.
Going back to the BRDF the Cook-Torrance approach has the following expression:
\f[f_s(v,l)=\frac{DGF}{4\cos\theta_l\cos\theta_v}\f]
Three parts presented in nominator have its own meaning but can have different implementation with various levels of complexity and physical accuracy.
In that paper only one certain implementation is used. The \f$D\f$ component is responsible for **micro faces normals distribution**.
It is the main instrument that controls reflection's shape and strength according to **roughness** \f$r\f$ parameter.
The implementation with good visual results is **Trowbridge-Reitz GGX** approach used in Disney's RenderMan and Unreal Engine:
\f[D=\frac{\alpha^2}{\pi(\cos^2\theta_h(\alpha^2-1) + 1)^2}\f]
Where \f$\alpha = r^2\f$. This square in needed only for smoother roughness parameter control.
Without it the visual appearance of surface becomes rough too quickly during the parameter's increasing.
The second \f$G\f$ component is called **geometric shadowing** or attenuation factor.
The point is that micro surfaces form kind of terrain and can cast shadows over each other especially on extreme viewing angles.
**Schlick's model** has been chosen as implementation:
\f[\displaystyle G=\frac{\cos\theta_l \cos\theta_v}{(\cos\theta_l(1-k)+k)(\cos\theta_v(1-k)+k)}\f]
Where \f$k=\frac{\alpha}{2}\f$, which means \f$k=\frac{r^2}{2}\f$ in terms of this paper.
But \f$G\f$ depends on many factors so that it's approximations has float nature and can be modified a little bit in some cases in order to get more pleasant visual results.
One of this modification will be described later in following chapters.
The last component \f$F\f$ shows **how much light is reflected from surface** and is called **Fresnel's factor**.
The rest amount of radiance might be absorbed or refracted by material.
The most accurate expression of it is pretty complicate for calculation so that there is a variety of approximations.
The good one with less computation efforts is **Schlick's implementation**:
\f[F=F_0+(1-F_0)(1-\cos\theta_{vh})^5\f]
Here \f$F_0\f$ is material's response coefficient at normal incidence (zero angle).
Fresnel's factor has to be calculated differently for metals and dielectric/non-metals, but PBR theory tries to come up with universal formula for all types of material.
In order to do that it is needed to be noticed that Schlick's approximation is applicable only to non-conductors and in that case \f$F_0 = F_{dielectric} = \left(\frac{1-IOR}{1+IOR}\right)^2\f$.
**Index of Refraction** \f$IOR\f$ shows the proportion between light speed in vacuum (or even in air) and in material.
The reference value of \f$IOR\f$ for plastic is **1.5**, and this value can be considered as default for all unknown dielectrics.
In practice this parameter controls reflectance ability of material.
Also it should be remembered that this approximation produces poor results with large \f$IOR\f$ values so that it is recommended to be kept in range of \f$[1, 3]\f$ in order to get plausible Fresnel's factor.
This formula might be further propagated onto metals by using \f$F_0\f$ measured specifically for certain metal.
It can be considered as some kind of a 'color' of metal and can be stored as albedo parameter \f$c\f$.
And the final step of defining Fresnel's factor formula is mixing all this \f$F_0\f$ using metallic parameter \f$m\f$ (**metalness**):
\f[F_0 = F_{dielectric}(1-m)+cm\f]
For pure dielectrics with \f$m=0\f$ exactly Schlick's approximation will be used.
For pure metals with \f$m=1\f$ it will be a little inaccurate but the same formula with measured \f$F_0\f$ values.
Everything else for \f$m \in (0, 1)\f$ is not physically correct and it is recommended to keep \f$m\f$ exactly 1 or 0.
Intermediate values may represent mixed areas for smooth transition between materials - like partially rusted metal (rust is mostly dielectric).
Also it might be useful when parameters are read from textures with filtering and smoothing.
BRDF described above has one important trait making computations easier called **isotropy**.
Isotropy in this case means independence from rotation about normal resulting from supposition of uniform micro faces distribution at any direction along a surface.
It allows to simplify random samples generation during Monte-Carlo integrals calculation and reduce dimensions of some lookup tables, which will be discussed in following chapters.
Of course, isotropic materials form only subset of all real world's materials, but this subset covers majority of cases.
There are special models considering special anisotropic traits of surfaces like a grinding of metal or other with dependency on rotation about normal;
these models require special calculation tricks and additional parameters and are out of scope of this paper.
The only thing left to do is to define \f$f_d(v,l)\f$.
This part is responsible for processes happening in depth of material.
First of all the amount of input light radiance participating in these processes is needed to be calculated.
And it exactly can be realized from already known Fresnel's factor \f$F\f$ showing amount of reflected light but in negative term in this case in order to get the radiance left after reflection:
\f[1-F\f]
This part of ingoing light is assumed to be refracted in depth of surface and variety of events may happen there.
A sequence of absorptions, reflections and reemissions more or less leads to light's subsurface scattering.
Some part of this scattered light can go back outside but in modified form and in pretty unpredictable directions and positions.
For opaque materials this part is noticeable and forms it's own color.
If subsurface's paths of light are small enough and points of output are distributed locally around the input point it's possible to work in statistical way similar to the micro faces.
This assumption covers a big amount of real world opaque materials.
Other materials like skin, milk etc. with noticeable effect of subsurface scattering usually presented in form of partial translucency and some kind of self emission
have more widely distributed output points and require more accurate and complicate ways of modeling with maybe some theory and techniques from volumetric rendering.
The simple but visually enough assuming for statistically driven type of materials is just the same radiance for any direction. It results to **Lambertian's BRDF**:
\f[\frac{c}{\pi}\f]
Where \f$\pi\f$ is normalization coefficient in order to meet BRDF's criteria and \f$c\f$ is material's own color formed by adventures of light under surface.
There is one detail about light interaction bringing some physicality to the model, and that is an absence of this diffuse component in metals.
Metals reflect main part of light and the rest of it is absorbed being transformed into other form (mostly heat).
That is the main visual difference between metallic and non-metallic materials realizing of which brings model to higher level of quality in compare to older non-physical models.
So that all parts described above can be combined into united diffuse BRDF:
\f[f_d(v,l) = (1-F)(1-m)\frac{c}{\pi}\f]
\f$m\f$ is recommended to be exactly 1 or 0 but all values between can represent transition areas, as mentioned before.
In this chapter one possible implementation of illumination model reflecting main PBR principles has been defined.
The next step is using of it in practice.
# Practical application
It's time to apply deduced illumination model in practice.
And the first step of it is separation of **direction based light sources** from illumination integral.
Directional nature of such light sources means possibility to calculate it's influence to point of surface using only one direction and its intensity.
Usually sources of this type do not have physical size and are represented only by position in space (for point or spot lights) or by direction itself (direction light imagined to be too far point sources like sun).
This is just a kind of abstraction, while real world light emitters have noticeably sizes.
But sources with realistic form and size cannot be presented in discrete term and require continuous integrals calculations or special approximations in order to be accurately injected to the model.
In most cases direct based light sources in form of emitting points in space or just certain directions are good approximations and are enough for beginning.
Having finite discrete amount of it in scene and considering only single direction from every of these lights, the integral is transformed just to the sum:
\f[L_{direct} = \sum_{j=1}^M f(v, l_j) L_i^{direct}(l_j) \cos\theta_{l_j}\f]
Where \f$M\f$ is a number of sources, \f$l_j\f$ is a direction and \f$L_i^{direct}\f$ is an intensity related to this direction.
\f$direct\f$ label means that illumination has been computed directly from sources.
The BRDF can be used directly without any calculation problems.
The only exception might be \f$k\f$ in \f$G\f$ factor - it is recommended to be equal \f$\frac{(r+1)^2}{8}\f$ in order to get more pleasant results (that is modification mentioned in previous chapter).
And actually it is enough to finally see something.
There will be correct visualization with assumption of complete dark environment and absence of other points influence.
It is called **local illumination**. Based on this name there is also a global or **indirect illumination** and that is the rest of integral:
\f[L_{indirect} = \int\limits_H f(v, l) L_i^{indirect}(l) \cos\theta_l\, \mathrm{d}l\f]
It includes influence of light reflected or scattered from other points and environment's contribution.
It's impossible to achieve photorealistic results without this component, but is is also very difficult to compute.
While the cross point light interaction cannot be calculated in a simple way (especially in real time rendering), the environment illumination has some options to be realized via precomputational work before visualization.
But right now lets summarize the practical application of illumination model.
At this moment the output radiance is represented as:
\f[L_o = L_{direct} + L_{indirect}\f]
Where \f$L_{direct}\f$ is direction based light sources contribution which can be directly computed just applying bare formulas.
It is enough to get some results in terms of local illumination but without \f$L_{indirect}\f$ component image will not be looked lifelike.
\f$L_{indirect}\f$ is not trivial thing for calculation and that is stumbling block for real time rendering applications.
But it can be relatively easy implemented in case of environment illumination via some precomputational work about which will be told in details in following chapters.
# Image based lighting
The next goal after \f$L_{direct}\f$ calculation is to find \f$L_{indirect}\f$.
And it would be easier if \f$L_i^{indirect}(l)\f$ was known for every \f$l\f$.
That is the main assumption of **image based lightning** (**IBL**).
In practice, it can be achieved using environment image map, which is a special image representing illumination from all possible directions.
This image might be a photo capturing a real world environment (spherical 360 degrees panoramas) or generated image baking the 3D scene itself, including in that case reflections of other objects.
Environment image might be packed in different ways - **cube maps** and equirectangular maps are the most commonly used.
Anyway, it allows \f$L_i^{indirect}(l)\f$ to be defined for every \f$l\f$ and its practical implementation in form of images gives name for this approach.
Lets back to indirect illumination integral:
\f[L_{indirect} = \int\limits_H f(v, l) L_i^{indirect}(l) \cos\theta_l\, \mathrm{d}l\f]
Substituting the BRDF by its expression allows to split indirect illumination into diffuse and specular components:
\f[L_{indirect} = \int\limits_H f_d(v,l)L_i^{indirect}(l)\cos\theta_l\, \mathrm{d}l + \int\limits_H f_s(v,l)L_i^{indirect}(l)\cos\theta_l\, \mathrm{d}l = \f]
\f[= (1-m)\frac{c}{\pi}\int\limits_H (1-F)L_i^{indirect}(l)\cos\theta_l\, \mathrm{d}l + \frac{1}{4}\int\limits_H \frac{DFG}{\cos\theta_l \cos\theta_v}L_i^{indirect}(l)\cos\theta_l\, \mathrm{d}l\f]
This splitting seems not to lead to simplicity of calculation but these two parts will be computed in slightly different ways in future.
Lets write down this separately:
\f[L_{indirect}^d = (1-m)\frac{c}{\pi}\int\limits_H (1-F)L_i^{indirect}(l)\cos\theta_l\, \mathrm{d}l\f]
\f[L_{indirect}^s = \frac{1}{4}\int\limits_H \frac{DFG}{\cos\theta_v \cos\theta_l} L_i^{indirect}(l) \cos\theta_l\, \mathrm{d}l\f]
Next transformations of these expressions require understanding of numerical way to find hemisphere integral and also its performance optimization techniques.
And that the topic of the next chapter.
# Monte-Carlo numeric integration
**Monte-Carlo** is one of numeric methods to **find integral**.
It is based on idea of mathematical expectation calculation.
In one dimensional case if \f$f(x)\f$ is a function with parameter distributed according to probability density \f$p(x)\f$ the mathematical expectation of it can be found using following expression:
\f[E = \int\limits_{-\infty}^\infty f(x) p(x)\, \mathrm{d}x\f]
Also this expectation can be approximated in statistical term using certain sequence of random variable \f$x\f$:
\f[E \approx \frac{1}{N} \sum_{i=1}^{N} f(x_i)\f]
It can be used in general definite integrals calculations.
Just valid \f$p(x)\f$ defined on \f$[a, b]\f$ range and sequence \f$x_i\f$ generated according to it are needed for that:
\f[\int\limits_a^b f(x)\, \mathrm{d}x = \int\limits_a^b \frac{f(x)}{p(x)}p(x)\, \mathrm{d}x = \int\limits_{-\infty}^{\infty} \frac{f(x)}{p(x)}p(x)\, \mathrm{d}x \approx \frac{1}{N} \sum_{i=1}^{N} \frac{f(x_i)}{p(x_i)}\f]
Where \f$f(x)\f$ is considered to be equal to zero outside of \f$[a, b]\f$ range.
This is also true for functions on sphere or hemisphere:
\f[\int\limits_{H|S} f(l)\, \mathrm{d}l \approx \frac{1}{N}\sum_{i=1}^{N} \frac{f(l_i)}{p(l_i)}\f]
The main questions are choosing \f$p(l)\f$ and generating samples \f$l_i\f$.
The one of the simple ways is uniform distribution along sphere or hemisphere.
Lets realize that on sphere for example.
There are \f$4\pi\f$ possible directions in terms of sphere's areas and steradians (direction can be presented as dot on a unit sphere):
\f[\int\limits_S 1\, \mathrm{d}l = 4\pi\f]
Where \f$S\f$ is the unit sphere.
In order to be uniform \f$p(l)\f$ must be constant and satisfy normalization criteria:
\f[\int\limits_S p(l)\, \mathrm{d}l = 1\f]
So that \f$p(l) = \frac{1}{4\pi}\f$.
Usually direction \f$l\f$ is parametrized by spherical coordinates \f$\phi \in [0, 2\pi]\f$ and \f$\theta \in [0, \pi]\f$ boiling down to the 2D samples generation.
But in these terms joint \f$p(\theta, \phi)\f$ will be looked slightly different due to variables transition.
\f$l\f$ is defined in regular Cartesian coordinates \f$l=(x, y, z)\f$ with \f$\|l\| = 1\f$.
The spherical coordinates transform looks like:
\f[x = r\sin\theta\cos\phi,\, y = r\sin\theta\sin\phi,\, z = r\cos\theta\f]
Where \f$r = 1\f$.
In order to express probability density using new variables it is needed to multiply this density by Jacobian of transform:
\f[p(\theta,\phi) = p(l)|J_T|\f]
Where:
\f[|J_T| = \begin{vmatrix} \frac{\partial x}{\partial r} & \frac{\partial x}{\partial \theta} & \frac{\partial x}{\partial \phi} \\ \frac{\partial y}{\partial r} & \frac{\partial y}{\partial \theta} & \frac{\partial y}{\partial \phi} \\ \frac{\partial z}{\partial r} & \frac{\partial z}{\partial \theta} & \frac{\partial z}{\partial \phi} \end{vmatrix} = r^2\sin\theta\f]
So that joint probability density in new variables looks like:
\f[p(\theta, \phi) = \frac{\sin\theta}{4\pi}\f]
This variable transfer rule of **Probability Density Function** (**PDF**) will be useful in following chapters, when integral calculation optimization techniques will be being told.
Having \f$p(\theta, \phi)\f$ the partial single dimensional probability densities are able to be found:
\f[p(\phi) = \int\limits_0^\pi p(\theta, \phi)\, \mathrm{d}\theta = \frac{1}{4\pi} \int\limits_0^\pi \sin\theta\, \mathrm{d}\theta = \frac{1}{2\pi}\f]
\f[p(\theta) = \int\limits_0^{2\pi} p(\theta, \phi)\, \mathrm{d}\phi = \frac{\sin\theta}{4\pi}\int\limits_0^{2\pi}1\, \mathrm{d}\phi = \frac{\sin\theta}{2}\f]
The final step is sequence generation itself.
In order to be able to generate values with arbitrary distributions it is helpful to start from uniform numbers in range of \f$[0, 1]\f$.
And that can be done via any known true- and pseudo- random generators.
Even simple \f$\frac{1}{i}\f$ sequence is appropriate for beginning but it can be not so efficient in terms of computations convergence.
There are specially designed series for the last reason and it will be tackled in chapter about optimizations.
The \f$\phi\f$ variable is noticed to be uniformly distributed so that it can be directly generated without any additional manipulations.
Just range \f$[0, 1]\f$ is needed to be mapped to range \f$[0, 2\pi]\f$.
For any other variables including \f$\theta\f$ the inverse transform sampling approach can be applied.
First of all **cumulative distribution function** (**CDF**) is needed to be found.
It is probability of random value to be less than argument of this functions by definition.
For continues distributions it can be expressed in following form:
\f[F(x) = \int\limits_{-\infty}^x p(x')\, \mathrm{d}x'\f]
Lets find CDF for \f$\theta\f$:
\f[F(\theta) = \int\limits_{-\infty}^\theta p(\theta')\, \mathrm{d}\theta' = \int\limits_0^\theta \frac{\sin\theta'}{2}\, \mathrm{d}\theta' = \frac{1-\cos\theta}{2}\f]
The CDF maps \f$\theta\f$ values from range of \f$[0, \pi]\f$ to probability in range of \f$[0, 1]\f$.
The next step is to find inverse cumulative function which can be not so trivial sometimes but pretty obvious in current case:
\f[F^{-1}(u) = \arccos(1-2u)\f]
If substitute uniform distributed in range \f$[0, 1]\f$ values \f$u\f$ as argument of this function the values with origin probability density will appear.
In other words:
\f[\theta = \arccos(1 - 2u),\, u \in [0, 1],\, p(u) = 1 \Rightarrow p(\theta) = \frac{\sin\theta}{2}\f]
That is the key of this random values generation technique.
All steps described above can be also done for hemisphere:
\f[p(l) = \frac{1}{2\pi}\f]
\f[p(\theta, \phi) = \frac{\sin\theta}{2\pi}\f]
\f[p(\phi) = \int\limits_0^\frac{\pi}{2} p(\theta, \phi)\, \mathrm{d}\theta = \frac{1}{2\pi} \int\limits_0^\frac{\pi}{2} \sin\theta\, \mathrm{d}\theta = \frac{1}{2\pi}\f]
\f[p(\theta) = \int\limits_0^{2\pi} p(\theta, \phi)\, \mathrm{d}\phi = \frac{\sin\theta}{2\pi}\int\limits_0^{2\pi}1\, \mathrm{d}\phi = \sin\theta\f]
\f[\theta = \arccos(1-u)\f]
Mote-Carlo integration cannot guarantee exact estimation of convergence speed with using random generated samples.
There is only probability estimation of it.
But this algorithm is pretty universal and relatively simple to be applied to almost any function using at least uniform distributed points.
Moreover special \f$p(l)\f$ can be chosen and special pseudo-random sequences can be designed in order to speed up convergence for some functions (following chapter talk about that in details).
That is why this method is widely used in computer graphics and demonstrates good results.
Also another one advantage is worth to be mentioned - possibility to iteratively accumulate computations and present intermediate results during rendering which is used in some ray tracing applications.
# Split sum
Lets go back to the image based lighting and the figure of specular component.
As was defined before that is hemisphere integral with following expression:
\f[L_{indirect}^s = \frac{1}{4}\int\limits_H \frac{DFG}{\cos\theta_v \cos\theta_l} L_i^{indirect}(l) \cos\theta_l\, \mathrm{d}l\f]
The Monte-Carlo integration algorithm can be directly applied:
\f[L_{indirect}^s = \int\limits_H f_s(v, l)L_i^{indirect}(l)\cos\theta_l\, \mathrm{d}l \approx \frac{1}{N}\sum_{i=1}^N \frac{f_s(v, l_i) L_i^{indirect}(l_i) \cos\theta_{l_i}}{p(v, l_i)}\f]
\f$p(v, l_i)\f$ depends on \f$v\f$ and implicitly on \f$r\f$ in order to be completely general.
Optimization strategies use different samples distributions for different view direction orientations and roughness values.
Anyway even with all optimization techniques this algorithm continues to require too much calculations.
Good visual results require noticeable number of samples and using this approach for every point in real time rendering becomes unrealistic.
The way to avoid these enormous calculations is doing them beforehand somehow.
The first trick on the way to this is split the sum separating environment light component:
\f[L_{indirect}^s \approx \frac{1}{N} \sum_{i=1}^N \frac{f_s(v, l_i) L_i^{indirect}(l_i) \cos\theta_{l_i}}{p(v, l_i)} \approx \left( \frac{1}{N} \sum_{i=1}^N L_i^{indirect}(l_i) \right) \left( \frac{1}{N} \sum_{i=1}^N \frac{f_s(v, l_i) \cos\theta_{l_i}}{p(v, l_i)} \right)\f]
Where the second brackets represent approximation of integral so that the expression can be rewritten as:
\f[L_{indirect}^s \approx \frac{1}{N} \sum_{i=1}^N \frac{f_s(v, l_i) L_i^{indirect}(l_i) \cos\theta_{l_i}}{p(v, l_i)} \approx \left( \frac{1}{N} \sum_{i=1}^N L_i^{indirect}(l_i) \right) \int\limits_H f_s(v, l) \cos\theta_l\, \mathrm{d}l\f]
This integral is exact \f$L_{indirect}^s\f$ in condition when \f$L_i^{indirect}(l) = 1\f$ what just means white uniform environment.
The sum before it is kind of averaged environment illumination.
The main accomplishment after all this manipulations is possibility to calculate light and BRDF components separately.
The sum with \f$L_i^{indirect}(l_i)\f$ can be computed beforehand for every normal direction and stored to image called specular map but with some valuable details.
The problem is that \f$l_i\f$ samples must be generated according to \f$p(v, l_i)\f$ distribution depended on \f$v\f$ and \f$r\f$ as was mentioned earlier.
Variation of normal is not enough in that case and these variables are needed to be considered too.
The ways to resolve it are topic of one of the following chapters and now understanding the fact that at least this part can be precomputed before rendering is enough for now.
And it is important not to miss out that there is no more BRDF influence in this sum and only \f$p(v, l)\f$ can affect in this case.
That is why it is so important to strict to PDF during samples generation and that is why \f$p(v, l)\f$ must be correlated with BRDF somehow in this approximation approach with splitting.
For example completely mirroring materials with \f$r = 0\f$ will not be looked as expected if just uniform distribution is used
because such surfaces have only one possible direction from which light can be reflected along view direction in compare with \f$N\f$ absolutely scattered in case of uniform or many other distributions.
The rest part also can be saved to image. Lets unroll its expression:
\f[\int\limits_H f_s(v, l) \cos\theta_l\, \mathrm{d}l = \int\limits_H \frac{DGF}{4\cos\theta_v \cos\theta_l} \cos\theta_l\, \mathrm{d}l\f]
This integral is not actually a scalar.
That is RGB value due to only \f$F\f$ factor and even more only to \f$F_0\f$.
In order to simplify future computations \f$F_0\f$ is needed to be moved out of integral.
Substitution of Schlick's approximation helps to achieve it:
\f[F = F_0+(1-F_0)(1-\cos\theta_{vh})^5 = F_0(1-(1-\cos\theta_{vh})^5) + (1-\cos\theta_{vh})^5\f]
\f[\int\limits_H \frac{DGF}{\cos\theta_v \cos\theta_l} \cos\theta_l\, \mathrm{d}l = F_0 \int\limits_H \frac{DG}{4\cos\theta_v \cos\theta_l} (1-(1-\cos\theta_{vh})^5) \cos\theta_l\, \mathrm{d}l + \int\limits_H \frac{DG}{4\cos\theta_v \cos\theta_l} (1-\cos\theta_{vh})^5 \cos\theta_l\, \mathrm{d}l\f]
This form may not look easier, but it has several advantages.
The first one is independence from globally defined \f$L_i^{indirect}(l)\f$, so that normal orientation does not matter and can be set in any handful way for calculations (Z axis for example).
The second one results from isotropic illumination system allowing \f$\phi\f$ component of view vector to be set arbitrarily (0 for example) and \f$\cos\theta_v\f$ will be enough to define view direction.
And the third one is scalar nature of integrals so that only two precomputed numbers are needed to find BRDF part of \f$L_{indirect}^s\f$.
Considering dependency of these integrals from \f$\cos\theta_v\f$ and \f$r\f$ both of it can be precomputed and stored to 2D look-up image variating these two parameters in range \f$[0, 1]\f$ with two channels consisting of scale and bias for \f$F_0\f$.
Current result for \f$L_{indirect}^s\f$ is computing it using 2D image for BRDF part and omnidirectional image for environment illumination.
There were a lot of words about Monte-Carlo optimizations techniques and about PDF choice which is important not only in terms of numeric integration but in terms of visual results correctness.
It's time to talk about that.
# Importance sampling
Current goal is to speed up Monte-Carlo integration of Cook-Torrance like integrals with following expression:
\f[\int\limits_H \frac{DG}{4\cos\theta_v \cos\theta_l} g(v, l) \cos\theta_l\, \mathrm{d}l\f]
Where \f$g(v, l)\f$ is just arbitrary function representing Fresnel's factor itself or its components.
In order to increase convergence the samples with larger contribution (or in other words with larger function's values) have to appear more frequently than others proportionally to its contribution.
So that less significant summand with less influence to result will be considered rarely and in opposite way parts brining noticeable changes to the sum will be taken often.
That is the main idea of **importance sampling technique**.
\f$p(l)\f$ has to represent significance of sample in terms of integrated function via probability somehow.
And it will be like that if PDF is already part of original function because in that case probability density directly affects to contribution forming.
Separating this distribution component is one possible and effective way to realize importance sampling strategy.
In integral presented above PDF part already exists and that is \f$D\f$ component.
But it is distribution of micro faces normals or ideally reflection direction or \f$h\f$ in other word and not light directions distribution which is needed in fact.
Anyway that is good starting point and lets generate \f$h\f$ vectors first.
\f$D\f$ has the following expression:
\f[D=\frac{\alpha^2}{\pi(\cos^2\theta_h(\alpha^2-1) + 1)^2}\f]
Frankly speaking \f$D(h)\f$ is called normal distribution but cannot be directly used as hemisphere distribution.
Originally it is statistical factor used to define total area of micro faces \f$\mathrm{d}A_h\f$
whose normals lie withing given infinitesimal solid angle \f$\mathrm{d}h\f$ centered on \f$h\f$ direction using the original small enough area of macro surface \f$\mathrm{d}A\f$:
\f[dA_h = D(h)\,\mathrm{d}h\, \mathrm{d}A\f]
First of all this factor must be positive:
\f[D(h) \geq 0\f]
But the total area of micro faces landscape is at least equal to origin surface but even bigger in general:
\f[1 \leq \int\limits_H D(h)\, \mathrm{d}h\f]
This trait does not allow to use \f$D\f$ as hemisphere distribution.
But it can be fixed with following feature:
\f[\forall v\, \int\limits_H D(h)(v \cdot h)\, \mathrm{d}h = (v \cdot n)\f]
Which means that total area of micro faces projected to any direction must be the same as projected area of origin macro surface.
It is pretty tricky trait in \f$D\f$ definition but it leads to interesting results in condition when \f$v = n\f$:
\f[\int\limits_H D(h)\cos\theta_h\, \mathrm{d}h = 1\f]
So that \f$\cos\theta_h\f$ coefficient normalizes normal distribution in terms of hemisphere and allows to use it as distribution.
Finally PDF of half vectors can be wrote:
\f[p(\theta_h, \phi_h) = D\cos\theta_h\sin\theta_h = \frac{\alpha^2 \cos\theta_h\sin\theta_h}{\pi(\cos^2\theta_h(\alpha^2-1) + 1)^2}\f]
\f$\sin\theta_h\f$ results from spherical coordinate system transfer which was described in Monte-Carlo integration chapter.
Lets strict to samples generation procedure and find partial probability densities:
\f[p(\phi_h) = \int\limits_0^\frac{\pi}{2} p(\theta_h, \phi_h)\, \mathrm{d}\theta_h = \int\limits_0^\frac{\pi}{2} \frac{\alpha^2 \cos\theta_h\sin\theta_h}{\pi(\cos^2\theta_h(\alpha^2-1) + 1)^2}\, \mathrm{d}\theta = \frac{1}{2\pi}\f]
\f[p(\theta_h) = \int\limits_0^{2\pi} p(\theta_h, \phi_h)\, \mathrm{d}\phi_h = \int\limits_0^{2\pi} \frac{\alpha^2 \cos\theta_h\sin\theta_h}{\pi(\cos^2\theta_h(\alpha^2-1) + 1)^2}\, \mathrm{d}\phi = \frac{2 \alpha^2 \cos\theta_h\sin\theta_h}{(\cos^2\theta_h(\alpha^2-1) + 1)^2}\f]
\f$p(\phi_h)\f$ is unnecessary to be calculated analytically.
The fact of independency from \f$\phi\f$ is enough to figure out that this coordinate is uniformly distributed.
Anyway the \f$F(\theta_h)\f$ is next step:
\f[F(\theta_h) = \int\limits_0^{\theta_h} \frac{2 \alpha^2 \cos\theta'_h\sin\theta'_h}{(\cos^2\theta'_h(\alpha^2-1) + 1)^2}\, \mathrm{d}\theta'_h = \int\limits_{\theta_h}^0 \frac{2 \alpha^2}{(\cos^2\theta'_h(\alpha^2-1) + 1)^2}\, \mathrm{d}(\cos^2\theta'_h) = \frac{\alpha^2}{\alpha^2-1}\int\limits_0^{\theta_h} \mathrm{d}\frac{1}{\cos^2\theta'_h(\alpha^2-1)+1} =\f]
\f[ = \frac{\alpha^2}{\alpha^2-1} \left( \frac{1}{\cos^2\theta_h(\alpha^2-1) + 1} - \frac{1}{\alpha^2} \right) = \frac{\alpha^2}{\cos^2\theta_h(\alpha^2-1)^2+(\alpha^2-1)} - \frac{1}{\alpha^2-1}\f]
In order to apply inverse transform sampling the \f$F^{-1}(u)\f$ is needed to be found:
\f[F^{-1}(u) = \theta_h = \arccos\sqrt{\frac{1-u}{u(\alpha^2-1)+1}}\f]
So that there is no more obstacles to generate \f$h\f$.
But the main goal was \f$l\f$ direction.
In order to get it the view vector \f$v\f$ has to be reflected related to already found \f$h\f$:
\f[l = 2(v \cdot h)h - v\f]
That is practical side of light direction generation.
But the theoretical one is needed to be resolved to calculate sum.
It is time to find \f$p(l)\f$ using known \f$p(h)\f$.
First of all the fact that \f$l\f$ is just transformed \f$h\f$ is needed to be understood.
In that way the light direction's PDF has following expression:
\f[p(l) = p(h)|J_T|\f]
Where \f$|J_T|\f$ is Jacobian of reflection transformation.
Lets find it.
Right now \f$n\f$ is axis from which \f$\theta\f$ spherical coordinate is encountered.
The first step is setting \f$v\f$ as starting point of \f$\theta\f$ instead of \f$n\f$.
This is linear transform so that \f$|J_T| = 1\f$.
Next step is transfer to spherical coordinate with \f$|J_T| = \sin\theta_{vh}\f$.
Due to previous step \f$\theta_{vh}\f$ is used instead of \f$\theta_h\f$.
In this coordinate system reflecting of \f$v\f$ relative to \f$h\f$ is just doubling \f$\theta_{vh}\f$ and Jacobian of it is equal to \f$\frac{1}{2}\f$.
In series of transform the Jacobians are multiplied so that currently \f$|J_T| = \frac{1}{2}\sin\theta_{vh}\f$.
And the final step is inverse transform to Cartesian coordinate system with \f$|J_T| = (\sin\theta_{vl})^{-1} = (\sin2\theta_{vh})^{-1}\f$.
Combining this all together the following expression is obtained for reflection transform Jacobian:
\f[|J_T| = \frac{\sin\theta_{vh}}{2\sin2\theta_{vh}} = \frac{\sin\theta_{vh}}{4\sin\theta_{vh}\cos\theta_{vh}} = \frac{1}{4\cos\theta_{vh}}\f]
And finally \f$p(l)\f$ looks like:
\f[p(l) = p(h)|J_T| = \frac{D\cos\theta_h}{4\cos\theta_{vh}}\f]
Lets go back to the Monte-Carlo sum and insert found result to it:
\f[\int\limits_H \frac{DG}{4\cos\theta_v \cos\theta_l} g(v, l) \cos\theta_l\, \mathrm{d}l \approx \frac{1}{N} \sum_{i=1}^N \frac{DG\, g(v, l_i) \cos\theta_{l_i}}{4\cos\theta_v \cos\theta_{l_i}\, p(l_i)} = \frac{1}{N} \sum_{i=1}^N \frac{G\, g(v, l_i) \cos\theta_{l_i} \cos\theta_{vh_i}}{\cos\theta_v \cos\theta_{l_i} \cos\theta_{h_i}}\f]
Here \f$G\f$ component is recommended to be calculated with original \f$k=\frac{\alpha}{2} = \frac{r^2}{2}\f$ in order to get more plausible result.
Of course, all \f$\cos\f$ must be clamped to range \f$[0, 1]\f$ because integral is calculated on a hemisphere and all expressions are defined on it.
\f$\cos\theta_v \cos\theta_{l_i}\f$ in denominator can be reduced with exactly the same part in geometric attenuation factor in order to avoid additional zero division cases.
Summarizing importance sampling strategy described above the convergence of Monte-Carlo integration can be improved using special PDF correlated with integrated function.
In case of BRDF with normal distribution functions \f$D\f$ the PDF producing procedure is defined.
Practically half vector \f$h\f$ is generated first and \f$l\f$ is obtained from it by view vector \f$v\f$ reflecting.
Due to this transformation final form of probability density used in sum is quite different but also has defined algorithm of calculation.
For isotropic Cook-Torrance BRDF the \f$\cos\theta_v\f$ and roughness \f$r\f$ are enough to start generation so that all integrals of that kind can be precalculated in 2D look-up tables variating these two parameters.
The same samples generation procedure must be used in specular map baking described in next chapter.
# Specular map
The situation with BRDF part of \f$L_{indirect}^s\f$ is clear now and \f$L_i^{indirect}(l)\f$ sum is left to be discussed.
That was called **specular map** and has following form:
\f[\frac{1}{N}\sum_{i=1}^N L_i^{indirect}(l_i)\f]
As was mentioned this sum must be calculated for every normal direction using the same samples generation principles as in numeric integration computation.
This principles require two scalar parameters \f$\cos\theta_v\f$ and \f$r\f$ but now \f$\phi\f$ really matters.
So that in fact the specular map has to be saved in 3D table consisting omnidirectional textures.
That is a big expense of computational and memory resources.
A couple of tricks helps to reduce dimensions.
First of all the \f$\cos\theta_v\f$ and \f$\phi\f$ can be just excluded.
In that way \f$v\f$ is considered to be equal to \f$n\f$.
Of course this approach produces an error and affects the final result.
It can be fixed more or less by \f$\cos\theta_{l_i}\f$ weighting:
\f[\frac{1}{N} \sum_{i=1}^N L_i^{indirect}(l_i) \cos\theta_{l_i}\f]
It is not a complete solution but practice shows that it is enough to get plausible illumination with sacrificing of lengthy reflections at grazing angles which exist in fact if everything is honestly computed.
The problem is that for \f$v \neq n\f$ considering this sum to be defined related to \f$n\f$ became incorrect.
For example, for complete mirroring materials with \f$r = 0\f$ this sum must boil down to \f$L_i^{indirect}(v_r)\f$
but not to \f$L_i^{indirect}(n)\f$ where \f$v_r\f$ is just reflected \f$v\f$ or in other words \f$v_r = 2(v \cdot n)n - v\f$.
That it just mirroring reflection principle.
Assumption of \f$n = v\f$ also means that \f$n = v = v_r\f$.
In that way radiance map better to be considered as averaging of illumination coming from \f$v_r\f$.
So that it has become to be defined related to reflection direction which has to be calculated before map's fetching.
Anyway, there are just two dimensions in radiance look-up table remain.
The rest one with \f$r\f$ parameter cannot be reduced.
There is no other ways except just roughness variation but in order to simplify that computations can be done for several values and the rest ones lying between can be obtained from linear interpolation.
This is another source of visual artifacts but it also works good in practice and that is pretty common approach.
But it still requires noticeably amount of samples and that is for every pixel related to each \f$r\f$ value.
It can be appropriate for precomputations but still limits using dynamic environments in real time rendering or just even static environments but on weak devices such as mobile ones.
And there are several possible ways to improve radiance map baking performance.
The first one is using textures with smaller resolutions for larger roughnesses.
The point is that smaller \f$r\f$ values produce map saving more details from origin environment in opposite to larger ones representing lower frequency components and working as low pass filters in fact.
So less pixels in combination with linear interpolation is enough to store less detailed convolutions.
Moreover, this approach naturally works with textures levels of details in graphics API
so that every certain radiance map related to certain \f$r\f$ can be stored on its own mip level and be directly fetched with linear interpolation not only over one texture but over levels too.
As practice shows 6 levels are enough.
After reducing pixels count it is turn for samples number.
And again correlation with roughness can be noticed.
For example map for completely mirroring materials with \f$r = 0\f$ the same sample \f$l_i = v_r\f$ will be produced.
So that only one sample is enough in this case.
In opposite way directions for \f$r = 1\f$ will be scattered over almost whole hemisphere what requires as much samples as available.
The 'locality' of distribution is decreased during increasing roughness and it is possible to assume that samples number might to be proportional to this 'locality' keeping accuracy at the same level.
But how can 'locality' be interpreted in terms of probability distribution? One possible way is CDF meaning.
\f$F(\theta_h)\f$ has been already defined and by definition it shows the probability of random value \f$\theta_h\f$ to be less than argument of CDF.
In other words \f$F(\theta'_h) = u\f$ means that probability of \f$\theta_h\f$ to be in range of \f$[0, \theta'_h]\f$ is \f$u\f$.
The inverse task of range searching using given \f$u\f$ can be solved with help of \f$F^{-1}(u) = \theta'_h\f$.
If \f$u\f$ is close to 1 (exact 1 has no sense because in that case \f$\theta'_h = \max\theta_h = \frac{\pi}{2}\f$)
then \f$\theta'_h\f$ represents the range of the most probable or most frequently generated values and that can be interpreted as 'locality' of distribution.
After that if samples number of the worst case with \f$r = 1\f$ is set (\f$N(1) = \max N\f$) the other ones can be estimated using following formula:
\f[N(r) = N(1)\frac{\theta'_h(r)}{\frac{\pi}{2}} = N(1)\frac{2\theta'_h(r)}{\pi} = N(1)\frac{2F^{-1}(u)}{\pi} = N(1)\frac{2}{\pi}\arccos\sqrt{\frac{1-u}{u(\alpha^2-1)+1}}\f]
It is approximate expression representing only estimated general proportionality so that cases of \f$r = 0\f$ and \f$r = 1\f$ must be processed separately with \f$N(0) = 1\f$ and \f$N(1) = \max N\f$.
\f$u\f$ can be parameter of this optimization strategy controlling speed of samples reducing in order to balance performance and quality (\f$u = 1\f$ disables this optimization at all).
This pretty tricky technique allows reducing calculations for every pixels without sacrificing the quality.
In addition to optimizations mentioned before another one can be applied in order to help to reduce samples numbers as previous one.
Using less samples produces image noise due to discrete nature of Monte-Carlo approximation.
But it can be slightly smoothed using some prefiltration.
The idea is that for the directions with small PDF or in other words for rare directions the samples near of it is unlikely to be generated.
So that this direction represents the averaged illumination from relatively big area on hemisphere but approximate it by just a constant.
It wold be better to get from such direction already averaged over bigger area environment.
It can be achieved using mip levels of origin \f$L_i^{indirect}\f$ whose pixels of one level is exact 4 averaged pixels from previous one.
Also mip levels generation is build in most common graphic API so there are no problems with it.
But first of all the area covered by one sample is needed to be found.
And that can be done as:
\f[\Omega_s = \frac{1}{N\,p(l)} = \frac{4\cos\theta_{vh}}{ND\cos\theta_h}\f]
Circumstance of \f$v = v_r = n\f$ leads to \f$\cos\theta_{vh}\f$ and \f$\cos\theta_h\f$ reducing so expression becomes even simpler:
\f[\Omega_s =\frac{4}{ND}\f]
Of course all zero divisions must be avoided by clamping, for example.
After that the area covered by one pixel of environment map is calculated.
In case of a cube map it looks like:
\f[\Omega_p = \frac{4\pi}{6k^2}\f]
Where \f$k\f$ is size of one cube map side in pixels (sides are assumed to be quads).
Finally the mip level of origin environment map which is needed to be fetched for this certain sample is defined by following expression:
\f[lod = \frac{1}{2} \log_2\left(\frac{\Omega_s}{\Omega_p}\right)\f]
The mathematics connected with mip levels sizes lie behind it but this is out of scope of this paper.
In combination with previous optimization technique this approach allows \f$N(1)\f$ to be smaller keeping visual results good.
That is not all possible optimization tricks but at least these three significantly reduces compute efforts and brings radiance map calculation to weak devices or even to dynamic environments in real time but in reasonable limits.
In that way \f$L_{indirect}^s\f$ can be completely computed without any integral approximations.
Only 2D look-up table of BRDF part and mip mapped omnidirectional texture of irradiance map are needed.
The first one can be got even without any environment.
It was achieved using some rough approximations and assumptions but despite of that the visual result are still plausible and can be compared even with ray traced images.
In order to complete whole image based lighting the \f$L_{indirect}^d\f$ component is left to be discussed.
# Spherical harmonics
Lets go back to diffuse indirect illumination component represented by following formula:
\f[L_{indirect}^d = (1-m)\frac{c}{\pi}\int\limits_H (1-F)L_i^{indirect}(l)\cos\theta_l\, \mathrm{d}l\f]
Of course, Monte-Carlo algorithm can be applied directly and hemisphere integral can be precalculated for every normal direction
but dependence from \f$v\f$ in Fresnel's factor does not allow to do it efficiently (every \f$v\f$ direction is needed to be considered again).
In order to resolve it modified version of Schlick's approximation has been created:
\f[F \approx F_{ss}=F_0+(\max(1-r, F_0))(1-\cos\theta_v)^5\f]
It differs from origin one and loses accuracy a little bit but now there is no light direction inside
so that it can be considered as kind of screen space defined Fresnel's factor (\f$ss\f$ means exactly 'screen space') and can be removed from integral:
\f[L_{indirect}^d = (1-m)(1-F_{ss})\frac{c}{\pi} \int\limits_H L_i^{indirect}(l) \cos\theta_l\, \mathrm{d}l\f]
The resulted expression without \f$(1-m)\f$ and \f$(1-F_{ss})\f$ parts is pretty known entity called **irradiance**.
It can be precalculated using \f$\cos\theta_l\f$ as PDF for importance sampling (actually it is only option in this case excluding uniform distribution).
But even with that samples will be scattered almost over whole hemisphere.
As was discussed in previous chapter this case requires significant amount of samples in order to average illumination with appropriate quality.
Poor accuracy resulted from lack of summand can be noticed especially on high frequency environments having a lot of contrasting details.
It worth to be mentioned that irradiance is used not only in BRDF.
Omnidirectional diffuse illumination captured for certain point or even for several points uniformly or hierarchically distributed is base of some baking global illumination techniques.
There it is called a **light probe**. So that other way to compute and store irradiance maps was found resolving many mentioned problems.
The Fourier's decomposition analogue for spherical function allows to achieve this.
That would be easy to explain concept directly on example.
So lets start from \f$L_i^{indirect}(l)\f$.
It is spherical function because directions are just points on sphere.
The decomposition looks like:
\f[L_i^{indirect}(l) = \sum_{i = 0}^\infty \sum_{j=-i}^i L_i^j y_i^j(l)\f]
Where \f$y_i^j(l)\f$ are spherical functions forming orthonormalized basis called spherical harmonics and \f$L_i^j\f$ is decompositions coefficients.
Orthonormality means that dot product of two basis elements is equal to 1 if this is the same functions and is equal to zero otherwise.
Dot product on a sphere is defined as integral of functions multiplication. In other words:
\f[\int\limits_S y_i^j(l)\, y_{i'}^{j'}(l)\, \mathrm{d}l = \begin{cases} 1 & \quad i,j = i',j' \\ 0 & \quad \mathrm{otherwise}\end{cases}\f]
Function basis with such traits is known and is described by following formulas:
\f[y_i^{j > 0}(\theta, \phi) = \sqrt{2}K_i^j\cos(j\phi)P_i^j(\cos\theta)\f]
\f[y_i^{j<0}(\theta, \phi) = \sqrt{2}K_i^j\sin(j\phi)P_i^{|j|}(\cos\theta)\f]
\f[y_i^0(\theta, \phi) = K_i^0P_i^0(\cos\theta)\f]
\f[K_i^j = \sqrt{\frac{(2i+1)(i-|j|)!}{4\pi(i+|j|)!}}\f]
\f[P_0^0(x) = 1\f]
\f[P_1^0(x) = x\f]
\f[P_i^i(x) = (-1)^i(2i-1)!!(1-x^2)^\frac{i}{2}\f]
\f[P_i^j(x) = \frac{(2i-1)xP_{i-1}^j(x) - (i + j - 1)P_{i-2}^j}{i - j}\f]
Here \f$K_i^j\f$ are normalization factors and \f$P_i^j\f$ are **Legendre's polynomials**.
Decomposition coefficients \f$L_i^j\f$ are dot product of origin function (\f$L_i^{indirect}(l)\f$ in current case) and corresponding basis element. It can be written down as:
\f[L_i^j = \int\limits_S L_i^{indirect}(l)\,y_i^j(l)\, \mathrm{d}l\f]
Fact that all calculation happen over a sphere but not over hemisphere right now is important not to be missed.
That was example of spherical function decomposition but not a solution for original task which looks like:
\f[\int\limits_H L_i^{indirect}(l) \cos\theta_l\, \mathrm{d}l\f]
First of all, lets transform this integral to be defined not over hemisphere but sphere:
\f[\int\limits_H L_i^{indirect}(l) \cos\theta_l\, \mathrm{d}l = \int\limits_S L_i^{indirect}(l)\overline{\cos}\theta_l\, \mathrm{d}l\f]
Where \f$\overline{\cos}\f$ is cosine clamped to zero which can be expressed as:
\f[\overline{\cos}\theta_l = \max(\cos\theta_l, 0)\f]
Resulted expression can be considered as convolution in terms of spherical functions where \f$L_i^{indirect}(l)\f$ is target and \f$\overline{\cos}\theta_l\f$ is core.
This integral may seem independent but in fact hemisphere is oriented related to \f$n\f$ therefore \f$\overline{\cos}\theta_l\f$ depends on it too and became a kind of 'oriented' version of cosine.
That is pretty tricky and explanation about meaning of convolution on sphere is out of scope of this paper.
Fact that this is convolution analogue related to \f$n\f$ is enough for now.
The goal of looking at integral from this angle is using of convolution's trait allowing to compute decomposition using just only coefficients of function and core.
\f$\overline{\cos}\theta_l\f$ is independent from \f$\phi_l\f$ and in case of such radial symmetric cores the resulting coefficients boil down to following formula:
\f[(L_i^{indirect}(l) \ast \overline{\cos}\theta_l)_i^j = \frac{1}{K_i^0}L_i^j\, c_i^0 = \sqrt{\frac{4\pi}{2i+1}}L_i^j\, c_i^0\f]
Where \f$c_i^0\f$ are spherical harmonics factors corresponding to \f$\overline{\cos}\theta\f$.
Therefore the final decomposition looks like:
\f[\int\limits_{H(n)} L_i^{indirect}(l) \cos\theta_l\, \mathrm{d}l = \int\limits_S L_i^{indirect}(l)\overline{\cos}\theta_l\, \mathrm{d}l = \sum_{i=0}^\infty \sum_{j = -i}^i \sqrt{\frac{4\pi}{2i+1}}L_i^j\, c_i^0\, y_i^j(n)\f]
\f$c_i^0\f$ is left to be found.
Due to independence from \f$\phi\f$ all \f$c_i^{j \neq 0} = 0\f$.
The rest ones are calculated by regular dot product with basis functions:
\f[c_i^0 = c_i = \int\limits_S y_i^0(l)\, \overline{\cos}\theta_l\, \mathrm{d}l = \int\limits_0^{2\pi} \mathrm{d}\phi \int\limits_0^\pi y_i^0(\theta, \phi)\, \overline{\cos}\theta \sin\theta\, \mathrm{d}\theta = \int\limits_0^{2\pi} \mathrm{d}\phi \int\limits_0^\frac{\pi}{2} y_i^0(\theta, \phi)\, \cos\theta\sin\theta\, \mathrm{d}\theta = \f]
\f[= 2\pi\int\limits_0^\frac{\pi}{2} y_i^0(\theta, \phi)\, \cos\theta\sin\theta\, \mathrm{d}\theta = 2\pi K_i^0\int\limits_0^\frac{\pi}{2} P_i^0(\cos\theta)\, \cos\theta\sin\theta\, \mathrm{d}\theta\f]
\f$\sin\theta\f$ appears due to transfer from integral over sphere to double integral where \f$\mathrm{d}l = \sin\theta\, \mathrm{d}\theta\, \mathrm{d}\phi\f$.
There is an analytical solution for this expressions:
\f[c_1 = \sqrt{\frac{\pi}{3}}\f]
\f[c_{odd} = 0 \quad c_{even} = 2\pi\sqrt{\frac{2i+1}{4\pi}}\frac{(-1)^{\frac{i}{2}-1}}{(i+2)(i-1)}\frac{i!}{2^i\left(\frac{i!}{2}\right)^2}\f]
Starting from about the third \f$c_i\f$ the coefficients become less and less valuable so that only couple of them is enough in order to approximate \f$\overline{\cos}\theta\f$ with appropriate accuracy.
The same principle is true for convolution too because its coefficients are multiplied by \f$c_i\f$.
So there is no need to use more than even three bands (\f$i = 0, 1, 2\f$) of basis functions.
Lets write down them all in Cartesian coordinate system:
\f[y_0^0 = \frac{1}{2}\sqrt{\frac{1}{\pi}} = Y_0^0\f]
\f[y_1^{-1} = -\frac{1}{2}\sqrt{\frac{3}{\pi}}y = Y_1^{-1}y\f]
\f[y_1^0 = \frac{1}{2}\sqrt{\frac{3}{\pi}}z = Y_1^0z\f]
\f[y_1^1 = -\frac{1}{2}\sqrt{\frac{3}{\pi}}x = Y_1^1x\f]
\f[y_2^{-2} = \frac{1}{2}\sqrt{\frac{15}{\pi}}xy = Y_2^{-2}xy\f]
\f[y_2^{-1} = -\frac{1}{2}\sqrt{\frac{15}{\pi}}yz = Y_2^{-1}yz\f]
\f[y_2^0 = \frac{1}{4}\sqrt{\frac{5}{\pi}}(3z^2-1) = Y_2^0(3z^2-1)\f]
\f[y_2^1 = -\frac{1}{2}\sqrt{\frac{15}{\pi}}xz = Y_2^1xz\f]
\f[y_2^2 = \frac{1}{4}\sqrt{\frac{15}{\pi}}(x^2-y^2) = Y_2^2(x^2-y^2)\f]
All \f$Y_i^j\f$ are just constants so that it can be moved from integral during calculations and can be taken from precomputed table.
Other constants related to \f$c_i\f$ can be united and also be calculated beforehand:
\f[\hat{c}_i = \frac{1}{K_i^0}\, c_i = \sqrt{\frac{4\pi}{2i+1}}\, c_i\f]
Finally expression of irradiance map approximation can be defined:
\f[\int\limits_{H(n)} L_i^{indirect}(l) \cos\theta_l\, \mathrm{d}l \approx \sum_{i=0}^2 \sum_{j=-i}^i L_i^j\, \hat{c}_i\, y_i^j(n)\f]
Where \f$\hat{c}_i\f$ is precalculated constants \f$y_i^j(n)\f$ are pretty easy functions and only \f$L_i^j\f$ are needed to be precomputed.
Of course \f$L_i^j\f$ are integrals over even whole sphere but now there is only nine of it instead of one for every pixel of omnidirectional image.
Moreover, texture is not needed at all in that case and only 9 colors representing \f$L_i^j\f$ have to be saved.
The Monte-Carlo algorithm can be applied with just uniform samples distribution without importance sampling at all.
\f$Y_i^j\f$ are used twice: in \f$L_i^j\f$ calculations and in sum after that.
So there is sense to store only squares of it.
All tables with constants presented below:
| |
|-|
| \f$(Y_0^0)^2 \approx (0.282095)^2\f$ |
| \f$(Y_1^{-1})^2 = (Y_1^0)^2 = (Y_1^1)^2 \approx (0.488603)^2\f$ |
| \f$(Y_2^{-2})^2 = (Y_2^{-1})^2 = (Y_2^1)^2 \approx (1.092548)^2\f$ |
| \f$(Y_2^0)^2 \approx (0.315392)^2\f$ |
| \f$(Y_2^2)^2 \approx (0.546274)^2\f$ |
| | |
|-|-|
| \f$\hat{c}_0\f$ | \f$3.141593\f$ |
| \f$\hat{c}_1\f$ | \f$2.094395\f$ |
| \f$\hat{c}_2\f$ | \f$0.785398\f$ |
Summarizing all mathematics above spherical harmonics decomposition boils down irradiance map to only 9 values which is needed to be precalculated as integrals.
As practice shows this is very good approximation of diffuse indirect illumination component.
# Transparent materials
TODO
# Low discrepancy sequence
TODO

View File

@@ -210,7 +210,7 @@ for which OCCT is certified to work.
| OS | Compiler |
| --------- | ----------- |
| Windows | Microsoft Visual Studio: 2008 SP1, 2010 SP1, 2012 Update 4, 2013 Update 5, 2015 Update 3, 2017 <sup>1</sup>, 2019 <br> GCC 4.3+ (Mingw-w64)|
| Windows | Microsoft Visual Studio: 2008 SP1, 2010 SP1, 2012 Update 4, 2013 Update 5, 2015 Update 3, 2017 <sup>1</sup>, 2019 <br>, LLVM (ClangCL), GCC 4.3+ (Mingw-w64)|
| Linux | GNU gcc 4.3+ <br> LLVM CLang 3.6+ |
| OS X / macOS | XCode 6 or newer |
| Android | NDK r10, GNU gcc 4.8 or newer |

View File

@@ -26,7 +26,7 @@ This modular structure is illustrated in the diagram below.
* @ref OCCT_TOVW_SECTION_2 "Foundation Classes" module underlies all other OCCT classes;
* @ref OCCT_TOVW_SECTION_3 "Modeling Data" module supplies data structures to represent 2D and 3D geometric primitives and their compositions into CAD models;
* @ref OCCT_TOVW_SECTION_4 "Modeling Algorithms" module contains a vast range of geometrical and topological algorithms;
* @ref OCCT_TOVW_SECTION_4a "Mesh" module implements tessellated representations of objects;
* @ref OCCT_TOVW_SECTION_4a "Mesh" toolkit from "Modeling Algorithms" module implements tessellated representations of objects;
* @ref OCCT_TOVW_SECTION_5 "Visualization" module provides complex mechanisms for graphical data representation;
* @ref OCCT_TOVW_SECTION_6 "Data Exchange" module inter-operates with popular data formats and relies on @ref OCCT_TOVW_SECTION_6a "Shape Healing" to improve compatibility between CAD software of different vendors;
* @ref OCCT_TOVW_SECTION_7 "Application Framework" module offers ready-to-use solutions for handling application-specific data (user attributes) and commonly used functionality (save/restore, undo/redo, copy/paste, tracking CAD modifications, etc).
@@ -38,21 +38,20 @@ In addition, @ref OCCT_TOVW_SECTION_8 "Open CASCADE Test Harness", also called D
**Foundation Classes** module contains data structures and services used by higher-level Open CASCADE Technology classes:
* Primitive types, such as Boolean, Character, Integer or Real;
* String classes that handle ASCII and Unicode strings;
* String classes that handle Unicode strings;
* Collection classes that handle statically or dynamically sized aggregates of data, such as arrays, lists, queues, sets and hash tables (data maps).
* Classes providing commonly used numerical algorithms and basic linear algebra calculations (addition, multiplication, transposition of vectors and matrices, solving linear systems etc).
* Fundamental types representing physical quantities and supporting date and time information;
* Fundamental types like color, date and time information;
* Primitive geometry types providing implementation of basic geometric and algebraic entities that define and manipulate elementary data structures.
* Exception classes that describe situations, when the normal execution of program is abandoned;
This module also provides a variety of general-purpose services, such as:
* Safe handling of dynamically created objects, ensuring automatic deletion of unreferenced objects (smart pointers);
* Configurable optimized memory manager increasing the performance of applications that intensively use dynamically created objects;
* Standard and specialized memory allocators;
* Extended run-time type information (RTTI) mechanism maintaining a full type hierarchy and providing means to iterate over it;
* Encapsulation of C++ streams;
* Automated management of heap memory by means of specific allocators;
* Basic interpreter of expressions facilitating the creation of customized scripting tools, generic definition of expressions, etc.;
* Tools for dealing with configuration resource files and customizable message files facilitating multi-language support in applications;
* Tools for dealing with configuration resource files and customizable message files facilitating multi-language support in applications;
* Progress indication and user break interfaces, giving a possibility even for low-level algorithms to communicate with the user in a universal and convenient way;
* and many others...
@@ -62,28 +61,33 @@ See also: our <a href="https://www.opencascade.com/content/tutorial-learning">E-
@section OCCT_TOVW_SECTION_3 Modeling Data
**Modeling Data** supplies data structures to implement boundary representation (BRep) of objects in 3D. In BRep the shape is represented as an aggregation of geometry within topology. The geometry is understood as a mathematical description of a shape, e.g. as curves and surfaces (simple or canonical, Bezier, NURBS, etc). The topology is a data structure binding geometrical objects together.
**Modeling Data** supplies data structures to implement boundary representation (BRep) of objects in 3D.
In BRep the shape is represented as an aggregation of geometry within topology.
The geometry is understood as a mathematical description of a shape, e.g. as curves and surfaces (simple or canonical, Bezier, NURBS, etc).
The topology is a data structure binding geometrical objects together.
Geometry types and utilities provide geometric data structures and services for:
* Description of points, vectors, curves and surfaces:
* their positioning in 3D space using axis or coordinate systems, and
* their geometric transformation, by applying translations, rotations, symmetries, scaling transformations and combinations thereof.
* their positioning in 3D space using axis or coordinate systems, and
* their geometric transformation, by applying translations, rotations, symmetries, scaling transformations and combinations thereof.
* Creation of parametric curves and surfaces by interpolation and approximation;
* Algorithms of direct construction;
* Conversion of curves and surfaces to NURBS form;
* Computation of point coordinates on 2D and 3D curves;
* Calculation of extrema between geometric objects.
Topology defines relationships between simple geometric entities. A shape, which is a basic topological entity, can be divided into components (sub-shapes):
Topology defines relationships between simple geometric entities.
A shape, which is a basic topological entity, can be divided into components (sub-shapes):
* Vertex -- a zero-dimensional shape corresponding to a point;
* Edge -- a shape corresponding to a curve and bounded by a vertex at each extremity;
* Wire -- a sequence of edges connected by their vertices;
* Face -- a part of a plane (in 2D) or a surface (in 3D) bounded by wires;
* Shell -- a collection of faces connected by edges of their wire boundaries;
* Solid -- a finite closed part of 3D space bounded by shells;
* Compound solid -- a collection of solids connected by faces of their shell boundaries.
* Composite solid -- a collection of solids connected by faces of their shell boundaries;
* Compound -- a collection of shapes of arbitrary type.
Complex shapes can be defined as assemblies of simpler entities.
Complex shapes can be defined as assemblies (compounds) of simpler entities.
See the details in @ref occt_user_guides__modeling_data "Modeling Data User's Guide"
@@ -94,56 +98,56 @@ See also: our <a href="https://www.opencascade.com/content/tutorial-learning">E-
@section OCCT_TOVW_SECTION_4 Modeling Algorithms
**Modeling Algorithms** module groups a wide range of topological and geometric algorithms used in geometric modeling. Basically, there are two groups of algorithms in Open CASCADE Technology:
* High-level modeling routines used in the real design;
* Low-level mathematical support functions used as a groundwork for the modeling API;
**Modeling Algorithms** module groups a wide range of topological and geometric algorithms used in geometric modeling.
Basically, there are two groups of algorithms in Open CASCADE Technology:
* High-level modeling routines used in the real design;
* Low-level mathematical support functions used as a groundwork for the modeling API.
* Low-level geometric tools provide the algorithms, which:
* Calculate the intersection of two curves, surfaces, or a curve and a surface;
* Project points onto 2D and 3D curves, points onto surfaces and 3D curves onto surfaces;
* Construct lines and circles from constraints;
* Construct free-form curves and surfaces from constraints (interpolation, approximation, skinning, gap filling, etc);
Low-level *geometric tools* provide the algorithms, which:
* Calculate the intersection of two curves, surfaces, or a curve and a surface;
* Project points onto 2D and 3D curves, points onto surfaces and 3D curves onto surfaces;
* Construct lines and circles from constraints;
* Construct free-form curves and surfaces from constraints (interpolation, approximation, skinning, gap filling, etc).
* Low-level topological tools provide the algorithms, which:
* Tessellate shapes;
* Check correct definition of shapes;
* Determine the local and global properties of shapes (derivatives, mass-inertia properties, etc);
* Perform affine transformations;
* Find planes in which edges are located;
* Convert shapes to NURBS geometry;
* Sew connected topologies (shells and wires) from separate topological elements (faces and edges).
Low-level *topological tools* provide the algorithms, which:
* Tessellate shapes;
* Check correct definition of shapes;
* Determine the local and global properties of shapes (derivatives, mass-inertia properties, etc);
* Perform affine transformations;
* Find planes in which edges are located;
* Convert shapes to NURBS geometry;
* Sew connected topologies (shells and wires) from separate topological elements (faces and edges).
Top-level API provides the following functionality:
* Construction of Primitives:
* Boxes;
* Prisms;
* Cylinders;
* Cones;
* Spheres;
* Toruses.
* Kinematic Modeling:
* Prisms -- linear sweeps;
* Revolutions -- rotational sweeps;
* Pipes -- general-form sweeps;
* Lofting.
* Construction of Primitives:
* Boxes;
* Prisms;
* Cylinders;
* Cones;
* Spheres;
* Toruses.
* Kinematic Modeling:
* Prisms -- linear sweeps;
* Revolutions -- rotational sweeps;
* Pipes -- general-form sweeps;
* Lofting.
@figure{/technical_overview/images/0001.png "Shapes containing pipes with variable radius produced by sweeping"}
* Boolean Operations, which allow creating new shapes from the combinations of source shapes. For two shapes *S1* and *S2*:
* *Common* contains all points that are in *S1* and *S2*;
* *Fuse* contains all points that are in *S1* or *S2*;
* *Cut* contains all points in that are in *S1* and not in *S2*
* Boolean Operations, which allow creating new shapes from the combinations of source shapes. For two shapes *S1* and *S2*:
* *Common* contains all points that are in *S1* and *S2*;
* *Fuse* contains all points that are in *S1* or *S2*;
* *Cut* contains all points in that are in *S1* and not in *S2*.
See @ref occt_user_guides__boolean_operations "Boolean Operations" User's Guide for detailed documentation.
* Algorithms for local modifications such as:
* Hollowing;
* Shelling;
* Creation of tapered shapes using draft angles;
* Algorithms to make fillets and chamfers on shape edges, including those with variable radius (chord).
* Algorithms for local modifications such as:
* Hollowing;
* Shelling;
* Creation of tapered shapes using draft angles;
* Algorithms to make fillets and chamfers on shape edges, including those with variable radius (chord).
* Algorithms for creation of mechanical features, i.e. depressions, protrusions, ribs and grooves or slots along planar or revolution surfaces.
* Algorithms for creation of mechanical features, i.e. depressions, protrusions, ribs and grooves or slots along planar or revolution surfaces.
@figure{/technical_overview/images/0004.png}
@@ -151,17 +155,13 @@ See the details in @ref occt_user_guides__modeling_algos "Modeling Algorithms Us
See also: our <a href="https://www.opencascade.com/content/tutorial-learning">E-learning & Training</a> offerings.
@section OCCT_TOVW_SECTION_4a Mesh
@subsection OCCT_TOVW_SECTION_4a Mesh
**Mesh** module provides the functionality to work with tessellated representations of objects in form of triangular facets. This module contains:
**Mesh** toolkit provides the functionality to work with tessellated representations of objects in form of triangular facets. This toolkit contains:
- data structures to store surface mesh data associated to shapes and basic algorithms to handle them;
- data structures and algorithms to a build triangular surface mesh from *BRep* objects (shapes);
- data structures and algorithms to build triangular surface mesh from *BRep* objects (shapes);
- tools for displaying meshes with associated pre- and post-processor data (scalars or vectors).
Open CASCADE Technology includes two mesh converters:
- VRML converter translates Open CASCADE shapes to VRML 1.0 files (Virtual Reality Modeling Language). Two representation modes are possible: shaded, which presents shapes as sets of triangles computed by the mesh algorithm, or wireframe, which presents shapes as sets of curves.
- STL converter translates Open CASCADE shapes to STL files. STL (STtereoLithography) format is widely used for rapid prototyping (3D printing).
Open CASCADE SAS also offers Advanced Mesh Products:
- <a href="https://www.opencascade.com/content/mesh-framework">Open CASCADE Mesh Framework (OMF)</a>
- <a href="https://www.opencascade.com/content/express-mesh">Express Mesh</a>
@@ -170,39 +170,41 @@ Open CASCADE SAS also offers Advanced Mesh Products:
@section OCCT_TOVW_SECTION_5 Visualization
**Visualization** module provides ready-to-use algorithms to create graphic presentations from various objects: shapes, meshes, etc.
In Open CASCADE Technology visualization is based on the separation of CAD data and its graphical presentation. The presentations can be customized to take the specificity of your application into account.
**Visualization** module provides ready-to-use algorithms to create graphic presentations from various objects: shapes, meshes, etc.
In Open CASCADE Technology visualization is based on the separation of CAD data and its graphical presentation.
The module also supports a fast and powerful interactive selection mechanism.
The view facilities provided by OCCT range from low-level tools working with basic geometry and topology (such as NURBS visualization with control points and nodes, rendering of isolines to estimate speed and quality of parameterization, or rendering of a parametric profile of edges) to high-level tools for real time quality rendering of models using ray tracing: shades, reflections, transparency, anti-aliasing, etc.
Visualization module relies on the following key toolkits:
- *TKV3d* toolkit defines a high-level API called (Application Interactive Services* (AIS) for working with interactive objects.
- *TKService* toolkit defines a low-level API for managing and creating presentations from primitive arrays.
This toolkit defines an abstraction layer for defining an arbitrary graphic driver responsible for actual rendering.
- *TKOpenGl* toolkit implements the graphic driver using OpenGL and OpenGL ES libraries.
Here are just a few examples:
While low-level API operates with primitive arrays (triangles, lines, points), the higher level includes services for building presentations for B-Rep shapes (shaded and wireframe).
A comprehensive list of standard interactive objects includes topological shape, mesh presentation, various dimensions, manipulators and others.
It provides a solid basis for rapid application development, while flexible and extensible API allows development of highly customized application-specific presentations.
* Camera-driven view projection and orientation. It is possible to choose between perspective, orthographic and stereographic projection.
* Real-time ray tracing technique using recursive Whitted's algorithm and Bounded Volume Hierarchy effective optimization structure.
@figure{/technical_overview/images/0002.png, "Real time visualization by ray tracing method"}
* Support of GLSL shaders. The shader management is fully automatic, like with any other OpenGL resource.
Here are a few examples of OCCT Visualization features:
* Camera-driven view projection and orientation.
Perspective, orthographic and stereographic projections are supported.
* Support of Common (diffuse/ambient/specular) and PBR metallic-roughness material models.
* Possibility to flexibly adjust appearance of dimensions in a 3D view.
The 3D text object represents a given text string as a true 3D object in the model space.
* Definition of clipping planes through the plane equation coefficients.
Ability to define visual attributes for cross-section at the level or individual clipping planes.
In the image below different parts of the rocket are clipped with different planes and hatched.
@figure{/technical_overview/images/0008.png, "Display of shape cross-section and dimensions"}
* Support of built-in and application-specific GLSL shaders.
@figure{/technical_overview/images/0013.png, "Fragment shader implementing custom clipping surface"}
* Support of standard and custom materials, defined by transparency, diffuse, ambient and specular reflection and refraction index. The latter allows implementing transparent materials, such as glass, diamond and water.
@figure{/technical_overview/images/0012.png, "Simulation of a glass cover"}
* Optimization of rendering performance through the algorithms of:
* View frustum culling, which skips the presentation outside camera at the rendering stage and
* Back face culling, which reduces the rendered number of triangles and eliminates artifacts at shape boundaries.
* Definition of clipping planes through the plane equation coefficients. Ability to define visual attributes for cross-section at the level or individual clipping planes. In the image below different parts of the rocket are clipped with different planes and hatched.
* Possibility to flexibly adjust appearance of dimensions in a 3D view. The 3D text object represents a given text string as a true 3D object in the model space.
@figure{/technical_overview/images/0008.png, "Display of shape cross-section and dimensions"}
* View frustum culling, which skips the presentation outside camera at the rendering stage;
* Back face culling, which reduces the rendered number of triangles and eliminates artifacts at shape boundaries.
* Real-time ray tracing technique using recursive Whitted's algorithm and Bounded Volume Hierarchy effective optimization structure.
@figure{/technical_overview/images/0002.png, "Real time visualization by ray tracing method"}
@figure{/technical_overview/images/0012.png, "Simulation of a glass cover"}
For more details, see @ref occt_user_guides__visualization "Visualization User's Guide".
@@ -210,21 +212,28 @@ The visualization of OCCT topological shapes by means of VTK library provided by
See also: our <a href="https://www.opencascade.com/content/tutorial-learning">E-learning & Training</a> offerings.
@section OCCT_TOVW_SECTION_6 Data Exchange
**Data Exchange** allows developing OCCT-based applications that can interact with other CAD systems by writing and reading CAD models to and from external data. The exchanges run smoothly regardless of the quality of external data or requirements to its internal representation, for example, to the data types, accepted geometric inaccuracies, etc.
**Data Exchange** allows developing OCCT-based applications that can interact with other CAD systems by writing and reading CAD models to and from external data.
@figure{/technical_overview/images/0014.png,"Shape imported from STEP"}
**Data Exchange** is organized in a modular way as a set of interfaces that comply with various CAD formats: IGES, STEP, STL, VRML, etc. The interfaces allow software based on OCCT to exchange data with various CAD/PDM software packages, maintaining a good level of interoperability.
**Data Exchange** is organized in a modular way as a set of interfaces that comply with various CAD formats: IGES, STEP, STL, VRML, etc.
The interfaces allow software based on OCCT to exchange data with various CAD/PDM software packages, maintaining a good level of interoperability.
This module handles various problems of interoperability between CAD systems, caused by differences in model validity criteria and requirements to internal representation.
* **Standardized Data Exchange** interfaces allow querying and examining the input file, converting its contents to a CAD model and running validity checks on a fully translated shape. The following formats are currently supported.
* @ref occt_user_guides__step "STEP" (AP203 : Mechanical Design, this covers General 3D CAD; AP214: Automotive Design)
* @ref occt_user_guides__iges "IGES" (up to 5.3)
* glTF, OBJ, VRML and STL meshes.
* **Standardized Data Exchange** interfaces allow querying and examining the input file, converting its contents to a CAD model and running validity checks on a fully translated shape.
The following formats are currently supported:
* @ref occt_user_guides__step "STEP" (AP203: Mechanical Design, this covers General 3D CAD; AP214: Automotive Design; AP242).
* @ref occt_user_guides__iges "IGES" (up to 5.3).
* **glTF** 2.0 reader and writer.
* **OBJ** mesh file reader.
* **VRML** converter translates Open CASCADE shapes to VRML 1.0 files (Virtual Reality Modeling Language).
* **STL** converter translates Open CASCADE shapes to STL files.
STL (STtereoLithography) format is widely used for rapid prototyping (3D printing).
* @ref occt_user_guides__xde "Extended data exchange" (XDE) allows translating additional attributes attached to geometric data (colors, layers, names, materials etc).
* <a href="https://www.opencascade.com/content/advanced-data-exchange-components">Advanced Data Exchange Components</a> are available in addition to standard Data Exchange interfaces to support interoperability and data adaptation (also using @ref OCCT_TOVW_SECTION_6a "Shape Healing") with CAD software using the following proprietary formats:
* <a href="https://www.opencascade.com/content/advanced-data-exchange-components">Advanced Data Exchange Components</a>
are available in addition to standard Data Exchange interfaces to support interoperability and data adaptation (also using @ref OCCT_TOVW_SECTION_6a "Shape Healing") with CAD software using the following proprietary formats:
* <a href="https://www.opencascade.com/content/acis-sat-import-export">ACIS SAT</a>
* <a href="https://www.opencascade.com/content/parasolid-import">Parasolid</a>
* <a href="https://www.opencascade.com/content/dxf-import-export">DXF</a>
@@ -238,22 +247,22 @@ These components are based on the same architecture as interfaces with STEP and
**Shape Healing** library provides algorithms to correct and adapt the geometry and topology of shapes imported to OCCT from other CAD systems.
Shape Healing algorithms include, but are not limited to, the following operations:
* analyze shape characteristics and, in particular, identify the shapes that do not comply with OCCT geometry and topology validity rules by analyzing geometrical objects and topology:
- check edge and wire consistency;
- check edge order in a wire;
- check the orientation of face boundaries;
- analyze shape tolerances;
- identify closed and open wires in a boundary.
* fix incorrect or incomplete shapes:
- provide consistency between a 3D curve and its corresponding parametric curve;
- repair defective wires;
- fit the shapes to a user-defined tolerance value;
- fill gaps between patches and edges.
* upgrade and change shape characteristics:
- reduce curve and surface degree;
- split shapes to obtain C1 continuity;
- convert any types of curves or surfaces to Bezier or B-Spline curves or surfaces and back;
- split closed surfaces and revolution surfaces.
* Analyze shape characteristics and, in particular, identify the shapes that do not comply with OCCT geometry and topology validity rules by analyzing geometrical objects and topology:
- check edge and wire consistency;
- check edge order in a wire;
- check the orientation of face boundaries;
- analyze shape tolerances;
- identify closed and open wires in a boundary.
* Fix incorrect or incomplete shapes:
- provide consistency between a 3D curve and its corresponding parametric curve;
- repair defective wires;
- fit the shapes to a user-defined tolerance value;
- fill gaps between patches and edges.
* Upgrade and change shape characteristics:
- reduce curve and surface degree;
- split shapes to obtain C1 continuity;
- convert any types of curves or surfaces to Bezier or B-Spline curves or surfaces and back;
- split closed surfaces and revolution surfaces.
Each sub-domain of Shape Healing has its own scope of functionality:
@@ -269,21 +278,24 @@ For more details, refer to @ref occt_user_guides__shape_healing "Shape Healing U
See also: our <a href="https://www.opencascade.com/content/tutorial-learning">E-learning & Training</a> offerings.
@section OCCT_TOVW_SECTION_7 Application Framework
**Open CASCADE Application Framework** (OCAF) handles Application Data basing on the Application/Document paradigm. It uses an associativity engine to simplify the development of a CAD application thanks to the following ready-to-use features and services:
**Open CASCADE Application Framework** (OCAF) handles Application Data basing on the Application/Document paradigm.
It uses an associativity engine to simplify the development of a CAD application thanks to the following ready-to-use features and services:
* Data attributes managing the application data, which can be organized according to the development needs;
* Data storage and persistence (open/save);
* Possibility to modify and recompute attributes in documents. With OCAF it is easy to represent the history of modification and parametric dependencies within your model;
* Possibility to modify and recompute attributes in documents.
With OCAF it is easy to represent the history of modification and parametric dependencies within your model;
* Possibility to manage multiple documents;
* Predefined attributes common to CAD/CAM/CAE applications (e.g. to store dimensions);
* Undo-Redo and Copy-Paste functions.
Since OCAF handles the application structure, the only development task is the creation of application-specific data and GUIs.
OCAF differs from any other CAD framework in the organization of application data, as there the data structures are based on reference keys rather than on shapes. In a model, such attributes as shape data, color and material are attached to an invariant structure, which is deeper than the shapes. A shape object becomes the value of *Shape* attribute, in the same way as an integer number is the value of *Integer* attribute and a string is the value of *Name* attribute.
OCAF differs from any other CAD framework in the organization of application data, as there the data structures are based on reference keys rather than on shapes.
In a model, such attributes as shape data, color and material are attached to an invariant structure, which is deeper than the shapes.
A shape object becomes the value of *Shape* attribute, in the same way as an integer number is the value of *Integer* attribute and a string is the value of *Name* attribute.
OCAF organizes and embeds these attributes in a document. OCAF documents, in their turn, are managed by an OCAF application.
@@ -291,10 +303,11 @@ For more details, see @ref occt_user_guides__ocaf "OCAF User's Guide".
See also: our <a href="https://www.opencascade.com/content/tutorial-learning">E-learning & Training</a> offerings.
@section OCCT_TOVW_SECTION_8 Draw Test Harness
**Test Harness** or **Draw** is a convenient testing tool for OCCT libraries. It can be used to test and prototype various algorithms before building an entire application. It includes:
**Test Harness** or **Draw** is a convenient testing tool for OCCT libraries.
It can be used to test and prototype various algorithms before building an entire application.
It includes:
- A command interpreter based on the TCL language;
- A number of 2D and 3D viewers;
- A set of predefined commands.

File diff suppressed because it is too large Load Diff

View File

@@ -406,6 +406,47 @@ if(!Interface_Static::SetIVal(;read.step.shape.aspect;,1))
~~~~~
Default value is 1 (ON).
<h4>read.step.constructivegeom.relationship:</h4>
Boolean flag regulating translation of "CONSTRUCTIVE_GEOMETRY_REPRESENTATION_RELATIONSHIP" entities that define
position of constructive geometry entities contained in "CONSTRUCTIVE_GEOMETRY_REPRESENTATION" with respect to the
main representation of the shape (product).
By default, the flag is set to 0 (OFF) so these entities are not translated.
Set this flag to 1 (ON) if you need to translate constructive geometry entities associated with the parts:
~~~~~
if (!Interface_Static::SetIVal("read.step.constructivegeom.relationship", 1)) { .. error .. }
~~~~~
The "CONSTRUCTIVE_GEOMETRY_REPRESENTATION" entity is translated into compound of two unlimited planar faces,
whose location is result of translation of corresponding "AXIS_PLACEMENT" entity.
Note that appropriate interpretation of the translated data should be done after translation.
The result of translation can be obtained either for the "CONSTRUCTIVE_GEOMETRY_REPRESENTATION_RELATIONSHIP" entity,
of for each of the two "AXIS2_PLACEMENT_3D" entities referenced by it. as follows:
~~~~~
STEPControl_Reader aReader;
... // translate file and parse STEP model to find relevant axis entity
Handle(StepGeom_Axis2Placement3d) aSTEPAxis = ...;
Handle(Transfer_Binder) aBinder = aReader->WS()->TransferReader()->TransientProcess()->Find(aSTEPAxis);
Handle(TransferBRep_ShapeBinder) aShBinder = Handle(TransferBRep_ShapeBinder)::DownCast(aBinder);
if (! aShBinder.IsNull())
{
TopoDS_Face aFace = TopoDS::Face (aShBinder->Result());
if (! aFace.IsNull())
{
Handle(Geom_Plane) aSurf = Handle(Geom_Plane)::DownCast (BRep_Tool::Surface (aFace));
if (! aSurf.IsNull())
{
gp_Ax3 anAxis = aSurf->Placement();
... // use the axis placement data
}
}
}
~~~~~
@subsubsection occt_step_2_3_4 Performing the STEP file translation
Perform the translation according to what you want to translate. You can choose either root entities (all or selected by the number of root), or select any entity by its number in the STEP file. There is a limited set of types of entities that can be used as starting entities for translation. Only the following entities are recognized as transferable:

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,7 @@
#include <Message.hxx>
#include <Message_Messenger.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <Prs3d.hxx>
#include <StdPrs_ToolTriangulatedShape.hxx>
#include <Prs3d_Drawer.hxx>
#include <STEPControl_Reader.hxx>
#include <STEPCAFControl_Reader.hxx>
@@ -257,12 +257,12 @@ bool OcctViewer::ImportSTEP(std::string theFilename)
}
Handle(Prs3d_Drawer) aDrawer = myContext->DefaultDrawer();
Standard_Real aDeflection = Prs3d::GetDeflection (aCompound, aDrawer);
Standard_Real aDeflection = StdPrs_ToolTriangulatedShape::GetDeflection (aCompound, aDrawer);
if (!BRepTools::Triangulation (aCompound, aDeflection))
{
BRepMesh_IncrementalMesh anAlgo;
anAlgo.ChangeParameters().Deflection = aDeflection;
anAlgo.ChangeParameters().Angle = aDrawer->HLRAngle();
anAlgo.ChangeParameters().Angle = aDrawer->DeviationAngle();
anAlgo.ChangeParameters().InParallel = Standard_True;
anAlgo.SetShape (aCompound);
anAlgo.Perform();

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/occtJniActivity/libs&quot; type=&quot;2&quot;/&gt;&#10;&lt;/resources&gt;}"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;resources&gt;&#10;&lt;item path=&quot;/occtJniActivity/jni&quot; type=&quot;2&quot;/&gt;&#10;&lt;/resources&gt;}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="~/develop/android-ndk-r10/ndk-build"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="V=1 jniall"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/occtJniActivity/jni}"/>
</launchConfiguration>

1
samples/java/jniviewer/.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.gradle eol=lf

View File

@@ -1,4 +1,10 @@
/assets
/bin
/gen
/libs
/.gradle
/.idea
/build
/gradle
gradlew
gradlew.bat
/app/.cxx
/app/build
gradle.properties
local.properties

View File

@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>occtJniActivity</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>auto,full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/C++ Builder.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -1,4 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6

View File

@@ -11,36 +11,22 @@ This sample demonstrates indirect method of wrapping C++ to Java using manually
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
https://www.opencascade.com/content/advanced-samples-and-tools
Run Eclipse from ADT (Android Developer Tools) for building the sample. To import sample project perform
~~~~
File -> Import... -> Android -> Existing Android code into Workspace
~~~~
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:
~~~~
Project -> Properties -> Builders -> C++ Builder -> Edit -> Location
~~~~
Install Android Studio 4.0+ and install building tools (check Tools -> SDK Manager):
- Android SDK (API level 21 or higher).
- Android SDK build tools.
- Android NDK r16 or higher (coming with CMake toolchain).
Using NDK r18 or newer will require changing ANDROID_STL in project settings.
- CMake 3.10+.
Now paths to OCCT C++ libraries and additional components should be specified in "jni/Android.mk" file:
~~~~
OCCT_ROOT := $(LOCAL_PATH)/../../../..
Specify this folder location in Android Studio for opening project.
You might need re-entering Android SDK explicitly in File -> Project Structure -> SDK Location settings (SDK, NDK, JDK locations).
FREETYPE_INC := $(OCCT_ROOT)/../freetype/include/freetype2
FREETYPE_LIBS := $(OCCT_ROOT)/../freetype/libs
FREEIMAGE_INC := $(OCCT_ROOT)/../FreeImage/include
FREEIMAGE_LIBS := $(OCCT_ROOT)/../FreeImage/libs
OCCT_INC := $(OCCT_ROOT)/inc
OCCT_LIBS := $(OCCT_ROOT)/and/libs
~~~~
The list of extra components (Freetype, FreeImage) depends on OCCT configuration.
Variable $(TARGET_ARCH_ABI) 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.
This sample expects OCCT to be already build - please refer to appropriate CMake building instructions in OCCT documentation.
The following variables should be added into file gradle.properties (see gradle.properties.template as template):
- `OCCT_ROOT` - path to OCCT installation folder.
- `FREETYPE_ROOT` - path to FreeType installation folder.
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:
@@ -49,10 +35,8 @@ and load the explicitly from Java code within OcctJniActivity::loadNatives() met
|| !loadLibVerbose ("TKMath", aLoaded, aFailed)
|| !loadLibVerbose ("TKG2d", aLoaded, aFailed)
~~~~
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.
Note that C++ STL library is not part of Android system, and application must package this library as well as extra component ("gnustl_shared" by default - see also `ANDROID_STL`).
After successful build, the application can be packaged to Android:
- 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.
- Prepare signed end-user package using wizard File -> Export -> Android -> Export Android Application.
After successful build via Build -> Rebuild Project, the application can be packaged to Android:
- Deploy and run application on connected device or emulator directly from Android Studio using adb interface by menu items "Run" and "Debug". This would sign package with debug certificate.
- Prepare signed end-user package using wizard Build -> Generate signed APK.

View File

@@ -0,0 +1,48 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.opencascade.jnisample"
minSdkVersion 21
targetSdkVersion 26
ndk {
abiFilters "arm64-v8a"
}
externalNativeBuild {
cmake {
arguments "-DOCCT_ROOT=" + OCCT_ROOT,
"-DFREETYPE_ROOT=" + FREETYPE_ROOT,
"-DANDROID_STL=gnustl_shared"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
assets.srcDirs = [OCCT_ROOT + "/src"]
}
}
externalNativeBuild {
cmake {
path "src/main/jni/CMakeLists.txt"
}
}
}
dependencies {
implementation fileTree(dir: 'java/com/opencascade/jnisample', include: ['*.jar'])
}

View File

@@ -31,6 +31,5 @@
</activity>
</application>
<uses-feature android:glEsVersion="0x00020000"/>
<uses-sdk android:minSdkVersion="15"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

View File

@@ -110,11 +110,8 @@ public class OcctJniActivity extends Activity implements OnClickListener
// copy OCCT resources
String aResFolder = getFilesDir().getAbsolutePath();
copyAssetFolder (getAssets(), "Shaders", aResFolder + "/Shaders");
copyAssetFolder (getAssets(), "SHMessage", aResFolder + "/SHMessage");
copyAssetFolder (getAssets(), "XSMessage", aResFolder + "/XSMessage");
copyAssetFolder (getAssets(), "TObj", aResFolder + "/TObj");
copyAssetFolder (getAssets(), "UnitsAPI", aResFolder + "/UnitsAPI");
copyAssetFolder (getAssets(), "src/SHMessage", aResFolder + "/SHMessage");
copyAssetFolder (getAssets(), "src/XSMessage", aResFolder + "/XSMessage");
// C++ runtime
loadLibVerbose ("gnustl_shared", aLoaded, aFailed);
@@ -204,6 +201,9 @@ public class OcctJniActivity extends Activity implements OnClickListener
String aDataPath = aDataUrl != null ? aDataUrl.getPath() : "";
myOcctView.open (aDataPath);
myLastPath = aDataPath;
myContext = new android.content.ContextWrapper (this);
myContext.getExternalFilesDir (null);
}
//! Handle scroll events
@@ -513,6 +513,9 @@ public class OcctJniActivity extends Activity implements OnClickListener
aClickedBtn.setBackgroundColor (getResources().getColor(R.color.pressedBtnColor));
if (myFileOpenDialog == null)
{
// should be requested on runtime since API level 26 (Android 8)
askUserPermission (android.Manifest.permission.WRITE_EXTERNAL_STORAGE, null); // for accessing SD card
myFileOpenDialog = new OcctJniFileDialog (this, aPath);
myFileOpenDialog.setFileEndsWith (".brep");
myFileOpenDialog.setFileEndsWith (".rle");
@@ -760,6 +763,88 @@ public class OcctJniActivity extends Activity implements OnClickListener
return aResultSize;
}
//! Request user permission.
private void askUserPermission (String thePermission, String theRationale)
{
// Dynamically load methods introduced by API level 23.
// On older system this permission is granted by user during application installation.
java.lang.reflect.Method aMetPtrCheckSelfPermission, aMetPtrRequestPermissions, aMetPtrShouldShowRequestPermissionRationale;
try
{
aMetPtrCheckSelfPermission = myContext.getClass().getMethod ("checkSelfPermission", String.class);
aMetPtrRequestPermissions = getClass().getMethod ("requestPermissions", String[].class, int.class);
aMetPtrShouldShowRequestPermissionRationale = getClass().getMethod ("shouldShowRequestPermissionRationale", String.class);
}
catch (SecurityException theError)
{
postMessage ("Unable to find permission methods:\n" + theError.getMessage(), Message_Trace);
return;
}
catch (NoSuchMethodException theError)
{
postMessage ("Unable to find permission methods:\n" + theError.getMessage(), Message_Trace);
return;
}
try
{
int isAlreadyGranted = (Integer )aMetPtrCheckSelfPermission.invoke (myContext, thePermission);
if (isAlreadyGranted == android.content.pm.PackageManager.PERMISSION_GRANTED)
{
return;
}
boolean toShowInfo = theRationale != null && (Boolean )aMetPtrShouldShowRequestPermissionRationale.invoke (this, thePermission);
if (toShowInfo)
{
postMessage (theRationale, Message_Info);
}
// show dialog to user
aMetPtrRequestPermissions.invoke (this, new String[]{thePermission}, 0);
}
catch (IllegalArgumentException theError)
{
postMessage ("Internal error: Unable to call permission method:\n" + theError.getMessage(), Message_Fail);
return;
}
catch (IllegalAccessException theError)
{
postMessage ("Internal error: Unable to call permission method:\n" + theError.getMessage(), Message_Fail);
return;
}
catch (java.lang.reflect.InvocationTargetException theError)
{
postMessage ("Internal error: Unable to call permission method:\n" + theError.getMessage(), Message_Fail);
return;
}
}
//! Message gravity.
private static final int Message_Trace = 0;
private static final int Message_Info = 1;
private static final int Message_Warning = 2;
private static final int Message_Alarm = 3;
private static final int Message_Fail = 4;
//! Auxiliary method to show info message.
public void postMessage (String theMessage, int theGravity)
{
if (theGravity == Message_Trace)
{
return;
}
final String aText = theMessage;
final Context aCtx = this;
this.runOnUiThread (new Runnable() { public void run() {
android.app.AlertDialog.Builder aBuilder = new android.app.AlertDialog.Builder (aCtx);
aBuilder.setMessage (aText).setNegativeButton ("OK", null);
android.app.AlertDialog aDialog = aBuilder.create();
aDialog.show();
}});
}
//! OCCT major version
private native long cppOcctMajorVersion();
@@ -772,6 +857,7 @@ public class OcctJniActivity extends Activity implements OnClickListener
private OcctJniView myOcctView;
private TextView myMessageTextView;
private String myLastPath;
private android.content.ContextWrapper myContext = null;
private OcctJniFileDialog myFileOpenDialog;
private int myButtonPreferSize = 65;

View File

@@ -34,11 +34,13 @@ public class OcctJniRenderer implements GLSurfaceView.Renderer
};
//! Empty constructor.
OcctJniRenderer()
OcctJniRenderer (GLSurfaceView theView,
float theScreenDensity)
{
myView = theView; // this makes cyclic dependency, but it is OK for JVM
if (OcctJniActivity.areNativeLoaded)
{
myCppViewer = cppCreate();
myCppViewer = cppCreate (theScreenDensity);
}
}
@@ -56,7 +58,10 @@ public class OcctJniRenderer implements GLSurfaceView.Renderer
{
if (myCppViewer != 0)
{
cppRedraw (myCppViewer);
if (cppRedraw (myCppViewer))
{
myView.requestRender(); // this method is allowed from any thread
}
}
}
@@ -77,48 +82,39 @@ public class OcctJniRenderer implements GLSurfaceView.Renderer
}
}
//! Initialize rotation (remember first point position)
public void onStartRotation (int theStartX, int theStartY)
//! Add touch point.
public void onAddTouchPoint (int theId, float theX, float theY)
{
if (myCppViewer != 0)
{
cppStartRotation (myCppViewer, theStartX, theStartY);
cppAddTouchPoint (myCppViewer, theId, theX, theY);
}
}
//! Perform rotation (relative to first point)
public void onRotation (int theX, int theY)
//! Update touch point.
public void onUpdateTouchPoint (int theId, float theX, float theY)
{
if (myCppViewer != 0)
{
cppOnRotation (myCppViewer, theX, theY);
cppUpdateTouchPoint (myCppViewer, theId, theX, theY);
}
}
//! Perform panning
public void onPanning (int theDX, int theDY)
//! Remove touch point.
public void onRemoveTouchPoint (int theId)
{
if (myCppViewer != 0)
{
cppOnPanning (myCppViewer, theDX, theDY);
cppRemoveTouchPoint (myCppViewer, theId);
}
}
//! Perform selection
public void onClick (int theX, int theY)
//! Select in 3D Viewer.
public void onSelectInViewer (float theX, float theY)
{
if (myCppViewer != 0)
{
cppOnClick (myCppViewer, theX, theY);
}
}
//! Stop previously active action (e.g. discard first rotation point)
public void onStopAction()
{
if (myCppViewer != 0)
{
cppStopAction (myCppViewer);
cppSelectInViewer (myCppViewer, theX, theY);
}
}
@@ -157,7 +153,7 @@ public class OcctJniRenderer implements GLSurfaceView.Renderer
}
//! Create instance of C++ class
private native long cppCreate();
private native long cppCreate (float theDispDensity);
//! Destroy instance of C++ class
private native void cppDestroy (long theCppPtr);
@@ -171,11 +167,21 @@ public class OcctJniRenderer implements GLSurfaceView.Renderer
//! Open CAD file
private native void cppOpen (long theCppPtr, String thePath);
//! Handle detection in the viewer
private native void cppMoveTo (long theCppPtr, int theX, int theY);
//! Add touch point
private native void cppAddTouchPoint (long theCppPtr, int theId, float theX, float theY);
//! Update touch point
private native void cppUpdateTouchPoint (long theCppPtr, int theId, float theX, float theY);
//! Remove touch point
private native void cppRemoveTouchPoint (long theCppPtr, int theId);
//! Select in 3D Viewer.
private native void cppSelectInViewer (long theCppPtr, float theX, float theY);
//! Redraw OCCT viewer
private native void cppRedraw (long theCppPtr);
//! Returns TRUE if more frames are requested.
private native boolean cppRedraw (long theCppPtr);
//! Fit All
private native void cppFitAll (long theCppPtr);
@@ -198,21 +204,7 @@ public class OcctJniRenderer implements GLSurfaceView.Renderer
//! Move camera
private native void cppSetZnegProj (long theCppPtr);
//! Initialize rotation
private native void cppStartRotation (long theCppPtr, int theStartX, int theStartY);
//! Perform rotation
private native void cppOnRotation (long theCppPtr, int theX, int theY);
//! Perform panning
private native void cppOnPanning (long theCppPtr, int theDX, int theDY);
//! Perform selection
private native void cppOnClick (long theCppPtr, int theX, int theY);
//! Stop action (rotation / panning / scaling)
private native void cppStopAction (long theCppPtr);
private GLSurfaceView myView = null; //!< back reference to the View
private long myCppViewer = 0; //!< pointer to c++ class instance
}

View File

@@ -38,6 +38,9 @@ class OcctJniView extends GLSurfaceView
{
super (theContext, theAttrs);
android.util.DisplayMetrics aDispInfo = theContext.getResources().getDisplayMetrics();
myScreenDensity = aDispInfo.density;
setPreserveEGLContextOnPause (true);
setEGLContextFactory (new ContextFactory());
setEGLConfigChooser (new ConfigChooser());
@@ -45,8 +48,9 @@ class OcctJniView extends GLSurfaceView
RelativeLayout.LayoutParams aLParams = new RelativeLayout.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
aLParams.addRule (RelativeLayout.ALIGN_TOP);
myRenderer = new OcctJniRenderer();
myRenderer = new OcctJniRenderer (this, myScreenDensity);
setRenderer (myRenderer);
setRenderMode (GLSurfaceView.RENDERMODE_WHEN_DIRTY); // render on request to spare battery
}
//! Open file.
@@ -54,6 +58,7 @@ class OcctJniView extends GLSurfaceView
{
final String aPath = thePath;
queueEvent (new Runnable() { public void run() { myRenderer.open (aPath); }});
requestRender();
}
//! Create OpenGL ES 2.0+ context
@@ -202,77 +207,44 @@ class OcctJniView extends GLSurfaceView
//! Callback to handle touch events
@Override public boolean onTouchEvent (MotionEvent theEvent)
{
int aPointerIndex = theEvent.getActionIndex();
int aPointerId = theEvent.getPointerId (aPointerIndex);
int aMaskedAction = theEvent.getActionMasked();
final int aMaskedAction = theEvent.getActionMasked();
switch (aMaskedAction)
{
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
{
PointF aPntLast = null;
if (myActivePointers.size() >= 1)
final int aPointerIndex = theEvent.getActionIndex();
final int aPointerId = theEvent.getPointerId (aPointerIndex);
final PointF aPnt = new PointF (theEvent.getX (aPointerIndex), theEvent.getY (aPointerIndex));
if (theEvent.getPointerCount() == 1)
{
aPntLast = myActivePointers.get (myActivePointers.keyAt (0));
}
final PointF aPnt = new PointF();
aPnt.x = theEvent.getX (aPointerIndex);
aPnt.y = theEvent.getY (aPointerIndex);
myActivePointers.put (aPointerId, aPnt);
switch (myActivePointers.size())
{
case 1:
{
final int aStartX = (int )aPnt.x;
final int aStartY = (int )aPnt.y;
queueEvent (new Runnable() { public void run() { myRenderer.onStartRotation (aStartX, aStartY); }});
break;
}
case 2:
{
myPanFrom.x = (aPntLast.x + aPnt.x) * 0.5f;
myPanFrom.y = (aPntLast.y + aPnt.y) * 0.5f;
break;
}
mySelectPoint = aPnt;
}
else
{
mySelectPoint = null;
}
queueEvent (new Runnable() { public void run() { myRenderer.onAddTouchPoint (aPointerId, aPnt.x, aPnt.y); }});
break;
}
case MotionEvent.ACTION_MOVE:
{
for (int aNbPointers = theEvent.getPointerCount(), aPntIter = 0; aPntIter < aNbPointers; ++aPntIter)
{
PointF aPnt = myActivePointers.get (theEvent.getPointerId (aPntIter));
if (aPnt != null)
{
aPnt.x = theEvent.getX (aPntIter);
aPnt.y = theEvent.getY (aPntIter);
}
final int aPointerId = theEvent.getPointerId (aPntIter);
final PointF aPnt = new PointF (theEvent.getX (aPntIter), theEvent.getY (aPntIter));
queueEvent (new Runnable() { public void run() { myRenderer.onUpdateTouchPoint (aPointerId, aPnt.x, aPnt.y); }});
}
switch (myActivePointers.size())
if (mySelectPoint != null)
{
case 1:
final float aTouchThreshold = 5.0f * myScreenDensity;
final int aPointerIndex = theEvent.getActionIndex();
final PointF aDelta = new PointF (theEvent.getX (aPointerIndex) - mySelectPoint.x, theEvent.getY (aPointerIndex) - mySelectPoint.y);
if (Math.abs (aDelta.x) > aTouchThreshold || Math.abs (aDelta.y) > aTouchThreshold)
{
PointF aPnt = myActivePointers.get (theEvent.getPointerId (0));
final int anX = (int )aPnt.x;
final int anY = (int )aPnt.y;
queueEvent (new Runnable() { public void run() { myRenderer.onRotation (anX, anY); }});
break;
}
case 2:
{
PointF aPnt1 = myActivePointers.get (myActivePointers.keyAt (0));
PointF aPnt2 = myActivePointers.get (myActivePointers.keyAt (1));
PointF aPntAver = new PointF ((aPnt1.x + aPnt2.x) * 0.5f,
(aPnt1.y + aPnt2.y) * 0.5f);
final int aDX = (int )(aPntAver.x - myPanFrom.x);
final int aDY = (int )(myPanFrom.y -aPntAver.y);
myPanFrom.x = aPntAver.x;
myPanFrom.y = aPntAver.y;
queueEvent (new Runnable() { public void run() { myRenderer.onPanning (aDX, aDY); }});
mySelectPoint = null;
}
}
break;
@@ -281,30 +253,21 @@ class OcctJniView extends GLSurfaceView
case MotionEvent.ACTION_POINTER_UP:
case MotionEvent.ACTION_CANCEL:
{
myActivePointers.remove (aPointerId);
if (myActivePointers.size() == 0)
if (mySelectPoint != null)
{
final int aPressX = (int )theEvent.getX (aPointerIndex);
final int aPressY = (int )theEvent.getY (aPointerIndex);
double aPressTimeMs = theEvent.getEventTime() - theEvent.getDownTime();
if (aPressTimeMs < 100.0)
{
queueEvent (new Runnable() { public void run() { myRenderer.onClick (aPressX, aPressY); }});
break;
}
final float aSelX = mySelectPoint.x;
final float aSelY = mySelectPoint.y;
queueEvent (new Runnable() { public void run() { myRenderer.onSelectInViewer (aSelX, aSelY); }});
mySelectPoint = null;
}
else if (myActivePointers.size() == 1)
{
PointF aPnt = myActivePointers.get (myActivePointers.keyAt (0));
final int aStartX = (int )aPnt.x;
final int aStartY = (int )aPnt.y;
queueEvent (new Runnable() { public void run() { myRenderer.onStartRotation (aStartX, aStartY); }});
}
//queueEvent (new Runnable() { public void run() { myRenderer.onStopAction(); }});
break;
final int aPointerIndex = theEvent.getActionIndex();
final int aPointerId = theEvent.getPointerId (aPointerIndex);
final PointF aPnt = new PointF (theEvent.getX (aPointerIndex), theEvent.getY (aPointerIndex));
queueEvent (new Runnable() { public void run() { myRenderer.onRemoveTouchPoint (aPointerId); }});
}
}
///invalidate();
requestRender();
return true;
}
@@ -312,21 +275,20 @@ class OcctJniView extends GLSurfaceView
public void fitAll()
{
queueEvent (new Runnable() { public void run() { myRenderer.fitAll(); }});
requestRender();
}
//! Move camera
public void setProj (final OcctJniRenderer.TypeOfOrientation theProj)
{
queueEvent (new Runnable() { public void run() { myRenderer.setProj (theProj); }});
requestRender();
}
//! OCCT viewer
private OcctJniRenderer myRenderer = null;
//! Touch events cache
private SparseArray<PointF> myActivePointers = new SparseArray<PointF>();
//! Starting point for panning event
private PointF myPanFrom = new PointF (0.0f, 0.0f);
private OcctJniRenderer myRenderer = null;
private int mySelectId = -1;
private PointF mySelectPoint = null;
private float myScreenDensity = 1.0f;
}

View File

@@ -0,0 +1,43 @@
cmake_minimum_required(VERSION 3.4.1)
set(HEADER_FILES OcctJni_MsgPrinter.hxx OcctJni_Viewer.hxx)
set(SOURCE_FILES OcctJni_MsgPrinter.cxx OcctJni_Viewer.cxx)
set (anOcctLibs
TKernel TKMath TKG2d TKG3d TKGeomBase TKBRep TKGeomAlgo TKTopAlgo TKShHealing TKMesh
# exchange
TKPrim TKBO TKBool TKFillet TKOffset
TKXSBase
TKIGES
TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP
# OCCT Visualization
TKService TKHLR TKV3d TKOpenGl
)
set(aLibDeps "")
# OCCT libraries
include_directories(${OCCT_ROOT}/inc)
foreach(anOcctLib ${anOcctLibs})
add_library(lib_${anOcctLib} SHARED IMPORTED)
set_target_properties(lib_${anOcctLib} PROPERTIES IMPORTED_LOCATION ${OCCT_ROOT}/libs/${ANDROID_ABI}/lib${anOcctLib}.so)
list(APPEND aLibDeps lib_${anOcctLib})
endforeach()
# FreeType
add_library(lib_FreeType SHARED IMPORTED)
set_target_properties(lib_FreeType PROPERTIES IMPORTED_LOCATION ${FREETYPE_ROOT}/libs/${ANDROID_ABI}/libfreetype.so)
list(APPEND aLibDeps lib_FreeType)
# FreeImage - uncomment, if OCCT was built with FreeImage
#add_library(lib_FreeImage SHARED IMPORTED)
#set_target_properties(lib_FreeImage PROPERTIES IMPORTED_LOCATION ${FREETYPE_ROOT}/libs/${ANDROID_ABI}/libfreeimage.so)
#list(APPEND aLibDeps lib_FreeImage)
# system libraries
list(APPEND aLibDeps EGL GLESv2 log android)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -frtti -fexceptions -fpermissive")
add_library(TKJniSample SHARED ${SOURCE_FILES})
target_link_libraries(TKJniSample ${aLibDeps})

View File

@@ -11,7 +11,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OcctJni_MsgPrinter.hxx>
#include "OcctJni_MsgPrinter.hxx"
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
@@ -48,27 +48,11 @@ OcctJni_MsgPrinter::~OcctJni_MsgPrinter()
}
// =======================================================================
// function : Send
// function : send
// purpose :
// =======================================================================
void OcctJni_MsgPrinter::Send (const TCollection_ExtendedString& theString,
const Message_Gravity theGravity,
const Standard_Boolean theToPutEndl) const
{
if (theGravity >= myTraceLevel)
{
const TCollection_AsciiString aStr (theString);
OcctJni_MsgPrinter::Send (aStr, theGravity, theToPutEndl);
}
}
// =======================================================================
// function : Send
// purpose :
// =======================================================================
void OcctJni_MsgPrinter::Send (const TCollection_AsciiString& theString,
const Message_Gravity theGravity,
const Standard_Boolean theToPutEndl) const
void OcctJni_MsgPrinter::send (const TCollection_AsciiString& theString,
const Message_Gravity theGravity) const
{
if (theGravity < myTraceLevel)
{
@@ -82,20 +66,6 @@ void OcctJni_MsgPrinter::Send (const TCollection_AsciiString& theString,
}
jstring aJStr = myJEnv->NewStringUTF ((theString + "\n").ToCString());
myJEnv->CallObjectMethod (myJObj, myJMet, aJStr);
myJEnv->CallVoidMethod (myJObj, myJMet, aJStr);
myJEnv->DeleteLocalRef (aJStr);
}
// =======================================================================
// function : Send
// purpose :
// =======================================================================
void OcctJni_MsgPrinter::Send (const Standard_CString& theString,
const Message_Gravity theGravity,
const Standard_Boolean theToPutEndl) const
{
if (theGravity >= myTraceLevel)
{
OcctJni_MsgPrinter::Send (TCollection_AsciiString (theString), theGravity, theToPutEndl);
}
}

View File

@@ -30,20 +30,11 @@ public:
//! Destructor.
~OcctJni_MsgPrinter();
//! Redirection to TCollection_AsciiString method
virtual void Send (const TCollection_ExtendedString& theString,
const Message_Gravity theGravity,
const Standard_Boolean theToPutEndl) const;
//! Redirection to TCollection_AsciiString method
virtual void Send (const Standard_CString& theString,
const Message_Gravity theGravity,
const Standard_Boolean theToPutEndl) const;
protected:
//! Main printing method
virtual void Send (const TCollection_AsciiString& theString,
const Message_Gravity theGravity,
const Standard_Boolean theToPutEndl) const;
virtual void send (const TCollection_AsciiString& theString,
const Message_Gravity theGravity) const override;
private:

View File

@@ -11,17 +11,21 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OcctJni_Viewer.hxx>
#include <OcctJni_MsgPrinter.hxx>
#include "OcctJni_Viewer.hxx"
#include "OcctJni_MsgPrinter.hxx"
#include <AIS_ViewCube.hxx>
#include <AIS_Shape.hxx>
#include <Aspect_NeutralWindow.hxx>
#include <Image_AlienPixMap.hxx>
#include <BRepTools.hxx>
#include <Message_Messenger.hxx>
#include <Message_MsgFile.hxx>
#include <Message_PrinterSystemLog.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <OSD_Environment.hxx>
#include <OSD_Timer.hxx>
#include <Prs3d_DatumAspect.hxx>
#include <Standard_Version.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
@@ -105,18 +109,69 @@ Standard_Boolean setResourceEnv (const TCollection_AsciiString& theVarName,
// function : OcctJni_Viewer
// purpose :
// =======================================================================
OcctJni_Viewer::OcctJni_Viewer()
OcctJni_Viewer::OcctJni_Viewer (float theDispDensity)
: myDevicePixelRatio (theDispDensity),
myIsJniMoreFrames (false)
{
SetTouchToleranceScale (theDispDensity);
#ifndef NDEBUG
// Register printer for logging messages into global Android log.
// Should never be used in production (or specify higher gravity for logging only failures).
Handle(Message_Messenger) aMsgMgr = Message::DefaultMessenger();
aMsgMgr->RemovePrinters (STANDARD_TYPE (Message_PrinterSystemLog));
aMsgMgr->AddPrinter (new Message_PrinterSystemLog ("OcctJni_Viewer"));
#endif
// prepare necessary environment
TCollection_AsciiString aResRoot = "/data/data/com.opencascade.jnisample/files";
setResourceEnv ("CSF_ShadersDirectory", aResRoot + "/Shaders", "Declarations.glsl", Standard_False);
setResourceEnv ("CSF_XSMessage", aResRoot + "/XSMessage", "XSTEP.us", Standard_False);
setResourceEnv ("CSF_SHMessage", aResRoot + "/XSMessage", "SHAPE.us", Standard_False);
//setResourceEnv ("CSF_PluginDefaults", "Plugin", Standard_False);
setResourceEnv ("CSF_XSMessage", aResRoot + "/XSMessage", "XSTEP.us", Standard_False);
setResourceEnv ("CSF_SHMessage", aResRoot + "/XSMessage", "SHAPE.us", Standard_False);
}
// make sure OCCT loads the dictionary
//UnitsAPI::SetLocalSystem (UnitsAPI_SI);
// ================================================================
// Function : dumpGlInfo
// Purpose :
// ================================================================
void OcctJni_Viewer::dumpGlInfo (bool theIsBasic)
{
TColStd_IndexedDataMapOfStringString aGlCapsDict;
myView->DiagnosticInformation (aGlCapsDict, Graphic3d_DiagnosticInfo_Basic); //theIsBasic ? Graphic3d_DiagnosticInfo_Basic : Graphic3d_DiagnosticInfo_Complete);
if (theIsBasic)
{
TCollection_AsciiString aViewport;
aGlCapsDict.FindFromKey ("Viewport", aViewport);
aGlCapsDict.Clear();
aGlCapsDict.Add ("Viewport", aViewport);
}
aGlCapsDict.Add ("Display scale", TCollection_AsciiString(myDevicePixelRatio));
// beautify output
{
TCollection_AsciiString* aGlVer = aGlCapsDict.ChangeSeek ("GLversion");
TCollection_AsciiString* aGlslVer = aGlCapsDict.ChangeSeek ("GLSLversion");
if (aGlVer != NULL
&& aGlslVer != NULL)
{
*aGlVer = *aGlVer + " [GLSL: " + *aGlslVer + "]";
aGlslVer->Clear();
}
}
TCollection_AsciiString anInfo;
for (TColStd_IndexedDataMapOfStringString::Iterator aValueIter (aGlCapsDict); aValueIter.More(); aValueIter.Next())
{
if (!aValueIter.Value().IsEmpty())
{
if (!anInfo.IsEmpty())
{
anInfo += "\n";
}
anInfo += aValueIter.Key() + ": " + aValueIter.Value();
}
}
Message::Send (anInfo, Message_Warning);
}
// =======================================================================
@@ -152,19 +207,10 @@ bool OcctJni_Viewer::init()
return false;
}
TCollection_AsciiString anEglInfo = TCollection_AsciiString()
+ "\n EGLVersion: " + eglQueryString (anEglDisplay, EGL_VERSION)
+ "\n EGLVendor: " + eglQueryString (anEglDisplay, EGL_VENDOR)
+ "\n EGLClient APIs: " + eglQueryString (anEglDisplay, EGL_CLIENT_APIS)
+ "\n GLvendor: " + (const char* )glGetString (GL_VENDOR)
+ "\n GLdevice: " + (const char* )glGetString (GL_RENDERER)
+ "\n GLversion: " + (const char* )glGetString (GL_VERSION) + " [GLSL: " + (const char* )glGetString (GL_SHADING_LANGUAGE_VERSION) + "]";
::Message::DefaultMessenger()->Send (anEglInfo, Message_Info);
if (!myViewer.IsNull())
{
Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myViewer->Driver());
Handle(OcctJni_Window) aWindow = Handle(OcctJni_Window)::DownCast (myView->Window());
Handle(Aspect_NeutralWindow) aWindow = Handle(Aspect_NeutralWindow)::DownCast (myView->Window());
if (!aDriver->InitEglContext (anEglDisplay, anEglContext, anEglConfig))
{
Message::DefaultMessenger()->Send ("Error: OpenGl_GraphicDriver can not be initialized!", Message_Fail);
@@ -174,6 +220,7 @@ bool OcctJni_Viewer::init()
aWindow->SetSize (aWidth, aHeight);
myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext);
dumpGlInfo (true);
return true;
}
@@ -187,6 +234,17 @@ bool OcctJni_Viewer::init()
return false;
}
myTextStyle = new Prs3d_TextAspect();
myTextStyle->SetFont (Font_NOF_ASCII_MONO);
myTextStyle->SetHeight (12);
myTextStyle->Aspect()->SetColor (Quantity_NOC_GRAY95);
myTextStyle->Aspect()->SetColorSubTitle (Quantity_NOC_BLACK);
myTextStyle->Aspect()->SetDisplayType (Aspect_TODT_SHADOW);
myTextStyle->Aspect()->SetTextFontAspect (Font_FA_Bold);
myTextStyle->Aspect()->SetTextZoomable (false);
myTextStyle->SetHorizontalJustification (Graphic3d_HTA_LEFT);
myTextStyle->SetVerticalJustification (Graphic3d_VTA_BOTTOM);
// create viewer
myViewer = new V3d_Viewer (aDriver);
myViewer->SetDefaultBackgroundColor (Quantity_NOC_BLACK);
@@ -195,14 +253,22 @@ bool OcctJni_Viewer::init()
// create AIS context
myContext = new AIS_InteractiveContext (myViewer);
//myContext->SetDisplayMode (AIS_WireFrame, false);
myContext->SetPixelTolerance (int(myDevicePixelRatio * 6.0)); // increase tolerance and adjust to hi-dpi screens
myContext->SetDisplayMode (AIS_Shaded, false);
Handle(OcctJni_Window) aWindow = new OcctJni_Window (aWidth, aHeight);
Handle(Aspect_NeutralWindow) aWindow = new Aspect_NeutralWindow();
aWindow->SetSize (aWidth, aHeight);
myView = myViewer->CreateView();
myView->SetImmediateUpdate (false);
myView->ChangeRenderingParams().Resolution = (unsigned int )(96.0 * myDevicePixelRatio + 0.5);
myView->ChangeRenderingParams().ToShowStats = true;
myView->ChangeRenderingParams().CollectedStats = (Graphic3d_RenderingParams::PerfCounters ) (Graphic3d_RenderingParams::PerfCounters_FrameRate | Graphic3d_RenderingParams::PerfCounters_Triangles);
myView->ChangeRenderingParams().StatsTextAspect = myTextStyle->Aspect();
myView->ChangeRenderingParams().StatsTextHeight = (int )myTextStyle->Height();
myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext);
myView->TriedronDisplay (Aspect_TOTP_RIGHT_LOWER, Quantity_NOC_WHITE, 0.08, V3d_ZBUFFER);
dumpGlInfo (false);
//myView->TriedronDisplay (Aspect_TOTP_RIGHT_LOWER, Quantity_NOC_WHITE, 0.08 * myDevicePixelRatio, V3d_ZBUFFER);
initContent();
return true;
@@ -233,13 +299,13 @@ void OcctJni_Viewer::resize (int theWidth,
}
Handle(OpenGl_GraphicDriver) aDriver = Handle(OpenGl_GraphicDriver)::DownCast (myViewer->Driver());
Handle(OcctJni_Window) aWindow = Handle(OcctJni_Window)::DownCast (myView->Window());
Handle(Aspect_NeutralWindow) aWindow = Handle(Aspect_NeutralWindow)::DownCast (myView->Window());
aWindow->SetSize (theWidth, theHeight);
//myView->MustBeResized(); // can be used instead of SetWindow() when EGLsurface has not been changed
EGLContext anEglContext = eglGetCurrentContext();
myView->SetImmediateUpdate (Standard_False);
myView->SetWindow (aWindow, (Aspect_RenderingContext )anEglContext);
dumpGlInfo (true);
//saveSnapshot ("/sdcard/Download/tt.png", theWidth, theHeight);
}
@@ -251,6 +317,28 @@ void OcctJni_Viewer::initContent()
{
myContext->RemoveAll (Standard_False);
if (myViewCube.IsNull())
{
myViewCube = new AIS_ViewCube();
{
// setup view cube size
static const double THE_CUBE_SIZE = 60.0;
myViewCube->SetSize (myDevicePixelRatio * THE_CUBE_SIZE, false);
myViewCube->SetBoxFacetExtension (myViewCube->Size() * 0.15);
myViewCube->SetAxesPadding (myViewCube->Size() * 0.10);
myViewCube->SetFontHeight (THE_CUBE_SIZE * 0.16);
}
// presentation parameters
myViewCube->SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_RIGHT_LOWER, Graphic3d_Vec2i (200, 200)));
myViewCube->Attributes()->SetDatumAspect (new Prs3d_DatumAspect());
myViewCube->Attributes()->DatumAspect()->SetTextAspect (myTextStyle);
// animation parameters
myViewCube->SetViewAnimation (myViewAnimation);
myViewCube->SetFixedAnimationLoop (false);
myViewCube->SetAutoStartAnimation (true);
}
myContext->Display (myViewCube, false);
OSD_Timer aTimer;
aTimer.Start();
if (!myShape.IsNull())
@@ -383,6 +471,10 @@ bool OcctJni_Viewer::open (const TCollection_AsciiString& thePath)
if (!myContext.IsNull())
{
myContext->RemoveAll (Standard_False);
if (!myViewCube.IsNull())
{
myContext->Display (myViewCube, false);
}
}
if (thePath.IsEmpty())
{
@@ -523,18 +615,33 @@ bool OcctJni_Viewer::saveSnapshot (const TCollection_AsciiString& thePath,
return true;
}
// ================================================================
// Function : handleViewRedraw
// Purpose :
// ================================================================
void OcctJni_Viewer::handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView)
{
AIS_ViewController::handleViewRedraw (theCtx, theView);
myIsJniMoreFrames = myToAskNextFrame;
}
// =======================================================================
// function : redraw
// purpose :
// =======================================================================
void OcctJni_Viewer::redraw()
bool OcctJni_Viewer::redraw()
{
if (myView.IsNull())
{
return;
return false;
}
myView->Redraw();
// handle user input
myIsJniMoreFrames = false;
myView->InvalidateImmediate();
FlushViewEvents (myContext, myView, true);
return myIsJniMoreFrames;
}
// =======================================================================
@@ -552,89 +659,13 @@ void OcctJni_Viewer::fitAll()
myView->Invalidate();
}
// =======================================================================
// function : startRotation
// purpose :
// =======================================================================
void OcctJni_Viewer::startRotation (int theStartX,
int theStartY)
{
if (myView.IsNull())
{
return;
}
myView->StartRotation (theStartX, theStartY, 0.45);
myView->Invalidate();
}
// =======================================================================
// function : onRotation
// purpose :
// =======================================================================
void OcctJni_Viewer::onRotation (int theX,
int theY)
{
if (myView.IsNull())
{
return;
}
myView->Rotation (theX, theY);
myView->Invalidate();
}
// =======================================================================
// function : onPanning
// purpose :
// =======================================================================
void OcctJni_Viewer::onPanning (int theDX,
int theDY)
{
if (myView.IsNull())
{
return;
}
myView->Pan (theDX, theDY);
myView->Invalidate();
}
// =======================================================================
// function : onClick
// purpose :
// =======================================================================
void OcctJni_Viewer::onClick (int theX,
int theY)
{
if (myView.IsNull())
{
return;
}
myContext->MoveTo (theX, theY, myView, Standard_False);
myContext->Select (Standard_False);
myView->Invalidate();
}
// =======================================================================
// function : stopAction
// purpose :
// =======================================================================
void OcctJni_Viewer::stopAction()
{
if (myView.IsNull())
{
return;
}
}
#define jexp extern "C" JNIEXPORT
jexp jlong JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppCreate (JNIEnv* theEnv,
jobject theObj)
jobject theObj,
jfloat theDispDensity)
{
return jlong(new OcctJni_Viewer());
return jlong(new OcctJni_Viewer (theDispDensity));
}
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppDestroy (JNIEnv* theEnv,
@@ -684,11 +715,11 @@ jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppOpen (JNIEnv
((OcctJni_Viewer* )theCppPtr)->open (aPath);
}
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppRedraw (JNIEnv* theEnv,
jobject theObj,
jlong theCppPtr)
jexp jboolean JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppRedraw (JNIEnv* theEnv,
jobject theObj,
jlong theCppPtr)
{
((OcctJni_Viewer* )theCppPtr)->redraw();
return ((OcctJni_Viewer* )theCppPtr)->redraw() ? JNI_TRUE : JNI_FALSE;
}
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppSetAxoProj (JNIEnv* theEnv,
@@ -747,47 +778,41 @@ jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppFitAll (JNIE
((OcctJni_Viewer* )theCppPtr)->fitAll();
}
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppStartRotation (JNIEnv* theEnv,
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppAddTouchPoint (JNIEnv* theEnv,
jobject theObj,
jlong theCppPtr,
jint theStartX,
jint theStartY)
jint theId,
jfloat theX,
jfloat theY)
{
((OcctJni_Viewer* )theCppPtr)->startRotation (theStartX, theStartY);
((OcctJni_Viewer* )theCppPtr)->AddTouchPoint (theId, Graphic3d_Vec2d (theX, theY));
}
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppOnRotation (JNIEnv* theEnv,
jobject theObj,
jlong theCppPtr,
jint theX,
jint theY)
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppUpdateTouchPoint (JNIEnv* theEnv,
jobject theObj,
jlong theCppPtr,
jint theId,
jfloat theX,
jfloat theY)
{
((OcctJni_Viewer* )theCppPtr)->onRotation (theX, theY);
((OcctJni_Viewer* )theCppPtr)->UpdateTouchPoint (theId, Graphic3d_Vec2d (theX, theY));
}
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppOnPanning (JNIEnv* theEnv,
jobject theObj,
jlong theCppPtr,
jint theDX,
jint theDY)
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppRemoveTouchPoint (JNIEnv* theEnv,
jobject theObj,
jlong theCppPtr,
jint theId)
{
((OcctJni_Viewer* )theCppPtr)->onPanning (theDX, theDY);
((OcctJni_Viewer* )theCppPtr)->RemoveTouchPoint (theId);
}
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppOnClick (JNIEnv* theEnv,
jobject theObj,
jlong theCppPtr,
jint theX,
jint theY)
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppSelectInViewer (JNIEnv* theEnv,
jobject theObj,
jlong theCppPtr,
jfloat theX,
jfloat theY)
{
((OcctJni_Viewer* )theCppPtr)->onClick (theX, theY);
}
jexp void JNICALL Java_com_opencascade_jnisample_OcctJniRenderer_cppStopAction (JNIEnv* theEnv,
jobject theObj,
jlong theCppPtr)
{
((OcctJni_Viewer* )theCppPtr)->stopAction();
((OcctJni_Viewer* )theCppPtr)->SelectInViewer (Graphic3d_Vec2i ((int )theX, (int )theY));
}
jexp jlong JNICALL Java_com_opencascade_jnisample_OcctJniActivity_cppOcctMajorVersion (JNIEnv* theEnv,

View File

@@ -11,21 +11,22 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OcctJni_Window.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_ViewController.hxx>
#include <TopoDS_Shape.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
class AIS_ViewCube;
//! Main C++ back-end for activity.
class OcctJni_Viewer
class OcctJni_Viewer : public AIS_ViewController
{
public:
//! Empty constructor
OcctJni_Viewer();
OcctJni_Viewer (float theDispDensity);
//! Initialize the viewer
bool init();
@@ -46,43 +47,45 @@ public:
int theHeight = 0);
//! Viewer update.
void redraw();
//! Returns TRUE if more frames should be requested.
bool redraw();
//! Move camera
void setProj (V3d_TypeOfOrientation theProj) { if (!myView.IsNull()) myView->SetProj (theProj); }
void setProj (V3d_TypeOfOrientation theProj)
{
if (myView.IsNull())
{
return;
}
myView->SetProj (theProj);
myView->Invalidate();
}
//! Fit All.
void fitAll();
//! Start rotation (remember first point position)
void startRotation (int theStartX,
int theStartY);
//! Perform rotation (relative to first point)
void onRotation (int theX,
int theY);
//! Perform panning
void onPanning (int theDX,
int theDY);
//! Perform selection
void onClick (int theX,
int theY);
//! Stop previously started action
void stopAction();
protected:
//! Reset viewer content.
void initContent();
//! Print information about OpenGL ES context.
void dumpGlInfo (bool theIsBasic);
//! Handle redraw.
virtual void handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
const Handle(V3d_View)& theView) override;
protected:
Handle(V3d_Viewer) myViewer;
Handle(V3d_View) myView;
Handle(AIS_InteractiveContext) myContext;
Handle(Prs3d_TextAspect) myTextStyle; //!< text style for OSD elements
Handle(AIS_ViewCube) myViewCube; //!< view cube object
TopoDS_Shape myShape;
float myDevicePixelRatio; //!< device pixel ratio for handling high DPI displays
bool myIsJniMoreFrames; //!< need more frame flag
};

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1002 B

After

Width:  |  Height:  |  Size: 1002 B

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 443 B

After

Width:  |  Height:  |  Size: 443 B

View File

Before

Width:  |  Height:  |  Size: 917 B

After

Width:  |  Height:  |  Size: 917 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 839 B

After

Width:  |  Height:  |  Size: 839 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@@ -0,0 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}

View File

@@ -0,0 +1,5 @@
# customized paths
OCCT_ROOT=c\:/android/occt-dev-android
FREETYPE_ROOT=c\:/android/freetype-2.7.1-android
# in case if OCCT was built with FreeImage
#FREEIMAGE_ROOT=c\:/android/freeimage-3.17-android

View File

@@ -1,205 +0,0 @@
LOCAL_PATH:= $(call my-dir)
STL_INC := $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/include $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/include
#STL_LIB := $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/libgnustl_static.a
STL_LIB := $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/libgnustl_shared.so
OCCT_ROOT := $(LOCAL_PATH)/../../../..
FREETYPE_INC := $(OCCT_ROOT)/../freetype/include/freetype2
FREETYPE_LIBS := $(OCCT_ROOT)/../freetype/libs
FREEIMAGE_INC := $(OCCT_ROOT)/../FreeImage/include
FREEIMAGE_LIBS := $(OCCT_ROOT)/../FreeImage/libs
OCCT_INC := $(OCCT_ROOT)/inc
OCCT_LIBS := $(OCCT_ROOT)/and/libs
ASSETDIR := $(LOCAL_PATH)/../assets
$(ASSETDIR)/Shaders: $(ASSETDIR)
-mkdir -p $(ASSETDIR)
-mkdir -p $(ASSETDIR)/Shaders
cp -f -r $(OCCT_ROOT)/src/Shaders/*.* $(ASSETDIR)/Shaders
$(ASSETDIR)/SHMessage: $(ASSETDIR)
-mkdir -p $(ASSETDIR)
-mkdir -p $(ASSETDIR)/SHMessage
cp -f -r $(OCCT_ROOT)/src/SHMessage/*.* $(ASSETDIR)/SHMessage
$(ASSETDIR)/XSMessage: $(ASSETDIR)
-mkdir -p $(ASSETDIR)
-mkdir -p $(ASSETDIR)/XSMessage
cp -f -r $(OCCT_ROOT)/src/XSMessage/*.* $(ASSETDIR)/XSMessage
pre_all: $(ASSETDIR)/Shaders $(ASSETDIR)/SHMessage $(ASSETDIR)/XSMessage
jniall: pre_all all
# STL libs
include $(CLEAR_VARS)
LOCAL_MODULE := SharedStl
LOCAL_EXPORT_C_INCLUDES := $(STL_INC)
LOCAL_SRC_FILES := $(STL_LIB)
include $(PREBUILT_SHARED_LIBRARY)
# 3rd-parties used in OCCT
include $(CLEAR_VARS)
LOCAL_MODULE := FreeType
LOCAL_EXPORT_C_INCLUDES := $(FREETYPE_INC)
LOCAL_SRC_FILES := $(FREETYPE_LIBS)/$(TARGET_ARCH_ABI)/libfreetype.so
include $(PREBUILT_SHARED_LIBRARY)
#include $(CLEAR_VARS)
#LOCAL_MODULE := FreeImage
#LOCAL_EXPORT_C_INCLUDES := $(FREEIMAGE_INC)
#LOCAL_SRC_FILES := $(FREEIMAGE_LIBS)/$(TARGET_ARCH_ABI)/libfreeimage.so
#include $(PREBUILT_SHARED_LIBRARY)
# OCCT core
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKernel
LOCAL_EXPORT_C_INCLUDES := $(OCCT_INC)
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKernel.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKMath
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKMath.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKG2d
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKG2d.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKG3d
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKG3d.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKGeomBase
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKGeomBase.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKBRep
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKBRep.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKGeomAlgo
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKGeomAlgo.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKTopAlgo
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKTopAlgo.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKShHealing
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKShHealing.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKMesh
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKMesh.so
include $(PREBUILT_SHARED_LIBRARY)
# OCCT Exchange
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKPrim
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKPrim.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKBO
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKBO.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKBool
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKBool.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKFillet
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKFillet.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKOffset
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKOffset.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKXSBase
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKXSBase.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKIGES
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKIGES.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKSTEPBase
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKSTEPBase.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKSTEPAttr
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKSTEPAttr.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKSTEP209
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKSTEP209.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKSTEP
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKSTEP.so
include $(PREBUILT_SHARED_LIBRARY)
# OCCT visualization
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKService
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKService.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKHLR
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKHLR.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKV3d
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKV3d.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := OcctTKOpenGl
LOCAL_SRC_FILES := $(OCCT_LIBS)/$(TARGET_ARCH_ABI)/libTKOpenGl.so
include $(PREBUILT_SHARED_LIBRARY)
# our sample
include $(CLEAR_VARS)
LOCAL_MODULE := libTKJniSample
LOCAL_C_INCLUDES := $(STL_INC)
#LOCAL_STATIC_LIBRARIES := $(STL_LIB) does not work
LOCAL_CFLAGS := -Wall -std=c++11
LOCAL_CPP_EXTENSION := .cxx .cpp
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_SRC_FILES := OcctJni_Viewer.cxx OcctJni_Window.cxx OcctJni_MsgPrinter.cxx
LOCAL_SHARED_LIBRARIES := OcctTKernel OcctTKMath OcctTKG2d OcctTKG3d OcctTKGeomBase OcctTKBRep OcctTKGeomAlgo OcctTKTopAlgo OcctTKShHealing OcctTKMesh OcctTKPrim
LOCAL_SHARED_LIBRARIES += OcctTKIGES OcctTKSTEP OcctTKXSBase
LOCAL_SHARED_LIBRARIES += OcctTKService OcctTKHLR OcctTKV3d OcctTKOpenGl
LOCAL_SHARED_LIBRARIES += SharedStl
LOCAL_LDLIBS := -llog -lGLESv2 -lEGL
#LOCAL_LDLIBS += $(STL_LIB)
include $(BUILD_SHARED_LIBRARY)

View File

@@ -1,8 +0,0 @@
NDK_TOOLCHAIN_VERSION := 4.8
APP_PLATFORM := android-15
APP_ABI := armeabi-v7a
#APP_ABI := all
#APP_STL := gnustl_static
#APP_STL := stlport_static

View File

@@ -1,109 +0,0 @@
// Copyright (c) 2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef OcctJni_Window_H
#define OcctJni_Window_H
#include <Aspect_Window.hxx>
//! This class defines dummy window
class OcctJni_Window : public Aspect_Window
{
public:
//! Creates a wrapper over existing Window handle
OcctJni_Window (const int theWidth, const int theHeight)
: myWidth (theWidth), myHeight(theHeight) {}
//! Returns native Window handle
virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE { return 0; }
//! Returns parent of native Window handle
virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return 0; }
//! Returns nothing on Android
virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return 0; }
virtual void Destroy() {}
//! Opens the window <me>
virtual void Map() const Standard_OVERRIDE {}
//! Closes the window <me>
virtual void Unmap() const Standard_OVERRIDE {}
//! Applies the resizing to the window <me>
virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
//! Apply the mapping change to the window <me>
virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
//! Returns True if the window <me> is opened
virtual Standard_Boolean IsMapped() const Standard_OVERRIDE { return Standard_True; }
//! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
virtual Standard_Real Ratio() const Standard_OVERRIDE { return 1.0; }
//! Returns The Window POSITION in PIXEL
virtual void Position (Standard_Integer& theX1,
Standard_Integer& theY1,
Standard_Integer& theX2,
Standard_Integer& theY2) const Standard_OVERRIDE
{
theX1 = 0;
theX2 = myWidth;
theY1 = 0;
theY2 = myHeight;
}
//! Set The Window POSITION in PIXEL
void SetPosition (const Standard_Integer theX1,
const Standard_Integer theY1,
const Standard_Integer theX2,
const Standard_Integer theY2)
{
myWidth = theX2 - theX1;
myHeight = theY2 - theY1;
}
//! Returns The Window SIZE in PIXEL
virtual void Size (Standard_Integer& theWidth,
Standard_Integer& theHeight) const Standard_OVERRIDE
{
theWidth = myWidth;
theHeight = myHeight;
}
//! Set The Window SIZE in PIXEL
void SetSize (const Standard_Integer theWidth,
const Standard_Integer theHeight)
{
myWidth = theWidth;
myHeight = theHeight;
}
private:
int myWidth;
int myHeight;
public:
DEFINE_STANDARD_RTTIEXT(OcctJni_Window,Aspect_Window)
};
DEFINE_STANDARD_HANDLE(OcctJni_Window, Aspect_Window)
#endif // OcctJni_Window_H

View File

@@ -1,14 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-15

View File

@@ -0,0 +1 @@
include ':app'

View File

@@ -1,57 +0,0 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="All"
SccProjectName=""
SccLocalPath=""
Keyword="MakeFileProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="10"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/All.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="10"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/All.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -1,431 +0,0 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="Approx"
SccProjectName=""
SccLocalPath=""
Keyword="MFCProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\../Debug"
IntermediateDirectory=".\../Debug/objd"
ConfigurationType="1"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../,../Common,../Common/WNT,../Common/ISession"
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;WNT"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="StdAfx.h"
PrecompiledHeaderFile=".\../Debug/objd/Approx.pch"
AssemblerListingLocation=".\../Debug/objd/"
ObjectFile=".\../Debug/objd/"
ProgramDataBaseFileName=".\../Debug/objd/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="TKBO.lib TKBool.lib TKCAF.lib TKCDF.lib TKDraw.lib TKernel.lib TKFeat.lib TKFillet.lib TKGeomAlgo.lib TKHLR.lib TKMath.lib TKOffset.lib TKPCAF.lib TKPrim.lib TKPShape.lib TKService.lib TKTopAlgo.lib TKV2d.lib TKV3d.lib TKBRep.lib TKG2d.lib TKG3d.lib TKGeomBase.lib"
OutputFile=".\../Debug/Approx.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\../Debug/Approx.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\../Debug/Approx.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\../Release"
IntermediateDirectory=".\../Release/obj"
ConfigurationType="1"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="../,../Common,../Common/WNT,../Common/ISession"
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;WNT"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="StdAfx.h"
PrecompiledHeaderFile=".\../Release/obj/Approx.pch"
AssemblerListingLocation=".\../Release/obj/"
ObjectFile=".\../Release/obj/"
ProgramDataBaseFileName=".\../Release/obj/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="TKBO.lib TKBool.lib TKCAF.lib TKCDF.lib TKDraw.lib TKernel.lib TKFeat.lib TKFillet.lib TKGeomAlgo.lib TKHLR.lib TKMath.lib TKOffset.lib TKPCAF.lib TKPrim.lib TKPShape.lib TKService.lib TKTopAlgo.lib TKV2d.lib TKV3d.lib TKBRep.lib TKG2d.lib TKG3d.lib TKGeomBase.lib"
OutputFile=".\../Release/Approx.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\../Release/Approx.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\../Release/Approx.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="Approx_Presentation.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="Approx_Presentation.h">
</File>
</Filter>
<Filter
Name="Common"
Filter="">
<File
RelativePath="..\env.bat">
</File>
<File
RelativePath="..\readme.txt">
</File>
<File
RelativePath="..\run.bat">
</File>
<File
RelativePath="..\vc.bat">
</File>
<Filter
Name="Source Files No. 1"
Filter="">
<File
RelativePath="..\Common\ISession\ISession_Curve.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\MainFrm.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\OCCDemo.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\OCCDemo.rc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="\RLS\tmp\demo\Common\WNT"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="\RLS\tmp\demo\Common\WNT"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\OCCDemo_Presentation.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\OCCDemoDoc.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\OCCDemoView.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\ResultDialog.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\StdAfx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files No. 1"
Filter="">
<File
RelativePath="..\Common\ISession\ISession_Curve.h">
</File>
<File
RelativePath="..\Common\WNT\MainFrm.h">
</File>
<File
RelativePath="..\Common\WNT\OCCDemo.h">
</File>
<File
RelativePath="..\Common\OCCDemo_Presentation.h">
</File>
<File
RelativePath="..\Common\WNT\OCCDemoDoc.h">
</File>
<File
RelativePath="..\Common\WNT\OCCDemoView.h">
</File>
<File
RelativePath="..\Common\WNT\resource.h">
</File>
<File
RelativePath="..\Common\WNT\ResultDialog.h">
</File>
<File
RelativePath="..\Common\WNT\StdAfx.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="">
<File
RelativePath="..\Common\WNT\res\OCCDemo.ico">
</File>
<File
RelativePath="..\Common\WNT\res\OCCDemo.rc2">
</File>
<File
RelativePath="..\Common\WNT\res\toolbar.bmp">
</File>
<File
RelativePath="..\Common\WNT\res\toolbar1.bmp">
</File>
</Filter>
</Filter>
<File
RelativePath="..\Common\WNT\res\occ_logo.bmp">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -1,603 +0,0 @@
// Approx_Presentation.cpp: implementation of the Approx_Presentation class.
// Approximation of curves and surfaces from points.
////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Approx_Presentation.h"
#include <GeomAPI_PointsToBSpline.hxx>
#include <GeomAPI_PointsToBSplineSurface.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <gp_Pnt.hxx>
#ifdef WNT
#define EOL "\r\n"
#else
#define EOL "\n"
#endif
#define SCALE 100
// Initialization of global variable with an instance of this class
OCCDemo_Presentation* OCCDemo_Presentation::Current = new Approx_Presentation;
// Initialization of array of samples
const Approx_Presentation::PSampleFuncType Approx_Presentation::SampleFuncs[] =
{
&Approx_Presentation::sample1,
&Approx_Presentation::sample2,
&Approx_Presentation::sample3,
&Approx_Presentation::sample4
};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Approx_Presentation::Approx_Presentation()
{
myIndex = 0;
myNbSamples = sizeof(SampleFuncs)/sizeof(PSampleFuncType);
setName ("Approximation of curves and surfaces.");
}
//////////////////////////////////////////////////////////////////////
// Sample execution
//////////////////////////////////////////////////////////////////////
void Approx_Presentation::DoSample()
{
getAISContext()->EraseAll();
if (myIndex >=0 && myIndex < myNbSamples)
(this->*SampleFuncs[myIndex])();
}
//////////////////////////////////////////////////////////////////////
// Sample functions
//////////////////////////////////////////////////////////////////////
//================================================================
//defining the data of BSpline curves and surfaces:
static Standard_Real Tol [] =
{
0.5*SCALE,
0.7*SCALE,
0.4*SCALE,
1*SCALE
};
static Standard_Integer DegMin [] =
{
2,3,5,7
};
static Standard_Integer DegMax [] =
{
7,9,10,12
};
static GeomAbs_Shape Continuity [] =
{
GeomAbs_C2, GeomAbs_C1, GeomAbs_C2, GeomAbs_C3
};
//================================================================
// Function : Comment
// Purpose :
//================================================================
static TCollection_AsciiString Comment(Standard_Real Step,
Standard_Integer Upper,
Standard_Integer DegMin,
Standard_Integer DegMax,
Standard_Integer Indicator,
Standard_Real Tol)
{
TCollection_AsciiString aText;
aText = (
"/////////////////////////////////////////////////////////////////" EOL
"// Approximation of surface." EOL
"// Building a BSpline surface which approximates a set of points." EOL
"/////////////////////////////////////////////////////////////////" EOL EOL
"// creating a set of points:" EOL
);
aText += "Standard_Real Step = ";
aText += TCollection_AsciiString(Step);
aText += ";" EOL;
aText += "Standard_Integer Upper = ";
aText += TCollection_AsciiString(Upper);
aText += ";" EOL EOL;
aText += (
" //a set of X and Y coordinates:" EOL
" Standard_Real aXStep = Step , aYStep = Step ;" EOL
" Standard_Real aX0 = -300, aY0 = -200;" EOL
" //Z coordinates:" EOL
" TColStd_Array2OfReal aZPoints( 1, Upper , 1, Upper );" EOL EOL
"// initializing array of Z coordinates:" EOL
"// aZPoints(1,1) = -2;" EOL
"// aZPoints(1,2) = 3;" EOL
"// ..." EOL EOL
"//creating a approximate BSpline surface:" EOL
);
aText += "Parameters of surface:" EOL ;
aText += "DegMin = ";
aText += TCollection_AsciiString(DegMin);
aText += ";" EOL;
aText += "DegMax = ";
aText += TCollection_AsciiString(DegMax);
aText += ";" EOL;
aText += "Continuity = " ;
if( Indicator == 2 )
aText += "GeomAbs_C1";
if( Indicator == 3 )
aText += "GeomAbs_C2";
if( Indicator == 4 )
aText += "GeomAbs_C3";
aText += ";" EOL;
aText += "Tolerance = ";
aText += TCollection_AsciiString(Tol/SCALE);
aText += ";" EOL EOL ;
aText += (
"GeomAPI_PointsToBSplineSurface aPTBS;" EOL
"aPTBS.Init(aZPoints,aX0,aXStep,aY0,aYStep," EOL
" DegMin,DegMax,Continuity,Tolerance);" EOL
"Handle(Geom_BSplineSurface) aSurface = aPTBS.Surface();" EOL EOL EOL
);
return aText;
}
//================================================================
// Function : Approx_Presentation::CreateBSplineSurface
// Purpose :
//================================================================
Handle(Geom_BSplineSurface) Approx_Presentation::CreateBSplineSurface(TColStd_Array2OfReal& aZPoints,
Standard_Real theXStep,
Standard_Real theYStep,
Standard_Integer Count)
{
Standard_Real aX0 = -300, aY0 = -200;
GeomAPI_PointsToBSplineSurface aPTBS;
aPTBS.Init(aZPoints,aX0,theXStep,aY0,theYStep,
DegMin[Count],DegMax[Count],Continuity[Count],Tol[Count]);
Handle(Geom_BSplineSurface) aSurface = aPTBS.Surface();
return aSurface;
}
//================================================================
// Function : Approx_Presentation::DrawModifyBSplineSurface
// Purpose :
//================================================================
Standard_Boolean Approx_Presentation::DrawModifyBSplineSurface(TColStd_Array2OfReal& aZPoints,
Standard_Real theXStep,
Standard_Real theYStep,
Standard_Integer theIndexX,
Standard_Integer theIndexY,
Standard_Real theDeflection,
Handle(AIS_InteractiveObject)& aMovePnt,
Handle(AIS_InteractiveObject)& aObj,
Standard_Integer Count)
{
Handle(AIS_InteractiveObject) auxObj;
Standard_Real aX0 = -300, aY0 = -200;
Standard_Real aLastZ = aZPoints(theIndexX,theIndexY);
aZPoints(theIndexX,theIndexY) += 100*theDeflection;
Standard_Real aCurrentX = aX0 + theXStep*(theIndexX-1),
aCurrentY = aY0 + theYStep*(theIndexY-1);
getAISContext()->Erase(aMovePnt);
aMovePnt = drawPoint(gp_Pnt(aCurrentX,aCurrentY,aZPoints(theIndexX,theIndexY)));
if(WAIT_A_LITTLE) return Standard_False;
GeomAPI_PointsToBSplineSurface aPTBS;
aPTBS.Init(aZPoints,aX0,theXStep,aY0,theYStep,
DegMin[Count],DegMax[Count],Continuity[Count],Tol[Count]);
aZPoints(theIndexX,theIndexY) = aLastZ;
Handle(Geom_BSplineSurface) aSurface = aPTBS.Surface();
auxObj = drawSurface(aSurface);
getAISContext()->Erase(aObj);
aObj = auxObj;
if(WAIT_A_SECOND) return Standard_False;
return Standard_True;
}
//================================================================
// Function : Approx_Presentation::sample1
// Purpose :
//================================================================
void Approx_Presentation::sample1()
{
Standard_Integer Count = 0;
TCollection_AsciiString aText = (
"//////////////////////////////////////////////////////////////" EOL
"// Approximation of curve." EOL
"// Building a BSpline curve which approximates a set of points." EOL
"//////////////////////////////////////////////////////////////" EOL EOL
"// creating a set of points to approximate," EOL
"// nPoint is the number of points:" EOL
"Standard_Integer nPoint = 20;" EOL
"TColgp_Array1OfPnt aCurvePoint (1, nPoint);" EOL EOL
"// initializing this array of points:" EOL
"// aCurvePoint(1,1) = gp_Pnt(-6,1,0);" EOL
"// aCurvePoint(1,2) = gp_Pnt(-5,1.5,0);" EOL
"// ..." EOL EOL
"//creating an empty approximation algorithm:" EOL
"GeomAPI_PointsToBSpline aPTB;" EOL EOL
"//creating a approximate BSpline curve:" EOL
);
aText += "//parameters of curve:" EOL ;
aText += "DegMin = ";
aText += TCollection_AsciiString(DegMin[Count]);
aText += ";" EOL;
aText += "DegMax = ";
aText += TCollection_AsciiString(DegMax[Count]);
aText += ";" EOL;
aText += "Continuity = GeomAbs_C2" ;
aText += ";" EOL;
aText += "Tolerance = ";
aText += TCollection_AsciiString(Tol[Count]/SCALE);
aText += ";" EOL EOL ;
aText += (
"aPTB.Init(aCurvePoint,DegMin,DegMax,Continuity,Tolerance);" EOL
"Handle(Geom_BSplineCurve) aCurve = aPTB.Curve();" EOL
);
setResultTitle("Creating approximations of curves");
setResultText(aText.ToCString());
getAISContext()->EraseAll();
Standard_Real aCoords[][3] = {
{-6,1,0},{-5,1.5,0},{-4,2,0},{-3.5,3,0},{-3,2.7,0},{-2,2.5,0},{-1.5,1,0},{-1,0.5,0},
{0,0,0},{1,0.3,0},{2,1,0},{3,1.5,0},{4,2.3,0},{5,2.7,0},{5.5,3.2,0},{6,2.5,0},
{7,2,0},{7.5,1,0},{8,0,0},{8.5,-1,0}
};
Standard_Integer nPoint = sizeof(aCoords)/(sizeof(Standard_Real)*3);
TColgp_Array1OfPnt aCurvePoint (1, nPoint);
GeomAPI_PointsToBSpline aPTB;
Handle(AIS_InteractiveObject) aIndexPnt [2],aObj;
Standard_Integer aIndex[2] = {9,13};
Standard_Real aDeflection[2] = {-1.5,2};
for (Standard_Integer i=0; i < nPoint; i++)
{
aCurvePoint(i+1) = gp_Pnt (aCoords[i][0]*SCALE-100, aCoords[i][1]*SCALE-100, aCoords[i][2]*SCALE);
if( i+1 == aIndex[0])
aIndexPnt[0] = drawPoint(aCurvePoint(aIndex[0]));
if( i+1 == aIndex[1])
aIndexPnt[1] = drawPoint(aCurvePoint(aIndex[1]));
if( i+1 != aIndex[0] && i+1 != aIndex[1])
drawPoint(aCurvePoint(i+1));
}
if(WAIT_A_LITTLE) return;
aPTB.Init(aCurvePoint,DegMin[Count],DegMax[Count],Continuity[Count],Tol[Count]);
Handle(Geom_BSplineCurve) aCurve = aPTB.Curve();
aObj = drawCurve(aCurve);
for( i = 0 ; i < 2 ; i++)
{
if (WAIT_A_SECOND) return;
getAISContext()->Erase(aIndexPnt[i]);
aCurvePoint(aIndex[i]) = gp_Pnt(aCurvePoint(aIndex[i]).X()-SCALE*aDeflection[i],
aCurvePoint(aIndex[i]).Y()+SCALE*aDeflection[i],
aCurvePoint(aIndex[i]).Z());
aIndexPnt[i] = drawPoint(aCurvePoint(aIndex[i]));
aPTB.Init(aCurvePoint,DegMin[Count],DegMax[Count],Continuity[Count],Tol[Count]);
aCurve = aPTB.Curve();
if (WAIT_A_LITTLE) return;
getAISContext()->Erase(aObj);
aObj = drawCurve(aCurve);
}
}
//================================================================
// Function : Approx_Presentation::sample2
// Purpose :
//================================================================
void Approx_Presentation::sample2()
{
setResultTitle("Creating approximations of surfaces");
Standard_Integer Count = 1;
Standard_Real aZCoords [] =
{
{-1},{0},{0},{1},{0},{-1},{-1},{0},{0},{-1.5},{-2.5},{0},{1},{-2},{-3},{0}
};
Standard_Real aXStep = 175, aYStep = 175;
Standard_Real aX0 = -300, aY0 = -200;
Standard_Integer anUpper = 4;
TColStd_Array2OfReal aZPoints(1,anUpper,1,anUpper);
Standard_Integer aIndexX[] = { 4, 3, 2, 2, 1 };
Standard_Integer aIndexY[] = { 4, 3, 2, 3, 4 };
Standard_Real aDeflection[] = { 1.5, 2.5, 1.5, 1.5, -1 };
Standard_Integer aNumOfIndexPnt = sizeof(aIndexX)/sizeof(Standard_Integer);
TColgp_Array2OfPnt aPnt(1,4,1,4);
Handle(AIS_InteractiveObject) aShowPnt[4][4],aObj,aMovePnt;
Standard_Integer aColLength = aZPoints.ColLength();
Standard_Integer aRowLength = aZPoints.RowLength();
Standard_Integer aIndex = -1;
for(Standard_Integer i = 0 ; i < aRowLength ; i++)
{
for(Standard_Integer j = 0; j < aColLength ; j++)
{
aIndex++;
aZPoints(i+1,j+1) = aZCoords[aIndex];
}
}
Standard_Real auxY0,auxX0 = aX0 - aXStep;
for( i = 0 ; i < aColLength ; i++)
{
auxX0 += aXStep;
auxY0 = aY0 - aYStep;
for(Standard_Integer j = 0 ; j < aRowLength ; j++)
{
aZPoints(i+1,j+1) *=SCALE;
auxY0 += aYStep;
aPnt(i+1,j+1) = gp_Pnt (auxX0,auxY0,aZPoints(i+1,j+1));
aShowPnt[i][j] = drawPoint(aPnt(i+1,j+1));
}
}
if(WAIT_A_LITTLE) return ;
TCollection_AsciiString aText;
aText = Comment(aXStep,anUpper,DegMin[Count],DegMax[Count],Count+1,Tol[Count]);
setResultText(aText.ToCString());
Handle(Geom_BSplineSurface) aSurface = CreateBSplineSurface(aZPoints,aXStep,aYStep,Count);
aObj = drawSurface(aSurface);
Standard_Boolean aBool;
if(WAIT_A_LITTLE) return ;
for( i = 0 ; i < aNumOfIndexPnt ; i++)
{
aMovePnt = aShowPnt[aIndexX[i]-1][aIndexY[i]-1];
aBool = DrawModifyBSplineSurface(aZPoints,aXStep,aYStep,aIndexX[i],aIndexY[i],
aDeflection[i],aMovePnt,aObj,Count);
if(!aBool) return;
if( i < aNumOfIndexPnt - 1)
{
drawPoint(aPnt(aIndexX[i],aIndexY[i]));
getAISContext()->Erase(aMovePnt);
}
}
}
//================================================================
// Function : Approx_Presentation::sample3
// Purpose :
//================================================================
void Approx_Presentation::sample3()
{
setResultTitle("Creating approximations of surfaces");
Standard_Integer Count = 2;
Standard_Real aZCoords [] =
{
{-3},{-2.3},{-3},{-0.5},{-1},{-1},{-1},{-1},{0},{0},{0},{0},{1},{-1},{-1},{0}
};
Standard_Integer anUpper = 4;
TColStd_Array2OfReal aZPoints(1,anUpper,1,anUpper);
Standard_Integer aIndexX[] = {1, 2, 3, 4};
Standard_Integer aIndexY[] = {1, 2, 3, 4};
Standard_Real aDeflection[] = {1.5, 2, 1, 1.5};
Standard_Integer aNumOfIndexPnt = sizeof(aIndexX)/sizeof(Standard_Integer);
TColgp_Array2OfPnt aPnt(1,4,1,4);
Handle(AIS_InteractiveObject) aShowPnt[4][4],aObj,aMovePnt;
Standard_Integer aColLength = aZPoints.ColLength();
Standard_Integer aRowLength = aZPoints.RowLength();
Standard_Integer aIndex = -1;
for(Standard_Integer i = 0 ; i < aRowLength ; i++)
{
for(Standard_Integer j = 0; j < aColLength ; j++)
{
aIndex++;
aZPoints(i+1,j+1) = aZCoords[aIndex];
}
}
Standard_Real aXStep = 175, aYStep = 175;
Standard_Real aX0 = -300, aY0 = -200;
Standard_Real auxY0,auxX0 = aX0 - aXStep;
for( i = 0 ; i < aColLength ; i++)
{
auxX0 += aXStep;
auxY0 = aY0 - aYStep;
for(Standard_Integer j = 0 ; j < aRowLength ; j++)
{
aZPoints(i+1,j+1) *=SCALE;
auxY0 += aYStep;
aPnt(i+1,j+1) = gp_Pnt (auxX0,auxY0,aZPoints(i+1,j+1));
aShowPnt[i][j] = drawPoint(aPnt(i+1,j+1));
}
}
if(WAIT_A_LITTLE) return ;
TCollection_AsciiString aText;
aText += Comment(aXStep,anUpper,DegMin[Count],DegMax[Count],Count+1,Tol[Count]);
setResultText(aText.ToCString());
Handle(Geom_BSplineSurface) aSurface = CreateBSplineSurface(aZPoints,aXStep,aYStep,Count);
aObj = drawSurface(aSurface);
Standard_Boolean aBool;
if(WAIT_A_LITTLE) return ;
for( i = 0 ; i < aNumOfIndexPnt ; i++)
{
aMovePnt = aShowPnt[aIndexX[i]-1][aIndexY[i]-1];
aBool = DrawModifyBSplineSurface(aZPoints,aXStep,aYStep,aIndexX[i],aIndexY[i],
aDeflection[i],aMovePnt,aObj,Count);
if(!aBool) return;
if( i < aNumOfIndexPnt - 1)
{
drawPoint(aPnt(aIndexX[i],aIndexY[i]));
getAISContext()->Erase(aMovePnt);
}
}
}
//================================================================
// Function : Approx_Presentation::sample4
// Purpose :
//================================================================
void Approx_Presentation::sample4()
{
setResultTitle("Creating approximations of surfaces");
Standard_Integer Count = 3;
Standard_Real aZCoords [] =
{
{-1.5},{0.5},{1},{0.5},{-1.5},{0},{-0.5},{0},{-0.5},{0},{1},{-0.5},{0},{-0.5},{1},{0},{-0.5},
{0},{-0.5},{0},{-1.5},{0.5},{1},{0.5},{-1.5}
};
Standard_Integer anUpper = 5;
TColStd_Array2OfReal aZPoints(1,anUpper,1,anUpper);
Standard_Integer aIndexX[] = { 1, 3, 5 };
Standard_Integer aIndexY[] = { 3, 3, 3 };
Standard_Real aDeflection[] = {-2, 1, -2 };
Standard_Integer aNumOfIndexPnt = sizeof(aIndexX)/sizeof(Standard_Integer);
TColgp_Array2OfPnt aPnt(1,5,1,5);
Handle(AIS_InteractiveObject) aShowPnt[5][5],aObj,aMovePnt;
Standard_Integer aColLength = aZPoints.ColLength();
Standard_Integer aRowLength = aZPoints.RowLength();
Standard_Integer aIndex = -1;
for(Standard_Integer i = 0 ; i < aRowLength ; i++)
{
for(Standard_Integer j = 0; j < aColLength ; j++)
{
aIndex++;
aZPoints(i+1,j+1) = aZCoords[aIndex];
}
}
Standard_Real aXStep = 140, aYStep = 140;
Standard_Real aX0 = -300, aY0 = -200;
Standard_Real auxY0,auxX0 = aX0 - aXStep;
for( i = 0 ; i < aColLength ; i++)
{
auxX0 += aXStep;
auxY0 = aY0 - aYStep;
for(Standard_Integer j = 0 ; j < aRowLength ; j++)
{
aZPoints(i+1,j+1) *=SCALE;
auxY0 += aYStep;
aPnt(i+1,j+1) = gp_Pnt (auxX0,auxY0,aZPoints(i+1,j+1));
aShowPnt[i][j] = drawPoint(aPnt(i+1,j+1));
}
}
if(WAIT_A_LITTLE) return ;
TCollection_AsciiString aText;
aText += Comment(aXStep,anUpper,DegMin[Count],DegMax[Count],Count+1,Tol[Count]);
setResultText(aText.ToCString());
Handle(Geom_BSplineSurface) aSurface = CreateBSplineSurface(aZPoints,aXStep,aYStep,Count);
aObj = drawSurface(aSurface);
Standard_Boolean aBool;
if(WAIT_A_LITTLE) return ;
for( i = 0 ; i < aNumOfIndexPnt ; i++)
{
aMovePnt = aShowPnt[aIndexX[i]-1][aIndexY[i]-1];
aBool = DrawModifyBSplineSurface(aZPoints,aXStep,aYStep,aIndexX[i],aIndexY[i],
aDeflection[i],aMovePnt,aObj,Count);
if(!aBool) return;
if( i < aNumOfIndexPnt - 1)
{
drawPoint(aPnt(aIndexX[i],aIndexY[i]));
getAISContext()->Erase(aMovePnt);
}
}
}

View File

@@ -1,50 +0,0 @@
// Approx_Presentation.h: interface for the Approx_Presentation class.
// Presentation class: Approximation of curves and surfaces.
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_Approx_PRESENTATION_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_)
#define AFX_Approx_PRESENTATION_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <OCCDemo_Presentation.h>
#include <Geom_BSplineSurface.hxx>
class Approx_Presentation : public OCCDemo_Presentation
{
public:
// Construction
Approx_Presentation();
public:
// Iteration on samples
virtual void DoSample();
// one phase of iterations
private:
// Sample functions
void sample1();
void sample2();
void sample3();
void sample4();
Standard_Boolean DrawModifyBSplineSurface(TColStd_Array2OfReal& ,
Standard_Real ,Standard_Real ,
Standard_Integer ,Standard_Integer ,
Standard_Real,Handle(AIS_InteractiveObject)&,
Handle(AIS_InteractiveObject)&,
Standard_Integer);
Handle(Geom_BSplineSurface) CreateBSplineSurface(TColStd_Array2OfReal& ,
Standard_Real ,Standard_Real,
Standard_Integer);
private:
// Array of pointers to sample functions
typedef void (Approx_Presentation::*PSampleFuncType)();
static const PSampleFuncType SampleFuncs[];
};
#endif // !defined(AFX_Approx_PRESENTATION_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_)

View File

@@ -1,428 +0,0 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="Chamfers"
SccProjectName=""
SccLocalPath=""
Keyword="MFCProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\../Release"
IntermediateDirectory=".\../Release/obj"
ConfigurationType="1"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="../,../Common,../Common/WNT,../Common/ISession"
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;WNT"
StringPooling="TRUE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="StdAfx.h"
PrecompiledHeaderFile=".\../Release/obj/Chamfers.pch"
AssemblerListingLocation=".\../Release/obj/"
ObjectFile=".\../Release/obj/"
ProgramDataBaseFileName=".\../Release/obj/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="TKBool.lib TKCAF.lib TKCDF.lib TKDraw.lib TKernel.lib TKFeat.lib TKFillet.lib TKGeomAlgo.lib TKHLR.lib TKMath.lib TKOffset.lib TKPCAF.lib TKPrim.lib TKPShape.lib TKService.lib TKTopAlgo.lib TKV2d.lib TKV3d.lib TKBRep.lib TKG2d.lib TKG3d.lib TKGeomBase.lib TKBO.lib"
OutputFile=".\../Release/Chamfers.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\../Release/Chamfers.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\../Release/Chamfers.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\../Debug"
IntermediateDirectory=".\../Debug/objd"
ConfigurationType="1"
UseOfMFC="2"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../,../Common,../Common/WNT,../Common/ISession"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;WNT"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="StdAfx.h"
PrecompiledHeaderFile=".\../Debug/objd/Chamfers.pch"
AssemblerListingLocation=".\../Debug/objd/"
ObjectFile=".\../Debug/objd/"
ProgramDataBaseFileName=".\../Debug/objd/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="TKBO.lib TKBool.lib TKCAF.lib TKCDF.lib TKDraw.lib TKernel.lib TKFeat.lib TKFillet.lib TKGeomAlgo.lib TKHLR.lib TKMath.lib TKOffset.lib TKPCAF.lib TKPrim.lib TKPShape.lib TKService.lib TKTopAlgo.lib TKV2d.lib TKV3d.lib TKBRep.lib TKG2d.lib TKG3d.lib TKGeomBase.lib"
OutputFile=".\../Debug/Chamfers.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\../Debug/Chamfers.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\../Debug/Chamfers.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="Chamfers_Presentation.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="Chamfers_Presentation.h">
</File>
</Filter>
<Filter
Name="Common"
Filter="">
<File
RelativePath="..\env.bat">
</File>
<File
RelativePath="..\readme.txt">
</File>
<File
RelativePath="..\run.bat">
</File>
<File
RelativePath="..\vc.bat">
</File>
<Filter
Name="Source Files No. 1"
Filter="">
<File
RelativePath="..\Common\ISession\ISession_Curve.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\MainFrm.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\OCCDemo.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\OCCDemo.rc">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="\RLS\tmp\demo\Common\WNT"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="\RLS\tmp\demo\Common\WNT"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\OCCDemo_Presentation.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\OCCDemoDoc.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\OCCDemoView.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\ResultDialog.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
<File
RelativePath="..\Common\WNT\StdAfx.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files No. 1"
Filter="">
<File
RelativePath="..\Common\ISession\ISession_Curve.h">
</File>
<File
RelativePath="..\Common\WNT\MainFrm.h">
</File>
<File
RelativePath="..\Common\WNT\OCCDemo.h">
</File>
<File
RelativePath="..\Common\OCCDemo_Presentation.h">
</File>
<File
RelativePath="..\Common\WNT\OCCDemoDoc.h">
</File>
<File
RelativePath="..\Common\WNT\OCCDemoView.h">
</File>
<File
RelativePath="..\Common\WNT\resource.h">
</File>
<File
RelativePath="..\Common\WNT\ResultDialog.h">
</File>
<File
RelativePath="..\Common\WNT\StdAfx.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="">
<File
RelativePath="..\Common\WNT\res\OCCDemo.ico">
</File>
<File
RelativePath="..\Common\WNT\res\OCCDemo.rc2">
</File>
<File
RelativePath="..\Common\WNT\res\toolbar.bmp">
</File>
<File
RelativePath="..\Common\WNT\res\toolbar1.bmp">
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -1,781 +0,0 @@
// Chamfers_Presentation.cpp: implementation of the Chamfers_Presentation class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Chamfers_Presentation.h"
#ifdef WNT
#pragma warning (disable : 4786)
#endif
#include <TopoDS_Edge.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepAlgo_Fuse.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepFilletAPI_MakeChamfer.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS.hxx>
#include <TopOpeBRepBuild_HBuilder.hxx>
#include <Precision.hxx>
#ifdef WNT
#define EOL "\r\n"
#else
#define EOL "\n"
#endif
#define BOX_SIDE_LEN 500
// Initialization of global variable with an instance of this class
OCCDemo_Presentation* OCCDemo_Presentation::Current = new Chamfers_Presentation;
// Initialization of array of samples
const Chamfers_Presentation::PSampleFuncType Chamfers_Presentation::SampleFuncs[] =
{
&Chamfers_Presentation::sampleBoxChamfer,
&Chamfers_Presentation::sampleBoxCylChamfer,
&Chamfers_Presentation::sampleBoxCylAngChamfer,
&Chamfers_Presentation::sampleBoxFillet,
&Chamfers_Presentation::sampleBoxCylFillet,
&Chamfers_Presentation::sampleBoxCylAngFillet
};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Chamfers_Presentation::Chamfers_Presentation()
{
myIndex = 0;
myNbSamples = sizeof(SampleFuncs)/sizeof(PSampleFuncType);
setName ("Chamfers and Fillets");
}
//////////////////////////////////////////////////////////////////////
// Sample execution
//////////////////////////////////////////////////////////////////////
void Chamfers_Presentation::DoSample()
{
getAISContext()->EraseAll();
if (myIndex >=0 && myIndex < myNbSamples)
(this->*SampleFuncs[myIndex])();
}
//////////////////////////////////////////////////////////////////////
// Sample functions
//////////////////////////////////////////////////////////////////////
//================================================================
// Function : createDiverseChamferOnBox
// Purpose : makes chamfers of different size on 3 converging edges
// of the given box using given distances d1, d2, d3;
// outputs its own source code into result dialog
//================================================================
Standard_Boolean Chamfers_Presentation::createDiverseChamferOnBox(
TopoDS_Solid& aBox,
Standard_Real d1, // chamfer on edge 1
Standard_Real d2, // chamfer on edge 2
Standard_Real d3, // chamfer on edge 3
Handle(AIS_InteractiveObject)& thePrevShape)// for smoth drawing
// we display the new shape first, then erase the previous one
{
// initializing a class that builds chamfer
BRepFilletAPI_MakeChamfer aMakeChamfer(aBox);
// a map of "edge-to-list of faces". Key = edge, value = list of 2 faces
// of the box that "touch" the edge
TopTools_IndexedDataMapOfShapeListOfShape aMapOfEdgeToFaces;
// filling the map with edges and faces of the box
TopExp::MapShapesAndAncestors(aBox, TopAbs_EDGE, TopAbs_FACE, aMapOfEdgeToFaces);
// array of indexes of edges to be chamfered
int aEdgeInd[] = {6, 2, 10, 12, 5};
// creating chamfer on one of an edge of the top face, using d1
if (d1 > Precision::Confusion())
{
TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdgeToFaces.FindKey(aEdgeInd[0]));
TopoDS_Face aFace = TopoDS::Face(aMapOfEdgeToFaces.FindFromKey(anEdge).First());
aMakeChamfer.Add(d1, d1, anEdge, aFace);
}
// creating chamfer on the other 3 edges of the top face, using d2
if (d2 > Precision::Confusion())
{
for (Standard_Integer i = 1; i <= 3; i++)
{
TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdgeToFaces.FindKey(aEdgeInd[i]));
TopoDS_Face aFace = TopoDS::Face(aMapOfEdgeToFaces.FindFromKey(anEdge).First());
aMakeChamfer.Add(d2, d2, anEdge, aFace);
}
}
// creating chamfer on a vertical edge of box, using d3
if (d3 > Precision::Confusion())
{
TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdgeToFaces.FindKey(aEdgeInd[4]));
TopoDS_Face aFace = TopoDS::Face(aMapOfEdgeToFaces.FindFromKey(anEdge).First());
aMakeChamfer.Add(d3, d3, anEdge, aFace);
}
aMakeChamfer.Build();
if (aMakeChamfer.IsDone())
{
Handle(AIS_InteractiveObject) aNewShape = new AIS_Shape(aMakeChamfer.Shape());
getAISContext()->Erase(thePrevShape, Standard_False);
thePrevShape = aNewShape;
getAISContext()->Display(aNewShape);
}
TCollection_AsciiString aText;
aText = aText +
" // creating a box and centering it on the screen" EOL
" Standard_Real a = "+TCollection_AsciiString(BOX_SIDE_LEN)+";" EOL
" TopoDS_Solid aBox = BRepPrimAPI_MakeBox(gp_Pnt(-a/2, -a/2, -a/2), a, a, a);" EOL EOL
" // initializing a class that builds chamfer" EOL
" BRepFilletAPI_MakeChamfer aMakeChamfer(aBox);" EOL EOL
" // a map of \"edge-to-list of faces\". Key = edge, value = list of 2 faces " EOL
" // of the box that \"touch\" the edge" EOL
" TopTools_IndexedDataMapOfShapeListOfShape aMapOfEdgeToFaces;" EOL
" // filling the map with edges and faces of the box" EOL
" TopExp::MapShapesAndAncestors(aBox, TopAbs_EDGE, TopAbs_FACE, aMapOfEdgeToFaces);" EOL
"" EOL
" Standard_Real d1 = "+TCollection_AsciiString(d1)+";" EOL
" Standard_Real d2 = "+TCollection_AsciiString(d2)+";" EOL
" Standard_Real d3 = "+TCollection_AsciiString(d3)+";" EOL
"" EOL
" // array of indexes of edges to be chamfered" EOL
" int aEdgeInd[] = {6, 2, 10, 12, 5};" EOL
"" EOL
" // creating chamfer on one of an edge of the top face, using d1" EOL
" if (d1 > Precision::Confusion())" EOL
" {" EOL
" TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdgeToFaces.FindKey(aEdgeInd[0]));" EOL
" TopoDS_Face aFace = TopoDS::Face(aMapOfEdgeToFaces.FindFromKey(anEdge).First());" EOL
" aMakeChamfer.Add(d1, d1, anEdge, aFace);" EOL
" }" EOL
"" EOL
" // creating chamfer on the other 3 edges of the top face, using d2" EOL
" if (d2 > Precision::Confusion())" EOL
" {" EOL
" for (Standard_Integer i = 1; i <= 3; i++)" EOL
" {" EOL
" TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdgeToFaces.FindKey(aEdgeInd[i]));" EOL
" TopoDS_Face aFace = TopoDS::Face(aMapOfEdgeToFaces.FindFromKey(anEdge).First());" EOL
" aMakeChamfer.Add(d2, d2, anEdge, aFace);" EOL
" }" EOL
" }" EOL
"" EOL
" // creating chamfer on a vertical edge of box, using d3" EOL
" if (d3 > Precision::Confusion())" EOL
" {" EOL
" TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdgeToFaces.FindKey(aEdgeInd[4]));" EOL
" TopoDS_Face aFace = TopoDS::Face(aMapOfEdgeToFaces.FindFromKey(anEdge).First());" EOL
" aMakeChamfer.Add(d3, d3, anEdge, aFace);" EOL
" }" EOL
" " EOL
" aMakeChamfer.Build();" EOL
" if (aMakeChamfer.IsDone())" EOL
" TopoDS_Shape aChamferedShape = aMakeChamfer.Shape();" EOL;
setResultText(aText.ToCString());
return WAIT_A_SECOND;
}
//================================================================
// Function : createChamferOnBox
// Purpose : makes chamfers on edges of the top face of the given box
// using given distances theDistA and theDistB, outputs its own
// source code into result dialog
//================================================================
Standard_Boolean Chamfers_Presentation::createChamferOnBox(
TopoDS_Solid& aBox,
Standard_Real theDistA, // distance along first face
Standard_Real theDistB, // distance along second face
Handle(AIS_InteractiveObject)& thePrevShape)// for smoth drawing
// we display the new shape first, then erase the previous one
{
// initializing a class that builds chamfer
BRepFilletAPI_MakeChamfer aMakeChamfer(aBox);
// a map of "edge-to-list of faces". Key = edge, value = list of 2 faces
// of the box that "touch" the edge
TopTools_IndexedDataMapOfShapeListOfShape aMapOfEdgeToFaces;
// filling the map with edges and faces of the box
TopExp::MapShapesAndAncestors(aBox, TopAbs_EDGE, TopAbs_FACE, aMapOfEdgeToFaces);
// array of indexes of edges to be chamfered
int aEdgeInd[] = {2, 6, 10, 12};
// building chamfers
for (int i = 0; i <= sizeof(aEdgeInd)/sizeof(int)-1; i++)
//for (int i = 1; i <= 12; i++) // uncomment to iterate through ALL edges of the box
{
TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdgeToFaces.FindKey(aEdgeInd[i]));
//TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdgeToFaces.FindKey(i));
// uncomment to iterate through ALL edges of the box
const TopTools_ListOfShape& aFaces = aMapOfEdgeToFaces.FindFromKey(anEdge);
TopoDS_Face aFace = TopoDS::Face(aFaces.First());
aMakeChamfer.Add(theDistA, theDistB, anEdge, aFace);
}
aMakeChamfer.Build();
if (aMakeChamfer.IsDone())
{
Handle(AIS_InteractiveObject) aNewShape = new AIS_Shape(aMakeChamfer.Shape());
getAISContext()->Erase(thePrevShape, Standard_False);
getAISContext()->Display(aNewShape, Standard_True);
thePrevShape = aNewShape;
}
TCollection_AsciiString aText;
aText = aText +
" // creating a box and centering it on the screen" EOL
" Standard_Real a = "+TCollection_AsciiString(BOX_SIDE_LEN)+";" EOL
" TopoDS_Solid aBox = BRepPrimAPI_MakeBox(gp_Pnt(-a/2, -a/2, -a/2), a, a, a);" EOL EOL
" // initializing a class that builds chamfer" EOL
" BRepFilletAPI_MakeChamfer aMakeChamfer(aBox);" EOL EOL
" // a map of \"edge-to-list of faces\". Key = edge, value = list of 2 faces " EOL
" // of the box that \"touch\" the edge" EOL
" TopTools_IndexedDataMapOfShapeListOfShape aMapOfEdgeToFaces;" EOL
" // filling the map with edges and faces of the box" EOL
" TopExp::MapShapesAndAncestors(aBox, TopAbs_EDGE, TopAbs_FACE, aMapOfEdgeToFaces);" EOL
"" EOL
" Standard_Real aDistA = "+TCollection_AsciiString(theDistA)+";" EOL
" Standard_Real aDistB = "+TCollection_AsciiString(theDistB)+";" EOL
"" EOL
" // array of indexes of edges to be chamfered" EOL
" int aEdgeInd[] = {2, 6, 10, 12};" EOL EOL
" // building chamfers" EOL
" for (int i = 0; i <= sizeof(aEdgeInd)/sizeof(int)-1; i++)" EOL
" {" EOL
" TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdgeToFaces.FindKey(aEdgeInd[i]));" EOL
" const TopTools_ListOfShape& aFaces = aMapOfEdgeToFaces.FindFromKey(anEdge);" EOL
" TopoDS_Face aFace = TopoDS::Face(aFaces.First());" EOL
" // creating a chamfer with lengths aDistA, aDistB" EOL
" aMakeChamfer.Add(aDistA, aDistB, anEdge, aFace);" EOL
" }" EOL EOL
" aMakeChamfer.Build();" EOL
" if (aMakeChamfer.IsDone())" EOL
" TopoDS_Shape aChamferedShape = aMakeChamfer.Shape();" EOL;
setResultText(aText.ToCString());
return WAIT_A_SECOND;
}
//================================================================
// Function : createFilletOnBox
// Purpose : creates a box with side=10, makes fillets on some of its edges
// using given value of radius and shape of fillet, outputs its own
// source code into theText parameter
//================================================================
Standard_Boolean Chamfers_Presentation::createFilletOnBox(
TopoDS_Solid& aBox,
Standard_Real theRad, // radius of fillet
ChFi3d_FilletShape theFShape, // shape of fillet
Handle(AIS_InteractiveObject)& thePrevObj) // to erase
// the previous shape
{
// initializing a class that builds fillet
// second parameter is a shape of fillet:
// enum ChFi3d_FilletShape { ChFi3d_Rational, ChFi3d_QuasiAngular, ChFi3d_Polynomial };
BRepFilletAPI_MakeFillet aMakeFillet(aBox, theFShape);
// a map of edges
TopTools_IndexedMapOfShape aMapOfEdges;
// filling the map with edges of the box
TopExp::MapShapes(aBox, TopAbs_EDGE, aMapOfEdges);
// array of indexes of edges to be chamfered
int aEdgeInd[] = {2, 6, 10, 12};
// adding edges that will have fillet
for (int i = 0; i <= sizeof(aEdgeInd)/sizeof(int)-1; i++)
{
TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdges(aEdgeInd[i]));
aMakeFillet.Add(theRad, anEdge);
}
aMakeFillet.Build();
if (aMakeFillet.IsDone())
{
Handle(AIS_InteractiveObject) aNewShape = new AIS_Shape(aMakeFillet.Shape());
getAISContext()->Erase(thePrevObj, Standard_False);
getAISContext()->Display(aNewShape, Standard_True);
thePrevObj = aNewShape;
}
// calculating the string corresponding to theFShape
TCollection_AsciiString aFShapeStr;
aFShapeStr = ((theFShape==ChFi3d_Rational)? "ChFi3d_Rational":
((theFShape==ChFi3d_QuasiAngular)? "ChFi3d_QuasiAngular":
"ChFi3d_Polynomial"));
TCollection_AsciiString aText;
aText = aText +
" // creating a box and centering it on the screen" EOL
" Standard_Real a = "+TCollection_AsciiString(BOX_SIDE_LEN)+";" EOL
" TopoDS_Solid aBox = BRepPrimAPI_MakeBox(gp_Pnt(-a/2, -a/2, -a/2), a, a, a);" EOL
" " EOL
" // initializing a class that builds fillet" EOL
" // second parameter is a shape of fillet:" EOL
" // enum ChFi3d_FilletShape { ChFi3d_Rational, ChFi3d_QuasiAngular, ChFi3d_Polynomial };" EOL
" BRepFilletAPI_MakeFillet aMakeFillet(aBox, "+aFShapeStr+");" EOL
" " EOL
" // a map of edges" EOL
" TopTools_IndexedMapOfShape aMapOfEdges;" EOL
" // filling the map with edges of the box" EOL
" TopExp::MapShapes(aBox, TopAbs_EDGE, aMapOfEdges);" EOL EOL
" // array of indexes of edges to be chamfered" EOL
" int aEdgeInd[] = {2, 6, 10, 12};" EOL EOL
" // adding edges that will have fillet" EOL
" Standard_Real r = "+TCollection_AsciiString(theRad)+";" EOL
" for (int i = 0; i <= sizeof(aEdgeInd)/sizeof(int)-1; i++)" EOL
" {" EOL
" TopoDS_Edge anEdge = TopoDS::Edge(aMapOfEdges(aEdgeInd[i]));" EOL
" aMakeFillet.Add(r, anEdge);" EOL
" }" EOL
" aMakeFillet.Build();" EOL
" if (aMakeFillet.IsDone())" EOL
" TopoDS_Shape aShapeWithFillet = aMakeFillet.Shape();" EOL;
setResultText(aText.ToCString());
return WAIT_A_SECOND;
}
// ===============================================================
// CHAMFER CASES
// ===============================================================
//================================================================
// Function : Chamfers_Presentation::sampleBoxChamfer1,2,3
// Purpose :
//================================================================
void Chamfers_Presentation::sampleBoxChamfer()
{
setResultTitle("Creating Chamfer");
TCollection_AsciiString aText;
aText = aText +
" // creating a box and centering it on the screen" EOL
" Standard_Real a = "+TCollection_AsciiString(BOX_SIDE_LEN)+";" EOL
" TopoDS_Solid aBox = BRepPrimAPI_MakeBox(gp_Pnt(-a/2, -a/2, -a/2), a, a, a);" EOL;
setResultText(aText.ToCString());
// show initial shape
Standard_Real a = BOX_SIDE_LEN;
TopoDS_Solid aBox = BRepPrimAPI_MakeBox(gp_Pnt(-a/2, -a/2, -a/2), a, a, a);
Handle(AIS_InteractiveObject) aPrevShape = new AIS_Shape(aBox);
getAISContext()->Display(aPrevShape, Standard_False);
COCCDemoDoc::Fit();
if (WAIT_A_SECOND) return;
// show several chamfers
if (createChamferOnBox(aBox, a/10, a/10, aPrevShape)) return;
if (createChamferOnBox(aBox, a/24, a/10, aPrevShape)) return;
if (createChamferOnBox(aBox, a/10, a/10, aPrevShape)) return;
if (createChamferOnBox(aBox, a/10, a/24, aPrevShape)) return;
if (createChamferOnBox(aBox, a/10, a/10, aPrevShape)) return;
if (createDiverseChamferOnBox(aBox, a/6, a/10, 0, aPrevShape)) return;
if (createDiverseChamferOnBox(aBox, a/6, a/10, a/24, aPrevShape)) return;
}
//================================================================
// Function : Chamfers_Presentation::sampleBoxCylChamfer
// Purpose : creates a more complecated chamfer on a shape created
// by fusing box and cylinder
//================================================================
void Chamfers_Presentation::sampleBoxCylChamfer()
{
setResultTitle("Creating Chamfer");
TCollection_AsciiString aText;
aText = aText +
" // creating a shape, a result of fusing of a box and cylinder" EOL
" Standard_Real a = "+TCollection_AsciiString(BOX_SIDE_LEN)+";" EOL
" Standard_Real b = a/2;" EOL
" BRepPrimAPI_MakeBox aBoxMaker (gp_Pnt(-b, -b, -b), a, a, a);" EOL
" BRepPrimAPI_MakeCylinder aCylMaker(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), a/4, a);" EOL
" BRepAlgoAPI_Fuse aFuser(aBoxMaker.Solid(), aCylMaker.Solid());" EOL
" aFuser.Build();" EOL EOL
" // initializing a class that builds chamfer" EOL
" BRepFilletAPI_MakeChamfer aMakeChamfer(aFuser.Shape());" EOL EOL
" // a map of \"edge-to-list of faces\". Key = edge, value = list of 2 faces " EOL
" // of the box that \"touch\" the edge" EOL
" TopTools_IndexedDataMapOfShapeListOfShape aMapOfEdgeToFaces;" EOL
" // filling the map with edges and faces of the box" EOL
" TopExp::MapShapesAndAncestors(aFuser.Shape(), TopAbs_EDGE, TopAbs_FACE, aMapOfEdgeToFaces);" EOL EOL
" // retrieving list of edges to build a chamfer on - edges of " EOL
" // intersection of the cylinder and the box" EOL
" const TopTools_ListOfShape& aEdgesOfIntersection = aFuser.Builder()->Section();" EOL
" TopTools_ListIteratorOfListOfShape anIntersectionEdgesIt(aEdgesOfIntersection);" EOL
"" EOL
" // creating fillet on edge intersection edges" EOL
" Standard_Real d = a/20;" EOL
" for (; anIntersectionEdgesIt.More(); anIntersectionEdgesIt.Next())" EOL
" {" EOL
" TopoDS_Edge anEdge = TopoDS::Edge(anIntersectionEdgesIt.Value());" EOL
" if (!aMapOfEdgeToFaces.Contains(anEdge)) continue;" EOL
" const TopTools_ListOfShape& aFaces = aMapOfEdgeToFaces.FindFromKey(anEdge);" EOL
" TopoDS_Face aFace = TopoDS::Face(aFaces.First());" EOL
" aMakeChamfer.Add(d, d, anEdge, aFace);" EOL
" }" EOL
" " EOL
" aMakeChamfer.Build();" EOL
" if (aMakeChamfer.IsDone())" EOL
" TopoDS_Shape aChamferedShape = aMakeChamfer.Shape();" EOL;
setResultText(aText.ToCString());
// creating a shape, a result of fusing of a box and cylinder
Standard_Real a = BOX_SIDE_LEN;
Standard_Real b = a/2;
BRepPrimAPI_MakeBox aBoxMaker (gp_Pnt(-b, -b, -b), a, a, a);
BRepPrimAPI_MakeCylinder aCylMaker(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), a/4, a);
BRepAlgo_Fuse aFuser(aBoxMaker.Solid(), aCylMaker.Solid());
aFuser.Build();
Handle(AIS_InteractiveObject) aPrevObj = new AIS_Shape(aFuser.Shape());
getAISContext()->Display(aPrevObj, Standard_False);
COCCDemoDoc::Fit();
if (WAIT_A_SECOND) return;
// initializing a class that builds chamfer
BRepFilletAPI_MakeChamfer aMakeChamfer(aFuser.Shape());
// a map of "edge-to-list of faces". Key = edge, value = list of 2 faces
// of the box that "touch" the edge
TopTools_IndexedDataMapOfShapeListOfShape aMapOfEdgeToFaces;
// filling the map with edges and faces of the box
TopExp::MapShapesAndAncestors(aFuser.Shape(), TopAbs_EDGE, TopAbs_FACE, aMapOfEdgeToFaces);
// retrieving list of edges to build a chamfer on - edges of
// intersection of the cylinder and the box
const TopTools_ListOfShape& aEdgesOfIntersection = aFuser.Builder()->Section();
TopTools_ListIteratorOfListOfShape anIntersectionEdgesIt(aEdgesOfIntersection);
// creating fillet on edge intersection edges
Standard_Real d = a/20;
for (; anIntersectionEdgesIt.More(); anIntersectionEdgesIt.Next())
{
TopoDS_Edge anEdge = TopoDS::Edge(anIntersectionEdgesIt.Value());
if (!aMapOfEdgeToFaces.Contains(anEdge)) continue;
const TopTools_ListOfShape& aFaces = aMapOfEdgeToFaces.FindFromKey(anEdge);
TopoDS_Face aFace = TopoDS::Face(aFaces.First());
aMakeChamfer.Add(d, d, anEdge, aFace);
}
aMakeChamfer.Build();
if (aMakeChamfer.IsDone())
{
getAISContext()->Erase(aPrevObj, Standard_False);
getAISContext()->Display(new AIS_Shape(aMakeChamfer.Shape()));
//aPrevObj = aNewShape;// uncomment if further thePrevObj is used
}
}
//================================================================
// Function : Chamfers_Presentation::sampleBoxCylAngChamfer
// Purpose : creates a more complecated chamfer on a shape created
// by fusing box and cylinder
//================================================================
void Chamfers_Presentation::sampleBoxCylAngChamfer()
{
setResultTitle("Creating Chamfer");
TCollection_AsciiString aText;
aText = aText +
" // creating a shape, a result of fusing of a box and cylinder" EOL
" Standard_Real a = "+TCollection_AsciiString(BOX_SIDE_LEN)+";" EOL
" Standard_Real b = a/2;" EOL
" BRepPrimAPI_MakeBox aBoxMaker (gp_Pnt(-b, -b, -b), a, a, a);" EOL
" BRepPrimAPI_MakeCylinder aCylMaker(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,-0.4,0.6)), a/4, a);" EOL
" BRepAlgoAPI_Fuse aFuser(aBoxMaker.Solid(), aCylMaker.Solid());" EOL
" aFuser.Build();" EOL EOL
" // initializing a class that builds chamfer" EOL
" BRepFilletAPI_MakeChamfer aMakeChamfer(aFuser.Shape());" EOL EOL
" // a map of \"edge-to-list of faces\". Key = edge, value = list of 2 faces " EOL
" // of the box that \"touch\" the edge" EOL
" TopTools_IndexedDataMapOfShapeListOfShape aMapOfEdgeToFaces;" EOL
" // filling the map with edges and faces of the box" EOL
" TopExp::MapShapesAndAncestors(aFuser.Shape(), TopAbs_EDGE, TopAbs_FACE, aMapOfEdgeToFaces);" EOL EOL
" // retrieving list of edges to build a chamfer on - edges of " EOL
" // intersection of the cylinder and the box" EOL
" const TopTools_ListOfShape& aEdgesOfIntersection = aFuser.Builder()->Section();" EOL
" TopTools_ListIteratorOfListOfShape anIntersectionEdgesIt(aEdgesOfIntersection);" EOL EOL
" // creating chamfer on intersection edges" EOL
" Standard_Real d = a/20;" EOL
" for (; anIntersectionEdgesIt.More(); anIntersectionEdgesIt.Next())" EOL
" {" EOL
" TopoDS_Edge anEdge = TopoDS::Edge(anIntersectionEdgesIt.Value());" EOL
" if (!aMapOfEdgeToFaces.Contains(anEdge)) continue;" EOL
" const TopTools_ListOfShape& aFaces = aMapOfEdgeToFaces.FindFromKey(anEdge);" EOL
" TopoDS_Face aFace = TopoDS::Face(aFaces.First());" EOL
" aMakeChamfer.Add(d, d, anEdge, aFace);" EOL
" }" EOL EOL
" aMakeChamfer.Build();" EOL
" if (aMakeChamfer.IsDone())" EOL
" TopoDS_Shape aChamferedShape = aMakeChamfer.Shape();" EOL;
setResultText(aText.ToCString());
// creating a shape, a result of fusing of a box and cylinder
Standard_Real a = BOX_SIDE_LEN;
Standard_Real b = a/2;
BRepPrimAPI_MakeBox aBoxMaker (gp_Pnt(-b, -b, -b), a, a, a);
BRepPrimAPI_MakeCylinder aCylMaker(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,-0.4,0.6)), a/4, a);
BRepAlgo_Fuse aFuser(aBoxMaker.Solid(), aCylMaker.Solid());
aFuser.Build();
Handle(AIS_InteractiveObject) aPrevObj = new AIS_Shape(aFuser.Shape());
getAISContext()->Display(aPrevObj, Standard_False);
COCCDemoDoc::Fit();
if (WAIT_A_SECOND) return;
// initializing a class that builds chamfer
BRepFilletAPI_MakeChamfer aMakeChamfer(aFuser.Shape());
// a map of "edge-to-list of faces". Key = edge, value = list of 2 faces
// of the box that "touch" the edge
TopTools_IndexedDataMapOfShapeListOfShape aMapOfEdgeToFaces;
// filling the map with edges and faces of the box
TopExp::MapShapesAndAncestors(aFuser.Shape(), TopAbs_EDGE, TopAbs_FACE, aMapOfEdgeToFaces);
// retrieving list of edges to build a chamfer on - edges of
// intersection of the cylinder and the box
const TopTools_ListOfShape& aEdgesOfIntersection = aFuser.Builder()->Section();
TopTools_ListIteratorOfListOfShape anIntersectionEdgesIt(aEdgesOfIntersection);
// creating fillet on edge intersection edges
Standard_Real d = a/20;
for (; anIntersectionEdgesIt.More(); anIntersectionEdgesIt.Next())
{
TopoDS_Edge anEdge = TopoDS::Edge(anIntersectionEdgesIt.Value());
if (!aMapOfEdgeToFaces.Contains(anEdge)) continue;
const TopTools_ListOfShape& aFaces = aMapOfEdgeToFaces.FindFromKey(anEdge);
TopoDS_Face aFace = TopoDS::Face(aFaces.First());
aMakeChamfer.Add(d, d, anEdge, aFace);
}
aMakeChamfer.Build();
if (aMakeChamfer.IsDone())
{
getAISContext()->Erase(aPrevObj, Standard_False);
getAISContext()->Display(new AIS_Shape(aMakeChamfer.Shape()));
//thePrevShape = aNewShape;// uncomment if further thePrevObj is used
}
}
// ===============================================================
// FILLET CASES
// ===============================================================
//================================================================
// Function : Chamfers_Presentation::sampleBoxFillet1,2,3
// Purpose :
//================================================================
void Chamfers_Presentation::sampleBoxFillet()
{
setResultTitle("Creating Fillet");
TCollection_AsciiString aText;
aText = aText +
" // creating a box and centering it on the screen" EOL
" Standard_Real a = "+TCollection_AsciiString(BOX_SIDE_LEN)+";" EOL
" TopoDS_Solid aBox = BRepPrimAPI_MakeBox(gp_Pnt(-a/2, -a/2, -a/2), a, a, a);" EOL;
setResultText(aText.ToCString());
// show initial shape
Standard_Real a = BOX_SIDE_LEN;
TopoDS_Solid aBox = BRepPrimAPI_MakeBox(gp_Pnt(-a/2, -a/2, -a/2), a, a, a);
Handle(AIS_InteractiveObject) aPrevObj = new AIS_Shape(aBox);
getAISContext()->Display(aPrevObj, Standard_False);
COCCDemoDoc::Fit();
if (WAIT_A_SECOND) return;
// show several fillets
if (createFilletOnBox(aBox, a/10, ChFi3d_Polynomial, aPrevObj)) return;
if (createFilletOnBox(aBox, a/5, ChFi3d_QuasiAngular, aPrevObj)) return;
if (createFilletOnBox(aBox, a/3.3, ChFi3d_Rational, aPrevObj)) return;
}
//================================================================
// Function : Chamfers_Presentation::sampleBoxCylFillet
// Purpose : creates a more complecated chamfer on a shape created
// by fusing box and cylinder
//================================================================
void Chamfers_Presentation::sampleBoxCylFillet()
{
setResultTitle("Creating Fillet");
TCollection_AsciiString aText;
aText = aText +
" // creating a shape - result of fusing a box and a cylinder" EOL
" Standard_Real a = "+TCollection_AsciiString(BOX_SIDE_LEN)+";" EOL
" Standard_Real b = a/2;" EOL
" BRepPrimAPI_MakeBox aBoxMaker (gp_Pnt(-b, -b, -b), a, a, a);" EOL
" BRepPrimAPI_MakeCylinder aCylMaker(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), a/4, a);" EOL
" BRepAlgoAPI_Fuse aFuser(aBoxMaker.Solid(), aCylMaker.Solid());" EOL
" aFuser.Build();" EOL EOL
" // initializing a class that builds fillet" EOL
" // second parameter is a shape of fillet:" EOL
" // enum ChFi3d_FilletShape { ChFi3d_Rational, ChFi3d_QuasiAngular, ChFi3d_Polynomial };" EOL
" BRepFilletAPI_MakeFillet aMakeFillet(aFuser.Shape(), ChFi3d_Rational);" EOL EOL
" // retrieving list of edges to build a chamfer on - edges of " EOL
" // intersection of the cylinder and the box" EOL
" const TopTools_ListOfShape& aEdgesOfIntersection = aFuser.Builder()->Section();" EOL
" TopTools_ListIteratorOfListOfShape anIntersectionEdgesIt(aEdgesOfIntersection);" EOL EOL
" // creating fillet on edge intersection edges" EOL
" Standard_Real d = a/10;" EOL
" for (; anIntersectionEdgesIt.More(); anIntersectionEdgesIt.Next())" EOL
" aMakeFillet.Add(d, TopoDS::Edge(anIntersectionEdgesIt.Value()));" EOL
"" EOL
" aMakeFillet.Build();" EOL EOL
" if (aMakeFillet.IsDone())" EOL
" TopoDS_Shape aShapeWithFillet = aMakeFillet.Shape();" EOL;
setResultText(aText.ToCString());
// creating a shape, a result of fusing of a box and cylinder
Standard_Real a = BOX_SIDE_LEN;
Standard_Real b = a/2;
BRepPrimAPI_MakeBox aBoxMaker (gp_Pnt(-b, -b, -b), a, a, a);
BRepPrimAPI_MakeCylinder aCylMaker(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), a/4, a);
BRepAlgo_Fuse aFuser(aBoxMaker.Solid(), aCylMaker.Solid());
aFuser.Build();
Handle(AIS_InteractiveObject) aPrevObj = new AIS_Shape(aFuser.Shape());
getAISContext()->Display(aPrevObj, Standard_False);
COCCDemoDoc::Fit();
if (WAIT_A_SECOND) return;
// initializing a class that builds fillet
// second parameter is a shape of fillet:
// enum ChFi3d_FilletShape { ChFi3d_Rational, ChFi3d_QuasiAngular, ChFi3d_Polynomial };
BRepFilletAPI_MakeFillet aMakeFillet(aFuser.Shape(), ChFi3d_Rational);
// retrieving list of edges to build a chamfer on - edges of
// intersection of the cylinder and the box
const TopTools_ListOfShape& aEdgesOfIntersection = aFuser.Builder()->Section();
TopTools_ListIteratorOfListOfShape anIntersectionEdgesIt(aEdgesOfIntersection);
// creating fillet on edge intersection edges
Standard_Real d = a/10;
for (; anIntersectionEdgesIt.More(); anIntersectionEdgesIt.Next())
aMakeFillet.Add(d, TopoDS::Edge(anIntersectionEdgesIt.Value()));
aMakeFillet.Build();
if (aMakeFillet.IsDone())
{
getAISContext()->Erase(aPrevObj, Standard_False);
//aPrevObj = new AIS_Shape(aMakeFillet.Shape());// uncomment if aPrevObj is used further
getAISContext()->Display(new AIS_Shape(aMakeFillet.Shape()));
}
}
//================================================================
// Function : Chamfers_Presentation::sampleBoxCylAngFillet
// Purpose : creates a fillet on a more complecated shape created
// by fusing box and cylinder
//================================================================
void Chamfers_Presentation::sampleBoxCylAngFillet()
{
setResultTitle("Creating Fillet");
TCollection_AsciiString aText;
aText = aText +
" // creating a shape - result of fusing a box and a cylinder" EOL
" Standard_Real a = "+TCollection_AsciiString(BOX_SIDE_LEN)+";" EOL
" Standard_Real b = a/2;" EOL
" BRepPrimAPI_MakeBox aBoxMaker (gp_Pnt(-b, -b, -b), a, a, a);" EOL
" BRepPrimAPI_MakeCylinder aCylMaker(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,-0.4,0.6)), a/4, a);" EOL
" BRepAlgoAPI_Fuse aFuser(aBoxMaker.Solid(), aCylMaker.Solid());" EOL
" aFuser.Build();" EOL EOL
" // initializing a class that builds fillet" EOL
" // second parameter is a shape of fillet:" EOL
" // enum ChFi3d_FilletShape { ChFi3d_Rational, ChFi3d_QuasiAngular, ChFi3d_Polynomial };" EOL
" BRepFilletAPI_MakeFillet aMakeFillet(aFuser.Shape(), ChFi3d_Rational);" EOL EOL
" // retrieving list of edges to build a chamfer on - edges of " EOL
" // intersection of the cylinder and the box" EOL
" const TopTools_ListOfShape& aEdgesOfIntersection = aFuser.Builder()->Section();" EOL
" TopTools_ListIteratorOfListOfShape anIntersectionEdgesIt(aEdgesOfIntersection);" EOL EOL
" // creating fillet on intersection edges" EOL
" Standard_Real d = a/10;" EOL
" for (; anIntersectionEdgesIt.More(); anIntersectionEdgesIt.Next())" EOL
" aMakeFillet.Add(d, TopoDS::Edge(anIntersectionEdgesIt.Value()));" EOL
" aMakeFillet.Build();" EOL EOL
" if (aMakeFillet.IsDone())" EOL
" TopoDS_Shape aShapeWithFillet = aMakeFillet.Shape();" EOL;
setResultText(aText.ToCString());
// creating a shape, a result of fusing of a box and cylinder
Standard_Real a = BOX_SIDE_LEN;
Standard_Real b = a/2;
BRepPrimAPI_MakeBox aBoxMaker (gp_Pnt(-b, -b, -b), a, a, a);
BRepPrimAPI_MakeCylinder aCylMaker(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,-0.4,0.6)), a/4, a);
BRepAlgo_Fuse aFuser(aBoxMaker.Solid(), aCylMaker.Solid());
aFuser.Build();
Handle(AIS_InteractiveObject) aPrevObj = new AIS_Shape(aFuser.Shape());
getAISContext()->Display(aPrevObj, Standard_False);
COCCDemoDoc::Fit();
if (WAIT_A_SECOND) return;
// initializing a class that builds fillet
// second parameter is a shape of fillet:
// enum ChFi3d_FilletShape { ChFi3d_Rational, ChFi3d_QuasiAngular, ChFi3d_Polynomial };
BRepFilletAPI_MakeFillet aMakeFillet(aFuser.Shape(), ChFi3d_Rational);
// retrieving list of edges to build a chamfer on - edges of
// intersection of the cylinder and the box
const TopTools_ListOfShape& aEdgesOfIntersection = aFuser.Builder()->Section();
TopTools_ListIteratorOfListOfShape anIntersectionEdgesIt(aEdgesOfIntersection);
// creating fillet on edge intersection edges
Standard_Real d = a/10;
for (; anIntersectionEdgesIt.More(); anIntersectionEdgesIt.Next())
aMakeFillet.Add(d, TopoDS::Edge(anIntersectionEdgesIt.Value()));
aMakeFillet.Build();
if (aMakeFillet.IsDone())
{
getAISContext()->Erase(aPrevObj, Standard_False);
//aPrevObj = new AIS_Shape(aMakeFillet.Shape());// uncomment if aPrevObj is used further
getAISContext()->Display(new AIS_Shape(aMakeFillet.Shape()));
}
}

View File

@@ -1,57 +0,0 @@
// Chamfers_Presentation.h: interface for the Chamfers_Presentation class.
// Presentation class: Example on chamfers and fillets
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_Chamfers_PRESENTATION_H)
#define AFX_Chamfers_PRESENTATION_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <OCCDemo_Presentation.h>
#include <ChFi3d_FilletShape.hxx>
class AIS_InteractiveObject;
class TopoDS_Solid;
class Chamfers_Presentation : public OCCDemo_Presentation
{
public:
// Construction
Chamfers_Presentation();
public:
// Iteration on samples
virtual void DoSample();
// one phase of iterations
private:
Standard_Boolean createChamferOnBox(
TopoDS_Solid&, Standard_Real, Standard_Real,
Handle(AIS_InteractiveObject)&);
Standard_Boolean createDiverseChamferOnBox(
TopoDS_Solid&, Standard_Real, Standard_Real,
Standard_Real, Handle(AIS_InteractiveObject)&);
Standard_Boolean createFilletOnBox(
TopoDS_Solid&, Standard_Real, ChFi3d_FilletShape,
Handle(AIS_InteractiveObject)&);
// Sample functions
void sampleBoxChamfer();
void sampleBoxFillet();
void sampleBoxCylChamfer();
void sampleBoxCylAngChamfer();
void sampleBoxCylFillet();
void sampleBoxCylAngFillet();
private:
// Array of pointers to sample functions
typedef void (Chamfers_Presentation::*PSampleFuncType)();
static const PSampleFuncType SampleFuncs[];
};
#endif // !defined(AFX_Chamfers_PRESENTATION_H)

View File

@@ -1,77 +0,0 @@
// ISession_Curve.cpp: implementation of the ISession_Curve class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ISession_Curve.h"
#include <Prs3d_LineAspect.hxx>
#include <StdPrs_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_ArrowAspect.hxx>
//
// Foreach ancestors, we add a IMPLEMENT_STANDARD_SUPERTYPE and
// a IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY macro.
// We must respect the order: from the direct ancestor class
// to the base class.
//
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ISession_Curve::ISession_Curve(const Handle(Geom_Curve)& aCurve)
:AIS_InteractiveObject(),myCurve(aCurve)
{
}
ISession_Curve::~ISession_Curve()
{
}
void ISession_Curve::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer /*aMode*/)
{
GeomAdaptor_Curve anAdaptorCurve(myCurve);
if (hasOwnColor)
myDrawer->LineAspect()->SetColor (myDrawer->Color());
myDrawer->Link()->SetDiscretisation(100);
myDrawer->Link()->SetMaximalParameterValue(500);
StdPrs_Curve::Add (aPresentation, anAdaptorCurve, myDrawer);
}
void ISession_Curve::Compute(const Handle(Prs3d_Projector)& aProjector,
const Handle(Prs3d_Presentation)& aPresentation)
{
}
void ISession_Curve::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
const Standard_Integer aMode)
{
}

View File

@@ -1,33 +0,0 @@
// ISession_Curve.h: interface for the ISession_Curve class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_ISESSION_CURVE_H__F981CB93_A3CC_11D1_8DA3_0800369C8A03__INCLUDED_)
#define AFX_ISESSION_CURVE_H__F981CB93_A3CC_11D1_8DA3_0800369C8A03__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include <Standard_Macro.hxx>
#include <Standard_DefineHandle.hxx>
#include <AIS_InteractiveObject.hxx>
#include <Geom_Curve.hxx>
DEFINE_STANDARD_HANDLE(ISession_Curve,AIS_InteractiveObject)
class ISession_Curve : public AIS_InteractiveObject
{
public:
ISession_Curve(const Handle(Geom_Curve)& aCurve);
virtual ~ISession_Curve();
DEFINE_STANDARD_RTTIEXT(ISession_Curve,AIS_InteractiveObject)
private:
Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,const Handle(Prs3d_Presentation)& aPresentation,const Standard_Integer aMode = 0) ;
Standard_EXPORT virtual void Compute(const Handle(Prs3d_Projector)& aProjector,const Handle(Prs3d_Presentation)& aPresentation) ;
void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,const Standard_Integer aMode) ;
Handle(Geom_Curve) myCurve;
};
#endif // !defined(AFX_ISESSION_CURVE_H__F981CB93_A3CC_11D1_8DA3_0800369C8A03__INCLUDED_)

View File

@@ -1,314 +0,0 @@
// OCCDemo_Presentation.cpp: implementation of the OCCDemo_Presentation class.
// This is a base class for all presentations
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "OCCDemo_Presentation.h"
#include "OCCDemoView.h"
#include "ISession_Curve.h"
#include <AIS_InteractiveObject.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <Quantity_Color.hxx>
#include <AIS_Shape.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <Precision.hxx>
#include <Geom_Line.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Prs_Drawer.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <AIS_Point.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Geom2d_OffsetCurve.hxx>
#include <GeomAPI.hxx>
#include <gp_Pln.hxx>
#include <Geom_OffsetCurve.hxx>
#define MAX_PARAM 1000 // if a surface parameter is infinite, it is assingned
// this value in order to display the "infinit" object in the viewer.
Standard_Boolean OCCDemo_Presentation::WaitForInput (unsigned long aMilliSeconds)
{
//::WaitForSingleObject(::CreateEvent (NULL, FALSE, FALSE, NULL), aMilliSeconds);
if (::MsgWaitForMultipleObjects(0, NULL, FALSE, aMilliSeconds,
QS_KEY | QS_MOUSEBUTTON) != WAIT_TIMEOUT)
{
MSG msg;
if (::PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (msg.message == WM_KEYUP)
{
::PeekMessage (&msg, NULL, 0, 0, PM_REMOVE);
return WaitForInput (aMilliSeconds);
}
else
return Standard_True;
}
}
return Standard_False;
}
//================================================================
// Function : fixParam
// Purpose : assings a finite value to theParam if it intinite
// (equal to +- Precision::Infinite())
//================================================================
static Standard_Boolean fixParam(Standard_Real& theParam)
{
Standard_Boolean aResult = Standard_False;
if (Precision::IsNegativeInfinite(theParam))
{
theParam = -MAX_PARAM;
aResult = Standard_True;
}
if (Precision::IsPositiveInfinite(theParam))
{
theParam = MAX_PARAM;
aResult = Standard_True;
}
return aResult;
}
//================================================================
// Function : DrawSurface
// Purpose : displays a given geometric surface in 3d viewer
// (creates a finite face and displays it)
//================================================================
Handle(AIS_InteractiveObject) OCCDemo_Presentation::drawSurface
(const Handle(Geom_Surface)& theSurface,
const Quantity_Color& theColor,
const Standard_Boolean toDisplay)
{
Standard_Real u1, u2, v1, v2;
theSurface->Bounds(u1,u2,v1,v2);
fixParam(u1);
fixParam(u2);
fixParam(v1);
fixParam(v2);
Handle(AIS_Shape) aGraphicSurface =
new AIS_Shape(BRepBuilderAPI_MakeFace (theSurface, u1, u2, v1, v2));
getAISContext()->SetMaterial(aGraphicSurface, Graphic3d_NOM_PLASTIC, toDisplay);
getAISContext()->SetColor(aGraphicSurface, theColor, toDisplay);
if (toDisplay) {
if (FitMode){
getAISContext()->Display (aGraphicSurface, Standard_False);
COCCDemoDoc::Fit();
}
else
getAISContext()->Display (aGraphicSurface);
}
return aGraphicSurface;
}
//================================================================
// Function : DrawCurve
// Purpose : displays a given curve 3d
//================================================================
Handle(AIS_InteractiveObject) OCCDemo_Presentation::drawCurve
(const Handle(Geom_Curve)& theCurve,
const Quantity_Color& theColor,
const Standard_Boolean toDisplay)
{
Handle(ISession_Curve) aGraphicCurve = new ISession_Curve (theCurve);
getAISContext()->SetColor (aGraphicCurve, theColor, toDisplay);
aGraphicCurve->Attributes()->Link()->SetLineArrowDraw(Standard_False);
if (toDisplay){
if (FitMode){
getAISContext()->Display (aGraphicCurve, Standard_False);
COCCDemoDoc::Fit();
}
else
getAISContext()->Display (aGraphicCurve);
}
return aGraphicCurve;
}
//================================================================
// Function : DrawCurve
// Purpose : displays a given curve 2d
//================================================================
Handle(AIS_InteractiveObject) OCCDemo_Presentation::drawCurve
(const Handle(Geom2d_Curve)& theCurve,
const Quantity_Color& theColor,
const Standard_Boolean toDisplay,
const gp_Ax2& aPosition)
{
// create 3D curve in plane
Handle(Geom_Curve) aCurve3d;
if (theCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve)))
{
Handle(Geom2d_OffsetCurve) aOffCurve =
Handle(Geom2d_OffsetCurve)::DownCast(theCurve);
Handle(Geom_Curve) aBasCurve3d =
GeomAPI::To3d (aOffCurve->BasisCurve(), gp_Pln(aPosition));
Standard_Real aDist = aOffCurve->Offset();
aCurve3d = new Geom_OffsetCurve (aBasCurve3d, aDist, aPosition.Direction());
}
else
{
aCurve3d = GeomAPI::To3d (theCurve, gp_Pln(aPosition));
}
return drawCurve (aCurve3d, theColor, toDisplay);
}
//================================================================
// Function : drawPoint
// Purpose : displays a given point
//================================================================
Handle(AIS_Point) OCCDemo_Presentation::drawPoint
(const gp_Pnt& aPnt,
const Quantity_Color& theColor,
const Standard_Boolean toDisplay)
{
Handle(AIS_Point) aGraphicPoint = new AIS_Point (new Geom_CartesianPoint(aPnt));
getAISContext()->SetColor (aGraphicPoint, theColor, toDisplay);
if (toDisplay) {
getAISContext()->Display (aGraphicPoint);
//COCCDemoDoc::Fit();
}
return aGraphicPoint;
}
//================================================================
// Function : drawVector
// Purpose : displays a given vector in 3d viewer
// (segment of line starting at thePnt with the arrow at the end,
// the length of segment is the length of the vector)
//================================================================
Handle(AIS_InteractiveObject) OCCDemo_Presentation::drawVector
(const gp_Pnt& thePnt,
const gp_Vec& theVec,
const Quantity_Color& theColor,
const Standard_Boolean toDisplay)
{
Standard_Real aLength = theVec.Magnitude();
if (aLength < Precision::Confusion())
return Handle(AIS_InteractiveObject)();
Handle(Geom_Curve) aCurve = new Geom_Line (thePnt, theVec);
aCurve = new Geom_TrimmedCurve (aCurve, 0, aLength);
Handle(ISession_Curve) aGraphicCurve = new ISession_Curve (aCurve);
getAISContext()->SetColor (aGraphicCurve, theColor, toDisplay);
Handle(Prs3d_Drawer) aDrawer = aGraphicCurve->Attributes()->Link();
aDrawer->SetLineArrowDraw(Standard_True);
aDrawer->ArrowAspect()->SetLength(aLength/10);
if (toDisplay) {
if (FitMode){
getAISContext()->Display (aGraphicCurve, Standard_False);
COCCDemoDoc::Fit();
}
else
getAISContext()->Display (aGraphicCurve);
}
return aGraphicCurve;
}
Handle(AIS_Shape) OCCDemo_Presentation::drawShape
(const TopoDS_Shape& theShape,const Quantity_Color& theColor,
const Standard_Boolean toDisplay)
{
Handle(AIS_Shape) aGraphicShape = new AIS_Shape(theShape);
getAISContext()->SetMaterial(aGraphicShape, Graphic3d_NOM_PLASTIC, toDisplay);
getAISContext()->SetColor (aGraphicShape, theColor, toDisplay);
if (toDisplay){
if (FitMode){
getAISContext()->Display (aGraphicShape, Standard_False);
COCCDemoDoc::Fit();
}
else
getAISContext()->Display (aGraphicShape);
}
return aGraphicShape;
}
Handle(AIS_Shape) OCCDemo_Presentation::drawShape
(const TopoDS_Shape& theShape,
const Graphic3d_NameOfMaterial theMaterial,
const Standard_Boolean toDisplay)
{
Handle(AIS_Shape) aGraphicShape = new AIS_Shape(theShape);
getAISContext()->SetMaterial(aGraphicShape, theMaterial, toDisplay);
if (toDisplay) {
if (FitMode){
getAISContext()->Display (aGraphicShape, Standard_False);
COCCDemoDoc::Fit();
}
else
getAISContext()->Display (aGraphicShape);
}
return aGraphicShape;
}
void OCCDemo_Presentation::GetViewCenter(Standard_Real& Xc, Standard_Real& Yc)
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
pView->GetViewCenter(Xc,Yc);
}
void OCCDemo_Presentation::SetViewCenter(Standard_Real Xc, Standard_Real Yc)
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
pView->SetViewCenter(Xc,Yc);
}
void OCCDemo_Presentation::GetViewEye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z)
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
pView->GetViewEye(X,Y,Z);
}
void OCCDemo_Presentation::SetViewEye(Standard_Real X, Standard_Real Y, Standard_Real Z)
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
pView->SetViewEye(X,Y,Z);
}
Standard_Real OCCDemo_Presentation::GetViewScale()
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
return pView->GetViewScale();
}
void OCCDemo_Presentation::SetViewScale(Standard_Real Coef)
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
pView->SetViewScale(Coef);
}
void OCCDemo_Presentation::ResetView()
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
pView->Reset();
}

View File

@@ -1,132 +0,0 @@
// OCCDemo_Presentation.h: interface for the OCCDemo_Presentation class.
// This is a base class for all presentations
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_OCCDEMO_PRESENTATION_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_)
#define AFX_OCCDEMO_PRESENTATION_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WAIT_A_LITTLE WaitForInput(500)
#define WAIT_A_SECOND WaitForInput(1000)
#include <OCCDemoDoc.h>
class AIS_InteractiveObject;
class Geom_Surface;
class Geom_Curve;
class Geom2d_Curve;
class Quantity_Color;
class OCCDemo_Presentation
{
public:
// Construction
OCCDemo_Presentation() : myIndex(0), myNbSamples(0), FitMode(false){}
virtual ~OCCDemo_Presentation() {}
public:
static OCCDemo_Presentation* Current;
// this pointer must be initialized when realize a derivable class;
// it is used by application to access to a presentation class instance
void SetDocument (COCCDemoDoc* theDoc) {myDoc = theDoc;}
// document must be set by the user of this class before first use of iterations
public:
// Titling
const CString& GetName() const {return myName;}
public:
// Iteration on samples
void FirstSample() {myIndex=0;}
void LastSample() {myIndex=myNbSamples-1;}
Standard_Boolean AtFirstSample() const {return myIndex <= 0;}
Standard_Boolean AtLastSample() const {return myIndex >= myNbSamples-1;}
void NextSample() {myIndex++;}
void PrevSample() {myIndex--;}
virtual void DoSample() = 0;
static void GetViewCenter(Standard_Real& Xc, Standard_Real& Yc);
static void SetViewCenter(const Standard_Real Xc, const Standard_Real Yc);
static void GetViewEye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z);
static void SetViewEye(Standard_Real X, Standard_Real Y, Standard_Real Z);
static Standard_Real GetViewScale();
static void SetViewScale(Standard_Real Coef);
static void ResetView();
// place one-time initialization code in this function
virtual void Init() {}
protected:
// Methods to call from a derivable class
void setName (const char* theName) {myName = CString(theName);}
Handle(AIS_InteractiveContext) getAISContext() const {return myDoc->GetAISContext();}
Handle(V3d_Viewer) getViewer() const {return myDoc->GetViewer();}
void setResultTitle (const char* theTitle) {myDoc->GetResultDialog()->SetTitle(theTitle);}
void setResultText (const char* theText) {myDoc->GetResultDialog()->SetText(theText);}
Standard_CString GetDataDir() {return myDoc->GetDataDir();}
Standard_Boolean WaitForInput (unsigned long aMilliSeconds);
// Waits for a user input or a period of time has been elapsed
Handle(AIS_InteractiveObject) drawSurface (const Handle(Geom_Surface)& theSurface,
const Quantity_Color& theColor = Quantity_Color(Quantity_NOC_LEMONCHIFFON3),
const Standard_Boolean toDisplay = Standard_True);
// creates a finite face based on the given geometric surface
// and displays it in the viewer if toDisplay = Standard_True
Handle(AIS_InteractiveObject) drawCurve (const Handle(Geom_Curve)& theCurve,
const Quantity_Color& theColor = Quantity_Color(Quantity_NOC_RED),
const Standard_Boolean toDisplay = Standard_True);
// creates an ISession_Curve based on the given geometric curve
// and displays it in the viewer if toDisplay = Standard_True
Handle(AIS_InteractiveObject) drawCurve (const Handle(Geom2d_Curve)& theCurve,
const Quantity_Color& theColor = Quantity_Color(Quantity_NOC_RED),
const Standard_Boolean toDisplay = Standard_True,
const gp_Ax2& aPosition = gp::XOY());
// converts a given curve to 3d using aPosition and calls the previous method
Handle(AIS_Point) drawPoint (const gp_Pnt& thePnt,
const Quantity_Color& theColor = Quantity_Color(Quantity_NOC_GREEN),
const Standard_Boolean toDisplay = Standard_True);
// creates a presentation of the given point
// and displays it in the viewer if toDisplay = Standard_True
Handle(AIS_InteractiveObject) drawVector (const gp_Pnt& thePnt,
const gp_Vec& theVec,
const Quantity_Color& theColor = Quantity_Color(Quantity_NOC_YELLOW),
const Standard_Boolean toDisplay = Standard_True);
// creates a presentation of the given vector
// and displays it in the viewer if toDisplay = Standard_True
Handle(AIS_Shape) drawShape (const TopoDS_Shape& theShape,
const Quantity_Color& theColor,
const Standard_Boolean toDisplay = Standard_True);
// creates a presentation of the given shape
// with material PLASTIC and a given color
// and displays it in the viewer if toDisplay = Standard_True
Handle(AIS_Shape) drawShape (const TopoDS_Shape& theShape,
const Graphic3d_NameOfMaterial theMaterial = Graphic3d_NOM_BRASS,
const Standard_Boolean toDisplay = Standard_True);
// creates a presentation of the given shape with the given material
// (color is default for a given material)
// and displays it in the viewer if toDisplay = Standard_True
protected:
// Fields to use in a derivable class
BOOL FitMode;
int myIndex;
int myNbSamples;
private:
COCCDemoDoc* myDoc;
CString myName;
};
#endif // !defined(AFX_OCCDEMO_PRESENTATION_H__790EED7F_7BA2_11D5_BA4A_0060B0EE18EA__INCLUDED_)

View File

@@ -1,112 +0,0 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "OCCDemo.h"
#include "MainFrm.h"
#include "OCCDemoDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code !
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR // status line indicator
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
/* | CBRS_GRIPPER */| CBRS_TOOLTIPS | CBRS_FLYBY) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBar1.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_TOOLTIPS | CBRS_FLYBY) ||
!m_wndToolBar1.LoadToolBar(IDR_TOOLBAR1))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
//m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
//EnableDocking(CBRS_ALIGN_ANY);
//DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

View File

@@ -1,59 +0,0 @@
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__57A6A22C_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
#define AFX_MAINFRM_H__57A6A22C_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
CToolBar m_wndToolBar1;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__57A6A22C_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)

View File

@@ -1,201 +0,0 @@
// OCCDemo.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "OCCDemo.h"
#include "MainFrm.h"
#include "OCCDemoDoc.h"
#include "OCCDemoView.h"
#include <Standard_Version.hxx>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COCCDemoApp
BEGIN_MESSAGE_MAP(COCCDemoApp, CWinApp)
//{{AFX_MSG_MAP(COCCDemoApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
//}}AFX_MSG_MAP
// Standard file based document commands
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COCCDemoApp construction
COCCDemoApp::COCCDemoApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
try
{
myGraphicDevice = new Graphic3d_WNTGraphicDevice;
}
catch(Standard_Failure)
{
AfxMessageBox("Fatal Error During Graphic Initialisation");
}
}
/////////////////////////////////////////////////////////////////////////////
// The one and only COCCDemoApp object
COCCDemoApp theApp;
/////////////////////////////////////////////////////////////////////////////
// COCCDemoApp initialization
BOOL COCCDemoApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(COCCDemoDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(COCCDemoView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// Create result dialog
AfxInitRichEdit();
CMainFrame* cFrame = (CMainFrame*) GetMainWnd();
COCCDemoDoc* aDoc = (COCCDemoDoc*) cFrame->GetActiveDocument();
// pass cFrame->GetDesktopWindow() as parent to have an independent dialog
// pass cFrame as parent to have the result dialog always above the main window
if (!aDoc->GetResultDialog()->Create(CResultDialog::IDD, cFrame->GetDesktopWindow()))
TRACE0("Failed to create result dialog\n");
aDoc->GetResultDialog()->SetIcon(AfxGetApp()->LoadIcon(IDR_MAINFRAME), FALSE);
aDoc->GetResultDialog()->ShowWindow(SW_HIDE);
aDoc->GetResultDialog()->Initialize();
// resize the result dialog, so no clipping occures when user
// resizes the dialog manually
// position the result dialog to the left bottom corner of the view
CRect aDlgRect, aViewRect;
aDoc->GetResultDialog()->GetWindowRect(&aDlgRect);
cFrame->GetActiveView()->GetWindowRect(&aViewRect);
int x = aViewRect.left;
int y = aViewRect.bottom - aDlgRect.Size().cy;
int cx = aDlgRect.Size().cx+1;
int cy = aDlgRect.Size().cy+1;
aDoc->GetResultDialog()->SetWindowPos(NULL, x, y, cx, cy, SWP_NOREDRAW | SWP_NOZORDER);
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
m_pMainWnd->SetFocus();
aDoc->Start();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
BOOL OnInitDialog();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BOOL CAboutDlg::OnInitDialog(){
CWnd* TitleWnd = GetDlgItem(IDC_ABOUTBOX_TITLE);
CString TitleString;
TitleWnd->GetWindowText(TitleString);
CString OCC_Version = OCC_VERSION_STRING;
TitleString = TitleString + OCC_Version;
TitleWnd->SetWindowText(TitleString);
CenterWindow();
return TRUE;
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void COCCDemoApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// COCCDemoApp message handlers

View File

@@ -1,55 +0,0 @@
// OCCDemo.h : main header file for the OCCDEMO application
//
#if !defined(AFX_OCCDEMO_H__57A6A228_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
#define AFX_OCCDEMO_H__57A6A228_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// COCCDemoApp:
// See OCCDemo.cpp for the implementation of this class
//
class COCCDemoApp : public CWinApp
{
public:
COCCDemoApp();
Handle(Graphic3d_WNTGraphicDevice) GetGraphicDevice() const
{ return myGraphicDevice; } ;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(COCCDemoApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(COCCDemoApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
Handle(Graphic3d_WNTGraphicDevice) myGraphicDevice;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_OCCDEMO_H__57A6A228_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)

View File

@@ -1,380 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif //_WIN32\r\n"
"#include ""res\\OCCDemo.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\OCCDemo.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_OCC_LOGO BITMAP DISCARDABLE "res\\occ_logo.bmp"
IDR_MAINFRAME BITMAP MOVEABLE PURE "res\\Toolbar.bmp"
IDR_TOOLBAR1 BITMAP DISCARDABLE "res\\Toolbar1.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Toolbar
//
IDR_MAINFRAME TOOLBAR DISCARDABLE 20, 20
BEGIN
BUTTON ID_BUTTONStart
BUTTON ID_BUTTONPrev
BUTTON ID_BUTTONRepeat
BUTTON ID_BUTTONNext
BUTTON ID_BUTTONEnd
SEPARATOR
BUTTON ID_BUTTONShowResult
BUTTON ID_DUMP_VIEW
END
IDR_TOOLBAR1 TOOLBAR DISCARDABLE 20, 20
BEGIN
BUTTON ID_BUTTONZoomAll
BUTTON ID_BUTTONZoomWin
BUTTON ID_BUTTONZoomProg
SEPARATOR
BUTTON ID_BUTTONPan
BUTTON ID_BUTTONPanGlo
SEPARATOR
BUTTON ID_BUTTONFront
BUTTON ID_BUTTONTop
BUTTON ID_BUTTONLeft
BUTTON ID_BUTTONBack
BUTTON ID_BUTTONRight
BUTTON ID_BUTTONBottom
BUTTON ID_BUTTONAxo
SEPARATOR
BUTTON ID_BUTTONRot
BUTTON ID_BUTTONReset
SEPARATOR
BUTTON ID_BUTTONWire
BUTTON ID_BUTTONShade
BUTTON ID_BUTTONHlrOn
END
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "Reset", ID_FILE_NEW
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_APP_EXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About OCCDemo...", ID_APP_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
"A", ID_BUTTONAxo, VIRTKEY, CONTROL, NOINVERT
"B", ID_BUTTONBack, VIRTKEY, CONTROL, NOINVERT
"F", ID_BUTTONZoomAll, VIRTKEY, NOINVERT
"F", ID_BUTTONFront, VIRTKEY, CONTROL, NOINVERT
"H", ID_BUTTONHlrOn, VIRTKEY, SHIFT, NOINVERT
"L", ID_BUTTONLeft, VIRTKEY, CONTROL, NOINVERT
"M", ID_BUTTONBottom, VIRTKEY, CONTROL, NOINVERT
"R", ID_BUTTONReset, VIRTKEY, NOINVERT
"R", ID_BUTTONRight, VIRTKEY, CONTROL, NOINVERT
"S", ID_BUTTONShade, VIRTKEY, SHIFT, NOINVERT
"T", ID_BUTTONTop, VIRTKEY, CONTROL, NOINVERT
VK_END, ID_BUTTONEnd, VIRTKEY, NOINVERT
VK_F11, ID_BUTTONShowResult, VIRTKEY, NOINVERT
VK_F12, ID_DUMP_VIEW, VIRTKEY, NOINVERT
VK_HOME, ID_BUTTONStart, VIRTKEY, NOINVERT
VK_NEXT, ID_BUTTONNext, VIRTKEY, NOINVERT
VK_PRIOR, ID_BUTTONPrev, VIRTKEY, NOINVERT
VK_SPACE, ID_BUTTONRepeat, VIRTKEY, NOINVERT
"W", ID_BUTTONWire, VIRTKEY, SHIFT, NOINVERT
"X", ID_APP_EXIT, VIRTKEY, CONTROL, NOINVERT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOGEX 34, 22, 201, 161
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
CAPTION "About"
FONT 8, "MS Sans Serif"
BEGIN
CTEXT "OCCDemo, Open CASCADE ",IDC_ABOUTBOX_TITLE,3,8,195,8
CTEXT "Copyright (C) 2008, Open CASCADE Company",IDC_STATIC,28,
99,147,8,SS_CENTERIMAGE
DEFPUSHBUTTON "OK",IDOK,55,135,88,14,WS_GROUP
CTEXT "http://www.opencascade.com",IDC_STATIC,50,115,98,8,
SS_CENTERIMAGE
CONTROL 1300,IDC_STATIC,"Static",SS_BITMAP,36,27,129,62,
WS_EX_CLIENTEDGE
END
IDD_ResultDialog DIALOG DISCARDABLE 0, 0, 244, 231
STYLE WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
WS_THICKFRAME
CAPTION "Result Dialog"
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "",IDC_RICHEDIT_ResultDialog,"RICHEDIT",ES_MULTILINE |
ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_NOHIDESEL |
ES_READONLY | WS_BORDER | WS_VSCROLL | WS_HSCROLL |
WS_TABSTOP,0,7,243,192
PUSHBUTTON "Copy selection",IDC_CopySelectionToClipboard,0,206,60,
18
PUSHBUTTON "Copy all",IDC_CopyAllToClipboard,65,206,60,18
PUSHBUTTON "Close",IDCANCEL,183,206,60,18
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Open CASCADE Demonstration Application\0"
VALUE "CompanyName", "Open CASCADE, France\0"
VALUE "FileDescription", "OCCDemo MFC Application\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "OCCDemo\0"
VALUE "LegalCopyright", "Copyright (C) 2001, Open CASCADE Company\0"
VALUE "LegalTrademarks", "Open CASCADE\0"
VALUE "OriginalFilename", "OCCDemo.EXE\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "OCCDemo Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ResultDialog, DIALOG
BEGIN
RIGHTMARGIN, 243
TOPMARGIN, 7
BOTTOMMARGIN, 224
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
IDR_MAINFRAME "OCCDemo\n\nOCCDem\n\n\nOCCDemo.Document\nOCCDem Document"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "OCCDemo"
AFX_IDS_IDLEMESSAGE "Ready"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_NEW "Start demo a new\nReset"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
ID_APP_EXIT "Quit the application\nExit"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCSIZE "Change the window size"
AFX_IDS_SCMOVE "Change the window position"
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
AFX_IDS_SCCLOSE "Close the active window"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCRESTORE "Restore the window to normal size"
AFX_IDS_SCTASKLIST "Activate Task List"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_BUTTONZoomAll "Press to zoom the application objects in the view\nFitAll (F)"
ID_BUTTONZoomWin "Press and drag MB1 to select a zoom window\nZoom Window"
ID_BUTTONZoomProg "Press and drag MB1 to zoom\nDynamic Zooming"
ID_BUTTONPan "Press and drag MB1 to pan\nDynamic Panning"
ID_BUTTONPanGlo "Press and select a new view center t\nGlobal Panning"
ID_BUTTONFront "Press to select a front View\nFront (Ctrl+F)"
ID_BUTTONLeft "Press to select a left View\nLeft (Ctrl+L)"
ID_BUTTONTop "Press to select a top View\nTop (Ctrl+T)"
ID_BUTTONBack "Press to select a back View\nBack (Ctrl+B)"
ID_BUTTONRight "Press to select a right View\nRight (Ctrl+R)"
ID_BUTTONBottom "Press to select a bottom View\nBottom (Ctrl+M)"
ID_BUTTONAxo "Press to select axonometric View\nAxo (Ctrl+A)"
ID_BUTTONRot "Press and drag MB1 to rotate\nDynamic Rotation"
ID_BUTTONReset "Press to reset view\nReset (R)"
ID_BUTTONWire "Press to switch to wireframe mode\nWireframe mode (Shift+W)"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_BUTTONShade "Press to switch to shading mode\nShading mode (Shift+S)"
ID_BUTTONHlrOn "Press to switch to HLR mode\nHLR mode (Shift+H)"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_BUTTONStart "Press to go to the first sample\nFirst sample (Home)"
ID_BUTTONNext "Press to go to the next sample\nNext sample (PgDn)"
ID_BUTTONShowResult "Press to toggle show of source code on/off\nSource code (F11)"
ID_DUMP_VIEW "Save current frame into a GIF file\nExport view to GIF (F12)"
ID_BUTTONEnd "Press to go to the last sample\nLast sample (End)"
ID_BUTTONPrev "Press to go to the previous sample\nPrevious sample (PgUp)"
ID_BUTTONRepeat "Press to repeat the current sample\nRepeat sample (Space)"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif //_WIN32
#include "res\OCCDemo.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -1,273 +0,0 @@
// OCCDemoDoc.cpp : implementation of the COCCDemoDoc class
//
#include "stdafx.h"
#include "OCCDemo.h"
#include "OCCDemoDoc.h"
#include "OCCDemo_Presentation.h"
#include "OCCDemoView.h"
#include <Standard_ErrorHandler.hxx>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COCCDemoDoc
IMPLEMENT_DYNCREATE(COCCDemoDoc, CDocument)
BEGIN_MESSAGE_MAP(COCCDemoDoc, CDocument)
//{{AFX_MSG_MAP(COCCDemoDoc)
ON_COMMAND(ID_BUTTONNext, OnBUTTONNext)
ON_COMMAND(ID_BUTTONStart, OnBUTTONStart)
ON_COMMAND(ID_BUTTONRepeat, OnBUTTONRepeat)
ON_COMMAND(ID_BUTTONPrev, OnBUTTONPrev)
ON_COMMAND(ID_BUTTONEnd, OnBUTTONEnd)
ON_UPDATE_COMMAND_UI(ID_BUTTONNext, OnUpdateBUTTONNext)
ON_UPDATE_COMMAND_UI(ID_BUTTONPrev, OnUpdateBUTTONPrev)
ON_COMMAND(ID_FILE_NEW, OnFileNew)
ON_COMMAND(ID_BUTTONShowResult, OnBUTTONShowResult)
ON_UPDATE_COMMAND_UI(ID_BUTTONShowResult, OnUpdateBUTTONShowResult)
ON_COMMAND(ID_DUMP_VIEW, OnDumpView)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COCCDemoDoc construction/destruction
COCCDemoDoc::COCCDemoDoc()
{
// TODO: add one-time construction code here
Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
((COCCDemoApp*)AfxGetApp())->GetGraphicDevice();
myViewer = new V3d_Viewer(theGraphicDevice);
myViewer->SetDefaultLights();
myViewer->SetLightOn();
myViewer->SetDefaultBackgroundColor(Quantity_TOC_RGB, 0.,0.,0.);
myAISContext = new AIS_InteractiveContext(myViewer);
myShowResult = FALSE;
myPresentation = OCCDemo_Presentation::Current;
myPresentation->SetDocument(this);
CFile aFile;
if (!aFile.Open("Data\\points.dat", CFile::modeRead)){
strcpy(myDataDir, "..\\Data");
}
else
strcpy(myDataDir, "Data");
strcpy(myLastPath, ".");
}
COCCDemoDoc::~COCCDemoDoc()
{
}
BOOL COCCDemoDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
SetTitle(myPresentation->GetName());
myAISContext->EraseAll(Standard_False);
myAISContext->SetDisplayMode(AIS_Shaded);
POSITION pos = GetFirstViewPosition();
while (pos != NULL)
{
COCCDemoView* pView = (COCCDemoView*) GetNextView(pos);
pView->Reset();
}
return TRUE;
}
void COCCDemoDoc::Start()
{
myPresentation->Init();
OnBUTTONStart();
}
/////////////////////////////////////////////////////////////////////////////
// COCCDemoDoc serialization
void COCCDemoDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{}// TODO: add storing code here
else
{}// TODO: add loading code here
}
/////////////////////////////////////////////////////////////////////////////
// COCCDemoDoc diagnostics
#ifdef _DEBUG
void COCCDemoDoc::AssertValid() const
{
CDocument::AssertValid();
}
void COCCDemoDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COCCDemoDoc commands
void COCCDemoDoc::OnFileNew()
{
OnNewDocument();
Start();
}
void COCCDemoDoc::InitViewButtons()
{
POSITION pos = GetFirstViewPosition();
while (pos != NULL)
{
COCCDemoView* pView = (COCCDemoView*) GetNextView(pos);
pView->InitButtons();
}
}
void COCCDemoDoc::DoSample()
{
InitViewButtons();
HCURSOR hOldCursor = ::GetCursor();
HCURSOR hNewCursor = AfxGetApp()->LoadStandardCursor(IDC_APPSTARTING);
SetCursor(hNewCursor);
{
try
{
myPresentation->DoSample();
}
catch (Standard_Failure)
{
Standard_SStream ostr;
ostr<<Standard_Failure::Caught()<<"\n\0";
AfxMessageBox (GetSString(ostr));
}
}
SetCursor(hOldCursor);
}
void COCCDemoDoc::OnBUTTONStart()
{
myAISContext->EraseAll(Standard_False);
myPresentation->FirstSample();
DoSample();
}
void COCCDemoDoc::OnBUTTONEnd()
{
myAISContext->EraseAll(Standard_False);
myPresentation->LastSample();
DoSample();
}
void COCCDemoDoc::OnBUTTONRepeat()
{
DoSample();
}
void COCCDemoDoc::OnBUTTONNext()
{
if (!myPresentation->AtLastSample())
{
myPresentation->NextSample();
DoSample();
}
}
void COCCDemoDoc::OnBUTTONPrev()
{
if (!myPresentation->AtFirstSample())
{
myPresentation->PrevSample();
DoSample();
}
}
void COCCDemoDoc::OnUpdateBUTTONNext(CCmdUI* pCmdUI)
{
pCmdUI->Enable (!myPresentation->AtLastSample());
}
void COCCDemoDoc::OnUpdateBUTTONPrev(CCmdUI* pCmdUI)
{
pCmdUI->Enable (!myPresentation->AtFirstSample());
}
void COCCDemoDoc::OnBUTTONShowResult()
{
myShowResult = !myShowResult;
if (myShowResult)
myCResultDialog.ShowWindow(SW_SHOWNORMAL);
else
myCResultDialog.ShowWindow(SW_HIDE);
}
void COCCDemoDoc::OnUpdateBUTTONShowResult(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (myShowResult);
}
void COCCDemoDoc::OnDumpView()
{
// save current directory and restore it on exit
char aCurPath[MAX_PATH];
::GetCurrentDirectory(MAX_PATH, aCurPath);
::SetCurrentDirectory(myLastPath);
CFileDialog *aDlg = new CFileDialog(false, "gif", "OCCView.gif",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "GIF Files (*.gif)|*.gif||", NULL);
int result = aDlg->DoModal();
if ( result == IDOK)
{
CString aFileName = aDlg->GetFileName();
delete aDlg;
POSITION pos = GetFirstViewPosition();
while (pos != NULL)
{
COCCDemoView* pView = (COCCDemoView*) GetNextView(pos);
pView->UpdateWindow();
}
myViewer->InitActiveViews();
Handle(V3d_View) aView = myViewer->ActiveView();
char aStrFileName[MAX_PATH];
strcpy(aStrFileName, aFileName);
aView->Dump(aStrFileName);
}
else
delete aDlg;
::GetCurrentDirectory(MAX_PATH, myLastPath);
::SetCurrentDirectory(aCurPath);
}
void COCCDemoDoc::Fit()
{
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
COCCDemoView *pView = (COCCDemoView *) pChild->GetActiveView();
pView->FitAll();
}

View File

@@ -1,88 +0,0 @@
// OCCDemoDoc.h : interface of the COCCDemoDoc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_OCCDEMODOC_H__57A6A22E_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
#define AFX_OCCDEMODOC_H__57A6A22E_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ResultDialog.h"
class OCCDemo_Presentation;
class COCCDemoDoc : public CDocument
{
public:
Handle(V3d_Viewer) GetViewer() const { return myViewer; };
Handle(AIS_InteractiveContext) GetAISContext() const { return myAISContext; };
CResultDialog* GetResultDialog () {return &myCResultDialog;}
Standard_CString GetDataDir() {return myDataDir;}
protected: // create from serialization only
COCCDemoDoc();
DECLARE_DYNCREATE(COCCDemoDoc)
// Attributes
public:
BOOL& IsShowResult() {return myShowResult;}
// Operations
public:
void Start();
static void Fit();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(COCCDemoDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~COCCDemoDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
void InitViewButtons();
void DoSample();
// Generated message map functions
protected:
//{{AFX_MSG(COCCDemoDoc)
afx_msg void OnBUTTONNext();
afx_msg void OnBUTTONStart();
afx_msg void OnBUTTONRepeat();
afx_msg void OnBUTTONPrev();
afx_msg void OnBUTTONEnd();
afx_msg void OnUpdateBUTTONNext(CCmdUI* pCmdUI);
afx_msg void OnUpdateBUTTONPrev(CCmdUI* pCmdUI);
afx_msg void OnFileNew();
afx_msg void OnBUTTONShowResult();
afx_msg void OnUpdateBUTTONShowResult(CCmdUI* pCmdUI);
afx_msg void OnDumpView();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
Handle(V3d_Viewer) myViewer;
Handle(AIS_InteractiveContext) myAISContext;
OCCDemo_Presentation *myPresentation;
CResultDialog myCResultDialog;
BOOL myShowResult;
char myDataDir[8]; // for "..\Data\0"
char myLastPath[MAX_PATH]; // directory of lastly saved file in DumpView()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_OCCDEMODOC_H__57A6A22E_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)

View File

@@ -1,583 +0,0 @@
// OCCDemoView.cpp : implementation of the COCCDemoView class
//
#include "stdafx.h"
#include "MainFrm.h"
#include "OCCDemo.h"
#include "OCCDemoDoc.h"
#include "OCCDemoView.h"
#include <Graphic3d_GraphicDriver.hxx>
#define ValZWMin 1
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COCCDemoView
IMPLEMENT_DYNCREATE(COCCDemoView, CView)
BEGIN_MESSAGE_MAP(COCCDemoView, CView)
//{{AFX_MSG_MAP(COCCDemoView)
ON_COMMAND(ID_BUTTONAxo, OnBUTTONAxo)
ON_COMMAND(ID_BUTTONBack, OnBUTTONBack)
ON_COMMAND(ID_BUTTONBottom, OnBUTTONBottom)
ON_COMMAND(ID_BUTTONFront, OnBUTTONFront)
ON_COMMAND(ID_BUTTONHlrOn, OnBUTTONHlrOn)
ON_COMMAND(ID_BUTTONLeft, OnBUTTONLeft)
ON_COMMAND(ID_BUTTONPan, OnBUTTONPan)
ON_COMMAND(ID_BUTTONPanGlo, OnBUTTONPanGlo)
ON_COMMAND(ID_BUTTONReset, OnBUTTONReset)
ON_COMMAND(ID_BUTTONRight, OnBUTTONRight)
ON_COMMAND(ID_BUTTONRot, OnBUTTONRot)
ON_COMMAND(ID_BUTTONTop, OnBUTTONTop)
ON_COMMAND(ID_BUTTONZoomAll, OnBUTTONZoomAll)
ON_WM_SIZE()
ON_COMMAND(ID_BUTTONZoomProg, OnBUTTONZoomProg)
ON_COMMAND(ID_BUTTONZoomWin, OnBUTTONZoomWin)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_RBUTTONDOWN()
ON_WM_RBUTTONUP()
ON_UPDATE_COMMAND_UI(ID_BUTTONPanGlo, OnUpdateBUTTONPanGlo)
ON_UPDATE_COMMAND_UI(ID_BUTTONPan, OnUpdateBUTTONPan)
ON_UPDATE_COMMAND_UI(ID_BUTTONZoomProg, OnUpdateBUTTONZoomProg)
ON_UPDATE_COMMAND_UI(ID_BUTTONZoomWin, OnUpdateBUTTONZoomWin)
ON_UPDATE_COMMAND_UI(ID_BUTTONRot, OnUpdateBUTTONRot)
ON_COMMAND(ID_BUTTONWire, OnBUTTONWire)
ON_COMMAND(ID_BUTTONShade, OnBUTTONShade)
ON_UPDATE_COMMAND_UI(ID_BUTTONHlrOn, OnUpdateBUTTONHlrOn)
ON_UPDATE_COMMAND_UI(ID_BUTTONShade, OnUpdateBUTTONShade)
ON_UPDATE_COMMAND_UI(ID_BUTTONWire, OnUpdateBUTTONWire)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COCCDemoView construction/destruction
COCCDemoView::COCCDemoView()
{
myXmin=0;
myYmin=0;
myXmax=0;
myYmax=0;
myCurZoom=0;
myCurrentMode = CurAction3d_Nothing;
myVisMode = VIS_SHADE;
m_Pen = NULL;
myGraphicDriver = Handle(Graphic3d_GraphicDriver)::DownCast(
((COCCDemoApp*)AfxGetApp())->GetGraphicDevice()->GraphicDriver() );
}
COCCDemoView::~COCCDemoView()
{
if (!myView.IsNull())
myView->Remove();
if (m_Pen)
delete m_Pen;
}
BOOL COCCDemoView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// COCCDemoView drawing
void COCCDemoView::OnInitialUpdate()
{
CView::OnInitialUpdate();
myView = GetDocument()->GetViewer()->CreateView();
Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice =
((COCCDemoApp*)AfxGetApp())->GetGraphicDevice();
Handle(WNT_Window) aWNTWindow = new WNT_Window(theGraphicDevice,GetSafeHwnd ());
myView->SetWindow(aWNTWindow);
if (!aWNTWindow->IsMapped()) aWNTWindow->Map();
myCurrentMode = CurAction3d_Nothing;
myVisMode = VIS_SHADE;
RedrawVisMode();
}
void COCCDemoView::OnDraw(CDC* pDC)
{
COCCDemoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
myView->Redraw();
}
/////////////////////////////////////////////////////////////////////////////
// COCCDemoView diagnostics
#ifdef _DEBUG
void COCCDemoView::AssertValid() const
{
CView::AssertValid();
}
void COCCDemoView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
COCCDemoDoc* COCCDemoView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COCCDemoDoc)));
return (COCCDemoDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COCCDemoView message handlers
void COCCDemoView::OnSize(UINT nType, int cx, int cy)
{
if (!myView.IsNull())
myView->MustBeResized();
}
void COCCDemoView::OnBUTTONBack()
{
myView->SetProj(V3d_Ypos);
}
void COCCDemoView::OnBUTTONFront()
{
myView->SetProj(V3d_Yneg);
}
void COCCDemoView::OnBUTTONBottom()
{
myView->SetProj(V3d_Zneg);
}
void COCCDemoView::OnBUTTONTop()
{
myView->SetProj(V3d_Zpos);
}
void COCCDemoView::OnBUTTONLeft()
{
myView->SetProj(V3d_Xneg);
}
void COCCDemoView::OnBUTTONRight()
{
myView->SetProj(V3d_Xpos);
}
void COCCDemoView::OnBUTTONAxo()
{
myView->SetProj(V3d_XposYnegZpos);
}
void COCCDemoView::OnBUTTONPan()
{
myCurrentMode = CurAction3d_DynamicPanning;
}
void COCCDemoView::OnBUTTONPanGlo()
{
// save the current zoom value
myCurZoom = myView->Scale();
// Do a Global Zoom
myView->FitAll();
// Set the mode
myCurrentMode = CurAction3d_GlobalPanning;
}
void COCCDemoView::OnBUTTONReset()
{
myView->Reset();
}
void COCCDemoView::OnBUTTONRot()
{
myCurrentMode = CurAction3d_DynamicRotation;
}
void COCCDemoView::OnBUTTONZoomAll()
{
myView->FitAll();
myView->ZFitAll();
}
void COCCDemoView::OnBUTTONZoomProg()
{
myCurrentMode = CurAction3d_DynamicZooming;
}
void COCCDemoView::OnBUTTONZoomWin()
{
myCurrentMode = CurAction3d_WindowZooming;
}
void COCCDemoView::OnLButtonDown(UINT nFlags, CPoint point)
{
// save the current mouse coordinate in min
myXmin=point.x; myYmin=point.y;
myXmax=point.x; myYmax=point.y;
if ( ! (nFlags & MK_CONTROL) )
{
if (myCurrentMode == CurAction3d_DynamicRotation)
{
myView->SetComputedMode(Standard_False);
myView->StartRotation(point.x,point.y);
}
}
}
void COCCDemoView::OnLButtonUp(UINT nFlags, CPoint point)
{
if ( !(nFlags & MK_CONTROL) )
{
switch (myCurrentMode)
{
case CurAction3d_Nothing :
myXmax=point.x;
myYmax=point.y;
break;
case CurAction3d_DynamicZooming :
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_WindowZooming :
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False);
myXmax=point.x;
myYmax=point.y;
if ((abs(myXmin-myXmax)>ValZWMin) || (abs(myYmin-myYmax)>ValZWMin))
// Test if the zoom window is greater than a minimale window.
{
// Do the zoom window between Pmin and Pmax
myView->WindowFitAll(myXmin,myYmin,myXmax,myYmax);
}
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_DynamicPanning :
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_GlobalPanning :
myView->Place(point.x,point.y,myCurZoom);
myCurrentMode = CurAction3d_Nothing;
break;
case CurAction3d_DynamicRotation :
if (myVisMode == VIS_HLR)
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode(Standard_True);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
myCurrentMode = CurAction3d_Nothing;
break;
} //switch (myCurrentMode)
}
}
void COCCDemoView::OnRButtonDown(UINT nFlags, CPoint point)
{
if ( nFlags & MK_CONTROL )
{
myView->SetComputedMode(Standard_False);
myView->StartRotation(point.x,point.y);
}
}
void COCCDemoView::OnRButtonUp(UINT nFlags, CPoint point)
{
if (myVisMode == VIS_HLR)
{
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode(Standard_True);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
}
}
void COCCDemoView::OnMouseMove(UINT nFlags, CPoint point)
{
// ============================ LEFT BUTTON =======================
if ( nFlags & MK_LBUTTON)
{
if ( nFlags & MK_CONTROL )
{
// move with MB1 and Control : on the dynamic zooming
// Do the zoom in function of mouse's coordinates
myView->Zoom(myXmax,myYmax,point.x,point.y);
// save the current mouse coordinate in max
myXmax = point.x;
myYmax = point.y;
}
else // if ( Ctrl )
{
switch (myCurrentMode)
{
case CurAction3d_Nothing :
myXmax = point.x;
myYmax = point.y;
break;
case CurAction3d_DynamicZooming :
myView->Zoom(myXmax,myYmax,point.x,point.y);
// save the current mouse coordinate in max;
myXmax=point.x;
myYmax=point.y;
break;
case CurAction3d_WindowZooming :
myXmax = point.x; myYmax = point.y;
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_False,LongDash);
DrawRectangle(myXmin,myYmin,myXmax,myYmax,Standard_True,LongDash);
break;
case CurAction3d_DynamicPanning :
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
myXmax = point.x; myYmax = point.y;
break;
case CurAction3d_GlobalPanning : // nothing
break;
case CurAction3d_DynamicRotation :
myView->Rotation(point.x,point.y);
myView->Redraw();
break;
}
}
}
// ============================ MIDDLE BUTTON =======================
else if ( nFlags & MK_MBUTTON)
{
if ( nFlags & MK_CONTROL )
{
myView->Pan(point.x-myXmax,myYmax-point.y); // Realize the panning
myXmax = point.x; myYmax = point.y;
}
}
// ============================ RIGHT BUTTON =======================
else if ( nFlags & MK_RBUTTON)
{
if ( nFlags & MK_CONTROL )
{
myView->Rotation(point.x,point.y);
}
}
// ============================ NO BUTTON =======================
else
{
myXmax = point.x;
myYmax = point.y;
}
}
void COCCDemoView::OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (myCurrentMode == CurAction3d_GlobalPanning);
pCmdUI->Enable (myCurrentMode != CurAction3d_GlobalPanning);
}
void COCCDemoView::OnUpdateBUTTONPan(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicPanning);
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicPanning );
}
void COCCDemoView::OnUpdateBUTTONZoomProg(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicZooming );
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicZooming);
}
void COCCDemoView::OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (myCurrentMode == CurAction3d_WindowZooming);
pCmdUI->Enable (myCurrentMode != CurAction3d_WindowZooming);
}
void COCCDemoView::OnUpdateBUTTONRot(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (myCurrentMode == CurAction3d_DynamicRotation);
pCmdUI->Enable (myCurrentMode != CurAction3d_DynamicRotation);
}
void COCCDemoView::DrawRectangle(const Standard_Integer MinX,
const Standard_Integer MinY,
const Standard_Integer MaxX,
const Standard_Integer MaxY,
const Standard_Boolean Draw,
const LineStyle aLineStyle)
{
static int m_DrawMode;
if (!m_Pen && aLineStyle ==Solid )
{
m_Pen = new CPen(PS_SOLID, 1, RGB(0,0,0)); m_DrawMode = R2_MERGEPENNOT;
}
else if (!m_Pen && aLineStyle ==Dot )
{
m_Pen = new CPen(PS_DOT, 1, RGB(0,0,0)); m_DrawMode = R2_XORPEN;
}
else if (!m_Pen && aLineStyle == ShortDash)
{
m_Pen = new CPen(PS_DASH, 1, RGB(255,0,0)); m_DrawMode = R2_XORPEN;
}
else if (!m_Pen && aLineStyle == LongDash)
{
m_Pen = new CPen(PS_DASH, 1, RGB(0,0,0)); m_DrawMode = R2_NOTXORPEN;
}
else if (aLineStyle == Default)
{
m_Pen = NULL; m_DrawMode = R2_MERGEPENNOT;
}
CPen* aOldPen;
CClientDC clientDC(this);
if (m_Pen)
aOldPen = clientDC.SelectObject(m_Pen);
clientDC.SetROP2(m_DrawMode);
static Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
static Standard_Boolean m_IsVisible = Standard_False;
if ( m_IsVisible && !Draw) // move or up : erase at the old position
{
clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
clientDC.LineTo(StoredMaxX,StoredMaxY);
clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
m_IsVisible = false;
}
StoredMinX = min ( MinX, MaxX );
StoredMinY = min ( MinY, MaxY );
StoredMaxX = max ( MinX, MaxX );
StoredMaxY = max ( MinY, MaxY);
if (Draw) // move : draw
{
clientDC.MoveTo(StoredMinX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMaxY);
clientDC.LineTo(StoredMaxX,StoredMaxY);
clientDC.LineTo(StoredMaxX,StoredMinY); clientDC.LineTo(StoredMinX,StoredMinY);
m_IsVisible = true;
}
if (m_Pen)
clientDC.SelectObject(aOldPen);
}
void COCCDemoView::InitButtons()
{
myXmin=0;
myYmin=0;
myXmax=0;
myYmax=0;
myCurZoom=0;
myCurrentMode = CurAction3d_Nothing;
}
void COCCDemoView::Reset()
{
InitButtons();
myVisMode = VIS_SHADE;
if (!myView.IsNull())
{
RedrawVisMode();
myView->Reset();
}
}
void COCCDemoView::RedrawVisMode()
{
switch (myVisMode)
{
case VIS_WIREFRAME:
GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame);
myView->SetComputedMode (Standard_False);
myView->Redraw();
break;
case VIS_SHADE:
GetDocument()->GetAISContext()->SetDisplayMode(AIS_Shaded);
myView->SetComputedMode (Standard_False);
myView->Redraw();
break;
case VIS_HLR:
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
myView->SetComputedMode (Standard_True);
myView->Redraw();
SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW));
GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame);
break;
}
}
void COCCDemoView::OnBUTTONWire()
{
myVisMode = VIS_WIREFRAME;
RedrawVisMode();
}
void COCCDemoView::OnBUTTONShade()
{
myVisMode = VIS_SHADE;
RedrawVisMode();
}
void COCCDemoView::OnBUTTONHlrOn()
{
myVisMode = VIS_HLR;
RedrawVisMode();
}
void COCCDemoView::OnUpdateBUTTONWire(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (myVisMode == VIS_WIREFRAME);
pCmdUI->Enable (myVisMode != VIS_WIREFRAME);
}
void COCCDemoView::OnUpdateBUTTONShade(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (myVisMode == VIS_SHADE);
pCmdUI->Enable (myVisMode != VIS_SHADE);
}
void COCCDemoView::OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck (myVisMode == VIS_HLR);
pCmdUI->Enable (myVisMode != VIS_HLR);
}
void COCCDemoView::GetViewCenter(Standard_Real& Xc, Standard_Real& Yc)
{
myView->Center(Xc,Yc);
}
void COCCDemoView::SetViewCenter(Standard_Real Xc, Standard_Real Yc)
{
myView->SetCenter(Xc,Yc);
}
void COCCDemoView::GetViewEye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z)
{
myView->Eye(X,Y,Z);
}
void COCCDemoView::SetViewEye(Standard_Real X, Standard_Real Y, Standard_Real Z)
{
myView->SetEye(X,Y,Z);
}
Standard_Real COCCDemoView::GetViewScale()
{
return myView->Scale();
}
void COCCDemoView::SetViewScale(Standard_Real Coef)
{
myView->SetScale(Coef);
}

View File

@@ -1,138 +0,0 @@
// OCCDemoView.h : interface of the COCCDemoView class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_OCCDEMOVIEW_H__57A6A230_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
#define AFX_OCCDEMOVIEW_H__57A6A230_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
enum View3D_CurrentAction {
CurAction3d_Nothing,
CurAction3d_DynamicZooming,
CurAction3d_WindowZooming,
CurAction3d_DynamicPanning,
CurAction3d_GlobalPanning,
CurAction3d_DynamicRotation
};
class COCCDemoView : public CView
{
protected: // create from serialization only
COCCDemoView();
DECLARE_DYNCREATE(COCCDemoView)
// Attributes
public:
COCCDemoDoc* GetDocument();
// Operations
public:
void InitButtons();
void Reset();
void FitAll() { myView->FitAll(); myView->ZFitAll(); };
void GetViewCenter(Standard_Real& Xc, Standard_Real& Yc);
void SetViewCenter(const Standard_Real Xc, const Standard_Real Yc);
void GetViewEye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z);
void SetViewEye(const Standard_Real X,const Standard_Real Y,const Standard_Real Z);
Standard_Real GetViewScale();
void SetViewScale(const Standard_Real Coef);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(COCCDemoView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnInitialUpdate();
protected:
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~COCCDemoView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(COCCDemoView)
afx_msg void OnBUTTONAxo();
afx_msg void OnBUTTONBack();
afx_msg void OnBUTTONBottom();
afx_msg void OnBUTTONFront();
afx_msg void OnBUTTONHlrOn();
afx_msg void OnBUTTONLeft();
afx_msg void OnBUTTONPan();
afx_msg void OnBUTTONPanGlo();
afx_msg void OnBUTTONReset();
afx_msg void OnBUTTONRight();
afx_msg void OnBUTTONRot();
afx_msg void OnBUTTONTop();
afx_msg void OnBUTTONZoomAll();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnBUTTONZoomProg();
afx_msg void OnBUTTONZoomWin();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
afx_msg void OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI);
afx_msg void OnUpdateBUTTONPan(CCmdUI* pCmdUI);
afx_msg void OnUpdateBUTTONZoomProg(CCmdUI* pCmdUI);
afx_msg void OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI);
afx_msg void OnUpdateBUTTONRot(CCmdUI* pCmdUI);
afx_msg void OnBUTTONWire();
afx_msg void OnBUTTONShade();
afx_msg void OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI);
afx_msg void OnUpdateBUTTONShade(CCmdUI* pCmdUI);
afx_msg void OnUpdateBUTTONWire(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void RedrawVisMode();
private:
enum VisMode { VIS_WIREFRAME, VIS_SHADE, VIS_HLR };
Handle(V3d_View) myView;
Handle(Graphic3d_GraphicDriver) myGraphicDriver;
View3D_CurrentAction myCurrentMode;
VisMode myVisMode;
Standard_Integer myXmin;
Standard_Integer myYmin;
Standard_Integer myXmax;
Standard_Integer myYmax;
Standard_Real myCurZoom;
private:
enum LineStyle { Solid, Dot, ShortDash, LongDash, Default };
CPen* m_Pen;
virtual void DrawRectangle (const Standard_Integer MinX ,
const Standard_Integer MinY ,
const Standard_Integer MaxX ,
const Standard_Integer MaxY ,
const Standard_Boolean Draw ,
const LineStyle aLineStyle = Default );
};
#ifndef _DEBUG // debug version in OCCDemoView.cpp
inline COCCDemoDoc* COCCDemoView::GetDocument()
{ return (COCCDemoDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_OCCDEMOVIEW_H__57A6A230_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)

View File

@@ -1,206 +0,0 @@
// ResultDialog.cpp : implementation file
//
#include "stdafx.h"
#include "OCCDemo.h"
#include "ResultDialog.h"
#include "MainFrm.h"
#include "OCCDemoDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// minimum distance between buttons, button and dialog border
#define d 5
/////////////////////////////////////////////////////////////////////////////
// CResultDialog dialog
CResultDialog::CResultDialog(CWnd* pParent /*=NULL*/)
: CDialog(CResultDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CResultDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CResultDialog::Empty()
{
CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
pEd->Clear();
}
void CResultDialog::SetText(LPCSTR aText)
{
CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
CString aCStr(aText);
pEd->SetWindowText(aCStr);
}
void CResultDialog::SetTitle(LPCSTR aTitle)
{
CString aCStr(aTitle);
SetWindowText(aCStr);
}
void CResultDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CResultDialog)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CResultDialog, CDialog)
//{{AFX_MSG_MAP(CResultDialog)
ON_BN_CLICKED(IDC_CopySelectionToClipboard, OnCopySelectionToClipboard)
ON_BN_CLICKED(IDC_CopyAllToClipboard, OnCopyAllToClipboard)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResultDialog message handlers
void CResultDialog::OnCopySelectionToClipboard()
{
CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
pEd->Copy( );
}
void CResultDialog::OnCopyAllToClipboard()
{
CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
long nStartChar, nEndChar;
pEd->GetSel (nStartChar, nEndChar);
pEd->SetSel (0, -1);
pEd->Copy();
pEd->SetSel (nStartChar, nEndChar);
}
void CResultDialog::OnCancel()
{
CMainFrame* cFrame = (CMainFrame*) AfxGetApp()->GetMainWnd();
COCCDemoDoc* aDoc = (COCCDemoDoc*) cFrame->GetActiveDocument();
aDoc->IsShowResult() = FALSE;
CDialog::OnCancel();
}
void CResultDialog::Initialize()
{
// Set Fixed Width Font for rich edit control
CRichEditCtrl *pEd = (CRichEditCtrl *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
CFont aFixedWidthFont;
VERIFY(aFixedWidthFont.CreateFont(
15, // nHeight
5, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
FF_MODERN, // Fix width fonts are FF_MODERN
"Courier New")); // lpszFacename
pEd->SetFont(&aFixedWidthFont, false);
// save button's width and height, so they are calculated only once
RECT rect;
CWnd *pBCopy = (CWnd *) GetDlgItem (IDC_CopySelectionToClipboard);
pBCopy->GetWindowRect(&rect);
bw = rect.right - rect.left; // a button's width (they are all equal)
bh = rect.bottom - rect.top; // a button's height
}
// OnSize is a message handler of WM_SIZE messge,
// it is reimplemented in order to reposition the buttons
// (keep them always in the bottom part of the dialog)
// and resize the rich edit controls as user resized THIS dialog.
void CResultDialog::OnSize(UINT nType, int cx, int cy)
{
// call the base class handler
CDialog::OnSize(nType, cx, cy);
//resizes internal GUI controls (rich edit control and 3 buttons)
//according to given values of this dialog width (cx) and height (cy).
//the method is called from OnSize message handler and
//from InitInstance of OCCDemo to do initial resize
CWnd *pEd = (CWnd *) GetDlgItem (IDC_RICHEDIT_ResultDialog);
CWnd *pBCopy = (CWnd *) GetDlgItem (IDC_CopySelectionToClipboard);
CWnd *pBCopyAll = (CWnd *) GetDlgItem (IDC_CopyAllToClipboard);
CWnd *pBClose = (CWnd *) GetDlgItem (IDCANCEL);
if (pEd != NULL) // it is NULL when dialog is being created and OnSize is called
{
int butY = cy-bh-d; // y coordinate of buttons' top left corner
pEd->SetWindowPos(&wndTop, 0, 0, cx, butY-4*d, SWP_NOMOVE);
pBCopy->SetWindowPos(&wndTop, d, butY, 0, 0, SWP_NOSIZE);
pBCopyAll->SetWindowPos(&wndTop, d+bw+d, butY, 0, 0, SWP_NOSIZE);
pBClose->SetWindowPos(&wndTop, cx-bw-d, butY, 0, 0, SWP_NOSIZE);
}
RedrawWindow();
}
LRESULT CResultDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message != WM_SIZING)
return CDialog::WindowProc(message, wParam, lParam);
LPRECT pRect = (LPRECT) lParam;
int cx = pRect->right - pRect->left;
int cy = pRect->bottom - pRect->top;
int minCx = 3*bw+5*d;
int minCy = 2*d+bh+200;
if (cx < minCx || cy < minCy)
{
switch (wParam)
{
case WMSZ_BOTTOM:
pRect->bottom = pRect->top + minCy;
break;
case WMSZ_TOP:
pRect->top = pRect->bottom - minCy;
break;
case WMSZ_LEFT:
pRect->left = pRect->right - minCx;
break;
case WMSZ_RIGHT:
pRect->right = pRect->left + minCx;
break;
case WMSZ_TOPLEFT:
if (cx < minCx) pRect->left = pRect->right - minCx;
if (cy < minCy) pRect->top = pRect->bottom - minCy;
break;
case WMSZ_BOTTOMRIGHT:
if (cx < minCx) pRect->right = pRect->left + minCx;
if (cy < minCy) pRect->bottom = pRect->top + minCy;
break;
case WMSZ_TOPRIGHT:
if (cx < minCx) pRect->right = pRect->left + minCx;
if (cy < minCy) pRect->top = pRect->bottom - minCy;
break;
case WMSZ_BOTTOMLEFT:
if (cx < minCx) pRect->left = pRect->right - minCx;
if (cy < minCy) pRect->bottom = pRect->top + minCy;
break;
}
}
return CDialog::WindowProc(message, wParam, lParam);
}

View File

@@ -1,66 +0,0 @@
#if !defined(AFX_RESULTDIALOG_H__6597303D_7F5B_11D5_BA4D_0060B0EE18EA__INCLUDED_)
#define AFX_RESULTDIALOG_H__6597303D_7F5B_11D5_BA4D_0060B0EE18EA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ResultDialog.h : header file
//
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
// CResultDialog dialog
class CResultDialog : public CDialog
{
// Construction
public:
void Initialize();
CResultDialog(CWnd* pParent = NULL); // standard constructor
void SetTitle(LPCSTR aTitle);
void SetText(LPCSTR aText);
void Empty();
// Dialog Data
//{{AFX_DATA(CResultDialog)
enum { IDD = IDD_ResultDialog };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CResultDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CResultDialog)
afx_msg void OnCopySelectionToClipboard();
afx_msg void OnCopyAllToClipboard();
virtual void OnCancel();
// OnSize is a message handler of WM_SIZE messge,
// it is reimplemented in order to reposition the buttons
// (keep them always in the bottom part of the dialog)
// and resize the rich edit controls as user resized THIS dialog.
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
int bw, bh; // button width and height
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_RESULTDIALOG_H__6597303D_7F5B_11D5_BA4D_0060B0EE18EA__INCLUDED_)

View File

@@ -1,6 +0,0 @@
// stdafx.cpp : source file that includes just the standard includes
// OCCDemo.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -1,44 +0,0 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__57A6A22A_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)
#define AFX_STDAFX_H__57A6A22A_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
//#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#if !defined(WNT)
#error WNT precompiler directive is mandatory for CasCade
#endif
#pragma warning( disable : 4244 ) // Issue warning 4244
#include "Standard_ShortReal.hxx"
#pragma warning( default : 4244 ) // Issue warning 4244
#include <Standard.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
#include <AIS_Point.hxx>
#include <Graphic3d_WNTGraphicDevice.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <WNT_Window.hxx>
#include <Standard_ErrorHandler.hxx>
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__57A6A22A_7B4F_11D5_BA4A_0060B0EE18EA__INCLUDED_)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Some files were not shown because too many files have changed in this diff Show More