Mantis issue 0021191: GlueEdges and GlueFaces problem with tolerance 1. A fix by PKV.

This commit is contained in:
jfa 2012-03-16 13:23:39 +00:00
parent 426cef8148
commit f91bad6fb6
7 changed files with 575 additions and 280 deletions

View File

@ -18,12 +18,10 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File: GEOMAlgo_GlueDetector.cxx // File: GEOMAlgo_GlueDetector.cxx
// Created:
// Author: Peter KURNEV // Author: Peter KURNEV
// <pkv@irinox>
//
#include <GEOMAlgo_GlueDetector.hxx> #include <GEOMAlgo_GlueDetector.hxx>
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
@ -61,6 +59,21 @@
#include <GEOMAlgo_PassKeyShape.hxx> #include <GEOMAlgo_PassKeyShape.hxx>
#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx> #include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
#include <GEOMAlgo_Tools.hxx> #include <GEOMAlgo_Tools.hxx>
//
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx>
//modified by NIZNHY-PKV Tue Mar 13 10:25:47 2012f
static
Standard_Integer CheckAncesstors
(const TopoDS_Shape& aVSD,
const TopTools_MapOfShape& aMVSD,
const TopTools_IndexedDataMapOfShapeListOfShape& aMVE,
const TopTools_IndexedDataMapOfShapeListOfShape& aMEV,
TopTools_IndexedDataMapOfShapeListOfShape& aMEVZ);
//modified by NIZNHY-PKV Tue Mar 13 10:25:50 2012t
//======================================================================= //=======================================================================
//function : //function :
@ -77,6 +90,17 @@ GEOMAlgo_GlueDetector::GEOMAlgo_GlueDetector()
//======================================================================= //=======================================================================
GEOMAlgo_GlueDetector::~GEOMAlgo_GlueDetector() GEOMAlgo_GlueDetector::~GEOMAlgo_GlueDetector()
{} {}
//modified by NIZNHY-PKV Tue Mar 13 12:26:50 2012f
//=======================================================================
//function : StickedShapes
//purpose :
//=======================================================================
const TopTools_IndexedDataMapOfShapeListOfShape&
GEOMAlgo_GlueDetector::StickedShapes()
{
return myStickedShapes;
}
//modified by NIZNHY-PKV Tue Mar 13 12:26:54 2012t
//======================================================================= //=======================================================================
//function : Perform //function : Perform
//purpose : //purpose :
@ -85,6 +109,7 @@ void GEOMAlgo_GlueDetector::Perform()
{ {
myErrorStatus=0; myErrorStatus=0;
myWarningStatus=0; myWarningStatus=0;
myStickedShapes.Clear();
// //
CheckData(); CheckData();
if (myErrorStatus) { if (myErrorStatus) {
@ -99,6 +124,13 @@ void GEOMAlgo_GlueDetector::Perform()
return; return;
} }
// //
//modified by NIZNHY-PKV Wed Mar 14 08:00:09 2012f
CheckDetected();
if (myErrorStatus) {
return;
}
//modified by NIZNHY-PKV Wed Mar 14 08:00:12 2012t
//
DetectEdges(); DetectEdges();
if (myErrorStatus) { if (myErrorStatus) {
return; return;
@ -127,7 +159,6 @@ void GEOMAlgo_GlueDetector::DetectVertices()
TopTools_DataMapOfShapeListOfShape aMVV; TopTools_DataMapOfShapeListOfShape aMVV;
GEOMAlgo_IndexedDataMapOfIntegerShape aMIS; GEOMAlgo_IndexedDataMapOfIntegerShape aMIS;
NMTDS_IndexedDataMapOfShapeBndSphere aMSB; NMTDS_IndexedDataMapOfShapeBndSphere aMSB;
//
NMTDS_BndSphereTreeSelector aSelector; NMTDS_BndSphereTreeSelector aSelector;
NMTDS_BndSphereTree aBBTree; NMTDS_BndSphereTree aBBTree;
NCollection_UBTreeFiller <Standard_Integer, NMTDS_BndSphere> aTreeFiller(aBBTree); NCollection_UBTreeFiller <Standard_Integer, NMTDS_BndSphere> aTreeFiller(aBBTree);
@ -179,49 +210,49 @@ void GEOMAlgo_GlueDetector::DetectVertices()
aNbIP=aMIP.Extent(); aNbIP=aMIP.Extent();
aIt1.Initialize(aMIP); aIt1.Initialize(aMIP);
for(; aIt1.More(); aIt1.Next()) { for(; aIt1.More(); aIt1.Next()) {
aIP=aIt1.Key(); aIP=aIt1.Key();
if (aMIPC.Contains(aIP)) { if (aMIPC.Contains(aIP)) {
continue; continue;
} }
// //
const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP); const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
const NMTDS_BndSphere& aBoxVP=aMSB.FindFromKey(aVP); const NMTDS_BndSphere& aBoxVP=aMSB.FindFromKey(aVP);
// //
aSelector.Clear(); aSelector.Clear();
aSelector.SetBox(aBoxVP); aSelector.SetBox(aBoxVP);
// //
aNbVSD=aBBTree.Select(aSelector); aNbVSD=aBBTree.Select(aSelector);
if (!aNbVSD) { if (!aNbVSD) {
continue; // it shoild not be so [at least IP itself] continue; // it shoild not be so [at least IP itself]
} }
// //
const TColStd_ListOfInteger& aLI=aSelector.Indices(); const TColStd_ListOfInteger& aLI=aSelector.Indices();
aIt.Initialize(aLI); aIt.Initialize(aLI);
for (; aIt.More(); aIt.Next()) { for (; aIt.More(); aIt.Next()) {
aIP1=aIt.Value(); aIP1=aIt.Value();
if (aMIP.Contains(aIP1)) { if (aMIP.Contains(aIP1)) {
continue; continue;
} }
aMIP1.Add(aIP1); aMIP1.Add(aIP1);
} //for (; aIt.More(); aIt.Next()) { } //for (; aIt.More(); aIt.Next()) {
}//for(; aIt1.More(); aIt1.Next()) { }//for(; aIt1.More(); aIt1.Next()) {
// //
aNbIP1=aMIP1.Extent(); aNbIP1=aMIP1.Extent();
if (!aNbIP1) { if (!aNbIP1) {
break; break;
} }
// //
aIt1.Initialize(aMIP); aIt1.Initialize(aMIP);
for(; aIt1.More(); aIt1.Next()) { for(; aIt1.More(); aIt1.Next()) {
aIP=aIt1.Key(); aIP=aIt1.Key();
aMIPC.Add(aIP); aMIPC.Add(aIP);
} }
// //
aMIP.Clear(); aMIP.Clear();
aIt1.Initialize(aMIP1); aIt1.Initialize(aMIP1);
for(; aIt1.More(); aIt1.Next()) { for(; aIt1.More(); aIt1.Next()) {
aIP=aIt1.Key(); aIP=aIt1.Key();
aMIP.Add(aIP); aMIP.Add(aIP);
} }
aMIP1.Clear(); aMIP1.Clear();
}// while(1) }// while(1)
@ -239,7 +270,7 @@ void GEOMAlgo_GlueDetector::DetectVertices()
aIP=aIt1.Key(); aIP=aIt1.Key();
const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP); const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP);
if (!j) { if (!j) {
aVF=aVP; aVF=aVP;
} }
aLVSD.Append(aVP); aLVSD.Append(aVP);
aMVProcessed.Add(aVP); aMVProcessed.Add(aVP);
@ -257,7 +288,7 @@ void GEOMAlgo_GlueDetector::DetectVertices()
for (; aItS.More(); aItS.Next()) { for (; aItS.More(); aItS.Next()) {
const TopoDS_Shape& aVSD=aItS.Value(); const TopoDS_Shape& aVSD=aItS.Value();
if (!myOrigins.IsBound(aVSD)) { if (!myOrigins.IsBound(aVSD)) {
myOrigins.Bind(aVSD, aV); myOrigins.Bind(aVSD, aV);
} }
} }
} }
@ -351,11 +382,12 @@ void GEOMAlgo_GlueDetector::DetectShapes(const TopAbs_ShapeEnum aType)
const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aS1); const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aS1);
bDegenerated=BRep_Tool::Degenerated(aE1); bDegenerated=BRep_Tool::Degenerated(aE1);
if (bDegenerated) { if (bDegenerated) {
continue; continue;
} }
} }
// //
myImages.Bind(aS1, aLSDF); myImages.Bind(aS1, aLSDF);
//
// origins // origins
aItLS.Initialize(aLSDF); aItLS.Initialize(aLSDF);
for (; aItLS.More(); aItLS.Next()) { for (; aItLS.More(); aItLS.Next()) {
@ -371,7 +403,7 @@ void GEOMAlgo_GlueDetector::DetectShapes(const TopAbs_ShapeEnum aType)
//purpose : //purpose :
//======================================================================= //=======================================================================
void GEOMAlgo_GlueDetector::FacePassKey(const TopoDS_Face& aF, void GEOMAlgo_GlueDetector::FacePassKey(const TopoDS_Face& aF,
GEOMAlgo_PassKeyShape& aPK) GEOMAlgo_PassKeyShape& aPK)
{ {
Standard_Integer i, aNbE; Standard_Integer i, aNbE;
TopoDS_Shape aER; TopoDS_Shape aER;
@ -404,7 +436,7 @@ void GEOMAlgo_GlueDetector::FacePassKey(const TopoDS_Face& aF,
//purpose : //purpose :
//======================================================================= //=======================================================================
void GEOMAlgo_GlueDetector::EdgePassKey(const TopoDS_Edge& aE, void GEOMAlgo_GlueDetector::EdgePassKey(const TopoDS_Edge& aE,
GEOMAlgo_PassKeyShape& aPK) GEOMAlgo_PassKeyShape& aPK)
{ {
TopAbs_Orientation aOr; TopAbs_Orientation aOr;
TopoDS_Shape aVR; TopoDS_Shape aVR;
@ -417,10 +449,10 @@ void GEOMAlgo_GlueDetector::EdgePassKey(const TopoDS_Edge& aE,
aOr=aV.Orientation(); aOr=aV.Orientation();
if (aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED) { if (aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED) {
if (myOrigins.IsBound(aV)) { if (myOrigins.IsBound(aV)) {
aVR=myOrigins.Find(aV); aVR=myOrigins.Find(aV);
} }
else { else {
aVR=aV; aVR=aV;
} }
aLV.Append(aVR); aLV.Append(aVR);
} }
@ -428,3 +460,152 @@ void GEOMAlgo_GlueDetector::EdgePassKey(const TopoDS_Edge& aE,
// //
aPK.SetShapes(aLV); aPK.SetShapes(aLV);
} }
//modified by NIZNHY-PKV Tue Mar 13 09:54:18 2012f
//=======================================================================
//function : CheckDetected
//purpose :
//=======================================================================
void GEOMAlgo_GlueDetector::CheckDetected()
{
TopoDS_Iterator aItA;
TopExp_Explorer aExp;
TopTools_ListOfShape aLV;
TopTools_MapOfShape aMFence;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm;
TopTools_IndexedDataMapOfShapeListOfShape aMVE, aMEV;
//
// 1. aMVE, aMEV
TopExp::MapShapesAndAncestors(myArgument, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
//
aExp.Init(myArgument, TopAbs_EDGE);
for (; aExp.More(); aExp.Next()) {
const TopoDS_Shape& aE=aExp.Current();
//
aLV.Clear();
aMFence.Clear();
aItA.Initialize(aE);
for (; aItA.More(); aItA.Next()) {
const TopoDS_Shape& aV=aItA.Value();
if (aMFence.Add(aV)) {
aLV.Append(aV);
}
}
//
aMEV.Add(aE, aLV);
}
// 2. Checking
aItIm.Initialize(myImages);
for (; aItIm.More(); aItIm.Next()) {
//const TopoDS_Shape& aV=aItIm.Key();
const TopTools_ListOfShape& aLVSD=aItIm.Value();
CheckDetected(aLVSD, aMVE, aMEV);
}
}
//=======================================================================
//function : CheckDetected
//purpose :
//=======================================================================
void GEOMAlgo_GlueDetector::CheckDetected
(const TopTools_ListOfShape& aLVSD,
const TopTools_IndexedDataMapOfShapeListOfShape& aMVE,
const TopTools_IndexedDataMapOfShapeListOfShape& aMEV)
{
Standard_Integer i, aNbVSD, aNbA, iRet;
TopAbs_ShapeEnum aTypeS, aTypeA[2];
TopExp_Explorer aExp, aExpA;
TopTools_MapOfShape aMFence, aMVSD;
TopTools_ListOfShape aLV;
TopTools_ListIteratorOfListOfShape aItLS;
//
myErrorStatus=0;
//
aNbVSD=aLVSD.Extent();
if (aNbVSD < 2) {
return ;
}
//
aItLS.Initialize(aLVSD);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aVSD=aItLS.Value();
aMVSD.Add(aVSD);
}
//
aItLS.Initialize(aLVSD);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aVSD=aItLS.Value();
//
iRet=CheckAncesstors(aVSD, aMVSD, aMVE, aMEV, myStickedShapes);
if (iRet) {
// Sticked shapes detected
myWarningStatus=2;
}
}
}
//=======================================================================
//function : CheckAncesstors
//purpose :
//=======================================================================
Standard_Integer CheckAncesstors
(const TopoDS_Shape& aVSD,
const TopTools_MapOfShape& aMVSD,
const TopTools_IndexedDataMapOfShapeListOfShape& aMVE,
const TopTools_IndexedDataMapOfShapeListOfShape& aMEV,
TopTools_IndexedDataMapOfShapeListOfShape& aMEVZ)
{
Standard_Address pLE, pLV, pLVZ;
Standard_Integer iRet, aNbVX;
TopTools_ListIteratorOfListOfShape aItLE, aItLV;
TopTools_MapOfShape aMFence;
TopTools_ListOfShape aLVX;
//
iRet=0;
//
pLE=aMVE.FindFromKey1(aVSD);
if (!pLE) {
return iRet;
}
//
const TopTools_ListOfShape& aLE=*((TopTools_ListOfShape*)pLE);
aItLE.Initialize(aLE);
for (; aItLE.More(); aItLE.Next()) {
const TopoDS_Shape& aE=aItLE.Value();
//
pLV=aMEV.FindFromKey1(aE);
if (!pLV) {
continue; // it should be not so
}
//
aLVX.Clear();
const TopTools_ListOfShape& aLV=*((TopTools_ListOfShape*)pLV);
aItLV.Initialize(aLV);
for (; aItLV.More(); aItLV.Next()) {
const TopoDS_Shape& aV=aItLV.Value();
if (!aV.IsSame(aVSD)) {
if (aMVSD.Contains(aV)) {
if (aMFence.Add(aV)) {
aLVX.Append(aV);
}
}
}
}
//
aNbVX=aLVX.Extent();
if (!aNbVX) {
continue;
}
//
iRet=1;
//
pLVZ=aMEVZ.FindFromKey1(aE);
if (!pLVZ) {
aMEVZ.Add(aE, aLVX);
}
else {
TopTools_ListOfShape& aLVZ=*((TopTools_ListOfShape*)pLVZ);
aLVZ.Append(aLVX);
}
}
//
return iRet;
}
//modified by NIZNHY-PKV Tue Mar 13 09:54:59 2012t

View File

@ -18,50 +18,82 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File: GEOMAlgo_GlueDetector.hxx // File: GEOMAlgo_GlueDetector.hxx
// Created:
// Author: Peter KURNEV // Author: Peter KURNEV
// <pkv@irinox>
//
#ifndef _GEOMAlgo_GlueDetector_HeaderFile #ifndef _GEOMAlgo_GlueDetector_HeaderFile
#define _GEOMAlgo_GlueDetector_HeaderFile #define _GEOMAlgo_GlueDetector_HeaderFile
#include <Standard.hxx> #include <Standard.hxx>
#include <Standard_Macro.hxx> #include <Standard_Macro.hxx>
#include <GEOMAlgo_GluerAlgo.hxx>
#include <TopAbs_ShapeEnum.hxx> #include <TopAbs_ShapeEnum.hxx>
#include <GEOMAlgo_PassKeyShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <GEOMAlgo_GluerAlgo.hxx>
#include <GEOMAlgo_Algo.hxx> #include <GEOMAlgo_Algo.hxx>
#include <GEOMAlgo_PassKeyShape.hxx>
//======================================================================= //=======================================================================
//function : GEOMAlgo_GlueDetector //function : GEOMAlgo_GlueDetector
//purpose : //purpose :
//======================================================================= //=======================================================================
class GEOMAlgo_GlueDetector : public GEOMAlgo_GluerAlgo, class GEOMAlgo_GlueDetector : public GEOMAlgo_GluerAlgo,
public GEOMAlgo_Algo { public GEOMAlgo_Algo
{
public: public:
Standard_EXPORT GEOMAlgo_GlueDetector(); Standard_EXPORT
GEOMAlgo_GlueDetector();
Standard_EXPORT virtual ~GEOMAlgo_GlueDetector(); Standard_EXPORT virtual
~GEOMAlgo_GlueDetector();
Standard_EXPORT virtual void Perform() ; Standard_EXPORT virtual
void Perform() ;
//modified by NIZNHY-PKV Tue Mar 13 12:23:20 2012f
Standard_EXPORT
const TopTools_IndexedDataMapOfShapeListOfShape& StickedShapes();
//modified by NIZNHY-PKV Tue Mar 13 12:23:26 2012t
//------------------------------------------------
protected: protected:
Standard_EXPORT void DetectVertices() ; Standard_EXPORT
void DetectVertices() ;
Standard_EXPORT void DetectEdges() ; Standard_EXPORT
void DetectEdges() ;
Standard_EXPORT void DetectFaces() ; Standard_EXPORT
void DetectFaces() ;
Standard_EXPORT void DetectShapes(const TopAbs_ShapeEnum aType) ; Standard_EXPORT
void DetectShapes(const TopAbs_ShapeEnum aType) ;
Standard_EXPORT void EdgePassKey(const TopoDS_Edge& aE, Standard_EXPORT
GEOMAlgo_PassKeyShape& aPK) ; void EdgePassKey(const TopoDS_Edge& aE,
GEOMAlgo_PassKeyShape& aPK) ;
Standard_EXPORT void FacePassKey(const TopoDS_Face& aF, Standard_EXPORT
GEOMAlgo_PassKeyShape& aPK) ; void FacePassKey(const TopoDS_Face& aF,
GEOMAlgo_PassKeyShape& aPK) ;
//modified by NIZNHY-PKV Tue Mar 13 09:53:03 2012f
Standard_EXPORT
void CheckDetected();
//
Standard_EXPORT
void CheckDetected
(const TopTools_ListOfShape& aLVSD,
const TopTools_IndexedDataMapOfShapeListOfShape& aMVE,
const TopTools_IndexedDataMapOfShapeListOfShape& aMEV);
protected:
TopTools_IndexedDataMapOfShapeListOfShape myStickedShapes;
//modified by NIZNHY-PKV Tue Mar 13 09:53:08 2012t
private:
}; };
#endif #endif

View File

@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File: GEOMAlgo_Gluer2.cxx // File: GEOMAlgo_Gluer2.cxx
// Author: Peter KURNEV // Author: Peter KURNEV
@ -81,7 +81,21 @@ void GEOMAlgo_Gluer2::Clear()
myImagesToWork.Clear(); myImagesToWork.Clear();
myOriginsToWork.Clear(); myOriginsToWork.Clear();
myKeepNonSolids=Standard_False; myKeepNonSolids=Standard_False;
//modified by NIZNHY-PKV Tue Mar 13 13:38:28 2012f
myDetector.Clear();
//modified by NIZNHY-PKV Tue Mar 13 13:38:30 2012t
} }
//modified by NIZNHY-PKV Tue Mar 13 12:26:50 2012f
//=======================================================================
//function : StickedShapes
//purpose :
//=======================================================================
const TopTools_IndexedDataMapOfShapeListOfShape&
GEOMAlgo_Gluer2::StickedShapes()
{
return myDetector.StickedShapes();
}
//modified by NIZNHY-PKV Tue Mar 13 12:26:54 2012t
//======================================================================= //=======================================================================
//function : SetShapesToGlue //function : SetShapesToGlue
//purpose : //purpose :
@ -151,7 +165,8 @@ void GEOMAlgo_Gluer2::Perform()
if (myErrorStatus) { if (myErrorStatus) {
return; return;
} }
if (myWarningStatus==1) {// no shapes to glue if (myWarningStatus==1) {
// no shapes to glue
myShape=myArgument; myShape=myArgument;
return; return;
} }
@ -426,9 +441,7 @@ void GEOMAlgo_Gluer2::FillContainers(const TopAbs_ShapeEnum aType)
} }
// //
GEOMAlgo_Tools3D::MakeContainer(aType, aWnew); GEOMAlgo_Tools3D::MakeContainer(aType, aWnew);
//modified by NIZNHY-PKV Tue May 10 13:46:30 2011f
aWnew.Orientation(aW.Orientation()); aWnew.Orientation(aW.Orientation());
//modified by NIZNHY-PKV Tue May 10 13:46:32 2011t
// //
aItS.Initialize(aW); aItS.Initialize(aW);
for (; aItS.More(); aItS.Next()) { for (; aItS.More(); aItS.Next()) {
@ -448,10 +461,6 @@ void GEOMAlgo_Gluer2::FillContainers(const TopAbs_ShapeEnum aType)
} }
} }
// //
//modified by NIZNHY-PKV Tue May 10 13:46:19 2011f
//aWnew.Orientation(aW.Orientation());
//modified by NIZNHY-PKV Tue May 10 13:46:22 2011t
//
//myImages / myOrigins //myImages / myOrigins
TopTools_ListOfShape aLSD; TopTools_ListOfShape aLSD;
// //
@ -631,4 +640,10 @@ void GEOMAlgo_Gluer2::BuildResult()
// 14 - PerformImagesToWork failed // 14 - PerformImagesToWork failed
// //
// WarningStatus // WarningStatus
// 1 - no shapes to glue // 1 - no shapes to glue
// 2 - sticked shapes are detected.
// The value of myTolerance is so large that
// subshapes of a shape becomes intefere
// (e.g. vertices of an edge).
// In the case
// the result is can not be obtained

View File

@ -18,26 +18,28 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File: GEOMAlgo_Gluer2.hxx // File: GEOMAlgo_Gluer2.hxx
// Created:
// Author: Peter KURNEV // Author: Peter KURNEV
// <pkv@irinox>
#ifndef _GEOMAlgo_Gluer2_HeaderFile #ifndef _GEOMAlgo_Gluer2_HeaderFile
#define _GEOMAlgo_Gluer2_HeaderFile #define _GEOMAlgo_Gluer2_HeaderFile
#include <Standard.hxx> #include <Standard.hxx>
#include <Standard_Macro.hxx> #include <Standard_Macro.hxx>
#include <Standard_Boolean.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx> #include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapOfShapeShape.hxx> #include <TopTools_DataMapOfShapeShape.hxx>
#include <Standard_Boolean.hxx>
#include <GEOMAlgo_GluerAlgo.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <NMTTools_CoupleOfShape.hxx> #include <NMTTools_CoupleOfShape.hxx>
#include <NMTTools_ListOfCoupleOfShape.hxx> #include <NMTTools_ListOfCoupleOfShape.hxx>
#include <GEOMAlgo_GluerAlgo.hxx>
#include <GEOMAlgo_BuilderShape.hxx> #include <GEOMAlgo_BuilderShape.hxx>
#include <GEOMAlgo_GlueDetector.hxx>
//======================================================================= //=======================================================================
//class : GEOMAlgo_Gluer2 //class : GEOMAlgo_Gluer2
@ -47,89 +49,128 @@ class GEOMAlgo_Gluer2 : public GEOMAlgo_GluerAlgo,
public GEOMAlgo_BuilderShape { public GEOMAlgo_BuilderShape {
public: public:
Standard_EXPORT GEOMAlgo_Gluer2(); Standard_EXPORT
GEOMAlgo_Gluer2();
Standard_EXPORT virtual ~GEOMAlgo_Gluer2(); Standard_EXPORT
virtual ~GEOMAlgo_Gluer2();
Standard_EXPORT void SetShapesToGlue(const TopTools_DataMapOfShapeListOfShape& aM) ; Standard_EXPORT
void SetShapesToGlue(const TopTools_DataMapOfShapeListOfShape& aM) ;
Standard_EXPORT const TopTools_DataMapOfShapeListOfShape& ShapesToGlue() const; Standard_EXPORT
const TopTools_DataMapOfShapeListOfShape& ShapesToGlue() const;
Standard_EXPORT void SetKeepNonSolids(const Standard_Boolean theFlag) ; Standard_EXPORT
void SetKeepNonSolids(const Standard_Boolean theFlag) ;
Standard_EXPORT Standard_Boolean KeepNonSolids() const; Standard_EXPORT
Standard_Boolean KeepNonSolids() const;
Standard_EXPORT virtual void Clear() ; Standard_EXPORT virtual void Clear() ;
Standard_EXPORT virtual void Perform() ; Standard_EXPORT
virtual void Perform() ;
Standard_EXPORT virtual void CheckData() ; Standard_EXPORT
virtual void CheckData() ;
Standard_EXPORT void Detect() ; Standard_EXPORT
void Detect() ;
Standard_EXPORT const TopTools_DataMapOfShapeListOfShape& ShapesDetected() const; Standard_EXPORT
const TopTools_DataMapOfShapeListOfShape& ShapesDetected() const;
Standard_EXPORT const TopTools_DataMapOfShapeListOfShape& ImagesToWork() const; Standard_EXPORT
const TopTools_DataMapOfShapeListOfShape& ImagesToWork() const;
Standard_EXPORT virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS) ; Standard_EXPORT
virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS) ;
Standard_EXPORT virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) ; Standard_EXPORT
virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) ;
Standard_EXPORT virtual Standard_Boolean IsDeleted(const TopoDS_Shape& theS) ; Standard_EXPORT
virtual Standard_Boolean IsDeleted(const TopoDS_Shape& theS) ;
Standard_EXPORT static void MakeVertex(const TopTools_ListOfShape& theLV, Standard_EXPORT
TopoDS_Vertex& theV) ; static void MakeVertex(const TopTools_ListOfShape& theLV,
TopoDS_Vertex& theV) ;
Standard_EXPORT static void MapBRepShapes(const TopoDS_Shape& theS, Standard_EXPORT
TopTools_MapOfShape& theM) ; static void MapBRepShapes(const TopoDS_Shape& theS,
TopTools_MapOfShape& theM) ;
Standard_EXPORT static void MapShapes(const TopoDS_Shape& theS,
TopTools_MapOfShape& theM) ;
Standard_EXPORT
static void MapShapes(const TopoDS_Shape& theS,
TopTools_MapOfShape& theM) ;
//modified by NIZNHY-PKV Tue Mar 13 12:23:20 2012f
Standard_EXPORT
const TopTools_IndexedDataMapOfShapeListOfShape& StickedShapes();
//modified by NIZNHY-PKV Tue Mar 13 12:23:26 2012t
//------------------------------------------------
protected: protected:
Standard_EXPORT
void PerformShapesToWork() ;
Standard_EXPORT void PerformShapesToWork() ; Standard_EXPORT
void FillVertices() ;
Standard_EXPORT void FillVertices() ; Standard_EXPORT
void FillEdges() ;
Standard_EXPORT void FillEdges() ; Standard_EXPORT
void FillWires() ;
Standard_EXPORT void FillWires() ; Standard_EXPORT
void FillFaces() ;
Standard_EXPORT void FillFaces() ; Standard_EXPORT
void FillShells() ;
Standard_EXPORT void FillShells() ; Standard_EXPORT
void FillSolids() ;
Standard_EXPORT void FillSolids() ; Standard_EXPORT
void FillCompSolids() ;
Standard_EXPORT void FillCompSolids() ; Standard_EXPORT
void FillCompounds() ;
Standard_EXPORT void FillCompounds() ; Standard_EXPORT
void BuildResult() ;
Standard_EXPORT void BuildResult() ; Standard_EXPORT
void FillBRepShapes(const TopAbs_ShapeEnum theType) ;
Standard_EXPORT void FillBRepShapes(const TopAbs_ShapeEnum theType) ; Standard_EXPORT
void FillContainers(const TopAbs_ShapeEnum theType) ;
Standard_EXPORT void FillContainers(const TopAbs_ShapeEnum theType) ; Standard_EXPORT
void FillCompound(const TopoDS_Shape& theC) ;
Standard_EXPORT void FillCompound(const TopoDS_Shape& theC) ; Standard_EXPORT
virtual void PrepareHistory() ;
Standard_EXPORT virtual void PrepareHistory() ; Standard_EXPORT
Standard_Boolean HasImage(const TopoDS_Shape& theC) ;
Standard_EXPORT Standard_Boolean HasImage(const TopoDS_Shape& theC) ; Standard_EXPORT
void MakeBRepShapes(const TopoDS_Shape& theS,
TopoDS_Shape& theSnew) ;
Standard_EXPORT void MakeBRepShapes(const TopoDS_Shape& theS, Standard_EXPORT
TopoDS_Shape& theSnew) ; void MakeEdge(const TopoDS_Edge& theE,
TopoDS_Edge& theEnew) ;
Standard_EXPORT void MakeEdge(const TopoDS_Edge& theE, Standard_EXPORT
TopoDS_Edge& theEnew) ; void MakeFace(const TopoDS_Face& theF,
TopoDS_Face& theFnew) ;
Standard_EXPORT void MakeFace(const TopoDS_Face& theF, Standard_EXPORT
TopoDS_Face& theFnew) ; void TreatPair(const NMTTools_CoupleOfShape& theCS,
NMTTools_ListOfCoupleOfShape& theLCS) ;
Standard_EXPORT void TreatPair(const NMTTools_CoupleOfShape& theCS,
NMTTools_ListOfCoupleOfShape& theLCS) ;
protected: protected:
TopTools_DataMapOfShapeListOfShape myShapesToGlue; TopTools_DataMapOfShapeListOfShape myShapesToGlue;
@ -138,7 +179,9 @@ protected:
TopTools_DataMapOfShapeListOfShape myImagesToWork; TopTools_DataMapOfShapeListOfShape myImagesToWork;
TopTools_DataMapOfShapeShape myOriginsToWork; TopTools_DataMapOfShapeShape myOriginsToWork;
Standard_Boolean myKeepNonSolids; Standard_Boolean myKeepNonSolids;
//modified by NIZNHY-PKV Tue Mar 13 13:30:40 2012f
GEOMAlgo_GlueDetector myDetector;
//modified by NIZNHY-PKV Tue Mar 13 13:30:43 2012t
private: private:
}; };
#endif #endif

View File

@ -18,10 +18,9 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File: GEOMAlgo_Gluer2_3.cxx // File: GEOMAlgo_Gluer2_3.cxx
// Created: // Author: Peter KURNEV
// Author: Peter KURNEV
#include <GEOMAlgo_Gluer2.hxx> #include <GEOMAlgo_Gluer2.hxx>
@ -55,8 +54,8 @@
static static
void MapShapes1(const TopoDS_Shape& aS, void MapShapes1(const TopoDS_Shape& aS,
const TopAbs_ShapeEnum aType, const TopAbs_ShapeEnum aType,
TopTools_IndexedMapOfShape& aM); TopTools_IndexedMapOfShape& aM);
//======================================================================= //=======================================================================
//function : Detect //function : Detect
@ -68,7 +67,7 @@ void GEOMAlgo_Gluer2::Detect()
Standard_Integer iErr, aNbSD; Standard_Integer iErr, aNbSD;
TopTools_ListIteratorOfListOfShape aItLS; TopTools_ListIteratorOfListOfShape aItLS;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS;
GEOMAlgo_GlueDetector aDetector; //GEOMAlgo_GlueDetector aDetector;
// //
myErrorStatus=0; myErrorStatus=0;
myWarningStatus=0; myWarningStatus=0;
@ -77,18 +76,31 @@ void GEOMAlgo_Gluer2::Detect()
myOriginsDetected.Clear(); myOriginsDetected.Clear();
// //
bCheckGeometry=Standard_True; bCheckGeometry=Standard_True;
aDetector.SetArgument(myArgument);
aDetector.SetTolerance(myTolerance);
aDetector.SetCheckGeometry(bCheckGeometry);
// //
aDetector.Perform(); //modified by NIZNHY-PKV Tue Mar 13 13:33:35 2012f
iErr=aDetector.ErrorStatus(); myDetector.Clear();
myDetector.SetContext(myContext);
//modified by NIZNHY-PKV Tue Mar 13 13:33:38 2012t
myDetector.SetArgument(myArgument);
myDetector.SetTolerance(myTolerance);
myDetector.SetCheckGeometry(bCheckGeometry);
//
myDetector.Perform();
iErr=myDetector.ErrorStatus();
if (iErr) { if (iErr) {
myErrorStatus=11;// Detector failed // Detector is failed
myErrorStatus=11;
return; return;
} }
//modified by NIZNHY-PKV Tue Mar 13 13:40:36 2012f
iErr=myDetector.WarningStatus();
if (iErr) {
// Sticked shapes are detected
myWarningStatus=2;
}
//modified by NIZNHY-PKV Tue Mar 13 13:40:39 2012t
// //
const TopTools_DataMapOfShapeListOfShape& aImages=aDetector.Images(); const TopTools_DataMapOfShapeListOfShape& aImages=myDetector.Images();
aItDMSLS.Initialize(aImages); aItDMSLS.Initialize(aImages);
for (; aItDMSLS.More(); aItDMSLS.Next()) { for (; aItDMSLS.More(); aItDMSLS.Next()) {
const TopoDS_Shape& aSkey=aItDMSLS.Key(); const TopoDS_Shape& aSkey=aItDMSLS.Key();
@ -114,7 +126,7 @@ void GEOMAlgo_Gluer2::Detect()
//======================================================================= //=======================================================================
void GEOMAlgo_Gluer2::PerformShapesToWork() void GEOMAlgo_Gluer2::PerformShapesToWork()
{ {
Standard_Integer aNbSG, i, j, aNbC, aNb, aNbSD; Standard_Integer aNbSG, i, j, k, aNbC, aNb, aNbSD;
TopTools_ListIteratorOfListOfShape aItLS1, aItLS2; TopTools_ListIteratorOfListOfShape aItLS1, aItLS2;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS; TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS;
NMTTools_CoupleOfShape aCS; NMTTools_CoupleOfShape aCS;
@ -144,8 +156,8 @@ void GEOMAlgo_Gluer2::PerformShapesToWork()
const TopTools_ListOfShape& aLSD=aItDMSLS.Value(); const TopTools_ListOfShape& aLSD=aItDMSLS.Value();
aItLS1.Initialize(aLSD); aItLS1.Initialize(aLSD);
for (; aItLS1.More(); aItLS1.Next()) { for (; aItLS1.More(); aItLS1.Next()) {
const TopoDS_Shape& aSx=aItLS1.Value(); const TopoDS_Shape& aSx=aItLS1.Value();
myOriginsToWork.Bind(aSx, aSkey); myOriginsToWork.Bind(aSx, aSkey);
} }
} }
return; return;
@ -153,20 +165,20 @@ void GEOMAlgo_Gluer2::PerformShapesToWork()
// //
// 1. Make pairs // 1. Make pairs
aItDMSLS.Initialize(myShapesToGlue); aItDMSLS.Initialize(myShapesToGlue);
for (; aItDMSLS.More(); aItDMSLS.Next()) { for (k=0; aItDMSLS.More(); aItDMSLS.Next(), ++k) {
//const TopoDS_Shape& aSkey=aItDMSLS.Key(); //const TopoDS_Shape& aSkey=aItDMSLS.Key();
const TopTools_ListOfShape& aLSG=aItDMSLS.Value(); const TopTools_ListOfShape& aLSG=aItDMSLS.Value();
aItLS1.Initialize(aLSG); aItLS1.Initialize(aLSG);
for (i=0; aItLS1.More(); aItLS1.Next(), ++i) { for (i=0; aItLS1.More(); aItLS1.Next(), ++i) {
aItLS2.Initialize(aLSG); aItLS2.Initialize(aLSG);
for (j=0; aItLS2.More(); aItLS2.Next(), ++j) { for (j=0; aItLS2.More(); aItLS2.Next(), ++j) {
if (j>i) { if (j>i) {
const TopoDS_Shape& aSG1=aItLS1.Value(); const TopoDS_Shape& aSG1=aItLS1.Value();
const TopoDS_Shape& aSG2=aItLS2.Value(); const TopoDS_Shape& aSG2=aItLS2.Value();
aCS.SetShape1(aSG1); aCS.SetShape1(aSG1);
aCS.SetShape2(aSG2); aCS.SetShape2(aSG2);
TreatPair(aCS, aLCS); TreatPair(aCS, aLCS);
} }
} }
} }
} }
@ -197,7 +209,7 @@ void GEOMAlgo_Gluer2::PerformShapesToWork()
//purpose : //purpose :
//======================================================================= //=======================================================================
void GEOMAlgo_Gluer2::TreatPair(const NMTTools_CoupleOfShape& aCS, void GEOMAlgo_Gluer2::TreatPair(const NMTTools_CoupleOfShape& aCS,
NMTTools_ListOfCoupleOfShape& aLCS) NMTTools_ListOfCoupleOfShape& aLCS)
{ {
if (myErrorStatus) { if (myErrorStatus) {
return; return;
@ -328,8 +340,8 @@ void GEOMAlgo_Gluer2::TreatPair(const NMTTools_CoupleOfShape& aCS,
//purpose : //purpose :
//======================================================================= //=======================================================================
void MapShapes1(const TopoDS_Shape& aS, void MapShapes1(const TopoDS_Shape& aS,
const TopAbs_ShapeEnum aType, const TopAbs_ShapeEnum aType,
TopTools_IndexedMapOfShape& aM) TopTools_IndexedMapOfShape& aM)
{ {
TopExp_Explorer aExp; TopExp_Explorer aExp;
@ -339,33 +351,9 @@ void MapShapes1(const TopoDS_Shape& aS,
if (aType==TopAbs_EDGE) { if (aType==TopAbs_EDGE) {
const TopoDS_Edge& aEx=*((TopoDS_Edge*)&aSx); const TopoDS_Edge& aEx=*((TopoDS_Edge*)&aSx);
if (BRep_Tool::Degenerated(aEx)) { if (BRep_Tool::Degenerated(aEx)) {
continue; continue;
} }
} }
aM.Add(aSx); aM.Add(aSx);
} }
} }
/*
//=======================================================================
//function : MapShapes1
//purpose :
//=======================================================================
void MapShapes1(const TopoDS_Shape& aS,
const TopAbs_ShapeEnum aType,
TopTools_IndexedMapOfShape& aM)
{
TopExp_Explorer aExp (aS, aType);
while (aExp.More()) {
const TopoDS_Shape aSx=aExp.Current();
if (aType==TopAbs_EDGE) {
const TopoDS_Edge& aEx=*((TopoDS_Edge*)&aSx);
if (BRep_Tool::Degenerated(aEx)) {
aExp.Next();
continue;
}
}
aM.Add(aSx);
aExp.Next();
}
}
*/

View File

@ -818,6 +818,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_GLUE_EDGES_TITLE</source> <source>GEOM_GLUE_EDGES_TITLE</source>
<translation>Glue edges</translation> <translation>Glue edges</translation>
</message> </message>
<message>
<source>GLUE_ERROR_STICKED_SHAPES</source>
<translation>The tolerance value is too big. Sticked shapes are detected.</translation>
</message>
<message> <message>
<source>GEOM_LIMIT_TOLERANCE_TITLE</source> <source>GEOM_LIMIT_TOLERANCE_TITLE</source>
<translation>Limit tolerance</translation> <translation>Limit tolerance</translation>

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
@ -29,13 +28,13 @@
#include <GEOM_Object.hxx> #include <GEOM_Object.hxx>
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
//#include <GEOMAlgo_Gluer.hxx>
//#include "GEOMAlgo_Gluer1.hxx"
#include "GEOMAlgo_Gluer2.hxx" #include "GEOMAlgo_Gluer2.hxx"
#include "GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx" #include "GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx"
#include "GEOMAlgo_CoupleOfShapes.hxx" #include "GEOMAlgo_CoupleOfShapes.hxx"
#include "GEOMAlgo_ListOfCoupleOfShapes.hxx" #include "GEOMAlgo_ListOfCoupleOfShapes.hxx"
#include <Basics_OCCTVersion.hxx>
#include "utilities.h" #include "utilities.h"
#include <TDataStd_IntegerArray.hxx> #include <TDataStd_IntegerArray.hxx>
@ -428,6 +427,39 @@ TopoDS_Shape GEOMImpl_GlueDriver::GlueWithWarnings (const TopoDS_Shape& theShape
// 2. Detect interferred shapes // 2. Detect interferred shapes
aGA.Detect(); aGA.Detect();
//modified by NIZNHY-PKV Tue Mar 13 14:07:12 2012f
#if OCC_VERSION_LARGE > 0x06050200
Standard_Integer iWrnDetect = aGA.WarningStatus();
if (iWrnDetect == 2) {
/*
TopTools_ListIteratorOfListOfShape aItLS;
// Sticked shapes are detected
const TopTools_IndexedDataMapOfShapeListOfShape& aIDMSS = pGluer2->StickedShapes();
Standard_Integer i, aNb = aIDMSS.Extent();
for (i = 1; i <= aNb; ++i) {
// ancestor aSa (edge, wire face,..)
const TopoDS_Shape& aSa = aIDMSS.FindKey(i);
// successors aSs (vertex, edge, ...)
// of the ancestor that are sticked
// for given value of the tolerance
const TopTools_ListOfShape& aLSS = aIDMSS.FindFromIndex(i);
aItLS.Initialize(aLSS);
for (; aItLS.More(); aItLS.Next()) {
const TopoDS_Shape& aSs = aItLS.Value();
}
}
*/
Standard_Failure::Raise("GLUE_ERROR_STICKED_SHAPES");
//Standard_Failure::Raise("Sticked shapes are detected. The tolerance value is too big.");
//theWarning = "Sticked shapes are detected. The tolerance value is too big.";
}
#endif
//modified by NIZNHY-PKV Tue Mar 13 14:07:14 2012t
Standard_Integer iErr = aGA.ErrorStatus(); Standard_Integer iErr = aGA.ErrorStatus();
if (iErr) { if (iErr) {
switch (iErr) { switch (iErr) {