1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

Compare commits

..

12 Commits

Author SHA1 Message Date
gka
5859be3886 0030302: XCAF - Typo in XCAFDoc_GeomTolerance
Typo in the XCAFDoc_GeomTolerance.cxx where Loc is used instead of aPnt was corrected.
2019-09-14 11:45:37 +03:00
gka
d45b7860a5 0030113: Data Exchange - STL file in text format with "Facet" keywords can't be imported
Case-sensitive method strncmp used in the REStl_Reader cosidered register of letter was replaced on the method _strnicmp for Windows and strncasecmp for Linux and MacOs
Test script for case 0030113
2019-09-14 11:45:36 +03:00
agv
0cdaa8a4a5 0030831: ShapeFix algorithm (creation of seam edge) takes too long time with thin faces
In class ShapeFix_ComposeShell the U- and V-closedness of input face is taken immediately avoiding the error when the face is small in any of these dimensions.
Test case for bug 0030831
2019-09-14 11:45:36 +03:00
abv
3b80dc166a 0030948: Configuration, CMake - problem building with CMake 3.15.2
Minor corrections in CMake procedures and include statements
2019-09-14 11:45:35 +03:00
mzernova
fdae2107d9 0030946: Visualization - Image_AlienPixMap ignores 1-bit pixelformat when using FreeImage
Convert 1-bit image to 8-bit one during its loading because only greyscale images are supported by visualization
2019-09-14 11:45:35 +03:00
kgv
44b80414d3 0030775: Foundation Classes - Preserve application-defined top-level exception filter
New overload for method OSD::SetSignal() is added accepting argument specifying how to set or unset handlers.
New enum OSD_SignalMode describes different modes of signal handlers setting used in extended version of OSD::SetSignal().
Method OSD::SignalMode() returns mode set by the last call to SetSignal().
Method OSD::IsFloatingSignalSet() is changed to return value based on actual floating point exception flags (rather than on variable set by previous call to SetSignal()).

Added new method OSD::SetThreadLocalSignal() intended to setup thread-specific handlers (e.g. _set_se_translator() on Windows) and FPE settings.
OSD_ThreadPool and Media_PlayerContext now use new method instead of OSD::SetSignal(), to avoid overriding global handlers.

dsetsignal syntax has been extended to support choice of signal handling mode.

DRAW command OCC30775 is added allowing to test signal handling in multithreaded process.
2019-09-14 11:45:34 +03:00
mzernova
b1492cb30f 0022777: Visualization - Unsafe way to get attribute values from MeshVS_Drawer
Set default values for local variables used for storing values that are obtained by MeshVS_Drawer::Get****() methods
2019-09-14 10:49:50 +03:00
iko
5c225e8e07 0030963: Visualization, TKOpenGl - texture unit error during FFP global texture's parameters processing
The texture units used in FFP texture functions are correct now.
2019-09-14 10:49:49 +03:00
oan
3068c3bb65 0030959: OSD_Parallel_TBB: number of execution threads is strictly limited by the root scope
Do not limit number of available threads by number of items processed within the root scope due to possibility of spawning of an additional threads within the subscopes.
2019-09-14 10:49:48 +03:00
tma
ac293bde7f 0030957: Data Exchange - Assembly item Id should not start with '/' symbol
Fix test case: added parsing of the output of the dump note command
2019-09-11 18:48:14 +03:00
jgv
a53d3975c9 0023380: BRepOffsetAPI_MakeFilling fails and leaves boundary faces with high tolerance
Avoid exception: use BRep_Builder for building wire instead of using BRepLib_MakeWire.
2019-09-09 19:27:59 +03:00
aml
94beb42a68 0029858: Modeling Data - Regression in GeomAPI_ExtremaCurveCurve
Fix Newton's minimum projection algorithm onto boundaries in case of conditional optimization.
Add possibility to detect several optimal points at initialization of the math_GlobOptMin.
2019-09-09 19:26:39 +03:00
43 changed files with 812 additions and 434 deletions

View File

@@ -274,7 +274,7 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
list (LENGTH OCCT_ALL_FILE_NAMES ALL_FILES_NB)
math (EXPR ALL_FILES_NB "${ALL_FILES_NB} - 1" )
# emit warnings if there is unprocessed headers
# emit warnings if there are unprocessed headers
file (GLOB OCCT_ALL_FILES_IN_DIR "${OCCT_COLLECT_SOURCE_DIR}/${OCCT_PACKAGE}/*.*")
file (GLOB OCCT_ALL_FILES_IN_PATCH_DIR "${BUILD_PATCH}/src/${OCCT_PACKAGE}/*.*")
@@ -307,8 +307,8 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
list (APPEND OCCT_HEADER_FILES_COMPLETE ${OCCT_FILE_IN_DIR})
# collect header files with name that does not contain its package one
string (FIND "${OCCT_FILE_NAME}" "${OCCT_PACKAGE}_" FOUND_INDEX)
if (NOT ${FOUND_INDEX} EQUAL 0)
string (REGEX MATCH "^${OCCT_PACKAGE}[_.]" IS_HEADER_MATHCING_PACKAGE "${OCCT_FILE_NAME}")
if (NOT IS_HEADER_MATHCING_PACKAGE)
list (APPEND OCCT_HEADER_FILE_WITH_PROPER_NAMES "${OCCT_FILE_NAME}")
endif()
endif()
@@ -355,12 +355,12 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
list (FIND OCCT_USED_PACKAGES ${PACKAGE_NAME} IS_HEADER_FOUND)
if (NOT ${IS_HEADER_FOUND} EQUAL -1)
if (NOT EXISTS "${OCCT_COLLECT_SOURCE_DIR}/${PACKAGE_NAME}/${HEADER_FILE_NAME}")
message (STATUS "Warning. ${OCCT_HEADER_FILE_OLD} is not presented in the sources and will be removed from ${ROOT_TARGET_OCCT_DIR}/inc")
message (STATUS "Warning. ${OCCT_HEADER_FILE_OLD} is not present in the sources and will be removed from ${ROOT_TARGET_OCCT_DIR}/inc")
file (REMOVE "${OCCT_HEADER_FILE_OLD}")
else()
list (FIND OCCT_HEADER_FILE_NAMES_NOT_IN_FILES ${PACKAGE_NAME} IS_HEADER_FOUND)
if (NOT ${IS_HEADER_FOUND} EQUAL -1)
message (STATUS "Warning. ${OCCT_HEADER_FILE_OLD} is presented in the sources but not involved in FILES and will be removed from ${ROOT_TARGET_OCCT_DIR}/inc")
message (STATUS "Warning. ${OCCT_HEADER_FILE_OLD} is present in the sources but not involved in FILES and will be removed from ${ROOT_TARGET_OCCT_DIR}/inc")
file (REMOVE "${OCCT_HEADER_FILE_OLD}")
endif()
endif()

View File

@@ -91,31 +91,50 @@ static gp_Vec MakeFinVec( const TopoDS_Wire aWire, const TopoDS_Vertex aVertex )
static TopoDS_Wire WireFromList(TopTools_ListOfShape& Edges)
{
BRepLib_MakeWire MW;
BRep_Builder BB;
TopoDS_Wire aWire;
BB.MakeWire(aWire);
TopoDS_Edge anEdge = TopoDS::Edge(Edges.First());
MW.Add(anEdge);
BB.Add(aWire, anEdge);
Edges.RemoveFirst();
TopoDS_Vertex V1, V2;
TopExp::Vertices(anEdge, V1, V2, Standard_True); //with orientation
while (!Edges.IsEmpty())
{
TopoDS_Wire CurWire = MW.Wire();
TopoDS_Vertex V1, V2;
TopExp::Vertices(CurWire, V1, V2);
TopTools_ListIteratorOfListOfShape itl(Edges);
for (; itl.More(); itl.Next())
{
anEdge = TopoDS::Edge(itl.Value());
TopoDS_Vertex V3, V4;
TopExp::Vertices(anEdge, V3, V4);
TopExp::Vertices(anEdge, V3, V4, Standard_True); //with orientation
if (V1.IsSame(V3) || V1.IsSame(V4) ||
V2.IsSame(V3) || V2.IsSame(V4))
{
if (V1.IsSame(V3))
{
anEdge.Reverse();
V1 = V4;
}
else if (V1.IsSame(V4))
V1 = V3;
else if (V2.IsSame(V3))
V2 = V4;
else
{
anEdge.Reverse();
V2 = V3;
}
break;
}
}
MW.Add(anEdge);
BB.Add(aWire, anEdge);
Edges.Remove(itl);
}
return (MW.Wire());
aWire.Closed(Standard_True);
return aWire;
}
//=======================================================================
@@ -707,8 +726,6 @@ void BRepFill_Filling::Build()
}
TopoDS_Wire FinalWire = WireFromList(FinalEdges);
if (!(FinalWire.Closed()))
throw Standard_Failure("Wire is not closed");
myFace = BRepLib_MakeFace( Surface, FinalWire );
}

View File

@@ -437,7 +437,7 @@ static void CurveHermite (const TopOpeBRepDS_DataStructure& DStr,
GeomAdaptor_Curve L (Bezier);
Extrema_ExtCC ext (C,L);
if (ext.IsDone()){
if (ext.NbExt()!=0){
if (!ext.IsParallel() && ext.NbExt()!=0){
Extrema_POnCurv POnC, POnL;
ext.Points(1, POnC, POnL);
if (POnC.Value().Distance(POnL.Value()) < Precision::Confusion())

View File

@@ -17,12 +17,13 @@
#ifdef _WIN32
#include <windows.h>
#include <COMMANDWINDOW.h>
#include <Draw_Window.hxx>
#include <MAINWINDOW.h>
#include <Draw_Appli.hxx>
#include <TCollection_AsciiString.hxx>
#include <MainWindow.h>
#include <CommandWindow.h>
#define CLIENTWND 0
#define THE_PROMPT L"Command >> "

View File

@@ -913,21 +913,70 @@ static int dperf (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char
static int dsetsignal (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
{
// arm FPE handler if argument is provided and its first symbol is not '0'
// or if environment variable CSF_FPE is set and its first symbol is not '0'
bool setFPE = false;
if (theArgNb > 1)
OSD_SignalMode aMode = OSD_SignalMode_Set;
Standard_Boolean aSetFPE = OSD::ToCatchFloatingSignals();
// default for FPE signal is defined by CSF_FPE variable, if set
OSD_Environment aEnv("CSF_FPE");
TCollection_AsciiString aEnvStr = aEnv.Value();
if (!aEnvStr.IsEmpty())
{
setFPE = (theArgVec[1][0] == '1' || theArgVec[1][0] == 't');
aSetFPE = (aEnvStr.Value(1) != '0');
}
else
// parse arguments
for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
{
OSD_Environment aEnv ("CSF_FPE");
TCollection_AsciiString aEnvStr = aEnv.Value();
setFPE = (! aEnvStr.IsEmpty() && aEnvStr.Value(1) != '0');
TCollection_AsciiString anArg(theArgVec[anArgIter]);
anArg.LowerCase();
if (anArg == "asis")
{
aMode = OSD_SignalMode_AsIs;
}
else if (anArg == "set")
{
aMode = OSD_SignalMode_Set;
}
else if (anArg == "unhandled")
{
aMode = OSD_SignalMode_SetUnhandled;
}
else if (anArg == "unset")
{
aMode = OSD_SignalMode_Unset;
}
else if (anArg == "1" || anArg == "on")
{
aSetFPE = Standard_True;
}
else if (anArg == "0" || anArg == "off")
{
aSetFPE = Standard_False;
}
else if (anArg == "default")
{
}
else
{
std::cout << "Syntax error: unknown argument '" << anArg << "'\n";
return 1;
}
}
OSD::SetSignal (setFPE);
theDI << "Signal handlers are set, with FPE " << (setFPE ? "armed" : "disarmed");
OSD::SetSignal(aMode, aSetFPE);
// report actual status in the end
const char* aModeStr = 0;
switch (OSD::SignalMode())
{
default:
case OSD_SignalMode_AsIs: aModeStr = "asis"; break;
case OSD_SignalMode_Set: aModeStr = "set"; break;
case OSD_SignalMode_SetUnhandled: aModeStr = "unhandled"; break;
case OSD_SignalMode_Unset: aModeStr = "unset"; break;
}
theDI << "Signal mode: " << aModeStr << "\n"
<< "Catch FPE: " << (OSD::ToCatchFloatingSignals() ? "1" : "0") << "\n";
return 0;
}
@@ -1057,7 +1106,7 @@ void Draw::BasicCommands(Draw_Interpretor& theCommands)
__FILE__, dmeminfo, g);
theCommands.Add("dperf","dperf [reset] -- show performance counters, reset if argument is provided",
__FILE__,dperf,g);
theCommands.Add("dsetsignal","dsetsignal [fpe=0] -- set OSD signal handler, with FPE option if argument is given",
theCommands.Add("dsetsignal","dsetsignal [{asis|set|unhandled|unset}=set] [{0|1|default=$CSF_FPE}]\n -- set OSD signal handler, with FPE option if argument is given",
__FILE__,dsetsignal,g);
theCommands.Add("dparallel",

View File

@@ -19,8 +19,9 @@
#include <windows.h>
#include <DrawRessource.h>
#include <init.h>
#include <MainWindow.h>
#include <Draw_Window.hxx>
#include <MainWindow.h>
#include <CommandWindow.h>
Standard_Boolean Draw_Interprete(const char* command); // Implemented in Draw.cxx

View File

@@ -212,7 +212,7 @@ IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile
{
if (thelibrary.IsNull()) return IFSelect_RetVoid;
if (theprotocol.IsNull()) return IFSelect_RetVoid;
Handle(Interface_InterfaceModel) model =myModel;
Handle(Interface_InterfaceModel) model;
IFSelect_ReturnStatus status = IFSelect_RetVoid;
try {
OCC_CATCH_SIGNALS
@@ -1701,12 +1701,11 @@ Standard_Integer IFSelect_WorkSession::RunTransformer
{
Standard_Integer effect = 0;
if (transf.IsNull() || !IsLoaded()) return effect;
Handle(Interface_InterfaceModel) newmod; // Null au depart
Interface_CheckIterator checks;
checks.SetName("X-STEP WorkSession : RunTransformer");
Standard_Boolean res = transf->Perform
(thegraph->Graph(),theprotocol,checks,myModel);
(thegraph->Graph(),theprotocol,checks,newmod);
if (!checks.IsEmpty(Standard_False)) {
Handle(Message_Messenger) sout = Message::DefaultMessenger();

View File

@@ -589,6 +589,13 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData,
return false;
}
if (FreeImage_GetBPP (anImage) == 1)
{
FIBITMAP* aTmpImage = FreeImage_ConvertTo8Bits (anImage);
FreeImage_Unload (anImage);
anImage = aTmpImage;
}
Image_Format aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage),
FreeImage_GetColorType(anImage),
FreeImage_GetBPP (anImage));

View File

@@ -508,7 +508,11 @@ bool Media_PlayerContext::receiveFrame (const Handle(Media_Frame)& theFrame,
//================================================================
void Media_PlayerContext::doThreadLoop()
{
OSD::SetSignal (false);
// always set OCCT signal handler to catch signals if any;
// this is safe (for thread local handler) since the thread
// is owned by this class
OSD::SetThreadLocalSignal (OSD_SignalMode_Set, false);
Handle(Media_Frame) aFrame;
bool wasSeeked = false;
for (;;)

View File

@@ -34,6 +34,7 @@ MeshVS_CommonSensitiveEntity::MeshVS_CommonSensitiveEntity (const Handle(SelectM
myDataSource (theParentMesh->GetDataSource()),
mySelMethod (theSelMethod)
{
myMaxFaceNodes = 0;
theParentMesh->GetDrawer()->GetInteger (MeshVS_DA_MaxFaceNodes, myMaxFaceNodes);
Standard_ASSERT_RAISE (myMaxFaceNodes > 0,
"The maximal amount of nodes in a face must be greater than zero to create sensitive entity");

View File

@@ -179,8 +179,7 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
//Now we are ready to draw faces with equal colors
Aspect_TypeOfLine anEdgeType = Aspect_TOL_SOLID;
Aspect_TypeOfLine aLineType = Aspect_TOL_SOLID;
Standard_Integer anEdgeInt, aLineInt;
Standard_Real anEdgeWidth, aLineWidth;
Standard_Real anEdgeWidth = 1.0, aLineWidth = 1.0;
Quantity_Color anInteriorColor;
Quantity_Color anEdgeColor, aLineColor;
Standard_Boolean anEdgeOn = Standard_True, IsReflect = Standard_False,
@@ -197,9 +196,11 @@ void MeshVS_ElementalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)&
aDrawer->GetBoolean( MeshVS_DA_SmoothShading, IsMeshSmoothShading );
aDrawer->GetBoolean (MeshVS_DA_SupressBackFaces, toSupressBackFaces);
Standard_Integer anEdgeInt = Aspect_TOL_SOLID;
if ( aDrawer->GetInteger ( MeshVS_DA_EdgeType, anEdgeInt) )
anEdgeType = (Aspect_TypeOfLine) anEdgeInt;
Standard_Integer aLineInt = Aspect_TOL_SOLID;
if ( aDrawer->GetInteger ( MeshVS_DA_BeamType, aLineInt) )
aLineType = (Aspect_TypeOfLine) aLineInt;

View File

@@ -195,7 +195,7 @@ void MeshVS_MeshPrsBuilder::BuildElements( const Handle(Prs3d_Presentation)& Prs
aDispMode &= MeshVS_DMF_OCCMask;
//--------------------------------------------------------
Standard_Real aShrinkCoef;
Standard_Real aShrinkCoef = 0.0;
aDrawer->GetDouble ( MeshVS_DA_ShrinkCoeff, aShrinkCoef );
Standard_Boolean IsWireFrame = ( aDispMode==MeshVS_DMF_WireFrame ),
@@ -203,11 +203,12 @@ void MeshVS_MeshPrsBuilder::BuildElements( const Handle(Prs3d_Presentation)& Prs
IsShrink = ( aDispMode==MeshVS_DMF_Shrink ),
HasHilightFlag = ( ( DisplayMode & MeshVS_DMF_HilightPrs ) != 0 ),
HasSelectFlag = ( ( DisplayMode & MeshVS_DMF_SelectionPrs ) != 0 ),
IsMeshReflect, IsMeshAllowOverlap, IsReflect, IsMeshSmoothShading = Standard_False;
IsMeshReflect = Standard_False, IsMeshAllowOverlap = Standard_False,
IsMeshSmoothShading = Standard_False;
aDrawer->GetBoolean ( MeshVS_DA_Reflection, IsMeshReflect );
aDrawer->GetBoolean ( MeshVS_DA_IsAllowOverlapped, IsMeshAllowOverlap );
IsReflect = ( IsMeshReflect && !HasHilightFlag );
const Standard_Boolean IsReflect = ( IsMeshReflect && !HasHilightFlag );
aDrawer->GetBoolean ( MeshVS_DA_SmoothShading, IsMeshSmoothShading );
// display mode for highlighted prs of groups

View File

@@ -411,8 +411,7 @@ void MeshVS_NodalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
// Aspect_InteriorStyle aStyle;
// Standard_Integer aStyleInt;
Aspect_TypeOfLine anEdgeType = Aspect_TOL_SOLID;
Standard_Integer anEdgeInt;
Standard_Real anEdgeWidth;
Standard_Real anEdgeWidth = 1.0;
Quantity_Color anInteriorColor;
Quantity_Color anEdgeColor, aLineColor;
Standard_Boolean aShowEdges = Standard_True;
@@ -423,6 +422,7 @@ void MeshVS_NodalColorPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
aDrawer->GetDouble ( MeshVS_DA_EdgeWidth, anEdgeWidth );
aDrawer->GetBoolean( MeshVS_DA_ShowEdges, aShowEdges );
Standard_Integer anEdgeInt = Aspect_TOL_SOLID;
if ( aDrawer->GetInteger ( MeshVS_DA_EdgeType, anEdgeInt ) )
anEdgeType = (Aspect_TypeOfLine) anEdgeInt;

View File

@@ -167,27 +167,29 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
Standard_Real AExpansionFactor = 1.0;
Standard_Real ASpace = 0.0;
Aspect_TypeOfStyleText ATextStyle = Aspect_TOST_ANNOTATION;
Standard_Integer AStyleInt;
Aspect_TypeOfDisplayText ADisplayType = Aspect_TODT_NORMAL;
TCollection_AsciiString AFontString;
Standard_Integer ADispInt;
// Bold font is used by default for better text readability
Font_FontAspect AFontAspectType = Font_FA_Bold;
Standard_Integer AAspect;
aDrawer->GetColor ( MeshVS_DA_TextColor, AColor );
aDrawer->GetDouble ( MeshVS_DA_TextExpansionFactor, AExpansionFactor );
aDrawer->GetDouble ( MeshVS_DA_TextSpace, ASpace );
TCollection_AsciiString AFontString = Font_NOF_ASCII_MONO;
if ( aDrawer->GetAsciiString ( MeshVS_DA_TextFont, AFontString ) )
AFont = AFontString.ToCString();
Standard_Integer AStyleInt = Aspect_TOST_ANNOTATION;
if ( aDrawer->GetInteger ( MeshVS_DA_TextStyle, AStyleInt ) )
ATextStyle = (Aspect_TypeOfStyleText) AStyleInt;
Standard_Integer ADispInt = Aspect_TODT_NORMAL;
if ( aDrawer->GetInteger ( MeshVS_DA_TextDisplayType, ADispInt ) )
ADisplayType = (Aspect_TypeOfDisplayText) ADispInt;
Standard_Integer AAspect = Font_FA_Bold;
if ( aDrawer->GetInteger ( MeshVS_DA_TextFontAspect, AAspect ) )
AFontAspectType = (Font_FontAspect)AAspect;
AFontAspectType = (Font_FontAspect)AAspect;
Handle (Graphic3d_AspectText3d) aTextAspect = new Graphic3d_AspectText3d ( AColor, AFont, AExpansionFactor, ASpace,
ATextStyle, ADisplayType );

View File

@@ -93,3 +93,4 @@ OSD_Timer.hxx
OSD_WhoAmI.hxx
OSD_WNT.cxx
OSD_WNT.hxx
OSD_SignalMode.hxx

View File

@@ -16,49 +16,26 @@
#define _OSD_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#include <Standard_PCharacter.hxx>
#include <Standard_CString.hxx>
class OSD_Error;
class OSD_Protection;
class OSD_Path;
class OSD_FileNode;
class OSD_Disk;
class OSD_File;
class OSD_FileIterator;
class OSD_Directory;
class OSD_DirectoryIterator;
class OSD_Timer;
class OSD_Host;
class OSD_Environment;
class OSD_EnvironmentIterator;
class OSD_Process;
class OSD_SharedLibrary;
class OSD_Thread;
#include <OSD_SignalMode.hxx>
//! Set of Operating Sytem Dependent Tools
//! (O)perating (S)ystem (D)ependent
//! Set of Operating Sytem Dependent (OSD) Tools
class OSD
{
public:
DEFINE_STANDARD_ALLOC
//! Sets signal and exception handlers.
//! Sets or removes signal and FPE (floating-point exception) handlers.
//! OCCT signal handlers translate signals raised by C subsystem to C++
//! exceptions inheriting Standard_Failure.
//!
//! ### Windows-specific notes
//!
//! Compiled with MS VC++ sets 3 main handlers:
//! @li Signal handlers (via ::signal() functions) that translate system signals
//! (SIGSEGV, SIGFPE, SIGILL) into C++ exceptions (classes inheriting
//! Standard_Failure). They only be called if user calls ::raise() function
//! Standard_Failure). They only be called if function ::raise() is called
//! with one of supported signal type set.
//! @li Exception handler OSD::WntHandler() (via ::SetUnhandledExceptionFilter())
//! that will be used when user's code is compiled with /EHs option.
@@ -71,41 +48,68 @@ public:
//! compile his code with (/EHs or /EHa), signals (or SE exceptions) will be
//! translated into Open CASCADE C++ exceptions.
//!
//! If @a theFloatingSignal is TRUE then floating point exceptions will be
//! generated in accordance with the mask
//! <tt>_EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW</tt> that is
//! used to call ::_controlfp() system function. If @a theFloatingSignal is FALSE
//! corresponding operations (e.g. division by zero) will gracefully complete
//! without an exception.
//! MinGW should use SEH exception mode for signal handling to work.
//!
//! ### Unix-specific notes
//! ### Linux-specific notes
//!
//! OSD::SetSignal() sets handlers (via ::sigaction()) for multiple signals
//! (SIGFPE, SIGSEGV, etc). Currently the number of handled signals is much
//! greater than for Windows, in the future this may change to provide better
//! consistency with Windows.
//!
//! @a theFloatingSignal is recognized on Sun Solaris, Linux, and SGI Irix to
//! generate floating-point exception according to the mask
//! <tt>FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW</tt> (in Linux conventions).<br>
//! When compiled with OBJS macro defined, already set signal handlers (e.g.
//! by Data Base Managers) are not redefined.
//! (SIGFPE, SIGSEGV, etc).
//!
//! ### Common notes
//!
//! If OSD::SetSignal() method is used in at least one thread, it must also be
//! called in any other thread where Open CASCADE will be used, to ensure
//! consistency of behavior. Its @a aFloatingSignal argument must be consistent
//! across threads.
//! If @a theFloatingSignal is TRUE then floating point exceptions will
//! generate SIGFPE in accordance with the mask
//! - Windows: _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW,
//! see _controlfp() system function.
//! - Linux: FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW,
//! see feenableexcept() system function.
//!
//! Keep in mind that whether the C++ exception will really be thrown (i.e.
//! ::throw() will be called) is regulated by the
//! OCC_CONVERT_SIGNALS macro used during compilation of Open CASCADE and
//! user's code. Refer to Foundation Classes User's Guide for further details.
//! If @a theFloatingSignal is FALSE then floating point calculations will gracefully
//! complete regardless of occurred exceptions (e.g. division by zero).
//! Otherwise the (thread-specific) FPE flags are set to raise signal if one of
//! floating-point exceptions (division by zero, overflow, or invalid operation) occurs.
//!
Standard_EXPORT static void SetSignal (const Standard_Boolean theFloatingSignal = Standard_True);
//! The recommended approach is to call OSD::SetSignal() in the beginning of the
//! execution of the program, in function main() or its equivalent.
//! In multithreaded programs it is advisable to call OSD::SetSignal() or
//! OSD::SetThreadLocalSignal() with the same parameters in other threads where
//! OCCT is used, to ensure consistency of behavior.
//!
//! Note that in order to handle signals as C++ exceptions on Linux and under
//! MinGW on Windows it is necessary to compile both OCCT and application with
//! OCC_CONVERT_SIGNALS macro, and use macro OCC_CATCH_SIGNALS within each try{}
//! block that has to catch this kind of exceptions.
//!
//! Refer to documentation of Standard_ErrorHandler.hxx for details.
Standard_EXPORT static void SetSignal (OSD_SignalMode theSignalMode,
Standard_Boolean theFloatingSignal);
//! Return floating signal catching value previously set by SetSignal().
//! Sets signal and FPE handlers.
//! Short-cut for OSD::SetSignal (OSD_SignalMode_Set, theFloatingSignal).
static void SetSignal (const Standard_Boolean theFloatingSignal = Standard_True)
{
SetSignal (OSD_SignalMode_Set, theFloatingSignal);
}
//! Initializes thread-local signal handlers.
//! This includes _set_se_translator() on Windows platform, and SetFloatingSignal().
//! The main purpose of this method is initializing handlers for newly created threads
//! without overriding global handlers (set by application or by OSD::SetSignal()).
Standard_EXPORT static void SetThreadLocalSignal (OSD_SignalMode theSignalMode,
Standard_Boolean theFloatingSignal);
//! Enables / disables generation of C signal on floating point exceptions (FPE).
//! This call does NOT register a handler for signal raised in case of FPE -
//! SetSignal() should be called beforehand for complete setup.
//! Note that FPE setting is thread-local, new threads inherit it from parent.
Standard_EXPORT static void SetFloatingSignal (Standard_Boolean theFloatingSignal);
//! Returns signal mode set by the last call to SetSignal().
//! By default, returns OSD_SignalMode_AsIs.
Standard_EXPORT static OSD_SignalMode SignalMode();
//! Returns true if floating point exceptions will raise C signal
//! according to current (platform-dependent) settings in this thread.
Standard_EXPORT static Standard_Boolean ToCatchFloatingSignals();
//! Commands the process to sleep for a number of seconds.

View File

@@ -40,7 +40,7 @@ void OSD_Parallel::forEachExternal (UniversalIterator& theBegin,
{
const Handle(OSD_ThreadPool)& aThreadPool = OSD_ThreadPool::DefaultPool();
const Standard_Integer aNbThreads = theNbItems > 0 ?
Min (theNbItems, aThreadPool->NbDefaultThreadsToLaunch()) : -1;
aThreadPool->NbDefaultThreadsToLaunch() : -1;
tbb::task_scheduler_init aScheduler (aNbThreads);
tbb::parallel_for_each (theBegin, theEnd, theFunctor);

View File

@@ -0,0 +1,26 @@
// 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 _OSD_SignalMode_HeaderFile
#define _OSD_SignalMode_HeaderFile
//! Mode of operation for OSD::SetSignal() function
enum OSD_SignalMode
{
OSD_SignalMode_AsIs, //!< Do not set or remove signal handlers
OSD_SignalMode_Set, //!< Set OCCT signal handlers
OSD_SignalMode_SetUnhandled, //!< Set OCCT signal handler but only if no handler is set, for each particular signal type
OSD_SignalMode_Unset //!< Unset signal handler to system default
};
#endif // _OSD_SignalMode_HeaderFile

View File

@@ -309,7 +309,7 @@ void OSD_ThreadPool::performJob (Handle(Standard_Failure)& theFailure,
// =======================================================================
void OSD_ThreadPool::EnumeratedThread::performThread()
{
OSD::SetSignal (false);
OSD::SetThreadLocalSignal (OSD::SignalMode(), false);
for (;;)
{
myWakeEvent.Wait();
@@ -322,7 +322,7 @@ void OSD_ThreadPool::EnumeratedThread::performThread()
myFailure.Nullify();
if (myJob != NULL)
{
OSD::SetSignal (myToCatchFpe);
OSD::SetThreadLocalSignal (OSD::SignalMode(), myToCatchFpe);
OSD_ThreadPool::performJob (myFailure, myJob, myThreadIndex);
myJob = NULL;
}

View File

@@ -16,16 +16,17 @@
#include <OSD_Exception_CTRL_BREAK.hxx>
#include <Standard_DivideByZero.hxx>
#include <Standard_Overflow.hxx>
#include <Standard_Assert.hxx>
static Standard_THREADLOCAL Standard_Boolean fFltExceptions = Standard_False;
static OSD_SignalMode OSD_WasSetSignal = OSD_SignalMode_AsIs;
//=======================================================================
//function : ToCatchFloatingSignals
//function : SignalMode
//purpose :
//=======================================================================
Standard_Boolean OSD::ToCatchFloatingSignals()
OSD_SignalMode OSD::SignalMode()
{
return fFltExceptions;
return OSD_WasSetSignal;
}
#ifdef _WIN32
@@ -90,7 +91,6 @@ static Standard_Boolean fDbgLoaded;
static LONG _osd_debug ( void );
#endif
//# define _OSD_FPX ( _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW | _EM_UNDERFLOW )
# define _OSD_FPX ( _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW )
#ifdef OCC_CONVERT_SIGNALS
@@ -236,15 +236,16 @@ static LONG CallHandler (DWORD dwExceptionCode,
} // end switch
// reset FPE state (before message box, otherwise it may fail to show up)
if ( flterr ) {
OSD::SetFloatingSignal (Standard_True);
}
#if ! defined(OCCT_UWP) && !defined(__MINGW32__) && !defined(__CYGWIN32__)
// provide message to the user with possibility to stop
size_t idx;
StringCchLengthW (buffer, _countof(buffer),&idx);
if ( idx && fMsgBox && dwExceptionCode != EXCEPTION_NONCONTINUABLE_EXCEPTION ) {
// reset FP operations before message box, otherwise it may fail to show up
_fpreset();
_clearfp();
#if ! defined(OCCT_UWP) && !defined(__MINGW32__) && !defined(__CYGWIN32__)
MessageBeep ( MB_ICONHAND );
int aChoice = ::MessageBoxW (0, buffer, L"OCCT Exception Handler", MB_ABORTRETRYIGNORE | MB_ICONSTOP);
if (aChoice == IDRETRY)
@@ -253,17 +254,8 @@ static LONG CallHandler (DWORD dwExceptionCode,
DebugBreak();
} else if (aChoice == IDABORT)
exit(0xFFFF);
}
#endif
}
// reset FPE state
if ( flterr ) {
if ( !fFltExceptions ) return EXCEPTION_EXECUTE_HANDLER;
_fpreset () ;
_clearfp() ;
_controlfp ( 0, _OSD_FPX ) ; // JR add :
// std::cout << "OSD::WntHandler _controlfp( 0, _OSD_FPX ) " << std::hex << _controlfp(0,0) << std::dec << std::endl ;
}
char aBufferA[2048];
WideCharToMultiByte(CP_UTF8, 0, buffer, -1, aBufferA, sizeof(aBufferA), NULL, NULL);
@@ -367,13 +359,60 @@ static LONG WINAPI WntHandler (EXCEPTION_POINTERS *lpXP)
lpXP->ExceptionRecord->ExceptionInformation[0]);
}
//=======================================================================
//function : SetFloatingSignal
//purpose :
//=======================================================================
void OSD::SetFloatingSignal (Standard_Boolean theFloatingSignal)
{
_fpreset();
_clearfp();
// Note: zero bit means exception will be raised
_controlfp (theFloatingSignal ? 0 : _OSD_FPX, _OSD_FPX);
}
//=======================================================================
//function : ToCatchFloatingSignals
//purpose :
//=======================================================================
Standard_Boolean OSD::ToCatchFloatingSignals()
{
// return true if at least one of bits within _OSD_FPX
// is unset, which means relevant FPE will raise exception
int aControlWord = _controlfp (0, 0);
return (_OSD_FPX & ~aControlWord) != 0;
}
//=======================================================================
//function : SetThreadLocalSignal
//purpose :
//=======================================================================
void OSD::SetThreadLocalSignal (OSD_SignalMode theSignalMode,
Standard_Boolean theFloatingSignal)
{
#ifdef _MSC_VER
_se_translator_function aPreviousFunc = NULL;
if (theSignalMode == OSD_SignalMode_Set || theSignalMode == OSD_SignalMode_SetUnhandled)
aPreviousFunc = _set_se_translator(TranslateSE);
if (theSignalMode == OSD_SignalMode_Unset || (theSignalMode == OSD_SignalMode_SetUnhandled && aPreviousFunc != NULL))
_set_se_translator(aPreviousFunc);
#else
(void)theSignalMode;
#endif
SetFloatingSignal (theFloatingSignal);
}
//=======================================================================
//function : SetSignal
//purpose :
//=======================================================================
void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
void OSD::SetSignal (OSD_SignalMode theSignalMode,
Standard_Boolean theFloatingSignal)
{
Standard_Mutex::Sentry aSentry (THE_SIGNAL_MUTEX); // lock the mutex to prevent simultaneous handling
OSD_WasSetSignal = theSignalMode;
#if !defined(OCCT_UWP) || defined(NTDDI_WIN10_TH2)
OSD_Environment env ("CSF_DEBUG_MODE");
TCollection_AsciiString val = env.Value();
@@ -391,37 +430,53 @@ void OSD::SetSignal (const Standard_Boolean theFloatingSignal)
// when user's code is compiled with /EHs
// Replaces the existing top-level exception filter for all existing and all future threads
// in the calling process
::SetUnhandledExceptionFilter (/*(LPTOP_LEVEL_EXCEPTION_FILTER)*/ WntHandler);
{
LPTOP_LEVEL_EXCEPTION_FILTER aPreviousFunc = NULL;
if (theSignalMode == OSD_SignalMode_Set || theSignalMode == OSD_SignalMode_SetUnhandled)
{
aPreviousFunc = ::SetUnhandledExceptionFilter(WntHandler);
}
if (theSignalMode == OSD_SignalMode_Unset || (theSignalMode == OSD_SignalMode_SetUnhandled && aPreviousFunc != NULL))
{
::SetUnhandledExceptionFilter(aPreviousFunc);
}
}
#endif // NTDDI_WIN10_TH2
// Signal handlers will only be used when the method ::raise() will be used
// Handlers must be set for every thread
if (signal (SIGSEGV, (void(*)(int))SIGWntHandler) == SIG_ERR)
std::cout << "signal(OSD::SetSignal) error\n";
if (signal (SIGFPE, (void(*)(int))SIGWntHandler) == SIG_ERR)
std::cout << "signal(OSD::SetSignal) error\n";
if (signal (SIGILL, (void(*)(int))SIGWntHandler) == SIG_ERR)
std::cout << "signal(OSD::SetSignal) error\n";
// Signal handlers will only be used when function ::raise() is called
const int NBSIG = 3;
const int aSignalTypes[NBSIG] = { SIGSEGV, SIGILL, SIGFPE };
for (int i = 0; i < NBSIG; ++i)
{
typedef void (*SignalFuncType)(int); // same as _crt_signal_t available since vc14
SignalFuncType aPreviousFunc = SIG_DFL;
if (theSignalMode == OSD_SignalMode_Set || theSignalMode == OSD_SignalMode_SetUnhandled)
{
aPreviousFunc = signal(aSignalTypes[i], (SignalFuncType)SIGWntHandler);
}
if (theSignalMode == OSD_SignalMode_Unset ||
(theSignalMode == OSD_SignalMode_SetUnhandled && aPreviousFunc != SIG_DFL && aPreviousFunc != SIG_ERR))
{
aPreviousFunc = signal(aSignalTypes[i], aPreviousFunc);
}
Standard_ASSERT(aPreviousFunc != SIG_ERR, "signal() failed", std::cout << "OSD::SetSignal(): signal() returns SIG_ERR");
}
// Set Ctrl-C and Ctrl-Break handler
fCtrlBrk = Standard_False;
#ifndef OCCT_UWP
SetConsoleCtrlHandler (&_osd_ctrl_break_handler, TRUE);
#endif
#ifdef _MSC_VER
// _se_translator_function pOldSeFunc =
_set_se_translator (TranslateSE);
if (theSignalMode == OSD_SignalMode_Set || theSignalMode == OSD_SignalMode_SetUnhandled)
{
SetConsoleCtrlHandler(&_osd_ctrl_break_handler, true);
}
else if (theSignalMode == OSD_SignalMode_Unset)
{
SetConsoleCtrlHandler(&_osd_ctrl_break_handler, false);
}
#endif
fFltExceptions = theFloatingSignal;
if (theFloatingSignal)
{
_controlfp (0, _OSD_FPX); // JR add :
}
else {
_controlfp (_OSD_FPX, _OSD_FPX); // JR add :
}
} // end OSD :: SetSignal
SetThreadLocalSignal (theSignalMode, theFloatingSignal);
}
//============================================================================
//==== ControlBreak
@@ -636,18 +691,12 @@ static Standard_Boolean fCtrlBrk;
typedef void (ACT_SIGIO_HANDLER)(void) ;
ACT_SIGIO_HANDLER *ADR_ACT_SIGIO_HANDLER = NULL ;
#ifdef DECOSF1
typedef void (* SIG_PFV) (int);
#endif
#ifdef __GNUC__
# include <stdlib.h>
# include <stdio.h>
#else
# ifdef SA_SIGINFO
# ifndef _AIX
# include <sys/siginfo.h>
# endif
# endif
#endif
typedef void (* SIG_PFV) (int);
@@ -658,6 +707,8 @@ typedef void (* SIG_PFV) (int);
#include <sys/signal.h>
#endif
# define _OSD_FPX (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW)
//============================================================================
//==== Handler
//==== Catche the differents signals:
@@ -696,11 +747,7 @@ static void Handler (const int theSignal)
// std::cout << "OSD::Handler: signal " << (int) theSignal << " occured inside a try block " << std::endl ;
if ( ADR_ACT_SIGIO_HANDLER != NULL )
(*ADR_ACT_SIGIO_HANDLER)() ;
#ifdef __linux__
if (fFltExceptions)
feenableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
//feenableexcept (FE_INVALID | FE_DIVBYZERO);
#endif
sigset_t set;
sigemptyset(&set);
switch (theSignal) {
@@ -746,10 +793,8 @@ static void Handler (const int theSignal)
case SIGFPE:
sigaddset(&set, SIGFPE);
sigprocmask(SIG_UNBLOCK, &set, NULL) ;
#ifdef DECOSF1
// Pour DEC/OSF1 SIGFPE = Division par zero.
Standard_DivideByZero::NewInstance('')->Jump;
break;
#ifdef __linux__
OSD::SetFloatingSignal (Standard_True);
#endif
#if (!defined (__sun)) && (!defined(SOLARIS))
Standard_NumericError::NewInstance("SIGFPE Arithmetic exception detected")->Jump();
@@ -788,12 +833,6 @@ static void Handler (const int theSignal)
}
#endif
break;
#if defined (__sgi) || defined(IRIX)
case SIGTRAP:
sigaddset(&set, SIGTRAP);
sigprocmask(SIG_UNBLOCK, &set, NULL) ;
Standard_DivideByZero::NewInstance("SIGTRAP IntegerDivideByZero")->Jump(); break;
#endif
default:
#ifdef OCCT_DEBUG
std::cout << "Unexpected signal " << theSignal << std::endl ;
@@ -814,11 +853,6 @@ static void SegvHandler(const int theSignal,
(void)theSignal; // silence GCC warnings
(void)theContext;
#ifdef __linux__
if (fFltExceptions)
feenableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
//feenableexcept (FE_INVALID | FE_DIVBYZERO);
#endif
// std::cout << "OSD::SegvHandler activated(SA_SIGINFO)" << std::endl ;
if ( ip != NULL ) {
sigset_t set;
@@ -874,160 +908,127 @@ static void SegvHandler(const int theSignal,
#endif
//=======================================================================
//function : SetFloatingSignal
//purpose :
//=======================================================================
void OSD::SetFloatingSignal (Standard_Boolean theFloatingSignal)
{
#if defined (__linux__)
feclearexcept (FE_ALL_EXCEPT);
if (theFloatingSignal)
{
feenableexcept (_OSD_FPX);
}
else
{
fedisableexcept (_OSD_FPX);
}
#elif defined (__sun) || defined (SOLARIS)
int aSunStat = 0;
sigfpe_handler_type anFpeHandler = (theFloatingSignal ? (sigfpe_handler_type)Handler : NULL);
aSunStat = ieee_handler ("set", "invalid", anFpeHandler);
aSunStat = ieee_handler ("set", "division", anFpeHandler) || aSunStat;
aSunStat = ieee_handler ("set", "overflow", anFpeHandler) || aSunStat;
if (aSunStat)
{
#ifdef OCCT_DEBUG
std::cerr << "ieee_handler does not work !!! KO\n";
#endif
}
#else
(void)theFloatingSignal;
#endif
}
//=======================================================================
//function : ToCatchFloatingSignals
//purpose :
//=======================================================================
Standard_Boolean OSD::ToCatchFloatingSignals()
{
#if defined (__linux__)
return (fegetexcept() & _OSD_FPX) != 0;
#else
return Standard_False;
#endif
}
//=======================================================================
//function : SetThreadLocalSignal
//purpose :
//=======================================================================
void OSD::SetThreadLocalSignal (OSD_SignalMode /*theSignalMode*/,
Standard_Boolean theFloatingSignal)
{
SetFloatingSignal (theFloatingSignal);
}
//============================================================================
//==== SetSignal
//==== Set the differents signals:
//============================================================================
void OSD::SetSignal(const Standard_Boolean aFloatingSignal)
void OSD::SetSignal (OSD_SignalMode theSignalMode,
Standard_Boolean theFloatingSignal)
{
struct sigaction act, oact;
int stat = 0;
SetFloatingSignal (theFloatingSignal);
if( aFloatingSignal ) {
//==== Enable the floating point exceptions ===============
#if defined (__sun) || defined (SOLARIS)
sigfpe_handler_type PHandler = (sigfpe_handler_type) Handler ;
stat = ieee_handler("set", "invalid", PHandler);
stat = ieee_handler("set", "division", PHandler) || stat;
stat = ieee_handler("set", "overflow", PHandler) || stat;
OSD_WasSetSignal = theSignalMode;
if (theSignalMode == OSD_SignalMode_AsIs)
{
return; // nothing to be done with signal handlers
}
//stat = ieee_handler("set", "underflow", PHandler) || stat;
//stat = ieee_handler("set", "inexact", PHandler) || stat;
// Prepare signal descriptors
struct sigaction anActSet, anActDfl, anActOld;
sigemptyset(&anActSet.sa_mask);
sigemptyset(&anActDfl.sa_mask);
sigemptyset(&anActOld.sa_mask);
#ifdef SA_RESTART
anActSet.sa_flags = anActDfl.sa_flags = anActOld.sa_flags = SA_RESTART;
#else
anActSet.sa_flags = anActDfl.sa_flags = anActOld.sa_flags = 0;
#endif
#ifdef SA_SIGINFO
anActSet.sa_flags = anActSet.sa_flags | SA_SIGINFO;
anActSet.sa_sigaction = Handler;
#else
anActSet.sa_handler = Handler;
#endif
anActDfl.sa_handler = SIG_DFL;
if (stat) {
#ifdef OCCT_DEBUG
std::cerr << "ieee_handler does not work !!! KO " << std::endl;
// Set signal handlers; NB: SIGSEGV must be the last one!
const int NBSIG = 8;
const int aSignalTypes[NBSIG] = { SIGFPE, SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGBUS, SIGSYS, SIGSEGV };
for (int i = 0; i < NBSIG; ++i)
{
// SIGSEGV has special handler
if (aSignalTypes[i] == SIGSEGV)
{
#ifdef SA_SIGINFO
anActSet.sa_sigaction = /*(void(*)(int, siginfo_t *, void*))*/ SegvHandler;
#else
anActSet.sa_handler = /*(SIG_PFV)*/ SegvHandler;
#endif
}
#elif defined (__linux__)
feenableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
fFltExceptions = Standard_True;
#endif
// set handler according to specified mode and current handler
int retcode = -1;
if (theSignalMode == OSD_SignalMode_Set || theSignalMode == OSD_SignalMode_SetUnhandled)
{
retcode = sigaction (aSignalTypes[i], &anActSet, &anActOld);
}
else if (theSignalMode == OSD_SignalMode_Unset)
{
retcode = sigaction (aSignalTypes[i], &anActDfl, &anActOld);
}
if (theSignalMode == OSD_SignalMode_SetUnhandled && retcode == 0 && anActOld.sa_handler != SIG_DFL)
{
retcode = sigaction (aSignalTypes[i], &anActOld, &anActOld);
}
Standard_ASSERT(retcode == 0, "sigaction() failed", std::cout << "OSD::SetSignal(): sigaction() failed for " << aSignalTypes[i] << std::endl);
}
else
{
#if defined (__linux__)
fedisableexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
fFltExceptions = Standard_False;
#endif
}
#if defined (sgi) || defined (IRIX )
char *TRAP_FPE = getenv("TRAP_FPE") ;
if ( TRAP_FPE == NULL ) {
#ifdef OCCT_DEBUG
std::cout << "On SGI you must set TRAP_FPE environment variable : " << std::endl ;
std::cout << "set env(TRAP_FPE) \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\" or" << std::endl ;
std::cout << "setenv TRAP_FPE \"UNDERFL=FLUSH_ZERO;OVERFL=DEFAULT;DIVZERO=DEFAULT;INT_OVERFL=DEFAULT\"" << std::endl ;
#endif
}
#endif
//==== Save the old Signal Handler, and set the new one ===================
sigemptyset(&act.sa_mask) ;
#ifdef SA_RESTART
act.sa_flags = SA_RESTART ;
#else
act.sa_flags = 0 ;
#endif
#ifdef SA_SIGINFO
act.sa_flags = act.sa_flags | SA_SIGINFO ;
act.sa_sigaction = /*(void(*)(int, siginfo_t *, void*))*/ Handler;
#else
act.sa_handler = /*(SIG_PFV)*/ Handler;
#endif
//==== Always detected the signal "SIGFPE" =================================
stat = sigaction(SIGFPE,&act,&oact); // ...... floating point exception
if (stat) {
#ifdef OCCT_DEBUG
std::cerr << "sigaction does not work !!! KO " << std::endl;
#endif
perror("sigaction ");
}
//==== Detected the only the "free" signals ================================
sigaction(SIGHUP,&act,&oact); // ...... hangup
#ifdef OBJS
if(oact.sa_handler)
sigaction(SIGHUP,&oact,&oact);
#endif
sigaction(SIGINT,&act,&oact); // ...... interrupt
#ifdef OBJS
if(oact.sa_handler)
sigaction(SIGINT,&oact,&oact);
#endif
sigaction(SIGQUIT,&act,&oact); // ...... quit
#ifdef OBJS
if(oact.sa_handler)
sigaction(SIGQUIT,&oact,&oact);
#endif
sigaction(SIGILL,&act,&oact); // ...... illegal instruction
#ifdef OBJS
if(oact.sa_handler)
sigaction(SIGILL,&oact,&oact);
#endif
sigaction(SIGBUS,&act,&oact); // ...... bus error
#ifdef OBJS
if(oact.sa_handler)
sigaction(SIGBUS,&oact,&oact);
#endif
#if !defined(__linux__)
sigaction(SIGSYS,&act,&oact); // ...... bad argument to system call
# ifdef OBJS
if(oact.sa_handler)
sigaction(SIGSYS,&oact,&oact);
# endif
#endif
#if defined (__sgi) || defined(IRIX)
sigaction(SIGTRAP,&act,&oact); // Integer Divide By Zero (IRIX)
# ifdef OBJS
if(oact.sa_handler)
sigaction(SIGTRAP,&oact,&oact);
# endif
#endif
#ifdef SA_SIGINFO
act.sa_sigaction = /*(void(*)(int, siginfo_t *, void*))*/ SegvHandler;
#else
act.sa_handler = /*(SIG_PFV)*/ SegvHandler;
#endif
if ( sigaction( SIGSEGV , &act , &oact ) ) // ...... segmentation violation
perror("OSD::SetSignal sigaction( SIGSEGV , &act , &oact ) ") ;
#ifdef OBJS
if(oact.sa_handler)
sigaction(SIGSEGV,&oact,&oact);
#endif
#if defined(__osf__) || defined(DECOSF1)
struct sigaction action, prev_action;
action.sa_handler = SIG_IGN;
action.sa_mask = 0;
action.sa_flags = 0;
if (sigaction (SIGFPE, &action, &prev_action) == -1) {
perror ("sigaction");
exit (1);
}
#endif
}
//============================================================================

View File

@@ -162,6 +162,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
myTexClamp (GL_CLAMP_TO_EDGE),
myMaxTexDim (1024),
myMaxTexCombined (1),
myMaxTexUnitsFFP (1),
myMaxDumpSizeX (1024),
myMaxDumpSizeY (1024),
myMaxClipPlanes (6),
@@ -1557,18 +1558,19 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
}
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &myMaxTexDim);
#if !defined(GL_ES_VERSION_2_0)
if (IsGlGreaterEqual (1, 3) && core11 != NULL)
{
// this is a maximum of texture units for FFP functionality,
// usually smaller than combined texture units available for GLSL
glGetIntegerv (GL_MAX_TEXTURE_UNITS, &myMaxTexUnitsFFP);
myMaxTexCombined = myMaxTexUnitsFFP;
}
#endif
if (IsGlGreaterEqual (2, 0))
{
glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &myMaxTexCombined);
}
#if !defined(GL_ES_VERSION_2_0)
else if (IsGlGreaterEqual (1, 3))
{
// this is a maximum of texture units for FFP functionality,
// dramatically smaller than combined texture units available for GLSL
glGetIntegerv (GL_MAX_TEXTURE_UNITS, &myMaxTexCombined);
}
#endif
mySpriteTexUnit = myMaxTexCombined >= 2
? Graphic3d_TextureUnit_1
: Graphic3d_TextureUnit_0;
@@ -3233,13 +3235,13 @@ Handle(OpenGl_TextureSet) OpenGl_Context::BindTextures (const Handle(OpenGl_Text
{
if (const Handle(OpenGl_Texture)& aTextureOld = aTextureIterOld.Value())
{
aTextureOld->Unbind(aThisCtx);
#if !defined(GL_ES_VERSION_2_0)
if (core11 != NULL)
{
OpenGl_Sampler::resetGlobalTextureParams (aThisCtx, *aTextureOld, aTextureOld->Sampler()->Parameters());
}
#endif
aTextureOld->Unbind (aThisCtx);
}
}
break;
@@ -3260,13 +3262,13 @@ Handle(OpenGl_TextureSet) OpenGl_Context::BindTextures (const Handle(OpenGl_Text
{
if (!aTextureOld.IsNull())
{
aTextureOld->Unbind(aThisCtx);
#if !defined(GL_ES_VERSION_2_0)
if (core11 != NULL)
{
OpenGl_Sampler::resetGlobalTextureParams (aThisCtx, *aTextureOld, aTextureOld->Sampler()->Parameters());
}
#endif
aTextureOld->Unbind (aThisCtx);
}
aTextureIterNew.Next();

View File

@@ -497,6 +497,11 @@ public:
//! @return value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
Standard_Integer MaxCombinedTextureUnits() const { return myMaxTexCombined; }
//! This method returns the multi-texture limit for obsolete fixed-function pipeline.
//! Use MaxCombinedTextureUnits() instead for limits for using programmable pipeline.
//! @return value for GL_MAX_TEXTURE_UNITS
Standard_Integer MaxTextureUnitsFFP() const { return myMaxTexUnitsFFP; }
//! @return texture unit to be used for sprites
Graphic3d_TextureUnit SpriteTextureUnit() const { return mySpriteTexUnit; }
@@ -965,6 +970,7 @@ private: // context info
Standard_Integer myTexClamp; //!< either GL_CLAMP_TO_EDGE (1.2+) or GL_CLAMP (1.1)
Standard_Integer myMaxTexDim; //!< value for GL_MAX_TEXTURE_SIZE
Standard_Integer myMaxTexCombined; //!< value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
Standard_Integer myMaxTexUnitsFFP; //!< value for GL_MAX_TEXTURE_UNITS (fixed-function pipeline only)
Standard_Integer myMaxDumpSizeX; //!< maximum FBO width for image dump
Standard_Integer myMaxDumpSizeY; //!< maximum FBO height for image dump
Standard_Integer myMaxClipPlanes; //!< value for GL_MAX_CLIP_PLANES

View File

@@ -276,7 +276,8 @@ void OpenGl_Sampler::applyGlobalTextureParams (const Handle(OpenGl_Context)& the
(void )theTexture;
(void )theParams;
#else
if (theCtx->core11 == NULL)
if (theCtx->core11 == NULL
|| theParams->TextureUnit() >= theCtx->MaxTextureUnitsFFP())
{
return;
}

View File

@@ -55,6 +55,7 @@
#include <OSD_Exception_ACCESS_VIOLATION.hxx>
#include <OSD_Exception_STACK_OVERFLOW.hxx>
#include <OSD.hxx>
#include <OSD_ThreadPool.hxx>
#include <STEPCAFControl_Writer.hxx>
#include <STEPControl_StepModelType.hxx>
#include <Interface_Static.hxx>
@@ -2458,6 +2459,68 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
return 0;
}
//! Auxiliary functor.
struct TestParallelFunctor
{
TestParallelFunctor() : myNbNotRaised (0), myNbSigSegv (0), myNbUnknown (0) {}
Standard_Integer NbNotRaised() const { return myNbNotRaised; }
Standard_Integer NbSigSegv() const { return myNbSigSegv; }
Standard_Integer NbUnknown() const { return myNbUnknown; }
void operator() (int theThreadId, int theTaskId) const
{
(void )theThreadId;
(void )theTaskId;
// Test Access Violation
{
try {
OCC_CATCH_SIGNALS
int* pint = NULL;
*pint = 4;
Standard_Atomic_Increment (&myNbNotRaised);
}
#ifdef _WIN32
catch (OSD_Exception_ACCESS_VIOLATION const&)
#else
catch (OSD_SIGSEGV const&)
#endif
{
Standard_Atomic_Increment (&myNbSigSegv);
}
catch (Standard_Failure const& )
{
Standard_Atomic_Increment (&myNbUnknown);
}
}
}
private:
mutable volatile Standard_Integer myNbNotRaised;
mutable volatile Standard_Integer myNbSigSegv;
mutable volatile Standard_Integer myNbUnknown;
};
static Standard_Integer OCC30775 (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** )
{
if (theNbArgs != 1)
{
std::cout << "Syntax error: wrong number of arguments\n";
return 1;
}
Handle(OSD_ThreadPool) aPool = new OSD_ThreadPool (4);
OSD_ThreadPool::Launcher aLauncher (*aPool, 4);
TestParallelFunctor aFunctor;
aLauncher.Perform (0, 100, aFunctor);
theDI << "NbRaised: " << (aFunctor.NbSigSegv() + aFunctor.NbUnknown()) << "\n"
<< "NbNotRaised: " << aFunctor.NbNotRaised() << "\n"
<< "NbSigSeg: " << aFunctor.NbSigSegv() << "\n"
<< "NbUnknown: " << aFunctor.NbUnknown() << "\n";
return 0;
}
#if defined(_MSC_VER)
#pragma optimize( "", on )
#endif
@@ -4816,7 +4879,8 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
theCommands.Add("OCC5739", "OCC5739 name shape step", __FILE__, OCC5739_UniAbs, group);
theCommands.Add("OCC6046", "OCC6046 nb_of_vectors size", __FILE__, OCC6046, group);
theCommands.Add("OCC5698", "OCC5698 wire", __FILE__, OCC5698, group);
theCommands.Add("OCC6143", "OCC6143", __FILE__, OCC6143, group);
theCommands.Add("OCC6143", "OCC6143 catching signals", __FILE__, OCC6143, group);
theCommands.Add("OCC30775", "OCC30775 catching signals in threads", __FILE__, OCC30775, group);
theCommands.Add("OCC7141", "OCC7141 [nCount] aPath", __FILE__, OCC7141, group);
theCommands.Add("OCC7372", "OCC7372", __FILE__, OCC7372, group);
theCommands.Add("OCC8169", "OCC8169 edge1 edge2 plane", __FILE__, OCC8169, group);

View File

@@ -236,10 +236,14 @@ Standard_Boolean RWStl_Reader::IsAscii (Standard_IStream& theStream)
#define GETPOS(aPos) ((int64_t)aPos)
#endif
# if defined(_MSC_VER) && ! defined(strncasecmp)
# define strncasecmp _strnicmp
# endif
static inline bool str_starts_with (const char* theStr, const char* theWord, int theN)
{
while (isspace (*theStr) && *theStr != '\0') theStr++;
return !strncmp (theStr, theWord, theN);
return !strncasecmp (theStr, theWord, theN);
}
static bool ReadVertex (const char* theStr, double& theX, double& theY, double& theZ)

View File

@@ -30,7 +30,7 @@
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dInt_GInter.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Geom_ElementarySurface.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Lin2d.hxx>
@@ -118,26 +118,32 @@ void ShapeFix_ComposeShell::Init (const Handle(ShapeExtend_CompositeSurface) &Gr
// DTK-CKY 100531 : protection against very thin face
// Test "isclosed" should be filtered on the overall (non trimmed) surface, must be closed
Handle(Geom_Surface) theSurface = BRep_Tool::Surface(Face,myLoc);
Standard_Real U0,U1,V0,V1,GU0 = 0.,GU1 = 0.,GV0 = 0.,GV1 = 0.;
theSurface->Bounds(U0,U1,V0,V1);
if (::Precision::IsInfinite (U0) || ::Precision::IsInfinite (U1) ||
::Precision::IsInfinite (V0) || ::Precision::IsInfinite (V1))
BRepTools::UVBounds(Face, GU0, GU1, GV0, GV1);
if (myUClosed) {
if (::Precision::IsInfinite (V0)) V0 = GV0;
if (::Precision::IsInfinite (V1)) V1 = GV1;
gp_Pnt P0 = theSurface->Value(U0,(V0+V1)/2.);
gp_Pnt P1 = theSurface->Value(U1,(V0+V1)/2.);
if (P0.Distance(P1) > Precision::Confusion()*10)
myUClosed = Standard_False;
}
if (myVClosed) {
if (::Precision::IsInfinite (U0)) U0 = GU0;
if (::Precision::IsInfinite (U1)) U1 = GU1;
gp_Pnt P0 = theSurface->Value((U0+U1)/2.,V0);
gp_Pnt P1 = theSurface->Value((U0+U1)/2.,V1);
if (P0.Distance(P1) > Precision::Confusion()*10)
myVClosed = Standard_False;
// avoid false detection of 'Closed' on very thin faces
if (theSurface->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) {
myUClosed = myUClosed && theSurface->IsUClosed();
myVClosed = myVClosed && theSurface->IsVClosed();
} else {
Standard_Real U0,U1,V0,V1,GU0 = 0.,GU1 = 0.,GV0 = 0.,GV1 = 0.;
theSurface->Bounds(U0,U1,V0,V1);
if (::Precision::IsInfinite (U0) || ::Precision::IsInfinite (U1) ||
::Precision::IsInfinite (V0) || ::Precision::IsInfinite (V1))
BRepTools::UVBounds(Face, GU0, GU1, GV0, GV1);
if (myUClosed) {
if (::Precision::IsInfinite (V0)) V0 = GV0;
if (::Precision::IsInfinite (V1)) V1 = GV1;
gp_Pnt P0 = theSurface->Value(U0,(V0+V1)/2.);
gp_Pnt P1 = theSurface->Value(U1,(V0+V1)/2.);
if (P0.Distance(P1) > Precision::Confusion()*10)
myUClosed = Standard_False;
}
if (myVClosed) {
if (::Precision::IsInfinite (U0)) U0 = GU0;
if (::Precision::IsInfinite (U1)) U1 = GU1;
gp_Pnt P0 = theSurface->Value((U0+U1)/2.,V0);
gp_Pnt P1 = theSurface->Value((U0+U1)/2.,V1);
if (P0.Distance(P1) > Precision::Confusion()*10)
myVClosed = Standard_False;
}
}
// DTK-CKY 100531 end

View File

@@ -70,16 +70,8 @@ Standard_Integer StepSelect_WorkLibrary::ReadFile
long status = 1;
DeclareAndCast(StepData_Protocol,stepro,protocol);
if (stepro.IsNull()) return 1;
Handle(StepData_StepModel) stepmodel;
if(!model.IsNull())
stepmodel = Handle(StepData_StepModel)::DownCast(model);
if(stepmodel.IsNull())
{
stepmodel = new StepData_StepModel;
model = stepmodel;
}
Handle(StepData_StepModel) stepmodel = new StepData_StepModel;
model = stepmodel;
StepFile_ReadTrace (0);
char *pName=(char *)name;
status = StepFile_Read (pName,stepmodel,stepro);

View File

@@ -119,5 +119,6 @@ XCAFDoc_AssemblyItemId::ToString() const
aStr += '/';
aStr += anIt.Value();
}
aStr.Remove(1, 1);
return aStr;
}

View File

@@ -345,7 +345,7 @@ Handle(XCAFDimTolObjects_GeomToleranceObject) XCAFDoc_GeomTolerance::GetObject()
Handle(TDataStd_RealArray) aPnt;
if (Label().FindChild(ChildLab_Pnt).FindAttribute(TDataStd_RealArray::GetID(), aPnt) && aPnt->Length() == 3)
{
gp_Pnt aP(aLoc->Value(aPnt->Lower()), aPnt->Value(aPnt->Lower() + 1), aPnt->Value(aPnt->Lower() + 2));
gp_Pnt aP(aPnt->Value(aPnt->Lower()), aPnt->Value(aPnt->Lower() + 1), aPnt->Value(aPnt->Lower() + 2));
anObj->SetPoint(aP);
}

View File

@@ -243,8 +243,8 @@ static Standard_Boolean MinimizeDirection(math_Vector& P,
// Make direction to go along the border
for (Standard_Integer anIdx = 1; anIdx <= theLeft.Upper(); anIdx++)
{
if (Abs(P(anIdx) - theRight(anIdx)) < Precision::PConfusion() ||
Abs(P(anIdx) - theLeft(anIdx)) < Precision::PConfusion())
if ((Abs(P(anIdx) - theRight(anIdx)) < Precision::PConfusion() && Dir(anIdx) > 0.0) ||
(Abs(P(anIdx) - theLeft(anIdx)) < Precision::PConfusion() && Dir(anIdx) < 0.0))
{
Dir(anIdx) = 0.0;
}

View File

@@ -69,7 +69,8 @@ math_GlobOptMin::math_GlobOptMin(math_MultipleVarFunction* theFunc,
myMaxV(1, myN),
myCellSize(0, myN - 1),
myFilter(theFunc->NbVariables()),
myCont(2)
myCont(2),
myF(Precision::Infinite())
{
Standard_Integer i;
@@ -382,17 +383,6 @@ void math_GlobOptMin::computeInitialValues()
myC = Max(aLipConst * aMinEps, aMinLC);
else if (aLipConst > myC * aMaxEps)
myC = Min(myC * aMaxEps, aMaxLC);
// Clear all solutions except one.
if (myY.Size() != myN)
{
for(i = 1; i <= myN; i++)
aBestPnt(i) = myY(i);
myY.Clear();
for(i = 1; i <= myN; i++)
myY.Append(aBestPnt(i));
}
mySolCount = 1;
}
//=======================================================================
@@ -453,37 +443,8 @@ void math_GlobOptMin::computeGlobalExtremum(Standard_Integer j)
aStepBestValue = (isInside && (val < d))? val : d;
aStepBestPoint = (isInside && (val < d))? myTmp : myX;
// Solutions are close to each other
// and it is allowed to have more than one solution.
if (Abs(aStepBestValue - myF) < mySameTol * 0.01 &&
!myIsFindSingleSolution)
{
if (!isStored(aStepBestPoint))
{
if ((aStepBestValue - myF) * myZ > 0.0)
myF = aStepBestValue;
for(i = 1; i <= myN; i++)
myY.Append(aStepBestPoint(i));
mySolCount++;
}
}
// New best solution:
// new point is out of (mySameTol * 0.01) surrounding or
// new point is better than old + single point search.
Standard_Real aFunctionalDelta = (aStepBestValue - myF) * myZ;
if (aFunctionalDelta > mySameTol * 0.01 ||
(aFunctionalDelta > 0.0 && myIsFindSingleSolution))
{
mySolCount = 0;
myF = aStepBestValue;
myY.Clear();
for(i = 1; i <= myN; i++)
myY.Append(aStepBestPoint(i));
mySolCount++;
isFirstCellFilterInvoke = Standard_True;
}
// Check point and value on the current step to be optimal.
checkAddCandidate(aStepBestPoint, aStepBestValue);
if (CheckFunctionalStopCriteria())
return; // Best possible value is obtained.
@@ -639,34 +600,59 @@ Standard_Boolean math_GlobOptMin::CheckFunctionalStopCriteria()
//=======================================================================
void math_GlobOptMin::ComputeInitSol()
{
Standard_Real aCurrVal, aBestVal;
math_Vector aCurrPnt(1, myN);
math_Vector aBestPnt(1, myN);
math_Vector aParamStep(1, myN);
// Check functional value in midpoint, lower and upper border points and
// in each point try to perform local optimization.
aBestPnt = (myGlobA + myGlobB) * 0.5;
myFunc->Value(aBestPnt, aBestVal);
Standard_Real aVal;
math_Vector aPnt(1, myN);
Standard_Integer i;
for(i = 1; i <= 3; i++)
// Check functional value in midpoint. It is necessary since local optimization
// algorithm may fail and return nothing. This is a protection from uninitialized
// variables.
aPnt = (myGlobA + myGlobB) * 0.5;
myFunc->Value(aPnt, aVal);
checkAddCandidate(aPnt, aVal);
// Run local optimization from lower corner, midpoint, and upper corner.
for(Standard_Integer i = 1; i <= 3; i++)
{
aCurrPnt = myA + (myB - myA) * (i - 1) / 2.0;
aPnt = myA + (myB - myA) * (i - 1) / 2.0;
if(computeLocalExtremum(aCurrPnt, aCurrVal, aCurrPnt))
if(computeLocalExtremum(aPnt, aVal, aPnt))
checkAddCandidate(aPnt, aVal);
}
}
//=======================================================================
//function : checkAddCandidate
//purpose :
//=======================================================================
void math_GlobOptMin::checkAddCandidate(const math_Vector& thePnt,
const Standard_Real theValue)
{
if (Abs(theValue - myF) < mySameTol * 0.01 && // Value in point is close to optimal value.
!myIsFindSingleSolution) // Several optimal solutions are allowed.
{
if (!isStored(thePnt))
{
// Local search tries to find better solution than current point.
if (aCurrVal < aBestVal)
{
aBestVal = aCurrVal;
aBestPnt = aCurrPnt;
}
if ((theValue - myF) * myZ > 0.0)
myF = theValue;
for (Standard_Integer j = 1; j <= myN; j++)
myY.Append(thePnt(j));
mySolCount++;
}
}
myF = aBestVal;
myY.Clear();
for(i = 1; i <= myN; i++)
myY.Append(aBestPnt(i));
mySolCount = 1;
// New best solution:
// new point is out of (mySameTol * 0.01) surrounding or
// new point is better than old and single point search.
Standard_Real aDelta = (theValue - myF) * myZ;
if (aDelta > mySameTol * 0.01 ||
(aDelta > 0.0 && myIsFindSingleSolution))
{
myF = theValue;
myY.Clear();
for (Standard_Integer j = 1; j <= myN; j++)
myY.Append(thePnt(j));
mySolCount = 1;
isFirstCellFilterInvoke = Standard_True;
}
}

View File

@@ -232,6 +232,13 @@ private:
//! Check presence of thePnt in GlobOpt sequence.
Standard_Boolean isStored(const math_Vector &thePnt);
//! Check and add candidate point into solutions.
//! @param thePnt Candidate point.
//! @param theValue Function value in the candidate point.
void checkAddCandidate(const math_Vector& thePnt,
const Standard_Real theValue);
// Input.
math_MultipleVarFunction* myFunc;
Standard_Integer myN;

View File

@@ -195,8 +195,8 @@ void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F,
// Nullify corresponding TheStep indexes.
for(Standard_Integer anIdx = 1; anIdx <= myLeft.Upper(); anIdx++)
{
if (Abs(precedent->Value(anIdx) - myRight(anIdx)) < Precision::PConfusion() ||
Abs(precedent->Value(anIdx) - myLeft(anIdx) ) < Precision::PConfusion())
if ((Abs(precedent->Value(anIdx) - myRight(anIdx)) < Precision::PConfusion() && TheStep(anIdx) < 0.0) ||
(Abs(precedent->Value(anIdx) - myLeft(anIdx) ) < Precision::PConfusion() && TheStep(anIdx) > 0.0) )
{
TheStep(anIdx) = 0.0;
}

View File

@@ -0,0 +1,24 @@
puts "================"
puts "0030775: OSD::SetSignal() within OSD_ThreadPool should not override global handlers"
puts "================"
puts ""
pload QAcommands
dsetsignal set
set IsDone [catch {set aResult [OCC30775]} result]
if { ${IsDone} != 0 } {
puts "result = ${result}"
puts "Error: command raised exception"
} else {
if { [string first "NbRaised: 100" $aResult] != -1 } {
puts "OK test case"
} else {
puts "Error: expected to have 100 raised expections"
}
}
# restore defaults
dsetsignal

12
tests/bugs/heal/bug30831 Normal file
View File

@@ -0,0 +1,12 @@
puts "========================"
puts "0030831: Shape Healing - ShapeFix algorithm (creation of seam edge) takes too long time with thin faces"
puts "========================"
cpulimit 10
binrestore [locate_data_file bug30831.bin] a
fixshape r a 1.e-7 1.
checkshape r a
tolerance r
checkview -display r -2d -path ${imagedir}/${test_image}.png

View File

@@ -0,0 +1,25 @@
puts "======================================================================================="
puts "OCC23380: BRepOffsetAPI_MakeFilling fails and leaves boundary faces with high tolerance"
puts "======================================================================================="
puts ""
brestore [locate_data_file bug23380.brep] b
explode b
renamevar b_5 d
renamevar b_1 f
renamevar b_4 i
explode f E
explode d E
tolerance f
donly f_1 d_3 b_2 b_3
filling result 4 0 0 i f_1 f 1 d_3 d 1 b_2 0 b_3 0
checknbshapes result -face 1 -wire 1 -edge 4 -vertex 4
set tolres [checkmaxtol result]
if { ${tolres} > 230.} {
puts "Error: bad tolerance of result"
}

View File

@@ -0,0 +1,8 @@
readstl a [locate_data_file bug30113.stl]
# Number of triangles check
checktrinfo a -tri 14248 -nod 7114
# Visual check
checkview -display a -3d -vdispmode 0 -path ${imagedir}/${test_image}_edges.png
checkview -display a -3d -vdispmode 1 -path ${imagedir}/${test_image}_shading.png

14
tests/bugs/vis/bug30946 Normal file
View File

@@ -0,0 +1,14 @@
puts "============="
puts "0030946: Visualization - Image_AlienPixMap ignores 1-bit pixelformat when using FreeImage"
puts "============="
pload VISUALIZATION
vinit View
vbackground -image [locate_data_file bug30946_img_1bit_256px.png]
if { [vreadpixel 120 315 rgb name] != "WHITE" } { puts "Error: background image was loaded incorrectly" }
vpoint p0 0 0 0
vaspects p0 -setMarkerType [locate_data_file bug30946_img_1bit_32px.png]
vdump $imagedir/${casename}.png

View File

@@ -4,7 +4,7 @@ set comment [XNoteCreateComment D "Hello, World!" --user "The user" --time [cloc
XNoteDump D ${comment}
# annotate box_1
XNoteRefDump D [XNoteAdd D ${comment} ${box_1}]
set assemblyItemId [XNoteRefDump D [XNoteAdd D ${comment} ${box_1}]]
# annotate box_2
XNoteRefDump D [XNoteAdd D ${comment} ${box_2}]
@@ -16,3 +16,10 @@ XNoteAnnotations D
set nb_annotations_result 2
set nb_notes_result 1
set nb_orphan_result 0
# check the assembly item id
if {[regexp "Item : ${box_1}" ${assemblyItemId}]} {
puts "OK : assembly item id"
} else {
puts "Error : wrong assembly item id"
}

View File

@@ -0,0 +1,21 @@
puts "========"
puts "OCC29858"
puts "========"
puts ""
#################################################
# Regression in GeomAPI_ExtremaCurveCurve
#################################################
# Read input
restore [locate_data_file bug29858_01_e1.brep] e1
restore [locate_data_file bug29858_01_e2.brep] e2
# Extract geometry from topology
mkcurve c1 e1
mkcurve c2 e2
# Run extrema
extrema c1 c2
# Check result
checklength ext_1 -l 9.4224516867962155e-10 -eps 0.01

View File

@@ -0,0 +1,28 @@
puts "========"
puts "OCC29858"
puts "========"
puts ""
#################################################
# Regression in GeomAPI_ExtremaCurveCurve
#################################################
# Read input
restore [locate_data_file bug29858_02_e1.brep] e1
restore [locate_data_file bug29858_02_e2.brep] e2
# Extract geometry from topology
mkcurve c1 e1
mkcurve c2 e2
# Run extrema
set info [extrema c1 c2]
# Check result
regexp {Extrema 1 is point : +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $info full x y z
# Point check
set good_x 0.001
set good_y 0.0073371170841145797
set good_z -0.083369169789921913
checkreal "Intersection point x:" ${x} ${good_x} 0.01 0.01
checkreal "Intersection point y:" ${y} ${good_y} 0.01 0.01
checkreal "Intersection point z:" ${z} ${good_z} 0.01 0.01

View File

@@ -0,0 +1,28 @@
puts "========"
puts "OCC29858"
puts "========"
puts ""
#################################################
# Regression in GeomAPI_ExtremaCurveCurve
#################################################
# Read input
restore [locate_data_file bug29858_03_e1.brep] e1
restore [locate_data_file bug29858_03_e2.brep] e2
# Extract geometry from topology
mkcurve c1 e1
mkcurve c2 e2
# Run extrema
set info [extrema c1 c2]
# Check result
regexp {Extrema 1 is point : +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $info full x y z
# Point check
set good_x 0.0
set good_y 0.070710562195021642
set good_z -0.65305318986891325
checkreal "Intersection point x:" ${x} ${good_x} 0.01 0.01
checkreal "Intersection point y:" ${y} ${good_y} 0.01 0.01
checkreal "Intersection point z:" ${z} ${good_z} 0.01 0.01

View File

@@ -0,0 +1,27 @@
puts "========"
puts "OCC29858"
puts "========"
puts ""
#################################################
# Regression in GeomAPI_ExtremaCurveCurve
#################################################
# Read input
restore [locate_data_file bug29858_04_e1.brep] e1
restore [locate_data_file bug29858_04_e2.brep] e2
# Extract geometry from topology
mkcurve c1 e1
mkcurve c2 e2
# Run extrema
set info [extrema c1 c2]
# Amount Check
if { [llength $info] != 2 } {
puts "Error: Invalid extrema number in extrema output"
}
# Check result
checklength ext_1 -l 2.2204460492503131e-16 -eps 0.01
checklength ext_2 -l 9.693032344962995e-16 -eps 0.01