preamble
Open CASCADE is an open source software development platform developed and supported by Open Cascade SAS, Inc. designed for rapid development of programs for specific domains. It is an object-oriented C++ class library that provides rich functionality for geometric modeling, data exchange and visualization, and has become a core component of many CAD software.
This article describes the process of setting up a Qt development occ environment.
Demo
Note: The internal QWidgets used are promoted to OccWidgets, and the borders are all 9px by default.
Compiler version issues
Since 7.7, which uses deocc, is itself a msvc2015x64 version, Qt uses the msvc2015x64 version of 5.9.3 (the previous post was written as msvc2017x64).
Build Qt development environment
Step 1: New demo, modularization ideas
Step 2: Modularize the occ sdk
Here was going to put all the tripartite libraries into a bin, lib and include under the mix, so that the pro inside to write xcopy script, and then found out that it is not very good, had to keep it alone as is.
The following start copying, all the folders inside the bin inside the copy to the module under the bin, lib and include to do this operation, here under a single folder have bin, lib and include, only occ does not.
draco-1.4.1-vc14-64: copying bin, include, libs
ffmpeg-3.3.4-64: copy bin, include, lib
freeimage-3.17.0-vc14-64: copying bin, include, libs
freetype-2.5.5-vc14-64: copying bin, include, libs
opencascade-7.7.0: copy inc and win64
header files in inc, bin and lib in win64, keep the relative paths to prevent subsequent tracking of directory consistency.
openvr-1.14.15-64: copy bin, include, lib
qt5.11.2-vc14-64: no copy, we are Qt5.9.3 msvc2017x64 (that's vc14-64)
rapidjson-1.1.0: copy include
This one is special in that the source files are inside the header file, not generating a library.
tbb_2021.5-vc14-64: copy bin, include, lib
tcltk-86-64: copy bin, include, lib
vtk-6.1.0-vc14-64: copy bin, include, lib
Step 3: Configure the pri introduction library
Header file paths, library file paths and library files are introduced here:
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
HEADERS += \
$$PWD/OccManager.h
SOURCES += \
$$PWD/OccManager.cpp
# occ-7.7.0-msvc2015x64(openCascade-7.7.0-vc14-64)
INCLUDEPATH += $$PWD/occ-7.7.0-msvc2015x64/opencascade-7.7.0/inc
LIBS += -L$$PWD/occ-7.7.0-msvc2015x64/opencascade-7.7.0/win64/vc14/lib
LIBS += -lTKBin
LIBS += -lTKBinL
LIBS += -lTKBinTObj
LIBS += -lTKBinXCAF
LIBS += -lTKBO
LIBS += -lTKBool
LIBS += -lTKBRep
LIBS += -lTKCAF
LIBS += -lTKCDF
LIBS += -lTKD3DHost
LIBS += -lTKD3DHostTest
LIBS += -lTKDCAF
LIBS += -lTKDFBrowser
LIBS += -lTKDraw
LIBS += -lTKernel
LIBS += -lTKExpress
LIBS += -lTKFeat
LIBS += -lTKFillet
LIBS += -lTKG2d
LIBS += -lTKG3d
LIBS += -lTKGeomAlgo
LIBS += -lTKGeomBase
LIBS += -lTKHLR
LIBS += -lTKIGES
LIBS += -lTKIVtk
LIBS += -lTKIVtkDraw
LIBS += -lTKLCAF
LIBS += -lTKMath
LIBS += -lTKMesh
LIBS += -lTKMeshVS
LIBS += -lTKMessageModel
LIBS += -lTKMessageView
LIBS += -lTKOffset
LIBS += -lTKOpenGl
LIBS += -lTKOpenGles
LIBS += -lTKOpenGlesTest
LIBS += -lTKOpenGlTest
LIBS += -lTKPrim
LIBS += -lTKQADraw
LIBS += -lTKRWMesh
LIBS += -lTKService
LIBS += -lTKShapeView
LIBS += -lTKShHealing
LIBS += -lTKStd
LIBS += -lTKStdL
LIBS += -lTKSTEP
LIBS += -lTKSTEP209
LIBS += -lTKSTEPAttr
LIBS += -lTKSTEPBase
LIBS += -lTKSTL
LIBS += -lTKTInspector
LIBS += -lTKTInspectorAPI
LIBS += -lTKTObj
LIBS += -lTKTObjDRAW
LIBS += -lTKToolsDraw
LIBS += -lTKTopAlgo
LIBS += -lTKTopTest
LIBS += -lTKTreeModel
LIBS += -lTKV3d
LIBS += -lTKVCAF
LIBS += -lTKView
LIBS += -lTKViewerTest
LIBS += -lTKVInspector
LIBS += -lTKVRML
LIBS += -lTKXCAF
LIBS += -lTKXDE
LIBS += -lTKXDECascade
LIBS += -lTKXDEDRAW
LIBS += -lTKXDEIGES
LIBS += -lTKXDESTEP
LIBS += -lTKXMesh
LIBS += -lTKXml
LIBS += -lTKXmlL
LIBS += -lTKXmlTObj
LIBS += -lTKXmlXCAF
LIBS += -lTKXSBase
LIBS += -lTKXSDRAW
Step 4: Compilation
Common errors occur:
Check out the article "About fatal error LNK1158: can't run "" solution" to solve it. (Note: Direct assignment of rc related files to qt's msvc2015_64 version bin folder is the best).
So far, the introduction of the occ library is good, but we still need calls to detect it.
Step 5: Compile and run the test using the demo
It's not enough to just include the opencascade bin (as we expected, but the compilation doesn't bring in the other library libs, so I don't know):
The dlls under the bin of all the previous libraries are needed to get it up and running correctly, but it really doesn't need libs outside of opencascade when compiling.
The resultant run, with nothing much in the program, releases the deployment package (Qt5.9.3 msvc2017x64 opencascade-7.7.0) with about 220MB, as shown below:
A total of 303 items:
Demo key source code
…
protected slots: // Once displayed, you need to refresh the size of the occ window to make it the same size.
void slot_resize();
protected: // Three functions of the parent class need to be overridden
QPaintEngine* paintEngine() const;
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
private: // Occ's proprietary variables
opencascade::handle<V3d_Viewer> _pV3dViewer;
opencascade::handle<V3d_View> _pV3dView;
opencascade::handle<Aspect_DisplayConnection> _pAspectDisplayConnection;
opencascade::handle<OpenGl_GraphicDriver> _pOpenGLGraphicDriver;
opencascade::handle<AIS_InteractiveContext> _pAisInteractiveContext;
WId _wid;
opencascade::handle<WNT_Window> _pWntWindow;
};
…
…
void OccWidget::initControl()
{
// Initialize occ
{
// Display to screen
setAttribute(Qt::WA_PaintOnScreen);
// Create a connection to the display device
_pAspectDisplayConnection= new Aspect_DisplayConnection();
// Create a 3D interface to define the graphics driver
_pOpenGLGraphicDriver= new OpenGl_GraphicDriver(_pAspectDisplayConnection);
// Create the 3D viewer object and specify the graphics driver
_pV3dViewer= new V3d_Viewer(_pOpenGLGraphicDriver);
// Create an interactive context object to associate with the 3D viewer
_pAisInteractiveContext= new AIS_InteractiveContext(_pV3dViewer);
// Create the view and associate it to the 3D viewer
_pV3dView= _pV3dViewer->CreateView();
// Get the window handle and create WNT_Window.
_wid= winId();
_pWntWindow= new WNT_Window((Aspect_Handle)_wid);
// Setting up the view window
_pV3dView->SetWindow(_pWntWindow);
if(!_pWntWindow->IsMapped())
{
_pWntWindow->Map();
_pV3dView->Redraw();
}
QTimer::singleShot(10, this, SLOT(slot_resize()));
}
}
void OccWidget::slot_resize()
{
_pV3dView->MustBeResized();
}
QPaintEngine *OccWidget::paintEngine() const
{
return 0;
}
void OccWidget::paintEvent(QPaintEvent *event)
{
if(!_pV3dView.IsNull())
{
_pV3dView->Redraw();
}
QWidget::paintEvent(event);
}
void OccWidget::resizeEvent(QResizeEvent *event)
{
if(!_pV3dView.IsNull())
{
_pV3dView->MustBeResized();
}
QWidget::resizeEvent(event);
}
…
fig. make a career out of it
Pitfall 1: Window stretching appears to be a window re-flashing problem
concern
The stretching is shown below:
rationale
The judgment was swiped but it seemed to be overwritten, then I found out the reason was a code problem when hand coding
settle (a dispute)
Pitfall 2: Display window will redraw incorrectly the first time
concern
Show that the problem occurs
Stretching down then refreshes no problem:
rationale
It should be a refreshing problem, the window is refreshed according to some value (indeterminate) before it is fully displayed, which is the same as dynamic layout getting inconsistent size in the construction.
settle (a dispute)
This one just needs to pick up another slot function in the construct (this one will make sure that it is re-called once after startup).