1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0022653: Bad performance of Open CASCADE libraries that are used by Partition Algorithm Devekoped by : PKV

This commit is contained in:
bugmaster 2011-08-17 08:30:24 +00:00 committed by bugmaster
parent 9dfd728754
commit cf8e963aff
6 changed files with 202 additions and 106 deletions

View File

@ -108,8 +108,9 @@
{ {
Standard_Address anAdr; Standard_Address anAdr;
IntTools_FClass2d* pFClass2d; IntTools_FClass2d* pFClass2d;
//
if (!myFClass2dMap.Contains(aF)) { anAdr=myFClass2dMap.FindFromKey1(aF);
if (!anAdr) {
Standard_Real aTolF; Standard_Real aTolF;
TopoDS_Face aFF=aF; TopoDS_Face aFF=aF;
aFF.Orientation(TopAbs_FORWARD); aFF.Orientation(TopAbs_FORWARD);
@ -122,8 +123,8 @@
} }
else { else {
anAdr=myFClass2dMap.FindFromKey(aF); Standard_Address *pAdr=(Standard_Address *)anAdr;
pFClass2d=(IntTools_FClass2d*)anAdr; pFClass2d=(IntTools_FClass2d*)*pAdr;
} }
return *pFClass2d; return *pFClass2d;
@ -136,8 +137,9 @@
{ {
Standard_Address anAdr; Standard_Address anAdr;
GeomAPI_ProjectPointOnSurf* pProjPS; GeomAPI_ProjectPointOnSurf* pProjPS;
//
if (!myProjPSMap.Contains(aF)) { anAdr=myProjPSMap.FindFromKey1(aF);
if (!anAdr) {
Standard_Real Umin, Usup, Vmin, Vsup, anEpsT=1.e-12 ; Standard_Real Umin, Usup, Vmin, Vsup, anEpsT=1.e-12 ;
BRepAdaptor_Surface aBAS; BRepAdaptor_Surface aBAS;
// //
@ -157,8 +159,8 @@
} }
else { else {
anAdr=myProjPSMap.FindFromKey(aF); Standard_Address *pAdr=(Standard_Address *)anAdr;
pProjPS=(GeomAPI_ProjectPointOnSurf*)anAdr; pProjPS=(GeomAPI_ProjectPointOnSurf*)*pAdr;
} }
return *pProjPS; return *pProjPS;
} }
@ -170,8 +172,9 @@
{ {
Standard_Address anAdr; Standard_Address anAdr;
GeomAPI_ProjectPointOnCurve* pProjPC; GeomAPI_ProjectPointOnCurve* pProjPC;
//
if (!myProjPCMap.Contains(aE)) { anAdr=myProjPCMap.FindFromKey1(aE);
if (!anAdr) {
Standard_Real f, l; Standard_Real f, l;
// //
Handle(Geom_Curve)aC3D=BRep_Tool::Curve (aE, f, l); Handle(Geom_Curve)aC3D=BRep_Tool::Curve (aE, f, l);
@ -182,10 +185,9 @@
anAdr=(Standard_Address)pProjPC; anAdr=(Standard_Address)pProjPC;
myProjPCMap.Add(aE, anAdr); myProjPCMap.Add(aE, anAdr);
} }
else { else {
anAdr=myProjPCMap.FindFromKey(aE); Standard_Address *pAdr=(Standard_Address *)anAdr;
pProjPC=(GeomAPI_ProjectPointOnCurve*)anAdr; pProjPC=(GeomAPI_ProjectPointOnCurve*)*pAdr;
} }
return *pProjPC; return *pProjPC;
} }
@ -198,8 +200,9 @@
{ {
Standard_Address anAdr; Standard_Address anAdr;
GeomAPI_ProjectPointOnCurve* pProjPT; GeomAPI_ProjectPointOnCurve* pProjPT;
//
if (!myProjPTMap.Contains(aC3D)) { anAdr=myProjPTMap.FindFromKey1(aC3D);
if (!anAdr) {
Standard_Real f, l; Standard_Real f, l;
f=aC3D->FirstParameter(); f=aC3D->FirstParameter();
l=aC3D->LastParameter(); l=aC3D->LastParameter();
@ -212,8 +215,8 @@
} }
else { else {
anAdr=myProjPTMap.FindFromKey(aC3D); Standard_Address *pAdr=(Standard_Address *)anAdr;
pProjPT=(GeomAPI_ProjectPointOnCurve*)anAdr; pProjPT=(GeomAPI_ProjectPointOnCurve*)*pAdr;
} }
return *pProjPT; return *pProjPT;
} }
@ -225,8 +228,9 @@
{ {
Standard_Address anAdr; Standard_Address anAdr;
IntTools_SurfaceRangeLocalizeData* pSData; IntTools_SurfaceRangeLocalizeData* pSData;
//
if (!myProjSDataMap.Contains(aF)) { anAdr=myProjSDataMap.FindFromKey1(aF);
if (!anAdr) {
// //
pSData=new IntTools_SurfaceRangeLocalizeData(3, pSData=new IntTools_SurfaceRangeLocalizeData(3,
3, 3,
@ -238,8 +242,8 @@
} }
else { else {
anAdr=myProjSDataMap.FindFromKey(aF); Standard_Address *pAdr=(Standard_Address *)anAdr;
pSData=(IntTools_SurfaceRangeLocalizeData*)anAdr; pSData=(IntTools_SurfaceRangeLocalizeData*)*pAdr;
} }
return *pSData; return *pSData;
@ -252,24 +256,21 @@
{ {
Standard_Address anAdr; Standard_Address anAdr;
BRepClass3d_SolidClassifier* pSC; BRepClass3d_SolidClassifier* pSC;
//
if (!mySClassMap.Contains(aSolid)) { anAdr=mySClassMap.FindFromKey1(aSolid);
if (!anAdr) {
// //
pSC=new BRepClass3d_SolidClassifier(aSolid); pSC=new BRepClass3d_SolidClassifier(aSolid);
// //
anAdr=(Standard_Address)pSC; anAdr=(Standard_Address)pSC;
mySClassMap.Add(aSolid, anAdr); mySClassMap.Add(aSolid, anAdr);
} }
else { else {
anAdr=mySClassMap.FindFromKey(aSolid); Standard_Address *pAdr=(Standard_Address *)anAdr;
pSC =(BRepClass3d_SolidClassifier*)anAdr; pSC =(BRepClass3d_SolidClassifier*)*pAdr;
} }
return *pSC; return *pSC;
} }
//modified by NIZNHY-PKV Tue Feb 2 08:33:16 2010f
//======================================================================= //=======================================================================
//function : ComputeVE //function : ComputeVE
//purpose : //purpose :
@ -302,9 +303,12 @@
if (BRep_Tool::Degenerated(aE2)) { if (BRep_Tool::Degenerated(aE2)) {
return -1; return -1;
} }
if (!BRep_Tool::IsGeometric(aE2)) { //
return -2; //modified by NIZNHY-PKV Wed Jul 13 08:30:08 2011f
} //if (!BRep_Tool::IsGeometric(aE2)) {
// return -2;
//}
//modified by NIZNHY-PKV Wed Jul 13 08:30:13 2011t
// //
Standard_Real aTolV1, aTolE2, aTolSum, aTolVx; Standard_Real aTolV1, aTolE2, aTolSum, aTolVx;
Standard_Integer aNbProj; Standard_Integer aNbProj;
@ -337,7 +341,6 @@
// //
return 0; return 0;
} }
//modified by NIZNHY-PKV Tue Feb 2 08:33:21 2010t
//======================================================================= //=======================================================================
//function : ComputeVS //function : ComputeVS
//purpose : //purpose :

View File

@ -83,25 +83,34 @@ static
//======================================================================= //=======================================================================
Standard_Boolean IntTools_Tools::IsClosed (const Handle(Geom_Curve)& aC3D) Standard_Boolean IntTools_Tools::IsClosed (const Handle(Geom_Curve)& aC3D)
{ {
Standard_Boolean bRet;
Standard_Real aF, aL, aDist; Standard_Real aF, aL, aDist, aPC;
gp_Pnt aP1, aP2; gp_Pnt aP1, aP2;
Handle (Geom_BoundedCurve) aGBC= Handle (Geom_BoundedCurve) aGBC=
Handle (Geom_BoundedCurve)::DownCast(aC3D); Handle (Geom_BoundedCurve)::DownCast(aC3D);
if (aGBC.IsNull()) { if (aGBC.IsNull()) {
return Standard_False; return Standard_False;
} }
aF=aC3D->FirstParameter(); aF=aC3D->FirstParameter();
aL=aC3D-> LastParameter(); aL=aC3D-> LastParameter();
aC3D->D0(aF, aP1); aC3D->D0(aF, aP1);
aC3D->D0(aL, aP2); aC3D->D0(aL, aP2);
aDist=aP1.Distance(aP2);
//return (aDist < 1.e-12); //
return (aDist < Precision::Confusion()); //modified by NIZNHY-PKV Mon Jul 04 11:58:23 2011f
aPC=Precision::Confusion();
aPC=aPC*aPC;
aDist=aP1.SquareDistance(aP2);
bRet=aDist<aPC;
return bRet;
//
//aDist=aP1.Distance(aP2);
//return (aDist < Precision::Confusion());
//modified by NIZNHY-PKV Mon Jul 04 11:59:50 2011t
} }
//======================================================================= //=======================================================================
@ -218,7 +227,6 @@ static
aF=aC3D->FirstParameter(); aF=aC3D->FirstParameter();
aL=aC3D->LastParameter(); aL=aC3D->LastParameter();
aMid=0.5*(aF+aL); aMid=0.5*(aF+aL);
//modified by NIZNHY-PKV Thu Feb 5 08:26:58 2009 f
GeomAdaptor_Curve aGAC(aC3D); GeomAdaptor_Curve aGAC(aC3D);
GeomAbs_CurveType aCT=aGAC.GetType(); GeomAbs_CurveType aCT=aGAC.GetType();
if (aCT==GeomAbs_BSplineCurve || if (aCT==GeomAbs_BSplineCurve ||
@ -226,7 +234,6 @@ static
//aMid=0.5*aMid; //aMid=0.5*aMid;
aMid=IntTools_Tools::IntermediatePoint(aF, aL); aMid=IntTools_Tools::IntermediatePoint(aF, aL);
} }
//modified by NIZNHY-PKV Thu Feb 5 08:27:00 2009 t
// //
Handle(Geom_Curve) aC3DNewF, aC3DNewL; Handle(Geom_Curve) aC3DNewF, aC3DNewL;
aC3DNewF =new Geom_TrimmedCurve (aC3D, aF, aMid); aC3DNewF =new Geom_TrimmedCurve (aC3D, aF, aMid);
@ -278,20 +285,26 @@ static
const Standard_Real aTolPV, const Standard_Real aTolPV,
const TopoDS_Vertex& aV) const TopoDS_Vertex& aV)
{ {
Standard_Boolean bRet;
Standard_Real aTolV, aD, dTol; Standard_Real aTolV, aD, dTol;
gp_Pnt aPv; gp_Pnt aPv;
aTolV=BRep_Tool::Tolerance(aV); aTolV=BRep_Tool::Tolerance(aV);
// //
//modified by NIZNHY-PKV Thu Jan 18 17:44:46 2007f
//aTolV=aTolV+aTolPV;
dTol=Precision::Confusion(); dTol=Precision::Confusion();
aTolV=aTolV+aTolPV+dTol; aTolV=aTolV+aTolPV+dTol;
//modified by NIZNHY-PKV Thu Jan 18 17:44:49 2007t
// //
aPv=BRep_Tool::Pnt(aV); aPv=BRep_Tool::Pnt(aV);
aD=aPv.Distance(aP); //
return (aD<=aTolV); //modified by NIZNHY-PKV Mon Jul 04 12:00:37 2011f
aD=aPv.SquareDistance(aP);
aTolV=aTolV*aTolV;
bRet=(aD<=aTolV);
return bRet;
//
//aD=aPv.Distance(aP);
//return (aD<=aTolV);
//modified by NIZNHY-PKV Mon Jul 04 12:00:40 2011t
} }
@ -390,11 +403,14 @@ static
aTolV1=BRep_Tool::Tolerance(aV1); aTolV1=BRep_Tool::Tolerance(aV1);
aTolV2=BRep_Tool::Tolerance(aV2); aTolV2=BRep_Tool::Tolerance(aV2);
aTolSum=aTolV1+aTolV2; aTolSum=aTolV1+aTolV2;
aP1=BRep_Tool::Pnt(aV1); aP1=BRep_Tool::Pnt(aV1);
aP2=BRep_Tool::Pnt(aV2); aP2=BRep_Tool::Pnt(aV2);
//modified by NIZNHY-PKV Mon Jul 04 11:55:52 2011f
d=aP1.Distance(aP2); aTolSum=aTolSum*aTolSum;
d=aP1.SquareDistance(aP2);
//d=aP1.Distance(aP2);
//modified by NIZNHY-PKV Mon Jul 04 11:55:53 2011t
if (d<aTolSum) { if (d<aTolSum) {
return 0; return 0;
} }
@ -442,7 +458,8 @@ static
const TopoDS_Edge& aE2) const TopoDS_Edge& aE2)
{ {
Standard_Real f1, l1, m1, f2, l2, m2, aTol1, aTol2, aSumTol; Standard_Boolean bRet;
Standard_Real f1, l1, m1, f2, l2, m2, aTol1, aTol2, aSumTol, aD2;
gp_Pnt aP1, aP2; gp_Pnt aP1, aP2;
aTol1=BRep_Tool::Tolerance(aE1); aTol1=BRep_Tool::Tolerance(aE1);
@ -456,11 +473,17 @@ static
C2->D0(m2, aP2); C2->D0(m2, aP2);
aSumTol=aTol1+aTol2; aSumTol=aTol1+aTol2;
//modified by NIZNHY-PKV Mon Jul 04 12:02:20 2011f
if (aP1.Distance(aP2) < aSumTol) { aSumTol=aSumTol*aSumTol;
return Standard_True; aD2=aP1.SquareDistance(aP2);
} bRet=aD2<aSumTol;
return Standard_False; return bRet;
//
//if (aP1.Distance(aP2) < aSumTol) {
// return Standard_True;
//}
//return Standard_False;
//modified by NIZNHY-PKV Mon Jul 04 12:02:24 2011t
} }
//======================================================================= //=======================================================================

View File

@ -191,5 +191,16 @@ is
---C++: return & ---C++: return &
raises NoSuchObject from Standard raises NoSuchObject from Standard
is static; is static;
--modified by NIZNHY-PKV Tue Jul 05 09:57:10 2011f
Find1(me; K : TheKey)
returns Address from Standard;
---Purpose: Returns the address of Item of the key <K>
-- or NULL if K is not in the map.
ChangeFind1(me:out; K : TheKey)
returns Address from Standard;
---Purpose: Returns the address of Item of the key <K>
-- or NULL if K is not in the map.
--modified by NIZNHY-PKV Tue Jul 05 09:57:14 2011t
end DataMap; end DataMap;

View File

@ -137,24 +137,6 @@ Standard_Boolean TCollection_DataMap::Bind(const TheKey& K, const TheItem& I)
return Standard_True; return Standard_True;
} }
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean TCollection_DataMap::IsBound(const TheKey& K) const
{
if (IsEmpty()) return Standard_False;
TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
TCollection_DataMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
while (p) {
if (Hasher::IsEqual(p->Key(),K)) {
return Standard_True;
}
p = (TCollection_DataMapNode*) p->Next();
}
return Standard_False;
}
//======================================================================= //=======================================================================
//function : Remove //function : Remove
@ -181,12 +163,27 @@ Standard_Boolean TCollection_DataMap::UnBind(const TheKey& K)
} }
return Standard_False; return Standard_False;
} }
//=======================================================================
//function : IsBound
//purpose :
//=======================================================================
Standard_Boolean TCollection_DataMap::IsBound(const TheKey& K) const
{
if (IsEmpty()) return Standard_False;
TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
TCollection_DataMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
while (p) {
if (Hasher::IsEqual(p->Key(),K)) {
return Standard_True;
}
p = (TCollection_DataMapNode*) p->Next();
}
return Standard_False;
}
//======================================================================= //=======================================================================
//function : Find //function : Find
//purpose : //purpose :
//======================================================================= //=======================================================================
const TheItem& TCollection_DataMap::Find(const TheKey& K) const const TheItem& TCollection_DataMap::Find(const TheKey& K) const
{ {
Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_DataMap::Find"); Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_DataMap::Find");
@ -201,12 +198,10 @@ const TheItem& TCollection_DataMap::Find(const TheKey& K) const
Standard_NoSuchObject::Raise("TCollection_DataMap::Find"); Standard_NoSuchObject::Raise("TCollection_DataMap::Find");
return p->Value(); return p->Value();
} }
//======================================================================= //=======================================================================
//function : ChangeFind //function : ChangeFind
//purpose : //purpose :
//======================================================================= //=======================================================================
TheItem& TCollection_DataMap::ChangeFind(const TheKey& K) TheItem& TCollection_DataMap::ChangeFind(const TheKey& K)
{ {
Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_DataMap::ChangeFind"); Standard_NoSuchObject_Raise_if(IsEmpty(),"TCollection_DataMap::ChangeFind");
@ -221,7 +216,36 @@ TheItem& TCollection_DataMap::ChangeFind(const TheKey& K)
Standard_NoSuchObject::Raise("TCollection_DataMap::ChangeFind"); Standard_NoSuchObject::Raise("TCollection_DataMap::ChangeFind");
return p->Value(); return p->Value();
} }
//modified by NIZNHY-PKV Tue Jul 05 09:54:14 2011f
//=======================================================================
//function : Find1
//purpose :
//=======================================================================
Standard_Address TCollection_DataMap::Find1(const TheKey& K) const
{
TCollection_DataMap *pMap=(TCollection_DataMap *)this;
return pMap->ChangeFind1(K);
}
//=======================================================================
//function : ChangeFind1
//purpose :
//=======================================================================
Standard_Address TCollection_DataMap::ChangeFind1(const TheKey& K)
{
if (IsEmpty()) {
return NULL;
}
TCollection_DataMapNode** data = (TCollection_DataMapNode**) myData1;
TCollection_DataMapNode* p = data[Hasher::HashCode(K,NbBuckets())];
while (p) {
if (Hasher::IsEqual(p->Key(),K)) {
return (Standard_Address)&p->Value();
}
p = (TCollection_DataMapNode*) p->Next();
}
return NULL;
}
//modified by NIZNHY-PKV Tue Jul 05 09:54:18 2011t

View File

@ -203,6 +203,17 @@ is
-- Trigger: Raises NoSuchObject if K is not in the map. -- Trigger: Raises NoSuchObject if K is not in the map.
raises NoSuchObject from Standard raises NoSuchObject from Standard
---C++: return & ---C++: return &
is static; is static;
--modified by NIZNHY-PKV Tue Jul 05 08:38:26 2011f
FindFromKey1(me; K : TheKey)
returns Address from Standard;
---Purpose: Returns the address of Item of the key <K>
-- or NULL if K is not in the map.
ChangeFromKey1(me:out; K : TheKey)
returns Address from Standard;
---Purpose: Returns the address of Item of the key <K>
-- or NULL if K is not in the map.
--modified by NIZNHY-PKV Tue Jul 05 08:38:26 2011t
end IndexedDataMap; end IndexedDataMap;

View File

@ -242,24 +242,6 @@ void TCollection_IndexedDataMap::RemoveLast()
delete p; delete p;
} }
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean TCollection_IndexedDataMap::Contains(const TheKey& K1) const
{
if (IsEmpty()) return Standard_False;
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedDataMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher::IsEqual(p1->Key1(),K1)) return Standard_True;
p1 = (TCollection_IndexedDataMapNode*) p1->Next();
}
return Standard_False;
}
//======================================================================= //=======================================================================
//function : FindKey //function : FindKey
@ -340,12 +322,27 @@ Standard_Integer TCollection_IndexedDataMap::FindIndex(const TheKey& K1) const
} }
return 0; return 0;
} }
//=======================================================================
//function : Contains
//purpose :
//=======================================================================
Standard_Boolean TCollection_IndexedDataMap::Contains(const TheKey& K1) const
{
if (IsEmpty()) return Standard_False;
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedDataMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher::IsEqual(p1->Key1(),K1)) return Standard_True;
p1 = (TCollection_IndexedDataMapNode*) p1->Next();
}
return Standard_False;
}
//======================================================================= //=======================================================================
//function : FindFromKey //function : FindFromKey
//purpose : //purpose :
//======================================================================= //=======================================================================
const TheItem& TCollection_IndexedDataMap::FindFromKey(const TheKey& K1) const const TheItem& TCollection_IndexedDataMap::FindFromKey(const TheKey& K1) const
{ {
Standard_OutOfRange_Raise_if(IsEmpty(),"TCollection_IndexedDataMap::FindFromKey"); Standard_OutOfRange_Raise_if(IsEmpty(),"TCollection_IndexedDataMap::FindFromKey");
@ -360,12 +357,10 @@ const TheItem& TCollection_IndexedDataMap::FindFromKey(const TheKey& K1) const
Standard_OutOfRange::Raise("TCollection_IndexedDataMap::FindFromKey"); Standard_OutOfRange::Raise("TCollection_IndexedDataMap::FindFromKey");
return p1->Value(); return p1->Value();
} }
//======================================================================= //=======================================================================
//function : ChangeFromKey //function : ChangeFromKey
//purpose : //purpose :
//======================================================================= //=======================================================================
TheItem& TCollection_IndexedDataMap::ChangeFromKey(const TheKey& K1) TheItem& TCollection_IndexedDataMap::ChangeFromKey(const TheKey& K1)
{ {
Standard_OutOfRange_Raise_if(IsEmpty(),"TCollection_IndexedDataMap::ChangeFromKey"); Standard_OutOfRange_Raise_if(IsEmpty(),"TCollection_IndexedDataMap::ChangeFromKey");
@ -380,8 +375,37 @@ TheItem& TCollection_IndexedDataMap::ChangeFromKey(const TheKey& K1)
Standard_OutOfRange::Raise("TCollection_IndexedDataMap::ChangeFromKey"); Standard_OutOfRange::Raise("TCollection_IndexedDataMap::ChangeFromKey");
return p1->Value(); return p1->Value();
} }
//modified by NIZNHY-PKV Tue Jul 05 08:37:03 2011f
//=======================================================================
//function : FindFromKey1
//purpose :
//=======================================================================
Standard_Address TCollection_IndexedDataMap::FindFromKey1(const TheKey& K1) const
{
TCollection_IndexedDataMap *pMap=(TCollection_IndexedDataMap *)this;
return pMap->ChangeFromKey1(K1);
}
//=======================================================================
//function : ChangeFromKey1
//purpose :
//=======================================================================
Standard_Address TCollection_IndexedDataMap::ChangeFromKey1(const TheKey& K1)
{
if (IsEmpty()) {
return NULL;
}
TCollection_IndexedDataMapNode** data1 = (TCollection_IndexedDataMapNode**)myData1;
Standard_Integer k1 = Hasher::HashCode(K1,NbBuckets());
TCollection_IndexedDataMapNode *p1;
p1 = data1[k1];
while (p1) {
if (Hasher::IsEqual(p1->Key1(),K1)) {
return (Standard_Address)&p1->Value();
}
p1 = (TCollection_IndexedDataMapNode*) p1->Next();
}
return NULL;
}
// @@SDM: begin // @@SDM: begin