Compare commits
30 Commits
CR0_IntSeg
...
CR31150
Author | SHA1 | Date | |
---|---|---|---|
|
9785e5939b | ||
|
60d61bea5e | ||
|
0d1b52780b | ||
|
5a60253c55 | ||
|
98d49da76f | ||
|
0e965f544e | ||
|
62e59942c9 | ||
|
47329f0adf | ||
|
41114c82f0 | ||
|
d7272de6a6 | ||
|
63c48876e4 | ||
|
bf2a25e092 | ||
|
92fe90c559 | ||
|
c0b0919b8c | ||
|
64c52c0521 | ||
|
9cbf89af71 | ||
|
22f35b2166 | ||
|
6ad25e3a28 | ||
|
ea4a8b2ba1 | ||
|
9ef696f23e | ||
|
c39cf33aeb | ||
|
aef350836f | ||
|
9dfef0dba8 | ||
|
04f32ec6a6 | ||
|
f7d176b4c9 | ||
|
68175994e7 | ||
|
36939d056a | ||
|
fc0dfabf9f | ||
|
8dfef072d0 | ||
|
bbe059fc76 |
@@ -1,4 +1,4 @@
|
|||||||
TModelingData TKShapeView
|
TModelingData TKShapeView TKMessageModel TKMessageView
|
||||||
TVisualization TKView TKVInspector
|
TVisualization TKView TKVInspector
|
||||||
TApplicationFramework TKTreeModel TKTInspectorAPI TKDFBrowser
|
TApplicationFramework TKTreeModel TKTInspectorAPI TKDFBrowser
|
||||||
TTool TKTInspector TKToolsDraw TInspectorEXE
|
TTool TKTInspector TKToolsDraw TInspectorEXE
|
@@ -108,7 +108,6 @@ else()
|
|||||||
elseif (ANDROID)
|
elseif (ANDROID)
|
||||||
set (CSF_ThreadLibs "c")
|
set (CSF_ThreadLibs "c")
|
||||||
set (CSF_OpenGlLibs "EGL GLESv2")
|
set (CSF_OpenGlLibs "EGL GLESv2")
|
||||||
set (CSF_androidlog "log")
|
|
||||||
elseif (UNIX)
|
elseif (UNIX)
|
||||||
set (CSF_ThreadLibs "pthread rt stdc++")
|
set (CSF_ThreadLibs "pthread rt stdc++")
|
||||||
if (USE_GLES2)
|
if (USE_GLES2)
|
||||||
|
@@ -12,12 +12,18 @@ macro (OCCT_CHECK_AND_UNSET VARNAME)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro (OCCT_CHECK_AND_UNSET_GROUP GROUPNAME)
|
macro (OCCT_CHECK_AND_UNSET_GROUP VARNAME)
|
||||||
get_cmake_property(VARS VARIABLES)
|
OCCT_CHECK_AND_UNSET ("${VARNAME}_DIR")
|
||||||
string (REGEX MATCHALL "(^|;)${GROUPNAME}[A-Za-z0-9_]*" GROUPNAME_VARS "${VARS}")
|
|
||||||
foreach(GROUPNAME_VAR ${GROUPNAME_VARS})
|
OCCT_CHECK_AND_UNSET ("${VARNAME}_INCLUDE_DIR")
|
||||||
OCCT_CHECK_AND_UNSET(${GROUPNAME_VAR})
|
|
||||||
endforeach()
|
OCCT_CHECK_AND_UNSET ("${VARNAME}_LIBRARY")
|
||||||
|
OCCT_CHECK_AND_UNSET ("${VARNAME}_LIBRARY_DIR")
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
OCCT_CHECK_AND_UNSET ("${VARNAME}_DLL")
|
||||||
|
OCCT_CHECK_AND_UNSET ("${VARNAME}_DLL_DIR")
|
||||||
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro (OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS)
|
macro (OCCT_CHECK_AND_UNSET_INSTALL_DIR_SUBDIRS)
|
||||||
|
@@ -31,4 +31,10 @@ if (NOT ${Qt5_FOUND})
|
|||||||
#message (STATUS "Qt4 cmake configuration")
|
#message (STATUS "Qt4 cmake configuration")
|
||||||
else()
|
else()
|
||||||
#message (STATUS "Qt5 cmake configuration")
|
#message (STATUS "Qt5 cmake configuration")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (3RDPARTY_QT_DIR OR EXISTS "${3RDPARTY_QT_DIR}")
|
||||||
|
list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_QT_DIR}/bin")
|
||||||
|
else()
|
||||||
|
list (APPEND 3RDPARTY_NO_DLLS 3RDPARTY_QT_DLL_DIR)
|
||||||
|
endif()
|
||||||
|
@@ -1419,9 +1419,6 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
|
|||||||
set aFrmsMap(CSF_TclTkLibs) "Tk"
|
set aFrmsMap(CSF_TclTkLibs) "Tk"
|
||||||
set aLibsMap(CSF_TclTkLibs) ""
|
set aLibsMap(CSF_TclTkLibs) ""
|
||||||
set aLibsMap(CSF_QT) "QtCore QtGui"
|
set aLibsMap(CSF_QT) "QtCore QtGui"
|
||||||
} elseif { "$theOS" == "android" } {
|
|
||||||
set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
|
|
||||||
set aLibsMap(CSF_androidlog) "log"
|
|
||||||
} else {
|
} else {
|
||||||
set aLibsMap(CSF_fontconfig) "fontconfig"
|
set aLibsMap(CSF_fontconfig) "fontconfig"
|
||||||
if { "$theOS" == "qnx" } {
|
if { "$theOS" == "qnx" } {
|
||||||
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 11 KiB |
BIN
data/images/hatch_1_.png
Normal file
After Width: | Height: | Size: 670 B |
BIN
data/images/hatch_2.png
Normal file
After Width: | Height: | Size: 679 B |
BIN
data/images/hatch_3.png
Normal file
After Width: | Height: | Size: 761 B |
BIN
data/images/hatch_4.png
Normal file
After Width: | Height: | Size: 674 B |
BIN
data/images/hatch_5.png
Normal file
After Width: | Height: | Size: 887 B |
BIN
data/images/hatch_6.png
Normal file
After Width: | Height: | Size: 933 B |
BIN
data/images/hatch_7.png
Normal file
After Width: | Height: | Size: 633 B |
BIN
data/images/hatch_8.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
@@ -14,7 +14,6 @@ overview/overview.md
|
|||||||
../samples/qt/AndroidQt/ReadMe.md
|
../samples/qt/AndroidQt/ReadMe.md
|
||||||
../samples/java/jniviewer/ReadMe.md
|
../samples/java/jniviewer/ReadMe.md
|
||||||
../samples/ios/UIKitSample/ReadMe.md
|
../samples/ios/UIKitSample/ReadMe.md
|
||||||
../samples/webgl/ReadMe.md
|
|
||||||
|
|
||||||
tutorial/tutorial.md
|
tutorial/tutorial.md
|
||||||
|
|
||||||
|
@@ -1857,34 +1857,3 @@ The following API changes have been made:
|
|||||||
@subsection upgrade_740_stdnamespace Standard_Stream.hxx no more has "using std::" statements
|
@subsection upgrade_740_stdnamespace Standard_Stream.hxx no more has "using std::" statements
|
||||||
*Standard_Stream.hxx* header, commonly included by other OCCT header files, does no more add entities from *std namespace* related to streams (like *std::cout*, *std::istream* and others) into global namespace.
|
*Standard_Stream.hxx* header, commonly included by other OCCT header files, does no more add entities from *std namespace* related to streams (like *std::cout*, *std::istream* and others) into global namespace.
|
||||||
The application code relying on this matter should be updated to either specify std namespace explicitly (like std::cout) or add "using std::" statements locally.
|
The application code relying on this matter should be updated to either specify std namespace explicitly (like std::cout) or add "using std::" statements locally.
|
||||||
|
|
||||||
@section upgrade_occt750 Upgrade to OCCT 7.5.0
|
|
||||||
|
|
||||||
@subsection upgrade_750_srgb_color RGB color definition
|
|
||||||
|
|
||||||
OCCT 3D Viewer has been improved to properly perform lighting using in linear RGB color space and then convert result into non-linear gamma-shifted sRGB color space before displaying on display.
|
|
||||||
This change affects texture mapping, material definition and color definition.
|
|
||||||
|
|
||||||
Previously *Quantity_Color* definition was provided with unspecified RGB color space.
|
|
||||||
In practice, mixed color spaces have been actually used, with non-linear sRGB prevailing in general.
|
|
||||||
Since OCCT 7.5.0, *Quantity_Color* now specifies that components are defined in linear RGB color space.
|
|
||||||
|
|
||||||
This change affects following parts:
|
|
||||||
* Standard colors defined by *Quantity_NameOfColor* enumeration have been converted into linear RGB values within Quantity_Color construction.
|
|
||||||
* Application may use new enumeration value *Quantity_TOC_sRGB* for passing/fetching colors in sRGB color space,
|
|
||||||
which can be useful for interoperation with color picking widgets (returning 8-bit integer values within [0..255] range)
|
|
||||||
or for porting colors constants within old application code without manual conversion.
|
|
||||||
* *Graphic3d_MaterialAspect* color components are now expected in linear RGB color space,
|
|
||||||
and standard OCCT materials within *Graphic3d_NameOfMaterial* enumeration have been updated accordingly.
|
|
||||||
* Texture mapping now handles new *Graphic3d_TextureRoot::IsColorMap()* for interpreting content in linear RGB or sRGB color space.
|
|
||||||
It is responsibility of user specifying this flag correctly. The flag value is TRUE by default.
|
|
||||||
* Method *Image_PixMap::PixelColor()* has been extended with a new Boolean flag for performing linearization of non-linear sRGB.
|
|
||||||
This flag is FALSE by default; application should consider passing TRUE instead for further handling *Quantity_Color* properly as linear RGB values.
|
|
||||||
|
|
||||||
@subsection upgrade_750_aspectwindow Aspect_Window interface change
|
|
||||||
|
|
||||||
Unexpected const-ness of Aspect_Window::DoResize() method has been removed, so that application classes implementing this interface should be updated accordingly.
|
|
||||||
|
|
||||||
@subsection upgrade_750_rename Renaming of types
|
|
||||||
|
|
||||||
Enumeration BRepOffset_Type is renamed to ChFiDS_TypeOfConcavity.
|
|
||||||
|
Before Width: | Height: | Size: 74 KiB |
@@ -153,9 +153,6 @@ on this tool.
|
|||||||
**RapidJSON** is an Open Source JSON parser and generator for C++.
|
**RapidJSON** is an Open Source JSON parser and generator for C++.
|
||||||
RapidJSON is optionally used by OCCT for reading glTF files (https://rapidjson.org/).
|
RapidJSON is optionally used by OCCT for reading glTF files (https://rapidjson.org/).
|
||||||
|
|
||||||
**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.
|
|
||||||
|
|
||||||
Adobe Systems, Inc. provides **Adobe Reader**, which can be used to view files in Portable Document Format (PDF).
|
Adobe Systems, Inc. provides **Adobe Reader**, which can be used to view files in Portable Document Format (PDF).
|
||||||
|
|
||||||
@section OCCT_OVW_SECTION_3 Documentation
|
@section OCCT_OVW_SECTION_3 Documentation
|
||||||
@@ -214,7 +211,6 @@ for which OCCT is certified to work.
|
|||||||
| Linux | GNU gcc 4.3+ <br> LLVM CLang 3.6+ |
|
| Linux | GNU gcc 4.3+ <br> LLVM CLang 3.6+ |
|
||||||
| OS X / macOS | XCode 6 or newer |
|
| OS X / macOS | XCode 6 or newer |
|
||||||
| Android | NDK r10, GNU gcc 4.8 or newer |
|
| Android | NDK r10, GNU gcc 4.8 or newer |
|
||||||
| Web | Emscripten SDK 1.39 or newer (CLang) |
|
|
||||||
|
|
||||||
1) VC++ 141 64-bit is used for regular testing and for building binary package of official release of OCCT on Windows.
|
1) VC++ 141 64-bit is used for regular testing and for building binary package of official release of OCCT on Windows.
|
||||||
|
|
||||||
@@ -573,11 +569,3 @@ There is a sample demonstrating usage of OCCT on iOS with Apple UIKit framework.
|
|||||||
@figure{/overview/images/sample_ios_uikit.png}
|
@figure{/overview/images/sample_ios_uikit.png}
|
||||||
|
|
||||||
See \subpage occt_samples_ios_uikit "iOS sample Readme" for details.
|
See \subpage occt_samples_ios_uikit "iOS sample Readme" for details.
|
||||||
|
|
||||||
@subsubsection OCCT_OVW_SECTION_7_3_6 Web
|
|
||||||
|
|
||||||
WebGL Viewer sample demonstrating usage of OCCT 3D Viewer in Web browser with Emscripten SDK can be found in `samples/webgl`.
|
|
||||||
|
|
||||||
@figure{/overview/images/sample_webgl.png}
|
|
||||||
|
|
||||||
See \subpage occt_samples_webgl "WebGL sample Readme" for details.
|
|
||||||
|
@@ -35,49 +35,13 @@
|
|||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
//! Convert GLFW mouse button into Aspect_VKeyMouse.
|
|
||||||
static Aspect_VKeyMouse mouseButtonFromGlfw (int theButton)
|
|
||||||
{
|
|
||||||
switch (theButton)
|
|
||||||
{
|
|
||||||
case GLFW_MOUSE_BUTTON_LEFT: return Aspect_VKeyMouse_LeftButton;
|
|
||||||
case GLFW_MOUSE_BUTTON_RIGHT: return Aspect_VKeyMouse_RightButton;
|
|
||||||
case GLFW_MOUSE_BUTTON_MIDDLE: return Aspect_VKeyMouse_MiddleButton;
|
|
||||||
}
|
|
||||||
return Aspect_VKeyMouse_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Convert GLFW key modifiers into Aspect_VKeyFlags.
|
|
||||||
static Aspect_VKeyFlags keyFlagsFromGlfw (int theFlags)
|
|
||||||
{
|
|
||||||
Aspect_VKeyFlags aFlags = Aspect_VKeyFlags_NONE;
|
|
||||||
if ((theFlags & GLFW_MOD_SHIFT) != 0)
|
|
||||||
{
|
|
||||||
aFlags |= Aspect_VKeyFlags_SHIFT;
|
|
||||||
}
|
|
||||||
if ((theFlags & GLFW_MOD_CONTROL) != 0)
|
|
||||||
{
|
|
||||||
aFlags |= Aspect_VKeyFlags_CTRL;
|
|
||||||
}
|
|
||||||
if ((theFlags & GLFW_MOD_ALT) != 0)
|
|
||||||
{
|
|
||||||
aFlags |= Aspect_VKeyFlags_ALT;
|
|
||||||
}
|
|
||||||
if ((theFlags & GLFW_MOD_SUPER) != 0)
|
|
||||||
{
|
|
||||||
aFlags |= Aspect_VKeyFlags_META;
|
|
||||||
}
|
|
||||||
return aFlags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
// ================================================================
|
||||||
// Function : GlfwOcctView
|
// Function : GlfwOcctView
|
||||||
// Purpose :
|
// Purpose :
|
||||||
// ================================================================
|
// ================================================================
|
||||||
GlfwOcctView::GlfwOcctView()
|
GlfwOcctView::GlfwOcctView()
|
||||||
|
: myCurAction3d (CurAction3d_Nothing),
|
||||||
|
myToRedraw (true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +193,15 @@ void GlfwOcctView::mainloop()
|
|||||||
glfwWaitEvents();
|
glfwWaitEvents();
|
||||||
if (!myView.IsNull())
|
if (!myView.IsNull())
|
||||||
{
|
{
|
||||||
FlushViewEvents (myContext, myView, true);
|
if (myView->IsInvalidated())
|
||||||
|
{
|
||||||
|
myView->Redraw();
|
||||||
|
}
|
||||||
|
else if (myToRedraw)
|
||||||
|
{
|
||||||
|
myView->RedrawImmediate();
|
||||||
|
}
|
||||||
|
myToRedraw = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,6 +237,7 @@ void GlfwOcctView::onResize (int theWidth, int theHeight)
|
|||||||
myView->MustBeResized();
|
myView->MustBeResized();
|
||||||
myView->Invalidate();
|
myView->Invalidate();
|
||||||
myView->Redraw();
|
myView->Redraw();
|
||||||
|
//myToRedraw = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,10 +247,13 @@ void GlfwOcctView::onResize (int theWidth, int theHeight)
|
|||||||
// ================================================================
|
// ================================================================
|
||||||
void GlfwOcctView::onMouseScroll (double theOffsetX, double theOffsetY)
|
void GlfwOcctView::onMouseScroll (double theOffsetX, double theOffsetY)
|
||||||
{
|
{
|
||||||
if (!myView.IsNull())
|
if (myView.IsNull()) { return; }
|
||||||
{
|
|
||||||
UpdateZoom (Aspect_ScrollDelta (myOcctWindow->CursorPosition(), int(theOffsetY * 8.0)));
|
const Graphic3d_Vec2i aPos = myOcctWindow->CursorPosition();
|
||||||
}
|
myView->StartZoomAtPoint (aPos.x(), aPos.y());
|
||||||
|
myView->ZoomAtPoint (0, 0, int(theOffsetY * 4.0), int(theOffsetY * 4.0));
|
||||||
|
myView->Invalidate();
|
||||||
|
myToRedraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================================================================
|
// ================================================================
|
||||||
@@ -289,13 +265,27 @@ void GlfwOcctView::onMouseButton (int theButton, int theAction, int theMods)
|
|||||||
if (myView.IsNull()) { return; }
|
if (myView.IsNull()) { return; }
|
||||||
|
|
||||||
const Graphic3d_Vec2i aPos = myOcctWindow->CursorPosition();
|
const Graphic3d_Vec2i aPos = myOcctWindow->CursorPosition();
|
||||||
if (theAction == GLFW_PRESS)
|
if (theAction != GLFW_PRESS)
|
||||||
{
|
{
|
||||||
PressMouseButton (aPos, mouseButtonFromGlfw (theButton), keyFlagsFromGlfw (theMods), false);
|
myCurAction3d = CurAction3d_Nothing;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
myMouseMin = aPos;
|
||||||
|
myMouseMax = aPos;
|
||||||
|
switch (theButton)
|
||||||
{
|
{
|
||||||
ReleaseMouseButton (aPos, mouseButtonFromGlfw (theButton), keyFlagsFromGlfw (theMods), false);
|
case GLFW_MOUSE_BUTTON_RIGHT:
|
||||||
|
{
|
||||||
|
myCurAction3d = CurAction3d_DynamicRoation;
|
||||||
|
myView->StartRotation (aPos.x(), aPos.y());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GLFW_MOUSE_BUTTON_MIDDLE:
|
||||||
|
{
|
||||||
|
myCurAction3d = CurAction3d_DynamicPanning;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,9 +295,30 @@ void GlfwOcctView::onMouseButton (int theButton, int theAction, int theMods)
|
|||||||
// ================================================================
|
// ================================================================
|
||||||
void GlfwOcctView::onMouseMove (int thePosX, int thePosY)
|
void GlfwOcctView::onMouseMove (int thePosX, int thePosY)
|
||||||
{
|
{
|
||||||
const Graphic3d_Vec2i aNewPos (thePosX, thePosY);
|
if (myView.IsNull()) { return; }
|
||||||
if (!myView.IsNull())
|
|
||||||
|
switch (myCurAction3d)
|
||||||
{
|
{
|
||||||
UpdateMousePosition (aNewPos, PressedMouseButtons(), LastMouseFlags(), false);
|
case CurAction3d_DynamicRoation:
|
||||||
|
{
|
||||||
|
myView->Rotation (thePosX, thePosY);
|
||||||
|
myView->Invalidate();
|
||||||
|
myToRedraw = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CurAction3d_DynamicPanning:
|
||||||
|
{
|
||||||
|
myView->Pan (thePosX - myMouseMax.x(), -(thePosY - myMouseMax.y()));
|
||||||
|
myView->Invalidate();
|
||||||
|
myToRedraw = true;
|
||||||
|
myMouseMax.SetValues (thePosX, thePosY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
myContext->MoveTo (thePosX, thePosY, myView, false);
|
||||||
|
myToRedraw = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,12 +25,20 @@
|
|||||||
#include "GlfwOcctWindow.h"
|
#include "GlfwOcctWindow.h"
|
||||||
|
|
||||||
#include <AIS_InteractiveContext.hxx>
|
#include <AIS_InteractiveContext.hxx>
|
||||||
#include <AIS_ViewController.hxx>
|
|
||||||
#include <V3d_View.hxx>
|
#include <V3d_View.hxx>
|
||||||
|
|
||||||
//! Sample class creating 3D Viewer within GLFW window.
|
//! Sample class creating 3D Viewer within GLFW window.
|
||||||
class GlfwOcctView : protected AIS_ViewController
|
class GlfwOcctView
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
enum CurAction3d
|
||||||
|
{
|
||||||
|
CurAction3d_Nothing,
|
||||||
|
CurAction3d_DynamicZooming,
|
||||||
|
CurAction3d_DynamicPanning,
|
||||||
|
CurAction3d_DynamicRoation
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Default constructor.
|
//! Default constructor.
|
||||||
GlfwOcctView();
|
GlfwOcctView();
|
||||||
@@ -107,6 +115,11 @@ private:
|
|||||||
Handle(V3d_View) myView;
|
Handle(V3d_View) myView;
|
||||||
Handle(AIS_InteractiveContext) myContext;
|
Handle(AIS_InteractiveContext) myContext;
|
||||||
|
|
||||||
|
CurAction3d myCurAction3d;
|
||||||
|
Graphic3d_Vec2i myMouseMin;
|
||||||
|
Graphic3d_Vec2i myMouseMax;
|
||||||
|
bool myToRedraw;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _GlfwOcctView_Header
|
#endif // _GlfwOcctView_Header
|
||||||
|
@@ -134,17 +134,17 @@ void GlfwOcctWindow::Unmap() const
|
|||||||
// Function : DoResize
|
// Function : DoResize
|
||||||
// Purpose :
|
// Purpose :
|
||||||
// ================================================================
|
// ================================================================
|
||||||
Aspect_TypeOfResize GlfwOcctWindow::DoResize()
|
Aspect_TypeOfResize GlfwOcctWindow::DoResize() const
|
||||||
{
|
{
|
||||||
if (glfwGetWindowAttrib (myGlfwWindow, GLFW_VISIBLE) == 1)
|
if (glfwGetWindowAttrib (myGlfwWindow, GLFW_VISIBLE) == 1)
|
||||||
{
|
{
|
||||||
int anXPos = 0, anYPos = 0, aWidth = 0, aHeight = 0;
|
int anXPos = 0, anYPos = 0, aWidth = 0, aHeight = 0;
|
||||||
glfwGetWindowPos (myGlfwWindow, &anXPos, &anYPos);
|
glfwGetWindowPos (myGlfwWindow, &anXPos, &anYPos);
|
||||||
glfwGetWindowSize(myGlfwWindow, &aWidth, &aHeight);
|
glfwGetWindowSize(myGlfwWindow, &aWidth, &aHeight);
|
||||||
myXLeft = anXPos;
|
*const_cast<Standard_Integer*>(&myXLeft ) = anXPos;
|
||||||
myXRight = anXPos + aWidth;
|
*const_cast<Standard_Integer*>(&myXRight ) = anXPos + aWidth;
|
||||||
myYTop = anYPos;
|
*const_cast<Standard_Integer*>(&myYTop ) = anYPos;
|
||||||
myYBottom = anYPos + aHeight;
|
*const_cast<Standard_Integer*>(&myYBottom) = anYPos + aHeight;
|
||||||
}
|
}
|
||||||
return Aspect_TOR_UNKNOWN;
|
return Aspect_TOR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ public:
|
|||||||
virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return 0; }
|
virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return 0; }
|
||||||
|
|
||||||
//! Applies the resizing to the window <me>
|
//! Applies the resizing to the window <me>
|
||||||
virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE;
|
virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE;
|
||||||
|
|
||||||
//! Returns True if the window <me> is opened and False if the window is closed.
|
//! Returns True if the window <me> is opened and False if the window is closed.
|
||||||
virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
|
virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
|
||||||
|
@@ -44,7 +44,7 @@ public:
|
|||||||
virtual void Unmap() const Standard_OVERRIDE {}
|
virtual void Unmap() const Standard_OVERRIDE {}
|
||||||
|
|
||||||
//! Applies the resizing to the window <me>
|
//! Applies the resizing to the window <me>
|
||||||
virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
|
virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
|
||||||
|
|
||||||
//! Apply the mapping change to the window <me>
|
//! Apply the mapping change to the window <me>
|
||||||
virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
|
virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
|
||||||
|
@@ -216,7 +216,8 @@ void GeomSources::DisplaySurface(CGeometryDoc* aDoc,
|
|||||||
|
|
||||||
void GeomSources::ResetView(CGeometryDoc* aDoc)
|
void GeomSources::ResetView(CGeometryDoc* aDoc)
|
||||||
{
|
{
|
||||||
Handle(V3d_View) aView = aDoc->GetAISContext()->CurrentViewer()->ActiveViews().First();
|
aDoc->GetAISContext()->CurrentViewer()->InitActiveViews();
|
||||||
|
Handle(V3d_View) aView = aDoc->GetAISContext()->CurrentViewer()->ActiveView();
|
||||||
aView->Reset();
|
aView->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -68,7 +68,8 @@ void TexturesExt_Presentation::DoSample()
|
|||||||
void TexturesExt_Presentation::Init()
|
void TexturesExt_Presentation::Init()
|
||||||
{
|
{
|
||||||
// initialize v3d_view so it displays TexturesExt well
|
// initialize v3d_view so it displays TexturesExt well
|
||||||
Handle(V3d_View) aView = getViewer()->ActiveViews().First();
|
getViewer()->InitActiveViews();
|
||||||
|
Handle(V3d_View) aView = getViewer()->ActiveView();
|
||||||
aView->SetSize(ZVIEW_SIZE);
|
aView->SetSize(ZVIEW_SIZE);
|
||||||
|
|
||||||
// getDocument()->UpdateResultMessageDlg("Textured Shape",
|
// getDocument()->UpdateResultMessageDlg("Textured Shape",
|
||||||
|
@@ -1020,7 +1020,8 @@ void CViewer3dDoc::OnDumpView()
|
|||||||
pView->UpdateWindow();
|
pView->UpdateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(V3d_View) aView = myViewer->ActiveViews().First();
|
myViewer->InitActiveViews();
|
||||||
|
Handle(V3d_View) aView = myViewer->ActiveView();
|
||||||
ExportView (aView);
|
ExportView (aView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1012,61 +1012,65 @@ aParams.NbMsaaSamples = aParams.NbMsaaSamples == 0 ? 8 : 0;\n\
|
|||||||
GetDocument()->UpdateResultMessageDlg("SetAntialiasingOn/SetAntialiasingOff",Message);
|
GetDocument()->UpdateResultMessageDlg("SetAntialiasingOn/SetAntialiasingOff",Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CViewer3dView::OnClearLights()
|
void CViewer3dView::OnClearLights()
|
||||||
{
|
{
|
||||||
// Setting Off all viewer active lights
|
// Setting Off all viewer active lights
|
||||||
V3d_ListOfLight lights;
|
TColStd_ListOfTransient lights;
|
||||||
for (V3d_ListOfLightIterator anIter = myView->Viewer()->ActiveLightIterator(); anIter.More(); anIter.Next())
|
for(myView->Viewer()->InitActiveLights(); myView->Viewer()->MoreActiveLights(); myView->Viewer()->NextActiveLights())
|
||||||
{
|
{
|
||||||
lights.Append (anIter.Value());
|
lights.Append(myView->Viewer()->ActiveLight());
|
||||||
}
|
}
|
||||||
V3d_ListOfLightIterator itrLights(lights);
|
TColStd_ListIteratorOfListOfTransient itrLights(lights);
|
||||||
for (; itrLights.More(); itrLights.Next())
|
for (; itrLights.More(); itrLights.Next())
|
||||||
{
|
{
|
||||||
myView->Viewer()->SetLightOff (itrLights.Value());
|
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());
|
||||||
|
myView->Viewer()->SetLightOff(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting Off all view active lights
|
// Setting Off all view active lights
|
||||||
lights.Clear();
|
lights.Clear();
|
||||||
for (V3d_ListOfLightIterator anIter = myView->ActiveLightIterator(); anIter.More(); anIter.Next())
|
for(myView->InitActiveLights(); myView->MoreActiveLights(); myView->NextActiveLights())
|
||||||
{
|
{
|
||||||
lights.Append (anIter.Value());
|
lights.Append(myView->ActiveLight());
|
||||||
}
|
}
|
||||||
itrLights.Initialize (lights);
|
itrLights.Initialize(lights);
|
||||||
for (; itrLights.More(); itrLights.Next())
|
for (; itrLights.More(); itrLights.Next())
|
||||||
{
|
{
|
||||||
myView->SetLightOff (itrLights.Value());
|
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());
|
||||||
|
myView->SetLightOff(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
myView->Viewer()->SetDefaultLights(); // Setting the default lights on
|
myView->Viewer()->SetDefaultLights();// Setting the default lights on
|
||||||
|
|
||||||
NbActiveLights = 2; // There are 2 default active lights
|
NbActiveLights = 2;// There are 2 default active lights
|
||||||
|
|
||||||
myView->Update();
|
myView->Update();
|
||||||
|
|
||||||
TCollection_AsciiString Message("\
|
TCollection_AsciiString Message("\
|
||||||
// Setting Off all viewer active lights\n\
|
// Setting Off all viewer active lights\n\
|
||||||
V3d_ListOfLight lights;\n\
|
TColStd_ListOfTransient lights;\n\
|
||||||
for (V3d_ListOfLightIterator anIter = myView->Viewer()->ActiveLightIterator(); anIter.More(); anIter.Next())\n\
|
for(myView->Viewer()->InitActiveLights(); myView->Viewer()->MoreActiveLights(); myView->Viewer()->NextActiveLights())\n\
|
||||||
{\n\
|
{\n\
|
||||||
lights.Append (anIter.Value());\n\
|
lights.Append(myView->Viewer()->ActiveLight());\n\
|
||||||
}\n\
|
}\n\
|
||||||
V3d_ListOfLightIterator itrLights(lights);\n\
|
TColStd_ListIteratorOfListOfTransient itrLights(lights);\n\
|
||||||
for (; itrLights.More(); itrLights.Next())\n\
|
for (; itrLights.More(); itrLights.Next())\n\
|
||||||
{\n\
|
{\n\
|
||||||
myView->Viewer()->SetLightOff (itrLights.Value())\n\
|
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());\n\
|
||||||
|
myView->Viewer()->SetLightOff(light);\n\
|
||||||
}\n\
|
}\n\
|
||||||
\n\
|
\n\
|
||||||
// Setting Off all view active lights\n\
|
// Setting Off all view active lights\n\
|
||||||
lights.Clear();\n\
|
lights.Clear();\n\
|
||||||
for (V3d_ListOfLightIterator anIter = myView->ActiveLightIterator(); anIter.More(); anIter.Next())\n\
|
for(myView->InitActiveLights(); myView->MoreActiveLights(); myView->NextActiveLights())\n\
|
||||||
{\n\
|
{\n\
|
||||||
lights.Append (anIter.Value());\n\
|
lights.Append(myView->ActiveLight());\n\
|
||||||
}\n\
|
}\n\
|
||||||
itrLights.Initialize(lights);\n\
|
itrLights.Initialize(lights);\n\
|
||||||
for (; itrLights.More(); itrLights.Next())\n\
|
for (; itrLights.More(); itrLights.Next())\n\
|
||||||
{\n\
|
{\n\
|
||||||
myView->SetLightOff (itrLights.Value());\n\
|
Handle(V3d_Light) light = Handle(V3d_Light)::DownCast(itrLights.Value());\n\
|
||||||
|
myView->SetLightOff(light);\n\
|
||||||
}\n\
|
}\n\
|
||||||
\n\
|
\n\
|
||||||
myView->Viewer()->SetDefaultLights();// Setting the default lights on\n\
|
myView->Viewer()->SetDefaultLights();// Setting the default lights on\n\
|
||||||
|
@@ -413,7 +413,8 @@ void CTriangulationDoc::OnDumpView()
|
|||||||
pView->UpdateWindow();
|
pView->UpdateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(V3d_View) aView = myViewer->ActiveViews().First();
|
myViewer->InitActiveViews();
|
||||||
|
Handle(V3d_View) aView = myViewer->ActiveView();
|
||||||
ExportView (aView);
|
ExportView (aView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -230,7 +230,8 @@ void COCCDemoDoc::OnDumpView()
|
|||||||
pView->UpdateWindow();
|
pView->UpdateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(V3d_View) aView = myViewer->ActiveViews().First();
|
myViewer->InitActiveViews();
|
||||||
|
Handle(V3d_View) aView = myViewer->ActiveView();
|
||||||
ExportView (aView);
|
ExportView (aView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -489,7 +489,8 @@ void OCC_3dBaseDoc::OnUpdateV3dButtons (CCmdUI* pCmdUI)
|
|||||||
// Common function to change raytracing params and redraw view
|
// Common function to change raytracing params and redraw view
|
||||||
void OCC_3dBaseDoc::OnObjectRayTracingAction()
|
void OCC_3dBaseDoc::OnObjectRayTracingAction()
|
||||||
{
|
{
|
||||||
Handle(V3d_View) aView = myAISContext->CurrentViewer()->ActiveViews().First();
|
myAISContext->CurrentViewer()->InitActiveViews();
|
||||||
|
Handle(V3d_View) aView = myAISContext->CurrentViewer()->ActiveView();
|
||||||
Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
|
Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
|
||||||
if (myRayTracingIsOn)
|
if (myRayTracingIsOn)
|
||||||
aParams.Method = Graphic3d_RM_RAYTRACING;
|
aParams.Method = Graphic3d_RM_RAYTRACING;
|
||||||
|
@@ -44,7 +44,7 @@ public:
|
|||||||
virtual void Unmap() const {}
|
virtual void Unmap() const {}
|
||||||
|
|
||||||
//! Applies the resizing to the window <me>
|
//! Applies the resizing to the window <me>
|
||||||
virtual Aspect_TypeOfResize DoResize() { return Aspect_TOR_UNKNOWN; }
|
virtual Aspect_TypeOfResize DoResize() const { return Aspect_TOR_UNKNOWN; }
|
||||||
|
|
||||||
//! Apply the mapping change to the window <me>
|
//! Apply the mapping change to the window <me>
|
||||||
virtual Standard_Boolean DoMapping() const { return Standard_True; }
|
virtual Standard_Boolean DoMapping() const { return Standard_True; }
|
||||||
|
@@ -81,7 +81,7 @@ void OcctWindow::Unmap() const
|
|||||||
// function : DoResize
|
// function : DoResize
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
Aspect_TypeOfResize OcctWindow::DoResize()
|
Aspect_TypeOfResize OcctWindow::DoResize() const
|
||||||
{
|
{
|
||||||
int aMask = 0;
|
int aMask = 0;
|
||||||
Aspect_TypeOfResize aMode = Aspect_TOR_UNKNOWN;
|
Aspect_TypeOfResize aMode = Aspect_TOR_UNKNOWN;
|
||||||
@@ -126,10 +126,10 @@ Aspect_TypeOfResize OcctWindow::DoResize()
|
|||||||
break;
|
break;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
myXLeft = myWidget->rect().left();
|
*( ( Standard_Integer* )&myXLeft ) = myWidget->rect().left();
|
||||||
myXRight = myWidget->rect().right();
|
*( ( Standard_Integer* )&myXRight ) = myWidget->rect().right();
|
||||||
myYTop = myWidget->rect().top();
|
*( ( Standard_Integer* )&myYTop ) = myWidget->rect().top();
|
||||||
myYBottom = myWidget->rect().bottom();
|
*( ( Standard_Integer* )&myYBottom) = myWidget->rect().bottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
return aMode;
|
return aMode;
|
||||||
|
@@ -51,7 +51,7 @@ public:
|
|||||||
virtual Aspect_Drawable NativeParentHandle() const;
|
virtual Aspect_Drawable NativeParentHandle() const;
|
||||||
|
|
||||||
//! Applies the resizing to the window <me>
|
//! Applies the resizing to the window <me>
|
||||||
virtual Aspect_TypeOfResize DoResize();
|
virtual Aspect_TypeOfResize DoResize() const;
|
||||||
|
|
||||||
//! Returns True if the window <me> is opened
|
//! Returns True if the window <me> is opened
|
||||||
//! and False if the window is closed.
|
//! and False if the window is closed.
|
||||||
|
@@ -276,7 +276,7 @@ blend result _model 2 _model_161
|
|||||||
# Show result
|
# Show result
|
||||||
pload VISUALIZATION
|
pload VISUALIZATION
|
||||||
vinit Driver1/Viewer1/View1
|
vinit Driver1/Viewer1/View1
|
||||||
vbackground -color C8C8FF
|
vbackground -color 0.784314 0.784314 1
|
||||||
vdisplay -dispMode 1 result
|
vdisplay -dispMode 1 result
|
||||||
vfit
|
vfit
|
||||||
vaspects result -setFaceBoundaryDraw 1 -mostContinuity c2
|
vaspects result -setFaceBoundaryDraw 1 -mostContinuity c2
|
||||||
|
@@ -262,7 +262,7 @@ unifysamedom result p_1
|
|||||||
# Show result
|
# Show result
|
||||||
pload VISUALIZATION
|
pload VISUALIZATION
|
||||||
vinit Driver1/Viewer1/View1
|
vinit Driver1/Viewer1/View1
|
||||||
vbackground -color C8C8FF
|
vbackground -color 0.784314 0.784314 1
|
||||||
vdisplay -dispMode 1 result
|
vdisplay -dispMode 1 result
|
||||||
vfit
|
vfit
|
||||||
vaspects result -setFaceBoundaryDraw 1
|
vaspects result -setFaceBoundaryDraw 1
|
||||||
|
@@ -68,18 +68,18 @@ vlight add directional direction 0 -10 0 head 1 color white
|
|||||||
vdisplay b1 b2 b3 b4 b5 b6 b7 b8 b9 b10
|
vdisplay b1 b2 b3 b4 b5 b6 b7 b8 b9 b10
|
||||||
|
|
||||||
# set colors like in boxes of on OCC logo
|
# set colors like in boxes of on OCC logo
|
||||||
vsetcolor b1 DD0029
|
vsetcolor b1 0.8671875 0 0.16015625
|
||||||
vsetcolor b2 F6DD00
|
vsetcolor b2 0.96484375 0.8671875 0
|
||||||
vsetcolor b3 98F918
|
vsetcolor b3 0.609375 0.97734375 0.09375
|
||||||
vsetcolor b4 E9007A
|
vsetcolor b4 0.90234375 0 0.48046875
|
||||||
vsetcolor b5 007ABC
|
vsetcolor b5 0 0.48046875 0.73828125
|
||||||
vsetcolor b6 93007A
|
vsetcolor b6 0.578125 0 0.48046875
|
||||||
vsetcolor b7 EE9800
|
vsetcolor b7 0.93359375 0.609375 0
|
||||||
vsetcolor b8 00B489
|
vsetcolor b8 0 0.70703125 0.9296875
|
||||||
vsetcolor b9 00A47A
|
vsetcolor b9 0 0.64453125 0.48046875
|
||||||
vsetcolor b10 007ABC
|
vsetcolor b10 0 0.48046875 0.73828125
|
||||||
|
|
||||||
# set material to plastic for better look
|
# set material to plastic for better look
|
||||||
for {set i 1} {$i <= 10} {incr i} {vsetmaterial b$i plastic}
|
for {set i 1} {$i <= 10} {incr i} {vsetmaterial b$i plastic}
|
||||||
|
|
||||||
vdrawtext label "Which\nbox\nis\ncloser\nto\nyou?" -pos 0 -6 -2 -color BLACK -halign left -valign bottom -angle 0 -zoom 0 -height 40
|
vdrawtext label "Which\nbox\nis\ncloser\nto\nyou?" -pos 0 -6 -2 -color 0 0 0 -halign left -valign bottom -angle 0 -zoom 0 -height 40
|
||||||
|
@@ -255,27 +255,27 @@ if [info exists i7_show_3dview] {
|
|||||||
vlight add directional direction 1 -1 -2 head 1
|
vlight add directional direction 1 -1 -2 head 1
|
||||||
|
|
||||||
vdisplay case
|
vdisplay case
|
||||||
vsetcolor case GRAY70
|
vsetcolor case 0.7 0.7 0.7
|
||||||
|
|
||||||
vdisplay title
|
vdisplay title
|
||||||
vsetcolor title GRAY10
|
vsetcolor title 0.1 0.1 0.1
|
||||||
|
|
||||||
# board is mostly yellow (edges, triangle markers)
|
# board is mostly yellow (edges, triangle markers)
|
||||||
foreach f [explode board f] { vdisplay $f; vsetcolor $f B3803D }
|
foreach f [explode board f] { vdisplay $f; vsetcolor $f 0.7 0.5 0.3 }
|
||||||
# top and bottom faces are light-green (outside) and dark-green (inside)
|
# top and bottom faces are light-green (outside) and dark-green (inside)
|
||||||
vsetcolor board_4 00998C
|
vsetcolor board_4 0 0.6 0.55
|
||||||
vsetcolor board_5 00998C
|
vsetcolor board_5 0 0.6 0.55
|
||||||
vsetcolor board_12 004D54
|
vsetcolor board_12 0 0.3 0.33
|
||||||
vsetcolor board_14 004D54
|
vsetcolor board_14 0 0.3 0.33
|
||||||
|
|
||||||
vdisplay rpads
|
vdisplay rpads
|
||||||
vsetcolor rpads B39966
|
vsetcolor rpads 0.7 0.6 0.4
|
||||||
|
|
||||||
vdisplay bpads
|
vdisplay bpads
|
||||||
vsetcolor bpads B39966
|
vsetcolor bpads 0.7 0.6 0.4
|
||||||
|
|
||||||
vdisplay brpk
|
vdisplay brpk
|
||||||
vsetcolor brpk 80664D
|
vsetcolor brpk 0.5 0.4 0.3
|
||||||
|
|
||||||
donly board case rpads brpk; fit
|
donly board case rpads brpk; fit
|
||||||
}
|
}
|
||||||
@@ -287,17 +287,17 @@ pload OCAF XDE
|
|||||||
NewDocument D MDTV-XCAF
|
NewDocument D MDTV-XCAF
|
||||||
|
|
||||||
SetName D [XAddShape D board 0] "Board"
|
SetName D [XAddShape D board 0] "Board"
|
||||||
foreach f [explode board f] { XSetColor D $f B3803D }
|
foreach f [explode board f] { XSetColor D $f 0.7 0.5 0.3 }
|
||||||
XSetColor D board_4 00998C
|
XSetColor D board_4 0 0.6 0.55
|
||||||
XSetColor D board_5 00998C
|
XSetColor D board_5 0 0.6 0.55
|
||||||
XSetColor D board_12 004D54
|
XSetColor D board_12 0 0.3 0.33
|
||||||
XSetColor D board_14 004D54
|
XSetColor D board_14 0 0.3 0.33
|
||||||
|
|
||||||
SetName D [XAddShape D case 0] "Case"
|
SetName D [XAddShape D case 0] "Case"
|
||||||
XSetColor D case GRAY70
|
XSetColor D case 0.7 0.7 0.7
|
||||||
|
|
||||||
SetName D [XAddShape D title 0] "Case title"
|
SetName D [XAddShape D title 0] "Case title"
|
||||||
XSetColor D title GRAY10
|
XSetColor D title 0.1 0.1 0.1
|
||||||
|
|
||||||
SetName D [XAddShape D rpads 1] "Top side contact pads"
|
SetName D [XAddShape D rpads 1] "Top side contact pads"
|
||||||
SetName D [XAddShape D bpads 1] "Bottom contact pads"
|
SetName D [XAddShape D bpads 1] "Bottom contact pads"
|
||||||
@@ -306,17 +306,17 @@ SetName D [XFindShape D rpad] "Round pad"
|
|||||||
SetName D [XFindShape D Rpad] "Big round pad"
|
SetName D [XFindShape D Rpad] "Big round pad"
|
||||||
SetName D [XFindShape D spad_1] "Square pad 1"
|
SetName D [XFindShape D spad_1] "Square pad 1"
|
||||||
SetName D [XFindShape D spad_2] "Square pad 2"
|
SetName D [XFindShape D spad_2] "Square pad 2"
|
||||||
XSetColor D rpad B39966
|
XSetColor D rpad 0.7 0.6 0.4
|
||||||
XSetColor D Rpad B39966
|
XSetColor D Rpad 0.7 0.6 0.4
|
||||||
XSetColor D bpad B39966
|
XSetColor D bpad 0.7 0.6 0.4
|
||||||
XSetColor D spad_1 B39966
|
XSetColor D spad_1 0.7 0.6 0.4
|
||||||
XSetColor D spad_2 B39966
|
XSetColor D spad_2 0.7 0.6 0.4
|
||||||
|
|
||||||
SetName D [XAddShape D brpk 1] "Bottom packages"
|
SetName D [XAddShape D brpk 1] "Bottom packages"
|
||||||
SetName D [XFindShape D rpk] "Bottom package"
|
SetName D [XFindShape D rpk] "Bottom package"
|
||||||
XSetColor D rpk1 GRAY70
|
XSetColor D rpk1 0.7 0.7 0.7
|
||||||
XSetColor D rpk2 80664D
|
XSetColor D rpk2 0.5 0.4 0.3
|
||||||
XSetColor D rpk3 GRAY70
|
XSetColor D rpk3 0.7 0.7 0.7
|
||||||
|
|
||||||
XShow D
|
XShow D
|
||||||
vlight clear
|
vlight clear
|
||||||
|
@@ -36,7 +36,9 @@ set anArrAngle [expr 3.14 * 12.0 / 180.0]
|
|||||||
|
|
||||||
# Form dimension names list to set parameters with vdimparam command
|
# Form dimension names list to set parameters with vdimparam command
|
||||||
set aList {rd_1 rd_2 ad_1 ad_2 ad_3}
|
set aList {rd_1 rd_2 ad_1 ad_2 ad_3}
|
||||||
for {set i 1} {$i <= 10} {incr i} { lappend aList ld_$i }
|
for {set i 1} {$i <= 10} {incr i} {
|
||||||
|
lappend aList ld_$i
|
||||||
|
}
|
||||||
|
|
||||||
puts "Creating dimensions..."
|
puts "Creating dimensions..."
|
||||||
vdimension ld_1 -length -shapes bs_27 -plane xoy -color black -flyout -15
|
vdimension ld_1 -length -shapes bs_27 -plane xoy -color black -flyout -15
|
||||||
@@ -65,14 +67,29 @@ foreach i $aList {
|
|||||||
vfit
|
vfit
|
||||||
|
|
||||||
puts "Displaying exported shapes..."
|
puts "Displaying exported shapes..."
|
||||||
vdisplay -dispMode 1 a b
|
vdisplay a b
|
||||||
|
vsetdispmode a 1
|
||||||
|
vsetdispmode b 1
|
||||||
vaspects a -setmaterial steel
|
vaspects a -setmaterial steel
|
||||||
vaspects b -setmaterial bronze
|
vaspects b -setmaterial bronze
|
||||||
|
|
||||||
puts "Clipping shapes for better view..."
|
puts "Clipping shapes for better view..."
|
||||||
|
vclipplane create pa
|
||||||
|
vclipplane change pa equation 0 0 1 0
|
||||||
|
vclipplane change pa capping on
|
||||||
|
vclipplane change pa capping color 0.9 0.9 0.9
|
||||||
|
vclipplane set pa object a
|
||||||
|
|
||||||
vclipplane pa -set a -equation 0 0 1 0 -capping on -color GRAY90 -texName $aHatch -texScale 0.05 -0.05
|
vclipplane create pb
|
||||||
vclipplane pb -set b -equation 0 0 1 0 -capping on -color GOLD -texName $aHatch -texScale 0.05 -0.05
|
vclipplane change pb equation 0 0 1 0
|
||||||
|
vclipplane change pb capping on
|
||||||
|
vclipplane change pb capping color 1.0 0.8 0.0
|
||||||
|
vclipplane set pb object b
|
||||||
|
|
||||||
|
vclipplane change pa capping texname $aHatch
|
||||||
|
vclipplane change pa capping texscale 0.05 -0.05
|
||||||
|
vclipplane change pb capping texname $aHatch
|
||||||
|
vclipplane change pb capping texscale 0.05 0.05
|
||||||
|
|
||||||
vbottom
|
vbottom
|
||||||
vrotate -0.3 -0.3 0
|
vrotate -0.3 -0.3 0
|
||||||
|
@@ -77,13 +77,14 @@ SetName D $main "OCC Logo 2019"
|
|||||||
SetName D [XFindShape D sb] "Core"
|
SetName D [XFindShape D sb] "Core"
|
||||||
SetName D [XFindShape D tp] "Loop"
|
SetName D [XFindShape D tp] "Loop"
|
||||||
SetName D [XFindShape D rs] "Connector"
|
SetName D [XFindShape D rs] "Connector"
|
||||||
XSetColor D sb FF3652
|
XSetColor D sb 1 0.21 0.32
|
||||||
XSetColor D tp 00AADA
|
XSetColor D tp 0 0.667 0.855
|
||||||
XSetColor D rs 0073B0
|
XSetColor D rs 0 0.45 0.69
|
||||||
|
|
||||||
# display
|
# display
|
||||||
vinit View1
|
vinit
|
||||||
vbackground -color WHITE
|
vsetcolorbg 1 1 1
|
||||||
XDisplay -dispMode 1 D
|
vsetdispmode 1
|
||||||
|
XDisplay D
|
||||||
vtop
|
vtop
|
||||||
vfit
|
vfit
|
||||||
|
@@ -56,7 +56,7 @@ for { set aMarkerType 0 } { $aMarkerType <= 13 } { incr aMarkerType } {
|
|||||||
set aRow [expr $aMarkerType - 7]
|
set aRow [expr $aMarkerType - 7]
|
||||||
set aCol 5
|
set aCol 5
|
||||||
set aName [lindex $aMarkerTypeNames $aMarkerType]
|
set aName [lindex $aMarkerTypeNames $aMarkerType]
|
||||||
vdrawtext "$aName" "$aName" -pos 0 [expr $aRow + 0.5] 0 -color 7FFFFF -halign center -valign center -angle 000 -zoom 0 -height 12 -aspect bold -font $aLabelFont -noupdate
|
vdrawtext "$aName" "$aName" -pos 0 [expr $aRow + 0.5] 0 -color 0.5 1.0 1.0 -halign center -valign center -angle 000 -zoom 0 -height 12 -aspect bold -font $aLabelFont -noupdate
|
||||||
vdisplay -top -noupdate "$aName"
|
vdisplay -top -noupdate "$aName"
|
||||||
if { $aMarkerType == 13 } {
|
if { $aMarkerType == 13 } {
|
||||||
vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom1
|
vmarkerstest m${aMarkerType}_${aCol} $aCol $aRow 0 PointsOnSide=1 FileName=$aCustom1
|
||||||
|
@@ -4,22 +4,36 @@
|
|||||||
#Title: Material properties in viewer
|
#Title: Material properties in viewer
|
||||||
|
|
||||||
set THE_MATERIALS {brass bronze copper gold jade neon_phc pewter obsidian plaster plastic satin silver steel stone chrome aluminium water glass diamond charcoal}
|
set THE_MATERIALS {brass bronze copper gold jade neon_phc pewter obsidian plaster plastic satin silver steel stone chrome aluminium water glass diamond charcoal}
|
||||||
set THE_COLORS {default red green blue}
|
set THE_COLORS {default red green blue1}
|
||||||
set THE_ROW_DIST 35
|
set THE_ROW_DIST 35
|
||||||
|
|
||||||
proc drawLabels {} {
|
proc drawLabels {} {
|
||||||
set x 20
|
set x 20
|
||||||
set y 15
|
set y 15
|
||||||
|
set r 0.098
|
||||||
|
set g 0.098
|
||||||
|
set b 0.098
|
||||||
foreach aMatIter $::THE_MATERIALS {
|
foreach aMatIter $::THE_MATERIALS {
|
||||||
vdrawtext "$aMatIter" "$aMatIter" -pos $x $y 0 -color GRAY10 -halign right -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
|
vdrawtext "$aMatIter" "$aMatIter" -pos $x $y 0 -color $r $g $b -halign right -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
|
||||||
incr y 10
|
incr y 10
|
||||||
}
|
}
|
||||||
set x 40
|
set x 40
|
||||||
set y 5
|
set y 5
|
||||||
foreach aColIter $::THE_COLORS {
|
foreach aColIter $::THE_COLORS {
|
||||||
set aLabColor "$aColIter"
|
if { $aColIter == "red" } {
|
||||||
if { "$aColIter" == "default" } { set aLabColor BLACK }
|
set r 1.0
|
||||||
vdrawtext "$aColIter" "$aColIter" -pos $x $y 0 -color "$aLabColor" -halign center -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
|
set g 0.0
|
||||||
|
set b 0
|
||||||
|
} elseif { $aColIter == "green" } {
|
||||||
|
set r 0.0
|
||||||
|
set g 1.0
|
||||||
|
set b 0.0
|
||||||
|
} elseif { $aColIter == "blue1" } {
|
||||||
|
set r 0.0
|
||||||
|
set g 0.0
|
||||||
|
set b 1.0
|
||||||
|
}
|
||||||
|
vdrawtext "$aColIter" "$aColIter" -pos $x $y 0 -color $r $g $b -halign center -valign center -angle 000 -zoom 0 -height 14 -aspect regular -font Arial
|
||||||
incr x $::THE_ROW_DIST
|
incr x $::THE_ROW_DIST
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,7 +69,7 @@ vclose ALL
|
|||||||
vinit View1 w=768 h=768
|
vinit View1 w=768 h=768
|
||||||
vtop
|
vtop
|
||||||
vglinfo
|
vglinfo
|
||||||
vbackground -gradient B4C8FF B4B4B4 -gradientMode VERTICAL
|
vbackground -gradient 0.705882 0.784314 1 0.705882 0.705882 0.705882 -gradientMode VERTICAL
|
||||||
|
|
||||||
vlight -change 0 -dir 0.577 -0.577 -0.577
|
vlight -change 0 -dir 0.577 -0.577 -0.577
|
||||||
vrenderparams -msaa 8
|
vrenderparams -msaa 8
|
||||||
|
@@ -46,17 +46,18 @@ NewDocument D
|
|||||||
XAddShape D body_1
|
XAddShape D body_1
|
||||||
XAddShape D core_1
|
XAddShape D core_1
|
||||||
|
|
||||||
for {set i 1} {$i <= 26} {incr i} {XSetColor D body_1_$i BLUE}
|
#XSetColor D body_1 0. 0. 1.
|
||||||
XSetColor D body_1_1 E68066
|
for {set i 1} {$i <= 26} {incr i} {XSetColor D body_1_$i 0. 0. 1.}
|
||||||
XSetColor D body_1_9 E68066
|
XSetColor D body_1_1 0.9 0.5 0.4
|
||||||
for {set i 10} {$i <= 22} {incr i} {XSetColor D body_1_$i 99B300}
|
XSetColor D body_1_9 0.9 0.5 0.4
|
||||||
XSetColor D core_1 1A1AFF
|
for {set i 10} {$i <= 22} {incr i} {XSetColor D body_1_$i 0.6 0.7 0.0}
|
||||||
foreach ff [explode core_1 f] { XSetColor D $ff 1A1AFF ; puts "set color $ff" }
|
XSetColor D core_1 0.1 0.1 1.
|
||||||
|
foreach ff [explode core_1 f] { XSetColor D $ff 0.1 0.1 1. ; puts "set color $ff" }
|
||||||
|
|
||||||
|
XShow D
|
||||||
|
|
||||||
vclear
|
|
||||||
vinit View1
|
|
||||||
XDisplay -dispMode 1 D -explore
|
|
||||||
vfit
|
vfit
|
||||||
|
vsetdispmode 1
|
||||||
vrenderparams -msaa 8
|
vrenderparams -msaa 8
|
||||||
vbackground -color WHITE
|
vbackground -color WHITE
|
||||||
|
|
||||||
|
@@ -28,20 +28,19 @@ SetName D [XFindShape D link]:2 "Nut instance 1"
|
|||||||
SetName D [XFindShape D link]:3 "Nut instance 2"
|
SetName D [XFindShape D link]:3 "Nut instance 2"
|
||||||
|
|
||||||
puts "- Pin will be white"
|
puts "- Pin will be white"
|
||||||
XSetColor D [XFindShape D pin] WHITE
|
XSetColor D [XFindShape D pin] 1 1 1
|
||||||
puts "- Nut itself will be dark gray"
|
puts "- Nut itself will be dark gray"
|
||||||
XSetColor D [XFindShape D nut] GRAY10
|
XSetColor D [XFindShape D nut] 0.1 0.1 0.1
|
||||||
puts "- Nut instance #1 will be red"
|
puts "- Nut instance #1 will be red"
|
||||||
XSetColor D [XFindShape D link]:2 RED
|
XSetColor D [XFindShape D link]:2 1 0 0
|
||||||
puts "- Nut instance #2 will be green"
|
puts "- Nut instance #2 will be green"
|
||||||
XSetColor D [XFindShape D link]:3 GREEN
|
XSetColor D [XFindShape D link]:3 0 1 0
|
||||||
|
|
||||||
puts "Starting DF browser..."
|
puts "Starting DF browser..."
|
||||||
DFBrowse D
|
DFBrowse D
|
||||||
puts "Expand the document tree to see its structure and assigned names"
|
puts "Expand the document tree to see its structure and assigned names"
|
||||||
|
|
||||||
puts "Showing assembly in 3d view..."
|
puts "Showing assembly in 3d view..."
|
||||||
vclear
|
XShow D
|
||||||
vinit View1
|
|
||||||
XDisplay -dispMode 1 D -explore
|
|
||||||
vfit
|
vfit
|
||||||
|
vsetdispmode 1
|
||||||
|
2
samples/webgl/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
/build
|
|
||||||
/work
|
|
@@ -1,66 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.2)
|
|
||||||
|
|
||||||
project(occt-webgl-sample)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
set(APP_VERSION_MAJOR 1)
|
|
||||||
set(APP_VERSION_MINOR 0)
|
|
||||||
set(APP_TARGET occt-webgl-sample)
|
|
||||||
|
|
||||||
# customize build
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_WEBGL2=1")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1")
|
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s SAFE_HEAP=1")
|
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s NO_EXIT_RUNTIME=1")
|
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s TOTAL_MEMORY=16MB")
|
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ABORTING_MALLOC=0")
|
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s FORCE_FILESYSTEM=1")
|
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --preload-file myFile")
|
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
|
|
||||||
file(GLOB SOURCES
|
|
||||||
*.h
|
|
||||||
*.cpp
|
|
||||||
)
|
|
||||||
source_group ("Headers" FILES
|
|
||||||
WasmOcctView.h)
|
|
||||||
source_group ("Sources" FILES
|
|
||||||
WasmOcctView.cpp
|
|
||||||
main.cpp)
|
|
||||||
|
|
||||||
# FreeType
|
|
||||||
find_package(freetype REQUIRED NO_DEFAULT_PATH)
|
|
||||||
if(freetype_FOUND)
|
|
||||||
message (STATUS "Using FreeType from \"${freetype_DIR}\"" )
|
|
||||||
else()
|
|
||||||
message(WARNING "Could not find FreeType, please set freetype_DIR variable." )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Open CASCADE Technology
|
|
||||||
find_package(OpenCASCADE REQUIRED NO_DEFAULT_PATH)
|
|
||||||
if(OpenCASCADE_FOUND)
|
|
||||||
message (STATUS "Using OpenCASCADE from \"${OpenCASCADE_DIR}\"" )
|
|
||||||
INCLUDE_DIRECTORIES(${OpenCASCADE_INCLUDE_DIR})
|
|
||||||
LINK_DIRECTORIES(${OpenCASCADE_LIBRARY_DIR})
|
|
||||||
else()
|
|
||||||
message(WARNING "Could not find OpenCASCADE, please set OpenCASCADE_DIR variable." )
|
|
||||||
set(OCCT_LIBRARY_DIR)
|
|
||||||
set(OCCT_BIN_DIR)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(OpenCASCADE_LIBS TKRWMesh TKBinXCAF TKBin TKBinL TKOpenGl TKXCAF TKVCAF TKCAF TKV3d TKHLR TKMesh TKService TKShHealing TKPrim TKTopAlgo TKGeomAlgo TKBRep TKGeomBase TKG3d TKG2d TKMath TKLCAF TKCDF TKernel)
|
|
||||||
|
|
||||||
add_executable(${APP_TARGET} ${SOURCES})
|
|
||||||
target_link_libraries(
|
|
||||||
${APP_TARGET}
|
|
||||||
${OpenCASCADE_LIBS}
|
|
||||||
freetype
|
|
||||||
)
|
|
||||||
set_target_properties(${APP_TARGET} PROPERTIES LINK_FLAGS "-s EXPORTED_FUNCTIONS=['_main','_onFileDataRead'] -s EXTRA_EXPORTED_RUNTIME_METHODS=['ccall','cwrap']")
|
|
||||||
|
|
||||||
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}")
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.wasm DESTINATION ${CMAKE_INSTALL_PREFIX})
|
|
||||||
install(FILES occt-webgl-sample.html DESTINATION ${CMAKE_INSTALL_PREFIX})
|
|
||||||
install(FILES ${OpenCASCADE_RESOURCE_DIR}/DrawResources/OCC_logo.png DESTINATION ${CMAKE_INSTALL_PREFIX})
|
|
||||||
install(FILES ${OpenCASCADE_RESOURCE_DIR}/DrawResources/lamp.ico DESTINATION ${CMAKE_INSTALL_PREFIX})
|
|
@@ -1,28 +0,0 @@
|
|||||||
OCCT WebGL Viewer sample {#occt_samples_webgl}
|
|
||||||
==================
|
|
||||||
|
|
||||||
This sample demonstrates simple way of using OCCT libraries in Web application written in C++ and translated into WebAssembly module using Emscripten SDK (emsdk):
|
|
||||||
https://emscripten.org/
|
|
||||||
|
|
||||||
Sample consists of the Open CASCADE 3D Viewer with a button for opening a model in BREP format.
|
|
||||||
The sample requires a WebGL 2.0 capable browser supporting WebAssembly 1.0 (Wasm).
|
|
||||||
|
|
||||||
Installation and configuration:
|
|
||||||
1. Install Emscripten SDK and activate minimal configuration (Python, Java and CLang) following *emsdk* documentation. Activate also MinGW when building sample on Windows host.
|
|
||||||
2. Build (using *emsdk*) or download FreeType static library.
|
|
||||||
3. Configure CMake for building Open CASCADE Technology (OCCT) static libraries (BUILD_LIBRARY_TYPE="Static").
|
|
||||||
For this, activate *emsdk* command prompt, configure CMake for building OCCT using cross-compilation toolchain, disable *BUILD_MODULE_Draw*.
|
|
||||||
4. Perform building and installation steps.
|
|
||||||
~~~~~
|
|
||||||
> ${EMSDK}/fastcomp/emscripten/cmake/Modules/Platform/Emscripten.cmake
|
|
||||||
~~~~~
|
|
||||||
5. Configure CMake for building this WebGL sample using *emsdk* with paths to OCCT and FreeType. Perform building and installation steps.
|
|
||||||
6. Copy data/occ/Ball.brep from OCCT into "samples" folder within WebGL sample installation path.
|
|
||||||
7. Navigate to installation folder and start web server from it; Python coming with *emsdk* can be used for this purpose:
|
|
||||||
~~~~~
|
|
||||||
> python -m SimpleHTTPServer 8080
|
|
||||||
~~~~~
|
|
||||||
8. Open compatible browser and enter path taking into account your web server settings:
|
|
||||||
~~~~~
|
|
||||||
> http://localhost:8080/occt-webgl-sample.html
|
|
||||||
~~~~~
|
|
@@ -1,678 +0,0 @@
|
|||||||
// Copyright (c) 2019 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 "WasmOcctView.h"
|
|
||||||
|
|
||||||
#include "WasmVKeys.h"
|
|
||||||
|
|
||||||
#include <AIS_Shape.hxx>
|
|
||||||
#include <AIS_ViewCube.hxx>
|
|
||||||
#include <Aspect_Handle.hxx>
|
|
||||||
#include <Aspect_DisplayConnection.hxx>
|
|
||||||
#include <Aspect_NeutralWindow.hxx>
|
|
||||||
#include <Message.hxx>
|
|
||||||
#include <Message_Messenger.hxx>
|
|
||||||
#include <OpenGl_GraphicDriver.hxx>
|
|
||||||
#include <Prs3d_DatumAspect.hxx>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#define THE_CANVAS_ID "canvas"
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
EM_JS(int, jsCanvasGetWidth, (), {
|
|
||||||
return canvas.width;
|
|
||||||
});
|
|
||||||
|
|
||||||
EM_JS(int, jsCanvasGetHeight, (), {
|
|
||||||
return canvas.height;
|
|
||||||
});
|
|
||||||
|
|
||||||
EM_JS(float, jsDevicePixelRatio, (), {
|
|
||||||
var aDevicePixelRatio = window.devicePixelRatio || 1;
|
|
||||||
return aDevicePixelRatio;
|
|
||||||
});
|
|
||||||
|
|
||||||
//! Return cavas size in pixels.
|
|
||||||
static Graphic3d_Vec2i jsCanvasSize()
|
|
||||||
{
|
|
||||||
return Graphic3d_Vec2i (jsCanvasGetWidth(), jsCanvasGetHeight());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : WasmOcctView
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
WasmOcctView::WasmOcctView()
|
|
||||||
: myDevicePixelRatio (1.0f),
|
|
||||||
myUpdateRequests (0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : ~WasmOcctView
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
WasmOcctView::~WasmOcctView()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : run
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
void WasmOcctView::run()
|
|
||||||
{
|
|
||||||
initWindow();
|
|
||||||
initViewer();
|
|
||||||
initDemoScene();
|
|
||||||
if (myView.IsNull())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
myView->MustBeResized();
|
|
||||||
myView->Redraw();
|
|
||||||
|
|
||||||
// There is no inifinite message loop, main() will return from here immediately.
|
|
||||||
// Tell that our Module should be left loaded and handle events through callbacks.
|
|
||||||
//emscripten_set_main_loop (redrawView, 60, 1);
|
|
||||||
//emscripten_set_main_loop (redrawView, -1, 1);
|
|
||||||
EM_ASM(Module['noExitRuntime'] = true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : initWindow
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
void WasmOcctView::initWindow()
|
|
||||||
{
|
|
||||||
myDevicePixelRatio = jsDevicePixelRatio();
|
|
||||||
myCanvasId = THE_CANVAS_ID;
|
|
||||||
const char* aTargetId = !myCanvasId.IsEmpty() ? myCanvasId.ToCString() : NULL;
|
|
||||||
const EM_BOOL toUseCapture = EM_TRUE;
|
|
||||||
emscripten_set_resize_callback (NULL, this, toUseCapture, onResizeCallback);
|
|
||||||
|
|
||||||
emscripten_set_mousedown_callback (NULL, this, toUseCapture, onMouseCallback);
|
|
||||||
emscripten_set_mouseup_callback (NULL, this, toUseCapture, onMouseCallback);
|
|
||||||
emscripten_set_mousemove_callback (NULL, this, toUseCapture, onMouseCallback);
|
|
||||||
emscripten_set_dblclick_callback (aTargetId, this, toUseCapture, onMouseCallback);
|
|
||||||
emscripten_set_click_callback (aTargetId, this, toUseCapture, onMouseCallback);
|
|
||||||
emscripten_set_mouseenter_callback (aTargetId, this, toUseCapture, onMouseCallback);
|
|
||||||
emscripten_set_mouseleave_callback (aTargetId, this, toUseCapture, onMouseCallback);
|
|
||||||
emscripten_set_wheel_callback (aTargetId, this, toUseCapture, onWheelCallback);
|
|
||||||
|
|
||||||
emscripten_set_touchstart_callback (aTargetId, this, toUseCapture, onTouchCallback);
|
|
||||||
emscripten_set_touchend_callback (aTargetId, this, toUseCapture, onTouchCallback);
|
|
||||||
emscripten_set_touchmove_callback (aTargetId, this, toUseCapture, onTouchCallback);
|
|
||||||
emscripten_set_touchcancel_callback(aTargetId, this, toUseCapture, onTouchCallback);
|
|
||||||
|
|
||||||
//emscripten_set_keypress_callback (NULL, this, toUseCapture, onKeyCallback);
|
|
||||||
emscripten_set_keydown_callback (NULL, this, toUseCapture, onKeyDownCallback);
|
|
||||||
emscripten_set_keyup_callback (NULL, this, toUseCapture, onKeyUpCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : dumpGlInfo
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
void WasmOcctView::dumpGlInfo (bool theIsBasic)
|
|
||||||
{
|
|
||||||
TColStd_IndexedDataMapOfStringString aGlCapsDict;
|
|
||||||
myView->DiagnosticInformation (aGlCapsDict, theIsBasic ? Graphic3d_DiagnosticInfo_Basic : Graphic3d_DiagnosticInfo_Complete);
|
|
||||||
if (theIsBasic)
|
|
||||||
{
|
|
||||||
TCollection_AsciiString aViewport;
|
|
||||||
aGlCapsDict.FindFromKey ("Viewport", aViewport);
|
|
||||||
aGlCapsDict.Clear();
|
|
||||||
aGlCapsDict.Add ("Viewport", aViewport);
|
|
||||||
}
|
|
||||||
aGlCapsDict.Add ("Display scale", TCollection_AsciiString(myDevicePixelRatio));
|
|
||||||
|
|
||||||
// beautify output
|
|
||||||
{
|
|
||||||
TCollection_AsciiString* aGlVer = aGlCapsDict.ChangeSeek ("GLversion");
|
|
||||||
TCollection_AsciiString* aGlslVer = aGlCapsDict.ChangeSeek ("GLSLversion");
|
|
||||||
if (aGlVer != NULL
|
|
||||||
&& aGlslVer != NULL)
|
|
||||||
{
|
|
||||||
*aGlVer = *aGlVer + " [GLSL: " + *aGlslVer + "]";
|
|
||||||
aGlslVer->Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TCollection_AsciiString anInfo;
|
|
||||||
for (TColStd_IndexedDataMapOfStringString::Iterator aValueIter (aGlCapsDict); aValueIter.More(); aValueIter.Next())
|
|
||||||
{
|
|
||||||
if (!aValueIter.Value().IsEmpty())
|
|
||||||
{
|
|
||||||
if (!anInfo.IsEmpty())
|
|
||||||
{
|
|
||||||
anInfo += "\n";
|
|
||||||
}
|
|
||||||
anInfo += aValueIter.Key() + ": " + aValueIter.Value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
::Message::DefaultMessenger()->Send (anInfo, Message_Warning);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : initPixelScaleRatio
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
void WasmOcctView::initPixelScaleRatio()
|
|
||||||
{
|
|
||||||
SetTouchToleranceScale (myDevicePixelRatio);
|
|
||||||
if (!myView.IsNull())
|
|
||||||
{
|
|
||||||
myView->ChangeRenderingParams().Resolution = (unsigned int )(96.0 * myDevicePixelRatio + 0.5);
|
|
||||||
}
|
|
||||||
if (!myContext.IsNull())
|
|
||||||
{
|
|
||||||
myContext->SetPixelTolerance (int(myDevicePixelRatio * 6.0));
|
|
||||||
if (!myViewCube.IsNull())
|
|
||||||
{
|
|
||||||
static const double THE_CUBE_SIZE = 60.0;
|
|
||||||
myViewCube->SetSize (myDevicePixelRatio * THE_CUBE_SIZE, false);
|
|
||||||
myViewCube->SetBoxFacetExtension (myViewCube->Size() * 0.15);
|
|
||||||
myViewCube->SetAxesPadding (myViewCube->Size() * 0.10);
|
|
||||||
myViewCube->SetFontHeight (THE_CUBE_SIZE * 0.16);
|
|
||||||
if (myViewCube->HasInteractiveContext())
|
|
||||||
{
|
|
||||||
myContext->Redisplay (myViewCube, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : initViewer
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
bool WasmOcctView::initViewer()
|
|
||||||
{
|
|
||||||
// Build with "--preload-file MyFontFile.ttf" option
|
|
||||||
// and register font in Font Manager to use custom font(s).
|
|
||||||
/*const char* aFontPath = "MyFontFile.ttf";
|
|
||||||
if (Handle(Font_SystemFont) aFont = Font_FontMgr::GetInstance()->CheckFont (aFontPath))
|
|
||||||
{
|
|
||||||
Font_FontMgr::GetInstance()->RegisterFont (aFont, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: font '") + aFontPath + "' is not found", Message_Fail);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
Handle(Aspect_DisplayConnection) aDisp;
|
|
||||||
Handle(OpenGl_GraphicDriver) aDriver = new OpenGl_GraphicDriver (aDisp, false);
|
|
||||||
aDriver->ChangeOptions().buffersNoSwap = true; // swap has no effect in WebGL
|
|
||||||
if (!aDriver->InitContext())
|
|
||||||
{
|
|
||||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: EGL initialization failed"), Message_Fail);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle(V3d_Viewer) aViewer = new V3d_Viewer (aDriver);
|
|
||||||
aViewer->SetComputedMode (false);
|
|
||||||
aViewer->SetDefaultShadingModel (Graphic3d_TOSM_FRAGMENT);
|
|
||||||
aViewer->SetDefaultLights();
|
|
||||||
aViewer->SetLightOn();
|
|
||||||
|
|
||||||
Handle(Aspect_NeutralWindow) aWindow = new Aspect_NeutralWindow();
|
|
||||||
Graphic3d_Vec2i aWinSize = jsCanvasSize();
|
|
||||||
if (aWinSize.x() < 10 || aWinSize.y() < 10)
|
|
||||||
{
|
|
||||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Warning: invalid canvas size"), Message_Warning);
|
|
||||||
}
|
|
||||||
aWindow->SetSize (aWinSize.x(), aWinSize.y());
|
|
||||||
|
|
||||||
myTextStyle = new Prs3d_TextAspect();
|
|
||||||
myTextStyle->SetFont (Font_NOF_ASCII_MONO);
|
|
||||||
myTextStyle->SetHeight (12);
|
|
||||||
myTextStyle->Aspect()->SetColor (Quantity_NOC_GRAY95);
|
|
||||||
myTextStyle->Aspect()->SetColorSubTitle (Quantity_NOC_BLACK);
|
|
||||||
myTextStyle->Aspect()->SetDisplayType (Aspect_TODT_SHADOW);
|
|
||||||
myTextStyle->Aspect()->SetTextFontAspect (Font_FA_Bold);
|
|
||||||
myTextStyle->Aspect()->SetTextZoomable (false);
|
|
||||||
myTextStyle->SetHorizontalJustification (Graphic3d_HTA_LEFT);
|
|
||||||
myTextStyle->SetVerticalJustification (Graphic3d_VTA_BOTTOM);
|
|
||||||
|
|
||||||
myView = new V3d_View (aViewer);
|
|
||||||
myView->SetImmediateUpdate (false);
|
|
||||||
myView->ChangeRenderingParams().Resolution = (unsigned int )(96.0 * myDevicePixelRatio + 0.5);
|
|
||||||
myView->ChangeRenderingParams().ToShowStats = true;
|
|
||||||
myView->ChangeRenderingParams().StatsTextAspect = myTextStyle->Aspect();
|
|
||||||
myView->ChangeRenderingParams().StatsTextHeight = (int )myTextStyle->Height();
|
|
||||||
myView->SetWindow (aWindow);
|
|
||||||
dumpGlInfo (false);
|
|
||||||
|
|
||||||
myContext = new AIS_InteractiveContext (aViewer);
|
|
||||||
initPixelScaleRatio();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : initDemoScene
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
void WasmOcctView::initDemoScene()
|
|
||||||
{
|
|
||||||
if (myContext.IsNull())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//myView->TriedronDisplay (Aspect_TOTP_LEFT_LOWER, Quantity_NOC_GOLD, 0.08, V3d_WIREFRAME);
|
|
||||||
|
|
||||||
myViewCube = new AIS_ViewCube();
|
|
||||||
// presentation parameters
|
|
||||||
initPixelScaleRatio();
|
|
||||||
myViewCube->SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_RIGHT_LOWER, Graphic3d_Vec2i (100, 100)));
|
|
||||||
myViewCube->Attributes()->SetDatumAspect (new Prs3d_DatumAspect());
|
|
||||||
myViewCube->Attributes()->DatumAspect()->SetTextAspect (myTextStyle);
|
|
||||||
// animation parameters
|
|
||||||
myViewCube->SetViewAnimation (myViewAnimation);
|
|
||||||
myViewCube->SetFixedAnimationLoop (false);
|
|
||||||
myViewCube->SetAutoStartAnimation (true);
|
|
||||||
myContext->Display (myViewCube, false);
|
|
||||||
|
|
||||||
// Build with "--preload-file MySampleFile.brep" option to load some shapes here.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : updateView
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
void WasmOcctView::updateView()
|
|
||||||
{
|
|
||||||
if (!myView.IsNull())
|
|
||||||
{
|
|
||||||
if (++myUpdateRequests == 1)
|
|
||||||
{
|
|
||||||
emscripten_async_call (onRedrawView, this, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : redrawView
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
void WasmOcctView::redrawView()
|
|
||||||
{
|
|
||||||
if (!myView.IsNull())
|
|
||||||
{
|
|
||||||
FlushViewEvents (myContext, myView, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : handleViewRedraw
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
void WasmOcctView::handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
|
|
||||||
const Handle(V3d_View)& theView)
|
|
||||||
{
|
|
||||||
myUpdateRequests = 0;
|
|
||||||
AIS_ViewController::handleViewRedraw (theCtx, theView);
|
|
||||||
if (myToAskNextFrame)
|
|
||||||
{
|
|
||||||
// ask more frames
|
|
||||||
++myUpdateRequests;
|
|
||||||
emscripten_async_call (onRedrawView, this, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : onResizeEvent
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
EM_BOOL WasmOcctView::onResizeEvent (int theEventType, const EmscriptenUiEvent* theEvent)
|
|
||||||
{
|
|
||||||
(void )theEventType; // EMSCRIPTEN_EVENT_RESIZE or EMSCRIPTEN_EVENT_CANVASRESIZED
|
|
||||||
(void )theEvent;
|
|
||||||
if (myView.IsNull())
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Handle(Aspect_NeutralWindow) aWindow = Handle(Aspect_NeutralWindow)::DownCast (myView->Window());
|
|
||||||
Graphic3d_Vec2i aWinSizeOld, aWinSizeNew (jsCanvasSize());
|
|
||||||
if (aWinSizeNew.x() < 10 || aWinSizeNew.y() < 10)
|
|
||||||
{
|
|
||||||
Message::DefaultMessenger()->Send (TCollection_AsciiString ("Warning: invalid canvas size"), Message_Warning);
|
|
||||||
}
|
|
||||||
aWindow->Size (aWinSizeOld.x(), aWinSizeOld.y());
|
|
||||||
const float aPixelRatio = jsDevicePixelRatio();
|
|
||||||
if (aWinSizeNew != aWinSizeOld
|
|
||||||
|| aPixelRatio != myDevicePixelRatio)
|
|
||||||
{
|
|
||||||
if (myDevicePixelRatio != aPixelRatio)
|
|
||||||
{
|
|
||||||
myDevicePixelRatio = aPixelRatio;
|
|
||||||
initPixelScaleRatio();
|
|
||||||
}
|
|
||||||
aWindow->SetSize (aWinSizeNew.x(), aWinSizeNew.y());
|
|
||||||
myView->MustBeResized();
|
|
||||||
myView->Invalidate();
|
|
||||||
myView->Redraw();
|
|
||||||
dumpGlInfo (true);
|
|
||||||
}
|
|
||||||
return EM_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : onMouseEvent
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
EM_BOOL WasmOcctView::onMouseEvent (int theEventType, const EmscriptenMouseEvent* theEvent)
|
|
||||||
{
|
|
||||||
if (myView.IsNull())
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Graphic3d_Vec2i aWinSize;
|
|
||||||
myView->Window()->Size (aWinSize.x(), aWinSize.y());
|
|
||||||
const Graphic3d_Vec2i aNewPos = convertPointToBacking (Graphic3d_Vec2i (theEvent->canvasX, theEvent->canvasY));
|
|
||||||
Aspect_VKeyFlags aFlags = 0;
|
|
||||||
if (theEvent->ctrlKey == EM_TRUE) { aFlags |= Aspect_VKeyFlags_CTRL; }
|
|
||||||
if (theEvent->shiftKey == EM_TRUE) { aFlags |= Aspect_VKeyFlags_SHIFT; }
|
|
||||||
if (theEvent->altKey == EM_TRUE) { aFlags |= Aspect_VKeyFlags_ALT; }
|
|
||||||
if (theEvent->metaKey == EM_TRUE) { aFlags |= Aspect_VKeyFlags_META; }
|
|
||||||
|
|
||||||
const bool isEmulated = false;
|
|
||||||
const Aspect_VKeyMouse aButtons = WasmVKeys_MouseButtonsFromNative (theEvent->buttons);
|
|
||||||
switch (theEventType)
|
|
||||||
{
|
|
||||||
case EMSCRIPTEN_EVENT_MOUSEMOVE:
|
|
||||||
{
|
|
||||||
if ((aNewPos.x() < 0 || aNewPos.x() > aWinSize.x()
|
|
||||||
|| aNewPos.y() < 0 || aNewPos.y() > aWinSize.y())
|
|
||||||
&& PressedMouseButtons() == Aspect_VKeyMouse_NONE)
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
if (UpdateMousePosition (aNewPos, aButtons, aFlags, isEmulated))
|
|
||||||
{
|
|
||||||
updateView();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EMSCRIPTEN_EVENT_MOUSEDOWN:
|
|
||||||
case EMSCRIPTEN_EVENT_MOUSEUP:
|
|
||||||
{
|
|
||||||
if (aNewPos.x() < 0 || aNewPos.x() > aWinSize.x()
|
|
||||||
|| aNewPos.y() < 0 || aNewPos.y() > aWinSize.y())
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
if (UpdateMouseButtons (aNewPos, aButtons, aFlags, isEmulated))
|
|
||||||
{
|
|
||||||
updateView();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EMSCRIPTEN_EVENT_CLICK:
|
|
||||||
case EMSCRIPTEN_EVENT_DBLCLICK:
|
|
||||||
{
|
|
||||||
if (aNewPos.x() < 0 || aNewPos.x() > aWinSize.x()
|
|
||||||
|| aNewPos.y() < 0 || aNewPos.y() > aWinSize.y())
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EMSCRIPTEN_EVENT_MOUSEENTER:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EMSCRIPTEN_EVENT_MOUSELEAVE:
|
|
||||||
{
|
|
||||||
// there is no SetCapture() support, so that mouse unclick events outside canvas will not arrive,
|
|
||||||
// so we have to forget current state...
|
|
||||||
if (UpdateMouseButtons (aNewPos, Aspect_VKeyMouse_NONE, aFlags, isEmulated))
|
|
||||||
{
|
|
||||||
updateView();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return EM_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : onWheelEvent
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
EM_BOOL WasmOcctView::onWheelEvent (int theEventType, const EmscriptenWheelEvent* theEvent)
|
|
||||||
{
|
|
||||||
if (myView.IsNull()
|
|
||||||
|| theEventType != EMSCRIPTEN_EVENT_WHEEL)
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Graphic3d_Vec2i aWinSize;
|
|
||||||
myView->Window()->Size (aWinSize.x(), aWinSize.y());
|
|
||||||
const Graphic3d_Vec2i aNewPos = convertPointToBacking (Graphic3d_Vec2i (theEvent->mouse.canvasX, theEvent->mouse.canvasY));
|
|
||||||
if (aNewPos.x() < 0 || aNewPos.x() > aWinSize.x()
|
|
||||||
|| aNewPos.y() < 0 || aNewPos.y() > aWinSize.y())
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
double aDelta = 0.0;
|
|
||||||
switch (theEvent->deltaMode)
|
|
||||||
{
|
|
||||||
case DOM_DELTA_PIXEL:
|
|
||||||
{
|
|
||||||
aDelta = theEvent->deltaY / (5.0 * myDevicePixelRatio);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DOM_DELTA_LINE:
|
|
||||||
{
|
|
||||||
aDelta = theEvent->deltaY * 8.0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DOM_DELTA_PAGE:
|
|
||||||
{
|
|
||||||
aDelta = theEvent->deltaY >= 0.0 ? 24.0 : -24.0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UpdateZoom (Aspect_ScrollDelta (aNewPos, -aDelta)))
|
|
||||||
{
|
|
||||||
updateView();
|
|
||||||
}
|
|
||||||
return EM_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : onTouchEvent
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
EM_BOOL WasmOcctView::onTouchEvent (int theEventType, const EmscriptenTouchEvent* theEvent)
|
|
||||||
{
|
|
||||||
const double aClickTolerance = 5.0;
|
|
||||||
if (myView.IsNull())
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Graphic3d_Vec2i aWinSize;
|
|
||||||
myView->Window()->Size (aWinSize.x(), aWinSize.y());
|
|
||||||
bool hasUpdates = false;
|
|
||||||
for (int aTouchIter = 0; aTouchIter < theEvent->numTouches; ++aTouchIter)
|
|
||||||
{
|
|
||||||
const EmscriptenTouchPoint& aTouch = theEvent->touches[aTouchIter];
|
|
||||||
if (!aTouch.isChanged)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Standard_Size aTouchId = (Standard_Size )aTouch.identifier;
|
|
||||||
const Graphic3d_Vec2i aNewPos = convertPointToBacking (Graphic3d_Vec2i (aTouch.canvasX, aTouch.canvasY));
|
|
||||||
switch (theEventType)
|
|
||||||
{
|
|
||||||
case EMSCRIPTEN_EVENT_TOUCHSTART:
|
|
||||||
{
|
|
||||||
if (aNewPos.x() >= 0 && aNewPos.x() < aWinSize.x()
|
|
||||||
&& aNewPos.y() >= 0 && aNewPos.y() < aWinSize.y())
|
|
||||||
{
|
|
||||||
hasUpdates = true;
|
|
||||||
AddTouchPoint (aTouchId, Graphic3d_Vec2d (aNewPos));
|
|
||||||
myClickTouch.From.SetValues (-1.0, -1.0);
|
|
||||||
if (myTouchPoints.Extent() == 1)
|
|
||||||
{
|
|
||||||
myClickTouch.From = Graphic3d_Vec2d (aNewPos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EMSCRIPTEN_EVENT_TOUCHMOVE:
|
|
||||||
{
|
|
||||||
const int anOldIndex = myTouchPoints.FindIndex (aTouchId);
|
|
||||||
if (anOldIndex != 0)
|
|
||||||
{
|
|
||||||
hasUpdates = true;
|
|
||||||
UpdateTouchPoint (aTouchId, Graphic3d_Vec2d (aNewPos));
|
|
||||||
if (myTouchPoints.Extent() == 1
|
|
||||||
&& (myClickTouch.From - Graphic3d_Vec2d (aNewPos)).cwiseAbs().maxComp() > aClickTolerance)
|
|
||||||
{
|
|
||||||
myClickTouch.From.SetValues (-1.0, -1.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EMSCRIPTEN_EVENT_TOUCHEND:
|
|
||||||
case EMSCRIPTEN_EVENT_TOUCHCANCEL:
|
|
||||||
{
|
|
||||||
if (RemoveTouchPoint (aTouchId))
|
|
||||||
{
|
|
||||||
if (myTouchPoints.IsEmpty()
|
|
||||||
&& myClickTouch.From.minComp() >= 0.0)
|
|
||||||
{
|
|
||||||
if (myDoubleTapTimer.IsStarted()
|
|
||||||
&& myDoubleTapTimer.ElapsedTime() <= myMouseDoubleClickInt)
|
|
||||||
{
|
|
||||||
myView->FitAll (0.01, false);
|
|
||||||
myView->Invalidate();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
myDoubleTapTimer.Stop();
|
|
||||||
myDoubleTapTimer.Reset();
|
|
||||||
myDoubleTapTimer.Start();
|
|
||||||
SelectInViewer (Graphic3d_Vec2i (myClickTouch.From), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hasUpdates = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasUpdates)
|
|
||||||
{
|
|
||||||
updateView();
|
|
||||||
}
|
|
||||||
return hasUpdates || !myTouchPoints.IsEmpty() ? EM_TRUE : EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : onKeyDownEvent
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
EM_BOOL WasmOcctView::onKeyDownEvent (int theEventType, const EmscriptenKeyboardEvent* theEvent)
|
|
||||||
{
|
|
||||||
if (myView.IsNull()
|
|
||||||
|| theEventType != EMSCRIPTEN_EVENT_KEYDOWN) // EMSCRIPTEN_EVENT_KEYPRESS
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const double aTimeStamp = EventTime();
|
|
||||||
const Aspect_VKey aVKey = WasmVKeys_VirtualKeyFromNative (theEvent->keyCode);
|
|
||||||
if (aVKey == Aspect_VKey_UNKNOWN)
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theEvent->repeat == EM_FALSE)
|
|
||||||
{
|
|
||||||
myKeys.KeyDown (aVKey, aTimeStamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Aspect_VKey2Modifier (aVKey) == 0)
|
|
||||||
{
|
|
||||||
// normal key
|
|
||||||
}
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================
|
|
||||||
// Function : onKeyUpEvent
|
|
||||||
// Purpose :
|
|
||||||
// ================================================================
|
|
||||||
EM_BOOL WasmOcctView::onKeyUpEvent (int theEventType, const EmscriptenKeyboardEvent* theEvent)
|
|
||||||
{
|
|
||||||
if (myView.IsNull()
|
|
||||||
|| theEventType != EMSCRIPTEN_EVENT_KEYUP)
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const double aTimeStamp = EventTime();
|
|
||||||
const Aspect_VKey aVKey = WasmVKeys_VirtualKeyFromNative (theEvent->keyCode);
|
|
||||||
if (aVKey == Aspect_VKey_UNKNOWN)
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theEvent->repeat == EM_TRUE)
|
|
||||||
{
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const unsigned int aModif = myKeys.Modifiers();
|
|
||||||
myKeys.KeyUp (aVKey, aTimeStamp);
|
|
||||||
if (Aspect_VKey2Modifier (aVKey) == 0)
|
|
||||||
{
|
|
||||||
// normal key released
|
|
||||||
switch (aVKey | aModif)
|
|
||||||
{
|
|
||||||
case Aspect_VKey_F:
|
|
||||||
{
|
|
||||||
myView->FitAll (0.01, false);
|
|
||||||
myView->Invalidate();
|
|
||||||
updateView();
|
|
||||||
return EM_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return EM_FALSE;
|
|
||||||
}
|
|
@@ -1,157 +0,0 @@
|
|||||||
// Copyright (c) 2019 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 _WasmOcctView_HeaderFile
|
|
||||||
#define _WasmOcctView_HeaderFile
|
|
||||||
|
|
||||||
#include <AIS_InteractiveContext.hxx>
|
|
||||||
#include <AIS_ViewController.hxx>
|
|
||||||
#include <V3d_View.hxx>
|
|
||||||
|
|
||||||
#include <emscripten.h>
|
|
||||||
#include <emscripten/html5.h>
|
|
||||||
|
|
||||||
class AIS_ViewCube;
|
|
||||||
|
|
||||||
//! Sample class creating 3D Viewer within Emscripten canvas.
|
|
||||||
class WasmOcctView : protected AIS_ViewController
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//! Default constructor.
|
|
||||||
WasmOcctView();
|
|
||||||
|
|
||||||
//! Destructor.
|
|
||||||
virtual ~WasmOcctView();
|
|
||||||
|
|
||||||
//! Main application entry point.
|
|
||||||
void run();
|
|
||||||
|
|
||||||
//! Return interactive context.
|
|
||||||
const Handle(AIS_InteractiveContext)& Context() const { return myContext; }
|
|
||||||
|
|
||||||
//! Return view.
|
|
||||||
const Handle(V3d_View)& View() const { return myView; }
|
|
||||||
|
|
||||||
//! Return device pixel ratio for handling high DPI displays.
|
|
||||||
float DevicePixelRatio() const { return myDevicePixelRatio; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Create window.
|
|
||||||
void initWindow();
|
|
||||||
|
|
||||||
//! Create 3D Viewer.
|
|
||||||
bool initViewer();
|
|
||||||
|
|
||||||
//! Fill 3D Viewer with a DEMO items.
|
|
||||||
void initDemoScene();
|
|
||||||
|
|
||||||
//! Application event loop.
|
|
||||||
void mainloop();
|
|
||||||
|
|
||||||
//! Request view redrawing.
|
|
||||||
void updateView();
|
|
||||||
|
|
||||||
//! Flush events and redraw view.
|
|
||||||
void redrawView();
|
|
||||||
|
|
||||||
//! Handle view redraw.
|
|
||||||
virtual void handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
|
|
||||||
const Handle(V3d_View)& theView) override;
|
|
||||||
|
|
||||||
//! Dump WebGL context information.
|
|
||||||
void dumpGlInfo (bool theIsBasic);
|
|
||||||
|
|
||||||
//! Initialize pixel scale ratio.
|
|
||||||
void initPixelScaleRatio();
|
|
||||||
|
|
||||||
//! Return point from logical units to backing store.
|
|
||||||
Graphic3d_Vec2d convertPointToBacking (const Graphic3d_Vec2d& thePnt) const
|
|
||||||
{
|
|
||||||
return thePnt * myDevicePixelRatio;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Return point from logical units to backing store.
|
|
||||||
Graphic3d_Vec2i convertPointToBacking (const Graphic3d_Vec2i& thePnt) const
|
|
||||||
{
|
|
||||||
Graphic3d_Vec2d aPnt = Graphic3d_Vec2d (thePnt) * myDevicePixelRatio + Graphic3d_Vec2d (0.5);
|
|
||||||
return Graphic3d_Vec2i (aPnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! @name Emscripten callbacks
|
|
||||||
private:
|
|
||||||
//! Window resize event.
|
|
||||||
EM_BOOL onResizeEvent (int theEventType, const EmscriptenUiEvent* theEvent);
|
|
||||||
|
|
||||||
//! Mouse event.
|
|
||||||
EM_BOOL onMouseEvent (int theEventType, const EmscriptenMouseEvent* theEvent);
|
|
||||||
|
|
||||||
//! Scroll event.
|
|
||||||
EM_BOOL onWheelEvent (int theEventType, const EmscriptenWheelEvent* theEvent);
|
|
||||||
|
|
||||||
//! Touch event.
|
|
||||||
EM_BOOL onTouchEvent (int theEventType, const EmscriptenTouchEvent* theEvent);
|
|
||||||
|
|
||||||
//! Key down event.
|
|
||||||
EM_BOOL onKeyDownEvent (int theEventType, const EmscriptenKeyboardEvent* theEvent);
|
|
||||||
|
|
||||||
//! Key up event.
|
|
||||||
EM_BOOL onKeyUpEvent (int theEventType, const EmscriptenKeyboardEvent* theEvent);
|
|
||||||
|
|
||||||
//! @name Emscripten callbacks (static functions)
|
|
||||||
private:
|
|
||||||
|
|
||||||
static EM_BOOL onResizeCallback (int theEventType, const EmscriptenUiEvent* theEvent, void* theView)
|
|
||||||
{ return ((WasmOcctView* )theView)->onResizeEvent (theEventType, theEvent); }
|
|
||||||
|
|
||||||
static void onRedrawView (void* theView)
|
|
||||||
{ return ((WasmOcctView* )theView)->redrawView(); }
|
|
||||||
|
|
||||||
static EM_BOOL onMouseCallback (int theEventType, const EmscriptenMouseEvent* theEvent, void* theView)
|
|
||||||
{ return ((WasmOcctView* )theView)->onMouseEvent (theEventType, theEvent); }
|
|
||||||
|
|
||||||
static EM_BOOL onWheelCallback (int theEventType, const EmscriptenWheelEvent* theEvent, void* theView)
|
|
||||||
{ return ((WasmOcctView* )theView)->onWheelEvent (theEventType, theEvent); }
|
|
||||||
|
|
||||||
static EM_BOOL onTouchCallback (int theEventType, const EmscriptenTouchEvent* theEvent, void* theView)
|
|
||||||
{ return ((WasmOcctView* )theView)->onTouchEvent (theEventType, theEvent); }
|
|
||||||
|
|
||||||
static EM_BOOL onKeyDownCallback (int theEventType, const EmscriptenKeyboardEvent* theEvent, void* theView)
|
|
||||||
{ return ((WasmOcctView* )theView)->onKeyDownEvent (theEventType, theEvent); }
|
|
||||||
|
|
||||||
static EM_BOOL onKeyUpCallback (int theEventType, const EmscriptenKeyboardEvent* theEvent, void* theView)
|
|
||||||
{ return ((WasmOcctView* )theView)->onKeyUpEvent (theEventType, theEvent); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Handle(AIS_InteractiveContext) myContext; //!< interactive context
|
|
||||||
Handle(V3d_View) myView; //!< 3D view
|
|
||||||
Handle(Prs3d_TextAspect) myTextStyle; //!< text style for OSD elements
|
|
||||||
Handle(AIS_ViewCube) myViewCube; //!< view cube object
|
|
||||||
TCollection_AsciiString myCanvasId; //!< canvas element id on HTML page
|
|
||||||
Aspect_Touch myClickTouch; //!< single touch position for handling clicks
|
|
||||||
OSD_Timer myDoubleTapTimer; //!< timer for handling double tap
|
|
||||||
float myDevicePixelRatio; //!< device pixel ratio for handling high DPI displays
|
|
||||||
unsigned int myUpdateRequests; //!< counter for unhandled update requests
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _WasmOcctView_HeaderFile
|
|
@@ -1,264 +0,0 @@
|
|||||||
// Copyright (c) 2019 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 _WasmVKeys_HeaderFile
|
|
||||||
#define _WasmVKeys_HeaderFile
|
|
||||||
|
|
||||||
#include <Aspect_VKey.hxx>
|
|
||||||
|
|
||||||
#include <emscripten/key_codes.h>
|
|
||||||
|
|
||||||
//! Convert Emscripten mouse buttons into Aspect_VKeyMouse.
|
|
||||||
inline Aspect_VKeyMouse WasmVKeys_MouseButtonsFromNative (unsigned short theButtons)
|
|
||||||
{
|
|
||||||
Aspect_VKeyMouse aButtons = Aspect_VKeyMouse_NONE;
|
|
||||||
if ((theButtons & 0x1) != 0)
|
|
||||||
{
|
|
||||||
aButtons |= Aspect_VKeyMouse_LeftButton;
|
|
||||||
}
|
|
||||||
if ((theButtons & 0x2) != 0)
|
|
||||||
{
|
|
||||||
aButtons |= Aspect_VKeyMouse_RightButton;
|
|
||||||
}
|
|
||||||
if ((theButtons & 0x4) != 0)
|
|
||||||
{
|
|
||||||
aButtons |= Aspect_VKeyMouse_MiddleButton;
|
|
||||||
}
|
|
||||||
return aButtons;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Convert DOM virtual key into Aspect_VKey.
|
|
||||||
inline Aspect_VKey WasmVKeys_VirtualKeyFromNative (Standard_Integer theKey)
|
|
||||||
{
|
|
||||||
if (theKey >= DOM_VK_0
|
|
||||||
&& theKey <= DOM_VK_9)
|
|
||||||
{
|
|
||||||
// numpad keys
|
|
||||||
return Aspect_VKey((theKey - DOM_VK_0) + Aspect_VKey_0);
|
|
||||||
}
|
|
||||||
if (theKey >= DOM_VK_A
|
|
||||||
&& theKey <= DOM_VK_Z)
|
|
||||||
{
|
|
||||||
// main latin alphabet keys
|
|
||||||
return Aspect_VKey((theKey - DOM_VK_A) + Aspect_VKey_A);
|
|
||||||
}
|
|
||||||
if (theKey >= DOM_VK_F1
|
|
||||||
&& theKey <= DOM_VK_F24)
|
|
||||||
{
|
|
||||||
// special keys
|
|
||||||
if (theKey <= DOM_VK_F12)
|
|
||||||
{
|
|
||||||
return Aspect_VKey((theKey - DOM_VK_F1) + Aspect_VKey_F1);
|
|
||||||
}
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
}
|
|
||||||
if (theKey >= DOM_VK_NUMPAD0
|
|
||||||
&& theKey <= DOM_VK_NUMPAD9)
|
|
||||||
{
|
|
||||||
// numpad keys
|
|
||||||
return Aspect_VKey((theKey - DOM_VK_NUMPAD0) + Aspect_VKey_Numpad0);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (theKey)
|
|
||||||
{
|
|
||||||
case DOM_VK_CANCEL:
|
|
||||||
case DOM_VK_HELP:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_BACK_SPACE:
|
|
||||||
return Aspect_VKey_Backspace;
|
|
||||||
case DOM_VK_TAB:
|
|
||||||
return Aspect_VKey_Tab;
|
|
||||||
case DOM_VK_CLEAR:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_RETURN:
|
|
||||||
case DOM_VK_ENTER:
|
|
||||||
return Aspect_VKey_Enter;
|
|
||||||
case DOM_VK_SHIFT:
|
|
||||||
return Aspect_VKey_Shift;
|
|
||||||
case DOM_VK_CONTROL:
|
|
||||||
return Aspect_VKey_Control;
|
|
||||||
case DOM_VK_ALT:
|
|
||||||
return Aspect_VKey_Alt;
|
|
||||||
case DOM_VK_PAUSE:
|
|
||||||
case DOM_VK_CAPS_LOCK:
|
|
||||||
case DOM_VK_KANA:
|
|
||||||
//case DOM_VK_HANGUL:
|
|
||||||
case DOM_VK_EISU:
|
|
||||||
case DOM_VK_JUNJA:
|
|
||||||
case DOM_VK_FINAL:
|
|
||||||
case DOM_VK_HANJA:
|
|
||||||
//case DOM_VK_KANJI:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_ESCAPE:
|
|
||||||
return Aspect_VKey_Escape;
|
|
||||||
case DOM_VK_CONVERT:
|
|
||||||
case DOM_VK_NONCONVERT:
|
|
||||||
case DOM_VK_ACCEPT:
|
|
||||||
case DOM_VK_MODECHANGE:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_SPACE:
|
|
||||||
return Aspect_VKey_Space;
|
|
||||||
case DOM_VK_PAGE_UP:
|
|
||||||
return Aspect_VKey_PageUp;
|
|
||||||
case DOM_VK_PAGE_DOWN:
|
|
||||||
return Aspect_VKey_PageDown;
|
|
||||||
case DOM_VK_END:
|
|
||||||
return Aspect_VKey_End;
|
|
||||||
case DOM_VK_HOME:
|
|
||||||
return Aspect_VKey_Home;
|
|
||||||
case DOM_VK_LEFT:
|
|
||||||
return Aspect_VKey_Left;
|
|
||||||
case DOM_VK_UP:
|
|
||||||
return Aspect_VKey_Up;
|
|
||||||
case DOM_VK_RIGHT:
|
|
||||||
return Aspect_VKey_Right;
|
|
||||||
case DOM_VK_DOWN:
|
|
||||||
return Aspect_VKey_Down;
|
|
||||||
case DOM_VK_SELECT:
|
|
||||||
case DOM_VK_PRINT:
|
|
||||||
case DOM_VK_EXECUTE:
|
|
||||||
case DOM_VK_PRINTSCREEN:
|
|
||||||
case DOM_VK_INSERT:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_DELETE:
|
|
||||||
return Aspect_VKey_Delete;
|
|
||||||
case DOM_VK_COLON:
|
|
||||||
return Aspect_VKey_Comma;
|
|
||||||
case DOM_VK_SEMICOLON:
|
|
||||||
return Aspect_VKey_Semicolon;
|
|
||||||
case DOM_VK_LESS_THAN:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_EQUALS:
|
|
||||||
return Aspect_VKey_Equal;
|
|
||||||
case DOM_VK_GREATER_THAN:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_QUESTION_MARK:
|
|
||||||
return Aspect_VKey_Slash;
|
|
||||||
case DOM_VK_AT: // @ key
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_WIN:
|
|
||||||
return Aspect_VKey_Meta;
|
|
||||||
case DOM_VK_CONTEXT_MENU:
|
|
||||||
case DOM_VK_SLEEP:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_MULTIPLY:
|
|
||||||
return Aspect_VKey_NumpadMultiply;
|
|
||||||
case DOM_VK_ADD:
|
|
||||||
return Aspect_VKey_NumpadAdd;
|
|
||||||
case DOM_VK_SEPARATOR:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_SUBTRACT:
|
|
||||||
return Aspect_VKey_NumpadSubtract;
|
|
||||||
case DOM_VK_DECIMAL:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_DIVIDE:
|
|
||||||
return Aspect_VKey_NumpadDivide;
|
|
||||||
case DOM_VK_NUM_LOCK:
|
|
||||||
return Aspect_VKey_Numlock;
|
|
||||||
case DOM_VK_SCROLL_LOCK:
|
|
||||||
return Aspect_VKey_Scroll;
|
|
||||||
case DOM_VK_WIN_OEM_FJ_JISHO:
|
|
||||||
case DOM_VK_WIN_OEM_FJ_MASSHOU:
|
|
||||||
case DOM_VK_WIN_OEM_FJ_TOUROKU:
|
|
||||||
case DOM_VK_WIN_OEM_FJ_LOYA:
|
|
||||||
case DOM_VK_WIN_OEM_FJ_ROYA:
|
|
||||||
case DOM_VK_CIRCUMFLEX:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_EXCLAMATION:
|
|
||||||
case DOM_VK_DOUBLE_QUOTE:
|
|
||||||
//case DOM_VK_HASH:
|
|
||||||
case DOM_VK_DOLLAR:
|
|
||||||
case DOM_VK_PERCENT:
|
|
||||||
case DOM_VK_AMPERSAND:
|
|
||||||
case DOM_VK_UNDERSCORE:
|
|
||||||
case DOM_VK_OPEN_PAREN:
|
|
||||||
case DOM_VK_CLOSE_PAREN:
|
|
||||||
case DOM_VK_ASTERISK:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_PLUS:
|
|
||||||
return Aspect_VKey_Plus;
|
|
||||||
case DOM_VK_PIPE:
|
|
||||||
case DOM_VK_HYPHEN_MINUS:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_OPEN_CURLY_BRACKET:
|
|
||||||
return Aspect_VKey_BracketLeft;
|
|
||||||
case DOM_VK_CLOSE_CURLY_BRACKET:
|
|
||||||
return Aspect_VKey_BracketRight;
|
|
||||||
case DOM_VK_TILDE:
|
|
||||||
return Aspect_VKey_Tilde;
|
|
||||||
case DOM_VK_VOLUME_MUTE:
|
|
||||||
return Aspect_VKey_VolumeMute;
|
|
||||||
case DOM_VK_VOLUME_DOWN:
|
|
||||||
return Aspect_VKey_VolumeDown;
|
|
||||||
case DOM_VK_VOLUME_UP:
|
|
||||||
return Aspect_VKey_VolumeUp;
|
|
||||||
case DOM_VK_COMMA:
|
|
||||||
return Aspect_VKey_Comma;
|
|
||||||
case DOM_VK_PERIOD:
|
|
||||||
return Aspect_VKey_Period;
|
|
||||||
case DOM_VK_SLASH:
|
|
||||||
return Aspect_VKey_Slash;
|
|
||||||
case DOM_VK_BACK_QUOTE:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_OPEN_BRACKET:
|
|
||||||
return Aspect_VKey_BracketLeft;
|
|
||||||
case DOM_VK_BACK_SLASH:
|
|
||||||
return Aspect_VKey_Backslash;
|
|
||||||
case DOM_VK_CLOSE_BRACKET:
|
|
||||||
return Aspect_VKey_BracketRight;
|
|
||||||
case DOM_VK_QUOTE:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_META:
|
|
||||||
return Aspect_VKey_Meta;
|
|
||||||
case DOM_VK_ALTGR:
|
|
||||||
return Aspect_VKey_Alt;
|
|
||||||
case DOM_VK_WIN_ICO_HELP:
|
|
||||||
case DOM_VK_WIN_ICO_00:
|
|
||||||
case DOM_VK_WIN_ICO_CLEAR:
|
|
||||||
case DOM_VK_WIN_OEM_RESET:
|
|
||||||
case DOM_VK_WIN_OEM_JUMP:
|
|
||||||
case DOM_VK_WIN_OEM_PA1:
|
|
||||||
case DOM_VK_WIN_OEM_PA2:
|
|
||||||
case DOM_VK_WIN_OEM_PA3:
|
|
||||||
case DOM_VK_WIN_OEM_WSCTRL:
|
|
||||||
case DOM_VK_WIN_OEM_CUSEL:
|
|
||||||
case DOM_VK_WIN_OEM_ATTN:
|
|
||||||
case DOM_VK_WIN_OEM_FINISH:
|
|
||||||
case DOM_VK_WIN_OEM_COPY:
|
|
||||||
case DOM_VK_WIN_OEM_AUTO:
|
|
||||||
case DOM_VK_WIN_OEM_ENLW:
|
|
||||||
case DOM_VK_WIN_OEM_BACKTAB:
|
|
||||||
case DOM_VK_ATTN:
|
|
||||||
case DOM_VK_CRSEL:
|
|
||||||
case DOM_VK_EXSEL:
|
|
||||||
case DOM_VK_EREOF:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
case DOM_VK_PLAY:
|
|
||||||
return Aspect_VKey_MediaPlayPause;
|
|
||||||
case DOM_VK_ZOOM:
|
|
||||||
case DOM_VK_PA1:
|
|
||||||
case DOM_VK_WIN_OEM_CLEAR:
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
}
|
|
||||||
return Aspect_VKey_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // _WasmVKeys_HeaderFile
|
|
@@ -1,66 +0,0 @@
|
|||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "WasmOcctView.h"
|
|
||||||
|
|
||||||
#include <Message.hxx>
|
|
||||||
#include <Message_Messenger.hxx>
|
|
||||||
#include <OSD_MemInfo.hxx>
|
|
||||||
#include <OSD_Parallel.hxx>
|
|
||||||
|
|
||||||
#include <AIS_Shape.hxx>
|
|
||||||
#include <BRepTools.hxx>
|
|
||||||
#include <BRep_Builder.hxx>
|
|
||||||
#include <Standard_ArrayStreamBuffer.hxx>
|
|
||||||
|
|
||||||
#include <emscripten.h>
|
|
||||||
#include <emscripten/html5.h>
|
|
||||||
|
|
||||||
//! Global viewer instance.
|
|
||||||
static WasmOcctView aViewer;
|
|
||||||
|
|
||||||
//! File data read event.
|
|
||||||
extern "C" void onFileDataRead (void* theOpaque, void* theBuffer, int theDataLen)
|
|
||||||
{
|
|
||||||
const char* aName = theOpaque != NULL ? (const char* )theOpaque : "";
|
|
||||||
{
|
|
||||||
AIS_ListOfInteractive aShapes;
|
|
||||||
aViewer.Context()->DisplayedObjects (AIS_KOI_Shape, -1, aShapes);
|
|
||||||
for (AIS_ListOfInteractive::Iterator aShapeIter (aShapes); aShapeIter.More(); aShapeIter.Next())
|
|
||||||
{
|
|
||||||
aViewer.Context()->Remove (aShapeIter.Value(), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_ArrayStreamBuffer aStreamBuffer ((const char* )theBuffer, theDataLen);
|
|
||||||
std::istream aStream (&aStreamBuffer);
|
|
||||||
TopoDS_Shape aShape;
|
|
||||||
BRep_Builder aBuilder;
|
|
||||||
BRepTools::Read (aShape, aStream, aBuilder);
|
|
||||||
|
|
||||||
Handle(AIS_Shape) aShapePrs = new AIS_Shape (aShape);
|
|
||||||
aShapePrs->SetMaterial (Graphic3d_NOM_SILVER);
|
|
||||||
aViewer.Context()->Display (aShapePrs, AIS_Shaded, 0, false);
|
|
||||||
aViewer.View()->FitAll (0.01, false);
|
|
||||||
aViewer.View()->Redraw();
|
|
||||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Loaded file ") + aName, Message_Info);
|
|
||||||
Message::DefaultMessenger()->Send (OSD_MemInfo::PrintInfo(), Message_Trace);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! File read error event.
|
|
||||||
static void onFileReadFailed (void* theOpaque)
|
|
||||||
{
|
|
||||||
const char* aName = (const char* )theOpaque;
|
|
||||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("Error: unable to load file ") + aName, Message_Fail);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
Message::DefaultMessenger()->Printers().First()->SetTraceLevel (Message_Trace);
|
|
||||||
Message::DefaultMessenger()->Send (TCollection_AsciiString("NbLogicalProcessors: ") + OSD_Parallel::NbLogicalProcessors(), Message_Trace);
|
|
||||||
aViewer.run();
|
|
||||||
Message::DefaultMessenger()->Send (OSD_MemInfo::PrintInfo(), Message_Trace);
|
|
||||||
|
|
||||||
// load some file
|
|
||||||
emscripten_async_wget_data ("samples/Ball.brep", (void* )"samples/Ball.brep", onFileDataRead, onFileReadFailed);
|
|
||||||
return 0;
|
|
||||||
}
|
|
@@ -1,133 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang=en-us>
|
|
||||||
<head>
|
|
||||||
<meta charset=utf-8><meta content="text/html; charset=utf-8" http-equiv=Content-Type>
|
|
||||||
<link rel="shortcut icon" href="lamp.ico" type="image/x-icon" />
|
|
||||||
<title>OCCT WebGL Viewer Sample</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h2>OCCT WebGL Viewer Sample</h2>
|
|
||||||
<div>
|
|
||||||
<canvas id=canvas oncontextmenu=event.preventDefault() tabindex=-1 style="border:0 none;background-color:#000" width="409" height="409"></canvas>
|
|
||||||
<img id=occlogo src="OCC_logo.png" style="position: absolute; left: 20px; top: 0px; z-index: 2;" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div><label for="fileInput">Choose BREP file to upload: </label><input type="file" id="fileInput" accept=".brep"></div>
|
|
||||||
<h4>Console output:</h4>
|
|
||||||
<p id="output"></p>
|
|
||||||
<script>
|
|
||||||
//! Resize canvas to fit into window.
|
|
||||||
function updateCanvasSize()
|
|
||||||
{
|
|
||||||
// size of canvas in logical (density-independent) units
|
|
||||||
var aSizeX = Math.min (window.innerWidth, window.screen.availWidth);
|
|
||||||
var aSizeY = Math.min (window.innerHeight, window.screen.availHeight);
|
|
||||||
aSizeX = Math.max (300, aSizeX - 30);
|
|
||||||
aSizeY = Math.max (300, aSizeY / 2);
|
|
||||||
canvas.style.width = aSizeX + "px";
|
|
||||||
canvas.style.height = aSizeY + "px";
|
|
||||||
|
|
||||||
// drawing buffer size (aka backing store)
|
|
||||||
var aDevicePixelRatio = window.devicePixelRatio || 1;
|
|
||||||
canvas.width = aSizeX * aDevicePixelRatio;
|
|
||||||
canvas.height = aSizeY * aDevicePixelRatio;
|
|
||||||
|
|
||||||
occlogo.style.top = (aSizeY - 30) + "px";
|
|
||||||
}
|
|
||||||
window.onresize = updateCanvasSize;
|
|
||||||
updateCanvasSize();
|
|
||||||
|
|
||||||
//! Check browser support.
|
|
||||||
function isWasmSupported()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
if (typeof WebAssembly === "object"
|
|
||||||
&& typeof WebAssembly.instantiate === "function") {
|
|
||||||
const aDummyModule = new WebAssembly.Module (Uint8Array.of (0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
|
|
||||||
if (aDummyModule instanceof WebAssembly.Module)
|
|
||||||
{
|
|
||||||
return new WebAssembly.Instance(aDummyModule) instanceof WebAssembly.Instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isWasmSupported())
|
|
||||||
{
|
|
||||||
var anElement = document.getElementById('output');
|
|
||||||
anElement.innerHTML += "Browser is too old - WebAssembly support is missing!<br>Please check updates or install a modern browser.<br>";
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Define OCCT WebGL Viewer module.
|
|
||||||
var Module =
|
|
||||||
{
|
|
||||||
print: (function() {
|
|
||||||
var anElement = document.getElementById('output');
|
|
||||||
return function(theText) { anElement.innerHTML += theText + "<br>"; };
|
|
||||||
})(),
|
|
||||||
printErr: function(theText) {
|
|
||||||
//var anElement = document.getElementById('output');
|
|
||||||
//anElement.innerHTML += theText + "<br>";
|
|
||||||
},
|
|
||||||
canvas: (function() {
|
|
||||||
var aCanvas = document.getElementById('canvas');
|
|
||||||
return aCanvas;
|
|
||||||
})()
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Handle file uploading.
|
|
||||||
fileInput.onchange = function()
|
|
||||||
{
|
|
||||||
if (fileInput.files.length == 0) { return; }
|
|
||||||
// Warning! Entire file is pre-loaded into memory.
|
|
||||||
var aFile = fileInput.files[0];
|
|
||||||
var aReader = new FileReader();
|
|
||||||
aReader.onload = function()
|
|
||||||
{
|
|
||||||
var aDataArray = new Uint8Array (aReader.result);
|
|
||||||
var aNameArray = new Uint8Array (toUtf8Array (aFile.name));
|
|
||||||
const aDataBuffer = Module._malloc(aDataArray.length);
|
|
||||||
const aNameBuffer = Module._malloc(aNameArray.length);
|
|
||||||
Module.HEAPU8.set(aNameArray, aNameBuffer);
|
|
||||||
Module.HEAPU8.set(aDataArray, aDataBuffer);
|
|
||||||
Module.ccall('onFileDataRead', null, ['number', 'number', 'number'], [aNameBuffer, aDataBuffer, aDataArray.length]);
|
|
||||||
Module._free(aDataBuffer);
|
|
||||||
Module._free(aNameBuffer);
|
|
||||||
fileInput.value = '';
|
|
||||||
};
|
|
||||||
aReader.readAsArrayBuffer(aFile);
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Convert string into UTF-8 array.
|
|
||||||
function toUtf8Array (theText)
|
|
||||||
{
|
|
||||||
var aRes = [];
|
|
||||||
for (var aCharIter = 0; aCharIter < theText.length; ++aCharIter)
|
|
||||||
{
|
|
||||||
var aCharCode = theText.charCodeAt (aCharIter);
|
|
||||||
if (aCharCode < 0x80)
|
|
||||||
{
|
|
||||||
aRes.push (aCharCode);
|
|
||||||
}
|
|
||||||
else if (aCharCode < 0x800)
|
|
||||||
{
|
|
||||||
aRes.push (0xc0 | (aCharCode >> 6), 0x80 | (aCharCode & 0x3f));
|
|
||||||
}
|
|
||||||
else if (aCharCode < 0xd800 || aCharCode >= 0xe000)
|
|
||||||
{
|
|
||||||
aRes.push (0xe0 | (aCharCode >> 12), 0x80 | ((aCharCode>>6) & 0x3f), 0x80 | (aCharCode & 0x3f));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
++aCharIter;
|
|
||||||
aCharCode = 0x10000 + (((aCharCode & 0x3ff)<<10) | (theText.charCodeAt (aCharIter) & 0x3ff));
|
|
||||||
aRes.push(0xf0 | (aCharCode >>18), 0x80 | ((aCharCode>>12) & 0x3f), 0x80 | ((aCharCode>>6) & 0x3f), 0x80 | (aCharCode & 0x3f));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return aRes;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<script type="text/javascript" src="occt-webgl-sample.js" charset="utf-8"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@@ -415,6 +415,11 @@ Standard_Boolean AIS_ColorScale::FindColor (const Standard_Real theValue,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
Standard_Integer AIS_ColorScale::computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const
|
Standard_Integer AIS_ColorScale::computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
Handle(V3d_Viewer) aViewer = GetContext()->CurrentViewer();
|
||||||
|
aViewer->InitActiveViews(); // for AIS_ColorScale::TextSize()
|
||||||
|
}
|
||||||
|
|
||||||
Standard_Integer aWidthMax = 0;
|
Standard_Integer aWidthMax = 0;
|
||||||
for (TColStd_SequenceOfExtendedString::Iterator aLabIter (theLabels); aLabIter.More(); aLabIter.Next())
|
for (TColStd_SequenceOfExtendedString::Iterator aLabIter (theLabels); aLabIter.More(); aLabIter.Next())
|
||||||
{
|
{
|
||||||
|
@@ -26,7 +26,6 @@ public:
|
|||||||
//! Default constructor.
|
//! Default constructor.
|
||||||
AIS_ColoredDrawer (const Handle(Prs3d_Drawer)& theLink)
|
AIS_ColoredDrawer (const Handle(Prs3d_Drawer)& theLink)
|
||||||
: myIsHidden (false),
|
: myIsHidden (false),
|
||||||
myHasOwnMaterial(false),
|
|
||||||
myHasOwnColor (false),
|
myHasOwnColor (false),
|
||||||
myHasOwnTransp(false),
|
myHasOwnTransp(false),
|
||||||
myHasOwnWidth (false)
|
myHasOwnWidth (false)
|
||||||
@@ -37,10 +36,6 @@ public:
|
|||||||
bool IsHidden() const { return myIsHidden; }
|
bool IsHidden() const { return myIsHidden; }
|
||||||
void SetHidden (const bool theToHide) { myIsHidden = theToHide;}
|
void SetHidden (const bool theToHide) { myIsHidden = theToHide;}
|
||||||
|
|
||||||
bool HasOwnMaterial() const { return myHasOwnMaterial; }
|
|
||||||
void UnsetOwnMaterial() { myHasOwnMaterial = false; }
|
|
||||||
void SetOwnMaterial() { myHasOwnMaterial = true; }
|
|
||||||
|
|
||||||
bool HasOwnColor() const { return myHasOwnColor; }
|
bool HasOwnColor() const { return myHasOwnColor; }
|
||||||
void UnsetOwnColor() { myHasOwnColor = false; }
|
void UnsetOwnColor() { myHasOwnColor = false; }
|
||||||
void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
|
void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
|
||||||
@@ -56,7 +51,6 @@ public:
|
|||||||
public: //! @name list of overridden properties
|
public: //! @name list of overridden properties
|
||||||
|
|
||||||
bool myIsHidden;
|
bool myIsHidden;
|
||||||
bool myHasOwnMaterial;
|
|
||||||
bool myHasOwnColor;
|
bool myHasOwnColor;
|
||||||
bool myHasOwnTransp;
|
bool myHasOwnTransp;
|
||||||
bool myHasOwnWidth;
|
bool myHasOwnWidth;
|
||||||
|
@@ -333,11 +333,7 @@ void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
|
|||||||
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
|
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
|
||||||
{
|
{
|
||||||
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
|
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
|
||||||
if (aDrawer->HasOwnMaterial())
|
//if (aDrawer->HasOwnMaterial()) continue;
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aDrawer->HasOwnShadingAspect())
|
if (aDrawer->HasOwnShadingAspect())
|
||||||
{
|
{
|
||||||
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), aDrawer->HasOwnTransparency());
|
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), aDrawer->HasOwnTransparency());
|
||||||
@@ -637,6 +633,11 @@ void AIS_ColoredShape::addShapesWithCustomProps (const Handle(Prs3d_Presentation
|
|||||||
{
|
{
|
||||||
aShadedGroup = thePrs->NewGroup();
|
aShadedGroup = thePrs->NewGroup();
|
||||||
aShadedGroup->SetClosed (isClosed);
|
aShadedGroup->SetClosed (isClosed);
|
||||||
|
if (isClosed)
|
||||||
|
{
|
||||||
|
if (aDrawer->HasOwnFillCappingAspect())
|
||||||
|
aShadedGroup->SetGroupPrimitivesAspect (aDrawer->FillCappingAspect());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect());
|
aShadedGroup->SetPrimitivesAspect (aDrawer->ShadingAspect()->Aspect());
|
||||||
aShadedGroup->AddPrimitiveArray (aTriangles);
|
aShadedGroup->AddPrimitiveArray (aTriangles);
|
||||||
|
@@ -79,12 +79,6 @@ void AIS_ConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& the
|
|||||||
|
|
||||||
if (!myReference.IsNull())
|
if (!myReference.IsNull())
|
||||||
{
|
{
|
||||||
if (myReference->HasInteractiveContext()
|
|
||||||
&& myReference->GetContext()->DisplayStatus (myReference) != AIS_DS_None)
|
|
||||||
{
|
|
||||||
myReference.Nullify();
|
|
||||||
throw Standard_ProgramError("AIS_ConnectedInteractive::Connect() - connected object should NOT be displayed in context");
|
|
||||||
}
|
|
||||||
myTypeOfPresentation3d = myReference->TypeOfPresentation3d();
|
myTypeOfPresentation3d = myReference->TypeOfPresentation3d();
|
||||||
}
|
}
|
||||||
setLocalTransformation (theLocation);
|
setLocalTransformation (theLocation);
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include <AIS_ListOfInteractive.hxx>
|
#include <AIS_ListOfInteractive.hxx>
|
||||||
#include <AIS_Selection.hxx>
|
#include <AIS_Selection.hxx>
|
||||||
#include <AIS_SelectionModesConcurrency.hxx>
|
#include <AIS_SelectionModesConcurrency.hxx>
|
||||||
|
#include <AIS_SelectionScheme.hxx>
|
||||||
#include <AIS_StatusOfDetection.hxx>
|
#include <AIS_StatusOfDetection.hxx>
|
||||||
#include <AIS_StatusOfPick.hxx>
|
#include <AIS_StatusOfPick.hxx>
|
||||||
#include <AIS_TypeOfIso.hxx>
|
#include <AIS_TypeOfIso.hxx>
|
||||||
@@ -470,6 +471,24 @@ public: //! @name Selection management
|
|||||||
return AddSelect (theObject->GlobalSelOwner());
|
return AddSelect (theObject->GlobalSelOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
|
||||||
|
//! The objects detected are passed to the main viewer, which is then updated.
|
||||||
|
Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
|
||||||
|
const Standard_Integer theYPMin,
|
||||||
|
const Standard_Integer theXPMax,
|
||||||
|
const Standard_Integer theYPMax,
|
||||||
|
const Handle(V3d_View)& theView,
|
||||||
|
const AIS_SelectionScheme theSelScheme);
|
||||||
|
|
||||||
|
//! polyline selection; clears the previous picked list
|
||||||
|
Standard_EXPORT AIS_StatusOfPick Select (const TColgp_Array1OfPnt2d& thePolyline,
|
||||||
|
const Handle(V3d_View)& theView,
|
||||||
|
const AIS_SelectionScheme theSelScheme);
|
||||||
|
|
||||||
|
//! Stores and hilights the previous detected; Unhilights the previous picked.
|
||||||
|
//! @sa MoveTo().
|
||||||
|
Standard_EXPORT AIS_StatusOfPick Select (const AIS_SelectionScheme theSelScheme);
|
||||||
|
|
||||||
//! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
|
//! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view.
|
||||||
//! The objects detected are passed to the main viewer, which is then updated.
|
//! The objects detected are passed to the main viewer, which is then updated.
|
||||||
Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
|
Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin,
|
||||||
@@ -511,6 +530,13 @@ public: //! @name Selection management
|
|||||||
//! Returns bounding box of selected objects.
|
//! Returns bounding box of selected objects.
|
||||||
Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
|
Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const;
|
||||||
|
|
||||||
|
//! Sets list of owner selected/deselected using selection scheme
|
||||||
|
//! It is possible that selection of other objects is changed relatively selection scheme .
|
||||||
|
//! \param theOwner owners to change selection state
|
||||||
|
//! \param theSelScheme selection scheme
|
||||||
|
Standard_EXPORT AIS_StatusOfPick Select (const AIS_NListOfEntityOwner& theOwners,
|
||||||
|
const AIS_SelectionScheme theSelScheme);
|
||||||
|
|
||||||
//! Fits the view correspondingly to the bounds of selected objects.
|
//! Fits the view correspondingly to the bounds of selected objects.
|
||||||
//! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
|
//! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
|
||||||
Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
|
Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
|
||||||
@@ -675,6 +701,9 @@ public: //! @name immediate mode rendering
|
|||||||
//! Redraws immediate structures in all views of the viewer given taking into account its visibility.
|
//! Redraws immediate structures in all views of the viewer given taking into account its visibility.
|
||||||
void RedrawImmediate (const Handle(V3d_Viewer)& theViewer) { myMainPM->RedrawImmediate (theViewer); }
|
void RedrawImmediate (const Handle(V3d_Viewer)& theViewer) { myMainPM->RedrawImmediate (theViewer); }
|
||||||
|
|
||||||
|
//! Change state to reset V3d_View bounding boxes. It should be used after a clipping plane was changed
|
||||||
|
Standard_EXPORT void InvalidateBoundingBox();
|
||||||
|
|
||||||
public: //! @name management of active Selection Modes
|
public: //! @name management of active Selection Modes
|
||||||
|
|
||||||
//! Activates or deactivates the selection mode for specified object.
|
//! Activates or deactivates the selection mode for specified object.
|
||||||
@@ -1216,6 +1245,9 @@ public: //! @name sub-intensity management (deprecated)
|
|||||||
//! @param theSelection an instance of the selection
|
//! @param theSelection an instance of the selection
|
||||||
void SetSelection (const Handle(AIS_Selection)& theSelection) { mySelection = theSelection; }
|
void SetSelection (const Handle(AIS_Selection)& theSelection) { mySelection = theSelection; }
|
||||||
|
|
||||||
|
//! Dumps the content of me into the stream
|
||||||
|
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const;
|
||||||
|
|
||||||
protected: //! @name internal methods
|
protected: //! @name internal methods
|
||||||
|
|
||||||
Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const;
|
Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const;
|
||||||
|
@@ -490,86 +490,14 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMi
|
|||||||
const Standard_Integer theXPMax,
|
const Standard_Integer theXPMax,
|
||||||
const Standard_Integer theYPMax,
|
const Standard_Integer theYPMax,
|
||||||
const Handle(V3d_View)& theView,
|
const Handle(V3d_View)& theView,
|
||||||
const Standard_Boolean toUpdateViewer)
|
const AIS_SelectionScheme theSelScheme)
|
||||||
{
|
{
|
||||||
if (theView->Viewer() != myMainVwr)
|
if (theView->Viewer() != myMainVwr)
|
||||||
{
|
{
|
||||||
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
|
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
|
||||||
}
|
}
|
||||||
|
|
||||||
// all objects detected by the selector are taken, previous current objects are emptied,
|
|
||||||
// new objects are put...
|
|
||||||
ClearSelected (Standard_False);
|
|
||||||
myLastActiveView = theView.get();
|
myLastActiveView = theView.get();
|
||||||
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
|
||||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
|
||||||
{
|
|
||||||
const Handle(SelectMgr_EntityOwner)& aCurOwner = myMainSel->Picked (aPickIter);
|
|
||||||
if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mySelection->Select (aCurOwner);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myAutoHilight)
|
|
||||||
{
|
|
||||||
HilightSelected (toUpdateViewer);
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer aSelNum = NbSelected();
|
|
||||||
|
|
||||||
return (aSelNum == 0) ? AIS_SOP_NothingSelected
|
|
||||||
: (aSelNum == 1) ? AIS_SOP_OneSelected
|
|
||||||
: AIS_SOP_SeveralSelected;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Select
|
|
||||||
//purpose : Selection by polyline
|
|
||||||
//=======================================================================
|
|
||||||
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
|
|
||||||
const Handle(V3d_View)& theView,
|
|
||||||
const Standard_Boolean toUpdateViewer)
|
|
||||||
{
|
|
||||||
if (theView->Viewer() != myMainVwr)
|
|
||||||
{
|
|
||||||
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
|
|
||||||
}
|
|
||||||
|
|
||||||
// all objects detected by the selector are taken, previous current objects are emptied,
|
|
||||||
// new objects are put...
|
|
||||||
ClearSelected (Standard_False);
|
|
||||||
myLastActiveView = theView.get();
|
|
||||||
myMainSel->Pick (thePolyline, theView);
|
|
||||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
|
||||||
{
|
|
||||||
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
|
|
||||||
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mySelection->Select (anOwner);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myAutoHilight)
|
|
||||||
{
|
|
||||||
HilightSelected (toUpdateViewer);
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer aSelNum = NbSelected();
|
|
||||||
|
|
||||||
return (aSelNum == 0) ? AIS_SOP_NothingSelected
|
|
||||||
: (aSelNum == 1) ? AIS_SOP_OneSelected
|
|
||||||
: AIS_SOP_SeveralSelected;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Select
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
|
|
||||||
{
|
|
||||||
if (!myLastPicked.IsNull())
|
if (!myLastPicked.IsNull())
|
||||||
{
|
{
|
||||||
Graphic3d_Vec2i aMousePos (-1, -1);
|
Graphic3d_Vec2i aMousePos (-1, -1);
|
||||||
@@ -582,54 +510,126 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate
|
|||||||
{
|
{
|
||||||
return AIS_SOP_NothingSelected;
|
return AIS_SOP_NothingSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myAutoHilight)
|
|
||||||
{
|
|
||||||
clearDynamicHighlight();
|
|
||||||
}
|
|
||||||
if (!myLastPicked->IsSelected()
|
|
||||||
|| myLastPicked->IsForcedHilight()
|
|
||||||
|| NbSelected() > 1)
|
|
||||||
{
|
|
||||||
SetSelected (myLastPicked, Standard_False);
|
|
||||||
if(toUpdateViewer)
|
|
||||||
{
|
|
||||||
UpdateCurrentViewer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
||||||
|
|
||||||
|
AIS_NListOfEntityOwner aPickedOwners;
|
||||||
|
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||||
{
|
{
|
||||||
ClearSelected (toUpdateViewer);
|
aPickedOwners.Append (myMainSel->Picked (aPickIter));
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer aSelNum = NbSelected();
|
return Select (aPickedOwners, theSelScheme);
|
||||||
|
}
|
||||||
|
|
||||||
return (aSelNum == 0) ? AIS_SOP_NothingSelected
|
//=======================================================================
|
||||||
: (aSelNum == 1) ? AIS_SOP_OneSelected
|
//function : Select
|
||||||
: AIS_SOP_SeveralSelected;
|
//purpose : Selection by polyline
|
||||||
|
//=======================================================================
|
||||||
|
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
|
||||||
|
const Handle(V3d_View)& theView,
|
||||||
|
const AIS_SelectionScheme theSelScheme)
|
||||||
|
{
|
||||||
|
if (theView->Viewer() != myMainVwr)
|
||||||
|
{
|
||||||
|
throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
myMainSel->Pick (thePolyline, theView);
|
||||||
|
|
||||||
|
AIS_NListOfEntityOwner aPickedOwners;
|
||||||
|
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
||||||
|
{
|
||||||
|
aPickedOwners.Append (myMainSel->Picked (aPickIter));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Select (aPickedOwners, theSelScheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Select
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_SelectionScheme theSelScheme)
|
||||||
|
{
|
||||||
|
// special case: single selection of detected owner - is it necessary ?
|
||||||
|
/*if (myWasLastMain && !myLastinMain.IsNull() && !myAutoHilight &&
|
||||||
|
(myLastinMain->IsSelected()
|
||||||
|
&& !myLastinMain->IsForcedHilight()
|
||||||
|
&& NbSelected() <= 1))
|
||||||
|
{
|
||||||
|
mySelection->selectOwner(myLastinMain, aPrevSelected, theSelScheme);
|
||||||
|
|
||||||
|
Graphic3d_Vec2i aMousePos (-1, -1);
|
||||||
|
if (myMainSel->GetManager().GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point)
|
||||||
|
{
|
||||||
|
aMousePos.SetValues ((Standard_Integer )myMainSel->GetManager().GetMousePosition().X(),
|
||||||
|
(Standard_Integer )myMainSel->GetManager().GetMousePosition().Y());
|
||||||
|
}
|
||||||
|
if (myLastPicked->HandleMouseClick (aMousePos, Aspect_VKeyMouse_LeftButton, Aspect_VKeyFlags_NONE, false))
|
||||||
|
{
|
||||||
|
return AIS_SOP_NothingSelected;
|
||||||
|
}
|
||||||
|
return getStatusOfPick (NbSelected());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
AIS_NListOfEntityOwner aPickedOwners;
|
||||||
|
if (!myLastPicked.IsNull() &&
|
||||||
|
myLastPicked->HasSelectable())
|
||||||
|
{
|
||||||
|
Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(myLastPicked->Selectable());
|
||||||
|
if (!anIO.IsNull() &&
|
||||||
|
myObjects.IsBound(anIO))
|
||||||
|
{
|
||||||
|
aPickedOwners.Append (myLastPicked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Select (aPickedOwners, theSelScheme);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Select
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
|
||||||
|
const Standard_Integer theYPMin,
|
||||||
|
const Standard_Integer theXPMax,
|
||||||
|
const Standard_Integer theYPMax,
|
||||||
|
const Handle(V3d_View)& theView,
|
||||||
|
const Standard_Boolean)
|
||||||
|
{
|
||||||
|
return Select (theXPMin, theYPMin, theXPMax, theYPMax, theView, AIS_SelectionScheme_ClearAndAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Select
|
||||||
|
//purpose : Selection by polyline
|
||||||
|
//=======================================================================
|
||||||
|
AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
|
||||||
|
const Handle(V3d_View)& theView,
|
||||||
|
const Standard_Boolean)
|
||||||
|
{
|
||||||
|
return Select (thePolyline, theView, AIS_SelectionScheme_ClearAndAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : Select
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean)
|
||||||
|
{
|
||||||
|
return Select (AIS_SelectionScheme_ClearAndAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : ShiftSelect
|
//function : ShiftSelect
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
|
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean)
|
||||||
{
|
{
|
||||||
if (myAutoHilight)
|
return Select (AIS_SelectionScheme_Switch);
|
||||||
{
|
|
||||||
clearDynamicHighlight();
|
|
||||||
}
|
|
||||||
if (!myLastPicked.IsNull())
|
|
||||||
{
|
|
||||||
AddOrRemoveSelected (myLastPicked, toUpdateViewer);
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer aSelNum = NbSelected();
|
|
||||||
|
|
||||||
return (aSelNum == 0) ? AIS_SOP_NothingSelected
|
|
||||||
: (aSelNum == 1) ? AIS_SOP_OneSelected
|
|
||||||
: AIS_SOP_SeveralSelected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -641,39 +641,9 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
|
|||||||
const Standard_Integer theXPMax,
|
const Standard_Integer theXPMax,
|
||||||
const Standard_Integer theYPMax,
|
const Standard_Integer theYPMax,
|
||||||
const Handle(V3d_View)& theView,
|
const Handle(V3d_View)& theView,
|
||||||
const Standard_Boolean toUpdateViewer)
|
const Standard_Boolean)
|
||||||
{
|
{
|
||||||
if (theView->Viewer() != myMainVwr)
|
return Select (theXPMin, theYPMin, theXPMax, theYPMax, theView, AIS_SelectionScheme_Switch);
|
||||||
{
|
|
||||||
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
|
|
||||||
}
|
|
||||||
|
|
||||||
myLastActiveView = theView.get();
|
|
||||||
if (myAutoHilight)
|
|
||||||
{
|
|
||||||
UnhilightSelected (Standard_False);
|
|
||||||
}
|
|
||||||
myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
|
|
||||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
|
||||||
{
|
|
||||||
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
|
|
||||||
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mySelection->Select (anOwner);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myAutoHilight)
|
|
||||||
{
|
|
||||||
HilightSelected (toUpdateViewer);
|
|
||||||
}
|
|
||||||
|
|
||||||
Standard_Integer aSelNum = NbSelected();
|
|
||||||
|
|
||||||
return (aSelNum == 0) ? AIS_SOP_NothingSelected
|
|
||||||
: (aSelNum == 1) ? AIS_SOP_OneSelected
|
|
||||||
: AIS_SOP_SeveralSelected;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -682,31 +652,31 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
|
AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
|
||||||
const Handle(V3d_View)& theView,
|
const Handle(V3d_View)& theView,
|
||||||
const Standard_Boolean toUpdateViewer)
|
const Standard_Boolean)
|
||||||
{
|
{
|
||||||
if (theView->Viewer() != myMainVwr)
|
return Select (thePolyline, theView, AIS_SelectionScheme_Switch);
|
||||||
{
|
}
|
||||||
throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument");
|
|
||||||
}
|
|
||||||
|
|
||||||
myLastActiveView = theView.get();
|
//=======================================================================
|
||||||
|
//function : Select
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_NListOfEntityOwner& theOwners,
|
||||||
|
const AIS_SelectionScheme theSelScheme)
|
||||||
|
{
|
||||||
|
// all objects detected by the selector are taken, previous current objects are emptied,
|
||||||
|
// new objects are put...
|
||||||
if (myAutoHilight)
|
if (myAutoHilight)
|
||||||
{
|
{
|
||||||
|
clearDynamicHighlight();
|
||||||
UnhilightSelected (Standard_False);
|
UnhilightSelected (Standard_False);
|
||||||
}
|
}
|
||||||
myMainSel->Pick (thePolyline, theView);
|
|
||||||
for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter)
|
|
||||||
{
|
|
||||||
const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter);
|
|
||||||
if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mySelection->Select (anOwner);
|
mySelection->SelectOwners (theOwners, theSelScheme, myFilters);
|
||||||
}
|
|
||||||
|
|
||||||
if (myAutoHilight)
|
if (myAutoHilight)
|
||||||
{
|
{
|
||||||
HilightSelected (toUpdateViewer);
|
HilightSelected (Standard_False);
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer aSelNum = NbSelected();
|
Standard_Integer aSelNum = NbSelected();
|
||||||
@@ -990,7 +960,9 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO
|
|||||||
if (myAutoHilight)
|
if (myAutoHilight)
|
||||||
{
|
{
|
||||||
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
|
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
|
||||||
Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
|
if (!myObjects.IsBound(anObj)) // e.g. AIS_ViewCubeFlat is not displayed
|
||||||
|
return;
|
||||||
|
Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
|
||||||
if (theOwner->IsSelected())
|
if (theOwner->IsSelected())
|
||||||
{
|
{
|
||||||
highlightSelected (theOwner);
|
highlightSelected (theOwner);
|
||||||
|
@@ -454,3 +454,17 @@ Standard_Boolean AIS_InteractiveContext::EndImmediateDraw()
|
|||||||
myMainPM->EndImmediateDraw (myMainVwr);
|
myMainPM->EndImmediateDraw (myMainVwr);
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : InvalidateBoundingBox
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
void AIS_InteractiveContext::InvalidateBoundingBox()
|
||||||
|
{
|
||||||
|
const Handle(V3d_Viewer)& aCurViewer = CurrentViewer();
|
||||||
|
for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
|
||||||
|
{
|
||||||
|
anActiveViewIter.Value()->View()->InvalidateAllLayerBoundingBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -86,3 +86,42 @@ void AIS_InteractiveContext::PolygonOffsets(
|
|||||||
anObj->PolygonOffsets( aMode, aFactor, aUnits );
|
anObj->PolygonOffsets( aMode, aFactor, aUnits );
|
||||||
}
|
}
|
||||||
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
// OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : DumpJson
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_InteractiveContext::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const
|
||||||
|
{
|
||||||
|
OCCT_DUMP_CLASS_BEGIN (theOStream, AIS_InteractiveContext);
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myObjects.Size());
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mgrSelector.get());
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainPM.get());
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainVwr.get());
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainSel.get());
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastActiveView);
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastPicked.get());
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToHilightSelected);
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mySelection.get());
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myFilters.get());
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myDefaultDrawer.get());
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Selected]);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Dynamic]);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalSelected]);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalDynamic]);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_SubIntensity]);
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDetectedSeq.Size());
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurDetected);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurHighlighted);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPickingStrategy);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoHilight);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsAutoActivateSelMode);
|
||||||
|
}
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <AIS_InteractiveContext.hxx>
|
#include <AIS_InteractiveContext.hxx>
|
||||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||||
|
#include <Graphic3d_AspectFillCapping.hxx>
|
||||||
#include <Graphic3d_AspectLine3d.hxx>
|
#include <Graphic3d_AspectLine3d.hxx>
|
||||||
#include <Graphic3d_AspectMarker3d.hxx>
|
#include <Graphic3d_AspectMarker3d.hxx>
|
||||||
#include <Graphic3d_AspectText3d.hxx>
|
#include <Graphic3d_AspectText3d.hxx>
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
#include <AIS_Selection.hxx>
|
#include <AIS_Selection.hxx>
|
||||||
|
|
||||||
#include <AIS_InteractiveObject.hxx>
|
#include <AIS_InteractiveObject.hxx>
|
||||||
|
#include <AIS_SelectionScheme.hxx>
|
||||||
|
#include <SelectMgr_Filter.hxx>
|
||||||
|
|
||||||
IMPLEMENT_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
|
IMPLEMENT_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient)
|
||||||
|
|
||||||
@@ -130,3 +132,71 @@ AIS_SelectStatus AIS_Selection::AddSelect (const Handle(SelectMgr_EntityOwner)&
|
|||||||
theObject->SetSelected (Standard_True);
|
theObject->SetSelected (Standard_True);
|
||||||
return AIS_SS_Added;
|
return AIS_SS_Added;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SelectOwners
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_Selection::SelectOwners (const AIS_NListOfEntityOwner& thePickedOwners,
|
||||||
|
const int theSelScheme,
|
||||||
|
const Handle(SelectMgr_Filter)& theFilter)
|
||||||
|
{
|
||||||
|
int aSelScheme = theSelScheme;
|
||||||
|
AIS_NListOfEntityOwner aPrevSelected = Objects();
|
||||||
|
if (theSelScheme & AIS_SelectionScheme_Clear)
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
|
||||||
|
if (theSelScheme & AIS_SelectionScheme_Switch &&
|
||||||
|
theSelScheme & AIS_SelectionScheme_PickedIfEmpty &&
|
||||||
|
thePickedOwners.Size() < aPrevSelected.Size())
|
||||||
|
{
|
||||||
|
// check if all picked objects are in previous selected list, if so, all objects will be deselected,
|
||||||
|
// but in mode AIS_SelectionScheme_PickedIfEmpty new picked objects should be selected, here, after Clear, Add
|
||||||
|
Standard_Boolean anOtherFound = Standard_False;
|
||||||
|
for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
|
||||||
|
{
|
||||||
|
anOtherFound = !aPrevSelected.Contains (aSelIter.Value());
|
||||||
|
if (anOtherFound)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!anOtherFound)
|
||||||
|
aSelScheme = AIS_SelectionScheme_Add;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
|
||||||
|
{
|
||||||
|
selectOwner(aSelIter.Value(), aPrevSelected, aSelScheme, theFilter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : selectOwner
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
AIS_SelectStatus AIS_Selection::selectOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||||
|
const AIS_NListOfEntityOwner& thePreviousSelected,
|
||||||
|
const int theSelScheme,
|
||||||
|
const Handle(SelectMgr_Filter)& theFilter)
|
||||||
|
{
|
||||||
|
if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk (theOwner))
|
||||||
|
return AIS_SS_NotDone;
|
||||||
|
|
||||||
|
if (theSelScheme & AIS_SelectionScheme_Add)
|
||||||
|
{
|
||||||
|
return AddSelect (theOwner);
|
||||||
|
}
|
||||||
|
else if (theSelScheme & AIS_SelectionScheme_Switch)
|
||||||
|
{
|
||||||
|
if (thePreviousSelected.Contains (theOwner)) // was selected, should not be now
|
||||||
|
{
|
||||||
|
if (theOwner->IsSelected())
|
||||||
|
return Select (theOwner); // deselect
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return AddSelect (theOwner); // was not selected, should be now
|
||||||
|
}
|
||||||
|
|
||||||
|
return AIS_SS_NotDone;
|
||||||
|
}
|
||||||
|
@@ -22,6 +22,8 @@
|
|||||||
#include <Standard.hxx>
|
#include <Standard.hxx>
|
||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
|
|
||||||
|
class SelectMgr_Filter;
|
||||||
|
|
||||||
//! Class holding the list of selected owners.
|
//! Class holding the list of selected owners.
|
||||||
class AIS_Selection : public Standard_Transient
|
class AIS_Selection : public Standard_Transient
|
||||||
{
|
{
|
||||||
@@ -75,6 +77,28 @@ public:
|
|||||||
//! Return selected object at iterator position.
|
//! Return selected object at iterator position.
|
||||||
const Handle(SelectMgr_EntityOwner)& Value() const { return myIterator.Value(); }
|
const Handle(SelectMgr_EntityOwner)& Value() const { return myIterator.Value(); }
|
||||||
|
|
||||||
|
//! Select or deselect owners depending on the selection scheme
|
||||||
|
//! \param theOwners elements to change selection state
|
||||||
|
//! \param theSelScheme selection scheme, defines how owner is selected
|
||||||
|
//! \param theFilter context filter to skip not acceptable owners
|
||||||
|
//! \return result of selection
|
||||||
|
Standard_EXPORT virtual void SelectOwners (const AIS_NListOfEntityOwner& thePickedOwners,
|
||||||
|
const int theSelScheme,
|
||||||
|
const Handle(SelectMgr_Filter)& theFilter);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Select or deselect owner depending on the selection scheme
|
||||||
|
//! \param theOwner element to change selection state
|
||||||
|
//! \param thePreviousSelected previous selected objects
|
||||||
|
//! \param theSelScheme selection scheme, defines how owner is selected
|
||||||
|
//! \param theFilter context filter to skip not acceptable owners
|
||||||
|
//! \return result of selection
|
||||||
|
Standard_EXPORT virtual AIS_SelectStatus selectOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
|
||||||
|
const AIS_NListOfEntityOwner& thePreviousSelected,
|
||||||
|
const int theSelScheme,
|
||||||
|
const Handle(SelectMgr_Filter)& theFilter);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
AIS_NListOfEntityOwner myresult;
|
AIS_NListOfEntityOwner myresult;
|
||||||
|
34
src/AIS/AIS_SelectionScheme.hxx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||||
|
//
|
||||||
|
// This file is part of Open CASCADE Technology software library.
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||||
|
// by the Free Software Foundation, with special exception defined in the file
|
||||||
|
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||||
|
// distribution for complete text of the license and disclaimer of any warranty.
|
||||||
|
//
|
||||||
|
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||||
|
// commercial license or contractual agreement.
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _AIS_SelectionScheme_HeaderFile
|
||||||
|
#define _AIS_SelectionScheme_HeaderFile
|
||||||
|
|
||||||
|
|
||||||
|
//! Sets selection schemes for interactive contexts.
|
||||||
|
//! It is possible to use combination of schemes.
|
||||||
|
enum AIS_SelectionScheme
|
||||||
|
{
|
||||||
|
AIS_SelectionScheme_Empty = 0x0000, // do nothing
|
||||||
|
AIS_SelectionScheme_Clear = 0x0001, // clears current selection
|
||||||
|
AIS_SelectionScheme_Add = 0x0002, // add detected object to current selection
|
||||||
|
AIS_SelectionScheme_Switch = 0x0004, // switch selection state in values selected/deselected
|
||||||
|
AIS_SelectionScheme_PickedIfEmpty = 0x0008, // if after switch, result selection is empty, select picked objects
|
||||||
|
AIS_SelectionScheme_ClearAndSwitch = AIS_SelectionScheme_Clear | AIS_SelectionScheme_Switch,
|
||||||
|
AIS_SelectionScheme_ClearAndAdd = AIS_SelectionScheme_Clear | AIS_SelectionScheme_Add,
|
||||||
|
AIS_SelectionScheme_ClearAndSwitchAndPicked = AIS_SelectionScheme_ClearAndSwitch | AIS_SelectionScheme_PickedIfEmpty,
|
||||||
|
AIS_SelectionScheme_Custom // reserved item for custom selection scheme
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _AIS_SelectionScheme_HeaderFile
|
@@ -180,10 +180,7 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
OCC_CATCH_SIGNALS
|
OCC_CATCH_SIGNALS
|
||||||
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer,
|
StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer, myDrawer->FillCappingAspect());
|
||||||
myDrawer->ShadingAspect()->Aspect()->ToMapTexture()
|
|
||||||
&& !myDrawer->ShadingAspect()->Aspect()->TextureMap().IsNull(),
|
|
||||||
myUVOrigin, myUVRepeat, myUVScale);
|
|
||||||
}
|
}
|
||||||
catch (Standard_Failure const& anException)
|
catch (Standard_Failure const& anException)
|
||||||
{
|
{
|
||||||
@@ -990,3 +987,23 @@ Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real & anAngle,
|
|||||||
aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
|
aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
|
||||||
return myDrawer->HasOwnHLRDeviationAngle();
|
return myDrawer->HasOwnHLRDeviationAngle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : DumpJson
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_Shape::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
|
||||||
|
{
|
||||||
|
OCCT_DUMP_CLASS_BEGIN (theOStream, AIS_Shape);
|
||||||
|
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, AIS_InteractiveObject);
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myshape);
|
||||||
|
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBB);
|
||||||
|
//OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUVOrigin);
|
||||||
|
//OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUVRepeat);
|
||||||
|
//OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUVScale);
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myInitAng);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCompBB);
|
||||||
|
}
|
||||||
|
@@ -325,6 +325,9 @@ public:
|
|||||||
const TopoDS_Shape& theShape,
|
const TopoDS_Shape& theShape,
|
||||||
const Handle(Prs3d_Drawer)& theDrawer);
|
const Handle(Prs3d_Drawer)& theDrawer);
|
||||||
|
|
||||||
|
//! Dumps the content of me into the stream
|
||||||
|
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
TopoDS_Shape myshape; //!< shape to display
|
TopoDS_Shape myshape; //!< shape to display
|
||||||
|
@@ -41,10 +41,12 @@ AIS_TextLabel::AIS_TextLabel()
|
|||||||
myFont ("Courier"),
|
myFont ("Courier"),
|
||||||
myFontAspect (Font_FA_Regular),
|
myFontAspect (Font_FA_Regular),
|
||||||
myHasOrientation3D (Standard_False),
|
myHasOrientation3D (Standard_False),
|
||||||
|
myHasOwnAnchorPoint (Standard_True),
|
||||||
myHasFlipping (Standard_False)
|
myHasFlipping (Standard_False)
|
||||||
{
|
{
|
||||||
myDrawer->SetTextAspect (new Prs3d_TextAspect());
|
myDrawer->SetTextAspect (new Prs3d_TextAspect());
|
||||||
myDrawer->SetDisplayMode (0);
|
|
||||||
|
SetDisplayMode (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -307,7 +309,12 @@ void AIS_TextLabel::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePr
|
|||||||
|
|
||||||
gp_Ax2 anOrientation = myOrientation3D;
|
gp_Ax2 anOrientation = myOrientation3D;
|
||||||
anOrientation.SetLocation (aPosition);
|
anOrientation.SetLocation (aPosition);
|
||||||
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePrs), anAsp, myText, myOrientation3D, !myHasFlipping);
|
|
||||||
|
Standard_Boolean aHasOwnAnchor = HasOwnAnchorPoint();
|
||||||
|
if (myHasFlipping)
|
||||||
|
aHasOwnAnchor = Standard_False; // always not using own anchor if flipping
|
||||||
|
|
||||||
|
Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (thePrs), anAsp, myText, myOrientation3D, aHasOwnAnchor);
|
||||||
if (myHasFlipping && isInit)
|
if (myHasFlipping && isInit)
|
||||||
{
|
{
|
||||||
Prs3d_Root::CurrentGroup (thePrs)->SetFlippingOptions (Standard_False, gp_Ax2());
|
Prs3d_Root::CurrentGroup (thePrs)->SetFlippingOptions (Standard_False, gp_Ax2());
|
||||||
|
@@ -32,9 +32,6 @@ public:
|
|||||||
//! Default constructor
|
//! Default constructor
|
||||||
Standard_EXPORT AIS_TextLabel();
|
Standard_EXPORT AIS_TextLabel();
|
||||||
|
|
||||||
//! Return TRUE for supported display mode.
|
|
||||||
virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
|
|
||||||
|
|
||||||
//! Setup color of entire text.
|
//! Setup color of entire text.
|
||||||
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
|
Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE;
|
||||||
|
|
||||||
@@ -93,6 +90,12 @@ public:
|
|||||||
|
|
||||||
Standard_EXPORT Standard_Boolean HasFlipping() const;
|
Standard_EXPORT Standard_Boolean HasFlipping() const;
|
||||||
|
|
||||||
|
//! Returns flag if text uses position as point of attach
|
||||||
|
Standard_Boolean HasOwnAnchorPoint() const { return myHasOwnAnchorPoint; }
|
||||||
|
|
||||||
|
//! Set flag if text uses position as point of attach
|
||||||
|
void SetOwnAnchorPoint (const Standard_Boolean theOwnAnchorPoint) { myHasOwnAnchorPoint = theOwnAnchorPoint; }
|
||||||
|
|
||||||
//! Define the display type of the text.
|
//! Define the display type of the text.
|
||||||
//!
|
//!
|
||||||
//! TODT_NORMAL Default display. Text only.
|
//! TODT_NORMAL Default display. Text only.
|
||||||
@@ -124,6 +127,7 @@ protected:
|
|||||||
Font_FontAspect myFontAspect;
|
Font_FontAspect myFontAspect;
|
||||||
gp_Ax2 myOrientation3D;
|
gp_Ax2 myOrientation3D;
|
||||||
Standard_Boolean myHasOrientation3D;
|
Standard_Boolean myHasOrientation3D;
|
||||||
|
Standard_Boolean myHasOwnAnchorPoint;
|
||||||
Standard_Boolean myHasFlipping;
|
Standard_Boolean myHasFlipping;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@@ -995,3 +995,33 @@ Handle(Prs3d_PointAspect) AIS_Trihedron::getHighlightPointAspect()
|
|||||||
|
|
||||||
return myHighlightPointAspect;
|
return myHighlightPointAspect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : DumpJson
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void AIS_Trihedron::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
|
||||||
|
{
|
||||||
|
OCCT_DUMP_CLASS_BEGIN (theOStream, AIS_Trihedron);
|
||||||
|
|
||||||
|
OCCT_DUMP_BASE_CLASS (theOStream, theDepth, AIS_InteractiveObject);
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnSize);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnTextColor);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnArrowColor);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDatumAspect);
|
||||||
|
OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTrihDispMode);
|
||||||
|
|
||||||
|
//Handle(Geom_Axis2Placement) myComponent;
|
||||||
|
//NCollection_DataMap<Prs3d_DatumParts, Standard_Integer> mySelectionPriority;
|
||||||
|
//NCollection_DataMap<Prs3d_DatumParts, TCollection_ExtendedString> myLabel;
|
||||||
|
|
||||||
|
//NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_Group)> myPartToGroup;
|
||||||
|
//NCollection_List<Prs3d_DatumParts> mySelectedParts;
|
||||||
|
|
||||||
|
OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myHighlightAspect.get());
|
||||||
|
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myHighlightLineAspect.get());
|
||||||
|
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myHighlightPointAspect.get());
|
||||||
|
|
||||||
|
//NCollection_DataMap<Prs3d_DatumParts, Handle(Graphic3d_ArrayOfPrimitives)> myPrimitives;
|
||||||
|
}
|
||||||
|
@@ -222,6 +222,9 @@ protected:
|
|||||||
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
|
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
|
||||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||||
|
|
||||||
|
//! Dumps the content of me into the stream
|
||||||
|
Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//! Creates a sensitive entity for the datum part that will be used in selection owner creation.
|
//! Creates a sensitive entity for the datum part that will be used in selection owner creation.
|
||||||
|
@@ -69,7 +69,6 @@ AIS_ViewController::AIS_ViewController()
|
|||||||
myMousePressed (Aspect_VKeyMouse_NONE),
|
myMousePressed (Aspect_VKeyMouse_NONE),
|
||||||
myMouseModifiers (Aspect_VKeyFlags_NONE),
|
myMouseModifiers (Aspect_VKeyFlags_NONE),
|
||||||
myMouseSingleButton (-1),
|
myMouseSingleButton (-1),
|
||||||
myMouseStopDragOnUnclick (false),
|
|
||||||
//
|
//
|
||||||
myTouchToleranceScale (1.0f),
|
myTouchToleranceScale (1.0f),
|
||||||
myTouchRotationThresholdPx (6.0f),
|
myTouchRotationThresholdPx (6.0f),
|
||||||
@@ -612,7 +611,6 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
|
|||||||
{
|
{
|
||||||
myMouseClickTimer.Stop();
|
myMouseClickTimer.Stop();
|
||||||
myMouseClickCounter = 0;
|
myMouseClickCounter = 0;
|
||||||
myMouseStopDragOnUnclick = false;
|
|
||||||
myUI.Dragging.ToStop = true;
|
myUI.Dragging.ToStop = true;
|
||||||
toUpdateView = true;
|
toUpdateView = true;
|
||||||
}
|
}
|
||||||
@@ -621,12 +619,6 @@ bool AIS_ViewController::UpdateMouseButtons (const Graphic3d_Vec2i& thePoint,
|
|||||||
else if (theButtons == Aspect_VKeyMouse_NONE)
|
else if (theButtons == Aspect_VKeyMouse_NONE)
|
||||||
{
|
{
|
||||||
myMouseSingleButton = -1;
|
myMouseSingleButton = -1;
|
||||||
if (myMouseStopDragOnUnclick)
|
|
||||||
{
|
|
||||||
myMouseStopDragOnUnclick = false;
|
|
||||||
myUI.Dragging.ToStop = true;
|
|
||||||
toUpdateView = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (myMouseSingleButton == -1)
|
else if (myMouseSingleButton == -1)
|
||||||
{
|
{
|
||||||
@@ -777,7 +769,6 @@ bool AIS_ViewController::UpdateMousePosition (const Graphic3d_Vec2i& thePoint,
|
|||||||
myMouseClickTimer.Stop();
|
myMouseClickTimer.Stop();
|
||||||
myMouseClickCounter = 0;
|
myMouseClickCounter = 0;
|
||||||
myMouseSingleButton = -1;
|
myMouseSingleButton = -1;
|
||||||
myMouseStopDragOnUnclick = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -647,7 +647,6 @@ protected: //! @name mouse input variables
|
|||||||
Aspect_VKeyMouse myMousePressed; //!< active mouse buttons
|
Aspect_VKeyMouse myMousePressed; //!< active mouse buttons
|
||||||
Aspect_VKeyFlags myMouseModifiers; //!< active key modifiers passed with last mouse event
|
Aspect_VKeyFlags myMouseModifiers; //!< active key modifiers passed with last mouse event
|
||||||
Standard_Integer myMouseSingleButton; //!< index of mouse button pressed alone (>0)
|
Standard_Integer myMouseSingleButton; //!< index of mouse button pressed alone (>0)
|
||||||
Standard_Boolean myMouseStopDragOnUnclick; //!< queue stop dragging even with at next mouse unclick
|
|
||||||
|
|
||||||
protected: //! @name multi-touch input variables
|
protected: //! @name multi-touch input variables
|
||||||
|
|
||||||
|
@@ -137,9 +137,6 @@ AIS_ViewCube::AIS_ViewCube()
|
|||||||
myBoxEdgeGap (0.0),
|
myBoxEdgeGap (0.0),
|
||||||
myBoxFacetExtension (1.0),
|
myBoxFacetExtension (1.0),
|
||||||
myAxesPadding (1.0),
|
myAxesPadding (1.0),
|
||||||
myAxesRadius (1.0),
|
|
||||||
myAxesConeRadius (3.0),
|
|
||||||
myAxesSphereRadius (4.0),
|
|
||||||
myCornerMinSize (2.0),
|
myCornerMinSize (2.0),
|
||||||
myRoundRadius (0.0),
|
myRoundRadius (0.0),
|
||||||
myToDisplayAxes (true),
|
myToDisplayAxes (true),
|
||||||
@@ -602,7 +599,7 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
|||||||
anAxisGroup->SetGroupPrimitivesAspect (aDatumAspect->ShadingAspect (aPart)->Aspect());
|
anAxisGroup->SetGroupPrimitivesAspect (aDatumAspect->ShadingAspect (aPart)->Aspect());
|
||||||
|
|
||||||
const Standard_Real anArrowLength = 0.2 * anAxisSize;
|
const Standard_Real anArrowLength = 0.2 * anAxisSize;
|
||||||
Handle(Graphic3d_ArrayOfTriangles) aTriangleArray = Prs3d_Arrow::DrawShaded (anAx1, myAxesRadius, anAxisSize, myAxesConeRadius, anArrowLength, THE_NB_ARROW_FACETTES);
|
Handle(Graphic3d_ArrayOfTriangles) aTriangleArray = Prs3d_Arrow::DrawShaded (anAx1, 1.0, anAxisSize, 3.0, anArrowLength, THE_NB_ARROW_FACETTES);
|
||||||
anAxisGroup->AddPrimitiveArray (aTriangleArray);
|
anAxisGroup->AddPrimitiveArray (aTriangleArray);
|
||||||
|
|
||||||
TCollection_AsciiString anAxisLabel;
|
TCollection_AsciiString anAxisLabel;
|
||||||
@@ -624,7 +621,7 @@ void AIS_ViewCube::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
|
|||||||
Handle(Prs3d_ShadingAspect) anAspectCen = new Prs3d_ShadingAspect();
|
Handle(Prs3d_ShadingAspect) anAspectCen = new Prs3d_ShadingAspect();
|
||||||
anAspectCen->SetColor (Quantity_NOC_WHITE);
|
anAspectCen->SetColor (Quantity_NOC_WHITE);
|
||||||
aGroup->SetGroupPrimitivesAspect (anAspectCen->Aspect());
|
aGroup->SetGroupPrimitivesAspect (anAspectCen->Aspect());
|
||||||
Prs3d_ToolSphere aTool (myAxesSphereRadius, THE_NB_DISK_SLICES, THE_NB_DISK_SLICES);
|
Prs3d_ToolSphere aTool (4.0, THE_NB_DISK_SLICES, THE_NB_DISK_SLICES);
|
||||||
gp_Trsf aTrsf;
|
gp_Trsf aTrsf;
|
||||||
aTrsf.SetTranslation (gp_Vec (gp::Origin(), aLocation));
|
aTrsf.SetTranslation (gp_Vec (gp::Origin(), aLocation));
|
||||||
Handle(Graphic3d_ArrayOfTriangles) aCenterArray;
|
Handle(Graphic3d_ArrayOfTriangles) aCenterArray;
|
||||||
|
@@ -189,45 +189,6 @@ public: //! @name Geometry management API
|
|||||||
//! The value should be within [0, 0.5] range.
|
//! The value should be within [0, 0.5] range.
|
||||||
Standard_EXPORT void SetRoundRadius (const Standard_Real theValue);
|
Standard_EXPORT void SetRoundRadius (const Standard_Real theValue);
|
||||||
|
|
||||||
//! Returns radius of axes of the trihedron; 1.0 by default.
|
|
||||||
Standard_Real AxesRadius() const { return myAxesRadius; }
|
|
||||||
|
|
||||||
//! Sets radius of axes of the trihedron.
|
|
||||||
void SetAxesRadius (const Standard_Real theRadius)
|
|
||||||
{
|
|
||||||
if (Abs (myAxesRadius - theRadius) > Precision::Confusion())
|
|
||||||
{
|
|
||||||
myAxesRadius = theRadius;
|
|
||||||
SetToUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Returns radius of cone of axes of the trihedron; 3.0 by default.
|
|
||||||
Standard_Real AxesConeRadius() const { return myAxesConeRadius; }
|
|
||||||
|
|
||||||
//! Sets radius of cone of axes of the trihedron.
|
|
||||||
void SetAxesConeRadius (Standard_Real theRadius)
|
|
||||||
{
|
|
||||||
if (Abs (myAxesConeRadius - theRadius) > Precision::Confusion())
|
|
||||||
{
|
|
||||||
myAxesConeRadius = theRadius;
|
|
||||||
SetToUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Returns radius of sphere (central point) of the trihedron; 4.0 by default.
|
|
||||||
Standard_Real AxesSphereRadius() const { return myAxesSphereRadius; }
|
|
||||||
|
|
||||||
//! Sets radius of sphere (central point) of the trihedron.
|
|
||||||
void SetAxesSphereRadius (Standard_Real theRadius)
|
|
||||||
{
|
|
||||||
if (Abs (myAxesSphereRadius - theRadius) > Precision::Confusion())
|
|
||||||
{
|
|
||||||
myAxesSphereRadius = theRadius;
|
|
||||||
SetToUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! @return TRUE if trihedron is drawn; TRUE by default.
|
//! @return TRUE if trihedron is drawn; TRUE by default.
|
||||||
Standard_Boolean ToDrawAxes() const { return myToDisplayAxes; }
|
Standard_Boolean ToDrawAxes() const { return myToDisplayAxes; }
|
||||||
|
|
||||||
@@ -660,9 +621,6 @@ protected:
|
|||||||
Standard_Real myBoxEdgeGap; //!< gap between box side and box edge
|
Standard_Real myBoxEdgeGap; //!< gap between box side and box edge
|
||||||
Standard_Real myBoxFacetExtension; //!< box facet extension
|
Standard_Real myBoxFacetExtension; //!< box facet extension
|
||||||
Standard_Real myAxesPadding; //!< Padding between box and axes
|
Standard_Real myAxesPadding; //!< Padding between box and axes
|
||||||
Standard_Real myAxesRadius; //!< radius of axes of the trihedron; 1.0 by default
|
|
||||||
Standard_Real myAxesConeRadius; //!< radius of cone of axes of the trihedron; 3.0 by default
|
|
||||||
Standard_Real myAxesSphereRadius; //!< radius of sphere (central point) of the trihedron; 4.0 by default
|
|
||||||
Standard_Real myCornerMinSize; //!< minimal size of box corner
|
Standard_Real myCornerMinSize; //!< minimal size of box corner
|
||||||
Standard_Real myRoundRadius; //!< relative round radius within [0; 0.5] range
|
Standard_Real myRoundRadius; //!< relative round radius within [0; 0.5] range
|
||||||
Standard_Boolean myToDisplayAxes; //!< trihedron visibility
|
Standard_Boolean myToDisplayAxes; //!< trihedron visibility
|
||||||
|
@@ -145,6 +145,7 @@ AIS_Selection.cxx
|
|||||||
AIS_Selection.hxx
|
AIS_Selection.hxx
|
||||||
AIS_SelectStatus.hxx
|
AIS_SelectStatus.hxx
|
||||||
AIS_SelectionModesConcurrency.hxx
|
AIS_SelectionModesConcurrency.hxx
|
||||||
|
AIS_SelectionScheme.hxx
|
||||||
AIS_SequenceOfDimension.hxx
|
AIS_SequenceOfDimension.hxx
|
||||||
AIS_SequenceOfInteractive.hxx
|
AIS_SequenceOfInteractive.hxx
|
||||||
AIS_Shape.cxx
|
AIS_Shape.cxx
|
||||||
|
@@ -27,10 +27,8 @@
|
|||||||
#include <Geom2d_BSplineCurve.hxx>
|
#include <Geom2d_BSplineCurve.hxx>
|
||||||
#include <Geom2dAdaptor_HCurve.hxx>
|
#include <Geom2dAdaptor_HCurve.hxx>
|
||||||
#include <Geom_BSplineCurve.hxx>
|
#include <Geom_BSplineCurve.hxx>
|
||||||
#include <Geom_TrimmedCurve.hxx>
|
|
||||||
#include <GeomAdaptor_HCurve.hxx>
|
#include <GeomAdaptor_HCurve.hxx>
|
||||||
#include <GeomAdaptor_HSurface.hxx>
|
#include <GeomAdaptor_HSurface.hxx>
|
||||||
#include <GeomConvert.hxx>
|
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <gp_Vec.hxx>
|
#include <gp_Vec.hxx>
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
@@ -302,10 +300,6 @@ void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : Approx_CurveOnSurface
|
|
||||||
//purpose : Constructor
|
|
||||||
//=============================================================================
|
|
||||||
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C2D,
|
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C2D,
|
||||||
const Handle(Adaptor3d_HSurface)& Surf,
|
const Handle(Adaptor3d_HSurface)& Surf,
|
||||||
const Standard_Real First,
|
const Standard_Real First,
|
||||||
@@ -316,75 +310,14 @@ void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
|
|||||||
const Standard_Integer MaxSegments,
|
const Standard_Integer MaxSegments,
|
||||||
const Standard_Boolean only3d,
|
const Standard_Boolean only3d,
|
||||||
const Standard_Boolean only2d)
|
const Standard_Boolean only2d)
|
||||||
: myC2D(C2D),
|
|
||||||
mySurf(Surf),
|
|
||||||
myFirst(First),
|
|
||||||
myLast(Last),
|
|
||||||
myTol(Tol),
|
|
||||||
myIsDone(Standard_False),
|
|
||||||
myHasResult(Standard_False),
|
|
||||||
myError3d(0.0),
|
|
||||||
myError2dU(0.0),
|
|
||||||
myError2dV(0.0)
|
|
||||||
{
|
|
||||||
Perform(MaxSegments, MaxDegree, S, only3d, only2d);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : Approx_CurveOnSurface
|
|
||||||
//purpose : Constructor
|
|
||||||
//=============================================================================
|
|
||||||
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& theC2D,
|
|
||||||
const Handle(Adaptor3d_HSurface)& theSurf,
|
|
||||||
const Standard_Real theFirst,
|
|
||||||
const Standard_Real theLast,
|
|
||||||
const Standard_Real theTol)
|
|
||||||
: myC2D(theC2D),
|
|
||||||
mySurf(theSurf),
|
|
||||||
myFirst(theFirst),
|
|
||||||
myLast(theLast),
|
|
||||||
myTol(theTol),
|
|
||||||
myIsDone(Standard_False),
|
|
||||||
myHasResult(Standard_False),
|
|
||||||
myError3d(0.0),
|
|
||||||
myError2dU(0.0),
|
|
||||||
myError2dV(0.0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : Perform
|
|
||||||
//purpose :
|
|
||||||
//=============================================================================
|
|
||||||
void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|
||||||
const Standard_Integer theMaxDegree,
|
|
||||||
const GeomAbs_Shape theContinuity,
|
|
||||||
const Standard_Boolean theOnly3d,
|
|
||||||
const Standard_Boolean theOnly2d)
|
|
||||||
{
|
{
|
||||||
myIsDone = Standard_False;
|
myIsDone = Standard_False;
|
||||||
myHasResult = Standard_False;
|
if(only3d && only2d) throw Standard_ConstructionError();
|
||||||
myError2dU = 0.0;
|
GeomAbs_Shape Order = S;
|
||||||
myError2dV = 0.0;
|
|
||||||
myError3d = 0.0;
|
|
||||||
|
|
||||||
if(theOnly3d && theOnly2d) throw Standard_ConstructionError();
|
Handle( Adaptor2d_HCurve2d ) TrimmedC2D = C2D->Trim( First, Last, Precision::PConfusion() );
|
||||||
|
|
||||||
Handle( Adaptor2d_HCurve2d ) TrimmedC2D = myC2D->Trim( myFirst, myLast, Precision::PConfusion() );
|
Adaptor3d_CurveOnSurface COnS( TrimmedC2D, Surf );
|
||||||
|
|
||||||
Standard_Boolean isU, isForward;
|
|
||||||
Standard_Real aParam;
|
|
||||||
if (theOnly3d && isIsoLine(TrimmedC2D, isU, aParam, isForward))
|
|
||||||
{
|
|
||||||
if (buildC3dOnIsoLine(TrimmedC2D, isU, aParam, isForward))
|
|
||||||
{
|
|
||||||
myIsDone = Standard_True;
|
|
||||||
myHasResult = Standard_True;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Adaptor3d_CurveOnSurface COnS( TrimmedC2D, mySurf );
|
|
||||||
Handle(Adaptor3d_HCurveOnSurface) HCOnS = new Adaptor3d_HCurveOnSurface();
|
Handle(Adaptor3d_HCurveOnSurface) HCOnS = new Adaptor3d_HCurveOnSurface();
|
||||||
HCOnS->Set(COnS);
|
HCOnS->Set(COnS);
|
||||||
|
|
||||||
@@ -394,34 +327,37 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|||||||
Handle(TColStd_HArray1OfReal) ThreeDTol;
|
Handle(TColStd_HArray1OfReal) ThreeDTol;
|
||||||
|
|
||||||
// create evaluators and choose appropriate one
|
// create evaluators and choose appropriate one
|
||||||
Approx_CurveOnSurface_Eval3d Eval3dCvOnSurf (HCOnS, myFirst, myLast);
|
Approx_CurveOnSurface_Eval3d Eval3dCvOnSurf (HCOnS, First, Last);
|
||||||
Approx_CurveOnSurface_Eval2d Eval2dCvOnSurf ( TrimmedC2D, myFirst, myLast);
|
Approx_CurveOnSurface_Eval2d Eval2dCvOnSurf ( TrimmedC2D, First, Last);
|
||||||
Approx_CurveOnSurface_Eval EvalCvOnSurf (HCOnS, TrimmedC2D, myFirst, myLast);
|
Approx_CurveOnSurface_Eval EvalCvOnSurf (HCOnS, TrimmedC2D, First, Last);
|
||||||
AdvApprox_EvaluatorFunction* EvalPtr;
|
AdvApprox_EvaluatorFunction* EvalPtr;
|
||||||
if ( theOnly3d ) EvalPtr = &Eval3dCvOnSurf;
|
if ( only3d ) EvalPtr = &Eval3dCvOnSurf;
|
||||||
else if ( theOnly2d ) EvalPtr = &Eval2dCvOnSurf;
|
else if ( only2d ) EvalPtr = &Eval2dCvOnSurf;
|
||||||
else EvalPtr = &EvalCvOnSurf;
|
else EvalPtr = &EvalCvOnSurf;
|
||||||
|
|
||||||
// Initialization for 2d approximation
|
// Initialization for 2d approximation
|
||||||
if(!theOnly3d) {
|
if(!only3d) {
|
||||||
Num1DSS = 2;
|
Num1DSS = 2;
|
||||||
OneDTol = new TColStd_HArray1OfReal(1,Num1DSS);
|
OneDTol = new TColStd_HArray1OfReal(1,Num1DSS);
|
||||||
|
|
||||||
Standard_Real TolU, TolV;
|
Standard_Real TolU, TolV;
|
||||||
|
|
||||||
TolU = mySurf->UResolution(myTol)/2;
|
TolU = Surf->UResolution(Tol)/2;
|
||||||
TolV = mySurf->VResolution(myTol)/2;
|
TolV = Surf->VResolution(Tol)/2;
|
||||||
|
|
||||||
OneDTol->SetValue(1,TolU);
|
OneDTol->SetValue(1,TolU);
|
||||||
OneDTol->SetValue(2,TolV);
|
OneDTol->SetValue(2,TolV);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!theOnly2d) {
|
if(!only2d) {
|
||||||
Num3DSS=1;
|
Num3DSS=1;
|
||||||
ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS);
|
ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS);
|
||||||
ThreeDTol->Init(myTol/2);
|
ThreeDTol->Init(Tol/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myError2dU = 0;
|
||||||
|
myError2dV = 0;
|
||||||
|
myError3d = 0;
|
||||||
|
|
||||||
Standard_Integer NbInterv_C2 = HCOnS->NbIntervals(GeomAbs_C2);
|
Standard_Integer NbInterv_C2 = HCOnS->NbIntervals(GeomAbs_C2);
|
||||||
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
|
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
|
||||||
@@ -433,8 +369,8 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|||||||
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
|
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
|
||||||
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
|
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
|
||||||
OneDTol, TwoDTolNul, ThreeDTol,
|
OneDTol, TwoDTolNul, ThreeDTol,
|
||||||
myFirst, myLast, theContinuity,
|
First, Last, Order,
|
||||||
theMaxDegree, theMaxSegments,
|
MaxDegree, MaxSegments,
|
||||||
*EvalPtr, CutTool);
|
*EvalPtr, CutTool);
|
||||||
|
|
||||||
myIsDone = aApprox.IsDone();
|
myIsDone = aApprox.IsDone();
|
||||||
@@ -445,14 +381,14 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|||||||
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
|
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
|
||||||
Standard_Integer Degree = aApprox.Degree();
|
Standard_Integer Degree = aApprox.Degree();
|
||||||
|
|
||||||
if(!theOnly2d)
|
if(!only2d)
|
||||||
{
|
{
|
||||||
TColgp_Array1OfPnt Poles(1,aApprox.NbPoles());
|
TColgp_Array1OfPnt Poles(1,aApprox.NbPoles());
|
||||||
aApprox.Poles(1,Poles);
|
aApprox.Poles(1,Poles);
|
||||||
myCurve3d = new Geom_BSplineCurve(Poles, Knots->Array1(), Mults->Array1(), Degree);
|
myCurve3d = new Geom_BSplineCurve(Poles, Knots->Array1(), Mults->Array1(), Degree);
|
||||||
myError3d = aApprox.MaxError(3, 1);
|
myError3d = aApprox.MaxError(3, 1);
|
||||||
}
|
}
|
||||||
if(!theOnly3d)
|
if(!only3d)
|
||||||
{
|
{
|
||||||
TColgp_Array1OfPnt2d Poles2d(1,aApprox.NbPoles());
|
TColgp_Array1OfPnt2d Poles2d(1,aApprox.NbPoles());
|
||||||
TColStd_Array1OfReal Poles1dU(1,aApprox.NbPoles());
|
TColStd_Array1OfReal Poles1dU(1,aApprox.NbPoles());
|
||||||
@@ -468,6 +404,8 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Boolean Approx_CurveOnSurface::IsDone() const
|
Standard_Boolean Approx_CurveOnSurface::IsDone() const
|
||||||
@@ -505,161 +443,3 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|||||||
return myError2dV;
|
return myError2dV;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : isIsoLine
|
|
||||||
//purpose :
|
|
||||||
//=============================================================================
|
|
||||||
Standard_Boolean Approx_CurveOnSurface::isIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
Standard_Boolean& theIsU,
|
|
||||||
Standard_Real& theParam,
|
|
||||||
Standard_Boolean& theIsForward) const
|
|
||||||
{
|
|
||||||
// These variables are used to check line state (vertical or horizontal).
|
|
||||||
Standard_Boolean isAppropriateType = Standard_False;
|
|
||||||
gp_Pnt2d aLoc2d;
|
|
||||||
gp_Dir2d aDir2d;
|
|
||||||
|
|
||||||
// Test type.
|
|
||||||
const GeomAbs_CurveType aType = theC2D->GetType();
|
|
||||||
if (aType == GeomAbs_Line)
|
|
||||||
{
|
|
||||||
gp_Lin2d aLin2d = theC2D->Line();
|
|
||||||
aLoc2d = aLin2d.Location();
|
|
||||||
aDir2d = aLin2d.Direction();
|
|
||||||
isAppropriateType = Standard_True;
|
|
||||||
}
|
|
||||||
else if (aType == GeomAbs_BSplineCurve)
|
|
||||||
{
|
|
||||||
Handle(Geom2d_BSplineCurve) aBSpline2d = theC2D->BSpline();
|
|
||||||
if (aBSpline2d->Degree() != 1 || aBSpline2d->NbPoles() != 2)
|
|
||||||
return Standard_False; // Not a line or uneven parameterization.
|
|
||||||
|
|
||||||
aLoc2d = aBSpline2d->Pole(1);
|
|
||||||
|
|
||||||
// Vector should be non-degenerated.
|
|
||||||
gp_Vec2d aVec2d(aBSpline2d->Pole(1), aBSpline2d->Pole(2));
|
|
||||||
if (aVec2d.SquareMagnitude() < Precision::Confusion())
|
|
||||||
return Standard_False; // Degenerated spline.
|
|
||||||
aDir2d = aVec2d;
|
|
||||||
|
|
||||||
isAppropriateType = Standard_True;
|
|
||||||
}
|
|
||||||
else if (aType == GeomAbs_BezierCurve)
|
|
||||||
{
|
|
||||||
Handle(Geom2d_BezierCurve) aBezier2d = theC2D->Bezier();
|
|
||||||
if (aBezier2d->Degree() != 1 || aBezier2d->NbPoles() != 2)
|
|
||||||
return Standard_False; // Not a line or uneven parameterization.
|
|
||||||
|
|
||||||
aLoc2d = aBezier2d->Pole(1);
|
|
||||||
|
|
||||||
// Vector should be non-degenerated.
|
|
||||||
gp_Vec2d aVec2d(aBezier2d->Pole(1), aBezier2d->Pole(2));
|
|
||||||
if (aVec2d.SquareMagnitude() < Precision::Confusion())
|
|
||||||
return Standard_False; // Degenerated spline.
|
|
||||||
aDir2d = aVec2d;
|
|
||||||
|
|
||||||
isAppropriateType = Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAppropriateType)
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
// Check line to be vertical or horizontal.
|
|
||||||
if (aDir2d.IsParallel(gp::DX2d(), Precision::Angular()))
|
|
||||||
{
|
|
||||||
// Horizontal line. V = const.
|
|
||||||
theIsU = Standard_False;
|
|
||||||
theParam = aLoc2d.Y();
|
|
||||||
theIsForward = aDir2d.Dot(gp::DX2d()) > 0.0;
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
else if (aDir2d.IsParallel(gp::DY2d(), Precision::Angular()))
|
|
||||||
{
|
|
||||||
// Vertical line. U = const.
|
|
||||||
theIsU = Standard_True;
|
|
||||||
theParam = aLoc2d.X();
|
|
||||||
theIsForward = aDir2d.Dot(gp::DY2d()) > 0.0;
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <GeomLib.hxx>
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : buildC3dOnIsoLine
|
|
||||||
//purpose :
|
|
||||||
//=============================================================================
|
|
||||||
Standard_Boolean Approx_CurveOnSurface::buildC3dOnIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
const Standard_Boolean theIsU,
|
|
||||||
const Standard_Real theParam,
|
|
||||||
const Standard_Boolean theIsForward)
|
|
||||||
{
|
|
||||||
// Convert adapter to the appropriate type.
|
|
||||||
Handle(GeomAdaptor_HSurface) aGeomAdapter = Handle(GeomAdaptor_HSurface)::DownCast(mySurf);
|
|
||||||
if (aGeomAdapter.IsNull())
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
if (mySurf->GetType() == GeomAbs_Sphere)
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
// Extract isoline
|
|
||||||
Handle(Geom_Surface) aSurf = aGeomAdapter->ChangeSurface().Surface();
|
|
||||||
Handle(Geom_Curve) aC3d;
|
|
||||||
|
|
||||||
gp_Pnt2d aF2d = theC2D->Value(theC2D->FirstParameter());
|
|
||||||
gp_Pnt2d aL2d = theC2D->Value(theC2D->LastParameter());
|
|
||||||
|
|
||||||
if (theIsU)
|
|
||||||
{
|
|
||||||
aC3d = aSurf->UIso(theParam);
|
|
||||||
aC3d = new Geom_TrimmedCurve(aC3d, aF2d.Y(), aL2d.Y());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aC3d = aSurf->VIso(theParam);
|
|
||||||
aC3d = new Geom_TrimmedCurve(aC3d, aF2d.X(), aL2d.X());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert arbitrary curve type to the b-spline.
|
|
||||||
myCurve3d = GeomConvert::CurveToBSplineCurve(aC3d, Convert_QuasiAngular);
|
|
||||||
if (!theIsForward)
|
|
||||||
myCurve3d->Reverse();
|
|
||||||
|
|
||||||
// Rebuild parameterization for the 3d curve to have the same parameterization with
|
|
||||||
// a two-dimensional curve.
|
|
||||||
TColStd_Array1OfReal aKnots = myCurve3d->Knots();
|
|
||||||
BSplCLib::Reparametrize(theC2D->FirstParameter(), theC2D->LastParameter(), aKnots);
|
|
||||||
myCurve3d->SetKnots(aKnots);
|
|
||||||
|
|
||||||
// Evaluate error.
|
|
||||||
myError3d = 0.0;
|
|
||||||
|
|
||||||
const Standard_Real aParF = myFirst;
|
|
||||||
const Standard_Real aParL = myLast;
|
|
||||||
const Standard_Integer aNbPnt = 23;
|
|
||||||
for(Standard_Integer anIdx = 0; anIdx <= aNbPnt; ++anIdx)
|
|
||||||
{
|
|
||||||
const Standard_Real aPar = aParF + ((aParL - aParF) * anIdx) / aNbPnt;
|
|
||||||
|
|
||||||
const gp_Pnt2d aPnt2d = theC2D->Value(aPar);
|
|
||||||
|
|
||||||
const gp_Pnt aPntC3D = myCurve3d->Value(aPar);
|
|
||||||
const gp_Pnt aPntC2D = mySurf->Value(aPnt2d.X(), aPnt2d.Y());
|
|
||||||
|
|
||||||
const Standard_Real aSqDeviation = aPntC3D.SquareDistance(aPntC2D);
|
|
||||||
myError3d = Max(aSqDeviation, myError3d);
|
|
||||||
}
|
|
||||||
|
|
||||||
myError3d = Sqrt(myError3d);
|
|
||||||
|
|
||||||
// Target tolerance is not obtained. This situation happens for isolines on the sphere.
|
|
||||||
// OCCT is unable to convert it keeping original parameterization, while the geometric
|
|
||||||
// form of the result is entirely identical. In that case, it is better to utilize
|
|
||||||
// a general-purpose approach.
|
|
||||||
if (myError3d > myTol)
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
|
@@ -40,22 +40,9 @@ public:
|
|||||||
|
|
||||||
DEFINE_STANDARD_ALLOC
|
DEFINE_STANDARD_ALLOC
|
||||||
|
|
||||||
//! This constructor calls perform method. This constructor is deprecated.
|
|
||||||
Standard_DEPRECATED("This constructor is deprecated. Use other constructor and perform method instead.")
|
|
||||||
Standard_EXPORT Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C2D, const Handle(Adaptor3d_HSurface)& Surf, const Standard_Real First, const Standard_Real Last, const Standard_Real Tol, const GeomAbs_Shape Continuity, const Standard_Integer MaxDegree, const Standard_Integer MaxSegments, const Standard_Boolean Only3d = Standard_False, const Standard_Boolean Only2d = Standard_False);
|
Standard_EXPORT Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C2D, const Handle(Adaptor3d_HSurface)& Surf, const Standard_Real First, const Standard_Real Last, const Standard_Real Tol, const GeomAbs_Shape Continuity, const Standard_Integer MaxDegree, const Standard_Integer MaxSegments, const Standard_Boolean Only3d = Standard_False, const Standard_Boolean Only2d = Standard_False);
|
||||||
|
|
||||||
//! This constructor does not call perform method.
|
|
||||||
//! @param theC2D 2D Curve to be approximated in 3D.
|
|
||||||
//! @param theSurf Surface where 2D curve is located.
|
|
||||||
//! @param theFirst First parameter of resulting curve.
|
|
||||||
//! @param theFirst Last parameter of resulting curve.
|
|
||||||
//! @param theTol Computation tolerance.
|
|
||||||
Standard_EXPORT Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& theC2D,
|
|
||||||
const Handle(Adaptor3d_HSurface)& theSurf,
|
|
||||||
const Standard_Real theFirst,
|
|
||||||
const Standard_Real theLast,
|
|
||||||
const Standard_Real theTol);
|
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean IsDone() const;
|
Standard_EXPORT Standard_Boolean IsDone() const;
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean HasResult() const;
|
Standard_EXPORT Standard_Boolean HasResult() const;
|
||||||
@@ -72,64 +59,18 @@ public:
|
|||||||
//! 2d Curve
|
//! 2d Curve
|
||||||
Standard_EXPORT Standard_Real MaxError2dV() const;
|
Standard_EXPORT Standard_Real MaxError2dV() const;
|
||||||
|
|
||||||
//! Constructs the 3d curve. Input parameters are ignored when the input curve is
|
|
||||||
//! U-isoline or V-isoline.
|
|
||||||
//! @param theMaxSegments Maximal number of segments in the resulting spline.
|
|
||||||
//! @param theMaxDegree Maximal degree of the result.
|
|
||||||
//! @param theContinuity Resulting continuity.
|
|
||||||
//! @param theOnly3d Determines building only 3D curve.
|
|
||||||
//! @param theOnly2d Determines building only 2D curve.
|
|
||||||
Standard_EXPORT void Perform(const Standard_Integer theMaxSegments,
|
|
||||||
const Standard_Integer theMaxDegree,
|
|
||||||
const GeomAbs_Shape theContinuity,
|
|
||||||
const Standard_Boolean theOnly3d = Standard_False,
|
|
||||||
const Standard_Boolean theOnly2d = Standard_False);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//! Checks whether the 2d curve is a isoline. It can be represented by b-spline, bezier,
|
|
||||||
//! or geometric line. This line should have natural parameterization.
|
|
||||||
//! @param theC2D Trimmed curve to be checked.
|
|
||||||
//! @param theIsU Flag indicating that line is u const.
|
|
||||||
//! @param theParam Line parameter.
|
|
||||||
//! @param theIsForward Flag indicating forward parameterization on a isoline.
|
|
||||||
//! @return Standard_True when 2d curve is a line and Standard_False otherwise.
|
|
||||||
Standard_Boolean isIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
Standard_Boolean& theIsU,
|
|
||||||
Standard_Real& theParam,
|
|
||||||
Standard_Boolean& theIsForward) const;
|
|
||||||
|
|
||||||
//! Builds 3D curve for a isoline. This method takes corresponding isoline from
|
|
||||||
//! the input surface.
|
|
||||||
//! @param theC2D Trimmed curve to be approximated.
|
|
||||||
//! @param theIsU Flag indicating that line is u const.
|
|
||||||
//! @param theParam Line parameter.
|
|
||||||
//! @param theIsForward Flag indicating forward parameterization on a isoline.
|
|
||||||
//! @return Standard_True when 3d curve is built and Standard_False otherwise.
|
|
||||||
Standard_Boolean buildC3dOnIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
const Standard_Boolean theIsU,
|
|
||||||
const Standard_Real theParam,
|
|
||||||
const Standard_Boolean theIsForward);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Approx_CurveOnSurface& operator= (const Approx_CurveOnSurface&);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Input curve.
|
|
||||||
const Handle(Adaptor2d_HCurve2d) myC2D;
|
|
||||||
|
|
||||||
//! Input surface.
|
|
||||||
const Handle(Adaptor3d_HSurface) mySurf;
|
|
||||||
|
|
||||||
//! First parameter of the result.
|
|
||||||
const Standard_Real myFirst;
|
|
||||||
|
|
||||||
//! Last parameter of the result.
|
|
||||||
const Standard_Real myLast;
|
|
||||||
|
|
||||||
//! Tolerance.
|
|
||||||
Standard_Real myTol;
|
|
||||||
|
|
||||||
Handle(Geom2d_BSplineCurve) myCurve2d;
|
Handle(Geom2d_BSplineCurve) myCurve2d;
|
||||||
Handle(Geom_BSplineCurve) myCurve3d;
|
Handle(Geom_BSplineCurve) myCurve3d;
|
||||||
|
@@ -25,7 +25,7 @@ IMPLEMENT_STANDARD_RTTIEXT(Aspect_DisplayConnection,Standard_Transient)
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
Aspect_DisplayConnection::Aspect_DisplayConnection()
|
Aspect_DisplayConnection::Aspect_DisplayConnection()
|
||||||
{
|
{
|
||||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||||
myDisplay = NULL;
|
myDisplay = NULL;
|
||||||
myIsOwnDisplay = false;
|
myIsOwnDisplay = false;
|
||||||
OSD_Environment anEnv ("DISPLAY");
|
OSD_Environment anEnv ("DISPLAY");
|
||||||
@@ -40,7 +40,7 @@ Aspect_DisplayConnection::Aspect_DisplayConnection()
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
Aspect_DisplayConnection::~Aspect_DisplayConnection()
|
Aspect_DisplayConnection::~Aspect_DisplayConnection()
|
||||||
{
|
{
|
||||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||||
if (myDisplay != NULL
|
if (myDisplay != NULL
|
||||||
&& myIsOwnDisplay)
|
&& myIsOwnDisplay)
|
||||||
{
|
{
|
||||||
@@ -49,7 +49,7 @@ Aspect_DisplayConnection::~Aspect_DisplayConnection()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : Aspect_DisplayConnection
|
// function : Aspect_DisplayConnection
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
#include <NCollection_DataMap.hxx>
|
#include <NCollection_DataMap.hxx>
|
||||||
|
|
||||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||||
#include <InterfaceGraphic.hxx>
|
#include <InterfaceGraphic.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
//! Destructor. Close opened connection.
|
//! Destructor. Close opened connection.
|
||||||
Standard_EXPORT ~Aspect_DisplayConnection();
|
Standard_EXPORT ~Aspect_DisplayConnection();
|
||||||
|
|
||||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||||
//! Constructor. Creates connection with display specified in theDisplayName.
|
//! Constructor. Creates connection with display specified in theDisplayName.
|
||||||
//! Display name should be in format "hostname:number" or "hostname:number.screen_number", where:
|
//! Display name should be in format "hostname:number" or "hostname:number.screen_number", where:
|
||||||
//! hostname - Specifies the name of the host machine on which the display is physically attached.
|
//! hostname - Specifies the name of the host machine on which the display is physically attached.
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#ifndef _Aspect_FBConfig_HeaderFile
|
#ifndef _Aspect_FBConfig_HeaderFile
|
||||||
#define _Aspect_FBConfig_HeaderFile
|
#define _Aspect_FBConfig_HeaderFile
|
||||||
|
|
||||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||||
typedef struct __GLXFBConfigRec* GLXFBConfig;
|
typedef struct __GLXFBConfigRec* GLXFBConfig;
|
||||||
typedef GLXFBConfig Aspect_FBConfig; // GLXFBConfig* under UNIX
|
typedef GLXFBConfig Aspect_FBConfig; // GLXFBConfig* under UNIX
|
||||||
#else
|
#else
|
||||||
|
@@ -59,7 +59,7 @@ public:
|
|||||||
virtual void Unmap() const Standard_OVERRIDE { myIsMapped = Standard_False; }
|
virtual void Unmap() const Standard_OVERRIDE { myIsMapped = Standard_False; }
|
||||||
|
|
||||||
//! Resize window - do nothing.
|
//! Resize window - do nothing.
|
||||||
virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
|
virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
|
||||||
|
|
||||||
//! Map window - do nothing.
|
//! Map window - do nothing.
|
||||||
virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
|
virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
|
||||||
|
@@ -58,7 +58,7 @@ public:
|
|||||||
Standard_EXPORT virtual void Unmap() const = 0;
|
Standard_EXPORT virtual void Unmap() const = 0;
|
||||||
|
|
||||||
//! Apply the resizing to the window <me>.
|
//! Apply the resizing to the window <me>.
|
||||||
Standard_EXPORT virtual Aspect_TypeOfResize DoResize() = 0;
|
Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const = 0;
|
||||||
|
|
||||||
//! Apply the mapping change to the window <me>.
|
//! Apply the mapping change to the window <me>.
|
||||||
//! and returns TRUE if the window is mapped at screen.
|
//! and returns TRUE if the window is mapped at screen.
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#ifndef __Aspect_WNTXWD_HXX
|
#ifndef __Aspect_WNTXWD_HXX
|
||||||
# define __Aspect_WNTXWD_HXX
|
# define __Aspect_WNTXWD_HXX
|
||||||
|
|
||||||
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__) && !defined(__EMSCRIPTEN__)
|
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
|
||||||
# include <X11/XWDFile.h>
|
# include <X11/XWDFile.h>
|
||||||
# else
|
# else
|
||||||
|
|
||||||
|
@@ -89,63 +89,28 @@ class BOPAlgo_EdgeEdge :
|
|||||||
Handle(BOPDS_PaveBlock)& PaveBlock2() {
|
Handle(BOPDS_PaveBlock)& PaveBlock2() {
|
||||||
return myPB2;
|
return myPB2;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
void SetBoxes (const Bnd_Box& theBox1,
|
|
||||||
const Bnd_Box& theBox2)
|
|
||||||
{
|
|
||||||
myBox1 = theBox1;
|
|
||||||
myBox2 = theBox2;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
void SetFuzzyValue(const Standard_Real theFuzz) {
|
void SetFuzzyValue(const Standard_Real theFuzz) {
|
||||||
IntTools_EdgeEdge::SetFuzzyValue(theFuzz);
|
IntTools_EdgeEdge::SetFuzzyValue(theFuzz);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
virtual void Perform() {
|
virtual void Perform() {
|
||||||
BOPAlgo_Algo::UserBreak();
|
BOPAlgo_Algo::UserBreak();
|
||||||
TopoDS_Edge anE1 = myEdge1, anE2 = myEdge2;
|
|
||||||
Standard_Boolean hasTrsf = false;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OCC_CATCH_SIGNALS
|
OCC_CATCH_SIGNALS
|
||||||
|
|
||||||
gp_Trsf aTrsf;
|
|
||||||
if (BOPAlgo_Tools::TrsfToPoint (myBox1, myBox2, aTrsf))
|
|
||||||
{
|
|
||||||
// Shapes are located far from origin, move the shapes to the origin,
|
|
||||||
// to increase the accuracy of intersection.
|
|
||||||
TopLoc_Location aLoc (aTrsf);
|
|
||||||
myEdge1.Move (aLoc);
|
|
||||||
myEdge2.Move (aLoc);
|
|
||||||
hasTrsf = Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
IntTools_EdgeEdge::Perform();
|
IntTools_EdgeEdge::Perform();
|
||||||
}
|
}
|
||||||
catch (Standard_Failure const&)
|
catch (Standard_Failure const&)
|
||||||
{
|
{
|
||||||
AddError(new BOPAlgo_AlertIntersectionFailed);
|
AddError(new BOPAlgo_AlertIntersectionFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
myEdge1 = anE1;
|
|
||||||
myEdge2 = anE2;
|
|
||||||
if (hasTrsf)
|
|
||||||
{
|
|
||||||
for (Standard_Integer i = 1; i <= myCommonParts.Length(); ++i)
|
|
||||||
{
|
|
||||||
IntTools_CommonPrt& aCPart = myCommonParts (i);
|
|
||||||
aCPart.SetEdge1 (myEdge1);
|
|
||||||
aCPart.SetEdge2 (myEdge2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
protected:
|
protected:
|
||||||
Handle(BOPDS_PaveBlock) myPB1;
|
Handle(BOPDS_PaveBlock) myPB1;
|
||||||
Handle(BOPDS_PaveBlock) myPB2;
|
Handle(BOPDS_PaveBlock) myPB2;
|
||||||
Bnd_Box myBox1;
|
|
||||||
Bnd_Box myBox2;
|
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -251,7 +216,6 @@ void BOPAlgo_PaveFiller::PerformEE()
|
|||||||
//
|
//
|
||||||
anEdgeEdge.SetEdge1(aE1, aT11, aT12);
|
anEdgeEdge.SetEdge1(aE1, aT11, aT12);
|
||||||
anEdgeEdge.SetEdge2(aE2, aT21, aT22);
|
anEdgeEdge.SetEdge2(aE2, aT21, aT22);
|
||||||
anEdgeEdge.SetBoxes (aBB1, aBB2);
|
|
||||||
anEdgeEdge.SetFuzzyValue(myFuzzyValue);
|
anEdgeEdge.SetFuzzyValue(myFuzzyValue);
|
||||||
anEdgeEdge.SetProgressIndicator(myProgressIndicator);
|
anEdgeEdge.SetProgressIndicator(myProgressIndicator);
|
||||||
}//for (; aIt2.More(); aIt2.Next()) {
|
}//for (; aIt2.More(); aIt2.Next()) {
|
||||||
@@ -960,8 +924,6 @@ void BOPAlgo_PaveFiller::ForceInterfEE()
|
|||||||
if (!aNbPB)
|
if (!aNbPB)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const Standard_Boolean bSICheckMode = (myArguments.Extent() == 1);
|
|
||||||
|
|
||||||
// Prepare pave blocks with the same vertices for intersection.
|
// Prepare pave blocks with the same vertices for intersection.
|
||||||
BOPAlgo_VectorOfEdgeEdge aVEdgeEdge;
|
BOPAlgo_VectorOfEdgeEdge aVEdgeEdge;
|
||||||
|
|
||||||
@@ -978,12 +940,10 @@ void BOPAlgo_PaveFiller::ForceInterfEE()
|
|||||||
const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(nV1));
|
const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(nV1));
|
||||||
const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(nV2));
|
const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(nV2));
|
||||||
|
|
||||||
// Use the max tolerance of vertices as Fuzzy value for intersection of edges.
|
// Use the max tolerance of vertices as Fuzzy value for intersection
|
||||||
// In the Self-Interference check mode we are interested in real
|
// of edges
|
||||||
// intersections only, so use only the real tolerance of edges,
|
Standard_Real aTolAdd = 2 * Max(BRep_Tool::Tolerance(aV1),
|
||||||
// no need to use the extended tolerance.
|
BRep_Tool::Tolerance(aV2));
|
||||||
Standard_Real aTolAdd = (bSICheckMode ? myFuzzyValue :
|
|
||||||
2 * Max(BRep_Tool::Tolerance(aV1), BRep_Tool::Tolerance(aV2)));
|
|
||||||
|
|
||||||
// All possible pairs combined from the list <aLPB> should be checked
|
// All possible pairs combined from the list <aLPB> should be checked
|
||||||
BOPDS_ListIteratorOfListOfPaveBlock aItLPB1(aLPB);
|
BOPDS_ListIteratorOfListOfPaveBlock aItLPB1(aLPB);
|
||||||
@@ -1062,7 +1022,6 @@ void BOPAlgo_PaveFiller::ForceInterfEE()
|
|||||||
anEdgeEdge.SetPaveBlock2(aPB2);
|
anEdgeEdge.SetPaveBlock2(aPB2);
|
||||||
anEdgeEdge.SetEdge1(aE1, aT11, aT12);
|
anEdgeEdge.SetEdge1(aE1, aT11, aT12);
|
||||||
anEdgeEdge.SetEdge2(aE2, aT21, aT22);
|
anEdgeEdge.SetEdge2(aE2, aT21, aT22);
|
||||||
anEdgeEdge.SetBoxes (myDS->ShapeInfo(nE1).Box(), myDS->ShapeInfo (nE2).Box());
|
|
||||||
if (bUseAddTol)
|
if (bUseAddTol)
|
||||||
anEdgeEdge.SetFuzzyValue(myFuzzyValue + aTolAdd);
|
anEdgeEdge.SetFuzzyValue(myFuzzyValue + aTolAdd);
|
||||||
else
|
else
|
||||||
|
@@ -105,50 +105,18 @@ class BOPAlgo_EdgeFace :
|
|||||||
IntTools_EdgeFace::SetFuzzyValue(theFuzz);
|
IntTools_EdgeFace::SetFuzzyValue(theFuzz);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
void SetBoxes (const Bnd_Box& theBox1,
|
|
||||||
const Bnd_Box& theBox2)
|
|
||||||
{
|
|
||||||
myBox1 = theBox1;
|
|
||||||
myBox2 = theBox2;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
virtual void Perform() {
|
virtual void Perform() {
|
||||||
BOPAlgo_Algo::UserBreak();
|
BOPAlgo_Algo::UserBreak();
|
||||||
TopoDS_Face aFace = myFace;
|
|
||||||
TopoDS_Edge anEdge = myEdge;
|
|
||||||
Standard_Boolean hasTrsf = false;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OCC_CATCH_SIGNALS
|
OCC_CATCH_SIGNALS
|
||||||
|
|
||||||
gp_Trsf aTrsf;
|
|
||||||
if (BOPAlgo_Tools::TrsfToPoint (myBox1, myBox2, aTrsf))
|
|
||||||
{
|
|
||||||
// Shapes are located far from origin, move the shapes to the origin,
|
|
||||||
// to increase the accuracy of intersection.
|
|
||||||
TopLoc_Location aLoc (aTrsf);
|
|
||||||
myEdge.Move (aLoc);
|
|
||||||
myFace.Move (aLoc);
|
|
||||||
hasTrsf = Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
IntTools_EdgeFace::Perform();
|
IntTools_EdgeFace::Perform();
|
||||||
}
|
}
|
||||||
catch (Standard_Failure const&)
|
catch (Standard_Failure const&)
|
||||||
{
|
{
|
||||||
AddError(new BOPAlgo_AlertIntersectionFailed);
|
AddError(new BOPAlgo_AlertIntersectionFailed);
|
||||||
}
|
}
|
||||||
myFace = aFace;
|
|
||||||
myEdge = anEdge;
|
|
||||||
|
|
||||||
if (hasTrsf)
|
|
||||||
{
|
|
||||||
for (Standard_Integer i = 1; i <= mySeqOfCommonPrts.Length(); ++i)
|
|
||||||
{
|
|
||||||
IntTools_CommonPrt& aCPart = mySeqOfCommonPrts (i);
|
|
||||||
aCPart.SetEdge1 (myEdge);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
protected:
|
protected:
|
||||||
@@ -156,8 +124,6 @@ class BOPAlgo_EdgeFace :
|
|||||||
Standard_Integer myIF;
|
Standard_Integer myIF;
|
||||||
IntTools_Range myNewSR;
|
IntTools_Range myNewSR;
|
||||||
Handle(BOPDS_PaveBlock) myPB;
|
Handle(BOPDS_PaveBlock) myPB;
|
||||||
Bnd_Box myBox1;
|
|
||||||
Bnd_Box myBox2;
|
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -265,7 +231,6 @@ void BOPAlgo_PaveFiller::PerformEF()
|
|||||||
//
|
//
|
||||||
aEdgeFace.SetEdge (aE);
|
aEdgeFace.SetEdge (aE);
|
||||||
aEdgeFace.SetFace (aF);
|
aEdgeFace.SetFace (aF);
|
||||||
aEdgeFace.SetBoxes (myDS->ShapeInfo(nE).Box(), myDS->ShapeInfo (nF).Box());
|
|
||||||
aEdgeFace.SetFuzzyValue(myFuzzyValue);
|
aEdgeFace.SetFuzzyValue(myFuzzyValue);
|
||||||
aEdgeFace.UseQuickCoincidenceCheck(bExpressCompute);
|
aEdgeFace.UseQuickCoincidenceCheck(bExpressCompute);
|
||||||
//
|
//
|
||||||
@@ -791,8 +756,6 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
|
|||||||
// Shake the tree
|
// Shake the tree
|
||||||
aBBTree.Build();
|
aBBTree.Build();
|
||||||
|
|
||||||
const Standard_Boolean bSICheckMode = (myArguments.Extent() == 1);
|
|
||||||
|
|
||||||
// Find pairs of Face/PaveBlock containing the same vertices
|
// Find pairs of Face/PaveBlock containing the same vertices
|
||||||
// and prepare those pairs for intersection.
|
// and prepare those pairs for intersection.
|
||||||
BOPAlgo_VectorOfEdgeFace aVEdgeFace;
|
BOPAlgo_VectorOfEdgeFace aVEdgeFace;
|
||||||
@@ -911,12 +874,8 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
|
|||||||
// tolerance as the criteria.
|
// tolerance as the criteria.
|
||||||
const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(nV1));
|
const TopoDS_Vertex& aV1 = TopoDS::Vertex(myDS->Shape(nV1));
|
||||||
const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(nV2));
|
const TopoDS_Vertex& aV2 = TopoDS::Vertex(myDS->Shape(nV2));
|
||||||
|
Standard_Real aTolCheck = 2 * Max(BRep_Tool::Tolerance(aV1),
|
||||||
// In the Self-Interference check mode we are interested in real
|
BRep_Tool::Tolerance(aV2));
|
||||||
// intersections only, so use only the real tolerance of edges,
|
|
||||||
// no need to use the extended tolerance.
|
|
||||||
Standard_Real aTolCheck = (bSICheckMode ? myFuzzyValue :
|
|
||||||
2 * Max(BRep_Tool::Tolerance(aV1), BRep_Tool::Tolerance(aV2)));
|
|
||||||
|
|
||||||
if (aProjPS.LowerDistance() > aTolCheck + myFuzzyValue)
|
if (aProjPS.LowerDistance() > aTolCheck + myFuzzyValue)
|
||||||
continue;
|
continue;
|
||||||
@@ -981,7 +940,6 @@ void BOPAlgo_PaveFiller::ForceInterfEF(const BOPDS_IndexedMapOfPaveBlock& theMPB
|
|||||||
aEdgeFace.SetPaveBlock(aPB);
|
aEdgeFace.SetPaveBlock(aPB);
|
||||||
aEdgeFace.SetEdge(aE);
|
aEdgeFace.SetEdge(aE);
|
||||||
aEdgeFace.SetFace(aF);
|
aEdgeFace.SetFace(aF);
|
||||||
aEdgeFace.SetBoxes (myDS->ShapeInfo(nE).Box(), myDS->ShapeInfo (nF).Box());
|
|
||||||
aEdgeFace.SetFuzzyValue(myFuzzyValue + aTolAdd);
|
aEdgeFace.SetFuzzyValue(myFuzzyValue + aTolAdd);
|
||||||
aEdgeFace.UseQuickCoincidenceCheck(Standard_True);
|
aEdgeFace.UseQuickCoincidenceCheck(Standard_True);
|
||||||
aEdgeFace.SetRange(IntTools_Range(aPB->Pave1().Parameter(), aPB->Pave2().Parameter()));
|
aEdgeFace.SetRange(IntTools_Range(aPB->Pave1().Parameter(), aPB->Pave2().Parameter()));
|
||||||
|
@@ -122,12 +122,6 @@ class BOPAlgo_FaceFace :
|
|||||||
myF2=aF2;
|
myF2=aF2;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
void SetBoxes(const Bnd_Box& theBox1,
|
|
||||||
const Bnd_Box& theBox2) {
|
|
||||||
myBox1 = theBox1;
|
|
||||||
myBox2 = theBox2;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
const TopoDS_Face& Face1()const {
|
const TopoDS_Face& Face1()const {
|
||||||
return myF1;
|
return myF1;
|
||||||
}
|
}
|
||||||
@@ -148,37 +142,13 @@ class BOPAlgo_FaceFace :
|
|||||||
IntTools_FaceFace::SetFuzzyValue(theFuzz);
|
IntTools_FaceFace::SetFuzzyValue(theFuzz);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
const gp_Trsf& Trsf() const { return myTrsf; }
|
|
||||||
//
|
|
||||||
virtual void Perform() {
|
virtual void Perform() {
|
||||||
BOPAlgo_Algo::UserBreak();
|
BOPAlgo_Algo::UserBreak();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
OCC_CATCH_SIGNALS
|
OCC_CATCH_SIGNALS
|
||||||
|
|
||||||
gp_Trsf aTrsf;
|
IntTools_FaceFace::Perform(myF1, myF2);
|
||||||
TopoDS_Face aF1 = myF1, aF2 = myF2;
|
|
||||||
if (BOPAlgo_Tools::TrsfToPoint (myBox1, myBox2, aTrsf))
|
|
||||||
{
|
|
||||||
// Shapes are located far from origin, move the shapes to the origin,
|
|
||||||
// to increase the accuracy of intersection.
|
|
||||||
TopLoc_Location aLoc (aTrsf);
|
|
||||||
aF1.Move (aLoc);
|
|
||||||
aF2.Move (aLoc);
|
|
||||||
|
|
||||||
// The starting point is initialized only with the UV parameters
|
|
||||||
// on the faces - 3D point is not set (see GetEFPnts method),
|
|
||||||
// so no need to transform anything.
|
|
||||||
//for (IntSurf_ListOfPntOn2S::Iterator it (myListOfPnts); it.More(); it.Next())
|
|
||||||
//{
|
|
||||||
// IntSurf_PntOn2S& aP2S = it.ChangeValue();
|
|
||||||
// aP2S.SetValue (aP2S.Value().Transformed (aTrsf));
|
|
||||||
//}
|
|
||||||
|
|
||||||
myTrsf = aTrsf.Inverted();
|
|
||||||
}
|
|
||||||
|
|
||||||
IntTools_FaceFace::Perform (aF1, aF2);
|
|
||||||
}
|
}
|
||||||
catch (Standard_Failure const&)
|
catch (Standard_Failure const&)
|
||||||
{
|
{
|
||||||
@@ -186,39 +156,12 @@ class BOPAlgo_FaceFace :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
void ApplyTrsf()
|
|
||||||
{
|
|
||||||
if (IsDone())
|
|
||||||
{
|
|
||||||
// Update curves
|
|
||||||
for (Standard_Integer i = 1; i <= mySeqOfCurve.Length(); ++i)
|
|
||||||
{
|
|
||||||
IntTools_Curve& aIC = mySeqOfCurve (i);
|
|
||||||
aIC.Curve()->Transform (myTrsf);
|
|
||||||
}
|
|
||||||
// Update points
|
|
||||||
for (Standard_Integer i = 1; i <= myPnts.Length(); ++i)
|
|
||||||
{
|
|
||||||
IntTools_PntOn2Faces& aP2F = myPnts (i);
|
|
||||||
IntTools_PntOnFace aPOnF1 = aP2F.P1(), aPOnF2 = aP2F.P2();
|
|
||||||
aPOnF1.SetPnt (aPOnF1.Pnt().Transformed (myTrsf));
|
|
||||||
aPOnF2.SetPnt (aPOnF2.Pnt().Transformed (myTrsf));
|
|
||||||
aP2F.SetP1 (aPOnF1);
|
|
||||||
aP2F.SetP2 (aPOnF2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
protected:
|
protected:
|
||||||
Standard_Integer myIF1;
|
Standard_Integer myIF1;
|
||||||
Standard_Integer myIF2;
|
Standard_Integer myIF2;
|
||||||
Standard_Real myTolFF;
|
Standard_Real myTolFF;
|
||||||
TopoDS_Face myF1;
|
TopoDS_Face myF1;
|
||||||
TopoDS_Face myF2;
|
TopoDS_Face myF2;
|
||||||
Bnd_Box myBox1;
|
|
||||||
Bnd_Box myBox2;
|
|
||||||
gp_Trsf myTrsf;
|
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -292,7 +235,6 @@ void BOPAlgo_PaveFiller::PerformFF()
|
|||||||
//
|
//
|
||||||
aFaceFace.SetIndices(nF1, nF2);
|
aFaceFace.SetIndices(nF1, nF2);
|
||||||
aFaceFace.SetFaces(aF1, aF2);
|
aFaceFace.SetFaces(aF1, aF2);
|
||||||
aFaceFace.SetBoxes (myDS->ShapeInfo (nF1).Box(), myDS->ShapeInfo (nF2).Box());
|
|
||||||
// compute minimal tolerance for the curves
|
// compute minimal tolerance for the curves
|
||||||
Standard_Real aTolFF = ToleranceFF(aBAS1, aBAS2);
|
Standard_Real aTolFF = ToleranceFF(aBAS1, aBAS2);
|
||||||
aFaceFace.SetTolFF(aTolFF);
|
aFaceFace.SetTolFF(aTolFF);
|
||||||
@@ -340,8 +282,6 @@ void BOPAlgo_PaveFiller::PerformFF()
|
|||||||
//
|
//
|
||||||
aFaceFace.PrepareLines3D(bSplitCurve);
|
aFaceFace.PrepareLines3D(bSplitCurve);
|
||||||
//
|
//
|
||||||
aFaceFace.ApplyTrsf();
|
|
||||||
//
|
|
||||||
const IntTools_SequenceOfCurves& aCvsX = aFaceFace.Lines();
|
const IntTools_SequenceOfCurves& aCvsX = aFaceFace.Lines();
|
||||||
const IntTools_SequenceOfPntOn2Faces& aPntsX = aFaceFace.Points();
|
const IntTools_SequenceOfPntOn2Faces& aPntsX = aFaceFace.Points();
|
||||||
//
|
//
|
||||||
@@ -1771,16 +1711,12 @@ void BOPAlgo_PaveFiller::PutBoundPaveOnCurve(const TopoDS_Face& aF1,
|
|||||||
getBoundPaves(myDS, aNC, aBndNV);
|
getBoundPaves(myDS, aNC, aBndNV);
|
||||||
//
|
//
|
||||||
Standard_Real aTolVnew = Precision::Confusion();
|
Standard_Real aTolVnew = Precision::Confusion();
|
||||||
Standard_Boolean isClosed = aP[1].IsEqual (aP[0], aTolVnew);
|
|
||||||
if (isClosed && (aBndNV[0] > 0 || aBndNV[1] > 0))
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (Standard_Integer j = 0; j<2; ++j)
|
for (Standard_Integer j = 0; j<2; ++j)
|
||||||
{
|
{
|
||||||
if (aBndNV[j] < 0)
|
if (aBndNV[j] < 0)
|
||||||
{
|
{
|
||||||
// no vertex on this end
|
// no vertex on this end
|
||||||
if (j && isClosed) {
|
if (j && aP[1].IsEqual(aP[0], aTolVnew)) {
|
||||||
//if curve is closed, process only one bound
|
//if curve is closed, process only one bound
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -215,15 +215,11 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
|
|||||||
//
|
//
|
||||||
// use only connected faces
|
// use only connected faces
|
||||||
TopTools_ListOfShape aLFConnected;
|
TopTools_ListOfShape aLFConnected;
|
||||||
// Boundary faces
|
|
||||||
TopTools_MapOfShape aBoundaryFaces;
|
|
||||||
aItF.Initialize (myShapes);
|
aItF.Initialize (myShapes);
|
||||||
for (; aItF.More(); aItF.Next()) {
|
for (; aItF.More(); aItF.Next()) {
|
||||||
const TopoDS_Shape& aF = aItF.Value();
|
const TopoDS_Shape& aF = aItF.Value();
|
||||||
if (aMFaces.Contains(aF)) {
|
if (aMFaces.Contains(aF)) {
|
||||||
aLFConnected.Append(aF);
|
aLFConnected.Append(aF);
|
||||||
if (!aBoundaryFaces.Add (aF))
|
|
||||||
aBoundaryFaces.Remove (aF);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@@ -258,7 +254,6 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
|
|||||||
aItS.Initialize(aShell);
|
aItS.Initialize(aShell);
|
||||||
for (; aItS.More(); aItS.Next()) {
|
for (; aItS.More(); aItS.Next()) {
|
||||||
const TopoDS_Face& aF = (*(TopoDS_Face*)(&aItS.Value()));
|
const TopoDS_Face& aF = (*(TopoDS_Face*)(&aItS.Value()));
|
||||||
Standard_Boolean isBoundary = aBoundaryFaces.Contains (aF);
|
|
||||||
//
|
//
|
||||||
// loop on edges of aF; find a good neighbor face of aF by aE
|
// loop on edges of aF; find a good neighbor face of aF by aE
|
||||||
aExp.Init(aF, TopAbs_EDGE);
|
aExp.Init(aF, TopAbs_EDGE);
|
||||||
@@ -294,8 +289,6 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
|
|||||||
// take only not-processed faces as a candidates
|
// take only not-processed faces as a candidates
|
||||||
BOPTools_ListOfCoupleOfShape aLCSOff;
|
BOPTools_ListOfCoupleOfShape aLCSOff;
|
||||||
//
|
//
|
||||||
Standard_Integer aNbWaysInside = 0;
|
|
||||||
TopoDS_Face aSelF;
|
|
||||||
TopTools_ListIteratorOfListOfShape aItLF(aLF);
|
TopTools_ListIteratorOfListOfShape aItLF(aLF);
|
||||||
for (; aItLF.More(); aItLF.Next()) {
|
for (; aItLF.More(); aItLF.Next()) {
|
||||||
const TopoDS_Face& aFL = (*(TopoDS_Face*)(&aItLF.Value()));
|
const TopoDS_Face& aFL = (*(TopoDS_Face*)(&aItLF.Value()));
|
||||||
@@ -308,11 +301,6 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (isBoundary && !aBoundaryFaces.Contains (aFL))
|
|
||||||
{
|
|
||||||
++aNbWaysInside;
|
|
||||||
aSelF = aFL;
|
|
||||||
}
|
|
||||||
aCSOff.SetShape1(aEL);
|
aCSOff.SetShape1(aEL);
|
||||||
aCSOff.SetShape2(aFL);
|
aCSOff.SetShape2(aFL);
|
||||||
aLCSOff.Append(aCSOff);
|
aLCSOff.Append(aCSOff);
|
||||||
@@ -325,14 +313,12 @@ void BOPAlgo_ShellSplitter::SplitBlock(BOPTools_ConnexityBlock& aCB)
|
|||||||
//
|
//
|
||||||
// among all the adjacent faces chose one with the minimal
|
// among all the adjacent faces chose one with the minimal
|
||||||
// angle to the current one
|
// angle to the current one
|
||||||
if (!isBoundary || aNbWaysInside != 1)
|
TopoDS_Face aSelF;
|
||||||
{
|
if (aNbOff == 1) {
|
||||||
if (aNbOff == 1) {
|
aSelF = (*(TopoDS_Face*)(&aLCSOff.First().Shape2()));
|
||||||
aSelF = (*(TopoDS_Face*)(&aLCSOff.First().Shape2()));
|
}
|
||||||
}
|
else if (aNbOff > 1) {
|
||||||
else if (aNbOff > 1) {
|
BOPTools_AlgoTools::GetFaceOff(aE, aF, aLCSOff, aSelF, aContext);
|
||||||
BOPTools_AlgoTools::GetFaceOff(aE, aF, aLCSOff, aSelF, aContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) {
|
if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) {
|
||||||
|
@@ -1756,30 +1756,3 @@ void BOPAlgo_Tools::FillInternals(const TopTools_ListOfShape& theSolids,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : TrsfToPoint
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
Standard_Boolean BOPAlgo_Tools::TrsfToPoint (const Bnd_Box& theBox1,
|
|
||||||
const Bnd_Box& theBox2,
|
|
||||||
gp_Trsf& theTrsf,
|
|
||||||
const gp_Pnt& thePoint,
|
|
||||||
const Standard_Real theCriteria)
|
|
||||||
{
|
|
||||||
// Unify two boxes
|
|
||||||
Bnd_Box aBox = theBox1;
|
|
||||||
aBox.Add (theBox2);
|
|
||||||
|
|
||||||
gp_XYZ aBCenter = (aBox.CornerMin().XYZ() + aBox.CornerMax().XYZ()) / 2.;
|
|
||||||
Standard_Real aPBDist = (thePoint.XYZ() - aBCenter).Modulus();
|
|
||||||
if (aPBDist < theCriteria)
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
Standard_Real aBSize = Sqrt (aBox.SquareExtent());
|
|
||||||
if ((aBSize / aPBDist) > (1. / theCriteria))
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
theTrsf.SetTranslation (gp_Vec (aBox.CornerMin(), thePoint));
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
|
@@ -205,20 +205,6 @@ public:
|
|||||||
const TopTools_DataMapOfShapeListOfShape& theImages,
|
const TopTools_DataMapOfShapeListOfShape& theImages,
|
||||||
const Handle(IntTools_Context)& theContext);
|
const Handle(IntTools_Context)& theContext);
|
||||||
|
|
||||||
//! Computes the transformation needed to move the objects
|
|
||||||
//! to the given point to increase the quality of computations.
|
|
||||||
//! Returns true if the objects are located far from the given point
|
|
||||||
//! (relatively given criteria), false otherwise.
|
|
||||||
//! @param theBox1 the AABB of the first object
|
|
||||||
//! @param theBox2 the AABB of the second object
|
|
||||||
//! @param theTrsf the computed transformation
|
|
||||||
//! @param thePoint the Point to compute transformation to
|
|
||||||
//! @param theCriteria the Criteria to check whether thranformation is required
|
|
||||||
Standard_EXPORT static Standard_Boolean TrsfToPoint (const Bnd_Box& theBox1,
|
|
||||||
const Bnd_Box& theBox2,
|
|
||||||
gp_Trsf& theTrsf,
|
|
||||||
const gp_Pnt& thePoint = gp_Pnt (0.0, 0.0, 0.0),
|
|
||||||
const Standard_Real theCriteria = 1.e+5);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _BOPAlgo_Tools_HeaderFile
|
#endif // _BOPAlgo_Tools_HeaderFile
|
||||||
|
@@ -27,9 +27,7 @@ class BOPAlgo_EdgeInfo {
|
|||||||
BOPAlgo_EdgeInfo() :
|
BOPAlgo_EdgeInfo() :
|
||||||
myPassed(Standard_False),
|
myPassed(Standard_False),
|
||||||
myInFlag(Standard_False),
|
myInFlag(Standard_False),
|
||||||
myIsInside (Standard_False),
|
myAngle (-1.) {
|
||||||
myAngle (-1.)
|
|
||||||
{
|
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
void SetEdge(const TopoDS_Edge& theE) {
|
void SetEdge(const TopoDS_Edge& theE) {
|
||||||
@@ -64,19 +62,10 @@ class BOPAlgo_EdgeInfo {
|
|||||||
return myAngle;
|
return myAngle;
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
Standard_Boolean IsInside() const {
|
|
||||||
return myIsInside;
|
|
||||||
};
|
|
||||||
//
|
|
||||||
void SetIsInside (const Standard_Boolean theIsInside) {
|
|
||||||
myIsInside = theIsInside;
|
|
||||||
};
|
|
||||||
//
|
|
||||||
protected:
|
protected:
|
||||||
TopoDS_Edge myEdge;
|
TopoDS_Edge myEdge;
|
||||||
Standard_Boolean myPassed;
|
Standard_Boolean myPassed;
|
||||||
Standard_Boolean myInFlag;
|
Standard_Boolean myInFlag;
|
||||||
Standard_Boolean myIsInside;
|
|
||||||
Standard_Real myAngle;
|
Standard_Real myAngle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -166,8 +166,6 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
|
|||||||
MyDataMapOfShapeBoolean aVertMap;
|
MyDataMapOfShapeBoolean aVertMap;
|
||||||
//
|
//
|
||||||
const TopTools_ListOfShape& myEdges=aCB.Shapes();
|
const TopTools_ListOfShape& myEdges=aCB.Shapes();
|
||||||
|
|
||||||
TopTools_MapOfShape aMS;
|
|
||||||
//
|
//
|
||||||
// 1.Filling mySmartMap
|
// 1.Filling mySmartMap
|
||||||
aIt.Initialize(myEdges);
|
aIt.Initialize(myEdges);
|
||||||
@@ -179,10 +177,6 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
|
|||||||
//
|
//
|
||||||
bIsClosed = BRep_Tool::Degenerated(aE) ||
|
bIsClosed = BRep_Tool::Degenerated(aE) ||
|
||||||
BRep_Tool::IsClosed(aE, myFace);
|
BRep_Tool::IsClosed(aE, myFace);
|
||||||
|
|
||||||
if (!aMS.Add (aE) && !bIsClosed)
|
|
||||||
aMS.Remove (aE);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
aItS.Initialize(aE);
|
aItS.Initialize(aE);
|
||||||
for(i = 0; aItS.More(); aItS.Next(), ++i) {
|
for(i = 0; aItS.More(); aItS.Next(), ++i) {
|
||||||
@@ -224,7 +218,7 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
|
|||||||
for (i=1; i<=aNb; i++) {
|
for (i=1; i<=aNb; i++) {
|
||||||
aCntIn=0;
|
aCntIn=0;
|
||||||
aCntOut=0;
|
aCntOut=0;
|
||||||
const BOPAlgo_ListOfEdgeInfo& aLEInfo = mySmartMap(i);
|
const BOPAlgo_ListOfEdgeInfo& aLEInfo= mySmartMap(i);
|
||||||
BOPAlgo_ListIteratorOfListOfEdgeInfo anIt(aLEInfo);
|
BOPAlgo_ListIteratorOfListOfEdgeInfo anIt(aLEInfo);
|
||||||
for (; anIt.More(); anIt.Next()) {
|
for (; anIt.More(); anIt.Next()) {
|
||||||
const BOPAlgo_EdgeInfo& aEI=anIt.Value();
|
const BOPAlgo_EdgeInfo& aEI=anIt.Value();
|
||||||
@@ -310,7 +304,6 @@ void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace,
|
|||||||
for (; aItLEI.More(); aItLEI.Next()) {
|
for (; aItLEI.More(); aItLEI.Next()) {
|
||||||
BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
|
BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue();
|
||||||
const TopoDS_Edge& aE=aEI.Edge();
|
const TopoDS_Edge& aE=aEI.Edge();
|
||||||
aEI.SetIsInside (!aMS.Contains (aE));
|
|
||||||
//
|
//
|
||||||
aVV = aV;
|
aVV = aV;
|
||||||
bIsIN = aEI.IsIn();
|
bIsIN = aEI.IsIn();
|
||||||
@@ -373,7 +366,7 @@ void Path (const GeomAdaptor_Surface& aGAS,
|
|||||||
Standard_Integer i, j, aNb, aNbj;
|
Standard_Integer i, j, aNb, aNbj;
|
||||||
Standard_Real anAngleIn, anAngleOut, anAngle, aMinAngle;
|
Standard_Real anAngleIn, anAngleOut, anAngle, aMinAngle;
|
||||||
Standard_Real aTol2D, aTol2D2, aD2, aTwoPI;
|
Standard_Real aTol2D, aTol2D2, aD2, aTwoPI;
|
||||||
Standard_Boolean anIsSameV2d, anIsSameV, anIsOut, anIsNotPassed;
|
Standard_Boolean anIsSameV2d, anIsSameV, anIsFound, anIsOut, anIsNotPassed;
|
||||||
Standard_Boolean bIsClosed;
|
Standard_Boolean bIsClosed;
|
||||||
TopoDS_Vertex aVa, aVb;
|
TopoDS_Vertex aVa, aVb;
|
||||||
TopoDS_Edge aEOuta;
|
TopoDS_Edge aEOuta;
|
||||||
@@ -508,12 +501,8 @@ void Path (const GeomAdaptor_Surface& aGAS,
|
|||||||
//
|
//
|
||||||
anAngleIn = AngleIn(aEOuta, aLEInfo);
|
anAngleIn = AngleIn(aEOuta, aLEInfo);
|
||||||
aMinAngle = 100.;
|
aMinAngle = 100.;
|
||||||
|
anIsFound = Standard_False;
|
||||||
Standard_Integer iCnt = NbWaysOut(aLEInfo);
|
Standard_Integer iCnt = NbWaysOut(aLEInfo);
|
||||||
|
|
||||||
Standard_Boolean isBoundary = !anEdgeInfo->IsInside();
|
|
||||||
Standard_Integer aNbWaysInside = 0;
|
|
||||||
BOPAlgo_EdgeInfo *pOnlyWayIn = NULL;
|
|
||||||
|
|
||||||
Standard_Integer aCurIndexE = 0;
|
Standard_Integer aCurIndexE = 0;
|
||||||
anIt.Initialize(aLEInfo);
|
anIt.Initialize(aLEInfo);
|
||||||
for (; anIt.More(); anIt.Next()) {
|
for (; anIt.More(); anIt.Next()) {
|
||||||
@@ -536,6 +525,7 @@ void Path (const GeomAdaptor_Surface& aGAS,
|
|||||||
if (iCnt==1) {
|
if (iCnt==1) {
|
||||||
// the one and only way to go out .
|
// the one and only way to go out .
|
||||||
pEdgeInfo=&anEI;
|
pEdgeInfo=&anEI;
|
||||||
|
anIsFound=Standard_True;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@@ -558,25 +548,15 @@ void Path (const GeomAdaptor_Surface& aGAS,
|
|||||||
anAngleOut=anEI.Angle();
|
anAngleOut=anEI.Angle();
|
||||||
anAngle=ClockWiseAngle(anAngleIn, anAngleOut);
|
anAngle=ClockWiseAngle(anAngleIn, anAngleOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isBoundary && anEI.IsInside())
|
|
||||||
{
|
|
||||||
++aNbWaysInside;
|
|
||||||
pOnlyWayIn = &anEI;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (anAngle < aMinAngle - eps) {
|
if (anAngle < aMinAngle - eps) {
|
||||||
aMinAngle=anAngle;
|
aMinAngle=anAngle;
|
||||||
pEdgeInfo=&anEI;
|
pEdgeInfo=&anEI;
|
||||||
|
anIsFound=Standard_True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // for (; anIt.More(); anIt.Next())
|
} // for (; anIt.More(); anIt.Next())
|
||||||
if (aNbWaysInside == 1)
|
|
||||||
{
|
|
||||||
pEdgeInfo = pOnlyWayIn;
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
if (!pEdgeInfo) {
|
if (!anIsFound) {
|
||||||
// no way to go . (Error)
|
// no way to go . (Error)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -525,7 +525,6 @@ namespace {
|
|||||||
struct EdgeData {
|
struct EdgeData {
|
||||||
const TopoDS_Edge* Edge; // Edge
|
const TopoDS_Edge* Edge; // Edge
|
||||||
Standard_Real VParameter; // Parameter of the vertex on the edge
|
Standard_Real VParameter; // Parameter of the vertex on the edge
|
||||||
Standard_Boolean IsClosed; // Closed flag of the edge
|
|
||||||
Geom2dAdaptor_Curve GAdaptor; // 2D adaptor for PCurve of the edge on the face
|
Geom2dAdaptor_Curve GAdaptor; // 2D adaptor for PCurve of the edge on the face
|
||||||
Standard_Real First; // First parameter in the range
|
Standard_Real First; // First parameter in the range
|
||||||
Standard_Real Last; // Last parameter in the rage
|
Standard_Real Last; // Last parameter in the rage
|
||||||
@@ -611,9 +610,9 @@ static
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
if ((!theEData1.IsClosed && Abs (aTint1 - aT1) > aHalfR1) ||
|
if (Abs(aTint1 - aT1) > aHalfR1 ||
|
||||||
(!theEData2.IsClosed && Abs (aTint2 - aT2) > aHalfR2)) {
|
Abs(aTint2 - aT2) > aHalfR2) {
|
||||||
// intersection is on the other end of the edge
|
// intersection on the other end of the closed edge
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@@ -635,7 +634,7 @@ void CorrectWires(const TopoDS_Face& aFx,
|
|||||||
const TopTools_IndexedMapOfShape& aMapToAvoid)
|
const TopTools_IndexedMapOfShape& aMapToAvoid)
|
||||||
{
|
{
|
||||||
Standard_Integer i, aNbV;
|
Standard_Integer i, aNbV;
|
||||||
Standard_Real aTol, aTol2, aD2, aD2max, aT1, aT2;
|
Standard_Real aTol, aTol2, aD2, aD2max, aT1, aT2, aT;
|
||||||
gp_Pnt aP, aPV;
|
gp_Pnt aP, aPV;
|
||||||
gp_Pnt2d aP2D;
|
gp_Pnt2d aP2D;
|
||||||
TopoDS_Face aF;
|
TopoDS_Face aF;
|
||||||
@@ -645,9 +644,11 @@ void CorrectWires(const TopoDS_Face& aFx,
|
|||||||
aF=aFx;
|
aF=aFx;
|
||||||
aF.Orientation(TopAbs_FORWARD);
|
aF.Orientation(TopAbs_FORWARD);
|
||||||
const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aFx);
|
const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aFx);
|
||||||
|
//
|
||||||
TopExp::MapShapesAndUniqueAncestors (aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE, Standard_True);
|
TopExp::MapShapesAndAncestors(aF,
|
||||||
|
TopAbs_VERTEX,
|
||||||
|
TopAbs_EDGE,
|
||||||
|
aMVE);
|
||||||
NCollection_DataMap<TopoDS_Shape, Standard_Real> aMapEdgeLen;
|
NCollection_DataMap<TopoDS_Shape, Standard_Real> aMapEdgeLen;
|
||||||
aNbV=aMVE.Extent();
|
aNbV=aMVE.Extent();
|
||||||
for (i=1; i<=aNbV; ++i) {
|
for (i=1; i<=aNbV; ++i) {
|
||||||
@@ -665,13 +666,7 @@ void CorrectWires(const TopoDS_Face& aFx,
|
|||||||
const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aIt.Value());
|
const TopoDS_Edge& aE=*(TopoDS_Edge*)(&aIt.Value());
|
||||||
const Handle(Geom2d_Curve)& aC2D=
|
const Handle(Geom2d_Curve)& aC2D=
|
||||||
BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2);
|
BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2);
|
||||||
Standard_Real aT = BRep_Tool::Parameter (aV, aE);
|
aT=BRep_Tool::Parameter(aV, aE);
|
||||||
Standard_Boolean isClosed = Standard_False;
|
|
||||||
{
|
|
||||||
TopoDS_Vertex aV1, aV2;
|
|
||||||
TopExp::Vertices (aE, aV1, aV2);
|
|
||||||
isClosed = aV1.IsSame (aV2);
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
aC2D->D0(aT, aP2D);
|
aC2D->D0(aT, aP2D);
|
||||||
aS->D0(aP2D.X(), aP2D.Y(), aP);
|
aS->D0(aP2D.X(), aP2D.Y(), aP);
|
||||||
@@ -679,7 +674,7 @@ void CorrectWires(const TopoDS_Face& aFx,
|
|||||||
if (aD2>aD2max) {
|
if (aD2>aD2max) {
|
||||||
aD2max=aD2;
|
aD2max=aD2;
|
||||||
}
|
}
|
||||||
EdgeData anEData = {&aE, aT, isClosed, Geom2dAdaptor_Curve(aC2D), aT1, aT2};
|
EdgeData anEData = {&aE, aT, Geom2dAdaptor_Curve(aC2D), aT1, aT2};
|
||||||
aLEPars.Append(anEData);
|
aLEPars.Append(anEData);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@@ -363,8 +363,9 @@ void BRepAlgo_NormalProjection::SetDefaultParams()
|
|||||||
#ifdef OCCT_DEBUG_CHRONO
|
#ifdef OCCT_DEBUG_CHRONO
|
||||||
InitChron(chr_approx);
|
InitChron(chr_approx);
|
||||||
#endif
|
#endif
|
||||||
Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d);
|
Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d,
|
||||||
appr.Perform(myMaxSeg, myMaxDegree, myContinuity, Only3d, Only2d);
|
myContinuity, myMaxDegree, myMaxSeg,
|
||||||
|
Only3d, Only2d);
|
||||||
#ifdef OCCT_DEBUG_CHRONO
|
#ifdef OCCT_DEBUG_CHRONO
|
||||||
ResultChron(chr_approx,t_approx);
|
ResultChron(chr_approx,t_approx);
|
||||||
approx_count++;
|
approx_count++;
|
||||||
|
@@ -126,8 +126,8 @@ Standard_Real BRepBlend_AppSurface::TolCurveOnSurf(const Standard_Integer Index)
|
|||||||
return approx.TolCurveOnSurf(Index);
|
return approx.TolCurveOnSurf(Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BRepBlend_AppSurface::TolReached (Standard_Real& Tol3d,
|
inline void BRepBlend_AppSurface::TolReached (Standard_Real& Tol3d,
|
||||||
Standard_Real& Tol2d) const
|
Standard_Real& Tol2d) const
|
||||||
{
|
{
|
||||||
Tol3d = approx.MaxErrorOnSurf();
|
Tol3d = approx.MaxErrorOnSurf();
|
||||||
Tol2d = 0;
|
Tol2d = 0;
|
||||||
|
@@ -1055,7 +1055,6 @@ void BRepFeat_MakeRevolutionForm::Perform()
|
|||||||
if(ex1.Current().IsSame(e1)) {
|
if(ex1.Current().IsSame(e1)) {
|
||||||
myLFMap(iter.Key()).Clear();
|
myLFMap(iter.Key()).Clear();
|
||||||
myLFMap(iter.Key()).Append(ex2.Current());
|
myLFMap(iter.Key()).Append(ex2.Current());
|
||||||
break; // break the cycle (e1 became a dead reference)
|
|
||||||
}
|
}
|
||||||
ex2.Next();
|
ex2.Next();
|
||||||
}
|
}
|
||||||
@@ -1063,14 +1062,16 @@ void BRepFeat_MakeRevolutionForm::Perform()
|
|||||||
|
|
||||||
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter1(mySlface);
|
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape iter1(mySlface);
|
||||||
for(; iter1.More(); iter1.Next()) {
|
for(; iter1.More(); iter1.Next()) {
|
||||||
|
const TopoDS_Shape& f1 = iter1.Key();
|
||||||
const TopoDS_Shape& e1 = iter1.Value().First();
|
const TopoDS_Shape& e1 = iter1.Value().First();
|
||||||
TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
|
TopExp_Explorer ex1(myPbase, TopAbs_EDGE);
|
||||||
TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
|
TopExp_Explorer ex2(Pbase, TopAbs_EDGE);
|
||||||
for(; ex1.More(); ex1.Next()) {
|
for(; ex1.More(); ex1.Next()) {
|
||||||
if(ex1.Current().IsSame(e1)) {
|
const TopoDS_Shape& E1 = ex1.Current();
|
||||||
mySlface(iter1.Key()).Clear();
|
const TopoDS_Shape& E2 = ex2.Current();
|
||||||
mySlface(iter1.Key()).Append(ex2.Current());
|
if(E1.IsSame(e1)) {
|
||||||
break; // break the cycle (e1 became a dead reference)
|
mySlface(f1).Clear();
|
||||||
|
mySlface(f1).Append(E2);
|
||||||
}
|
}
|
||||||
ex2.Next();
|
ex2.Next();
|
||||||
}
|
}
|
||||||
@@ -1157,9 +1158,9 @@ void BRepFeat_MakeRevolutionForm::Perform()
|
|||||||
const TopoDS_Shape& sh = it1.Value().First();
|
const TopoDS_Shape& sh = it1.Value().First();
|
||||||
exx.Init(VraiForm, TopAbs_FACE);
|
exx.Init(VraiForm, TopAbs_FACE);
|
||||||
for(; exx.More(); exx.Next()) {
|
for(; exx.More(); exx.Next()) {
|
||||||
TopoDS_Face fac = TopoDS::Face(exx.Current());
|
const TopoDS_Face& fac = TopoDS::Face(exx.Current());
|
||||||
TopExp_Explorer exx1(fac, TopAbs_WIRE);
|
TopExp_Explorer exx1(fac, TopAbs_WIRE);
|
||||||
TopoDS_Wire thew = TopoDS::Wire(exx1.Current());
|
const TopoDS_Wire& thew = TopoDS::Wire(exx1.Current());
|
||||||
if(thew.IsSame(myFShape)) {
|
if(thew.IsSame(myFShape)) {
|
||||||
const TopTools_ListOfShape& desfaces = trP.Modified(f2);
|
const TopTools_ListOfShape& desfaces = trP.Modified(f2);
|
||||||
myMap(myFShape) = desfaces;
|
myMap(myFShape) = desfaces;
|
||||||
@@ -1171,13 +1172,13 @@ void BRepFeat_MakeRevolutionForm::Perform()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(fac.IsSame(sh)) {
|
if(fac.IsSame(sh)) {
|
||||||
if (! trP.IsDeleted(fac))
|
if (trP.IsDeleted(fac)) {
|
||||||
{
|
}
|
||||||
|
else {
|
||||||
const TopTools_ListOfShape& desfaces = trP.Modified(fac);
|
const TopTools_ListOfShape& desfaces = trP.Modified(fac);
|
||||||
if(!desfaces.IsEmpty()) {
|
if(!desfaces.IsEmpty()) {
|
||||||
myMap(orig).Clear();
|
myMap(orig).Clear();
|
||||||
myMap(orig) = trP.Modified(fac);
|
myMap(orig) = trP.Modified(fac);
|
||||||
break; // break the cycle (sh became a dead reference)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -149,6 +149,9 @@ static void TrimEdge (const TopoDS_Edge& Edge,
|
|||||||
TColStd_SequenceOfReal& ThePar,
|
TColStd_SequenceOfReal& ThePar,
|
||||||
TopTools_SequenceOfShape& S);
|
TopTools_SequenceOfShape& S);
|
||||||
|
|
||||||
|
static TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E,
|
||||||
|
const TopoDS_Face& F);
|
||||||
|
|
||||||
static Standard_Integer PosOnFace (Standard_Real d1,
|
static Standard_Integer PosOnFace (Standard_Real d1,
|
||||||
Standard_Real d2,
|
Standard_Real d2,
|
||||||
Standard_Real d3);
|
Standard_Real d3);
|
||||||
@@ -983,8 +986,8 @@ void BRepFill_Evolved::ElementaryPerform (const TopoDS_Face& Sp,
|
|||||||
// skin => same orientation E[0] , inverted orientation E[2]
|
// skin => same orientation E[0] , inverted orientation E[2]
|
||||||
// if contreskin it is inverted.
|
// if contreskin it is inverted.
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
E[0].Orientation(BRepTools::OriEdgeInFace(E[0],F[0]));
|
E[0].Orientation(OriEdgeInFace(E[0],F[0]));
|
||||||
E[2].Orientation(BRepTools::OriEdgeInFace(E[2],F[1]));
|
E[2].Orientation(OriEdgeInFace(E[2],F[1]));
|
||||||
|
|
||||||
if (DistanceToOZ(VF) < DistanceToOZ(VL) ) {
|
if (DistanceToOZ(VF) < DistanceToOZ(VL) ) {
|
||||||
// Skin
|
// Skin
|
||||||
@@ -1196,14 +1199,14 @@ void BRepFill_Evolved::ElementaryPerform (const TopoDS_Face& Sp,
|
|||||||
TopTools_ListIteratorOfListOfShape itl;
|
TopTools_ListIteratorOfListOfShape itl;
|
||||||
const TopTools_ListOfShape& LF = myMap(CurrentSpine)(VCF);
|
const TopTools_ListOfShape& LF = myMap(CurrentSpine)(VCF);
|
||||||
|
|
||||||
TopAbs_Orientation Ori = BRepTools::OriEdgeInFace(TopoDS::Edge(LF.First()),
|
TopAbs_Orientation Ori = OriEdgeInFace(TopoDS::Edge(LF.First()),
|
||||||
CurrentFace);
|
CurrentFace);
|
||||||
for (itl.Initialize(LF), itl.Next(); itl.More(); itl.Next()) {
|
for (itl.Initialize(LF), itl.Next(); itl.More(); itl.Next()) {
|
||||||
TopoDS_Edge RE = TopoDS::Edge(itl.Value());
|
TopoDS_Edge RE = TopoDS::Edge(itl.Value());
|
||||||
MapBis(CurrentFace).Append(RE.Oriented(Ori));
|
MapBis(CurrentFace).Append(RE.Oriented(Ori));
|
||||||
}
|
}
|
||||||
const TopTools_ListOfShape& LL = myMap(CurrentSpine)(VCL);
|
const TopTools_ListOfShape& LL = myMap(CurrentSpine)(VCL);
|
||||||
Ori = BRepTools::OriEdgeInFace(TopoDS::Edge(LL.First()),CurrentFace);
|
Ori = OriEdgeInFace(TopoDS::Edge(LL.First()),CurrentFace);
|
||||||
for (itl.Initialize(LL), itl.Next() ; itl.More(); itl.Next()) {
|
for (itl.Initialize(LL), itl.Next() ; itl.More(); itl.Next()) {
|
||||||
TopoDS_Edge RE = TopoDS::Edge(itl.Value());
|
TopoDS_Edge RE = TopoDS::Edge(itl.Value());
|
||||||
MapBis(CurrentFace).Append(RE.Oriented(Ori));
|
MapBis(CurrentFace).Append(RE.Oriented(Ori));
|
||||||
@@ -2917,6 +2920,26 @@ static TopAbs_Orientation Relative (const TopoDS_Wire& W1,
|
|||||||
|
|
||||||
return TopAbs_REVERSED;
|
return TopAbs_REVERSED;
|
||||||
}
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : OriEdgeInFace
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
TopAbs_Orientation OriEdgeInFace (const TopoDS_Edge& E,
|
||||||
|
const TopoDS_Face& F )
|
||||||
|
|
||||||
|
{
|
||||||
|
TopExp_Explorer Exp(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE);
|
||||||
|
|
||||||
|
for (; Exp.More() ;Exp.Next()) {
|
||||||
|
if (Exp.Current().IsSame(E)) {
|
||||||
|
return Exp.Current().Orientation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw Standard_ConstructionError("BRepFill_Evolved::OriEdgeInFace");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : IsOnFace
|
//function : IsOnFace
|
||||||
|
@@ -451,12 +451,7 @@ void BRepFill_LocationLaw::CurvilinearBounds(const Standard_Integer Index,
|
|||||||
|
|
||||||
Standard_Boolean BRepFill_LocationLaw::IsClosed() const
|
Standard_Boolean BRepFill_LocationLaw::IsClosed() const
|
||||||
{
|
{
|
||||||
if (myPath.Closed())
|
return myPath.Closed();
|
||||||
return Standard_True;
|
|
||||||
|
|
||||||
TopoDS_Vertex V1, V2;
|
|
||||||
TopExp::Vertices(myPath, V1, V2);
|
|
||||||
return (V1.IsSame(V2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@@ -1377,7 +1377,7 @@ void BRepFill_PipeShell::BuildHistory(const BRepFill_Sweep& theSweep)
|
|||||||
BB.Add(aWire, CurEdge);
|
BB.Add(aWire, CurEdge);
|
||||||
} //for (jj = 2; jj <= SeqEdges.Length(); jj++)
|
} //for (jj = 2; jj <= SeqEdges.Length(); jj++)
|
||||||
//case of closed wire
|
//case of closed wire
|
||||||
if (myLocation->IsClosed() &&
|
if (mySection->IsVClosed() &&
|
||||||
!CurVertex.IsSame(FirstVertex))
|
!CurVertex.IsSame(FirstVertex))
|
||||||
{
|
{
|
||||||
const TopTools_ListOfShape& Elist = VEmap.FindFromKey(CurVertex);
|
const TopTools_ListOfShape& Elist = VEmap.FindFromKey(CurVertex);
|
||||||
|
@@ -330,9 +330,8 @@ static Standard_Boolean SameParameter(TopoDS_Edge& E,
|
|||||||
if (!HasPCurves(E))
|
if (!HasPCurves(E))
|
||||||
{
|
{
|
||||||
Handle(Geom2dAdaptor_HCurve) HC2d = new Geom2dAdaptor_HCurve( Pcurv );
|
Handle(Geom2dAdaptor_HCurve) HC2d = new Geom2dAdaptor_HCurve( Pcurv );
|
||||||
Approx_CurveOnSurface AppCurve(HC2d, S, HC2d->FirstParameter(), HC2d->LastParameter(),
|
Approx_CurveOnSurface AppCurve(HC2d, S, HC2d->FirstParameter(), HC2d->LastParameter(),
|
||||||
Precision::Confusion());
|
Precision::Confusion(), GeomAbs_C1, 10, 10, Standard_True);
|
||||||
AppCurve.Perform(10, 10, GeomAbs_C1, Standard_True);
|
|
||||||
if (AppCurve.IsDone() && AppCurve.HasResult())
|
if (AppCurve.IsDone() && AppCurve.HasResult())
|
||||||
{
|
{
|
||||||
C3d = AppCurve.Curve3d();
|
C3d = AppCurve.Curve3d();
|
||||||
|
@@ -1347,13 +1347,15 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Eval tol2d to compute SameRange
|
// Eval tol2d to compute SameRange
|
||||||
Standard_Real TolSameRange = Max(GAC.Resolution(theTolerance), Precision::PConfusion());
|
Standard_Real UResol = Max(GAS.UResolution(theTolerance), Precision::PConfusion());
|
||||||
|
Standard_Real VResol = Max(GAS.VResolution(theTolerance), Precision::PConfusion());
|
||||||
|
Standard_Real Tol2d = Min(UResol, VResol);
|
||||||
for(Standard_Integer i = 0; i < 2; i++){
|
for(Standard_Integer i = 0; i < 2; i++){
|
||||||
Handle(Geom2d_Curve) curPC = PC[i];
|
Handle(Geom2d_Curve) curPC = PC[i];
|
||||||
Standard_Boolean updatepc = 0;
|
Standard_Boolean updatepc = 0;
|
||||||
if(curPC.IsNull()) break;
|
if(curPC.IsNull()) break;
|
||||||
if(!SameRange){
|
if(!SameRange){
|
||||||
GeomLib::SameRange(TolSameRange,
|
GeomLib::SameRange(Tol2d,
|
||||||
PC[i],GCurve->First(),GCurve->Last(),
|
PC[i],GCurve->First(),GCurve->Last(),
|
||||||
f3d,l3d,curPC);
|
f3d,l3d,curPC);
|
||||||
|
|
||||||
@@ -1373,17 +1375,13 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
|
|||||||
|
|
||||||
if(GAC2d.GetType() == GeomAbs_BSplineCurve &&
|
if(GAC2d.GetType() == GeomAbs_BSplineCurve &&
|
||||||
GAC2d.Continuity() == GeomAbs_C0) {
|
GAC2d.Continuity() == GeomAbs_C0) {
|
||||||
Standard_Real UResol = GAS.UResolution(theTolerance);
|
|
||||||
Standard_Real VResol = GAS.VResolution(theTolerance);
|
|
||||||
Standard_Real TolConf2d = Min(UResol, VResol);
|
|
||||||
TolConf2d = Max(TolConf2d, Precision::PConfusion());
|
|
||||||
Handle(Geom2d_BSplineCurve) bs2d = GAC2d.BSpline();
|
Handle(Geom2d_BSplineCurve) bs2d = GAC2d.BSpline();
|
||||||
Handle(Geom2d_BSplineCurve) bs2dsov = bs2d;
|
Handle(Geom2d_BSplineCurve) bs2dsov = bs2d;
|
||||||
Standard_Real fC0 = bs2d->FirstParameter(), lC0 = bs2d->LastParameter();
|
Standard_Real fC0 = bs2d->FirstParameter(), lC0 = bs2d->LastParameter();
|
||||||
Standard_Boolean repar = Standard_True;
|
Standard_Boolean repar = Standard_True;
|
||||||
gp_Pnt2d OriginPoint;
|
gp_Pnt2d OriginPoint;
|
||||||
bs2d->D0(fC0, OriginPoint);
|
bs2d->D0(fC0, OriginPoint);
|
||||||
Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d, TolConf2d);
|
Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d, Tol2d);
|
||||||
isBSP = Standard_True;
|
isBSP = Standard_True;
|
||||||
|
|
||||||
if(bs2d->IsPeriodic()) { // -------- IFV, Jan 2000
|
if(bs2d->IsPeriodic()) { // -------- IFV, Jan 2000
|
||||||
@@ -1427,7 +1425,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
|
|||||||
}
|
}
|
||||||
d = sqrt(d)*.1;
|
d = sqrt(d)*.1;
|
||||||
|
|
||||||
Tol2dbail = Max(Min(Tol2dbail,d), TolConf2d);
|
Tol2dbail = Max(Min(Tol2dbail,d),Tol2d);
|
||||||
|
|
||||||
Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d,Tol2dbail);
|
Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d,Tol2dbail);
|
||||||
|
|
||||||
@@ -1533,8 +1531,8 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
|
|||||||
GAC2d.Load(bs2d,f3d,l3d);
|
GAC2d.Load(bs2d,f3d,l3d);
|
||||||
curPC = bs2d;
|
curPC = bs2d;
|
||||||
|
|
||||||
if(Abs(bs2d->FirstParameter() - fC0) > TolSameRange ||
|
if(Abs(bs2d->FirstParameter() - fC0) > Tol2d ||
|
||||||
Abs(bs2d->LastParameter() - lC0) > TolSameRange) {
|
Abs(bs2d->LastParameter() - lC0) > Tol2d ) {
|
||||||
Standard_Integer NbKnots = bs2d->NbKnots();
|
Standard_Integer NbKnots = bs2d->NbKnots();
|
||||||
TColStd_Array1OfReal Knots(1,NbKnots);
|
TColStd_Array1OfReal Knots(1,NbKnots);
|
||||||
bs2d->Knots(Knots);
|
bs2d->Knots(Knots);
|
||||||
@@ -1587,7 +1585,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
|
|||||||
//Approx_SameParameter has failed.
|
//Approx_SameParameter has failed.
|
||||||
//Consequently, the situation might be,
|
//Consequently, the situation might be,
|
||||||
//when 3D and 2D-curve do not have same-range.
|
//when 3D and 2D-curve do not have same-range.
|
||||||
GeomLib::SameRange( TolSameRange, PC[i],
|
GeomLib::SameRange( Tol2d, PC[i],
|
||||||
GCurve->First(), GCurve->Last(),
|
GCurve->First(), GCurve->Last(),
|
||||||
f3d,l3d,curPC);
|
f3d,l3d,curPC);
|
||||||
|
|
||||||
@@ -1833,12 +1831,6 @@ void BRepLib::UpdateInnerTolerances(const TopoDS_Shape& aShape)
|
|||||||
for (Standard_Integer i = 1; i <= EFmap.Extent(); i++)
|
for (Standard_Integer i = 1; i <= EFmap.Extent(); i++)
|
||||||
{
|
{
|
||||||
TopoDS_Edge anEdge = TopoDS::Edge(EFmap.FindKey(i));
|
TopoDS_Edge anEdge = TopoDS::Edge(EFmap.FindKey(i));
|
||||||
|
|
||||||
if (!BRep_Tool::IsGeometric(anEdge))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
TopoDS_Vertex V1, V2;
|
TopoDS_Vertex V1, V2;
|
||||||
TopExp::Vertices(anEdge, V1, V2);
|
TopExp::Vertices(anEdge, V1, V2);
|
||||||
Standard_Real fpar, lpar;
|
Standard_Real fpar, lpar;
|
||||||
|
@@ -55,7 +55,6 @@
|
|||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
#include <TopoDS_Vertex.hxx>
|
#include <TopoDS_Vertex.hxx>
|
||||||
#include <TopoDS_Wire.hxx>
|
#include <TopoDS_Wire.hxx>
|
||||||
#include <NCollection_Vector.hxx>
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Controle
|
//function : Controle
|
||||||
@@ -175,70 +174,6 @@ BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape& S,
|
|||||||
{
|
{
|
||||||
Init(S,Tol,OnlyPlane,OnlyClosed);
|
Init(S,Tol,OnlyPlane,OnlyClosed);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
static void fillParams (const TColStd_Array1OfReal& theKnots,
|
|
||||||
Standard_Integer theDegree,
|
|
||||||
Standard_Real theParMin,
|
|
||||||
Standard_Real theParMax,
|
|
||||||
NCollection_Vector<Standard_Real>& theParams)
|
|
||||||
{
|
|
||||||
Standard_Real aPrevPar = theParMin;
|
|
||||||
theParams.Append (aPrevPar);
|
|
||||||
|
|
||||||
Standard_Integer aNbP = Max (theDegree, 1);
|
|
||||||
|
|
||||||
for (Standard_Integer i = 1;
|
|
||||||
(i < theKnots.Length()) && (theKnots (i) < (theParMax - Precision::PConfusion())); ++i)
|
|
||||||
{
|
|
||||||
if (theKnots (i + 1) < theParMin + Precision::PConfusion())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Standard_Real aStep = (theKnots (i + 1) - theKnots (i)) / aNbP;
|
|
||||||
for (Standard_Integer k = 1; k <= aNbP ; ++k)
|
|
||||||
{
|
|
||||||
Standard_Real aPar = theKnots (i) + k * aStep;
|
|
||||||
if (aPar > theParMax - Precision::PConfusion())
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (aPar > aPrevPar + Precision::PConfusion())
|
|
||||||
{
|
|
||||||
theParams.Append (aPar);
|
|
||||||
aPrevPar = aPar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
theParams.Append (theParMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void fillPoints (const BRepAdaptor_Curve& theCurve,
|
|
||||||
const NCollection_Vector<Standard_Real> theParams,
|
|
||||||
TColgp_SequenceOfPnt& thePoints,
|
|
||||||
TColStd_SequenceOfReal& theWeights)
|
|
||||||
{
|
|
||||||
Standard_Real aDistPrev = 0., aDistNext;
|
|
||||||
gp_Pnt aPPrev (theCurve.Value (theParams (0))), aPNext;
|
|
||||||
|
|
||||||
for (Standard_Integer iP = 1; iP <= theParams.Length(); ++iP)
|
|
||||||
{
|
|
||||||
if (iP < theParams.Length())
|
|
||||||
{
|
|
||||||
Standard_Real aParam = theParams (iP);
|
|
||||||
aPNext = theCurve.Value (aParam);
|
|
||||||
aDistNext = aPPrev.Distance (aPNext);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
aDistNext = 0.0;
|
|
||||||
|
|
||||||
thePoints.Append (aPPrev);
|
|
||||||
theWeights.Append (aDistPrev + aDistNext);
|
|
||||||
aDistPrev = aDistNext;
|
|
||||||
aPPrev = aPNext;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Init
|
//function : Init
|
||||||
//purpose :
|
//purpose :
|
||||||
@@ -347,57 +282,117 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
|
|||||||
}
|
}
|
||||||
Standard_Integer iNbPoints=0;
|
Standard_Integer iNbPoints=0;
|
||||||
|
|
||||||
// Fill the parameters of the sampling points
|
// Add the points with weights to the sequences
|
||||||
NCollection_Vector<Standard_Real> aParams;
|
|
||||||
switch (c.GetType())
|
switch (c.GetType())
|
||||||
{
|
{
|
||||||
case GeomAbs_BezierCurve:
|
case GeomAbs_BezierCurve:
|
||||||
{
|
{
|
||||||
|
// Put all poles for bezier
|
||||||
Handle(Geom_BezierCurve) GC = c.Bezier();
|
Handle(Geom_BezierCurve) GC = c.Bezier();
|
||||||
TColStd_Array1OfReal aKnots (1, 2);
|
Standard_Integer iNbPol = GC->NbPoles();
|
||||||
aKnots.SetValue (1, GC->FirstParameter());
|
Standard_Real tf = GC->FirstParameter();
|
||||||
aKnots.SetValue (2, GC->LastParameter());
|
Standard_Real tl = GC->LastParameter();
|
||||||
|
Standard_Real r = (dfUl - dfUf) / (tl - tf);
|
||||||
fillParams (aKnots, GC->Degree(), dfUf, dfUl, aParams);
|
r *= iNbPol;
|
||||||
break;
|
if ( iNbPol < 2 || r < 1.)
|
||||||
|
// Degenerate
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
|
||||||
|
GC->Poles(aPoles->ChangeArray1());
|
||||||
|
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
|
||||||
|
Standard_Real dfDistPrev = 0., dfDistNext;
|
||||||
|
for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
|
||||||
|
{
|
||||||
|
if (iPol<iNbPol)
|
||||||
|
{
|
||||||
|
aPoleNext = aPoles->Value(iPol+1);
|
||||||
|
dfDistNext = aPolePrev.Distance(aPoleNext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dfDistNext = 0.;
|
||||||
|
aPoints.Append (aPolePrev);
|
||||||
|
aWeight.Append (dfDistPrev+dfDistNext);
|
||||||
|
dfDistPrev = dfDistNext;
|
||||||
|
aPolePrev = aPoleNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case GeomAbs_BSplineCurve:
|
break;
|
||||||
|
case GeomAbs_BSplineCurve:
|
||||||
{
|
{
|
||||||
|
// Put all poles for bspline
|
||||||
Handle(Geom_BSplineCurve) GC = c.BSpline();
|
Handle(Geom_BSplineCurve) GC = c.BSpline();
|
||||||
fillParams (GC->Knots(), GC->Degree(), dfUf, dfUl, aParams);
|
Standard_Integer iNbPol = GC->NbPoles();
|
||||||
break;
|
Standard_Real tf = GC->FirstParameter();
|
||||||
|
Standard_Real tl = GC->LastParameter();
|
||||||
|
Standard_Real r = (dfUl - dfUf) / (tl - tf);
|
||||||
|
r *= iNbPol;
|
||||||
|
if ( iNbPol < 2 || r < 1.)
|
||||||
|
// Degenerate
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
|
||||||
|
GC->Poles(aPoles->ChangeArray1());
|
||||||
|
gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
|
||||||
|
Standard_Real dfDistPrev = 0., dfDistNext;
|
||||||
|
for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
|
||||||
|
{
|
||||||
|
if (iPol<iNbPol)
|
||||||
|
{
|
||||||
|
aPoleNext = aPoles->Value(iPol+1);
|
||||||
|
dfDistNext = aPolePrev.Distance(aPoleNext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dfDistNext = 0.;
|
||||||
|
aPoints.Append (aPolePrev);
|
||||||
|
aWeight.Append (dfDistPrev+dfDistNext);
|
||||||
|
dfDistPrev = dfDistNext;
|
||||||
|
aPolePrev = aPoleNext;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case GeomAbs_Line:
|
break;
|
||||||
{
|
|
||||||
// Two points on a straight segment
|
case GeomAbs_Line:
|
||||||
aParams.Append (dfUf);
|
case GeomAbs_Circle:
|
||||||
aParams.Append (dfUl);
|
case GeomAbs_Ellipse:
|
||||||
break;
|
case GeomAbs_Hyperbola:
|
||||||
}
|
case GeomAbs_Parabola:
|
||||||
case GeomAbs_Circle:
|
// Two points on straight segment, Four points on otheranalitical curves
|
||||||
case GeomAbs_Ellipse:
|
iNbPoints = (c.GetType() == GeomAbs_Line ? 2 : 4);
|
||||||
case GeomAbs_Hyperbola:
|
Standard_FALLTHROUGH
|
||||||
case GeomAbs_Parabola:
|
default:
|
||||||
// Four points on other analytical curves
|
|
||||||
iNbPoints = 4;
|
|
||||||
Standard_FALLTHROUGH
|
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
// Put some points on other curves
|
// Put some points on other curves
|
||||||
if (iNbPoints == 0)
|
if (iNbPoints==0)
|
||||||
iNbPoints = 15 + c.NbIntervals (GeomAbs_C3);
|
iNbPoints = 15 + c.NbIntervals(GeomAbs_C3);
|
||||||
|
Standard_Real dfDelta = (dfUl-dfUf)/(iNbPoints-1);
|
||||||
TColStd_Array1OfReal aBounds (1, 2);
|
Standard_Integer iPoint;
|
||||||
aBounds.SetValue (1, dfUf);
|
Standard_Real dfU;
|
||||||
aBounds.SetValue (2, dfUl);
|
gp_Pnt aPointPrev = c.Value(dfUf), aPointNext;
|
||||||
|
Standard_Real dfDistPrev = 0., dfDistNext;
|
||||||
fillParams (aBounds, iNbPoints - 1, dfUf, dfUl, aParams);
|
for (iPoint=1, dfU=dfUf+dfDelta;
|
||||||
}
|
iPoint<=iNbPoints;
|
||||||
}
|
iPoint++, dfU+=dfDelta)
|
||||||
|
{
|
||||||
// Add the points with weights to the sequences
|
if (iPoint<iNbPoints)
|
||||||
fillPoints (c, aParams, aPoints, aWeight);
|
{
|
||||||
}
|
aPointNext = c.Value(dfU);
|
||||||
|
dfDistNext = aPointPrev.Distance(aPointNext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dfDistNext = 0.;
|
||||||
|
aPoints.Append (aPointPrev);
|
||||||
|
aWeight.Append (dfDistPrev+dfDistNext);
|
||||||
|
dfDistPrev = dfDistNext;
|
||||||
|
aPointPrev = aPointNext;
|
||||||
|
}
|
||||||
|
} // default:
|
||||||
|
} // switch (c.GetType()) ...
|
||||||
|
} // for (ex.Init(S,TopAbs_EDGE); ex.More() && control; ex.Next()) ...
|
||||||
|
|
||||||
if (aPoints.Length() < 3) {
|
if (aPoints.Length() < 3) {
|
||||||
return;
|
return;
|
||||||
@@ -510,33 +505,79 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// let us be more tolerant (occ415)
|
||||||
|
Standard_Real dfDist = RealLast();
|
||||||
|
Handle(Geom_Plane) aPlane;
|
||||||
|
//
|
||||||
|
if (isSolved) {
|
||||||
|
//Plane normal can have two directions, direction is chosen
|
||||||
|
//according to direction of eigenvector
|
||||||
|
gp_Vec anN(aVec(1), aVec(2), aVec(3));
|
||||||
|
aPlane = new Geom_Plane(aBaryCenter,anN);
|
||||||
|
dfDist = Controle (aPoints, aPlane);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
if (!isSolved || myTolerance < dfDist) {
|
||||||
|
gp_Pnt aFirstPnt=aPoints(1);
|
||||||
|
for (iPoint=2; iPoint<=aPoints.Length(); iPoint++) {
|
||||||
|
gp_Vec aDir(aFirstPnt,aPoints(iPoint));
|
||||||
|
Standard_Real dfSide=aDir.Magnitude();
|
||||||
|
if (dfSide<myTolerance) {
|
||||||
|
continue; // degeneration
|
||||||
|
}
|
||||||
|
for (Standard_Integer iP1=iPoint+1; iP1<=aPoints.Length(); iP1++) {
|
||||||
|
|
||||||
if (!isSolved)
|
gp_Vec aCross = gp_Vec(aFirstPnt,aPoints(iP1)) ^ aDir ;
|
||||||
return;
|
|
||||||
|
|
||||||
gp_Vec aN (aVec (1), aVec (2), aVec (3));
|
if (aCross.Magnitude() > dfSide*myTolerance) {
|
||||||
Handle(Geom_Plane) aPlane = new Geom_Plane (aBaryCenter, aN);
|
Handle(Geom_Plane) aPlane2 = new Geom_Plane(aBaryCenter, aCross);
|
||||||
myTolReached = Controle (aPoints, aPlane);
|
Standard_Real dfDist2 = Controle (aPoints, aPlane2);
|
||||||
const Standard_Real aWeakness = 5.0;
|
if (dfDist2 < myTolerance) {
|
||||||
if (myTolReached <= myTolerance || (Tol < 0 && myTolReached < myTolerance * aWeakness))
|
myTolReached = dfDist2;
|
||||||
{
|
mySurface = aPlane2;
|
||||||
mySurface = aPlane;
|
return;
|
||||||
//If S is wire, try to orient surface according to orientation of wire.
|
}
|
||||||
if (S.ShapeType() == TopAbs_WIRE && S.Closed())
|
if (dfDist2 < dfDist) {
|
||||||
{
|
dfDist = dfDist2;
|
||||||
TopoDS_Wire aW = TopoDS::Wire (S);
|
aPlane = aPlane2;
|
||||||
TopoDS_Face aTmpFace = BRepLib_MakeFace (mySurface, Precision::Confusion());
|
}
|
||||||
BRep_Builder BB;
|
}
|
||||||
BB.Add (aTmpFace, aW);
|
|
||||||
BRepTopAdaptor_FClass2d FClass (aTmpFace, 0.);
|
|
||||||
if (FClass.PerformInfinitePoint() == TopAbs_IN)
|
|
||||||
{
|
|
||||||
gp_Dir aNorm = aPlane->Position().Direction();
|
|
||||||
aNorm.Reverse();
|
|
||||||
mySurface = new Geom_Plane (aPlane->Position().Location(), aNorm);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
//XXf
|
||||||
|
//static Standard_Real weakness = 5.0;
|
||||||
|
Standard_Real weakness = 5.0;
|
||||||
|
//XXf
|
||||||
|
if(dfDist <= myTolerance || (dfDist < myTolerance*weakness && Tol<0)) {
|
||||||
|
//XXf
|
||||||
|
//myTolReached = dfDist;
|
||||||
|
//XXt
|
||||||
|
mySurface = aPlane;
|
||||||
|
//If S is wire, try to orient surface according to orientation of wire.
|
||||||
|
if(S.ShapeType() == TopAbs_WIRE && S.Closed())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
TopoDS_Wire aW = TopoDS::Wire(S);
|
||||||
|
TopoDS_Face aTmpFace = BRepLib_MakeFace(mySurface, Precision::Confusion());
|
||||||
|
BRep_Builder BB;
|
||||||
|
BB.Add(aTmpFace, aW);
|
||||||
|
BRepTopAdaptor_FClass2d FClass(aTmpFace, 0.);
|
||||||
|
if ( FClass.PerformInfinitePoint() == TopAbs_IN )
|
||||||
|
{
|
||||||
|
gp_Dir aN = aPlane->Position().Direction();
|
||||||
|
aN.Reverse();
|
||||||
|
mySurface = new Geom_Plane(aPlane->Position().Location(), aN);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//XXf
|
||||||
|
myTolReached = dfDist;
|
||||||
|
//XXt
|
||||||
}
|
}
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Found
|
//function : Found
|
||||||
|