我已测试了两宗个案:
我使用STEPCAFControl_Reader然后STEPControl_Reader来读取我的step文件,但是当我调用STEPCAFControl_Reader::Transfer时,这两种方法都会崩溃,重新命名为STEPControl_Reader::TransferRoots。
通过使用STEPControl_Reader,我在控制台上显示了一个日志,然后有如下消息:
1 F:(BOUNDED_SURFACE、B_SPLINE_SURFACE、B_SPLINE_SURFACE_WITH_KNOTS、GEOMETRIC_REPRESENTATION_ITEM、RATIONAL_B_SPLINE_SURFACE、REPRESENTATION_ITEM、SURFACE):representation_item的参数计数不是1
编辑:
TransferRoots()方法中有一个空引用。
const Handle(Transfer_TransientProcess) &proc = thesession->TransferReader()->TransientProcess();
if (proc->GetProgress().IsNull())
{
//This condition does not exist from the source code
std::cout << "GetProgress is null" << std::endl;
return 0;
}
Message_ProgressSentry PS ( proc->GetProgress(), "Root", 0, nb, 1 );
我的应用程序和FreeCAD崩溃,但如果我使用哪个OCC官方查看器,它加载。
发布于 2020-02-13 19:07:16
看起来评论已经给出了问题的答案,或者更准确地说是答案。
在基于OSD::SetSignal()的应用程序(如CAD )中使用OCCT来提高其对应用程序/OCCT代码中非致命错误的鲁棒性是一种常见的做法。它更方便用户报告内部错误消息,而不是默默地崩溃。
但是需要注意的是,OSD::SetSignal()不能保证应用程序不会崩溃,也不能保证应用程序在捕捉到这样的故障后能够正常工作--由于某些信号的异步性质,内存在C++异常被引发时可能已经损坏,从而导致各种不想要的行为。由于这个原因,最好不要忽略这种异常,即使它看起来像应用程序可以很好地处理它们。
OSD::SetSignal(false); // should be called ones at application startup
STEPCAFControl_Reader aReader;
try
{
OCC_CATCH_SIGNALS // necessary for redirecting signals on Linux
if (aReader.ReadFile (theFilePath) != IFSelect_RetDone) { return false; }
if (!aReader.Transfer (myXdeDoc)) { return false; }
}
catch (Standard_Failure const& theFailure)
{
std::cerr << "STEP import failed: " << theFailure.GetMessageString() << "\n";
return false;
}
return true;
https://stackoverflow.com/questions/57078323
复制相似问题