Skip to content

Commit dbfbef2

Browse files
committed
Coding - Refactor resource management and shape processing to optimize extent checks
1 parent ea8951b commit dbfbef2

4 files changed

Lines changed: 24 additions & 14 deletions

File tree

src/FoundationClasses/TKernel/Resource/Resource_Manager.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ void Resource_Manager::SetResource(const char* aResource, const char16_t* aValue
499499
TCollection_ExtendedString ExtValue = aValue;
500500
TCollection_AsciiString FormatStr(ExtValue.Length() * 3 + 10, ' ');
501501

502-
*myExtStrMap.Bound(Resource, ExtValue) = ExtValue;
502+
myExtStrMap.Bound(Resource, ExtValue);
503503
//
504504
pStr = (Standard_PCharacter)FormatStr.ToCString();
505505
//
@@ -516,9 +516,9 @@ void Resource_Manager::SetResource(const char* aResource, const char16_t* aValue
516516
//=======================================================================
517517
void Resource_Manager::SetResource(const char* aResource, const char* aValue)
518518
{
519-
TCollection_AsciiString Resource = aResource;
520-
TCollection_AsciiString Value = aValue;
521-
*myUserMap.Bound(Resource, Value) = Value;
519+
TCollection_AsciiString Resource = aResource;
520+
TCollection_AsciiString Value = aValue;
521+
myUserMap.Bound(Resource, Value);
522522
}
523523

524524
//=======================================================================

src/ModelingAlgorithms/TKBO/BOPTools/BOPTools_AlgoTools.cxx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ void BOPTools_AlgoTools::OrientFacesOnShell(TopoDS_Shape& aShell)
380380
NCollection_List<TopoDS_Shape>::Iterator anIt(aLF);
381381
for (; anIt.More(); anIt.Next())
382382
{
383-
const TopoDS_Shape& aF = anIt.Value();
384-
if (aFM.Add(aF) == aFM.Extent())
383+
const TopoDS_Shape& aF = anIt.Value();
384+
const int aPrevExtent = aFM.Extent();
385+
if (aFM.Add(aF) > aPrevExtent)
385386
{
386387
aLFTmp.Append(aF);
387388
}
@@ -483,8 +484,9 @@ void BOPTools_AlgoTools::OrientFacesOnShell(TopoDS_Shape& aShell)
483484
NCollection_List<TopoDS_Shape>::Iterator anIt(aLF);
484485
for (; anIt.More(); anIt.Next())
485486
{
486-
const TopoDS_Face& aF = (*(TopoDS_Face*)(&anIt.Value()));
487-
if (aProcessedFaces.Add(aF) == aProcessedFaces.Extent())
487+
const TopoDS_Face& aF = (*(TopoDS_Face*)(&anIt.Value()));
488+
const int aPrevExtent = aProcessedFaces.Extent();
489+
if (aProcessedFaces.Add(aF) > aPrevExtent)
488490
{
489491
aBB.Add(aShellNew, aF);
490492
}

src/ModelingAlgorithms/TKBool/TopOpeBRepBuild/TopOpeBRepBuild_Builder1.cxx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,14 +1850,16 @@ int TopOpeBRepBuild_Builder1::TwoPiecesON(const NCollection_Sequence<TopoDS_Shap
18501850
//// ????
18511851
else if (aStateObj == TopAbs_IN && aStateTool == TopAbs_IN)
18521852
{
1853-
if (myProcessedPartsON2d.Add(aPieceObj) == myProcessedPartsON2d.Extent())
1853+
const int aPrevExtent = myProcessedPartsON2d.Extent();
1854+
if (myProcessedPartsON2d.Add(aPieceObj) > aPrevExtent)
18541855
{ // we proceed IsSame only if we didn't it before
18551856
IsSame2d(aSeq, aListOfPiecesOut2d); // Perform IsSame 2d and keep periodic parts
18561857
}
18571858
}
18581859
else if (aStateObj == TopAbs_OUT && aStateTool == TopAbs_OUT)
18591860
{
1860-
if (myProcessedPartsON2d.Add(aPieceObj) == myProcessedPartsON2d.Extent())
1861+
const int aPrevExtent = myProcessedPartsON2d.Extent();
1862+
if (myProcessedPartsON2d.Add(aPieceObj) > aPrevExtent)
18611863
{ // we proceed IsSame only if we didn't it before
18621864
IsSame2d(aSeq, aListOfPiecesOut2d); // Perform IsSame 2d and keep periodic parts
18631865
}
@@ -1925,7 +1927,8 @@ int TopOpeBRepBuild_Builder1::TwoPiecesON(const NCollection_Sequence<TopoDS_Shap
19251927
}
19261928
else if (aStateObj == TopAbs_IN && aStateTool == TopAbs_IN)
19271929
{
1928-
if (myProcessedPartsON2d.Add(aPieceObj) == myProcessedPartsON2d.Extent())
1930+
const int aPrevExtent = myProcessedPartsON2d.Extent();
1931+
if (myProcessedPartsON2d.Add(aPieceObj) > aPrevExtent)
19291932
{ // we proceed IsSame only if we didn't it before
19301933
IsSame2d(aSeq, aListOfPiecesOut2d); // Perform IsSame 2d and keep periodic parts
19311934
}

src/ModelingAlgorithms/TKFeat/LocOpe/LocOpe_BuildShape.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,13 @@ void LocOpe_BuildShape::Perform(const NCollection_List<TopoDS_Shape>& L)
6969

7070
for (itl.Initialize(L); itl.More(); itl.Next())
7171
{
72-
if (itl.Value().ShapeType() == TopAbs_FACE && mapF.Add(itl.Value()))
72+
if (itl.Value().ShapeType() == TopAbs_FACE)
7373
{
74-
B.Add(C, itl.Value());
74+
const int aPrevExtent = mapF.Extent();
75+
if (mapF.Add(itl.Value()) > aPrevExtent)
76+
{
77+
B.Add(C, itl.Value());
78+
}
7579
}
7680
}
7781

@@ -336,7 +340,8 @@ static void Add(const int i
336340
NCollection_List<TopoDS_Shape>::Iterator itl(mapEF(ind));
337341
for (; itl.More(); itl.Next())
338342
{
339-
if (mapF.Add(itl.Value()))
343+
const int aPrevExtent = mapF.Extent();
344+
if (mapF.Add(itl.Value()) > aPrevExtent)
340345
{
341346
TopExp_Explorer exp;
342347
for (exp.Init(itl.Value(), TopAbs_EDGE);

0 commit comments

Comments
 (0)