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

Compare commits

..

4 Commits

Author SHA1 Message Date
ichesnok
1b836c1140 0033487: Data Exchange, Step Import - Unresolved reference crashes
IsNull() check added for Handle(StepVisual_FillAreaStyleColour).
2024-04-17 08:30:58 +01:00
ika
b78ccf1f9b 0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
Add processing of tessellated_annotation_occurrence.
Add test cases.
2024-04-07 10:46:17 +01:00
oan
2956d432e2 0033560: PARASOLID Import - XT importer raises exception SIGFPE Arithmetic Exception
Prevent division by zero in exceptional cases when vector of parameters contains only a single value.
2024-03-28 13:58:36 +00:00
anv
d3e00bfaa6 0033616: Application Framework - Using filter while reading XBF may result in unresolved links
- Added tracking of unresolved links for TreeNodes;
- Test case added.
2024-03-28 13:55:46 +00:00
12 changed files with 199 additions and 39 deletions

View File

@@ -808,8 +808,11 @@ void Approx_BSplComputeLine::Parameters(const MultiLine& Line,
const Standard_Integer aNbp = lastP - firstP + 1;
// The first parameter should always be zero according to all the logic below,
// so division by any value will give zero anyway, so it should never be scaled
// to avoid case when there is only one parameter in the array thus division by zero happens.
TheParameters(firstP) = 0.0;
if (aNbp == 2) {
TheParameters(firstP) = 0.0;
TheParameters(lastP) = 1.0;
}
else if (Par == Approx_ChordLength || Par == Approx_Centripetal)
@@ -820,7 +823,6 @@ void Approx_BSplComputeLine::Parameters(const MultiLine& Line,
if (nbP3d == 0) mynbP3d = 1;
if (nbP2d == 0) mynbP2d = 1;
TheParameters(firstP) = 0.0;
dist = 0.0;
TColgp_Array1OfPnt tabP(1, mynbP3d);
TColgp_Array1OfPnt tabPP(1, mynbP3d);
@@ -861,10 +863,10 @@ void Approx_BSplComputeLine::Parameters(const MultiLine& Line,
TheParameters(i) = TheParameters(i - 1) + Sqrt(dist);
}
}
for (i = firstP; i <= lastP; i++) TheParameters(i) /= TheParameters(lastP);
for (i = firstP + 1; i <= lastP; i++) TheParameters(i) /= TheParameters(lastP);
}
else {
for (i = firstP; i <= lastP; i++) {
for (i = firstP + 1; i <= lastP; i++) {
TheParameters(i) = (Standard_Real(i) - firstP) /
(Standard_Real(lastP - Standard_Real(firstP)));
}

View File

@@ -515,8 +515,13 @@ BSplCLib::EvalBsplineBasis
//
// this should be always invertible if ii is correctly computed
//
Factor = (Parameter - FlatKnots(ii - qq + pp + 1))
/ (FlatKnots(ii + pp) - FlatKnots(ii - qq + pp + 1)) ;
const Standard_Real aScale = (FlatKnots(ii + pp) - FlatKnots(ii - qq + pp + 1));
if (Abs (aScale) < gp::Resolution())
{
return 2;
}
Factor = (Parameter - FlatKnots(ii - qq + pp + 1)) / aScale;
Saved = Factor * BsplineBasis(1,pp) ;
BsplineBasis(1,pp) *= (1.0e0 - Factor) ;
BsplineBasis(1,pp) += BsplineBasis(1,qq) ;
@@ -536,7 +541,13 @@ BSplCLib::EvalBsplineBasis
}
for (pp = 1 ; pp <= qq - 1 ; pp++) {
Inverse = 1.0e0 / (FlatKnots(ii + pp) - FlatKnots(ii - qq + pp + 1)) ;
const Standard_Real aScale = (FlatKnots(ii + pp) - FlatKnots(ii - qq + pp + 1));
if (Abs (aScale) < gp::Resolution())
{
return 2;
}
Inverse = 1.0e0 / aScale;
Factor = (Parameter - FlatKnots(ii - qq + pp + 1)) * Inverse ;
Saved = Factor * BsplineBasis(1,pp) ;
BsplineBasis(1,pp) *= (1.0e0 - Factor) ;

View File

@@ -33,6 +33,7 @@
#include <Storage_Schema.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_Data.hxx>
#include <TDF_Label.hxx>
@@ -324,7 +325,16 @@ void BinLDrivers_DocumentRetrievalDriver::Read (Standard_IStream&
// read sub-tree of the root label
if (!theFilter.IsNull())
theFilter->StartIteration();
Standard_Integer nbRead = ReadSubTree (theIStream, aData->Root(), theFilter, aQuickPart, aPS.Next());
const auto aStreamStartPosition = theIStream.tellg();
Standard_Integer nbRead = ReadSubTree (theIStream, aData->Root(), theFilter, aQuickPart, Standard_False, aPS.Next());
if (!myUnresolvedLinks.IsEmpty())
{
// In case we have skipped some linked TreeNodes before getting to
// their children.
theFilter->StartIteration();
theIStream.seekg(aStreamStartPosition, std::ios_base::beg);
nbRead += ReadSubTree(theIStream, aData->Root(), theFilter, aQuickPart, Standard_True, aPS.Next());
}
if (!aPS.More())
{
myReaderStatus = PCDM_RS_UserBreak;
@@ -373,6 +383,7 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
const TDF_Label& theLabel,
const Handle(PCDM_ReaderFilter)& theFilter,
const Standard_Boolean& theQuickPart,
const Standard_Boolean theReadMissing,
const Message_ProgressRange& theRange)
{
Standard_Integer nbRead = 0;
@@ -393,7 +404,7 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
aLabelSize = InverseUint64(aLabelSize);
#endif
// no one sub-label is needed, so, skip everything
if (aSkipAttrs && !theFilter->IsSubPassed())
if (aSkipAttrs && !theFilter->IsSubPassed() && myUnresolvedLinks.IsEmpty())
{
aLabelSize -= sizeof (uint64_t);
theIS.seekg (aLabelSize, std::ios_base::cur);
@@ -403,6 +414,11 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
}
}
if (theReadMissing)
{
aSkipAttrs = Standard_True;
}
const auto anAttStartPosition = theIS.tellg();
// Read attributes:
for (theIS >> myPAtt;
theIS && myPAtt.TypeId() > 0 && // not an end marker ?
@@ -415,6 +431,12 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
myReaderStatus = PCDM_RS_UserBreak;
return -1;
}
if (myUnresolvedLinks.Remove(myPAtt.Id()) && aSkipAttrs)
{
aSkipAttrs = Standard_False;
theIS.seekg(anAttStartPosition, std::ios_base::beg);
continue;
}
if (aSkipAttrs)
{
if (myPAtt.IsDirect()) // skip direct written stream
@@ -487,7 +509,17 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
aDriver->TypeName(), Message_Warning);
}
else if (!isBound)
{
myRelocTable.Bind(anID, tAtt);
Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(tAtt);
if (!theFilter.IsNull() && !aNode.IsNull() && !aNode->Father().IsNull() && aNode->Father()->IsNew())
{
Standard_Integer anUnresolvedLink;
myPAtt.SetPosition(BP_HEADSIZE);
myPAtt >> anUnresolvedLink;
myUnresolvedLinks.Add(anUnresolvedLink);
}
}
}
else if (!myMapUnsupported.Contains(myPAtt.TypeId()))
myMsgDriver->Send(aMethStr + "warning: type ID not registered in header: "
@@ -522,7 +554,7 @@ Standard_Integer BinLDrivers_DocumentRetrievalDriver::ReadSubTree
// read sub-tree
if (!theFilter.IsNull())
theFilter->Down (aTag);
Standard_Integer nbSubRead = ReadSubTree (theIS, aLab, theFilter, theQuickPart, aPS.Next());
Standard_Integer nbSubRead = ReadSubTree (theIS, aLab, theFilter, theQuickPart, theReadMissing, aPS.Next());
// check for error
if (nbSubRead == -1)
return -1;

View File

@@ -80,6 +80,7 @@ protected:
const TDF_Label& theData,
const Handle(PCDM_ReaderFilter)& theFilter,
const Standard_Boolean& theQuickPart,
const Standard_Boolean theReadMissing,
const Message_ProgressRange& theRanges = Message_ProgressRange());
@@ -125,6 +126,7 @@ private:
BinObjMgt_Persistent myPAtt;
TColStd_MapOfInteger myMapUnsupported;
BinLDrivers_VectorOfDocumentSection mySections;
NCollection_Map<Standard_Integer> myUnresolvedLinks;
};

View File

@@ -2134,11 +2134,12 @@ Standard_Boolean readPMIPresentation(const Handle(Standard_Transient)& thePresen
return Standard_False;
}
Handle(Transfer_TransientProcess) aTP = theTR->TransientProcess();
Handle(StepVisual_AnnotationOccurrence) anAO;
Handle(StepVisual_StyledItem) anAO;
NCollection_Vector<Handle(StepVisual_StyledItem)> anAnnotations;
if (thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)))
if (thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)) ||
thePresentEntity->IsKind(STANDARD_TYPE(StepVisual_TessellatedAnnotationOccurrence)))
{
anAO = Handle(StepVisual_AnnotationOccurrence)::DownCast(thePresentEntity);
anAO = Handle(StepVisual_StyledItem)::DownCast(thePresentEntity);
if (!anAO.IsNull())
{
thePresentName = anAO->Name();
@@ -4368,7 +4369,8 @@ Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSess
}
}
else if (anEnt->IsKind(STANDARD_TYPE(StepVisual_DraughtingCallout)) ||
anEnt->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)))
anEnt->IsKind(STANDARD_TYPE(StepVisual_AnnotationOccurrence)) ||
anEnt->IsKind(STANDARD_TYPE(StepVisual_TessellatedAnnotationOccurrence)))
{
// Protection against import presentation twice
Handle(StepVisual_DraughtingCallout) aDC;

View File

@@ -634,7 +634,7 @@ Standard_Boolean STEPConstruct_Styles::GetColors (const Handle(StepVisual_Styled
for ( Standard_Integer m=1; m <= FAS->NbFillStyles(); m++ ) {
StepVisual_FillStyleSelect FSS = FAS->FillStylesValue ( m );
Handle(StepVisual_FillAreaStyleColour) FASC = FSS.FillAreaStyleColour();
if ( SurfCol.IsNull() || SSU->Side() != StepVisual_ssNegative ) //abv 30 Mar 00: trj3_s1-pe.stp
if ( !FASC.IsNull() && (SurfCol.IsNull() || SSU->Side() != StepVisual_ssNegative) ) //abv 30 Mar 00: trj3_s1-pe.stp
SurfCol = FASC->FillColour();
}
continue;

View File

@@ -14,10 +14,8 @@
#include <Standard_Type.hxx>
#include <Standard_Assert.hxx>
#include <Standard_CStringHasher.hxx>
#include <Standard_Mutex.hxx>
#include <Standard_Assert.hxx>
#include <unordered_map>
@@ -25,23 +23,12 @@ IMPLEMENT_STANDARD_RTTIEXT(Standard_Type,Standard_Transient)
//============================================================================
namespace
{
static Standard_CString copy_string (const char* theString)
{
size_t aLength = strlen (theString);
char* aResult = static_cast<char*> (Standard::Allocate (aLength + 1));
strncpy (aResult, theString, aLength + 1); //including null-character
return aResult;
}
}
Standard_Type::Standard_Type (const std::type_info& theInfo,
const char* theName,
Standard_Size theSize,
const Handle(Standard_Type)& theParent) :
myInfo(theInfo),
myName(copy_string (theName)),
myName(theName),
mySize(theSize),
myParent(theParent)
{
@@ -75,7 +62,7 @@ void Standard_Type::Print (Standard_OStream& AStream) const
namespace {
// Map of string to type
typedef std::unordered_map<Standard_CString, Standard_Type*, Standard_CStringHasher, Standard_CStringHasher> registry_type;
typedef std::unordered_map<std::type_index, Standard_Type*> registry_type;
// Registry is made static in the function to ensure that it gets
// initialized by the time of first access
@@ -100,7 +87,7 @@ Standard_Type* Standard_Type::Register (const std::type_info& theInfo, const cha
// return existing descriptor if already in the registry
registry_type& aRegistry = GetRegistry();
Standard_Type* aType = 0;
auto anIter = aRegistry.find(theName);
auto anIter = aRegistry.find(theInfo);
if (anIter != aRegistry.end())
return anIter->second;
@@ -108,7 +95,7 @@ Standard_Type* Standard_Type::Register (const std::type_info& theInfo, const cha
aType = new Standard_Type (theInfo, theName, theSize, theParent);
// then add it to registry and return (the reference to the handle stored in the registry)
aRegistry.emplace(theName, aType);
aRegistry.emplace(theInfo, aType);
return aType;
}
@@ -116,6 +103,5 @@ Standard_Type::~Standard_Type ()
{
// remove descriptor from the registry
registry_type& aRegistry = GetRegistry();
Standard_ASSERT(aRegistry.erase(myName) > 0, "Standard_Type::~Standard_Type() cannot find itself in registry",);
Standard::Free (myName);
Standard_ASSERT(aRegistry.erase(myInfo) > 0, "Standard_Type::~Standard_Type() cannot find itself in registry",);
}

11
tests/bugs/xde/bug33616 Normal file
View File

@@ -0,0 +1,11 @@
puts "========"
puts "0033616: Data Exchange - Using filter while reading XBF may result in unresolved links"
puts "========"
pload ALL
XOpen [locate_data_file bug28905_as1-oc-214.xbf] D -read0:1:1:2:1
XGetShape sh D 0:1:1:2:1
checknbshapes sh -solid 1
Close D

View File

@@ -3,12 +3,12 @@ set filename bug29362_MMT200.stp
set ref_data {
NbOfDimensions : 2
NbOfDimensions : 4
NbOfDimensionalSize : 1
NbOfDimensionalLocation: 1
NbOfAngular : 0
NbOfWithPath : 0
NbOfCommonLabels : 0
NbOfCommonLabels : 1
NbOfTolerances : 0
NbOfGTWithModifiers : 0
NbOfGTWithMaxTolerance : 0

92
tests/gdt/import/A6 Normal file
View File

@@ -0,0 +1,92 @@
# !!!! This file is generated automatically, do not edit manually! See end script
set filename bug33661_nist_ftc_08_asme1_ap242-e1-tg.stp
set ref_data {
NbOfDimensions : 60
NbOfTolerances : 0
NbOfDatumFeature : 0
NbOfAttachedDatum : 0
NbOfDatumTarget : 0
0:1:1:2:1 Shape.4
0:1:4:32 Dimension.4.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:2 Shape.5
0:1:4:4 Dimension.5.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:5 Dimension.5.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:4 Shape.7
0:1:4:14 Dimension.7.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:18 Dimension.7.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:20 Dimension.7.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:14 Shape.17
0:1:4:27 Dimension.17.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:62 Shape.65
0:1:4:35 Dimension.65.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:65 Shape.68
0:1:4:36 Dimension.68.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:72 Shape.75
0:1:4:53 Dimension.75.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:84 Shape.87
0:1:4:54 Dimension.87.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:90 Shape.93
0:1:4:31 Dimension.93.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:33 Dimension.93.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:34 Dimension.93.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:94 Shape.97
0:1:4:39 Dimension.97.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:40 Dimension.97.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:51 Dimension.97.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:52 Dimension.97.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:55 Dimension.97.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:96 Shape.99
0:1:4:43 Dimension.99.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:44 Dimension.99.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:45 Dimension.99.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:46 Dimension.99.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:57 Dimension.99.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:98 Shape.101
0:1:4:47 Dimension.101.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:48 Dimension.101.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:49 Dimension.101.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:50 Dimension.101.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:56 Dimension.101.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:100 Shape.103
0:1:4:37 Dimension.103.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:38 Dimension.103.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:41 Dimension.103.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:42 Dimension.103.4 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:58 Dimension.103.5 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:102 Shape.105
0:1:4:25 Dimension.105.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:26 Dimension.105.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:116 Shape.119
0:1:4:24 Dimension.119.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:120 Shape.123
0:1:4:23 Dimension.123.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:161 Shape.164
0:1:4:15 Dimension.164.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:179 Shape.182
0:1:4:1 Dimension.182.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:2 Dimension.182.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:3 Dimension.182.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:237 Shape.240
0:1:4:17 Dimension.240.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:19 Dimension.240.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:246 Shape.249
0:1:4:6 Dimension.249.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:8 Dimension.249.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:9 Dimension.249.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:248 Shape.251
0:1:4:7 Dimension.251.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:10 Dimension.251.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:11 Dimension.251.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:250 Shape.253
0:1:4:12 Dimension.253.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:13 Dimension.253.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:2:256 Shape.259
0:1:4:28 Dimension.259.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:29 Dimension.259.2 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:4:30 Dimension.259.3 ( N "DGT:Dimension" T 31, V 0, P 0 )
0:1:1:3:1 Shape.276
0:1:4:16 Dimension.276.1 ( N "DGT:Dimension" T 31, V 0, P 0 )
}

View File

@@ -2,7 +2,13 @@
set filename bug29362_MMT200.stp
set ref_data {
Centre of mass: 0 0 0
Mass: 0
Centre of mass: 13.412719368151439 6.1818909424750705 -13.415402720911091
Mass: 252.25931515680639
}
set ref_data_write {
Centre of mass: 13.412719368151233 6.1818909424748316 -13.415402720907935
Mass: 252.25931515678892
}

16
tests/gdt/presentation/C3 Normal file
View File

@@ -0,0 +1,16 @@
# !!!! This file is generated automatically, do not edit manually! See end script
puts "TODO CR11111 ALL: Error on writing file"
set filename bug33661_nist_ftc_08_asme1_ap242-e1-tg.stp
set ref_data {
Centre of mass: -62.99891835601813 78.203476181663817 20.269103705327481
Mass: 47784.542040997127
}
set ref_data_write {
Centre of mass: -261.12759307366923 196.9986700086933 -13.86055926862322
Mass: 17568.06377585962
}