1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

Compare commits

...

71 Commits

Author SHA1 Message Date
bugmaster
fecb042498 Update version up to 7.5.3 2021-08-04 10:41:47 +03:00
jgv
c194e1bc39 0032291: Modeling Algorithms - General Fuse produces wrong number of solids
Modify method IntWalk_IWalking::ComputeCloseLine: add new flag "isOnDegeneratedBorder" to reach the border successfully.
2021-08-04 10:14:00 +03:00
emv
96815dec17 0032307: Modeling Algorithms - Empty result of offset operation in mode "Complete" Joint type "Intersection"
Make sure the vertices created by pairwise intersection of edges connected in the same vertex are unified correctly.
2021-07-29 14:17:24 +03:00
emv
03e79361dc 0032088: Modeling Algorithms - Empty result of offset operation in mode "Complete" join type "Intersection"
Mark inverted edges located inside loops of invalid edges as invalid as well.
2021-07-29 12:55:24 +03:00
akaftasev
3a8f6b11e8 0031147: Modeling Algorithms - BRepOffsetAPI_MakePipeShell null access
Added to Draw command 'setsweep ' posibility to change degmax and segmax parameter manually by '-SM' and '-DM' options
Added test
Added new condition to prevent crash
2021-07-29 12:48:56 +03:00
akaftasev
45ec28cf68 0029645: Hang on making pipe shell using BRepOffsetAPI_MakePipeShell
Added new boolean parameter to GeomLib::FuseIntervals() to select method of defining an element with close values
2021-07-29 12:48:22 +03:00
aavtamon
7aaaf5eb13 0028572: Modeling Algorithms - Wrong result of the mkface command
- Added note to BRepBuilderAPI_MakeFace(const Handle(Geom_Surface)& S,
										const TopoDS_Wire& W,
										const Standard_Boolean Inside = Standard_True)
in BRepBuilderAPI_MakeFace.hxx;
- Modified subsubsection occt_modalg_3_5_2 in dox/user_guides/modeling_algos/modeling_algos.md
2021-07-29 12:46:44 +03:00
bugmaster
0dc2c377fc Update version up to 7.5.2 2021-04-20 10:07:58 +03:00
ifv
1078e94941 0032225: Modeling Data - Wrong result of extrema curve-surface
Extrema_GenExtCS.cxx: subdivision on intervals for periodic c curves is added

Extrema_FuncExtCS.hxx: access to fields mySqDist, myPoint1, myPoint2 is added

bug32225: new test case is added
2021-04-20 09:49:15 +03:00
emv
6b26c6d26d 0032199: Modeling Algorithms - BOP Cut produces invalid shape
Use section tolerance for checking the valid range.
2021-04-16 16:13:06 +03:00
jgv
dd56857183 0031984: Modeling Algorithms - Sweep crashes if Bi-normal is given
Small modification in BRepFill_Sweep: to avoid exception, return status NotDone if construction of pipe surface fails.
2021-04-16 15:54:26 +03:00
jgv
2c8eacb996 0032213: Modeling Algorithms - Invalid result of UnifySameDomain
Modify unification of faces: add splitting new wire into several ones.
2021-04-16 15:52:26 +03:00
gka
3b05b748de 0032264: Data Exchange - STEP exporter generates bad geometry [REGRESSION since 7.4.0]
Location of edge is applied to geom curve before analysis of vertices projections
2021-04-16 15:49:03 +03:00
jgv
91e51cb0f2 0032140: Modeling Algorithms - unify same domain calls crossed for opposite vectors
1. Correct unification of circular edges: avoid trying to make an axis with null magnitude.
2. New method UnionPCurves: unify existing pcurves of chain instead of projecting the curve of unified edge onto surfaces
2021-04-16 15:24:04 +03:00
emv
bb00fe2713 0032136: Modeling Algorithms - Boolean fuse fails and corrupts the argument-shape
Avoid increasing tolerance of the vertex before the check on valid range is passed.
2021-04-16 15:21:08 +03:00
bugmaster
94c00556ea Update version up to 7.5.1 2021-02-02 11:51:56 +03:00
emv
bf67bbf8fe 0031912: Modeling Algorithms - Boolean Cut can't build resulting shape
Problem is fixed by #0032058. Integrating test case only.
2021-02-02 11:49:33 +03:00
ifv
edf111202c 0032058: Modeling Data - Extrema curve-surface gives wrong result for planar surface of revolunion and circle
Extrema_GenExtCS.cxx : added solution refinement, if solution seems to be "bad" according to special criteria.
Extrema_FuncExtCS.cxx : "cosmetic" modifications
BOPAlgo_PaveFiller_3.cxx : adding control of shape index to prevent exception in ShapeInfo
bugs/moddata_3/bug32058 : new test
2021-02-02 11:30:40 +03:00
jgv
bbdcdcdd80 0031845: Modeling Algorithms - BRepOffsetAPI_MakeThickSolid fails
Multiple changes in BRepOffset_MakeOffset algorithm:
- correct fusing vertices;
- correct building intersection edges;
- correct intersecting new edges in 2D;
- correct building wire on a new face;
- correct building history.
2021-01-29 13:47:21 +03:00
bugmaster
2ecd3a06a6 Update version up to 7.5.1.dev 2020-11-11 20:08:01 +03:00
bugmaster
628c0211d5 Increment OCCT version up to 7.5.0 2020-11-02 19:52:44 +03:00
kgv
dbecff5fab 0031898: Coding Rules - extend Standard_WarningsDisable.hxx with -Wreorder 2020-11-02 19:41:29 +03:00
asuraven
7a88ce5b98 0029108: Crash writing STEP file
* Wrapped a try / catch block on creating objects in TopoDSToStep_MakeStepFace::Init()
2020-11-02 14:32:39 +03:00
Xu Zhongxing
2b7fd8c81c 0031887: IntTools_Context::IsPointInFace always return TRUE
If aDist >= aTol, bIn is never updated to false, and the function
always returns TRUE.
2020-10-30 18:25:19 +03:00
kgv
a8b9d7eb27 0031888: Configuration, qmake - linkage error due to missing .cpp file in TKMesh
OccToolkit.pri now handles also .cpp file extension.
2020-10-29 19:04:46 +03:00
dpasukhi
71af3370c4 0031878: DXF import - support Windows and ISO 8859 code pages in DXF import
Add support of converting Big5 and GBK code pages to Unicode within Resource_Unicode::ConvertFormatToUnicode
2020-10-29 19:01:54 +03:00
asuraven
40858cc79c 0030921: Data Exchange - STEPCAFControl_Reader incorrectly reads the specified stp file -- refactoring
File StepToGeom_MakeBSplineCurve.pxx is removed, relevant code is converted to C++ template and merged to StepToGeom.cxx
2020-10-29 18:55:37 +03:00
asuraven
3940436ae2 0030921: Data Exchange - STEPCAFControl_Reader incorrectly reads the specified stp file -- fix
The number of weights is adjusted to the number of poles in StepToGeom::MakeBSplineCurve(2d).
2020-10-29 18:55:36 +03:00
kgv
c3da64a686 0031884: Data Exchange - NULL de-reference within STEPCAFControl_Reader::SetSourceCodePage()
Removed methods with unclear usage rules.
2020-10-28 22:19:23 +03:00
mzernova
4065c66c24 0031808: Visualization - NULL dereference in Graphic3d_Structure::IsDisplayed() on Removed presentation
Added a NULL check for IsDisplayed(), IsHighlighted(), IsTransformed(), IsVisible(), etc.
2020-10-28 22:18:12 +03:00
abv
94f16a8961 0014673: Provide true support for Unicode symbols
Construction of TCollection_ExtendedString from plain C string is fixed to consider input string as UTF-8 in several places (identified as described in notes to #31113).

Message_MsgFile is corrected to load resource file as UTF-8 (unless it has BOM indicating use of UTF-16).

Added tests for use of Unicode in some DRAW commands (bugs demo bug14673_*)
2020-10-28 22:18:11 +03:00
kgv
aa7e9f8d78 0031881: Coding Rules - OpenGl_HaltonSampler::initRandom() uses deprecated in C++14 function std::random_shuffle
Unused function has been removed.
2020-10-28 19:24:00 +03:00
akaftasev
5445eaeed5 0030003: Construction of pipe by two circular sections and spine curve leads to crash
GeomFill_NSection.cxx  : setting of UPeriodic flag while call constructor of BSpline surface is added

bug3003 : Test cases added
2020-10-27 19:46:14 +03:00
asuraven
07bc68e8d8 0031873: Samples, Qt OCCT Overview sample - Problems of compilation and launch in 32 bit mode on Windows 2020-10-26 19:47:54 +03:00
kgv
ec4128df29 0031876: Configuration - Prs3d_Arrow::DrawShaded() crashes in msvc10 win32 Release build
Use longer code syntax to workaround compiler bug.
2020-10-26 19:45:16 +03:00
abv
f41fd243b6 0031877: DRAW - some Visualization commands are not protected against uninitialized viewer
Added protections in DRAW commands against accessing Null context

Added test bugs demo bug31877
2020-10-25 08:46:49 +03:00
kgv
9f9490e1ae 0031875: Draw Harness, ViewerTest - command vaspects -mostContinuity lacks g1 and g2 options
vaspects -mostContinuity now accepts g1 and g2 values.
2020-10-23 19:58:51 +03:00
emv
0612bb7010 0031858: Modeling Algorithms - boolean operation crash between the given cylinder and torus.
Integrating test cases only, as the problem is not reproduced.
2020-10-23 19:57:30 +03:00
ifv
7ccfd41fa2 0031782: Modeling Algorithms - Regressions on VS 2019 (vc142) on fillet tests
ChFiKPart_ComputeData_FilPlnCyl.cxx - rewriting some code to avoid "extra" optimization
2020-10-23 19:56:03 +03:00
dpasukhi
692decba26 0031825: Data Exchange, STEP - NULL dereference while re-exporting model with empty Datum description
Fix adding name and description of the datum
2020-10-23 19:54:58 +03:00
dpasukhi
1b9cb073b9 0028454: Data Exchange, STEP reader - names with special characters cannot be read
- Add support of the control directives ( "\X2\" "\X4" "\X\" "\P*\" "\S\");
- Make param "read.stepcaf.codepage" base for conversion inside StepData instead of CAF;
- Rename "read.stepcaf.codepage" to "read.step.codepage".
- Add ISO 8859-1 - 9 code pages for conversion
- Add Resource_FormatType_NoConversion format type, that indicates non-conversion behavior
- Update old test cases that contain control directives
2020-10-22 17:54:29 +03:00
ifv
380748c340 0027469: Modeling Algorithms - Regression vs 6.9.1: Wrong result of Edge/Face intersection
IntTools/IntTools_BeanFaceIntersector.cxx - decreasing parameter aDeltaRestrictor in method ComputeRangeFromStartPoint(...) to avoid "jumping" across the common part boundary.

IntTools/IntTools_EdgeFace.cxx - method IsCoincident() - improving criteria of coincidence between edge and face.
2020-10-22 17:49:17 +03:00
kgv
a966542b8a 0031866: Documentation - add description to Graphic3d_NameOfMaterial enumeration values
Enumeration values have been renamed to use complete prefix Graphic3d_NOM_ -> Graphic3d_NameOfMaterial_
and to match string names (with old values preserved as aliases).
2020-10-22 17:40:42 +03:00
asuraven
8833fd4dc5 0031827: Samples - Qt OCCT Overview sample is not compiled with VS 2010
* Menu storage changed from json to XML (because Qt 4 does not support json)
 * C++11 for(object : container) construction changed to OCCT iterators / Qt foreach
 * enum type::name changed to type_name
 * non used class members removed
 * Qt connect functions changed to macros version
 * warning 4127 disabled for Q_INIT_RESOURCE in VS2010 / Qt 4 case
 * widgets parent problem on Qt 4 fixed
 * QRegularExpression changed to QRegExp
2020-10-22 17:35:37 +03:00
kgv
1877dc98c9 0031856: Draw Harness - ReadStep should propagate progress indicator
Added progress indication to commands ReadStep, WriteStep, ReadIges, WriteIges, XOpen, XSave.

Draw_ProgressIndicator::Reset() now backups Tcl result string before evaluating command,
so that Draw_ProgressIndicator destructor will not eat error/result message in main command.
2020-10-20 18:16:09 +03:00
jgv
3e98579a83 0031855: Modeling Algorithms - regression of the unifysamedom command.
Transformation of 2d-curves on elementary surfaces has been corrected.
2020-10-20 18:13:49 +03:00
kgv
16ed73bec5 0031790: Configuration, CMake - add optional OpenVR dependency 2020-10-17 18:07:29 +03:00
abv
ae9f4b64ca 0031851: Data Exchange, STEP - enable Unicode symbols in STEP export
Class STEPCAFControl_Writer is corrected to avoid replacing non-Ascii symbols by question marks, and spaces by underscores, on export to STEP.

Related: DRAW commands dealing with strings in OCAF documents are corrected to pass Unicode symbols as UTF-8.

Off-topic: code saving names of external STEP files in XDE and fetching them back is corrected to preserve Unicode symbols as UTF-8.

Added test bugs xde bug31851

Test de step_4 E7 corrected (no more replacement of spaces by underscores in names of layers)
2020-10-14 19:28:58 +03:00
emv
870ae593c3 0031850: Modeling Algorithms - boolean cut and common generate unexpected result
IntPatch_WLineTool::JoinWLines(): using correct point for the check if WLines may be joined.
2020-10-14 19:25:45 +03:00
emv
135c2bd908 0031835: Modeling Algorithms - step by step Boolean common produces bad shape on given three cylinders
Fix inconsistency between IntAna_QuadQuadGeo(gp_Cylinder,gp_Cylinder) and AxeOperator::Coplanar().
2020-10-14 19:23:26 +03:00
kgv
6eeb528cd1 0031848: [REGRESSION] Visualization - MoveTo() triggers exception "gp_Dir() - input vector has zero norm"
SelectMgr_RectangularFrustum::Overlaps() - added zero magnitude check.

Commands vsphere,vcylinder,vtorus have been corrected to provide missing parameters defining number of stacks and slices.
2020-10-14 19:17:33 +03:00
emv
815f039bd2 0031836: Modeling Algorithms - Boolean cut failed between a Cone and a Torus
BOPAlgo_PaveFiller::UpdateExistingPaveBlocks: Add check for closed edge when updating pave block.
2020-10-13 19:18:02 +03:00
abv
81f2078cdb 0031575: Tests - make location of source test folder available in test
Documentation of global variables available for the test script during test execution is improved.

Off-topic: mark-up error is fixed in DRAW user guide
2020-10-13 19:15:39 +03:00
ifv
794aa3390c 0029722: Modeling Algorithms - checkshape modifies UV points of parametric curve
removed updating uvpoints from WireExplorer
2020-10-13 19:09:44 +03:00
kgv
d922149528 0031842: Coding Rules, BOPAlgo - eliminate CLang warning -fsanitize=undefined reference binding to null pointer
Added NULL checks before Progress Scope pointer dereference.
2020-10-13 19:07:42 +03:00
mpv
2958b91f62 0031841: Coding Rules, LDOM_XmlReader - eliminate new CLang compiler warning -Wtautological-overlap-compare 2020-10-13 19:06:40 +03:00
kgv
cdfcd39b69 0031833: Visualization - dynamic highlighting does not appear within ImmediateRedraw()
AIS_ViewController::contextLazyMoveTo() now undoes Z Range changes after MoveTo().
2020-10-09 18:29:52 +03:00
vsv
c4d4fceaa7 0031824: Samples - Code is not displayed in Qt OCCT Overview sample after compilation by CMake 2020-10-09 18:28:27 +03:00
abv
d730835599 0031095: Debugging - add code for display of TCollection_AsciiString as UTF-8 in Visual Studio debugger visualizer 2020-10-09 18:26:03 +03:00
kgv
a84f14abee 0031830: Documentation - broken reference 14 in pbr_math document
References to literature are simplified to reduce duplication of names.
List of references is converted to table for better presentation.
2020-10-09 18:24:24 +03:00
bugmaster
278da162dc Increment OCCT version up to 7.5.0beta 2020-10-06 20:40:27 +03:00
dpasukhi
baf60a870c 0031670: Data Exchange - cp1251 Cyrillic characters in STEP file
Add support for converting pages from Windows encoding to Unicode
2020-10-06 20:40:26 +03:00
jgv
99c9a82021 0031735: Modeling Algorithms - BRepOffset_MakeOffset works slowly and produces wrong result
Modify method IsPlanar of BRepOffset_MakeOffset: try to make planar all possible faces to simplify the input shape.
2020-10-06 20:40:25 +03:00
ifv
bf46352772 0031700: Modeling Algorithms - Regression in 0029580 after integration 0029839
BOPAlgo_PaveFiller_6.cxx: protection against creation of thin faces is added
bug29580_1: reverting in original state

dimensions.tcl: correction according to current state of BO algorithm
2020-10-06 20:40:24 +03:00
asuraven
a2176e6524 0031570: Samples - add Qt samples similar to standard MFC samples
Added Qt sample OCCTOverview providing examples of use of OCCT API with relevant code and demonstration of results in the viewer.

Off-topic: some unused images are removed from dox/introduction/images/
2020-10-06 20:40:23 +03:00
tiv
50ae6dad80 0031821: Coding - Uninitialized variables in TKFillet project
Some variables that remain uninitialized in the project TKFillet received proper initializers.
2020-10-06 20:40:22 +03:00
gka
809a2e13f8 0031812: IGES import - NURBS patches lost in the import process - 720
Correction for case invalid color definition to avoid considering an entity that has a number corresponding to the color field as erroneous if entity is not a color entity.
2020-10-06 20:40:21 +03:00
abv
b81a7e3160 0030378: Data Exchange - extract of subset of model entities fails (regression)
Field theflags in class Interface_BitMap is always initialized to avoid exception on operations with the class.

Added test bugs step bug30378
2020-10-06 20:40:20 +03:00
kgv
afe3ff9aaa 0031820: Tests - "dlog get" skips last exception when calling 'test" with echo OFF
Added missing puts to "test" command.
2020-10-05 13:29:54 +03:00
abv
b9ec690a2f 0031819: Documentation - add references to Flex and Bison
References to Flex and Bison added

Related:
- table of third-party tools in Requirements section is reorganized to be more clear
- sections Acknowledgements and Installation are updated
2020-10-03 16:07:52 +03:00
abv
d430d12909 0030800: Foundation Classes, UnitsAPI - poise dynamic viscosity unit is not defined correctly
Definition of Poise unit corrected.

Added test bugs fclasses bug30800
2020-10-03 16:06:35 +03:00
444 changed files with 19740 additions and 1642 deletions

View File

@@ -101,7 +101,7 @@ if (BUILD_USE_PCH)
# Load Cotire tool for accelerating build procedure
include(cotire)
# Set Cotire to ignore lxx, pxx, gxx
# Set Cotire to ignore lxx, pxx, gxx
set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS "lxx;pxx;gxx" CACHE STRING "Set Cotire to ignore OCCT specific files that can be #included" FORCE)
# Set priority for inclusion of system headers in PCH to reduce problems
@@ -165,7 +165,7 @@ if (NOT DEFINED CMAKE_INSTALL_PREFIX_PREV)
elseif (NOT "${CMAKE_INSTALL_PREFIX_PREV}" STREQUAL "${CMAKE_INSTALL_PREFIX}")
# CMAKE_INSTALL_PREFIX has been changed at previous step
set (CMAKE_INSTALL_PREFIX_PREV "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
# INSTALL_DIR is required to be updated
set (INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${INSTALL_DIR_DESCR}" FORCE)
endif()
@@ -177,10 +177,10 @@ elseif (NOT "${INSTALL_DIR_PREV}" STREQUAL "${INSTALL_DIR}")
# INSTALL_DIR has been changed at previous step
set (INSTALL_DIR_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
# sync CMAKE_INSTALL_PREFIX with INSTALL_DIR
# sync CMAKE_INSTALL_PREFIX with INSTALL_DIR
set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
# set CMAKE_INSTALL_PREFIX_PREV to avoid the reset of structure of the install folder
# set CMAKE_INSTALL_PREFIX_PREV to avoid the reset of structure of the install folder
set (CMAKE_INSTALL_PREFIX_PREV "${INSTALL_DIR}" CACHE INTERNAL "" FORCE)
endif()
@@ -406,7 +406,7 @@ if (NOT DEFINED BUILD_DOC_Overview)
set (DO_ONLY_CHECK_FOR_DOXYGEN ON)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/doxygen")
set (DO_ONLY_CHECK_FOR_DOXYGEN OFF)
if (CAN_DOXYGEN_BE_USED)
message (STATUS "Info. Overview building is turned on")
endif()
@@ -495,7 +495,7 @@ OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_csf")
if (USE_TCL)
message (STATUS "Info: TCL is used by OCCT")
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tcl")
message (STATUS "Info: TK is used by OCCT")
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/tk")
else()
@@ -523,7 +523,7 @@ if (USE_VTK)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")
if (NOT CAN_USE_VTK EQUAL -1)
message (STATUS "Info: TKIVtk and TKIVtkDraw toolkits excluded due to VTK usage is disabled")
@@ -565,6 +565,26 @@ else()
OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
endif()
# OpenVR
# search for CSF_OpenVR variable in EXTERNLIB of each being used toolkit
OCCT_IS_PRODUCT_REQUIRED (CSF_OpenVR CAN_USE_OPENVR)
if (CAN_USE_OPENVR)
set (USE_OPENVR OFF CACHE BOOL "${USE_OPENVR_DESCR}")
if (USE_OPENVR)
add_definitions (-DHAVE_OPENVR)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/openvr")
else()
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENVR")
OCCT_CHECK_AND_UNSET ("INSTALL_OPENVR")
endif()
else()
OCCT_CHECK_AND_UNSET ("USE_OPENVR")
OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENVR")
OCCT_CHECK_AND_UNSET ("INSTALL_OPENVR")
endif()
# FFmpeg
# search for CSF_FFmpeg variable in EXTERNLIB of each being used toolkit
OCCT_IS_PRODUCT_REQUIRED (CSF_FFmpeg CAN_USE_FFMPEG)
@@ -694,14 +714,14 @@ else()
OCCT_CHECK_AND_UNSET ("3RDPARTY_DOT_EXECUTABLE")
endif()
# bison
# bison
if (BUILD_YACCLEX)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/bison")
else()
OCCT_CHECK_AND_UNSET ("3RDPARTY_BISON_EXECUTABLE")
endif()
# flex
# flex
if (BUILD_YACCLEX)
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/flex")
else()
@@ -780,7 +800,7 @@ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/libd")
if (WIN32)
if (WIN32)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
@@ -849,9 +869,11 @@ if (INSTALL_SAMPLES)
OCCT_INSTALL_FILE_OR_DIR ("samples/java" "${INSTALL_DIR_SAMPLES}")
OCCT_INSTALL_FILE_OR_DIR ("samples/ocafsamples" "${INSTALL_DIR_SAMPLES}")
OCCT_INSTALL_FILE_OR_DIR ("samples/qt" "${INSTALL_DIR_SAMPLES}")
OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code" "${INSTALL_DIR_SAMPLES}/OCCTOverview")
install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/FuncDemo" RENAME "env.${SCRIPT_EXT}")
install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/IESample" RENAME "env.${SCRIPT_EXT}")
install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/OCCTOverview" RENAME "env.${SCRIPT_EXT}")
install (FILES "${CMAKE_BINARY_DIR}/env.samples.${SCRIPT_EXT}" DESTINATION "${INSTALL_DIR_SAMPLES}/qt/Tutorial" RENAME "env.${SCRIPT_EXT}")
endif()
@@ -965,6 +987,15 @@ if (BUILD_SAMPLES_QT)
OCCT_INSTALL_FILE_OR_DIR ("samples/${RESOURCE}" "${INSTALL_DIR_RESOURCE}/samples")
#message("Copy Sample resources: samples/${RESOURCE} into ${INSTALL_DIR_RESOURCE}/samples")
endforeach()
## Copy sources of OCCTOverview for using in the sample
OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/DataExchangeSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/OcafSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/GeometrySamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/TopologySamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/TriangulationSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/Viewer2dSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
OCCT_INSTALL_FILE_OR_DIR ("samples/OCCTOverview/code/Viewer3dSamples.cxx" "${INSTALL_DIR_SAMPLES}/OCCTOverview/code")
endif()
@@ -1182,7 +1213,7 @@ foreach (OCCT_MODULE ${OCCT_MODULES_ENABLED})
install(EXPORT OpenCASCADE${OCCT_MODULE}Targets DESTINATION "${INSTALL_DIR_CMAKE}")
endforeach()
# Update generated OpenCASCADETargets-*.cmake files
# Update generated OpenCASCADETargets-*.cmake files
# to have correct paths to libraries depending on the configuration
OCCT_UPDATE_TARGET_FILE ()

View File

@@ -1 +1 @@
qt AndroidQt FuncDemo IESample Tutorial
qt AndroidQt FuncDemo IESample Tutorial OCCTOverview

View File

@@ -1,2 +1,3 @@
qt/Common/res/
qt/Tutorial/res/
qt/Tutorial/res/
qt/OCCTOverview/res/

View File

@@ -97,12 +97,12 @@ macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_CSF_NAME LIBRARY_NAME
if (3RDPARTY_${PRODUCT_NAME}_DIR AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DIR}")
find_path (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR NAMES ${HEADER_NAME}
PATHS ${3RDPARTY_${PRODUCT_NAME}_DIR}
PATH_SUFFIXES include inc
PATH_SUFFIXES include inc headers
CMAKE_FIND_ROOT_PATH_BOTH
NO_DEFAULT_PATH)
else()
find_path (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR NAMES ${HEADER_NAME}
PATH_SUFFIXES include inc
PATH_SUFFIXES include inc headers
CMAKE_FIND_ROOT_PATH_BOTH)
endif()
endif()
@@ -125,10 +125,14 @@ macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_CSF_NAME LIBRARY_NAME
set (${PRODUCT_NAME}_PATH_SUFFIXES lib)
if (WIN32)
set (${PRODUCT_NAME}_PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES} win${COMPILER_BITNESS}/${COMPILER}/lib)
set (${PRODUCT_NAME}_PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES} lib/win${COMPILER_BITNESS})
endif()
if (ANDROID)
set (${PRODUCT_NAME}_PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES} libs/${ANDROID_ABI})
endif()
if(UNIX AND NOT APPLE AND NOT ANDROID)
set (${PRODUCT_NAME}_PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES} lib/linux${COMPILER_BITNESS})
endif()
# set 3RDPARTY_${PRODUCT_NAME}_LIBRARY as notfound, otherwise find_library can't assign a new value to 3RDPARTY_${PRODUCT_NAME}_LIBRARY
set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX} "3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX}-NOTFOUND" CACHE FILEPATH "The path to ${PRODUCT_NAME} library \"${LIBRARY_NAME}\"" FORCE)
@@ -184,7 +188,7 @@ macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_CSF_NAME LIBRARY_NAME
if ((3RDPARTY_${PRODUCT_NAME}_DIR AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DIR}") OR (3RDPARTY_${PRODUCT_NAME}_DLL_DIR_${LIBRARY_NAME} AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR_${LIBRARY_NAME}}"))
find_library (3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX} NAMES ${LIBRARY_NAME}
PATHS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR_${LIBRARY_NAME}}" "${3RDPARTY_${PRODUCT_NAME}_DIR}"
PATH_SUFFIXES bin win${COMPILER_BITNESS}/${COMPILER}/bin
PATH_SUFFIXES bin win${COMPILER_BITNESS}/${COMPILER}/bin bin/win${COMPILER_BITNESS}
NO_DEFAULT_PATH)
if (3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX} STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX}-NOTFOUND")
# find directory recursive
@@ -238,6 +242,7 @@ macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_CSF_NAME LIBRARY_NAME
if (INSTALL_${PRODUCT_NAME})
OCCT_MAKE_OS_WITH_BITNESS()
OCCT_MAKE_COMPILER_SHORT_NAME()
set (USED_3RDPARTY_${PRODUCT_NAME}_DIR "")
if (WIN32)
if (SINGLE_GENERATOR)
@@ -280,14 +285,17 @@ macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_CSF_NAME LIBRARY_NAME
endif()
else()
# the library directory for using by the executable
foreach (LIBRARY_NAME ${${LIBRARY_CSF_NAME}})
string (REPLACE "." "" LIBRARY_NAME_SUFFIX "${LIBRARY_NAME}")
foreach (LIBRARY_NAME ${${LIBRARY_CSF_NAME}})
string (REPLACE "." "" LIBRARY_NAME_SUFFIX "${LIBRARY_NAME}")
if (WIN32)
set (USED_3RDPARTY_${PRODUCT_NAME}_DIRS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR_${LIBRARY_NAME_SUFFIX}};${USED_3RDPARTY_${PRODUCT_NAME}_DIRS}")
else()
set (USED_3RDPARTY_${PRODUCT_NAME}_DIRS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR_${LIBRARY_NAME_SUFFIX}}:${USED_3RDPARTY_${PRODUCT_NAME}_DIRS}")
endif()
endforeach()
if (WIN32)
set (USED_3RDPARTY_${PRODUCT_NAME}_DIR ${3RDPARTY_${PRODUCT_NAME}_DLL_DIR_${LIBRARY_NAME_SUFFIX}})
endif()
endif()
mark_as_advanced (3RDPARTY_${PRODUCT_NAME}_LIBRARY_${LIBRARY_NAME_SUFFIX} 3RDPARTY_${PRODUCT_NAME}_DLL_${LIBRARY_NAME_SUFFIX})

View File

@@ -42,6 +42,13 @@ else()
endif()
endif()
# OpenVR
if (USE_OPENVR)
set (CSF_OpenVR "openvr_api")
else()
set (CSF_OpenVR)
endif()
# TCL/TK
if (USE_TCL)
if (WIN32)

5
adm/cmake/openvr.cmake Normal file
View File

@@ -0,0 +1,5 @@
# OpenVR SDK
# OpenVR is an API and runtime that allows access to VR hardware from multiple vendors without requiring that applications have specific knowledge of the hardware they are targeting.
# https://github.com/ValveSoftware/openvr
THIRDPARTY_PRODUCT("OPENVR" "openvr.h" "CSF_OpenVR" "")

View File

@@ -89,6 +89,7 @@ INSTALL_MESSAGE (INSTALL_TEST_CASES "non-regression OCCT test scripts")
INSTALL_MESSAGE (INSTALL_DOC_Overview "OCCT overview documentation (HTML format)")
INSTALL_MESSAGE (INSTALL_FFMPEG "FFmpeg binaries")
INSTALL_MESSAGE (INSTALL_FREEIMAGE "FreeImage binaries")
INSTALL_MESSAGE (INSTALL_OPENVR "OpenVR binaries")
INSTALL_MESSAGE (INSTALL_EIGEN "EIGEN header files")
INSTALL_MESSAGE (INSTALL_EGL "EGL binaries")
INSTALL_MESSAGE (INSTALL_GLES2 "OpenGL ES 2.0 binaries")
@@ -162,6 +163,9 @@ set (USE_FREEIMAGE_DESCR
"Indicates whether Freeimage product should be used in OCCT visualization
module for support of popular graphics image formats (PNG, BMP etc)")
set (USE_OPENVR_DESCR
"Indicates whether OpenVR should be used in OCCT visualization module for VR support")
set (USE_RAPIDJSON_DESCR
"Indicates whether RapidJSON product should be used in OCCT DataExchange
module for support of JSON-based formats like glTF")

View File

@@ -77,8 +77,8 @@ for (aCfgIter, CONFIG) {
# Define the list of standard OCCT file extensions
aHxxRegex = ^.*\.(hxx|h|lxx|gxx)$
aPxxRegex = ^.*\.(pxx)$
aCxxRegex = ^.*\.(cxx|c)$
mac { aCxxRegex = ^.*\.(cxx|c|m|mm)$ }
aCxxRegex = ^.*\.(cxx|cpp|c)$
mac { aCxxRegex = ^.*\.(cxx|cpp|c|m|mm)$ }
# Auxiliary function for probing file extension
defineTest (occCheckExtension) {

View File

@@ -14,6 +14,7 @@ if /I "%VCVER%" == "@COMPILER@" (
set "TBB_DIR=@3RDPARTY_TBB_DLL_DIR@"
set "VTK_DIR=@3RDPARTY_VTK_DLL_DIR@"
set "FFMPEG_DIR=@3RDPARTY_FFMPEG_DLL_DIR@"
set "OPENVR_DIR=@3RDPARTY_OPENVR_DLL_DIRS@"
if not "@3RDPARTY_QT_DIR@" == "" (
set "QTDIR=@3RDPARTY_QT_DIR@"

View File

@@ -10,12 +10,13 @@ if /I "%VCVER%" == "@COMPILER@" (
set "TCL_DIR=@USED_3RDPARTY_TCL_DIR@"
set "TK_DIR=@USED_3RDPARTY_TK_DIR@"
set "FREETYPE_DIR=@USED_3RDPARTY_FREETYPE_DIR@"
set "FREEIMAGE_DIR=@USED_3RDPARTY_FREEIMAGE_DIRS@"
set "FREEIMAGE_DIR=@USED_3RDPARTY_FREEIMAGE_DIR@"
set "EGL_DIR=@USED_3RDPARTY_EGL_DIRS@"
set "GLES2_DIR=@USED_3RDPARTY_GLES2_DIRS@"
set "TBB_DIR=@USED_3RDPARTY_TBB_DIR@"
set "VTK_DIR=@USED_3RDPARTY_VTK_DIR@"
set "FFMPEG_DIR=@USED_3RDPARTY_FFMPEG_DIR@"
set "OPENVR_DIR=@USED_3RDPARTY_OPENVR_DIR@"
if not "@USED_3RDPARTY_QT_DIR@" == "" (
set "QTDIR=@USED_3RDPARTY_QT_DIR@"

View File

@@ -140,7 +140,11 @@ if not ["%GLES2_DIR%"] == [""] set "PATH=%GLES2_DIR%;%PATH%"
if not ["%TBB_DIR%"] == [""] set "PATH=%TBB_DIR%;%PATH%"
if not ["%VTK_DIR%"] == [""] set "PATH=%VTK_DIR%;%PATH%"
if not ["%FFMPEG_DIR%"] == [""] set "PATH=%FFMPEG_DIR%;%PATH%"
if not ["%QTDIR%"] == [""] set "PATH=%QTDIR%/bin;%PATH%"
if not ["%OPENVR_DIR%"] == [""] set "PATH=%OPENVR_DIR%;%PATH%"
if not ["%QTDIR%"] == [""] (
set "PATH=%QTDIR%/bin;%PATH%"
set "QT_PLUGIN_PATH=%QTDIR%/plugins"
)
rem ----- Set path to 3rd party and OCCT libraries -----
if not "%CSF_OCCTBinPath%" == "" (

View File

@@ -27,3 +27,5 @@ if not "%QTDIR%" == "" (
set "PATH=%QTDIR%/bin;%PATH%"
set "QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%\plugins\platforms"
)
set "CSF_OCCTOverviewSampleCodePath=%~dp0..\..\OCCTOverview\code"

View File

@@ -20,3 +20,5 @@ export STATION=$host
export RES_DIR=${aSamplePath}/${STATION}/res
export PATH=${QTDIR}/bin:${PATH}
export "CSF_OCCTOverviewSampleCodePath=${aSamplePath}/../../OCCTOverview/code"

View File

@@ -19,6 +19,7 @@ if ["%1"] == [""] (
echo AndroidQt
echo FuncDemo
echo IESample
echo OCCTOverview
echo Tutorial
PAUSE
exit /B
@@ -35,5 +36,8 @@ if not exist "%EXE_PATH%" (
exit /B
)
rem Set path to location where sample code is installed
set "CSF_OCCTOverviewSampleCodePath=%CSF_OCCTSamplesPath%\OCCTOverview\code"
"%EXE_PATH%"

View File

@@ -8,6 +8,7 @@ if [ "$1" == "" ]; then
echo available samples:
echo FuncDemo
echo IESample
echo OCCTOverview
echo Tutorial
fi
@@ -31,5 +32,7 @@ if [ ! -f "$EXE_PATH" ]; then
exit 1
fi
export CSF_OCCTOverviewSampleCodePath="${CSF_OCCTSamplesPath}/OCCTOverview/code"
cd ${aCurrentPath}
"$EXE_PATH"
"$EXE_PATH"

View File

@@ -12,6 +12,7 @@ samples/samples.md
../samples/CSharp/ReadMe.md
../samples/CSharp/ReadMe_D3D.md
../samples/qt/AndroidQt/ReadMe.md
../samples/qt/OCCTOverview/ReadMe.md
../samples/java/jniviewer/ReadMe.md
../samples/ios/UIKitSample/ReadMe.md
../samples/webgl/ReadMe.md

View File

@@ -555,7 +555,31 @@ if { [expr $actual_length - $expected_length] > 0.001 } {
At the end, the test script should output *TEST COMPLETED* string to mark a successful completion of the script. This is often done by the *end* script in the grid.
When the test script requires a data file, use Tcl procedure *locate_data_file* to get a path to it, instead of putting the path explicitly. This will allow easy move of the data file from OCCT sources repository to the data files repository without the need to update the test script.
During execution of a test, the following Tcl variables are defined on global level:
| Variable | Value |
|-----------|-------|
| dirname | Path to the root directory of the current set of test scripts |
| groupname | Name of the test group (subfolder of $dirname) |
| gridname | Name of the test grid (subfolder of $dirname/$gridname) |
| casename | Name of the test |
| imagedir | Path to folder where test log and other artifacts are saved |
The test script can use some data stored in a separate file (e.g. reference results of the test execution).
Such file can be put in subfolder *data* of the test grid directory.
During execution of the test, location of such data file can be constructed using the variables listed above.
Example:
~~~~~
checkresult $result $::dirname/$::groupname/$::gridname/data/${::casename}.txt
~~~~~
CAD models and other data files which are not going to change over time should be stored separately from the source repository.
Use Tcl procedure *locate_data_file* to get a path to such data files, instead of coding the path explicitly.
For the file to be found by that procedure, add directory that contains it into the environment variable *CSF_TestDataPath* (list of paths separated by semicolons on Windows or colons on other platforms).
The search is recursive, thus adding only root folder of a directory containing data files is sufficient.
If the file is not found, *locate_data_file* will raise exception, and the test will be reported as SKIPPED.
Example:
@@ -578,11 +602,11 @@ The image format (defined by extension) should be *png*.
Example:
~~~~~
xwd $imagedir/${casename}.png
xwd $::imagedir/${::casename}.png
vdisplay result; vfit
vdump $imagedir/${casename}-axo.png
vdump $::imagedir/${::casename}-axo.png
vfront; vfit
vdump $imagedir/${casename}-front.png
vdump $::imagedir/${::casename}-front.png
~~~~~
would produce:
@@ -594,11 +618,6 @@ A1-front.png
Note that OCCT must be built with FreeImage support to be able to produce usable images.
Other Tcl variables defined during the test execution are:
- *groupname*: name of the test group;
- *gridname*: name of the test grid;
- *dirname*: path to the root directory of the current set of test scripts.
In order to ensure that the test works as expected in different environments, observe the following additional rules:
* Avoid using external commands such as *grep, rm,* etc., as these commands can be absent on another system (e.g. on Windows); use facilities provided by Tcl instead.
* Do not put call to *locate_data_file* in catch statement -- this can prevent correct interpretation of the missing data file by the test system.

View File

@@ -61,6 +61,9 @@
</Type>
<Type Name="TCollection_AsciiString">
<DisplayString>{mylength}: {mystring,s}</DisplayString>
<Expand>
<Item Name="[utf-8]">mystring,s8</Item>
</Expand>
</Type>
<Type Name="TCollection_HAsciiString">
<DisplayString>{myString.mylength}: {myString.mystring,s}</DisplayString>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -353,20 +353,31 @@ for which OCCT is certified to work.
1) VC++ 141 64-bit is used for regular testing and for building binary package of official release of OCCT on Windows.
@subsection intro_req_libs Third-party libraries
@subsection intro_req_libs Third-party libraries and tools
| Component | Requirement |
| --------- | ----------- |
| Graphic library | OpenGL 3.3+, OpenGL ES 2.0+ <br> Direct3D 9 |
| Qt (for samples and demos) | Desktop: Qt 4.8.6+ https://www.qt.io/download/ <br> Android: Qt 5.3.2+ https://www.qt.io/download/ |
| TCL (for testing tools) | Tcl/Tk 8.6.3+ https://www.tcl.tk/software/tcltk/download.html <br> or ActiveTcl 8.6 https://www.activestate.com/activetcl/downloads (for Windows)|
| Freetype (for text rendering) | FreeType 2.4.11-2.7.1 https://sourceforge.net/projects/freetype/files/ |
| FreeImage (optional, for support of common 2D graphic formats) | FreeImage 3.17.0+ https://sourceforge.net/projects/freeimage/files |
| FFmpeg (optional, for video recording) | FFmpeg 3.1+ https://www.ffmpeg.org/download.html |
| RapidJSON (optional, for reading glTF) | RapidJSON 1.1+ https://rapidjson.org/ |
| Intel TBB (optional, for multithreaded algorithms) | TBB 4.x or 5.x https://www.threadingbuildingblocks.org/ |
| VTK (for VTK Integration Services | VTK 6.1+ https://www.vtk.org/download/ |
| Doxygen (optional for building documentation) | Doxygen 1.8.5+ https://www.stack.nl/~dimitri/doxygen/download.html |
The following third-party libraries and tools are not included in OCCT sources but are either required or can be optionally used for the indicated components of OCCT.
They are not needed if relevant component is not needed.
Note that pre-built packages of many of the listed libraries are available at
https://www.opencascade.com/content/3rd-party-components
| Component | Where to find | Used for | Required or optional |
| --------- | ------------- | -------- | -------------------- |
| CMake 2.8+ | https://cmake.org/ | Build from sources | Optional |
| Intel TBB 4.x or later | https://www.threadingbuildingblocks.org/ | All | Optional (advanced parallelization of algorithms) |
| OpenGL 3.3+, OpenGL ES 2.0+ | System | Visualization | Required |
| OpenVR 1.10+ | https://github.com/ValveSoftware/openvr | Visualization | Optional (VR support) |
| Direct3D 9 | Windows | Visualization | Optional (integration with GUI using Direct3D) |
| FreeType 2.4.11-2.7.1 | https://sourceforge.net/projects/freetype/files/ | Visualization | Required |
| FreeImage 3.17.0+ | https://sourceforge.net/projects/freeimage/files | Visualization | Optional (support of common 2D graphic formats) |
| FFmpeg 3.1+ | https://www.ffmpeg.org/download.html | Visualization | Optional (video recording) |
| VTK 6.1+ | https://www.vtk.org/download/ | Visualization | Optional (VTK integration) |
| Flex 2.6.4+ and Bison 3.7.1+ | https://sourceforge.net/projects/winflexbison/ | Data Exchange | Optional (update of STEP and ExprIntrp parsers) |
| RapidJSON 1.1+ | https://rapidjson.org/ | Data Exchange | Optional (reading glTF files) |
| Tcl/Tk 8.6.3+ <br> or ActiveTcl 8.6 | https://www.tcl.tk/software/tcltk/download.html <br> https://www.activestate.com/activetcl/downloads | DRAW Test Harness | Required |
| Qt Desktop: Qt 4.8.6+ <br> Android: Qt 5.3.2+ | https://www.qt.io/download/ | Samples and demos | Optional (Qt samples) |
| Doxygen 1.8.5+ | https://www.doxygen.nl/download.html | Documentation | Required |
| Graphviz 2.38+ | https://graphviz.org/ | Documentation | Optional (dependency graphs) |
@subsection intro_req_hw Hardware
@@ -388,18 +399,20 @@ Therefore, if you observe some unexpected visual issues - first check for OpenGL
but beware that driver update might also come with new bugs.
Don't forget to report these bugs to vendors.
@section intro_install Installation
@section intro_install Download and Installation
In most cases you need to rebuild OCCT on your platform (OS, compiler) before
using it in your project, to ensure binary compatibility.
OCCT can be downloaded from https://www.opencascade.com/content/latest-release
In most cases you would want to rebuild OCCT from sources on your platform (OS, compiler) before
using it in your project, to ensure binary compatibility and appropriate configuration of the library.
See @ref build_upgrade for instructions on building OCCT from sources on supported platforms.
The following subsections describe how OCCT can be installed from ready-to-use packages on different platforms.
@subsection intro_install_windows Windows
On Windows Open CASCADE Technology can be installed with binaries precompiled by
Visual C++ 2010 with installation procedure.
On Windows Open CASCADE Technology with binaries precompiled by Visual C++ 2017
can be installed using installation procedure available on official download page.
**Recommendation:**
@@ -409,16 +422,8 @@ the previous version (using Control Panel, Add/Remove Programs) before
the installation of this new version, to avoid possible problems
(conflict of system variables, paths, etc).
**Attention:** For full installation OCCT requires approximately 650 Mb of disk space,
but during the installation process you will need 1,2 Gb of free disk space.
Full OCCT installation with reference documentation requires 1.8 Gb on disk.
OCCT installation with reference documentation requires 1,4 Gb on disk.
* Download the OCCT installer from OPEN CASCADE web site using the link. you have been provided
* Launch the installer and follow the instructions.
The includes and binaries of third-party libraries necessary for building and launching
OCCT are included into binary distribution (built with Visual C++ 2010).
When the installation is complete, you will find the directories for 3rd party products
(some might be absent in case of custom installation) and the main **OCCT** directory:
@@ -431,6 +436,7 @@ The contents of the OCCT-7.4.0 directory (called further "OCCT root", or $CASROO
* **adm** This folder contains administration files, which allow rebuilding OCCT;
* **adm/cmake** This folder contains files of CMake building procedure;
* **adm/msvc** This folder contains Visual Studio projects for Visual C++ 2010, 2012, 2013, 2015, 2017 and 2019 which allow rebuilding OCCT under Windows platform in 32 and 64-bit mode;
* **adm/scripts** This folder contains auxiliary scripts for semi-automated building and packaging of OCCT for different platforms;
* **data** This folder contains CAD files in different formats, which can be used to test the OCCT functionality;
* **doc** This folder contains OCCT documentation in HTML and PDF format;
* **dox** This folder contains sources of OCCT documentation in plain text (MarkDown) format;
@@ -450,7 +456,7 @@ See https://repology.org/project/opencascade/versions for overview of available
@subsection intro_install_mac macOS
On macOS, OCCT is available in Homebrew (https://formulae.brew.sh/formula/opencascade)
amd MacPorts (https://ports.macports.org/port/opencascade/summary) repositories.
and MacPorts (https://ports.macports.org/port/opencascade/summary) repositories.
@section intro_env Environment Variables
@@ -512,7 +518,7 @@ The scripts are located in the OCCT root folder.
@section intro_license License
Open CASCADE Technology and all materials, including this documentation, is
Copyright (c) 1999-2018 by OPEN CASCADE S.A.S. All rights reserved.
Copyright (c) 1999-2020 by OPEN CASCADE S.A.S. All rights reserved.
Open CASCADE Technology is free software; you can redistribute it and / or modify it under the terms of the
@ref license_lgpl_21 "GNU Lesser General Public License (LGPL) version 2.1", with additional @ref occt_lgpl_exception "exception".
@@ -578,7 +584,14 @@ implementation of 3D viewer. OpenGL specification is developed by the
Khronos group, https://www.khronos.org/opengl/. OCCT code includes header
file *glext.h* obtained from Khronos web site.
**VTK** -- The **Visualization Toolkit (VTK)** is an open-source, freely available software system for 3D computer graphics, image processing and visualization. OCCT VIS component provides adaptation functionality for visualization of OCCT topological shapes by means of VTK library. If you need further information on VTK, refer to VTK Homepage https://www.vtk.org/.
**OpenVR** is an API and runtime that allows access to VR hardware from multiple vendors
without requiring that applications have specific knowledge of the hardware they are targeting.
OpenVR is optionally used by OCCT for VR support.
OpenVR is released under BSD-like license (https://github.com/ValveSoftware/openvr/blob/master/LICENSE).
**VTK** -- The **Visualization Toolkit (VTK)** is an open-source, freely available software system for 3D computer graphics, image processing and visualization.
OCCT VIS component provides adaptation functionality for visualization of OCCT topological shapes by means of VTK library.
If you need further information on VTK, refer to VTK Homepage https://www.vtk.org/.
**Doxygen** developed by Dimitri van Heesch is open source documentation system for
C++, C, Java, Objective-C, Python, IDL, PHP and C#. This product is used in Open CASCADE Technology
@@ -601,20 +614,31 @@ FreeImage is easy to use, fast, multithreading safe, compatible with all 32-bit
and cross-platform (works both with Linux and Mac OS X). FreeImage is optionally used by OCCT to work
with images, on conditions of the FreeImage Public License (FIPL) (https://freeimage.sourceforge.net/freeimage-license.txt).
**FFmpeg** is an Open Source framework supporting various image, video and audio codecs.
FFmpeg is optionally used by OCCT for video recording, on LGPL conditions (https://www.ffmpeg.org/legal.html).
**David M. Gay's floating point routines** (dtoa.c) are used for fast reading of floating point values from text strings.
These routines are available under MIT-like license (see https://www.netlib.org/fp/).
**CMake** is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice.
OCCT uses CMake as a build system. CMake is available under BSD 3-Clause license. See more at https://cmake.org/
**Flex** is a generator of lexical analyzers (scanners), available under BSD license (https://github.com/westes/flex).
GNU **Bison** is a parser generator used (together with **Flex**) for implementation of reader of STEP file format and parser of expressions.
It is available under GNU GPL v3 license (https://www.gnu.org/software/bison/).
**Delabella** is an open-source, cross-platform implementation of the Newton Apple Wrapper algorithm producing 2D Delaunay triangulation.
Delabella is used by BRepMesh as one of alternative 2D triangulation algorithms.
Delabella is licensed under the MIT license (https://github.com/msokalski/delabella).
**CMake** is an open-source, cross-platform family of tools designed to build, test and package software.
CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice.
OCCT uses CMake as a build system. CMake is available under BSD 3-Clause license.
See more at https://cmake.org/
**Cotire** (compile time reducer) is a CMake module that speeds up the build process of CMake based build systems
by fully automating techniques as precompiled header usage and single compilation unit builds for C and C++.
Cotire is included in OCCT repository and used optionally by OCCT CMake scripts to accelerate builds by use of precompiled headers.
Cotire is licensed under the MIT license (https://github.com/sakra/cotire/blob/master/license).
**FFmpeg** is an Open Source framework supporting various image, video and audio codecs.
FFmpeg is optionally used by OCCT for video recording, on LGPL conditions (https://www.ffmpeg.org/legal.html).
**MikTEX** is up-to-date implementation of TeX/LaTeX and related programs for Windows. It is used
for generation of User and Developer Guides in PDF format. See https://miktex.org for information
on this tool.
@@ -625,8 +649,6 @@ RapidJSON is optionally used by OCCT for reading glTF files (https://rapidjson.o
**DejaVu** fonts are a font family based on the Vera Fonts under a permissive license (MIT-like, https://dejavu-fonts.github.io/License.html).
DejaVu Sans (basic Latin sub-set) is used by OCCT as fallback font when no system font is available.
**Delabella** is an open-source, cross-platform implementation of the Newton Apple Wrapper algorithm producing 2D Delaunay triangulation. Delabella is used by BRepMesh as one of alternative 2D triangulation algorithms. Delabella is licensed under the MIT license (https://github.com/msokalski/delabella).
Adobe Systems, Inc. provides **Adobe Reader**, which can be used to view files in Portable Document Format (PDF).
**CAS.CADE** and **Open CASCADE** are registered trademarks of OPEN CASCADE S.A.S.
@@ -636,3 +658,5 @@ Adobe Systems, Inc. provides **Adobe Reader**, which can be used to view files i
**Windows** is a registered trademark of Microsoft Corporation in the United States and other countries.
**Mac**, **OS X**, **macOS**, and the Mac logo are trademarks of Apple Inc., registered in the U.S. and other countries.
**Android** is a trademark of Google LLC.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View File

@@ -46,7 +46,10 @@ See @subpage samples_mfc_standard "Readme" for details.
Qt
---
OCCT contains three samples based on Qt application framework
OCCT includes several samples based on Qt application framework.
These samples are available on all supported desktop platforms.
To start a sample on Windows use Open CASCADE Technology\\Samples\\Qt\\ item of the Start\\Programs menu.
Import Export
-------------
@@ -69,6 +72,27 @@ The combination of these resources allows creating substantial applications.
**See also:** @ref occt__tutorial "OCCT Tutorial"
Overview
---------
The Qt application providing samples for basic usage of C++ API of various OCCT functionality.
The samples are organized in several categories according to relevant module of OCCT:
* Geometry
* Topology,
* Triangulation
* DataExchange
* OCAF
* Viewer 2d
* Viewer 3d
Each sample presents geometry view, C++ code fragment and sample output window.
@figure{/samples/images/sample_overview_qt.png}
See \subpage samples_qt_overview "Readme" for details.
C#
---

View File

@@ -60,7 +60,7 @@ More general model will require to consider directions all around a whole sphere
\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 @ref ref_Duvenhage13 "[Duvenhage13]":
It has to model all light and material interactions and also has to satisfy some following criteria in order to be physical correct [@ref Duvenhage13]:
* 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)
@@ -74,7 +74,7 @@ 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** @ref ref_Cook81 "[Cook81]". 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.
PBR theory is based on **Cook-Torrance specular BRDF** [@ref Cook81]. 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.
@@ -85,7 +85,7 @@ Going back to the BRDF the Cook-Torrance approach has the following expression:
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 @ref ref_Karis13 "[Karis13]":
The implementation with good visual results is **Trowbridge-Reitz GGX** approach used in Disney's RenderMan and Unreal Engine [@ref Karis13]:
\f[D=\frac{\alpha^2}{\pi(\cos^2\theta_h(\alpha^2-1) + 1)^2}\f]
@@ -93,8 +93,8 @@ Where \f$\alpha = r^2\f$. This square in needed only for smoother roughness para
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 @ref ref_Heitz14 "[Heitz14]".
**Smith-Schlick model** @ref ref_Heitz14 "[Heitz14]", @ref ref_Schlick94 "[Schlick94]" has been chosen as implementation:
The point is that micro surfaces form kind of terrain and can cast shadows over each other especially on extreme viewing angles [@ref Heitz14].
**Smith-Schlick model** [@ref Heitz14], [@ref Schlick94] 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]
@@ -105,7 +105,7 @@ 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** @ref ref_Schlick94 "[Schlick94]":
The good one with less computation efforts is **Schlick's implementation** [@ref Schlick94]:
\f[F=F_0+(1-F_0)(1-\cos\theta_{vh})^5\f]
@@ -115,7 +115,7 @@ In order to do that it is needed to be noticed that Schlick's approximation is a
**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 @ref ref_Lazanyi05 "[Lazanyi05]", @ref ref_Lagarde13 "[Lagarde13]".
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 [@ref Lazanyi05], [@ref Lagarde13].
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**):
@@ -184,7 +184,7 @@ Having finite discrete amount of it in scene and considering only single directi
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 @ref ref_Karis13 "[Karis13]" (that is modification mentioned in previous chapter).
The only exception might be \f$k\f$ in \f$G\f$ factor - it is recommended to use \f$ k = (r+1)^2 / 8 \f$ in order to get more pleasant results [@ref Karis13] (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:
@@ -359,7 +359,7 @@ Optimization strategies use different samples distributions for different view d
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 @ref ref_Karis13 "[Karis13]":
The first trick on the way to this is split the sum separating environment light component [@ref Karis13]:
\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]
@@ -424,7 +424,7 @@ Anyway that is good starting point and lets generate \f$h\f$ vectors first.
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$ @ref ref_Walter07 "[Walter07]":
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$ [@ref Walter07]:
\f[dA_h = D(h)\,\mathrm{d}h\, \mathrm{d}A\f]
@@ -460,7 +460,7 @@ Lets strict to samples generation procedure and find partial probability densiti
\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 @ref ref_Cao15 "[Cao15]":
Anyway the \f$F(\theta_h)\f$ is next step [@ref Cao15]:
\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]
@@ -494,7 +494,7 @@ 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 @ref ref_Schutte18 "[Schutte18]":
Combining this all together the following expression is obtained for reflection transform Jacobian [@ref Schutte18]:
\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]
@@ -532,7 +532,7 @@ 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 @ref ref_Karis13 "[Karis13]":
It can be fixed more or less by \f$\cos\theta_{l_i}\f$ weighting [@ref Karis13]:
\f[\frac{1}{N} \sum_{i=1}^N L_i^{indirect}(l_i) \cos\theta_{l_i}\f]
@@ -589,7 +589,7 @@ It wold be better to get from such direction already averaged over bigger area e
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 @ref ref_Colbert07 "[Colbert07]":
And that can be done as [@ref Colbert07]:
\f[\Omega_s = \frac{1}{N\,p(l)} = \frac{4\cos\theta_{vh}}{ND\cos\theta_h}\f]
@@ -658,7 +658,7 @@ Dot product on a sphere is defined as integral of functions multiplication. In o
\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 @ref ref_Guy18 "[Guy18]":
Function basis with such traits is known and is described by following formulas [@ref Guy18]:
\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]
@@ -691,7 +691,7 @@ Where \f$\overline{\cos}\f$ is cosine clamped to zero which can be expressed as:
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 @ref ref_Aguilar17 "[Aguilar17]", @ref ref_Ramamoorthi01 "[Ramamoorthi01]".
Fact that this is convolution analogue related to \f$n\f$ is enough for now [@ref Aguilar17], [@ref Ramamoorthi01].
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:
@@ -720,7 +720,7 @@ There is an analytical solution for this expressions:
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 @ref ref_Ramamoorthi01 "[Ramamoorthi01]":
Lets write down them all in Cartesian coordinate [@ref Ramamoorthi01]:
\f[y_0^0 = \frac{1}{2}\sqrt{\frac{1}{\pi}} = Y_0^0\f]
@@ -749,7 +749,7 @@ Moreover, texture is not needed at all in that case and only 9 colors representi
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 [[14](#(14))]:
All tables with constants presented below [@ref Ramamoorthi01]:
| |
|-|
@@ -778,59 +778,104 @@ TODO
@section pbr_references References
* @anchor ref_Duvenhage13 **[Duvenhage13]**
<table cellpadding="4">
<tr><td valign="top">
@anchor Duvenhage13 **[Duvenhage13]**
</td><td>
Bernardt Duvenhage, Kadi Bouatouch, D.G. Kourie,
"Numerical Verification of Bidirectional Reflectance Distribution Functions for Physical Plausibility",
*Proceedings of the South African Institute for Computer Scientists and Information Technologists Conference*,
October 2013.
</td></tr>
* @anchor ref_Cook81 **[Cook81]**
<tr><td valign="top">
@anchor Cook81 **[Cook81]**
</td><td>
Robert Cook, Kenneth Torrance,
"A Refectance Model for Computer Graphics",
*SIGGRAPH '81: Proceedings of the 8th annual conference on Computer graphics and interactive techniques*,
August 1981, pp. 307-316.
</td></tr>
* @anchor ref_Karis13 **[Karis13]**
<tr><td valign="top">
@anchor Karis13 **[Karis13]**
</td><td>
Brian Karis, "Real Shading in Unreal Engine 4", *SIGGRAPH 2013 Presentation Notes*.
</td></tr>
* @anchor ref_Heitz14 **[Heitz14]**
<tr><td valign="top">
@anchor Heitz14 **[Heitz14]**
</td><td>
Eric Heitz, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs",
*Journal of Computer Graphics Techniques*, Vol. 3, No. 2, 2014.
</td></tr>
* @anchor ref_Schlick94 **[Schlick94]**
<tr><td valign="top">
@anchor Schlick94 **[Schlick94]**
</td><td>
Christophe Schlick, "An inexpensive brdf model for physically-based rendering",
*Computer Graphics Forum 13*, 1994, pp. 233-246.
</td></tr>
* @anchor ref_Lazanyi05 **[Lazanyi05]**
<tr><td valign="top">
@anchor Lazanyi05 **[Lazanyi05]**
</td><td>
Istvan Lazanyi, Lazslo Szirmay-Kalos, "Fresnel term approximations for Metals", January 2005.
</td></tr>
* @anchor ref_Lagarde13 **[Lagarde13]**
<tr><td valign="top">
@anchor Lagarde13 **[Lagarde13]**
</td><td>
Sebastien Lagarde, "Memo on Fresnel equations",
*Blog post*: [https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/](https://seblagarde.wordpress.com/2013/04/29/memo-on-fresnel-equations/).
</td></tr>
* @anchor ref_Walter07 **[Walter07]**
<tr><td valign="top">
@anchor Walter07 **[Walter07]**
</td><td>
Bruce Walter, Stephen Marschner, Hongsong Li, Kenneth Torrance,
"Microfacet Models for Refraction through Rough Surfaces", *Proceedings of Eurographics Symposium on Rendering*, 2007.
</td></tr>
* @anchor ref_Cao15 **[Cao15]**
<tr><td valign="top">
@anchor Cao15 **[Cao15]**
</td><td>
Jiayin Cao, "Sampling microfacet BRDF", November 1, 2015,
*Blog post*: [https://agraphicsguy.wordpress.com/2015/11/01/sampling-microfacet-brdf/](https://agraphicsguy.wordpress.com/2015/11/01/sampling-microfacet-brdf/).
</td></tr>
* @anchor ref_Schutte18 **[Schutte18]**
<tr><td valign="top">
@anchor Schutte18 **[Schutte18]**
</td><td>
Joe Schutte, "Sampling techniques for GGX with Smith Masking-Shadowing: Part 1", March 7, 2018,
*Blog post*: [https://schuttejoe.github.io/post/ggximportancesamplingpart1/](https://schuttejoe.github.io/post/ggximportancesamplingpart1/).
</td></tr>
* @anchor ref_Colbert07 **[Colbert07]**
<tr><td valign="top">
@anchor Colbert07 **[Colbert07]**
</td><td>
Mark Colbert, Jaroslav Krivanek, "GPU-Based Importance Sampling", *NVIDIA GPU Gems 3*, Chapter 20, 2007.
</td></tr>
* @anchor ref_Guy18 **[Guy18]**
<tr><td valign="top">
@anchor Guy18 **[Guy18]**
</td><td>
Romain Guy, Mathias Agopian, "Physically Based Rendering in Filament", *Part of Google's Filament project documentation*:
[https://google.github.io/filament/](https://google.github.io/filament/Filament.md.html)
</td></tr>
* @anchor ref_Aguilar17 **[Aguilar17]**
<tr><td valign="top">
@anchor Aguilar17 **[Aguilar17]**
</td><td>
Orlando Aguilar, "Spherical Harmonics", *Blog post*:
[http://orlandoaguilar.github.io/sh/spherical/harmonics/irradiance/map/2017/02/12/SphericalHarmonics.html](http://orlandoaguilar.github.io/sh/spherical/harmonics/irradiance/map/2017/02/12/SphericalHarmonics.html)
</td></tr>
* @anchor ref_Ramamoorthi01 **[Ramamoorthi01]**
<tr><td valign="top">
@anchor Ramamoorthi01 **[Ramamoorthi01]**
</td><td>
Ravi Ramamoorthi, Pat Hanrahan, "An Efficient Representation for Irradiance Environment Maps",
*SIGGRAPH '01: Proceedings of the 28th annual conference on Computer graphics and interactive techniques*, August 2001, pp. 497-500
</td></tr>
</table>

View File

@@ -1889,6 +1889,10 @@ Unexpected const-ness of Aspect_Window::DoResize() method has been removed, so t
Enumeration BRepOffset_Type is renamed to ChFiDS_TypeOfConcavity.
@subsection upgrade_750_BRepOffset_MakeOffset change in construction of offset faces
Now by default offset faces of non-planar faces may be planar faces if their originals can be approximated by planes.
@subsection upgrade_750_tkv3d TKV3d/TKService toolkits changes
The following changes could be highlighted while porting:
@@ -2145,3 +2149,10 @@ For an example, access to labels and attributes could be protected by mutex if t
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.
@subsection upgrade_750_msgfile_utf8 Utf-8 encoding for message files
Message files (with extension .msg) are now expected to be in UTF-8 encoding (unless they have UTF-16 BOM in which case UTF-16 is expected).
This allows using arbitrary Unicode symbols for localization of messages.
Existing message files containing 8-bit characters (previously interpreted as characters from Latin-1 code block) should be converted to UTF-8.

View File

@@ -10989,8 +10989,6 @@ DT_SplitSurface <result> <Surface|GridSurf> <tol> <split(0|1)>
Divides surface with C1 criterion and returns the result of splitting of a given surface into surface, which is given as parameter result. If the surface has been divided into segments, then each segment is put to an individual result. This command can correct a given C0 surface at a knot with a given tolerance, if it is impossible, then the given surface is split at that knot. If the last parameter is 1, then 5 knots are added to the given surface, and its surface is split by segments, but this will be performed not for all parametric spaces.
**Example:**
~~~~~
~~~~~
# split surface with name "su"
DT_SplitSurface res su 0.1 1
@@ -11003,7 +11001,6 @@ DT_SplitSurface res su 0.1 1
==> transfert resultat
==> res1_1_1 res1_2_1 res1_3_1 res1_4_1 res1_5_1 res1_6_1
~~~~~
~~~~~
@subsubsection occt_draw_9_2_8 DT_ToBspl

View File

@@ -1356,9 +1356,7 @@ MF.Add(W);
TopoDS_Face F = MF;
~~~~~
More than one wire can be added to a face, provided that they do not cross each other and they define only one area on the surface. (Note that this is not checked). The edges on a Face must have a parametric curve description.
If there is no parametric curve for an edge of the wire on the Face it is computed by projection.
More than one wire can be added to a face, provided that they do not cross each other and they define only one area on the surface. (Note that this is not checked).
For one wire, a simple syntax is provided to construct the face from the surface and the wire. The above lines could be written:
@@ -1366,6 +1364,8 @@ For one wire, a simple syntax is provided to construct the face from the surfac
TopoDS_Face F = BRepBuilderAPI_MakeFace(C,W);
~~~~~
The edges on a face must have a parametric curve description. If there is no parametric curve for an edge of the wire on the face it is computed by projection, moreover, the calculation is possible only for the planar face.
A planar face can be created from only a wire, provided this wire defines a plane. For example, to create a planar face from a set of points you can use *BRepBuilderAPI_MakePolygon* and *BRepBuilderAPI_MakeFace*.
~~~~~

View File

@@ -1556,7 +1556,7 @@ aTriangles->AddVertex ( 100./2., 100./2., 0.0);
Handle(Graphic3d_AspectFillArea3d) anAspects = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_RED,
Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0f,
Graphic3d_NOM_GOLD, Graphic3d_NOM_GOLD);
Graphic3d_NameOfMaterial_Gold, Graphic3d_NameOfMaterial_Gold);
aPrsGroup->SetGroupPrimitivesAspect (anAspects);
aPrsGroup->AddPrimitiveArray (aTriangles);
@@ -2018,8 +2018,8 @@ aFirebrickMarker->SetMarkerImage (theImage)
Create facet attributes.
~~~~~{.cpp}
Handle(Graphic3d_AspectFillArea3d) aFaceAspect = new Graphic3d_AspectFillArea3d();
Graphic3d_MaterialAspect aBrassMaterial (Graphic3d_NOM_BRASS);
Graphic3d_MaterialAspect aGoldMaterial (Graphic3d_NOM_GOLD);
Graphic3d_MaterialAspect aBrassMaterial (Graphic3d_NameOfMaterial_Brass);
Graphic3d_MaterialAspect aGoldMaterial (Graphic3d_NameOfMaterial_Gold);
aFaceAspect->SetInteriorStyle (Aspect_IS_SOLID_WIREFRAME);
aFaceAspect->SetInteriorColor (aMyColor);
aFaceAspect->SetDistinguishOn ();

View File

@@ -748,7 +748,7 @@ public:
}
Handle(AIS_Shape) aPrs = new AIS_Shape (aShape);
myAISContext()->SetMaterial (aPrs, Graphic3d_NOM_GOLD, Standard_False);
myAISContext()->SetMaterial (aPrs, Graphic3d_NameOfMaterial_Gold, Standard_False);
myAISContext()->SetDisplayMode(aPrs, AIS_Shaded, Standard_False);
myAISContext()->Display (aPrs, Standard_True);
return true;

View File

@@ -0,0 +1,147 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "AdaptorCurve2d_AIS.h"
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <StdPrs_PoleCurve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <GCPnts_QuasiUniformDeflection.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2dLProp_CLProps2d.hxx>
AdaptorCurve2d_AIS::AdaptorCurve2d_AIS (const Handle(Geom2d_Curve)& theGeom2dCurve,
const Aspect_TypeOfLine theTypeOfLine,
const Aspect_WidthOfLine theWidthOfLine)
: myGeom2dCurve (theGeom2dCurve),
myTypeOfLine (theTypeOfLine),
myWidthOfLine (theWidthOfLine),
myDisplayPole (Standard_True),
myDisplayCurbure (Standard_False),
myDiscretisation (20),
myradiusmax (10),
myradiusratio (1)
{
//
}
void AdaptorCurve2d_AIS::Compute (const Handle(PrsMgr_PresentationManager3d)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
if (theMode != 0)
{
return;
}
Geom2dAdaptor_Curve anAdaptor(myGeom2dCurve);
GCPnts_QuasiUniformDeflection anEdgeDistrib(anAdaptor, 1.e-2);
if (anEdgeDistrib.IsDone())
{
Handle(Graphic3d_ArrayOfPolylines) aCurve = new Graphic3d_ArrayOfPolylines(anEdgeDistrib.NbPoints());
for (Standard_Integer i = 1; i <= anEdgeDistrib.NbPoints(); ++i)
{
aCurve->AddVertex(anEdgeDistrib.Value(i));
}
Handle(Graphic3d_Group) aPrsGroup = thePrs->NewGroup();
aPrsGroup->SetGroupPrimitivesAspect(myDrawer->LineAspect()->Aspect());
aPrsGroup->AddPrimitiveArray(aCurve);
}
if (myDisplayPole)
{
if (anAdaptor.GetType() == GeomAbs_BezierCurve)
{
Handle(Geom2d_BezierCurve) aBezier = anAdaptor.Bezier();
Handle(Graphic3d_ArrayOfPolylines) anArrayOfVertex = new Graphic3d_ArrayOfPolylines(aBezier->NbPoles());
for (int i = 1; i <= aBezier->NbPoles(); i++)
{
gp_Pnt2d CurrentPoint = aBezier->Pole(i);
anArrayOfVertex->AddVertex(CurrentPoint.X(), CurrentPoint.Y(), 0.);
}
Handle(Graphic3d_Group) aPrsGroup = thePrs->NewGroup();
aPrsGroup->SetGroupPrimitivesAspect(myDrawer->LineAspect()->Aspect());
aPrsGroup->AddPrimitiveArray(anArrayOfVertex);
}
if (anAdaptor.GetType() == GeomAbs_BSplineCurve)
{
Handle(Geom2d_BSplineCurve) aBSpline = anAdaptor.BSpline();
Handle(Graphic3d_ArrayOfPolylines) anArrayOfVertex = new Graphic3d_ArrayOfPolylines(aBSpline->NbPoles());
for (int i = 1; i <= aBSpline->NbPoles(); i++)
{
gp_Pnt2d CurrentPoint = aBSpline->Pole(i);
anArrayOfVertex->AddVertex(CurrentPoint.X(), CurrentPoint.Y(), 0.);
}
Handle(Graphic3d_Group) aPrsGroup = thePrs->NewGroup();
aPrsGroup->SetGroupPrimitivesAspect(myDrawer->LineAspect()->Aspect());
aPrsGroup->AddPrimitiveArray(anArrayOfVertex);
}
}
if (myDisplayCurbure && (anAdaptor.GetType() != GeomAbs_Line))
{
const Standard_Integer nbintv = anAdaptor.NbIntervals(GeomAbs_CN);
TColStd_Array1OfReal TI(1, nbintv + 1);
anAdaptor.Intervals(TI, GeomAbs_CN);
Standard_Real Resolution = 1.0e-9, Curvature;
Geom2dLProp_CLProps2d LProp(myGeom2dCurve, 2, Resolution);
gp_Pnt2d P1, P2;
Handle(Graphic3d_Group) aPrsGroup = thePrs->NewGroup();
aPrsGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
for (Standard_Integer intrv = 1; intrv <= nbintv; intrv++)
{
Standard_Real t = TI(intrv);
Standard_Real step = (TI(intrv + 1) - t) / GetDiscretisation();
Standard_Real LRad, ratio;
for (Standard_Integer ii = 1; ii <= myDiscretisation; ii++)
{
LProp.SetParameter(t);
if (LProp.IsTangentDefined())
{
Curvature = Abs(LProp.Curvature());
if (Curvature > Resolution)
{
myGeom2dCurve->D0(t, P1);
LRad = 1. / Curvature;
ratio = ((LRad > myradiusmax) ? myradiusmax / LRad : 1);
ratio *= myradiusratio;
LProp.CentreOfCurvature(P2);
gp_Vec2d V(P1, P2);
gp_Pnt2d P3 = P1.Translated(ratio*V);
Handle(Graphic3d_ArrayOfPolylines) aSegment = new Graphic3d_ArrayOfPolylines(2);
aSegment->AddVertex(P1.X(), P1.Y(), 0.);
aSegment->AddVertex(P3.X(), P3.Y(), 0.);
aPrsGroup->AddPrimitiveArray(aSegment);
}
}
t += step;
}
}
}
}

View File

@@ -0,0 +1,77 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef ADAPTOR_CURVE2D_AIS_H
#define ADAPTOR_CURVE2D_AIS_H
#include <AIS_InteractiveObject.hxx>
#include <Geom2d_Curve.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <Aspect_WidthOfLine.hxx>
//! AIS interactive Object for Geom2d_Curve
class AdaptorCurve2d_AIS : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTI_INLINE(AdaptorCurve2d_AIS, AIS_InteractiveObject)
public:
AdaptorCurve2d_AIS(const Handle(Geom2d_Curve)& theGeom2dCurve,
const Aspect_TypeOfLine theTypeOfline = Aspect_TOL_SOLID,
const Aspect_WidthOfLine theWidthOfLine = Aspect_WOL_MEDIUM);
Standard_Integer NbPossibleSelection() const { return 1; }
Aspect_TypeOfLine GetTypeOfLine() const { return myTypeOfLine; }
void SetTypeOfLine(const Aspect_TypeOfLine aNewTypeOfLine) { myTypeOfLine = aNewTypeOfLine; }
Aspect_WidthOfLine GetWidthOfLine() const { return myWidthOfLine; }
void SetWidthOfLine(const Aspect_WidthOfLine aNewWidthOfLine) { myWidthOfLine = aNewWidthOfLine; }
Standard_Boolean GetDisplayPole() const { return myDisplayPole; }
void SetDisplayPole(const Standard_Boolean aNewDisplayPole) { myDisplayPole = aNewDisplayPole; }
Standard_Boolean GetDisplayCurbure() const { return myDisplayCurbure; }
void SetDisplayCurbure(const Standard_Boolean aNewDisplayCurbure) { myDisplayCurbure = aNewDisplayCurbure; }
Standard_Real GetDiscretisation() const { return myDiscretisation; }
void SetDiscretisation(const Standard_Real aNewDiscretisation) { myDiscretisation = aNewDiscretisation; }
private:
//! Return TRUE for supported display modes (only 0 mode is supported).
virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
//! Compute presentation.
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection (not implemented).
virtual void ComputeSelection (const Handle(SelectMgr_Selection)&,
const Standard_Integer) Standard_OVERRIDE {}
private:
Handle(Geom2d_Curve) myGeom2dCurve;
Aspect_TypeOfLine myTypeOfLine;
Aspect_WidthOfLine myWidthOfLine;
Standard_Boolean myDisplayPole;
Standard_Boolean myDisplayCurbure;
Standard_Real myDiscretisation;
Standard_Real myradiusmax;
Standard_Real myradiusratio;
};
#endif

View File

@@ -0,0 +1,49 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "AdaptorCurve_AIS.h"
#include <GeomAdaptor_Curve.hxx>
#include <Prs3d_LineAspect.hxx>
#include <StdPrs_PoleCurve.hxx>
#include <StdPrs_Curve.hxx>
void AdaptorCurve_AIS::Compute (const Handle(PrsMgr_PresentationManager3d)&,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
GeomAdaptor_Curve anAdaptorCurve(myCurve);
switch (theMode)
{
case 1:
{
Handle(Prs3d_Drawer) aPoleDrawer = new Prs3d_Drawer();
aPoleDrawer->SetLineAspect(new Prs3d_LineAspect(Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0));
StdPrs_PoleCurve::Add(thePrs, anAdaptorCurve, aPoleDrawer);
}
Standard_FALLTHROUGH
case 0:
{
StdPrs_Curve::Add(thePrs, anAdaptorCurve, myDrawer);
break;
}
}
}

View File

@@ -0,0 +1,52 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef ADAPTOR_CURVE_AIS_H
#define ADAPTOR_CURVE_AIS_H
#include <AIS_InteractiveObject.hxx>
#include <Geom_Curve.hxx>
//! AIS interactive Object for Geom_Curve
class AdaptorCurve_AIS : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTI_INLINE(AdaptorCurve_AIS, AIS_InteractiveObject)
public:
AdaptorCurve_AIS (const Handle(Geom_Curve)& theCurve) : myCurve(theCurve) {}
private:
//! Return TRUE for supported display modes (modes 0 and 1 are supported).
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0 || theMode == 1; }
//! Compute presentation.
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection (not implemented).
virtual void ComputeSelection (const Handle(SelectMgr_Selection)&,
const Standard_Integer) Standard_OVERRIDE {}
private:
Handle(Geom_Curve) myCurve;
};
#endif

View File

@@ -0,0 +1,38 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "AdaptorPnt2d_AIS.h"
#include <Geom_CartesianPoint.hxx>
#include <StdPrs_Point.hxx>
void AdaptorPnt2d_AIS::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
if (theMode != 0)
{
return;
}
Handle(Geom_CartesianPoint) aGeomPoint = new Geom_CartesianPoint(myPoint);
StdPrs_Point::Add (thePrs, aGeomPoint, myDrawer);
}

View File

@@ -0,0 +1,57 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef ADAPTOR_PNT2D_AIS_H
#define ADAPTOR_PNT2D_AIS_H
#include <Geom2d_Point.hxx>
#include <AIS_InteractiveObject.hxx>
//! AIS interactive Object for Geom2d_Point
class AdaptorPnt2d_AIS : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTI_INLINE(AdaptorPnt2d_AIS, AIS_InteractiveObject)
public:
AdaptorPnt2d_AIS (const Handle(Geom2d_Point)& thePoint,
Standard_Real theElevation = 0)
: myPoint(thePoint->X(), thePoint->Y(), theElevation) {}
private:
//! Return TRUE for supported display modes (only mode 0 is supported).
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
//! Compute presentation.
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection (not implemented).
virtual void ComputeSelection (const Handle(SelectMgr_Selection)&,
const Standard_Integer) Standard_OVERRIDE {}
private:
gp_Pnt myPoint;
};
#endif // ADAPTOR_PNT2D_AIS_H

View File

@@ -0,0 +1,77 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "AdaptorVec_AIS.h"
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_Text.hxx>
AdaptorVec_AIS::AdaptorVec_AIS (const gp_Pnt2d& thePnt1,
const gp_Pnt2d& thePnt2,
Standard_Real theArrowLength)
: myPnt (gp_Pnt (thePnt1.X(), thePnt1.Y(), 0.0)),
myLength (0.0),
myArrowLength (theArrowLength)
{
gp_Vec aVec (thePnt2.X() - thePnt1.X(), thePnt2.Y() - thePnt1.Y(), 0.0);
myDir = gp_Dir(aVec);
myLength = aVec.Magnitude();
}
void AdaptorVec_AIS::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
if (theMode != 0)
{
return;
}
// Set style for arrow
Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
anArrowAspect->SetLength(myArrowLength);
gp_Pnt aLastPoint = myPnt;
aLastPoint.Translate(myLength*gp_Vec(myDir));
// Draw Line
{
Handle(Graphic3d_Group) aLineGroup = thePrs->NewGroup();
aLineGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect());
Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
aPrims->AddVertex(myPnt);
aPrims->AddVertex(aLastPoint);
aLineGroup->AddPrimitiveArray(aPrims);
// Draw arrow
Prs3d_Arrow::Draw (aLineGroup, aLastPoint, myDir, anArrowAspect->Angle(), anArrowAspect->Length());
}
// Draw text
if (!myText.IsEmpty())
{
gp_Pnt aTextPosition = aLastPoint;
Prs3d_Text::Draw (thePrs->NewGroup(), myDrawer->TextAspect(), myText, aTextPosition);
}
}

View File

@@ -0,0 +1,121 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef ADAPTOR_VEC_AIS_H
#define ADAPTOR_VEC_AIS_H
#include <AIS_InteractiveObject.hxx>
//! AIS interactive Object for vector with arrow and text
class AdaptorVec_AIS : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTI_INLINE(AdaptorVec_AIS, AIS_InteractiveObject)
public:
AdaptorVec_AIS()
: myLength (1.0),
myArrowLength (1.0)
{}
AdaptorVec_AIS (const gp_Pnt& thePnt,
const gp_Dir& theDir,
Standard_Real theLength = 1,
Standard_Real theArrowLength = 1)
: myPnt (thePnt),
myDir (theDir),
myLength (theLength),
myArrowLength (theArrowLength)
{
//
}
AdaptorVec_AIS (const gp_Pnt& thePnt,
const gp_Vec& theVec,
Standard_Real theArrowLength = 1)
: myPnt (thePnt),
myDir (theVec),
myLength (theVec.Magnitude()),
myArrowLength (theArrowLength)
{
//
}
AdaptorVec_AIS (const gp_Pnt2d& thePnt2d,
const gp_Dir2d& theDir2d,
Standard_Real theLength = 1,
Standard_Real theArrowLength = 1)
: myPnt (gp_Pnt(thePnt2d.X(), thePnt2d.Y(), 0.0)),
myDir (gp_Dir(theDir2d.X(), theDir2d.Y(), 0.0)),
myLength (theLength),
myArrowLength (theArrowLength)
{
//
}
AdaptorVec_AIS (const gp_Pnt2d& thePnt2d,
const gp_Vec2d& theVec2d,
Standard_Real theArrowLength = 1)
: myPnt (gp_Pnt(thePnt2d.X(), thePnt2d.Y(), 0.0)),
myDir (gp_Dir(theVec2d.X(), theVec2d.Y(), 0.0)),
myLength (theVec2d.Magnitude()),
myArrowLength (theArrowLength)
{
//
}
AdaptorVec_AIS (const gp_Pnt2d& thePnt1,
const gp_Pnt2d& thePnt2,
Standard_Real theArrowLength = 1);
void SetText (const TCollection_AsciiString& theText)
{
myText = theText;
}
void SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
{
myDrawer->SetLineAspect(theAspect);
}
private:
//! Return TRUE for supported display modes (only mode 0 is supported).
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
//! Compute presentation.
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection (not implemented).
virtual void ComputeSelection (const Handle(SelectMgr_Selection)&,
const Standard_Integer) Standard_OVERRIDE {}
private:
gp_Pnt myPnt;
gp_Dir myDir;
Standard_Real myLength;
Standard_Real myArrowLength;
TCollection_AsciiString myText;
};
#endif // ADAPTOR_VEC2D_AIS_H

View File

@@ -0,0 +1,185 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "BaseSample.h"
#include <iostream>
#include <regex>
#include <exception>
#include <stack>
#include <AIS_ViewCube.hxx>
#include <Message.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QDir>
#include <Standard_WarningsRestore.hxx>
const TCollection_AsciiString BaseSample::FILE_EXTENSION = "cxx";
void BaseSample::Clear()
{
myObject3d.Clear();
myObject2d.Clear();
myCode.Clear();
myResult.str("");
}
TCollection_AsciiString BaseSample::GetResult()
{
TCollection_AsciiString aResult(myResult.str().c_str());
myResult.str("");
return aResult;
}
void BaseSample::AppendCube()
{
Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
myObject3d.Append(aViewCube);
}
void BaseSample::Process (const TCollection_AsciiString& theSampleName)
{
myObject3d.Clear();
myObject2d.Clear();
myCode.Clear();
myIsProcessed = Standard_False;
try
{
ExecuteSample(theSampleName);
if (!myObject3d.IsEmpty())
{
Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
myObject3d.Append(aViewCube);
}
}
catch (...)
{
TraceError(TCollection_AsciiString("Error in sample: ") + theSampleName);
}
}
void BaseSample::TraceError (const TCollection_AsciiString& theErrorMessage)
{
Message::SendFail() << "\nERROR: " << theErrorMessage.ToCString() << std::endl;
myResult << "\nERROR: " << theErrorMessage << std::endl;
}
void BaseSample::FindSourceCode (const TCollection_AsciiString& theSampleName)
{
TCollection_AsciiString aClassName = DynamicType()->Name();
char aSeparator = QDir::separator().toLatin1();
TCollection_AsciiString aCxxFilePach = myCodePath + aSeparator + aClassName + '.' + FILE_EXTENSION;
OSD_File aCxxFile(aCxxFilePach);
try
{
const Standard_Integer aFileBufferSize = 100 * 1024;
TCollection_AsciiString aReadedText(aFileBufferSize);
aCxxFile.Open(OSD_ReadOnly, OSD_Protection());
aCxxFile.Read(aReadedText, aFileBufferSize);
TCollection_AsciiString aRegexpTemplate = aClassName + "::" + theSampleName + "[\\n\\s]*\\([\\n\\s]*\\)[\\n\\s]*\\{";
Standard_Integer aOpeningBracketPosition = findEndOfPhrase (aReadedText, aRegexpTemplate);
Standard_Integer aClosingBracketPosition = findClosingBracket (aReadedText, aOpeningBracketPosition, '}');
myCode = aReadedText.SubString(aOpeningBracketPosition + 1, aClosingBracketPosition - 1);
}
catch (...)
{
TraceError(TCollection_AsciiString("Cannot open file: ") + aCxxFilePach);
}
}
Standard_Integer BaseSample::findEndOfPhrase (const TCollection_AsciiString& theText,
const TCollection_AsciiString& theRegexpTemplate)
{
Standard_Integer aIndexOfLastFoundSymbol = -1;
std::string aStdText = theText.ToCString();
std::string aRegexpTemplate = theRegexpTemplate.ToCString();
try
{
std::regex aRegex(theRegexpTemplate.ToCString());
std::sregex_iterator aDetectIterator = std::sregex_iterator(aStdText.begin(), aStdText.end(), aRegex);
if (aDetectIterator != std::sregex_iterator())
{
std::smatch aMatch = *aDetectIterator;
std::string aFoundString = aMatch.str();
aIndexOfLastFoundSymbol = static_cast<Standard_Integer>(aStdText.find(aFoundString) + aFoundString.length());
}
else
{
TraceError(TCollection_AsciiString("No code found for template: ") + theRegexpTemplate);
}
}
catch (const std::regex_error& aRegError)
{
TraceError(TCollection_AsciiString("regex_error: ") + aRegError.what());
}
catch (const std::exception& aEx)
{
TraceError(TCollection_AsciiString("common error: ") + aEx.what());
}
catch (...)
{
TraceError("unknown error!");
}
return aIndexOfLastFoundSymbol;
}
Standard_Integer BaseSample::findClosingBracket (const TCollection_AsciiString& theText,
const Standard_Integer theOpeningBracketIndex,
Standard_Character theClosingBracketSymbol)
{
// TODO this function not implemented at least 2 cases:
// - brackets in strings & chars
// - brackets in comments
Standard_Integer aClosingBracketIndex = -1;
Standard_Character anOpeningBracketSymbol = theText.Value(theOpeningBracketIndex);
TCollection_AsciiString aBracketsSet(theClosingBracketSymbol);
aBracketsSet += anOpeningBracketSymbol;
Standard_Integer aBracketDepth = 1;
Standard_Integer aStartFindIndex = theOpeningBracketIndex + 1;
//Standard_Character aStartFindChar = theText.Value(aStartFindIndex-1);
while (aBracketDepth)
{
aStartFindIndex = theText.FirstLocationInSet(aBracketsSet, aStartFindIndex, theText.Length());
if (!aStartFindIndex)
{
TraceError("No closing bracket found!");
break;
}
TCollection_AsciiString aRSubstr = theText.SubString(aStartFindIndex, theText.Length());
if (theText.Value(aStartFindIndex) == anOpeningBracketSymbol)
aBracketDepth++;
else if (theText.Value(aStartFindIndex) == theClosingBracketSymbol)
aBracketDepth--;
if (!aBracketDepth)
{
aClosingBracketIndex = aStartFindIndex;
break;
}
aStartFindIndex++;
}
return aClosingBracketIndex;
}

View File

@@ -0,0 +1,87 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef BASESAMPLE_H
#define BASESAMPLE_H
#include <sstream>
#include <AIS_InteractiveObject.hxx>
#include <NCollection_Vector.hxx>
#include <TCollection_AsciiString.hxx>
//! Base class for specified category classes
class BaseSample: public Standard_Transient
{
DEFINE_STANDARD_RTTI_INLINE(BaseSample, Standard_Transient)
public:
BaseSample (const TCollection_AsciiString& theSampleSourcePath,
const Handle(AIS_InteractiveContext)& theContext)
: myCodePath (theSampleSourcePath),
myContext (theContext)
{
//
}
void Clear();
void AppendCube();
Standard_Boolean IsProcessed() const { return myIsProcessed; }
const NCollection_Vector<Handle(AIS_InteractiveObject)>& Get2dObjects() const { return myObject2d; }
const NCollection_Vector<Handle(AIS_InteractiveObject)>& Get3dObjects() const { return myObject3d; }
TCollection_AsciiString GetResult();
TCollection_AsciiString GetCode() const { return myCode; }
virtual void Process (const TCollection_AsciiString& theSampleName);
protected:
virtual void ExecuteSample (const TCollection_AsciiString& theSampleName) = 0;
void FindSourceCode (const TCollection_AsciiString& theSampleName);
void TraceError (const TCollection_AsciiString& theErrorMessage);
protected:
Standard_Boolean myIsProcessed;
NCollection_Vector<Handle(AIS_InteractiveObject)> myObject2d;
NCollection_Vector<Handle(AIS_InteractiveObject)> myObject3d;
std::ostringstream myResult;
TCollection_AsciiString myCode;
TCollection_AsciiString myCodePath;
Handle(AIS_InteractiveContext) myContext;
protected:
static const TCollection_AsciiString FILE_EXTENSION;
private:
Standard_Integer findEndOfPhrase (const TCollection_AsciiString& theText,
const TCollection_AsciiString& theRegexpTemplate);
Standard_Integer findClosingBracket (const TCollection_AsciiString& theText,
Standard_Integer theOpeningBracketIndex,
Standard_Character theClosingBracketSymbol);
};
#endif //BASESAMPLE_H

View File

@@ -0,0 +1,17 @@
<Menu>
<MenuItem name="Data Exchange">
<MenuItem name="Export">
<Sample name="BREP" function="BrepExportSample"/>
<Sample name="STEP" function="StepExportSample"/>
<Sample name="IGES" function="IgesExportSample"/>
<Sample name="STL" function="StlExportSample"/>
<Sample name="VRML" function="VrmlExportSample"/>
<Sample name="Image" function="ImageExportSample"/>
</MenuItem>
<MenuItem name="Import">
<Sample name="BREP" function="BrepImportSample"/>
<Sample name="STEP" function="StepImportSample"/>
<Sample name="IGES" function="IgesImportSample"/>
</MenuItem>
</MenuItem>
</Menu>

View File

@@ -0,0 +1,422 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "DataExchangeSamples.h"
#include "MakeBottle.h"
#include <AIS_ViewCube.hxx>
#include <AIS_Shape.hxx>
#include <BRepTools.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Line.hxx>
#include <Graphic3d_TextureEnv.hxx>
#include <IFSelect_ReturnStatus.hxx>
#include <IGESControl_Controller.hxx>
#include <IGESControl_Reader.hxx>
#include <IGESControl_Writer.hxx>
#include <Interface_Static.hxx>
#include <STEPControl_Reader.hxx>
#include <STEPControl_Writer.hxx>
#include <StlAPI_Writer.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <VrmlAPI_Writer.hxx>
void DataExchangeSamples::Process (const TCollection_AsciiString& theSampleName)
{
if (IsImportSample(theSampleName))
{
myObject3d.Clear();
}
myObject2d.Clear();
myCode.Clear();
myIsProcessed = Standard_False;
try
{
ExecuteSample(theSampleName);
}
catch (...)
{
TraceError(TCollection_AsciiString("Error in sample: ") + theSampleName);
}
}
void DataExchangeSamples::AppendBottle()
{
TopoDS_Shape aBottle = MakeBottle(50, 70, 30);
Handle(AIS_InteractiveObject) aShape = new AIS_Shape(aBottle);
myObject3d.Append(aShape);
Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
myObject3d.Append(aViewCube);
myResult << "A bottle shape was created." << std::endl;
}
void DataExchangeSamples::ExecuteSample (const TCollection_AsciiString& theSampleName)
{
Standard_Boolean anIsSamplePresent = Standard_True;
FindSourceCode(theSampleName);
if (theSampleName == "BrepExportSample")
{
BrepExportSample();
}
else if (theSampleName == "StepExportSample")
{
StepExportSample();
}
else if (theSampleName == "IgesExportSample")
{
IgesExportSample();
}
else if (theSampleName == "StlExportSample")
{
StlExportSample();
}
else if (theSampleName == "VrmlExportSample")
{
VrmlExportSample();
}
else if (theSampleName == "ImageExportSample")
{
ImageExportSample();
}
else if (theSampleName == "BrepImportSample")
{
BrepImportSample();
}
else if (theSampleName == "StepImportSample")
{
StepImportSample();
}
else if (theSampleName == "IgesImportSample")
{
IgesImportSample();
}
else
{
myResult << "No function found: " << theSampleName;
myCode += TCollection_AsciiString("No function found: ") + theSampleName;
anIsSamplePresent = Standard_False;
}
myIsProcessed = anIsSamplePresent;
}
void DataExchangeSamples::BrepExportSample()
{
Standard_Boolean anIsShapeExist = Standard_False;
for(NCollection_Vector<Handle(AIS_InteractiveObject)>::Iterator anIter(myObject3d);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anObject = anIter.Value();
if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anObject))
{
anIsShapeExist = Standard_True;
if (BRepTools::Write(aShape->Shape(), myFileName.ToCString()))
{
myResult << "A shape was successfully written" << std::endl;
}
else
{
myResult << "A shape was not written" << std::endl;
}
break; // write only one shape
}
}
if (!anIsShapeExist)
{
myResult << "A shape does not exist" << std::endl;
}
}
void DataExchangeSamples::StepExportSample()
{
if (myStepType < 0)
{
myResult << "Unknown step type" << std::endl;
return;
}
IFSelect_ReturnStatus aStatus;
if (myStepType == STEPControl_FacetedBrep && !CheckFacetedBrep())
{
myResult << "At least one shape doesn't contain facets" << std::endl;
return;
}
STEPControl_Writer aStepWriter;
for(NCollection_Vector<Handle(AIS_InteractiveObject)>::Iterator anIter(myObject3d);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anObject = anIter.Value();
if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anObject))
{
aStatus = aStepWriter.Transfer(aShape->Shape(), myStepType);
if (aStatus != IFSelect_RetDone)
{
myResult << "A shape was not transferred successfully" << std::endl;
return;
}
}
}
aStatus = aStepWriter.Write(myFileName.ToCString());
switch (aStatus)
{
case IFSelect_RetError:
myResult << "Incorrect Data." << std::endl;
break;
case IFSelect_RetFail:
myResult << "Writing error" << std::endl;
break;
case IFSelect_RetVoid:
myResult << "Nothing to transfer." << std::endl;
break;
case IFSelect_RetStop:
case IFSelect_RetDone:
myResult << "A STEP file was successfully written" << std::endl;
break;
}
}
void DataExchangeSamples::IgesExportSample()
{
IGESControl_Controller::Init();
IGESControl_Writer anIgesWriter(Interface_Static::CVal("XSTEP.iges.unit"),
Interface_Static::IVal("XSTEP.iges.writebrep.mode"));
Standard_Boolean anIsShapeExist = Standard_False;
for(NCollection_Vector<Handle(AIS_InteractiveObject)>::Iterator anIter(myObject3d);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anObject = anIter.Value();
if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anObject))
{
anIsShapeExist = Standard_True;
anIgesWriter.AddShape(aShape->Shape());
}
}
if (anIsShapeExist)
{
anIgesWriter.ComputeModel();
if (anIgesWriter.Write(myFileName.ToCString()))
{
myResult << "A STEP file was successfully written" << std::endl;
}
else
{
myResult << "A STEP file was not written" << std::endl;
}
}
else
{
myResult << "Shapes do not exist" << std::endl;
}
}
void DataExchangeSamples::StlExportSample()
{
TopoDS_Compound aTopoCompound;
BRep_Builder aBuilder;
aBuilder.MakeCompound(aTopoCompound);
Standard_Boolean anIsShapeExist = Standard_False;
for(NCollection_Vector<Handle(AIS_InteractiveObject)>::Iterator anIter(myObject3d);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anObject = anIter.Value();
if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anObject))
{
anIsShapeExist = Standard_True;
aBuilder.Add(aTopoCompound, aShape->Shape());
}
}
if (anIsShapeExist)
{
StlAPI_Writer aStlWriter;
if (aStlWriter.Write(aTopoCompound, myFileName.ToCString()))
{
myResult << "A STL file was successfully written" << std::endl;
}
else
{
myResult << "A STL file was not written" << std::endl;
}
}
else
{
myResult << "Shapes do not exist" << std::endl;
}
}
void DataExchangeSamples::VrmlExportSample()
{
TopoDS_Compound aTopoCompound;
BRep_Builder aBrepBuilder;
aBrepBuilder.MakeCompound(aTopoCompound);
Standard_Boolean anIsShapeExist = Standard_False;
for(NCollection_Vector<Handle(AIS_InteractiveObject)>::Iterator anIter(myObject3d);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anObject = anIter.Value();
if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anObject))
{
anIsShapeExist = Standard_True;
aBrepBuilder.Add(aTopoCompound, aShape->Shape());
}
}
if (anIsShapeExist)
{
VrmlAPI_Writer aVrmlWriter;
if (aVrmlWriter.Write(aTopoCompound, myFileName.ToCString()))
{
myResult << "A VRML file was successfully written" << std::endl;
}
else
{
myResult << "A VRML file was not written" << std::endl;
}
}
else
{
myResult << "Shapes do not exist" << std::endl;
}
}
void DataExchangeSamples::ImageExportSample()
{
if (myView)
{
Standard_Boolean aResult = myView->Dump(myFileName.ToCString());
if (aResult)
{
myResult << "An image file was successfully written" << std::endl;
}
else
{
myResult << "An image file was not written" << std::endl;
}
}
}
void DataExchangeSamples::BrepImportSample()
{
TopoDS_Shape aTopoShape;
BRep_Builder aBuilder;
Standard_Boolean aResult = BRepTools::Read(aTopoShape, myFileName.ToCString(), aBuilder);
if (aResult)
{
Handle(AIS_Shape) anAisShape = new AIS_Shape(aTopoShape);
myObject3d.Append(anAisShape);
myResult << "A BREP file was read successfully" << std::endl;
}
else
{
myResult << "A BREP file was not read successfully" << std::endl;
}
}
void DataExchangeSamples::StepImportSample()
{
Handle(TopTools_HSequenceOfShape) aSequence = new TopTools_HSequenceOfShape();
STEPControl_Reader aReader;
const IFSelect_ReturnStatus aStatus = aReader.ReadFile(myFileName.ToCString());
if (aStatus != IFSelect_RetDone)
{
myResult << "A BREP file was not read successfully" << std::endl;
return;
}
bool anIsFailsOnly = false;
aReader.PrintCheckLoad(anIsFailsOnly, IFSelect_ItemsByEntity);
int aRootsNumber = aReader.NbRootsForTransfer();
aReader.PrintCheckTransfer(anIsFailsOnly, IFSelect_ItemsByEntity);
for (Standard_Integer i = 1; i <= aRootsNumber; i++)
{
aReader.TransferRoot(i);
}
int aShapesNumber = aReader.NbShapes();
for (int i = 1; i <= aShapesNumber; i++)
{
TopoDS_Shape aTopoShape = aReader.Shape(i);
Handle(AIS_Shape) anAisShape = new AIS_Shape(aTopoShape);
myObject3d.Append(anAisShape);
}
myResult << "A STEP file was read successfully" << std::endl;
}
void DataExchangeSamples::IgesImportSample()
{
IGESControl_Reader aReader;
int status = aReader.ReadFile (myFileName.ToCString());
if (status != IFSelect_RetDone)
{
myResult << "A IGES file was not read successfully" << std::endl;
return;
}
aReader.TransferRoots();
TopoDS_Shape aTopoShape = aReader.OneShape();
Handle(AIS_Shape) anAisShape = new AIS_Shape (aTopoShape);
myObject3d.Append(anAisShape);
myResult << "A IGES file was read successfully" << std::endl;
}
Standard_Boolean DataExchangeSamples::CheckFacetedBrep()
{
Standard_Boolean anError = Standard_False;
for(NCollection_Vector<Handle(AIS_InteractiveObject)>::Iterator anIter (myObject3d);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anObject = anIter.Value();
if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anObject))
{
const TopoDS_Shape aTopoShape = aShape->Shape();
for (TopExp_Explorer aFaceExplorer(aTopoShape, TopAbs_FACE); aFaceExplorer.More() && !anError; aFaceExplorer.Next())
{
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(TopoDS::Face(aFaceExplorer.Current()));
if (!aSurface->IsKind(STANDARD_TYPE(Geom_Plane)))
{
anError = Standard_True;
}
}
for (TopExp_Explorer anEdgeExplorer(aTopoShape, TopAbs_EDGE); anEdgeExplorer.More() && !anError; anEdgeExplorer.Next())
{
Standard_Real fd, ld;
Handle(Geom_Curve) curve = BRep_Tool::Curve(TopoDS::Edge(anEdgeExplorer.Current()), fd, ld);
if (!curve->IsKind(STANDARD_TYPE(Geom_Line)))
{
anError = Standard_True;
}
}
}
}
return !anError;
}

View File

@@ -0,0 +1,90 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef DATAEXCHANGESAMPLES_H
#define DATAEXCHANGESAMPLES_H
#include "BaseSample.h"
#include <STEPControl_StepModelType.hxx>
#include <V3d_View.hxx>
//! Implements Data Exchange samples
class DataExchangeSamples : public BaseSample
{
DEFINE_STANDARD_RTTI_INLINE(DataExchangeSamples, BaseSample)
public:
DataExchangeSamples (const TCollection_AsciiString& theSampleSourcePath,
const Handle(V3d_View)& theView,
const Handle(AIS_InteractiveContext)& theContext)
: BaseSample (theSampleSourcePath, theContext),
myStepType (STEPControl_AsIs),
myView (theView)
{
//
}
virtual void Process (const TCollection_AsciiString& theSampleName) Standard_OVERRIDE;
void AppendBottle();
void SetFileName(TCollection_AsciiString theFileName) { myFileName = theFileName; };
void SetStepType(STEPControl_StepModelType theStepType) { myStepType = theStepType; };
static Standard_Boolean IsExportSample(const TCollection_AsciiString& theSampleName) { return theSampleName == "BrepExportSample"
|| theSampleName == "StepExportSample"
|| theSampleName == "IgesExportSample"
|| theSampleName == "StlExportSample"
|| theSampleName == "VrmlExportSample"
|| theSampleName == "ImageExportSample"; }
static Standard_Boolean IsImportSample(const TCollection_AsciiString& theSampleName) { return theSampleName == "BrepImportSample"
|| theSampleName == "StepImportSample"
|| theSampleName == "IgesImportSample"; }
static Standard_Boolean IsBrepSample (const TCollection_AsciiString& theSampleName) { return theSampleName == "BrepExportSample" || theSampleName == "BrepImportSample"; }
static Standard_Boolean IsStepSample (const TCollection_AsciiString& theSampleName) { return theSampleName == "StepExportSample" || theSampleName == "StepImportSample"; }
static Standard_Boolean IsIgesSample (const TCollection_AsciiString& theSampleName) { return theSampleName == "IgesExportSample" || theSampleName == "IgesImportSample"; }
static Standard_Boolean IsStlSample (const TCollection_AsciiString& theSampleName) { return theSampleName == "StlExportSample"; }
static Standard_Boolean IsVrmlSample (const TCollection_AsciiString& theSampleName) { return theSampleName == "VrmlExportSample"; }
static Standard_Boolean IsImageSample (const TCollection_AsciiString& theSampleName) { return theSampleName == "ImageExportSample"; }
protected:
virtual void ExecuteSample (const TCollection_AsciiString& theSampleName) Standard_OVERRIDE;
private:
TCollection_AsciiString myFileName;
STEPControl_StepModelType myStepType;
Handle(V3d_View) myView;
private:
Standard_Boolean CheckFacetedBrep();
// One function for every sample
void BrepExportSample();
void StepExportSample();
void IgesExportSample();
void StlExportSample();
void VrmlExportSample();
void ImageExportSample();
void BrepImportSample();
void StepImportSample();
void IgesImportSample();
};
#endif //DATAEXCHANGESAMPLES_H

View File

@@ -0,0 +1,48 @@
AdaptorCurve2d_AIS.cxx
AdaptorCurve2d_AIS.h
AdaptorCurve_AIS.cxx
AdaptorCurve_AIS.h
AdaptorPnt2d_AIS.cxx
AdaptorPnt2d_AIS.h
AdaptorVec_AIS.cxx
AdaptorVec_AIS.h
BaseSample.cxx
BaseSample.h
DataExchange.xml
DataExchangeSamples.cxx
DataExchangeSamples.h
Geometry.xml
GeometrySamples.cxx
GeometrySamples.h
MakeBottle.cxx
MakeBottle.h
Ocaf.xml
OcafSamples.cxx
OcafSamples.h
Sample2D_Face.cxx
Sample2D_Face.h
Sample2D_Image.cxx
Sample2D_Image.h
Sample2D_Markers.cxx
Sample2D_Markers.h
Samples.qrc
TOcafFunction_BoxDriver.cxx
TOcafFunction_BoxDriver.h
TOcafFunction_CutDriver.cxx
TOcafFunction_CutDriver.h
TOcafFunction_CylDriver.cxx
TOcafFunction_CylDriver.h
TOcaf_Application.cxx
TOcaf_Application.h
Topology.xml
TopologySamples.cxx
TopologySamples.h
Triangulation.xml
TriangulationSamples.cxx
TriangulationSamples.h
Viewer2d.xml
Viewer2dSamples.cxx
Viewer2dSamples.h
Viewer3d.xml
Viewer3dSamples.cxx
Viewer3dSamples.h

View File

@@ -0,0 +1,92 @@
<Menu>
<MenuItem name="Non Parametric">
<MenuItem name="Free creating">
<MenuItem name="3D">
<Sample name="Zero Dimension objects" function="ZeroDimensionObjects3dSample"/>
<Sample name="Vectors" function="Vectors3dSample"/>
<Sample name="Infinity lines" function="InfinityLines3dSample"/>
<Sample name="Second order curves" function="SecondOrderCurves3dSample"/>
<Sample name="Plane surfaces" function="PlaneSurfaces3dSample"/>
<Sample name="Second order surfaces" function="SecondOrderSurfaces3dSample"/>
</MenuItem>
<MenuItem name="2D">
<Sample name="Zero Dimension objects" function="ZeroDimensionObjects2dSample"/>
<Sample name="Vectors" function="Vectors2dSample"/>
<Sample name="Infinity lines" function="InfinityLines2dSample"/>
<Sample name="Second order curves" function="SecondOrderCurves2dSample"/>
</MenuItem>
</MenuItem>
<MenuItem name="Creating based on criteria">
<MenuItem name="3D">
<Sample name="Barycenter point" function="BarycenterPoint3dSample"/>
<Sample name="Rotated vector" function="RotatedVector3dSample"/>
<Sample name="Mirrored line" function="MirroredLine3dSample"/>
<Sample name="Scaled Ellipse" function="ScaledEllipse3dSample"/>
<Sample name="Transformed cylinder" function="TransformedCylinder3dSample"/>
<Sample name="Translated torus" function="TranslatedTorus3dSample"/>
<Sample name="Conjugate objects" function="ConjugateObjects3dSample"/>
<Sample name="Projection of point" function="ProjectionOfPoint3dSample"/>
<Sample name="Minimal distance" function="MinimalDistance3dSample"/>
<Sample name="Intersection" function="Intersection3dSample"/>
</MenuItem>
<MenuItem name="2D">
<Sample name="Translated point" function="TranslatedPoint2dSample"/>
<Sample name="Rotated direction" function="RotatedDirection2dSample"/>
<Sample name="Mirrored axis" function="MirroredAxis2dSample"/>
<Sample name="Transformed ellipse" function="TransformedEllipse2dSample"/>
<Sample name="Conjugate objects" function="ConjugateObjects2dSample"/>
<Sample name="Tangent to 2 cilcles" function="Tangent2dSample"/>
<Sample name="Projection of point" function="ProjectionOfPoint2dSample"/>
<Sample name="Minimal distance" function="MinimalDistance2dSample"/>
<Sample name="Intersection" function="Intersection2dSample"/>
</MenuItem>
</MenuItem>
<MenuItem name="Data extraction">
<MenuItem name="3D">
<Sample name="Point info" function="PointInfo3dSample"/>
<Sample name="Ellipse info" function="EllipseInfo3dSample"/>
</MenuItem>
<MenuItem name="2D">
<Sample name="Point info" function="PointInfo2dSample"/>
<Sample name="Circle info" function="CircleInfo2dSample"/>
</MenuItem>
</MenuItem>
</MenuItem>
<MenuItem name="Parametric">
<MenuItem name="Free creating">
<MenuItem name="3D">
<Sample name="Free style curves" function="FreeStyleCurves3dSample"/>
<Sample name="Analytical surfaces" function="AnalyticalSurfaces3dSample"/>
<Sample name="Free style surfaces" function="FreeStyleSurfaces3dSample"/>
</MenuItem>
<MenuItem name="2D">
<Sample name="Free style curves" function="FreeStyleCurves2dSample"/>
</MenuItem>
</MenuItem>
<MenuItem name="Creating based on geometry">
<MenuItem name="3D">
<Sample name="Trimmed curve" function="TrimmedCurve3dSample"/>
<Sample name="Offset curve" function="OffsetCurve3dSample"/>
<Sample name="BSpline from circle" function="BSplineFromCircle3dSample"/>
<Sample name="Trimmed surface" function="TrimmedSurface3dSample"/>
<Sample name="Offset surface" function="OffsetSurface3dSample"/>
<Sample name="Extrusion surface" function="ExtrusionSurface3dSample"/>
<Sample name="Revolution surface" function="RevolutionSurface3dSample"/>
</MenuItem>
<MenuItem name="2D">
<Sample name="Trimmed curve" function="TrimmedCurve2dSample"/>
<Sample name="Offset curve" function="OffsetCurve2dSample"/>
</MenuItem>
</MenuItem>
<MenuItem name="Extract geometry">
<Sample name="Bounding box of surface (3D)" function="BoundingBoxOfSurface3dSample"/>
<Sample name="Bounding box of curves (3D)" function="BoundingBoxOfCurves3dSample"/>
<Sample name="Bounding box of curves (2D)" function="BoundingBoxOfCurves2dSample"/>
</MenuItem>
<MenuItem name="Data extraction">
<Sample name="Dump circle info" function="DumpCircleInfoSample"/>
<Sample name="Dump BSpline curve info" function="DumpBSplineCurveInfoSample"/>
</MenuItem>
</MenuItem>
</Menu>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef GEOMETRYSAMPLES_H
#define GEOMETRYSAMPLES_H
#include "BaseSample.h"
//! Implements Geometry samples
class GeometrySamples : public BaseSample
{
DEFINE_STANDARD_RTTI_INLINE(GeometrySamples, BaseSample)
public:
GeometrySamples (const TCollection_AsciiString& theSampleSourcePath,
const Handle(AIS_InteractiveContext)& theContext)
: BaseSample(theSampleSourcePath, theContext) {}
protected:
virtual void ExecuteSample (const TCollection_AsciiString& theSampleName) Standard_OVERRIDE;
private:
void DisplayPnt (const gp_Pnt& thePnt, const TCollection_AsciiString& theText,
Aspect_TypeOfMarker theMarker = Aspect_TOM_PLUS,
Standard_Real theDistance = 5.0);
void DisplayPnt (const gp_Pnt2d& thePnt2d, const TCollection_AsciiString& theText,
Aspect_TypeOfMarker theMarker = Aspect_TOM_PLUS,
Standard_Real theDistance = 5.0);
// One function for every sample
void ZeroDimensionObjects3dSample();
void Vectors3dSample();
void InfinityLines3dSample();
void SecondOrderCurves3dSample();
void PlaneSurfaces3dSample();
void SecondOrderSurfaces3dSample();
void ZeroDimensionObjects2dSample();
void Vectors2dSample();
void InfinityLines2dSample();
void SecondOrderCurves2dSample();
void BarycenterPoint3dSample();
void RotatedVector3dSample();
void MirroredLine3dSample();
void ScaledEllipse3dSample();
void TransformedCylinder3dSample();
void TranslatedTorus3dSample();
void ConjugateObjects3dSample();
void ProjectionOfPoint3dSample();
void MinimalDistance3dSample();
void Intersection3dSample();
void TranslatedPoint2dSample();
void RotatedDirection2dSample();
void MirroredAxis2dSample();
void TransformedEllipse2dSample();
void ConjugateObjects2dSample();
void Tangent2dSample();
void ProjectionOfPoint2dSample();
void MinimalDistance2dSample();
void Intersection2dSample();
void PointInfo3dSample();
void EllipseInfo3dSample();
void PointInfo2dSample();
void CircleInfo2dSample();
void FreeStyleCurves3dSample();
void AnalyticalSurfaces3dSample();
void FreeStyleSurfaces3dSample();
void FreeStyleCurves2dSample();
void TrimmedCurve3dSample();
void OffsetCurve3dSample();
void BSplineFromCircle3dSample();
void TrimmedSurface3dSample();
void OffsetSurface3dSample();
void ExtrusionSurface3dSample();
void RevolutionSurface3dSample();
void TrimmedCurve2dSample();
void OffsetCurve2dSample();
void BoundingBoxOfSurface3dSample();
void BoundingBoxOfCurves3dSample();
void BoundingBoxOfCurves2dSample();
void DumpCircleInfoSample();
void DumpBSplineCurveInfoSample();
};
#endif //GEOMETRYSAMPLES_H

View File

@@ -0,0 +1,218 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "MakeBottle.h"
#include <BRep_Tool.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#include <BRepLib.hxx>
#include <BRepOffsetAPI_MakeThickSolid.hxx>
#include <BRepOffsetAPI_ThruSections.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <GC_MakeArcOfCircle.hxx>
#include <GC_MakeSegment.hxx>
#include <GCE2d_MakeSegment.hxx>
#include <gp.hxx>
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>
#include <gp_Ax2d.hxx>
#include <gp_Dir.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Trsf.hxx>
#include <gp_Vec.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Surface.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopTools_ListOfShape.hxx>
TopoDS_Shape MakeBottle (const Standard_Real theWidth,
const Standard_Real theHeight,
const Standard_Real theThickness)
{
// Profile : Define Support Points
gp_Pnt aPnt1(-theWidth / 2., 0, 0);
gp_Pnt aPnt2(-theWidth / 2., -theThickness / 4., 0);
gp_Pnt aPnt3(0, -theThickness / 2., 0);
gp_Pnt aPnt4(theWidth / 2., -theThickness / 4., 0);
gp_Pnt aPnt5(theWidth / 2., 0, 0);
// Profile : Define the Geometry
Handle(Geom_TrimmedCurve) anArcOfCircle = GC_MakeArcOfCircle(aPnt2, aPnt3, aPnt4);
Handle(Geom_TrimmedCurve) aSegment1 = GC_MakeSegment(aPnt1, aPnt2);
Handle(Geom_TrimmedCurve) aSegment2 = GC_MakeSegment(aPnt4, aPnt5);
// Profile : Define the Topology
TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(aSegment1);
TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(anArcOfCircle);
TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge(aSegment2);
TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge1, anEdge2, anEdge3);
// Complete Profile
gp_Ax1 xAxis = gp::OX();
gp_Trsf aTrsf;
aTrsf.SetMirror(xAxis);
BRepBuilderAPI_Transform aBRepTrsf(aWire, aTrsf);
TopoDS_Shape aMirroredShape = aBRepTrsf.Shape();
TopoDS_Wire aMirroredWire = TopoDS::Wire(aMirroredShape);
BRepBuilderAPI_MakeWire mkWire;
mkWire.Add(aWire);
mkWire.Add(aMirroredWire);
TopoDS_Wire myWireProfile = mkWire.Wire();
// Body : Prism the Profile
TopoDS_Face myFaceProfile = BRepBuilderAPI_MakeFace(myWireProfile);
gp_Vec aPrismVec(0, 0, theHeight);
TopoDS_Shape myBody = BRepPrimAPI_MakePrism(myFaceProfile, aPrismVec);
// Body : Apply Fillets
BRepFilletAPI_MakeFillet mkFillet(myBody);
TopExp_Explorer anEdgeExplorer(myBody, TopAbs_EDGE);
while (anEdgeExplorer.More())
{
TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExplorer.Current());
//Add edge to fillet algorithm
mkFillet.Add(theThickness / 12., anEdge);
anEdgeExplorer.Next();
}
myBody = mkFillet.Shape();
// Body : Add the Neck
gp_Pnt neckLocation(0, 0, theHeight);
gp_Dir neckAxis = gp::DZ();
gp_Ax2 neckAx2(neckLocation, neckAxis);
Standard_Real myNeckRadius = theThickness / 4.;
Standard_Real myNeckHeight = theHeight / 10.;
BRepPrimAPI_MakeCylinder MKCylinder(neckAx2, myNeckRadius, myNeckHeight);
TopoDS_Shape myNeck = MKCylinder.Shape();
myBody = BRepAlgoAPI_Fuse(myBody, myNeck);
// Body : Create a Hollowed Solid
TopoDS_Face faceToRemove;
Standard_Real zMax = -1;
for (TopExp_Explorer aFaceExplorer(myBody, TopAbs_FACE); aFaceExplorer.More(); aFaceExplorer.Next())
{
TopoDS_Face aFace = TopoDS::Face(aFaceExplorer.Current());
// Check if <aFace> is the top face of the bottle<6C>s neck
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
if (aSurface->DynamicType() == STANDARD_TYPE(Geom_Plane))
{
Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurface);
gp_Pnt aPnt = aPlane->Location();
Standard_Real aZ = aPnt.Z();
if (aZ > zMax)
{
zMax = aZ;
faceToRemove = aFace;
}
}
}
TopTools_ListOfShape facesToRemove;
facesToRemove.Append(faceToRemove);
BRepOffsetAPI_MakeThickSolid aSolidMaker;
aSolidMaker.MakeThickSolidByJoin(myBody, facesToRemove, -theThickness / 50, 1.e-3);
myBody = aSolidMaker.Shape();
// Threading : Create Surfaces
Handle(Geom_CylindricalSurface) aCyl1 = new Geom_CylindricalSurface(neckAx2, myNeckRadius * 0.99);
Handle(Geom_CylindricalSurface) aCyl2 = new Geom_CylindricalSurface(neckAx2, myNeckRadius * 1.05);
// Threading : Define 2D Curves
gp_Pnt2d aPnt(2. * M_PI, myNeckHeight / 2.);
gp_Dir2d aDir(2. * M_PI, myNeckHeight / 4.);
gp_Ax2d anAx2d(aPnt, aDir);
Standard_Real aMajor = 2. * M_PI;
Standard_Real aMinor = myNeckHeight / 10;
Handle(Geom2d_Ellipse) anEllipse1 = new Geom2d_Ellipse(anAx2d, aMajor, aMinor);
Handle(Geom2d_Ellipse) anEllipse2 = new Geom2d_Ellipse(anAx2d, aMajor, aMinor / 4);
Handle(Geom2d_TrimmedCurve) anArc1 = new Geom2d_TrimmedCurve(anEllipse1, 0, M_PI);
Handle(Geom2d_TrimmedCurve) anArc2 = new Geom2d_TrimmedCurve(anEllipse2, 0, M_PI);
gp_Pnt2d anEllipsePnt1 = anEllipse1->Value(0);
gp_Pnt2d anEllipsePnt2 = anEllipse1->Value(M_PI);
Handle(Geom2d_TrimmedCurve) aSegment = GCE2d_MakeSegment(anEllipsePnt1, anEllipsePnt2);
// Threading : Build Edges and Wires
TopoDS_Edge anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(anArc1, aCyl1);
TopoDS_Edge anEdge2OnSurf1 = BRepBuilderAPI_MakeEdge(aSegment, aCyl1);
TopoDS_Edge anEdge1OnSurf2 = BRepBuilderAPI_MakeEdge(anArc2, aCyl2);
TopoDS_Edge anEdge2OnSurf2 = BRepBuilderAPI_MakeEdge(aSegment, aCyl2);
TopoDS_Wire threadingWire1 = BRepBuilderAPI_MakeWire(anEdge1OnSurf1, anEdge2OnSurf1);
TopoDS_Wire threadingWire2 = BRepBuilderAPI_MakeWire(anEdge1OnSurf2, anEdge2OnSurf2);
BRepLib::BuildCurves3d(threadingWire1);
BRepLib::BuildCurves3d(threadingWire2);
// Create Threading
BRepOffsetAPI_ThruSections aTool(Standard_True);
aTool.AddWire(threadingWire1);
aTool.AddWire(threadingWire2);
aTool.CheckCompatibility(Standard_False);
TopoDS_Shape myThreading = aTool.Shape();
// Building the Resulting Compound
TopoDS_Compound aRes;
BRep_Builder aBuilder;
aBuilder.MakeCompound(aRes);
aBuilder.Add(aRes, myBody);
aBuilder.Add(aRes, myThreading);
return aRes;
}

View File

@@ -0,0 +1,33 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef MAKEBOTTLE_H
#define MAKEBOTTLE_H
#include <Standard_Macro.hxx>
#include <TopoDS_Shape.hxx>
//! Returns sample bottle TopoDS_Shape
TopoDS_Shape MakeBottle(const Standard_Real theWidth,
const Standard_Real theyHeight,
const Standard_Real theThickness);
#endif // MAKEBOTTLE_H

View File

@@ -0,0 +1,21 @@
<Menu>
<MenuItem name="OCAF">
<MenuItem name="1 Create">
<Sample name="Create Box" function="CreateBoxOcafSample"/>
<Sample name="Create Cylinder" function="CreateCylinderOcafSample"/>
</MenuItem>
<MenuItem name="2 Modify">
<Sample name="Modify Box" function="ModifyBoxOcafSample"/>
<Sample name="Modify Cylinder" function="ModifyCylinderOcafSample"/>
</MenuItem>
<MenuItem name="3 Action">
<Sample name="Undo" function="UndoOcafSample"/>
<Sample name="Redo" function="RedoOcafSample"/>
</MenuItem>
<MenuItem name="4 Data storage">
<Sample name="Open OCAF" function="DialogOpenOcafSample"/>
<Sample name="Save binary OCAF" function="DialogSaveBinOcafSample"/>
<Sample name="Save XML OCAF" function="DialogSaveXmlOcafSample"/>
</MenuItem>
</MenuItem>
</Menu>

View File

@@ -0,0 +1,629 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "OcafSamples.h"
#include "TOcaf_Application.h"
#include "TOcafFunction_BoxDriver.h"
#include "TOcafFunction_CylDriver.h"
#include <TPrsStd_AISViewer.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_DisplayMode.hxx>
#include <TPrsStd_AISPresentation.hxx>
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Real.hxx>
#include <TDataStd_Name.hxx>
#include <TFunction_Function.hxx>
#include <TFunction_DriverTable.hxx>
#include <TDF_ChildIterator.hxx>
#include <PCDM_StoreStatus.hxx>
#include <BinDrivers.hxx>
#include <XmlDrivers.hxx>
void OcafSamples::Process (const TCollection_AsciiString& theSampleName)
{
if (IsImportSample(theSampleName))
{
myObject3d.Clear();
}
myObject2d.Clear();
myCode.Clear();
myIsProcessed = Standard_False;
try
{
ExecuteSample(theSampleName);
}
catch (...)
{
TraceError(TCollection_AsciiString("Error in sample: ") + theSampleName);
}
}
void OcafSamples::ClearExtra()
{
myOcafDoc = nullptr;
myContext->RemoveAll(Standard_True);
}
void OcafSamples::ExecuteSample (const TCollection_AsciiString& theSampleName)
{
Standard_Boolean anIsSamplePresent = Standard_True;
FindSourceCode(theSampleName);
if (theSampleName == "CreateOcafDocument")
CreateOcafDocument();
else if (theSampleName == "CreateBoxOcafSample")
CreateBoxOcafSample();
else if (theSampleName == "CreateCylinderOcafSample")
CreateCylinderOcafSample();
else if (theSampleName == "ModifyBoxOcafSample")
ModifyBoxOcafSample();
else if (theSampleName == "ModifyCylinderOcafSample")
ModifyCylinderOcafSample();
else if (theSampleName == "UndoOcafSample")
UndoOcafSample();
else if (theSampleName == "RedoOcafSample")
RedoOcafSample();
else if (theSampleName == "DialogOpenOcafSample")
DialogOpenOcafSample();
else if (theSampleName == "DialogSaveBinOcafSample")
DialogSaveBinOcafSample();
else if (theSampleName == "DialogSaveXmlOcafSample")
DialogSaveXmlOcafSample();
else
{
myResult << "No function found: " << theSampleName;
myCode += TCollection_AsciiString("No function found: ") + theSampleName;
anIsSamplePresent = Standard_False;
}
myIsProcessed = anIsSamplePresent;
}
Standard_Boolean OcafSamples::IsExportSample (const TCollection_AsciiString& theSampleName)
{
if (theSampleName == "DialogSaveBinOcafSample" || theSampleName == "DialogSaveXmlOcafSample")
{
return Standard_True;
}
else
{
return Standard_False;
}
}
Standard_Boolean OcafSamples::IsImportSample (const TCollection_AsciiString& theSampleName)
{
if (theSampleName == "DialogOpenOcafSample")
{
return Standard_True;
}
else
{
return Standard_False;
}
}
Standard_Boolean OcafSamples::IsBinarySample (const TCollection_AsciiString& theSampleName)
{
if (theSampleName == "DialogOpenOcafSample" || theSampleName == "DialogSaveBinOcafSample")
{
return Standard_True;
}
else
{
return Standard_False;
}
}
Standard_Boolean OcafSamples::IsXmlSample (const TCollection_AsciiString& theSampleName)
{
if (theSampleName == "DialogOpenOcafSample" || theSampleName == "DialogSaveXmlOcafSample")
{
return Standard_True;
}
else
{
return Standard_False;
}
}
void OcafSamples::CreateOcafDocument()
{
Handle(TOcaf_Application) anOcaf_Application = new TOcaf_Application;
anOcaf_Application->NewDocument("BinOcaf", myOcafDoc);
TPrsStd_AISViewer::New(myOcafDoc->Main(), myViewer);
Handle(AIS_InteractiveContext) anAisContext;
TPrsStd_AISViewer::Find(myOcafDoc->Main(), anAisContext);
anAisContext->SetDisplayMode(AIS_Shaded, Standard_True);
myContext = anAisContext;
// Set the maximum number of available "undo" actions
myOcafDoc->SetUndoLimit(10);
}
void OcafSamples::CreateBoxOcafSample()
{
// Open a new command (for undo)
myOcafDoc->NewCommand();
// A data structure for our box:
// the box itself is attached to the BoxLabel label (as his name and his function attribute)
// its arguments (dimensions: width, length and height; and position: x, y, z)
// are attached to the child labels of the box:
// 0:1 Box Label ---> Name ---> Named shape ---> Function
// 0:1:1 -- Width Label
// 0:1:2 -- Length Label
// 0:1:3 -- Height Label
// 0:1:4 -- X Label
// 0:1:5 -- Y Label
// 0:1:6 -- Z Label
// Create a new label in the data structure for the box
TDF_Label aLabel = TDF_TagSource::NewChild(myOcafDoc->Main());
Standard_Real aBoxWidth(30.0), aBoxLength(20.0), aBoxHeight(10.0);
Standard_Real aBoxX(0.0), aBoxY(0.0), aBoxZ(0.0);
Standard_CString aBoxName("OcafBox");
// Create the data structure : Set the dimensions, position and name attributes
TDataStd_Real::Set(aLabel.FindChild(1), aBoxWidth);
TDataStd_Real::Set(aLabel.FindChild(2), aBoxLength);
TDataStd_Real::Set(aLabel.FindChild(3), aBoxHeight);
TDataStd_Real::Set(aLabel.FindChild(4), aBoxX);
TDataStd_Real::Set(aLabel.FindChild(5), aBoxY);
TDataStd_Real::Set(aLabel.FindChild(6), aBoxZ);
TDataStd_Name::Set(aLabel, aBoxName); // Name
// Instantiate a TFunction_Function attribute connected to the current box driver
// and attach it to the data structure as an attribute of the Box Label
Handle(TFunction_Function) myFunction = TFunction_Function::Set(aLabel, TOcafFunction_BoxDriver::GetID());
// Initialize and execute the box driver (look at the "Execute()" code)
Handle(TFunction_Logbook) aLogBook = TFunction_Logbook::Set(aLabel);
Handle(TFunction_Driver) myBoxDriver;
// Find the TOcafFunction_BoxDriver in the TFunction_DriverTable using its GUID
if (!TFunction_DriverTable::Get()->FindDriver(TOcafFunction_BoxDriver::GetID(), myBoxDriver))
{
myResult << "Ocaf Box driver not found" << std::endl;
}
myBoxDriver->Init(aLabel);
if (myBoxDriver->Execute(aLogBook))
{
myResult << "Create Box function execute failed" << std::endl;
}
// Get the TPrsStd_AISPresentation of the new box TNaming_NamedShape
Handle(TPrsStd_AISPresentation) anAisPresentation = TPrsStd_AISPresentation::Set(aLabel, TNaming_NamedShape::GetID());
// Display it
anAisPresentation->Display(1);
// Attach an integer attribute to aLabel to memorize it's displayed
TDataStd_Integer::Set(aLabel, 1);
myContext->UpdateCurrentViewer();
// Close the command (for undo)
myOcafDoc->CommitCommand();
myResult << "Created a box with name: " << aBoxName << std::endl;
myResult << "base coord X: " << aBoxX << " Y: " << aBoxY << " Z: " << aBoxZ << std::endl;
myResult << "width: " << aBoxWidth << " length: " << aBoxLength << " height: " << aBoxHeight << std::endl;
}
void OcafSamples::CreateCylinderOcafSample()
{
// Open a new command (for undo)
myOcafDoc->NewCommand();
// A data structure for our cylinder:
// the cylinder itself is attached to the CylinderLabel label (as his name and his function attribute)
// its arguments (dimensions: radius and height; and position: x, y, z)
// are attached to the child labels of the cylinder:
// 0:1 Cylinder Label ---> Name ---> Named shape ---> Function
// 0:1:1 -- Radius Label
// 0:1:2 -- Height Label
// 0:1:3 -- X Label
// 0:1:4 -- Y Label
// 0:1:5 -- Z Label
// Create a new label in the data structure for the cylinder
TDF_Label aLabel = TDF_TagSource::NewChild(myOcafDoc->Main());
Standard_Real aCylRadius(10.0), aCylHeight(20.0);
Standard_Real aCylX(60.0), aCylY(40.0), aCylZ(0.0);
Standard_CString aCylName("OcafCylinder");
// Create the data structure : Set the dimensions, position and name attributes
TDataStd_Real::Set(aLabel.FindChild(1), aCylRadius);
TDataStd_Real::Set(aLabel.FindChild(2), aCylHeight);
TDataStd_Real::Set(aLabel.FindChild(3), aCylX);
TDataStd_Real::Set(aLabel.FindChild(4), aCylY);
TDataStd_Real::Set(aLabel.FindChild(5), aCylZ);
TDataStd_Name::Set(aLabel, aCylName);
// Instantiate a TFunction_Function attribute connected to the current cylinder driver
// and attach it to the data structure as an attribute of the Cylinder Label
Handle(TFunction_Function) myFunction = TFunction_Function::Set(aLabel, TOcafFunction_CylDriver::GetID());
// Initialize and execute the cylinder driver (look at the "Execute()" code)
Handle(TFunction_Logbook) aLogBook = TFunction_Logbook::Set(aLabel);
Handle(TFunction_Driver) myCylDriver;
// Find the TOcafFunction_CylDriver in the TFunction_DriverTable using its GUID
if (!TFunction_DriverTable::Get()->FindDriver(TOcafFunction_CylDriver::GetID(), myCylDriver))
{
myResult << "Ocaf Cylinder driver not found";
}
myCylDriver->Init(aLabel);
if (myCylDriver->Execute(aLogBook))
{
myResult << "Create Cylinder function execute failed";
}
// Get the TPrsStd_AISPresentation of the new box TNaming_NamedShape
Handle(TPrsStd_AISPresentation) anAisPresentation = TPrsStd_AISPresentation::Set(aLabel, TNaming_NamedShape::GetID());
// Display it
anAisPresentation->Display(1);
// Attach an integer attribute to aLabel to memorize it's displayed
TDataStd_Integer::Set(aLabel, 1);
myContext->UpdateCurrentViewer();
// Close the command (for undo)
myOcafDoc->CommitCommand();
myResult << "Created a cylinder with name: " << aCylName << std::endl;
myResult << "radius: " << aCylRadius << " height: " << aCylHeight << std::endl;
myResult << "base coord X: " << aCylX << " Y: " << aCylY << " Z: " << aCylZ << std::endl;
}
void OcafSamples::ModifyBoxOcafSample()
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
Standard_Integer aBoxCount(0);
for(AIS_ListOfInteractive::Iterator anIter(anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
// Get the main label of the selected object
Handle(TPrsStd_AISPresentation) anAisPresentation = Handle(TPrsStd_AISPresentation)::DownCast(anAisObject->GetOwner());
TDF_Label aLabel = anAisPresentation->Label();
// Get the TFunction_Function attribute of the selected object
Handle(TFunction_Function) aFunction;
if (!aLabel.FindAttribute(TFunction_Function::GetID(), aFunction))
{
myResult << "Object cannot be modify.";
return;
}
// Get the Standard_GUID of the TFunction_FunctionDriver of the selected object TFunction_Function attribute
Standard_GUID aDriverID = aFunction->GetDriverGUID();
// Case of a box created with the box function driver
if (aDriverID == TOcafFunction_BoxDriver::GetID())
{
aBoxCount++;
Standard_Real aBoxX, aBoxY, aBoxZ, aBoxWidth, aBoxLength, aBoxHeight;
// Get the attributes values of the current box
Handle(TDataStd_Real) aCurrentReal;
aLabel.FindChild(1).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aBoxWidth = aCurrentReal->Get();
aLabel.FindChild(2).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aBoxLength = aCurrentReal->Get();
aLabel.FindChild(3).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aBoxHeight = aCurrentReal->Get();
aLabel.FindChild(4).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aBoxX = aCurrentReal->Get();
aLabel.FindChild(5).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aBoxY = aCurrentReal->Get();
aLabel.FindChild(6).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aBoxZ = aCurrentReal->Get();
Handle(TDataStd_Name) aBoxName;
aLabel.FindAttribute(TDataStd_Name::GetID(), aBoxName);
myResult << "Current parameters of box with name: " << aBoxName->Get() << std::endl;
myResult << "width: " << aBoxWidth << " length: " << aBoxLength << " height: " << aBoxHeight << std::endl;
myResult << "base coord X: " << aBoxX << " Y: " << aBoxY << " Z: " << aBoxZ << std::endl;
// Open a new command (for undo)
myOcafDoc->NewCommand();
// Modify the box - 1.5 times increase
aBoxWidth *= 1.5; aBoxLength *= 1.5; aBoxHeight *= 1.5;
TDataStd_Real::Set(aLabel.FindChild(1), aBoxWidth);
TDataStd_Real::Set(aLabel.FindChild(2), aBoxLength);
TDataStd_Real::Set(aLabel.FindChild(3), aBoxHeight);
TDataStd_Real::Set(aLabel.FindChild(4), aBoxX);
TDataStd_Real::Set(aLabel.FindChild(5), aBoxY);
TDataStd_Real::Set(aLabel.FindChild(6), aBoxZ);
// Get the TFunction_FunctionDriver GUID used with the TFunction_Function
aDriverID = aFunction->GetDriverGUID();
Handle(TFunction_Logbook) aLogBook = TFunction_Logbook::Set(aLabel);
Handle(TFunction_Driver) aBoxDriver;
// Find the TOcafFunction_BoxDriver in the TFunction_DriverTable using its GUID
TFunction_DriverTable::Get()->FindDriver(aDriverID, aBoxDriver);
// Execute the cut if it must be (if an attribute changes)
aBoxDriver->Init(aLabel);
// Set the box touched, it will be useful to recompute an object which used this box as attribute
aLogBook->SetTouched(aLabel);
if (aBoxDriver->Execute(aLogBook))
{
myResult << "Recompute failed" << std::endl;
}
// Get the presentation of the box, display it and set it selected
anAisPresentation = TPrsStd_AISPresentation::Set(aLabel, TNaming_NamedShape::GetID());
TDataStd_Integer::Set(aLabel, 1);
anAisPresentation->Display(1);
myContext->UpdateCurrentViewer();
// Close the command (for undo)
myOcafDoc->CommitCommand();
myResult << std::endl;
myResult << "New box parameters: " << std::endl;
myResult << "base coord X: " << aBoxX << " Y: " << aBoxY << " Z: " << aBoxZ << std::endl;
myResult << "width: " << aBoxWidth << " length: " << aBoxLength << " height: " << aBoxHeight << std::endl;
}
}
if (aBoxCount)
{
myResult << "Number of modified boxes: " << aBoxCount << std::endl;
}
else
{
myResult << "No boxes to modify" << std::endl;
}
}
void OcafSamples::ModifyCylinderOcafSample()
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
Standard_Integer aCylCount(0);
for(AIS_ListOfInteractive::Iterator anIter (anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
// Get the main label of the selected object
Handle(TPrsStd_AISPresentation) anAisPresentation = Handle(TPrsStd_AISPresentation)::DownCast(anAisObject->GetOwner());
TDF_Label aLabel = anAisPresentation->Label();
// Get the TFunction_Function attribute of the selected object
Handle(TFunction_Function) aFunction;
if (!aLabel.FindAttribute(TFunction_Function::GetID(), aFunction))
{
myResult << "Object cannot be modify.";
return;
}
// Get the Standard_GUID of the TFunction_FunctionDriver of the selected object TFunction_Function attribute
Standard_GUID aDriverID = aFunction->GetDriverGUID();
// Case of a box created with the box function driver
if (aDriverID == TOcafFunction_CylDriver::GetID())
{
aCylCount++;
Standard_Real aCylRadius, aCylHeight, aCylX, aCylY, aCylZ;
// Get the attributes values of the current box
Handle(TDataStd_Real) aCurrentReal;
aLabel.FindChild(1).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aCylRadius = aCurrentReal->Get();
aLabel.FindChild(2).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aCylHeight = aCurrentReal->Get();
aLabel.FindChild(3).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aCylX = aCurrentReal->Get();
aLabel.FindChild(4).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aCylY = aCurrentReal->Get();
aLabel.FindChild(5).FindAttribute(TDataStd_Real::GetID(), aCurrentReal);
aCylZ = aCurrentReal->Get();
Handle(TDataStd_Name) aCylName;
aLabel.FindAttribute(TDataStd_Name::GetID(), aCylName);
myResult << "Current parameters of box with name: " << aCylName->Get() << std::endl;
myResult << "radius: " << aCylRadius << " height: " << aCylHeight << std::endl;
myResult << "base coord X: " << aCylX << " Y: " << aCylY << " Z: " << aCylZ << std::endl;
// Open a new command (for undo)
myOcafDoc->NewCommand();
// Modify the cylinder - 2x increase
aCylRadius *= 2.0; aCylHeight *= 2.0;
// and move base point in XY plane
aCylX *= 2.0; aCylY *= 2.0;
TDataStd_Real::Set(aLabel.FindChild(1), aCylRadius);
TDataStd_Real::Set(aLabel.FindChild(2), aCylHeight);
TDataStd_Real::Set(aLabel.FindChild(3), aCylX);
TDataStd_Real::Set(aLabel.FindChild(4), aCylY);
TDataStd_Real::Set(aLabel.FindChild(5), aCylZ);
// Get the TFunction_FunctionDriver GUID used with the TFunction_Function
aDriverID = aFunction->GetDriverGUID();
Handle(TFunction_Logbook) aLogBook = TFunction_Logbook::Set(aLabel);
Handle(TFunction_Driver) aCylDriver;
// Find the TOcafFunction_CylDriver in the TFunction_DriverTable using its GUID
TFunction_DriverTable::Get()->FindDriver(aDriverID, aCylDriver);
// Execute the cut if it must be (if an attribute changes)
aCylDriver->Init(aLabel);
// Set the cylinder touched, it will be useful to recompute an object which used this box as attribute
aLogBook->SetTouched(aLabel);
if (aCylDriver->Execute(aLogBook))
{
myResult << "Recompute failed" << std::endl;
}
// Get the presentation of the box, display it and set it selected
anAisPresentation = TPrsStd_AISPresentation::Set(aLabel, TNaming_NamedShape::GetID());
TDataStd_Integer::Set(aLabel, 1);
anAisPresentation->Display(1);
myContext->UpdateCurrentViewer();
// Close the command (for undo)
myOcafDoc->CommitCommand();
myResult << std::endl;
myResult << "New cylinder parameters: " << std::endl;
myResult << "radius: " << aCylRadius << " height: " << aCylHeight << std::endl;
myResult << "base coord X: " << aCylX << " Y: " << aCylY << " Z: " << aCylZ << std::endl;
}
}
if (aCylCount)
{
myResult << "Number of modified boxes: " << aCylCount << std::endl;
}
else
{
myResult << "No boxes to modify" << std::endl;
}
}
void OcafSamples::UndoOcafSample()
{
if (myOcafDoc->Undo())
{
myOcafDoc->CommitCommand();
myContext->UpdateCurrentViewer();
myResult << "Undo was done successfully" << std::endl;
}
else
{
myResult << "Nothing to undo" << std::endl;
}
}
void OcafSamples::RedoOcafSample()
{
if (myOcafDoc->Redo())
{
myOcafDoc->CommitCommand();
myContext->UpdateCurrentViewer();
myResult << "Redo was done successfully" << std::endl;
}
else
{
myResult << "Nothing to redo" << std::endl;
}
}
void OcafSamples::DialogOpenOcafSample()
{
Handle(TOcaf_Application) anOcaf_Application = new TOcaf_Application;
// load persistence
BinDrivers::DefineFormat(anOcaf_Application);
XmlDrivers::DefineFormat(anOcaf_Application);
// Look for already opened
if (anOcaf_Application->IsInSession(myFileName))
{
myResult << "Document: " << myFileName << " is already in session" << std::endl;
return;
}
// Open the document in the current application
PCDM_ReaderStatus aReaderStatus = anOcaf_Application->Open(myFileName, myOcafDoc);
if (aReaderStatus == PCDM_RS_OK)
{
// Connect the document CAF (myDoc) with the AISContext (myAISContext)
TPrsStd_AISViewer::New(myOcafDoc->Main(), myViewer);
myOcafDoc->SetUndoLimit(10);
myContext->RemoveAll(Standard_False);
Handle(AIS_InteractiveContext) aContext;
TPrsStd_AISViewer::Find(myOcafDoc->Main(), aContext);
aContext->SetDisplayMode(AIS_Shaded, Standard_True);
myContext = aContext;
// Display the presentations (which was not stored in the document)
DisplayPresentation();
myResult << "Open a document" << std::endl;
}
else
{
myResult << "Error! The file wasn't opened. PCDM_ReaderStatus: " << aReaderStatus << std::endl;
}
}
void OcafSamples::DialogSaveBinOcafSample()
{
Handle(TOcaf_Application) anOcaf_Application = new TOcaf_Application;
BinDrivers::DefineFormat(anOcaf_Application);
myOcafDoc->ChangeStorageFormat("BinOcaf");
// Saves the document in the current application
PCDM_StoreStatus aStoreStatus = anOcaf_Application->SaveAs(myOcafDoc, myFileName);
if (aStoreStatus == PCDM_SS_OK)
{
myResult << "The file was saved successfully" << std::endl;
}
else
{
myResult << "Error! The file wasn't saved. PCDM_StoreStatus: " << aStoreStatus << std::endl;
}
}
void OcafSamples::DialogSaveXmlOcafSample()
{
Handle(TOcaf_Application) anOcaf_Application = new TOcaf_Application;
XmlDrivers::DefineFormat(anOcaf_Application);
myOcafDoc->ChangeStorageFormat("XmlOcaf");
// Saves the document in the current application
PCDM_StoreStatus aStoreStatus = anOcaf_Application->SaveAs(myOcafDoc, myFileName);
if (aStoreStatus == PCDM_SS_OK)
{
myResult << "The file was saved successfully" << std::endl;
}
else
{
myResult << "Error! The file wasn't saved. PCDM_StoreStatus: " << aStoreStatus << std::endl;
}
}
void OcafSamples::DisplayPresentation()
{
TDF_Label aRootlabel = myOcafDoc->Main();
for (TDF_ChildIterator it(aRootlabel); it.More(); it.Next())
{
TDF_Label aLabel = it.Value();
Handle(TNaming_NamedShape) aNamedShape;
if (!aLabel.FindAttribute(TNaming_NamedShape::GetID(), aNamedShape))
{
continue;
}
Handle(TDataStd_Integer) aDataInteger;
// To know if the object was displayed
if (aLabel.FindAttribute(TDataStd_Integer::GetID(), aDataInteger))
{
if (!aDataInteger->Get())
{
continue;
}
}
Handle(TPrsStd_AISPresentation) anAisPresentation;
if (!aLabel.FindAttribute(TPrsStd_AISPresentation::GetID(), anAisPresentation))
{
anAisPresentation = TPrsStd_AISPresentation::Set(aLabel, TNaming_NamedShape::GetID());
}
anAisPresentation->SetColor(Quantity_NOC_ORANGE);
anAisPresentation->Display(1);
}
myContext->UpdateCurrentViewer();
}

View File

@@ -0,0 +1,81 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef OCAFSAMPLES_H
#define OCAFSAMPLES_H
#include "BaseSample.h"
#include "TOcaf_Application.h"
#include <AIS_InteractiveContext.hxx>
#include <V3d_Viewer.hxx>
#include <TDocStd_Document.hxx>
//! Implements OCAF samples
class OcafSamples : public BaseSample
{
DEFINE_STANDARD_RTTI_INLINE(OcafSamples, BaseSample)
public:
OcafSamples (const TCollection_AsciiString& theSampleSourcePath,
const Handle(V3d_Viewer)& theViewer,
const Handle(AIS_InteractiveContext)& theContext)
: BaseSample (theSampleSourcePath, theContext),
myViewer (theViewer)
{
//
}
virtual void Process (const TCollection_AsciiString& theSampleName) Standard_OVERRIDE;
void ClearExtra();
void SetFileName (const TCollection_AsciiString& theFileName) { myFileName = theFileName; };
static Standard_Boolean IsExportSample (const TCollection_AsciiString& theSampleName);
static Standard_Boolean IsImportSample (const TCollection_AsciiString& theSampleName);
static Standard_Boolean IsBinarySample (const TCollection_AsciiString& theSampleName);
static Standard_Boolean IsXmlSample (const TCollection_AsciiString& theSampleName);
protected:
virtual void ExecuteSample (const TCollection_AsciiString& theSampleName) Standard_OVERRIDE;
private:
// One function for every sample
void CreateOcafDocument();
void CreateBoxOcafSample();
void CreateCylinderOcafSample();
void ModifyBoxOcafSample();
void ModifyCylinderOcafSample();
void UndoOcafSample();
void RedoOcafSample();
void DialogOpenOcafSample();
void DialogSaveBinOcafSample();
void DialogSaveXmlOcafSample();
void DisplayPresentation();
private:
TCollection_AsciiString myFileName;
Handle(V3d_Viewer) myViewer;
Handle(TDocStd_Document) myOcafDoc;
};
#endif //OCAFSAMPLES_H

View File

@@ -0,0 +1,486 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "Sample2D_Face.h"
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve2d.hxx>
#include <GCPnts_QuasiUniformDeflection.hxx>
#include <GeomLib.hxx>
#include <Select3D_SensitiveGroup.hxx>
#include <Select3D_SensitiveCurve.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
Sample2D_Face::Sample2D_Face (const TopoDS_Shape& theFace)
: myFORWARDColor (Quantity_NOC_BLUE1),
myREVERSEDColor (Quantity_NOC_YELLOW),
myINTERNALColor (Quantity_NOC_RED1),
myEXTERNALColor (Quantity_NOC_MAGENTA1),
myWidthIndex (1),
myTypeIndex (1),
//
myshape (theFace),
myForwardNum (0),
myReversedNum (0),
myInternalNum (0),
myExternalNum (0),
//
myForwardBounds (0),
myReversedBounds (0),
myInternalBounds (0),
myExternalBounds (0)
{
SetAutoHilight(Standard_False);
FillData(Standard_True);
}
void Sample2D_Face::DrawMarker (const Handle(Geom2d_TrimmedCurve)& theCurve,
const Handle(Prs3d_Presentation)& thePresentation)
{
Standard_Real aCenterParam = (theCurve->FirstParameter() + theCurve->LastParameter()) / 2;
gp_Pnt2d p;
gp_Vec2d v;
theCurve->D1(aCenterParam, p, v);
if (v.Magnitude() > gp::Resolution())
{
gp_Vec aDir(v.X(), v.Y(), 0.);
gp_Pnt aPoint(p.X(), p.Y(), 0.);
aDir.Normalize();
aDir.Reverse();
gp_Dir aZ(0, 0, 1);
gp_Pnt aLeft (aPoint.Translated(aDir.Rotated(gp_Ax1(aPoint, aZ), M_PI / 6) * 5));
gp_Pnt aRight(aPoint.Translated(aDir.Rotated(gp_Ax1(aPoint, aZ), M_PI * 11 / 6) * 5));
Handle(Graphic3d_ArrayOfPolylines) anArrow = new Graphic3d_ArrayOfPolylines(3);
anArrow->AddVertex(aLeft);
anArrow->AddVertex(aPoint);
anArrow->AddVertex(aRight);
thePresentation->CurrentGroup()->AddPrimitiveArray(anArrow);
}
}
void Sample2D_Face::FillData(Standard_Boolean isSizesRecompute)
{
if (myshape.IsNull() || myshape.ShapeType() != TopAbs_FACE)
{
return;
}
Standard_Real f, l;
TopoDS_Face aFace = TopoDS::Face(myshape);
// count number of vertices and bounds in primitive arrays
if (isSizesRecompute)
{
mySeq_FORWARD.Clear();
mySeq_REVERSED.Clear();
mySeq_INTERNAL.Clear();
mySeq_EXTERNAL.Clear();
myshape.Orientation(TopAbs_FORWARD);
for (TopExp_Explorer anEdgeIter (myshape, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Current());
BRepAdaptor_Curve2d aCurveOnEdge (anEdge, aFace);
GCPnts_QuasiUniformDeflection anEdgeDistrib(aCurveOnEdge, 1.e-2);
if (!anEdgeDistrib.IsDone())
{
continue;
}
switch (anEdge.Orientation())
{
case TopAbs_FORWARD:
{
myForwardNum += anEdgeDistrib.NbPoints();
myForwardBounds++;
break;
}
case TopAbs_REVERSED:
{
myReversedNum += anEdgeDistrib.NbPoints();
myReversedBounds++;
break;
}
case TopAbs_INTERNAL:
{
myInternalNum += anEdgeDistrib.NbPoints();
myInternalBounds++;
break;
}
case TopAbs_EXTERNAL:
{
myExternalNum += anEdgeDistrib.NbPoints();
myExternalBounds++;
break;
}
}
}
}
myForwardArray = new Graphic3d_ArrayOfPolylines(myForwardNum, myForwardBounds);
myReversedArray = new Graphic3d_ArrayOfPolylines(myReversedNum, myReversedBounds);
myInternalArray = new Graphic3d_ArrayOfPolylines(myInternalNum, myInternalBounds);
myExternalArray = new Graphic3d_ArrayOfPolylines(myExternalNum, myExternalBounds);
// fill primitive arrays
for (TopExp_Explorer anEdgeIter (myshape, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Current());
const Handle(Geom2d_Curve) aCurve = BRep_Tool::CurveOnSurface (anEdge, aFace, f, l);
Handle(Geom2d_TrimmedCurve) aTrimmedCurve = new Geom2d_TrimmedCurve(aCurve, f, l);
if (!aTrimmedCurve.IsNull())
{
Handle(Geom_Curve) aCurve3d = GeomLib::To3d(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), aTrimmedCurve);
BRepAdaptor_Curve2d aCurveOnEdge (anEdge, aFace);
GCPnts_QuasiUniformDeflection anEdgeDistrib (aCurveOnEdge, 1.e-2);
if (!anEdgeDistrib.IsDone())
{
continue;
}
switch (anEdge.Orientation())
{
case TopAbs_FORWARD:
{
myForwardArray->AddBound(anEdgeDistrib.NbPoints());
for (Standard_Integer i = 1; i <= anEdgeDistrib.NbPoints(); ++i)
{
myForwardArray->AddVertex(anEdgeDistrib.Value(i));
}
if (isSizesRecompute)
{
mySeq_FORWARD.Append(aCurve3d);
}
break;
}
case TopAbs_REVERSED:
{
myReversedArray->AddBound(anEdgeDistrib.NbPoints());
for (Standard_Integer i = 1; i <= anEdgeDistrib.NbPoints(); ++i)
{
myReversedArray->AddVertex(anEdgeDistrib.Value(i));
}
if (isSizesRecompute)
{
mySeq_REVERSED.Append(aCurve3d);
}
break;
}
case TopAbs_INTERNAL:
{
myInternalArray->AddBound(anEdgeDistrib.NbPoints());
for (Standard_Integer i = 1; i <= anEdgeDistrib.NbPoints(); ++i)
{
myInternalArray->AddVertex(anEdgeDistrib.Value(i));
}
if (isSizesRecompute)
{
mySeq_INTERNAL.Append(aCurve3d);
}
break;
}
case TopAbs_EXTERNAL:
{
myExternalArray->AddBound(anEdgeDistrib.NbPoints());
for (Standard_Integer i = 1; i <= anEdgeDistrib.NbPoints(); ++i)
{
myExternalArray->AddVertex(anEdgeDistrib.Value(i));
}
if (isSizesRecompute)
{
mySeq_EXTERNAL.Append(aCurve3d);
}
break;
}
}
}
}
}
void Sample2D_Face::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
if (theMode != 0)
{
return;
}
thePresentation->Clear();
myDrawer->SetWireDraw(1);
if (myshape.IsNull() || myshape.ShapeType() != TopAbs_FACE)
{
return;
}
Handle(Graphic3d_AspectLine3d) aLineAspect_FORWARD = new Graphic3d_AspectLine3d(myFORWARDColor, Aspect_TOL_SOLID, 1);
Handle(Graphic3d_AspectLine3d) aLineAspect_REVERSED = new Graphic3d_AspectLine3d(myREVERSEDColor, Aspect_TOL_SOLID, 1);
Handle(Graphic3d_AspectLine3d) aLineAspect_INTERNAL = new Graphic3d_AspectLine3d(myINTERNALColor, Aspect_TOL_SOLID, 1);
Handle(Graphic3d_AspectLine3d) aLineAspect_EXTERNAL = new Graphic3d_AspectLine3d(myEXTERNALColor, Aspect_TOL_SOLID, 1);
Standard_Real f, l;
TopoDS_Face aFace = TopoDS::Face(myshape);
// estimating number of vertices in primitive arrays
for (TopExp_Explorer anEdgeIter (myshape, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeIter.Current());
const Handle(Geom2d_Curve) aCurve = BRep_Tool::CurveOnSurface (anEdge, aFace, f, l);
Handle(Geom2d_TrimmedCurve) aTrimmedCurve = new Geom2d_TrimmedCurve(aCurve, f, l);
// make a 3D curve from 2D trimmed curve to display it
Handle(Geom_Curve) aCurve3d = GeomLib::To3d(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), aTrimmedCurve);
// make distribution of points
BRepAdaptor_Curve2d aCurveOnEdge (anEdge, aFace);
GCPnts_QuasiUniformDeflection anEdgeDistrib(aCurveOnEdge, 1.e-2);
if (anEdgeDistrib.IsDone())
{
switch (anEdge.Orientation())
{
case TopAbs_FORWARD:
{
thePresentation->CurrentGroup()->SetPrimitivesAspect(aLineAspect_FORWARD);
DrawMarker(aTrimmedCurve, thePresentation);
break;
}
case TopAbs_REVERSED:
{
thePresentation->CurrentGroup()->SetPrimitivesAspect(aLineAspect_REVERSED);
DrawMarker(aTrimmedCurve, thePresentation);
break;
}
case TopAbs_INTERNAL:
{
thePresentation->CurrentGroup()->SetPrimitivesAspect(aLineAspect_INTERNAL);
DrawMarker(aTrimmedCurve, thePresentation);
mySeq_INTERNAL.Append(aCurve3d);
break;
}
case TopAbs_EXTERNAL:
{
thePresentation->CurrentGroup()->SetPrimitivesAspect(aLineAspect_EXTERNAL);
DrawMarker(aTrimmedCurve, thePresentation);
break;
}
}
}
}
// add all primitives to the presentation
thePresentation->CurrentGroup()->SetPrimitivesAspect(aLineAspect_FORWARD);
thePresentation->CurrentGroup()->AddPrimitiveArray(myForwardArray);
thePresentation->CurrentGroup()->SetPrimitivesAspect(aLineAspect_REVERSED);
thePresentation->CurrentGroup()->AddPrimitiveArray(myReversedArray);
thePresentation->CurrentGroup()->SetPrimitivesAspect(aLineAspect_INTERNAL);
thePresentation->CurrentGroup()->AddPrimitiveArray(myInternalArray);
thePresentation->CurrentGroup()->SetPrimitivesAspect(aLineAspect_EXTERNAL);
thePresentation->CurrentGroup()->AddPrimitiveArray(myExternalArray);
}
void Sample2D_Face::HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const SelectMgr_SequenceOfOwner& theOwners)
{
Handle(Prs3d_Presentation) aSelectionPrs = GetSelectPresentation (thePrsMgr);
Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(Quantity_NOC_ANTIQUEWHITE, Aspect_TOL_SOLID, 2);
if (HasPresentation())
{
aSelectionPrs->SetTransformPersistence(Presentation()->TransformPersistence());
}
const Standard_Integer aLength = theOwners.Length();
aSelectionPrs->Clear();
FillData();
Handle(Graphic3d_Group) aSelectGroup = aSelectionPrs->NewGroup();
for (Standard_Integer i = 1; i <= aLength; ++i)
{
Handle(SelectMgr_EntityOwner) anOwner = theOwners.Value(i);
// check priority of owner to add primitives in one of array
// containing primitives with certain type of orientation
switch (anOwner->Priority())
{
case 7:
{
// add to objects with forward orientation
aSelectGroup->SetGroupPrimitivesAspect(aLineAspect);
aSelectGroup->AddPrimitiveArray(myForwardArray);
break;
}
case 6:
{
// add to objects with reversed orientation
aSelectGroup->SetGroupPrimitivesAspect(aLineAspect);
aSelectGroup->AddPrimitiveArray(myReversedArray);
break;
}
case 5:
{
// add to objects with internal orientation
aSelectGroup->SetGroupPrimitivesAspect(aLineAspect);
aSelectGroup->AddPrimitiveArray(myInternalArray);
break;
}
case 4:
{
// add to objects with external orientation
aSelectGroup->SetGroupPrimitivesAspect(aLineAspect);
aSelectGroup->AddPrimitiveArray(myExternalArray);
break;
}
}
}
aSelectionPrs->Display();
}
void Sample2D_Face::ClearSelected()
{
if (Handle(Prs3d_Presentation) aSelectionPrs = GetSelectPresentation(NULL))
{
aSelectionPrs->Clear();
}
}
void Sample2D_Face::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner)
{
Handle(Prs3d_Presentation) aHighlightPrs = GetHilightPresentation(thePM);
if (HasPresentation())
{
aHighlightPrs->SetTransformPersistence(Presentation()->TransformPersistence());
}
if (theOwner.IsNull())
{
return;
}
aHighlightPrs->Clear();
FillData();
// Direct highlighting
aHighlightPrs->NewGroup();
Handle(Graphic3d_Group) aHilightGroup = aHighlightPrs->CurrentGroup();
Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theStyle->Color(), Aspect_TOL_SOLID, 2);
switch (theOwner->Priority())
{
case 7:
{
aHilightGroup->SetGroupPrimitivesAspect(aLineAspect);
aHilightGroup->AddPrimitiveArray(myForwardArray);
break;
}
case 6:
{
aHilightGroup->SetGroupPrimitivesAspect(aLineAspect);
aHilightGroup->AddPrimitiveArray(myReversedArray);
break;
}
case 5:
{
aHilightGroup->SetGroupPrimitivesAspect(aLineAspect);
aHilightGroup->AddPrimitiveArray(myInternalArray);
break;
}
case 4:
{
aHilightGroup->SetGroupPrimitivesAspect(aLineAspect);
aHilightGroup->AddPrimitiveArray(myExternalArray);
break;
}
}
if (thePM->IsImmediateModeOn())
{
thePM->AddToImmediateList(aHighlightPrs);
}
}
void Sample2D_Face::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode)
{
if (myshape.IsNull()
|| theMode != 0)
{
return;
}
if (mySeq_FORWARD.IsEmpty()
&& mySeq_REVERSED.IsEmpty()
&& mySeq_INTERNAL.IsEmpty()
&& mySeq_EXTERNAL.IsEmpty())
{
return;
}
// create entity owner for every part of the face
// set different priorities for primitives of different orientation
Handle(SelectMgr_EntityOwner) anOwner_Forward = new SelectMgr_EntityOwner(this, 7);
Handle(SelectMgr_EntityOwner) anOwner_Reversed = new SelectMgr_EntityOwner(this, 6);
Handle(SelectMgr_EntityOwner) anOwner_Internal = new SelectMgr_EntityOwner(this, 5);
Handle(SelectMgr_EntityOwner) anOwner_External = new SelectMgr_EntityOwner(this, 4);
// create a sensitive for every part
Handle(Select3D_SensitiveGroup) aForwardGroup = new Select3D_SensitiveGroup(anOwner_Forward);
Handle(Select3D_SensitiveGroup) aReversedGroup = new Select3D_SensitiveGroup(anOwner_Reversed);
Handle(Select3D_SensitiveGroup) aInternalGroup = new Select3D_SensitiveGroup(anOwner_Internal);
Handle(Select3D_SensitiveGroup) aExternalGroup = new Select3D_SensitiveGroup(anOwner_External);
Standard_Integer aLength = mySeq_FORWARD.Length();
for (Standard_Integer i = 1; i <= aLength; ++i)
{
Handle(Select3D_SensitiveCurve) aSensitveCurve = new Select3D_SensitiveCurve(anOwner_Forward, mySeq_FORWARD(i));
aForwardGroup->Add(aSensitveCurve);
}
theSelection->Add(aForwardGroup);
aLength = mySeq_REVERSED.Length();
for (Standard_Integer i = 1; i <= aLength; ++i)
{
Handle(Select3D_SensitiveCurve) aSensitveCurve = new Select3D_SensitiveCurve(anOwner_Reversed, mySeq_REVERSED(i));
aReversedGroup->Add(aSensitveCurve);
}
theSelection->Add(aReversedGroup);
aLength = mySeq_INTERNAL.Length();
for (Standard_Integer i = 1; i <= aLength; ++i)
{
Handle(Select3D_SensitiveCurve) aSensitveCurve = new Select3D_SensitiveCurve(anOwner_Internal, mySeq_INTERNAL(i));
aInternalGroup->Add(aSensitveCurve);
}
theSelection->Add(aInternalGroup);
aLength = mySeq_EXTERNAL.Length();
for (Standard_Integer i = 1; i <= aLength; ++i)
{
Handle(Select3D_SensitiveCurve) aSensitveCurve = new Select3D_SensitiveCurve(anOwner_External, mySeq_EXTERNAL(i));
aExternalGroup->Add(aSensitveCurve);
}
theSelection->Add(aExternalGroup);
}

View File

@@ -0,0 +1,107 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef _Sample2D_Face_HeaderFile
#define _Sample2D_Face_HeaderFile
#include <AIS_InteractiveObject.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
#include <TopoDS_Face.hxx>
#include <TColGeom_SequenceOfCurve.hxx>
//! AIS interactive Object for sample 2D face
class Sample2D_Face : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTI_INLINE(Sample2D_Face, AIS_InteractiveObject)
public:
Standard_EXPORT Sample2D_Face (const TopoDS_Shape& theFace);
public:
TopoDS_Shape& Shape() { return myshape; }
void SetFace (const TopoDS_Shape& theFace) { myshape = theFace; }
public:
Quantity_Color myFORWARDColor;
Quantity_Color myREVERSEDColor;
Quantity_Color myINTERNALColor;
Quantity_Color myEXTERNALColor;
Standard_Integer myWidthIndex;
Standard_Integer myTypeIndex;
private:
//! Return TRUE for supported display modes (only mode 0 is supported).
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
//! Compute presentation.
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection.
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode) Standard_OVERRIDE;
virtual void ClearSelected() Standard_OVERRIDE;
//! Method for advanced customizable selection of picked object
virtual void HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
const SelectMgr_SequenceOfOwner& theOwners) Standard_OVERRIDE;
//! Method for advanced customizable highlighting of picked object.
virtual void HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
const Handle(Prs3d_Drawer)& theStyle,
const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
void DrawMarker (const Handle(Geom2d_TrimmedCurve)& theCurve,
const Handle(Prs3d_Presentation)& thePresentation);
void FillData(Standard_Boolean isSizesRecomputed = Standard_False);
private:
TopoDS_Shape myshape;
TColGeom_SequenceOfCurve mySeq_FORWARD;
TColGeom_SequenceOfCurve mySeq_REVERSED;
TColGeom_SequenceOfCurve mySeq_INTERNAL;
TColGeom_SequenceOfCurve mySeq_EXTERNAL;
Handle(Graphic3d_ArrayOfPolylines) myForwardArray;
Handle(Graphic3d_ArrayOfPolylines) myReversedArray;
Handle(Graphic3d_ArrayOfPolylines) myInternalArray;
Handle(Graphic3d_ArrayOfPolylines) myExternalArray;
Standard_Integer myForwardNum;
Standard_Integer myReversedNum;
Standard_Integer myInternalNum;
Standard_Integer myExternalNum;
Standard_Integer myForwardBounds;
Standard_Integer myReversedBounds;
Standard_Integer myInternalBounds;
Standard_Integer myExternalBounds;
};
#endif

View File

@@ -0,0 +1,88 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "Sample2D_Image.h"
#include <AIS_InteractiveContext.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_Texture1D.hxx>
#include <Graphic3d_Texture1Dsegment.hxx>
#include <Graphic3d_Texture2Dmanual.hxx>
#include <Image_AlienPixMap.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
Sample2D_Image::Sample2D_Image (const TCollection_AsciiString& theFileName,
const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theScale)
: AIS_Shape (TopoDS_Shape()),
myFilename (theFileName),
myX (theX),
myY (theY),
myScale (theScale)
{
//
}
void Sample2D_Image::MakeShape()
{
Standard_Real coeff = 1.0;
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
if (anImage->Load (myFilename))
{
coeff = Standard_Real(anImage->Height()) / Standard_Real(anImage->Width()) * myScale;
}
TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge (gp_Pnt(myX, myY, 0.),
gp_Pnt(100 * myScale + myX, myY, 0.));
TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge (gp_Pnt(100 * myScale + myX, myY, 0.),
gp_Pnt(100 * myScale + myX, 100 * coeff + myY, 0.));
TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge (gp_Pnt(100 * myScale + myX, 100 * coeff + myY, 0.),
gp_Pnt(myX, 100 * coeff + myY, 0.));
TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge (gp_Pnt(myX, 100 * coeff + myY, 0.),
gp_Pnt(myX, myY, 0.));
TopoDS_Wire anImageBounds = BRepBuilderAPI_MakeWire(E1, E2, E3, E4);
myFace = BRepBuilderAPI_MakeFace(gp_Pln(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), anImageBounds);
}
void Sample2D_Image::SetContext (const Handle(AIS_InteractiveContext)& theContext)
{
if (theContext.IsNull() || theContext->CurrentViewer().IsNull())
{
AIS_InteractiveObject::SetContext (theContext);
return;
}
AIS_InteractiveObject::SetContext (theContext);
MakeShape();
this->Set(TopoDS_Shape(myFace));
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual(myFilename);
aTexture->DisableModulate();
myDrawer->ShadingAspect()->Aspect()->SetTextureMap (aTexture);
myDrawer->ShadingAspect()->Aspect()->SetTextureMapOn();
}

View File

@@ -0,0 +1,86 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef _Sample2D_Image_HeaderFile
#define _Sample2D_Image_HeaderFile
#include <Standard_Macro.hxx>
#include <Standard_DefineHandle.hxx>
#include <OSD_File.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_CString.hxx>
#include <Standard_Integer.hxx>
#include <SelectMgr_Selection.hxx>
#include <Standard_OStream.hxx>
#include <Standard_IStream.hxx>
#include <AIS_Shape.hxx>
#include <TopoDS_Face.hxx>
//! AIS shape for sample 2D image
class Sample2D_Image : public AIS_Shape
{
DEFINE_STANDARD_RTTI_INLINE(Sample2D_Image, AIS_Shape)
public:
//! Constructor.
Standard_EXPORT Sample2D_Image (const TCollection_AsciiString& theFileName,
const Standard_Real theX = 0.0,
const Standard_Real theY = 0.0,
const Standard_Real theScale = 1.0);
//! Return image coordinates.
void GetCoord (Standard_Real& theX, Standard_Real& theY) const
{
theX = myX;
theY = myY;
}
//! Return image coordinates.
void SetCoord (const Standard_Real theX, const Standard_Real theY)
{
myX = theX;
myY = theY;
}
//! Return image scale factor.
Standard_Real GetScale() const { return myScale; }
//! Set image scale factor.
void SetScale(const Standard_Real theNewScale) { myScale = theNewScale; }
//! Assign new interactive context to the object.
Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& theContext) Standard_OVERRIDE;
private:
void MakeShape();
protected:
TopoDS_Face myFace;
TCollection_AsciiString myFilename;
Standard_Real myX;
Standard_Real myY;
Standard_Real myScale;
};
#endif

View File

@@ -0,0 +1,80 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "Sample2D_Markers.h"
#include <Aspect_TypeOfMarker.hxx>
// generic marker
Sample2D_Markers::Sample2D_Markers (const Standard_Real theXPosition,
const Standard_Real theYPosition,
const Aspect_TypeOfMarker theMarkerType,
const Quantity_Color theColor,
const Standard_Real theScaleOrId)
: myArrayOfPoints (new Graphic3d_ArrayOfPoints(1))
{
myXPosition = theXPosition;
myYPosition = theYPosition;
myMarkerType = theMarkerType;
myColor = theColor;
myIndex = theScaleOrId;
}
Sample2D_Markers::Sample2D_Markers (const Standard_Real theXPosition,
const Standard_Real theYPosition,
const Handle(Graphic3d_ArrayOfPoints)& theArrayOfPoints,
const Aspect_TypeOfMarker theMarkerType,
const Quantity_Color theColor,
const Standard_Real theScaleOrId)
: myArrayOfPoints (new Graphic3d_ArrayOfPoints(6))
{
myXPosition = theXPosition;
myYPosition = theYPosition;
myMarkerType = theMarkerType;
myColor = theColor;
myIndex = theScaleOrId;
myArrayOfPoints = theArrayOfPoints;
}
void Sample2D_Markers::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
const Handle(Prs3d_Presentation)& thePrs,
const Standard_Integer theMode)
{
if (theMode != 0)
{
return;
}
if (myMarkerType == Aspect_TOM_USERDEFINED)
{
Handle(Graphic3d_AspectMarker3d) aMarker = new Graphic3d_AspectMarker3d(Aspect_TOM_POINT, myColor, myIndex);
thePrs->CurrentGroup()->SetGroupPrimitivesAspect(aMarker);
thePrs->CurrentGroup()->AddPrimitiveArray(myArrayOfPoints);
}
else
{
Handle(Graphic3d_AspectMarker3d) aMarker = new Graphic3d_AspectMarker3d(myMarkerType, myColor, myIndex);
thePrs->CurrentGroup()->SetPrimitivesAspect(aMarker);
Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints(1);
anArrayOfPoints->AddVertex(myXPosition, myYPosition, 0);
thePrs->CurrentGroup()->AddPrimitiveArray(anArrayOfPoints);
}
}

View File

@@ -0,0 +1,88 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef _Sample2D_Markers_HeaderFile
#define _Sample2D_Markers_HeaderFile
#include <AIS_InteractiveObject.hxx>
#include <Graphic3d_ArrayOfPoints.hxx>
//! AIS AIS interactive object for sample 2D marker
class Sample2D_Markers : public AIS_InteractiveObject
{
DEFINE_STANDARD_RTTI_INLINE(Sample2D_Markers, AIS_InteractiveObject)
private:
enum Sample2D_CurrentTypeOfMarker
{
Sample2D_CTOM_Generic,
Sample2D_CTOM_Polyline,
Sample2D_CTOM_Circle,
Sample2D_CTOM_Ellips
};
public:
//! Generic marker
Standard_EXPORT Sample2D_Markers (const Standard_Real theXPosition,
const Standard_Real theYPosition,
const Aspect_TypeOfMarker theMarkerType,
const Quantity_Color theColor,
const Standard_Real theScaleOrId=5.0);
//! Polyline marker
Standard_EXPORT Sample2D_Markers (const Standard_Real theXPosition,
const Standard_Real theYPosition,
const Handle(Graphic3d_ArrayOfPoints)& theArrayOfPoints,
const Aspect_TypeOfMarker theMarkerType,
const Quantity_Color theColor,
const Standard_Real theScaleOrId=2.0);
private:
//! Return TRUE for supported display modes (only mode 0 is supported).
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
//! Compute presentation.
virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& /*aPresentation*/,
const Standard_Integer theMode) Standard_OVERRIDE;
//! Compute selection (not implemented).
virtual void ComputeSelection (const Handle(SelectMgr_Selection)& ,
const Standard_Integer ) Standard_OVERRIDE {}
virtual void SetContext(const Handle(AIS_InteractiveContext)& ) Standard_OVERRIDE {}
private:
Sample2D_CurrentTypeOfMarker myCurrentTypeOfMarker;
Standard_Real myXPosition;
Standard_Real myYPosition;
Aspect_TypeOfMarker myMarkerType;
Quantity_Color myColor;
Standard_Real myWidth;
Standard_Real myHeight;
Standard_Real myIndex;
//! specific polyline marker
Handle(Graphic3d_ArrayOfPoints) myArrayOfPoints;
};
#endif

View File

@@ -0,0 +1,11 @@
<RCC>
<qresource prefix="/menus">
<file>Geometry.xml</file>
<file>Topology.xml</file>
<file>Triangulation.xml</file>
<file>DataExchange.xml</file>
<file>Viewer3d.xml</file>
<file>Viewer2d.xml</file>
<file>Ocaf.xml</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,148 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "TOcafFunction_BoxDriver.h"
#include <BRepPrimAPI_MakeBox.hxx>
#include <Standard_GUID.hxx>
#include <TDataStd_Real.hxx>
#include <TNaming_Builder.hxx>
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TOcafFunction_BoxDriver::GetID()
{
static const Standard_GUID anID("22D22E51-D69A-11d4-8F1A-0060B0EE18E8");
return anID;
}
//=======================================================================
//function : Validate
//purpose :
//=======================================================================
void TOcafFunction_BoxDriver::Validate(Handle(TFunction_Logbook)& log) const
{
// We validate the object label ( Label() ), all the arguments and the results of the object:
log->SetValid(Label(), Standard_True);
}
//=======================================================================
//function : MustExecute
//purpose :
//=======================================================================
Standard_Boolean TOcafFunction_BoxDriver::MustExecute(const Handle(TFunction_Logbook)& log) const
{
// If the object's label is modified:
if (log->IsModified(Label())) return Standard_True;
// Cut (in our simple case) has two arguments: The original shape, and the tool shape.
// They are on the child labels of the box's label:
// So, OriginalNShape - is attached to the first child label
// ToolNShape - is attached to the second child label.
//
// Let's check them:
if (log->IsModified(Label().FindChild(1)))
{
return Standard_True; // width.
}
if (log->IsModified(Label().FindChild(2)))
{
return Standard_True; // length,
}
if (log->IsModified(Label().FindChild(3)))
{
return Standard_True; // width.
}
if (log->IsModified(Label().FindChild(4)))
{
return Standard_True; // length,
}
if (log->IsModified(Label().FindChild(5)))
{
return Standard_True; // width.
}
if (log->IsModified(Label().FindChild(6)))
{
return Standard_True; // length,
}
// if there are no any modifications concerned the box,
// it's not necessary to recompute (to call the method Execute()):
return Standard_False;
}
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer TOcafFunction_BoxDriver::Execute(Handle(TFunction_Logbook)& /*log*/) const
{
// Get the values of dimension and position attributes
Handle(TDataStd_Real) TSR;
Standard_Real x, y, z, l, h, w;
if (!Label().FindChild(1).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
l = TSR->Get();
if (!Label().FindChild(2).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
h = TSR->Get();
if (!Label().FindChild(3).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
w = TSR->Get();
if (!Label().FindChild(4).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
x = TSR->Get();
if (!Label().FindChild(5).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
y = TSR->Get();
if (!Label().FindChild(6).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
z = TSR->Get();
// Build a box using the dimension and position attributes
BRepPrimAPI_MakeBox mkBox(gp_Pnt(x, y, z), l, h, w);
TopoDS_Shape ResultShape = mkBox.Shape();
// Build a TNaming_NamedShape using built box
TNaming_Builder B(Label());
B.Generated(ResultShape);
// That's all:
// If there are no any mistakes we return 0:
return 0;
}

View File

@@ -0,0 +1,57 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef _TOcafFunction_BoxDriver_HeaderFile
#define _TOcafFunction_BoxDriver_HeaderFile
#include <TFunction_Driver.hxx>
#include <TFunction_Logbook.hxx>
//! Creation of an instance of the box driver. It's possible (and recommended)
//! to have only one instance of a driver for the whole session.
class TOcafFunction_BoxDriver : public TFunction_Driver
{
DEFINE_STANDARD_RTTI_INLINE(TOcafFunction_BoxDriver, TFunction_Driver)
public:
Standard_EXPORT static const Standard_GUID& GetID();
public:
TOcafFunction_BoxDriver() {}
//! Validation of the object label, its arguments and its results.
Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE;
//! We call this method to check if the object was modified to be invoked.
//! If the object label or an argument is modified, we must recompute the object - to call the method Execute().
Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE;
//! We compute the object and topologically name it.
//! If during the execution we found something wrong, we return the number of the failure.
//! For example:
//! 1 - an attribute hasn't been found,
//! 2 - algorithm failed,
//! if there are no any mistakes occurred we return 0:
//! 0 - no mistakes were found.
Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE;
};
#endif

View File

@@ -0,0 +1,152 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "TOcafFunction_CutDriver.h"
#include <TNaming_NamedShape.hxx>
#include <TNaming_Builder.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <Standard_GUID.hxx>
#include <TCollection_AsciiString.hxx>
#include <TDF_Tool.hxx>
#include <TDF_Reference.hxx>
#include <TFunction_Logbook.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QMessageBox>
#include <QApplication>
#include <QObject>
#include <Standard_WarningsRestore.hxx>
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TOcafFunction_CutDriver::GetID()
{
static const Standard_GUID anID("22D22E52-D69A-11d4-8F1A-0060B0EE18E8");
return anID;
}
//=======================================================================
//function : Validate
//purpose :
//=======================================================================
void TOcafFunction_CutDriver::Validate (Handle(TFunction_Logbook)& log) const
{
// We validate the object label ( Label() ), all the arguments and the results of the object:
log->SetValid(Label(), Standard_True);
}
//=======================================================================
//function : MustExecute
//purpose :
//=======================================================================
Standard_Boolean TOcafFunction_CutDriver::MustExecute(const Handle(TFunction_Logbook)& log) const
{
// If the object's label is modified:
if (log->IsModified(Label())) return Standard_True;
// Cut (in our simple case) has two arguments: The original shape, and the tool shape.
// They are on the child labels of the cut's label:
// So, OriginalNShape - is attached to the first child label
// ToolNShape - is attached to the second child label,
// .
// Let's check them:
Handle(TDF_Reference) OriginalRef;
//TDF_Label aLabel = Label().FindChild(1);
/*
BOOL f = Label().IsNull();
int a = Label().NbChildren();
*/
TCollection_AsciiString aEntry;
TDF_Tool::Entry(Label(), aEntry);
std::cout << "Entry: " << aEntry.ToCString() << std::endl;
Label().FindChild(1).FindAttribute(TDF_Reference::GetID(), OriginalRef);
if (log->IsModified(OriginalRef->Get())) return Standard_True; // Original shape.
Handle(TDF_Reference) ToolRef;
Label().FindChild(2).FindAttribute(TDF_Reference::GetID(), ToolRef);
if (log->IsModified(ToolRef->Get())) return Standard_True; // Tool shape.
// if there are no any modifications concerned the cut,
// it's not necessary to recompute (to call the method Execute()):
return Standard_False;
}
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer TOcafFunction_CutDriver::Execute(Handle(TFunction_Logbook)& /*log*/) const
{
// Let's get the arguments (OriginalNShape, ToolNShape of the object):
// First, we have to retrieve the TDF_Reference attributes to obtain
// the root labels of the OriginalNShape and the ToolNShape:
Handle(TDF_Reference) OriginalRef, ToolRef;
if (!Label().FindChild(1).FindAttribute(TDF_Reference::GetID(), OriginalRef))
{
return 1;
}
TDF_Label OriginalLab = OriginalRef->Get();
if (!Label().FindChild(2).FindAttribute(TDF_Reference::GetID(), ToolRef))
{
return 1;
}
TDF_Label ToolLab = ToolRef->Get();
// Get the TNaming_NamedShape attributes of these labels
Handle(TNaming_NamedShape) OriginalNShape, ToolNShape;
if (!(OriginalLab.FindAttribute(TNaming_NamedShape::GetID(), OriginalNShape)))
{
throw Standard_Failure("TOcaf_Commands::CutObjects");
}
if (!(ToolLab.FindAttribute(TNaming_NamedShape::GetID(), ToolNShape)))
{
throw Standard_Failure("TOcaf_Commands::CutObjects");
}
// Now, let's get the TopoDS_Shape of these TNaming_NamedShape:
TopoDS_Shape OriginalShape = OriginalNShape->Get();
TopoDS_Shape ToolShape = ToolNShape->Get();
// STEP 2:
// Let's call for algorithm computing a cut operation:
BRepAlgoAPI_Cut mkCut(OriginalShape, ToolShape);
// Let's check if the Cut has been successful:
if (!mkCut.IsDone())
{
QMessageBox::critical(qApp->activeWindow(),
QObject::tr("Cut Function Driver"),
QObject::tr("Cut not done."));
return 2;
}
TopoDS_Shape ResultShape = mkCut.Shape();
// Build a TNaming_NamedShape using built cut
TNaming_Builder B(Label());
B.Modify(OriginalShape, ResultShape);
// That's all:
// If there are no any mistakes we return 0:
return 0;
}

View File

@@ -0,0 +1,57 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef _TOcafFunction_CutDriver_HeaderFile
#define _TOcafFunction_CutDriver_HeaderFile
#include <TFunction_Driver.hxx>
#include <TFunction_Logbook.hxx>
//! Creation of an instance of the cut driver. It's possible (and recommended)
//! to have only one instance of a driver for the whole session.
class TOcafFunction_CutDriver : public TFunction_Driver
{
DEFINE_STANDARD_RTTI_INLINE(TOcafFunction_CutDriver, TFunction_Driver)
public:
Standard_EXPORT static const Standard_GUID& GetID();
public:
TOcafFunction_CutDriver() {}
//! Validation of the object label, its arguments and its results.
Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE;
//! We call this method to check if the object was modified to be invoked.
//! If the object label or an argument is modified, we must recompute the object - to call the method Execute().
Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE;
//! We compute the object and topologically name it.
//! If during the execution we found something wrong, we return the number of the failure.
//! For example:
//! 1 - an attribute hasn't been found,
//! 2 - algorithm failed,
//! if there are no any mistakes occurred we return 0:
//! 0 - no mistakes were found.
Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE;
};
#endif

View File

@@ -0,0 +1,147 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "TOcafFunction_CylDriver.h"
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <Standard_GUID.hxx>
#include <TCollection_AsciiString.hxx>
#include <TDF_Tool.hxx>
#include <TDataStd_Real.hxx>
#include <TNaming_Builder.hxx>
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TOcafFunction_CylDriver::GetID()
{
static const Standard_GUID anID("22D22E53-D69A-11d4-8F1A-0060B0EE18E8");
return anID;
}
//=======================================================================
//function : TPartStd_CylDriver
//purpose :
//=======================================================================
TOcafFunction_CylDriver::TOcafFunction_CylDriver()
{
//
}
//=======================================================================
//function : Validate
//purpose :
//=======================================================================
void TOcafFunction_CylDriver::Validate (Handle(TFunction_Logbook)& log) const
{
// We validate the object label ( Label() ), all the arguments and the results of the object:
log->SetValid(Label(), Standard_True);
}
//=======================================================================
//function : MustExecute
//purpose :
//=======================================================================
Standard_Boolean TOcafFunction_CylDriver::MustExecute(const Handle(TFunction_Logbook)& log) const
{
// If the object's label is modified:
if (log->IsModified(Label())) return Standard_True;
// Cylinder (in our simple case) has 5 arguments:
//
// Let's check them:
if (log->IsModified(Label().FindChild(1)))
{
return Standard_True; // radius.
}
if (log->IsModified(Label().FindChild(2)))
{
return Standard_True; // height,
}
if (log->IsModified(Label().FindChild(3)))
{
return Standard_True; // x.
}
if (log->IsModified(Label().FindChild(4)))
{
return Standard_True; // y,
}
if (log->IsModified(Label().FindChild(5)))
{
return Standard_True; // z.
}
// if there are no any modifications concerned the Cyl,
// it's not necessary to recompute (to call the method Execute()):
return Standard_False;
}
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer TOcafFunction_CylDriver::Execute(Handle(TFunction_Logbook)& /*log*/) const
{
// Get the values of dimension and position attributes
Handle(TDataStd_Real) TSR;
Standard_Real x, y, z, r, h;
if (!Label().FindChild(1).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
r = TSR->Get();
if (!Label().FindChild(2).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
h = TSR->Get();
if (!Label().FindChild(3).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
x = TSR->Get();
if (!Label().FindChild(4).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
y = TSR->Get();
if (!Label().FindChild(5).FindAttribute(TDataStd_Real::GetID(), TSR))
{
return 1;
}
z = TSR->Get();
// Build a Cyl using the dimension and position attributes
BRepPrimAPI_MakeCylinder mkCyl(gp_Ax2(gp_Pnt(x, y, z), gp_Dir(0, 0, 1)), r, h);
TopoDS_Shape ResultShape = mkCyl.Shape();
// Build a TNaming_NamedShape using built Cyl
TNaming_Builder B(Label());
B.Generated(ResultShape);
// That's all:
// If there are no any mistakes we return 0:
return 0;
}

View File

@@ -0,0 +1,59 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef _TOcafFunction_CylDriver_HeaderFile
#define _TOcafFunction_CylDriver_HeaderFile
#include <TFunction_Driver.hxx>
#include <TFunction_Logbook.hxx>
//! Creation of an instance of the cylinder driver. It's possible (and recommended)
//! to have only one instance of a driver for the whole session.
class TOcafFunction_CylDriver : public TFunction_Driver
{
DEFINE_STANDARD_RTTI_INLINE(TOcafFunction_CylDriver, TFunction_Driver)
public:
Standard_EXPORT static const Standard_GUID& GetID();
public:
//! Creation of an instance of the driver. It's possible (and recommended)
//! to have only one instance of a driver for the whole session.
Standard_EXPORT TOcafFunction_CylDriver();
//! Validation of the object label, its arguments and its results.
Standard_EXPORT virtual void Validate (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE;
//! We call this method to check if the object was modified to be invoked.
//! If the object label or an argument is modified, we must recompute the object - to call the method Execute().
Standard_EXPORT virtual Standard_Boolean MustExecute (const Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE;
//! We compute the object and topologically name it.
//! If during the execution we found something wrong,
//! we return the number of the failure. For example:
//! 1 - an attribute hasn't been found,
//! 2 - algorithm failed,
//! if there are no any mistakes occurred we return 0:
//! 0 - no mistakes were found.
Standard_EXPORT virtual Standard_Integer Execute (Handle(TFunction_Logbook)& theLog) const Standard_OVERRIDE;
};
#endif

View File

@@ -0,0 +1,52 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "TOcaf_Application.h"
#include <TDF_Label.hxx>
#include <TFunction_DriverTable.hxx>
#include <TNaming_NamedShape.hxx>
#include <TPrsStd_AISPresentation.hxx>
#include <TPrsStd_AISViewer.hxx>
#include "TOcafFunction_BoxDriver.h"
#include "TOcafFunction_CylDriver.h"
#include "TOcafFunction_CutDriver.h"
//=======================================================================
//function : TOcaf_Application
//purpose :
//=======================================================================
TOcaf_Application::TOcaf_Application()
{
// Instantiate a TOcafFunction_BoxDriver and add it to the TFunction_DriverTable
TFunction_DriverTable::Get()->AddDriver (TOcafFunction_BoxDriver::GetID(),
new TOcafFunction_BoxDriver());
// Instantiate a TOcafFunction_Cyl Driver and add it to the TFunction_DriverTable
TFunction_DriverTable::Get()->AddDriver (TOcafFunction_CylDriver::GetID(),
new TOcafFunction_CylDriver());
// Instantiate a TOcafFunction_CutDriver and add it to the TFunction_DriverTable
Handle(TOcafFunction_CutDriver) myCutDriver = new TOcafFunction_CutDriver();
TFunction_DriverTable::Get()->AddDriver (TOcafFunction_CutDriver::GetID(),
new TOcafFunction_CutDriver());
}

View File

@@ -0,0 +1,37 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef _TOcaf_Application_HeaderFile
#define _TOcaf_Application_HeaderFile
#include <TColStd_SequenceOfExtendedString.hxx>
#include <TDocStd_Application.hxx>
//! Sample OCAF application
class TOcaf_Application : public TDocStd_Application
{
DEFINE_STANDARD_RTTI_INLINE(TOcaf_Application, TDocStd_Application)
public:
Standard_EXPORT TOcaf_Application();
};
#endif

View File

@@ -0,0 +1,51 @@
<Menu>
<MenuItem name="Topology">
<MenuItem name="Topological Shape">
<Sample name="Vertex" function="Vertex3dSample"/>
<Sample name="Edge" function="Edge3dSample"/>
<Sample name="Face" function="Face3dSample"/>
<Sample name="Wire" function="Wire3dSample"/>
<Sample name="Shell" function="Shell3dSample"/>
<Sample name="Solid" function="Solid3dSample"/>
<Sample name="Edge (2D)" function="Edge2dSample"/>
</MenuItem>
<MenuItem name="BRep primitive objects">
<Sample name="Box" function="Box3dSample"/>
<Sample name="Cylinder" function="Cylinder3dSample"/>
<Sample name="Revolution" function="Revolution3dSample"/>
</MenuItem>
<MenuItem name="Topology access">
<Sample name="Topology iterator" function="TopologyIterator3dSample"/>
<Sample name="Topology explorer" function="TopologyExplorer3dSample"/>
<Sample name="Assess to curve" function="AssessToCurve3dSample"/>
<Sample name="Assess to composite curve" function="AssessToCompositeCurve3dSample"/>
<Sample name="Assess to surface" function="AssessToSurface3dSample"/>
</MenuItem>
<MenuItem name="Boolean operation">
<Sample name="Common" function="Common3dSample"/>
<Sample name="Cut" function="Cut3dSample"/>
<Sample name="Fuse" function="Fuse3dSample"/>
<Sample name="Section" function="Section3dSample"/>
<Sample name="Splitter" function="Splitter3dSample"/>
<Sample name="Defeaturing" function="Defeaturing3dSample"/>
</MenuItem>
<MenuItem name="Complex modelling">
<Sample name="Fillet" function="Fillet3dSample"/>
<Sample name="Chamfer" function="Chamfer3dSample"/>
<Sample name="Offset" function="Offset3dSample"/>
<Sample name="Evolved" function="Evolved3dSample"/>
</MenuItem>
<MenuItem name="Modification">
<Sample name="Copy" function="Copy3dSample"/>
<Sample name="Transform" function="Transform3dSample"/>
<Sample name="Convert to NURBS" function="ConvertToNurbs3dSample"/>
<Sample name="Sew contiguous faces" function="SewContiguousFaces3dSample"/>
</MenuItem>
<MenuItem name="Calculation">
<Sample name="Check validity" function="CheckValidity3dSample"/>
<Sample name="Compute linear properties" function="ComputeLinearProperties3dSample"/>
<Sample name="Compute surface properties" function="ComputeSurfaceProperties3dSample"/>
<Sample name="Compute volume properties" function="ComputeVolumeProperties3dSample"/>
</MenuItem>
</MenuItem>
</Menu>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,80 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef TOPOLOGYSAMPLES_H
#define TOPOLOGYSAMPLES_H
#include "BaseSample.h"
#include <AIS_InteractiveContext.hxx>
//! Implements Topology samples
class TopologySamples : public BaseSample
{
DEFINE_STANDARD_RTTI_INLINE(TopologySamples, BaseSample)
public:
TopologySamples (const TCollection_AsciiString& theSampleSourcePath,
const Handle(AIS_InteractiveContext)& theContext)
: BaseSample(theSampleSourcePath, theContext)
{}
protected:
virtual void ExecuteSample (const TCollection_AsciiString& theSampleName) Standard_OVERRIDE;
private:
// One function for every sample
void Vertex3dSample();
void Edge3dSample();
void Face3dSample();
void Wire3dSample();
void Shell3dSample();
void Solid3dSample();
void Edge2dSample();
void Box3dSample();
void Cylinder3dSample();
void Revolution3dSample();
void TopologyIterator3dSample();
void TopologyExplorer3dSample();
void AssessToCurve3dSample();
void AssessToCompositeCurve3dSample();
void AssessToSurface3dSample();
void Common3dSample();
void Cut3dSample();
void Fuse3dSample();
void Section3dSample();
void Splitter3dSample();
void Defeaturing3dSample();
void Fillet3dSample();
void Chamfer3dSample();
void Offset3dSample();
void Evolved3dSample();
void Copy3dSample();
void Transform3dSample();
void ConvertToNurbs3dSample();
void SewContiguousFaces3dSample();
void CheckValidity3dSample();
void ComputeLinearProperties3dSample();
void ComputeSurfaceProperties3dSample();
void ComputeVolumeProperties3dSample();
};
#endif //TOPOLOGYSAMPLES_H

View File

@@ -0,0 +1,7 @@
<Menu>
<MenuItem name="Triangulation">
<MenuItem name="Create Triangulation">
<Sample name="Triangulation on shape" function="Triangulation3dSample"/>
</MenuItem>
</MenuItem>
</Menu>

View File

@@ -0,0 +1,118 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "TriangulationSamples.h"
#include "MakeBottle.h"
#include <AIS_Shape.hxx>
#include <AIS_Triangulation.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <Poly_Triangulation.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
void TriangulationSamples::ExecuteSample (const TCollection_AsciiString& theSampleName)
{
Standard_Boolean anIsSamplePresent = Standard_True;
FindSourceCode(theSampleName);
if (theSampleName == "Triangulation3dSample")
{
Triangulation3dSample();
}
else
{
myResult << "No function found: " << theSampleName;
myCode += TCollection_AsciiString("No function found: ") + theSampleName;
anIsSamplePresent = Standard_False;
}
myIsProcessed = anIsSamplePresent;
}
void TriangulationSamples::Triangulation3dSample()
{
TopoDS_Shape aBottle = MakeBottle(50, 70, 30);
BRepMesh_IncrementalMesh(aBottle, 1);
BRep_Builder aBuilder;
TopoDS_Compound aCompound;
aBuilder.MakeCompound(aCompound);
Standard_Integer aNbTriangles(0);
for (TopExp_Explorer anExplorer(aBottle, TopAbs_FACE); anExplorer.More(); anExplorer.Next())
{
TopoDS_Face aFace = TopoDS::Face(anExplorer.Current());
TopLoc_Location aLocation;
Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation(aFace, aLocation);
TColgp_Array1OfPnt aTriangNodes(1, (aTriangulation->NbNodes()));
aTriangNodes = aTriangulation->Nodes();
Poly_Array1OfTriangle aTriangles(1, aTriangulation->NbTriangles());
aTriangles = aTriangulation->Triangles();
for (Standard_Integer i = 1; i <= (aTriangulation->NbTriangles()); i++)
{
Poly_Triangle trian = aTriangles.Value(i);
Standard_Integer index1, index2, index3, M = 0, N = 0;
trian.Get(index1, index2, index3);
for (Standard_Integer j = 1; j <= 3; j++)
{
switch (j)
{
case 1:
M = index1;
N = index2;
break;
case 2:
N = index3;
break;
case 3:
M = index2;
}
BRepBuilderAPI_MakeEdge anEdgeMaker(aTriangNodes.Value(M), aTriangNodes.Value(N));
if (anEdgeMaker.IsDone())
{
aBuilder.Add(aCompound, anEdgeMaker.Edge());
}
}
}
Handle(AIS_Triangulation) anAisTriangulation = new AIS_Triangulation(aTriangulation);
aNbTriangles += aTriangulation->NbTriangles();
myObject3d.Append(anAisTriangulation);
}
Handle(AIS_Shape) anAisCompound = new AIS_Shape(aCompound);
myObject3d.Append(anAisCompound);
Handle(AIS_Shape) AISBottle = new AIS_Shape(aBottle);
myObject3d.Append(AISBottle);
myResult << "Compute the triangulation on a shape: " << aNbTriangles;
}

View File

@@ -0,0 +1,49 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef TRIANGULATIONSAMPLES_H
#define TRIANGULATIONSAMPLES_H
#include "BaseSample.h"
//! Implements Triangulation sample
class TriangulationSamples : public BaseSample
{
DEFINE_STANDARD_RTTI_INLINE(TriangulationSamples, BaseSample)
public:
TriangulationSamples (const TCollection_AsciiString& theSampleSourcePath,
const Handle(AIS_InteractiveContext)& theContext)
: BaseSample (theSampleSourcePath, theContext)
{
//
}
protected:
virtual void ExecuteSample (const TCollection_AsciiString& theSampleName) Standard_OVERRIDE;
private:
// One function for every sample
void Triangulation3dSample();
};
#endif //TRIANGULATIONSAMPLES_H

View File

@@ -0,0 +1,20 @@
<Menu>
<MenuItem name="Viewer 2D">
<MenuItem name="Labels">
<Sample name="Text" function="TextView2dSample"/>
<Sample name="Marker" function="MarkerView2dSample"/>
<Sample name="Fill Area" function="FillAreaView2dSample"/>
<Sample name="Loop on face" function="LoopOnFaceView2dSample"/>
</MenuItem>
<MenuItem name="Grids">
<Sample name="Rectagular Lines" function="RectagularLineGrid2dSample"/>
<Sample name="Rectagular Points" function="RectagularPointGrid2dSample"/>
<Sample name="Circular Lines" function="CircularLineGrid2dSample"/>
<Sample name="Circular Points" function="CircularPointGrid2dSample"/>
<Sample name="Clear" function="ClearGrid2dSample"/>
</MenuItem>
<MenuItem name="Image">
<Sample name="Backgroung Image" function="BackgroungImage2dSample"/>
</MenuItem>
</MenuItem>
</Menu>

View File

@@ -0,0 +1,282 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "Viewer2dSamples.h"
#include "Sample2D_Markers.h"
#include "Sample2D_Face.h"
#include "Sample2D_Image.h"
#include <AIS_ColoredShape.hxx>
#include <AIS_TextLabel.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
#include <Quantity_NameOfColor.hxx>
void Viewer2dSamples::ExecuteSample (const TCollection_AsciiString& theSampleName)
{
Standard_Boolean anIsSamplePresent = Standard_True;
FindSourceCode(theSampleName);
if (theSampleName == "TextView2dSample")
TextView2dSample();
else if (theSampleName == "MarkerView2dSample")
MarkerView2dSample();
else if (theSampleName == "FillAreaView2dSample")
FillAreaView2dSample();
else if (theSampleName == "LoopOnFaceView2dSample")
LoopOnFaceView2dSample();
else if (theSampleName == "RectagularLineGrid2dSample")
RectagularLineGrid2dSample();
else if (theSampleName == "RectagularPointGrid2dSample")
RectagularPointGrid2dSample();
else if (theSampleName == "CircularLineGrid2dSample")
CircularLineGrid2dSample();
else if (theSampleName == "CircularPointGrid2dSample")
CircularPointGrid2dSample();
else if (theSampleName == "ClearGrid2dSample")
ClearGrid2dSample();
else if (theSampleName == "BackgroungImage2dSample")
BackgroungImage2dSample();
else {
myResult << "No function found: " << theSampleName;
myCode += TCollection_AsciiString("No function found: ") + theSampleName;
anIsSamplePresent = Standard_False;
}
myIsProcessed = anIsSamplePresent;
}
void Viewer2dSamples::ClearExtra()
{
myContext->RemoveAll(Standard_True);
myViewer->DeactivateGrid();
}
void Viewer2dSamples::TextView2dSample()
{
Standard_Integer aColor = Quantity_NOC_MATRABLUE;
for (Standard_Integer j = 15; j <= 20; j++)
{
Handle(AIS_TextLabel) aText = new AIS_TextLabel();
aText->SetText(TCollection_AsciiString("font 0 scale ") + (j / 20.0));
aText->SetPosition(gp_Pnt(0.0, 15.0 * (j - 15.0), 0.0));
aText->SetAngle(30.0 * M_PI / 180.0);
aText->SetColor(Quantity_NameOfColor(aColor++));
aText->SetFontAspect(Font_FA_Regular);
aText->SetFont("Courier");
aText->SetHeight(j);
aText->SetHJustification(Graphic3d_HTA_LEFT);
aText->SetVJustification(Graphic3d_VTA_BOTTOM);
aText->SetZoomable(Standard_False);
myObject2d.Append(aText);
}
for (Standard_Real j = 10; j <= 15; j++)
{
Handle(AIS_TextLabel) aText = new AIS_TextLabel();
aText->SetText(TCollection_AsciiString("font 1 scale ") + (j / 10.0));
aText->SetPosition(gp_Pnt(80.0, 15.0 * (j - 10.0), 0.0));
aText->SetAngle(0.0);
aText->SetColor(Quantity_NameOfColor(aColor++));
aText->SetFontAspect(Font_FA_BoldItalic);
aText->SetFont("Cambria");
aText->SetHeight(j * 2);
aText->SetHJustification(Graphic3d_HTA_LEFT);
aText->SetVJustification(Graphic3d_VTA_BOTTOM);
aText->SetZoomable(Standard_False);
myObject2d.Append(aText);
}
aColor = Quantity_NOC_MATRABLUE;
for (Standard_Real j = 5; j <= 10; j++)
{
Handle(AIS_TextLabel) aText = new AIS_TextLabel();
aText->SetText(TCollection_AsciiString("font 2 scale ") + (j / 10.0));
aText->SetPosition(gp_Pnt(140.0, 15.0 * (j - 5.0), 0.0));
aText->SetAngle(0.0);
aText->SetColor(Quantity_NameOfColor(aColor++));
aText->SetFontAspect(Font_FA_Bold);
aText->SetFont("Arial");
aText->SetHeight(j * 2);
aText->SetHJustification(Graphic3d_HTA_LEFT);
aText->SetVJustification(Graphic3d_VTA_BOTTOM);
aText->SetZoomable(Standard_False);
myObject2d.Append(aText);
}
for (Standard_Real j = 10; j <= 15; j++)
{
Handle(AIS_TextLabel) aText = new AIS_TextLabel();
aText->SetText(TCollection_AsciiString("font 3 scale ") + (j / 10.0));
aText->SetPosition(gp_Pnt(200.0, 15.0 * (j - 10.0), 0.0));
aText->SetAngle(0.0);
aText->SetColor(Quantity_NameOfColor(aColor++));
aText->SetFontAspect(Font_FA_Italic);
aText->SetFont("Georgia");
aText->SetHeight(j * 2);
aText->SetHJustification(Graphic3d_HTA_LEFT);
aText->SetVJustification(Graphic3d_VTA_BOTTOM);
aText->SetZoomable(Standard_False);
myObject2d.Append(aText);
}
}
void Viewer2dSamples::MarkerView2dSample()
{
// generic Markers
Standard_Integer aColor = 20;
for (int i = 1; i <= 2; i++)
{
Handle(Sample2D_Markers) aMarker = new Sample2D_Markers(10 + 5, 5 * i, Aspect_TOM_POINT, Quantity_NOC_YELLOW, 2.0);
myObject2d.Append(aMarker);
}
for (int i = 1; i <= 2; i++)
{
Handle(Sample2D_Markers) aMarker = new Sample2D_Markers(10 + 10, 5 * i, Aspect_TOM_O, (Quantity_NameOfColor)(aColor++));
myObject2d.Append(aMarker);
}
for (int i = 1; i <= 2; i++)
{
Handle(Sample2D_Markers) aMarker = new Sample2D_Markers(10 + 15, 5 * i, Aspect_TOM_O_PLUS, (Quantity_NameOfColor)(aColor++));
myObject2d.Append(aMarker);
}
for (int i = 1; i <= 2; i++)
{
Handle(Sample2D_Markers) aMarker = new Sample2D_Markers(10 + 20, 5 * i, Aspect_TOM_RING1, (Quantity_NameOfColor)(aColor++));
myObject2d.Append(aMarker);
}
for (int i = 1; i <= 2; i++)
{
Handle(Sample2D_Markers) aMarker = new Sample2D_Markers(10 + 25, 5 * i, Aspect_TOM_STAR, (Quantity_NameOfColor)(aColor++));
myObject2d.Append(aMarker);
}
for (int i = 1; i <= 2; i++)
{
Handle(Sample2D_Markers) aMarker = new Sample2D_Markers(10 + 30, 5 * i, Aspect_TOM_O_X, (Quantity_NameOfColor)(aColor++));
myObject2d.Append(aMarker);
}
}
void Viewer2dSamples::FillAreaView2dSample()
{
for (int i = 0; i <= 13; ++i)
{
for (int j = 0; j <= 5; ++j)
{
// set of rectangles here
TopoDS_Edge E1 = BRepBuilderAPI_MakeEdge(gp_Pnt(10 * i, 10 * j, 0.), gp_Pnt(10 * i + 7, 10 * j, 0.));
TopoDS_Edge E2 = BRepBuilderAPI_MakeEdge(gp_Pnt(10 * i + 7, 10 * j, 0.), gp_Pnt(10 * i + 7, 10 * j + 5, 0.));
TopoDS_Edge E3 = BRepBuilderAPI_MakeEdge(gp_Pnt(10 * i + 7, 10 * j + 5, 0.), gp_Pnt(10 * i, 10 * j + 5, 0.));
TopoDS_Edge E4 = BRepBuilderAPI_MakeEdge(gp_Pnt(10 * i, 10 * j + 5, 0.), gp_Pnt(10 * i, 10 * j, 0.));
TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1, E2, E3, E4);
TopoDS_Face F = BRepBuilderAPI_MakeFace(W);
Handle(AIS_Shape) aRect = new AIS_Shape(F);
// set attributes of boundaries
Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer();
Handle(Prs3d_LineAspect) aLineAttrib = new Prs3d_LineAspect (Quantity_NOC_YELLOW,
(Aspect_TypeOfLine)(Aspect_TOL_SOLID + j), 1);
aDrawer->SetFaceBoundaryAspect(aLineAttrib);
aDrawer->SetFaceBoundaryDraw(Standard_True);
aRect->SetAttributes(aDrawer);
myContext->SetDisplayMode(aRect, 1, Standard_False);
myContext->SetColor(aRect, (Quantity_NameOfColor)(Quantity_NOC_CADETBLUE + 2 * i), Standard_False);
myContext->SetMaterial(aRect, Graphic3d_NOM_PLASTIC, Standard_False);
myObject2d.Append(aRect);
}
}
}
void Viewer2dSamples::LoopOnFaceView2dSample()
{
// Make a flat rectangular face on XY plane.
gp_Pln aPln(gp::XOY());
TopoDS_Face aFaceRect = BRepBuilderAPI_MakeFace(aPln, -10.0, +10.0, -20.0, +20.0);
Handle(AIS_ColoredShape) anAisFaceRect = new AIS_ColoredShape(aFaceRect);
anAisFaceRect->SetColor(Quantity_Color(Quantity_NOC_RED));
myObject2d.Append(anAisFaceRect);
TopoDS_Shape aFaceShape;
Handle(Sample2D_Face) anAISFace = new Sample2D_Face(aFaceRect);
myObject2d.Append(anAISFace);
}
void Viewer2dSamples::RectagularLineGrid2dSample()
{
Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_RING1, Quantity_NOC_WHITE, 2);
myViewer->SetGridEcho(aGridAspect);
Standard_Integer aWidth = 0, aHeight = 0, anOffset = 0;
myView->Window()->Size(aWidth, aHeight);
myViewer->SetRectangularGridGraphicValues(aWidth, aHeight, anOffset);
myViewer->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Lines);
myViewer->Redraw();
}
void Viewer2dSamples::RectagularPointGrid2dSample()
{
Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_RING1, Quantity_NOC_WHITE, 2);
myViewer->SetGridEcho(aGridAspect);
Standard_Integer aWidth = 0, aHeight = 0, anOffset = 0;
myView->Window()->Size(aWidth, aHeight);
myViewer->SetRectangularGridGraphicValues(aWidth, aHeight, anOffset);
myViewer->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Points);
myViewer->Redraw();
}
void Viewer2dSamples::CircularLineGrid2dSample()
{
Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_RING1, Quantity_NOC_WHITE, 2);
myViewer->SetGridEcho(aGridAspect);
Standard_Integer aWidth = 0, aHeight = 0, anOffset = 0;
myView->Window()->Size(aWidth, aHeight);
myViewer->SetRectangularGridGraphicValues(aWidth, aHeight, anOffset);
myViewer->ActivateGrid(Aspect_GT_Circular, Aspect_GDM_Lines);
myViewer->Redraw();
}
void Viewer2dSamples::CircularPointGrid2dSample()
{
Handle(Graphic3d_AspectMarker3d) aGridAspect = new Graphic3d_AspectMarker3d(Aspect_TOM_RING1, Quantity_NOC_WHITE, 2);
myViewer->SetGridEcho(aGridAspect);
Standard_Integer aWidth = 0, aHeight = 0, anOffset = 0;
myView->Window()->Size(aWidth, aHeight);
myViewer->SetRectangularGridGraphicValues(aWidth, aHeight, anOffset);
myViewer->ActivateGrid(Aspect_GT_Circular, Aspect_GDM_Points);
myViewer->Redraw();
}
void Viewer2dSamples::ClearGrid2dSample()
{
myViewer->DeactivateGrid();
myViewer->Redraw();
}
void Viewer2dSamples::BackgroungImage2dSample()
{
Handle(Sample2D_Image) anImage = new Sample2D_Image(myFileName);
anImage->SetCoord(40, 50);
anImage->SetScale(1.0);
myObject2d.Append(anImage);
}

View File

@@ -0,0 +1,76 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef VIEWER2DSAMPLES_H
#define VIEWER2DSAMPLES_H
#include "BaseSample.h"
#include <AIS_InteractiveContext.hxx>
#include <V3d_View.hxx>
//! Implements viewer 2D samples.
class Viewer2dSamples : public BaseSample
{
DEFINE_STANDARD_RTTI_INLINE(Viewer2dSamples, BaseSample)
public:
Viewer2dSamples(const TCollection_AsciiString& theSampleSourcePath,
const Handle(V3d_View)& theView,
const Handle(V3d_Viewer)& theViewer,
const Handle(AIS_InteractiveContext)& theContext)
: BaseSample (theSampleSourcePath, theContext),
myView (theView),
myViewer (theViewer)
{}
void SetFileName (const TCollection_AsciiString& theFileName) { myFileName = theFileName; }
void ClearExtra();
static Standard_Boolean IsFileSample (const TCollection_AsciiString& theSampleName) { return theSampleName == "BackgroungImage2dSample"; }
static Standard_Boolean IsShadedSample(const TCollection_AsciiString& theSampleName) { return theSampleName == "BackgroungImage2dSample"; }
protected:
virtual void ExecuteSample (const TCollection_AsciiString& theSampleName) Standard_OVERRIDE;
private:
// One function for every sample
void TextView2dSample();
void MarkerView2dSample();
void FillAreaView2dSample();
void LoopOnFaceView2dSample();
void RectagularLineGrid2dSample();
void RectagularPointGrid2dSample();
void CircularLineGrid2dSample();
void CircularPointGrid2dSample();
void ClearGrid2dSample();
void BackgroungImage2dSample();
private:
TCollection_AsciiString myFileName;
Handle(V3d_View) myView;
Handle(V3d_Viewer) myViewer;
};
#endif // VIEWER2DSAMPLES_H

View File

@@ -0,0 +1,31 @@
<Menu>
<MenuItem name="Viewer 3D">
<MenuItem name="Light source">
<Sample name="Spot" function="SpotLight3dSample"/>
<Sample name="Positional" function="PositionalLight3dSample"/>
<Sample name="Directional" function="DirectionalLight3dSample"/>
<Sample name="Ambient" function="AmbientLight3dSample"/>
<Sample name="Clear" function="ClearLight3dSample"/>
</MenuItem>
<MenuItem name="Selection mode">
<Sample name="Vertices" function="VerticesSelect3dSample"/>
<Sample name="Edges" function="EdgesSelect3dSample"/>
<Sample name="Faces" function="FacesSelect3dSample"/>
<Sample name="Neutral point" function="NeutralPointSelect3dSample"/>
</MenuItem>
<MenuItem name="Shape presentation">
<Sample name="WireFrame" function="WireFramePresentation3dSample"/>
<Sample name="Shading" function="ShadingPresentation3dSample"/>
<Sample name="Set color to red" function="RedColorPresentation3dSample"/>
<Sample name="Set color to gray" function="GrayColorPresentation3dSample"/>
<Sample name="Set plastic material" function="PlasticPresentation3dSample"/>
<Sample name="Set bronze material" function="BronzePresentation3dSample"/>
<Sample name="Set opaque" function="OpaquePresentation3dSample"/>
<Sample name="Set half transparency" function="HalfTransparencyPresentation3dSample"/>
</MenuItem>
<MenuItem name="OpenGL VBO mode">
<Sample name="Vertex Buffer Object mode ON" function="VboOn3dSample"/>
<Sample name="Vertex Buffer Object mode OFF" function="VboOff3dSample"/>
</MenuItem>
</MenuItem>
</Menu>

View File

@@ -0,0 +1,342 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#include "Viewer3dSamples.h"
#include "MakeBottle.h"
#include <AIS_Shape.hxx>
#include <AIS_ViewCube.hxx>
#include <OpenGl_GraphicDriver.hxx>
#include <V3d_SpotLight.hxx>
#include <V3d_PositionalLight.hxx>
#include <V3d_DirectionalLight.hxx>
#include <V3d_AmbientLight.hxx>
void Viewer3dSamples::ExecuteSample (const TCollection_AsciiString& theSampleName)
{
Standard_Boolean anIsSamplePresent = Standard_True;
FindSourceCode(theSampleName);
if (theSampleName == "SpotLight3dSample")
SpotLight3dSample();
else if (theSampleName == "PositionalLight3dSample")
PositionalLight3dSample();
else if (theSampleName == "DirectionalLight3dSample")
DirectionalLight3dSample();
else if (theSampleName == "AmbientLight3dSample")
AmbientLight3dSample();
else if (theSampleName == "ClearLight3dSample")
ClearLight3dSample();
else if (theSampleName == "VerticesSelect3dSample")
VerticesSelect3dSample();
else if (theSampleName == "EdgesSelect3dSample")
EdgesSelect3dSample();
else if (theSampleName == "FacesSelect3dSample")
FacesSelect3dSample();
else if (theSampleName == "NeutralPointSelect3dSample")
NeutralPointSelect3dSample();
else if (theSampleName == "WireFramePresentation3dSample")
WireFramePresentation3dSample();
else if (theSampleName == "ShadingPresentation3dSample")
ShadingPresentation3dSample();
else if (theSampleName == "RedColorPresentation3dSample")
RedColorPresentation3dSample();
else if (theSampleName == "GrayColorPresentation3dSample")
GrayColorPresentation3dSample();
else if (theSampleName == "PlasticPresentation3dSample")
PlasticPresentation3dSample();
else if (theSampleName == "BronzePresentation3dSample")
BronzePresentation3dSample();
else if (theSampleName == "OpaquePresentation3dSample")
OpaquePresentation3dSample();
else if (theSampleName == "HalfTransparencyPresentation3dSample")
HalfTransparencyPresentation3dSample();
else if (theSampleName == "VboOn3dSample")
VboOn3dSample();
else if (theSampleName == "VboOff3dSample")
VboOff3dSample();
else
{
myResult << "No function found: " << theSampleName;
myCode += TCollection_AsciiString("No function found: ") + theSampleName;
anIsSamplePresent = Standard_False;
}
myIsProcessed = anIsSamplePresent;
}
void Viewer3dSamples::AppendBottle()
{
TopoDS_Shape aBottle = MakeBottle(50, 70, 30);
Handle(AIS_InteractiveObject) aShape = new AIS_Shape(aBottle);
myObject3d.Append(aShape);
Handle(AIS_ViewCube) aViewCube = new AIS_ViewCube();
myObject3d.Append(aViewCube);
myResult << "A bottle shape was created." << std::endl;
}
void Viewer3dSamples::ClearExtra()
{
NeutralPointSelect3dSample();
VboOff3dSample();
ClearLight3dSample();
// Delete Lights
V3d_ListOfLight aLights;
for(V3d_ListOfLightIterator anIter = myView->Viewer()->DefinedLightIterator();
anIter.More(); anIter.Next())
{
aLights.Append(anIter.Value());
}
for(V3d_ListOfLightIterator aLightIter (aLights);
aLightIter.More(); aLightIter.Next())
{
myView->Viewer()->DelLight (aLightIter.Value());
}
myView->Viewer()->SetDefaultLights(); // Setting the default lights on
myView->Update();
myContext->RemoveAll (Standard_True);
}
void Viewer3dSamples::SpotLight3dSample()
{
// Spot light source creation
Handle(V3d_SpotLight) aSpotLight =
new V3d_SpotLight(gp_Pnt(100.0, 0.0, 0.0), gp_Dir(-1.0, 0.0, 0.0), Quantity_NOC_RED);
aSpotLight->SetIntensity(5000);
myView->SetLightOn(aSpotLight);
}
void Viewer3dSamples::PositionalLight3dSample()
{
Handle(V3d_PositionalLight) aPositionalLight =
new V3d_PositionalLight(gp_Pnt(0.0, -100.0, 5.0), Quantity_NOC_GREEN);
aPositionalLight->SetAttenuation(1, 0);
myView->SetLightOn(aPositionalLight);
}
void Viewer3dSamples::DirectionalLight3dSample()
{
Handle(V3d_DirectionalLight) aDirectionalLight =
new V3d_DirectionalLight(gp_Dir(-1.0, 0.0, -1.0), Quantity_NOC_BLUE1);
myView->SetLightOn(aDirectionalLight);
}
void Viewer3dSamples::AmbientLight3dSample()
{
Handle(V3d_AmbientLight) aAmbientLight =
new V3d_AmbientLight(Quantity_NOC_MAGENTA1);
myView->SetLightOn(aAmbientLight);
}
void Viewer3dSamples::ClearLight3dSample()
{
// Setting Off all viewer active lights
V3d_ListOfLight aLights;
for(V3d_ListOfLightIterator anIter = myView->Viewer()->ActiveLightIterator();
anIter.More(); anIter.Next())
{
aLights.Append(anIter.Value());
}
for(V3d_ListOfLightIterator aLightIter(aLights);
aLightIter.More(); aLightIter.Next())
{
myView->Viewer()->SetLightOff (aLightIter.Value());
}
// Setting Off all view active lights
aLights.Clear();
for(V3d_ListOfLightIterator anIter = myView->ActiveLightIterator();
anIter.More(); anIter.Next())
{
aLights.Append(anIter.Value());
}
for(V3d_ListOfLightIterator aLightIter (aLights);
aLightIter.More(); aLightIter.Next())
{
myView->SetLightOff (aLightIter.Value());
}
myView->Viewer()->SetDefaultLights(); // Setting the default lights on
myView->Update();
}
void Viewer3dSamples::VerticesSelect3dSample()
{
myContext->Deactivate();
myContext->Activate(AIS_Shape::SelectionMode(TopAbs_VERTEX));
}
void Viewer3dSamples::EdgesSelect3dSample()
{
myContext->Deactivate();
myContext->Activate(AIS_Shape::SelectionMode(TopAbs_EDGE));
}
void Viewer3dSamples::FacesSelect3dSample()
{
myContext->Deactivate();
myContext->Activate(AIS_Shape::SelectionMode(TopAbs_FACE));
}
void Viewer3dSamples::NeutralPointSelect3dSample()
{
myContext->Deactivate();
myContext->Activate(0);
}
void Viewer3dSamples::WireFramePresentation3dSample()
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
for(AIS_ListOfInteractive::Iterator anIter(anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
myContext->SetDisplayMode(anAisObject, 0, false); // set wireframe
}
myContext->UpdateCurrentViewer();
}
void Viewer3dSamples::ShadingPresentation3dSample()
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
for(AIS_ListOfInteractive::Iterator anIter(anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
myContext->SetDisplayMode(anAisObject, 1, false); // set shading
}
myContext->UpdateCurrentViewer();
}
void Viewer3dSamples::RedColorPresentation3dSample()
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
for(AIS_ListOfInteractive::Iterator anIter(anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
Quantity_Color aShapeColor;
myContext->Color(anAisObject, aShapeColor);
myResult << "A Current shape color: Red = " << aShapeColor.Red()
<< " Green = " << aShapeColor.Green() << " Blue = " << aShapeColor.Blue() << std::endl;
aShapeColor.SetValues(0.8, 0.1, 0.1, Quantity_TOC_RGB);
myContext->SetColor(anAisObject, aShapeColor, Standard_False);
myResult << "A New shape color: Red = " << aShapeColor.Red()
<< " Green = " << aShapeColor.Green() << " Blue = " << aShapeColor.Blue() << std::endl;
}
}
void Viewer3dSamples::GrayColorPresentation3dSample()
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
for(AIS_ListOfInteractive::Iterator anIter(anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
Quantity_Color aShapeColor;
myContext->Color(anAisObject, aShapeColor);
myResult << "A Current shape color: Hue = " << aShapeColor.Hue()
<< " Light = " << aShapeColor.Light()
<< " Saturation = " << aShapeColor.Saturation() << std::endl;
aShapeColor.SetValues(0.0, 0.3, 0.1, Quantity_TOC_HLS);
myContext->SetColor(anAisObject, aShapeColor, Standard_False);
myResult << "A New shape color: Hue = " << aShapeColor.Hue()
<< " Light = " << aShapeColor.Light()
<< " Saturation = " << aShapeColor.Saturation() << std::endl;
}
}
void Viewer3dSamples::PlasticPresentation3dSample()
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
Graphic3d_NameOfMaterial aMaterial = Graphic3d_NOM_PLASTIC;
for(AIS_ListOfInteractive::Iterator anIter (anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
myContext->SetMaterial(anAisObject, aMaterial, Standard_False);
}
myContext->UpdateCurrentViewer();
}
void Viewer3dSamples::BronzePresentation3dSample()
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
Graphic3d_NameOfMaterial aMaterial = Graphic3d_NOM_BRONZE;
for(AIS_ListOfInteractive::Iterator anIter (anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
myContext->SetMaterial(anAisObject, aMaterial, Standard_False);
}
myContext->UpdateCurrentViewer();
}
void Viewer3dSamples::OpaquePresentation3dSample()
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
for(AIS_ListOfInteractive::Iterator anIter (anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
myContext->SetTransparency(anAisObject, 0.0, Standard_False);
}
myContext->UpdateCurrentViewer();
}
void Viewer3dSamples::HalfTransparencyPresentation3dSample()
{
AIS_ListOfInteractive anAisObjectsList;
myContext->DisplayedObjects(anAisObjectsList);
for(AIS_ListOfInteractive::Iterator anIter (anAisObjectsList);
anIter.More(); anIter.Next())
{
const Handle(AIS_InteractiveObject)& anAisObject = anIter.Value();
myContext->SetTransparency(anAisObject, 0.5, Standard_False);
}
myContext->UpdateCurrentViewer();
}
void Viewer3dSamples::VboOn3dSample()
{
if(Handle(OpenGl_GraphicDriver) aDriver =
Handle(OpenGl_GraphicDriver)::DownCast(myContext->CurrentViewer()->Driver()))
{
aDriver->ChangeOptions().vboDisable = Standard_False;
}
}
void Viewer3dSamples::VboOff3dSample()
{
if(Handle(OpenGl_GraphicDriver) aDriver =
Handle(OpenGl_GraphicDriver)::DownCast(myContext->CurrentViewer()->Driver()))
{
aDriver->ChangeOptions().vboDisable = Standard_True;
}
}

View File

@@ -0,0 +1,78 @@
// Copyright (c) 2020 OPEN CASCADE SAS
//
// This file is part of the examples of the Open CASCADE Technology software library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
#ifndef VIEWER3DSAMPLES_H
#define VIEWER3DSAMPLES_H
#include "BaseSample.h"
#include <AIS_InteractiveContext.hxx>
#include <V3d_View.hxx>
//! Implements viewer 3D samples.
class Viewer3dSamples : public BaseSample
{
DEFINE_STANDARD_RTTI_INLINE(Viewer3dSamples, BaseSample)
public:
Viewer3dSamples (const TCollection_AsciiString& theSampleSourcePath,
const Handle(V3d_View)& theView,
const Handle(AIS_InteractiveContext)& theContext)
: BaseSample (theSampleSourcePath, theContext),
myView (theView)
{}
void AppendBottle();
void ClearExtra();
protected:
virtual void ExecuteSample (const TCollection_AsciiString& theSampleName) Standard_OVERRIDE;
private:
// One function for every sample
void SpotLight3dSample();
void PositionalLight3dSample();
void DirectionalLight3dSample();
void AmbientLight3dSample();
void ClearLight3dSample();
void VerticesSelect3dSample();
void EdgesSelect3dSample();
void FacesSelect3dSample();
void NeutralPointSelect3dSample();
void WireFramePresentation3dSample();
void ShadingPresentation3dSample();
void RedColorPresentation3dSample();
void GrayColorPresentation3dSample();
void PlasticPresentation3dSample();
void BronzePresentation3dSample();
void OpaquePresentation3dSample();
void HalfTransparencyPresentation3dSample();
void VboOn3dSample();
void VboOff3dSample();
private:
Handle(V3d_View) myView;
};
#endif //VIEWER3DSAMPLES_H

View File

@@ -316,7 +316,7 @@ void OcctViewer::displayWithChildren (XCAFDoc_ShapeTool& theShapeToo
Handle(AIS_InteractiveObject) anAis;
if (!theMapOfShapes.Find (aRefLabel, anAis))
{
anAis = new CafShapePrs (aRefLabel, theParentStyle, Graphic3d_NOM_SHINY_PLASTIC);
anAis = new CafShapePrs (aRefLabel, theParentStyle, Graphic3d_NameOfMaterial_ShinyPlastified);
theMapOfShapes.Bind (aRefLabel, anAis);
}

View File

@@ -1532,7 +1532,7 @@ Handle(AIS_InteractiveObject) CGeometryDoc::drawSurface
Handle(AIS_Shape) aGraphicSurface =
new AIS_Shape(BRepBuilderAPI_MakeFace (theSurface, u1, u2, v1, v2, Precision::Confusion()));
myAISContext->SetMaterial(aGraphicSurface, Graphic3d_NOM_PLASTIC, toDisplay);
myAISContext->SetMaterial(aGraphicSurface, Graphic3d_NameOfMaterial_Plastified, toDisplay);
myAISContext->SetColor(aGraphicSurface, theColor, toDisplay);
if (toDisplay)
{

View File

@@ -76,7 +76,7 @@ public:
// 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 Graphic3d_NameOfMaterial theMaterial = Graphic3d_NameOfMaterial_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)

View File

@@ -114,7 +114,7 @@ protected:
// 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 Graphic3d_NameOfMaterial theMaterial = Graphic3d_NameOfMaterial_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)

View File

@@ -46,7 +46,7 @@ void CColoredShapes::Display(Handle(AIS_InteractiveContext)& anAIScontext)
{
Handle(AIS_Shape) ais = new AIS_Shape(iter.Value());
anAIScontext->SetColor(ais, (Quantity_NameOfColor)m_colorMap.Find(iter.Value()), Standard_False);
anAIScontext->SetMaterial(ais, Graphic3d_NOM_GOLD, Standard_False);
anAIScontext->SetMaterial(ais, Graphic3d_NameOfMaterial_Gold, Standard_False);
anAIScontext->Display(ais, Standard_False);
}
anAIScontext->UpdateCurrentViewer();

View File

@@ -25,7 +25,7 @@
#define DEFAULT_DCSMALL 0.0002
#define DEFAULT_DCVSMALL 0.00004
#define DEFAULT_COLOR Quantity_NOC_CYAN1
#define DEFAULT_MATERIAL Graphic3d_NOM_PLASTER
#define DEFAULT_MATERIAL Graphic3d_NameOfMaterial_Plastered
#define DEFAULT_BACKGROUNDCOLOR Quantity_NOC_MATRAGRAY
#define DEFAULT_HILIGHTCOLOR Quantity_NOC_YELLOW

View File

@@ -114,7 +114,7 @@ protected:
// 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 Graphic3d_NameOfMaterial theMaterial = Graphic3d_NameOfMaterial_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)

View File

@@ -29,7 +29,7 @@
#define DEFAULT_DCSMALL 0.0002
#define DEFAULT_DCVSMALL 0.00004
#define DEFAULT_COLOR Quantity_NOC_CYAN1
#define DEFAULT_MATERIAL Graphic3d_NOM_PLASTER
#define DEFAULT_MATERIAL Graphic3d_NameOfMaterial_Plastered
#define DEFAULT_BACKGROUNDCOLOR Quantity_NOC_MATRAGRAY
#define DEFAULT_HILIGHTCOLOR Quantity_NOC_YELLOW

View File

@@ -12,7 +12,7 @@
#include "Fonc.hxx"
#define DEFAULT_COLOR Quantity_NOC_CYAN1
#define DEFAULT_MATERIAL Graphic3d_NOM_PLASTER
#define DEFAULT_MATERIAL Graphic3d_NameOfMaterial_Plastered
#define DEFAULT_DEVIATIONCOEFFICIENT 0.001
#define DEFAULT_HILIGHTCOLOR Quantity_NOC_YELLOW
@@ -123,23 +123,23 @@ CAnimationDoc::CAnimationDoc()
myAisCylinderHead = new AIS_Shape (CylinderHead);
myAISContext->SetColor (myAisCylinderHead, Quantity_NOC_WHITE, Standard_False);
myAISContext->SetMaterial (myAisCylinderHead, Graphic3d_NOM_PLASTIC, Standard_False);
myAISContext->SetMaterial (myAisCylinderHead, Graphic3d_NameOfMaterial_Plastified, Standard_False);
myAisEngineBlock = new AIS_Shape (EngineBlock);
myAISContext->SetColor(myAisEngineBlock, Quantity_NOC_WHITE, Standard_False);
myAISContext->SetMaterial(myAisEngineBlock,Graphic3d_NOM_PLASTIC, Standard_False);
myAISContext->SetMaterial(myAisEngineBlock,Graphic3d_NameOfMaterial_Plastified, Standard_False);
myAISContext->Display(myAisCylinderHead ,1,-1,Standard_False);
myAISContext->Display(myAisEngineBlock ,1,-1,Standard_False);
myAisCrankArm = new AIS_Shape (CrankArm);
myAISContext->SetColor (myAisCrankArm, Quantity_NOC_HOTPINK, Standard_False);
myAISContext->SetMaterial(myAisCrankArm, Graphic3d_NOM_PLASTIC, Standard_False);
myAISContext->SetMaterial(myAisCrankArm, Graphic3d_NameOfMaterial_Plastified, Standard_False);
myAisPiston = new AIS_Shape (Piston);
myAISContext->SetColor (myAisPiston , Quantity_NOC_WHITE, Standard_False);
myAISContext->SetMaterial(myAisPiston , Graphic3d_NOM_PLASTIC, Standard_False);
myAISContext->SetMaterial(myAisPiston , Graphic3d_NameOfMaterial_Plastified, Standard_False);
myAisPropeller = new AIS_Shape (Propeller);
myAISContext->SetColor (myAisPropeller, Quantity_NOC_RED, Standard_False);
myAISContext->SetMaterial(myAisPropeller, Graphic3d_NOM_PLASTIC, Standard_False);
myAISContext->SetMaterial(myAisPropeller, Graphic3d_NameOfMaterial_Plastified, Standard_False);
myAISContext->Display(myAisCrankArm, 1,-1,Standard_False);
myAISContext->Display(myAisPropeller, 1,-1,Standard_False);
@@ -316,7 +316,7 @@ void CAnimationDoc::OnFileLoadgrid()
myAISContext->Display(myAISSurface, Standard_False);
myAISContext->Deactivate(myAISSurface,Standard_False);
myAISContext->SetColor (myAISSurface,Quantity_NOC_WHITE,Standard_False);
myAISContext->SetMaterial (myAISSurface,Graphic3d_NOM_STONE,Standard_False);
myAISContext->SetMaterial (myAISSurface,Graphic3d_NameOfMaterial_Stone,Standard_False);
myAISContext->SetDisplayMode (myAISSurface,1,Standard_False);
myAISContext->SetDeviationCoefficient (0.001);
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;

View File

@@ -39,7 +39,7 @@ enum CurrentAction3d {
#define DEFAULT_DCSMALL 0.0002
#define DEFAULT_DCVSMALL 0.00004
#define DEFAULT_COLOR Quantity_NOC_CYAN1
#define DEFAULT_MATERIAL Graphic3d_NOM_PLASTER
#define DEFAULT_MATERIAL Graphic3d_NameOfMaterial_Plastered
#define DEFAULT_BACKGROUNDCOLOR Quantity_NOC_MATRAGRAY
#define DEFAULT_HILIGHTCOLOR Quantity_NOC_YELLOW

View File

@@ -113,7 +113,7 @@ protected:
// 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 Graphic3d_NameOfMaterial theMaterial = Graphic3d_NameOfMaterial_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)

7
samples/qt/IESample/.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
/debug
/release
*.sln
*.vcxproj*
.qmake.stash
/custom.bat
/custom.sh

View File

@@ -1,4 +0,0 @@
@echo off
rem Define QTDIR variable
set "QTDIR="

View File

@@ -0,0 +1,5 @@
@echo off
rem Rename this file to custom.bat,
rem and define QTDIR variable.
set "QTDIR="

View File

@@ -1,4 +0,0 @@
#!/bin/bash
#Define QTDIR variable
export QTDIR=""

View File

@@ -0,0 +1,5 @@
#!/bin/bash
# Rename this file to custom.sh,
# and define QTDIR variable.
export QTDIR=""

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