mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0022924: We need more stable work of ShapeAnalysis_FreeBounds::ConnectEdgesToWires()
This commit is contained in:
parent
8b5567c78f
commit
974c25edb4
@ -48,6 +48,11 @@
|
|||||||
#include <TopAbs_State.hxx>
|
#include <TopAbs_State.hxx>
|
||||||
|
|
||||||
#include <Draw_ProgressIndicator.hxx>
|
#include <Draw_ProgressIndicator.hxx>
|
||||||
|
#include <ShapeAnalysis_FreeBounds.hxx>
|
||||||
|
#include <TopTools_HSequenceOfShape.hxx>
|
||||||
|
#include <BRep_Builder.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
|
||||||
#ifdef AIX
|
#ifdef AIX
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
@ -672,6 +677,69 @@ static Standard_Integer checkfclass2d(Draw_Interpretor& di, Standard_Integer n,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Standard_Integer connectedges(Draw_Interpretor& di, Standard_Integer n, const char** a)
|
||||||
|
{
|
||||||
|
if( n < 3) {
|
||||||
|
di<<"Invalid number of arguments. Should be : result shape [toler shared]"<<"\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
TopoDS_Shape aSh1 = DBRep::Get(a[2]);
|
||||||
|
if(aSh1.IsNull()) {
|
||||||
|
di<<"Shape is null"<<"\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Standard_Real aTol = Precision::Confusion();
|
||||||
|
if( n > 3)
|
||||||
|
aTol = atof(a[3]);
|
||||||
|
|
||||||
|
Standard_Boolean shared = Standard_True;
|
||||||
|
if( n > 4)
|
||||||
|
shared = (atoi(a[4]) == 1);
|
||||||
|
TopExp_Explorer aExpE(aSh1,TopAbs_EDGE);
|
||||||
|
Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
|
||||||
|
Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
|
||||||
|
TopTools_IndexedMapOfShape aMapEdges;
|
||||||
|
for( ; aExpE.More(); aExpE.Next())
|
||||||
|
{
|
||||||
|
aSeqEdges->Append(aExpE.Current());
|
||||||
|
aMapEdges.Add(aExpE.Current());
|
||||||
|
}
|
||||||
|
|
||||||
|
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges,aTol,shared,aSeqWires );
|
||||||
|
TopoDS_Compound aComp;
|
||||||
|
BRep_Builder aB;
|
||||||
|
aB.MakeCompound(aComp);
|
||||||
|
Standard_Integer i = 1;
|
||||||
|
for( ; i <= aSeqWires->Length() ; i++)
|
||||||
|
{
|
||||||
|
TopoDS_Shape aW = aSeqWires->Value(i);
|
||||||
|
di<<"Wire - "<<i<<" : "<<"\n";
|
||||||
|
|
||||||
|
TopExp_Explorer aExp1(aW, TopAbs_EDGE);
|
||||||
|
for( ; aExp1.More(); aExp1.Next())
|
||||||
|
{
|
||||||
|
if(shared)
|
||||||
|
{
|
||||||
|
Standard_Integer ind = aMapEdges.FindIndex(aExp1.Current());
|
||||||
|
di<<ind<<" ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TopoDS_Vertex aV1, aV2;
|
||||||
|
TopExp::Vertices(TopoDS::Edge(aExp1.Current()), aV1,aV2);
|
||||||
|
gp_Pnt aP = BRep_Tool::Pnt(aV1);
|
||||||
|
di<<aP.X()<<" "<<aP.Y()<<" "<<aP.Z()<<"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
di<<"\n";
|
||||||
|
aB.Add( aComp,aSeqWires->Value(i));
|
||||||
|
}
|
||||||
|
DBRep::Set(a[1],aComp);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : InitCommands
|
//function : InitCommands
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -706,5 +774,8 @@ static Standard_Integer checkfclass2d(Draw_Interpretor& di, Standard_Integer n,
|
|||||||
__FILE__,checkoverlapedges,g);
|
__FILE__,checkoverlapedges,g);
|
||||||
theCommands.Add ("checkfclass2d","face ucoord vcoord",
|
theCommands.Add ("checkfclass2d","face ucoord vcoord",
|
||||||
__FILE__,checkfclass2d,g);
|
__FILE__,checkfclass2d,g);
|
||||||
|
theCommands.Add ("connectedges","res shape [toler shared]",
|
||||||
|
__FILE__,connectedges,g);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <Precision.hxx>
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Reject
|
//function : Reject
|
||||||
@ -43,7 +44,11 @@ Standard_Boolean ShapeAnalysis_BoxBndTreeSelector::
|
|||||||
Standard_Boolean IsAccept = Standard_False;
|
Standard_Boolean IsAccept = Standard_False;
|
||||||
if (myList.Contains(theObj))
|
if (myList.Contains(theObj))
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
First = 1,
|
||||||
|
Last = 2
|
||||||
|
};
|
||||||
|
|
||||||
TopoDS_Wire W = TopoDS::Wire (mySeq->Value (theObj));
|
TopoDS_Wire W = TopoDS::Wire (mySeq->Value (theObj));
|
||||||
TopoDS_Vertex V1,V2;
|
TopoDS_Vertex V1,V2;
|
||||||
@ -52,21 +57,25 @@ Standard_Boolean ShapeAnalysis_BoxBndTreeSelector::
|
|||||||
if (myLVertex.IsSame(V1)){
|
if (myLVertex.IsSame(V1)){
|
||||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
|
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1);
|
||||||
IsAccept = Standard_True;
|
IsAccept = Standard_True;
|
||||||
|
myArrIndices(Last) = theObj;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (myLVertex.IsSame(V2)){
|
if (myLVertex.IsSame(V2)){
|
||||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
|
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2);
|
||||||
IsAccept = Standard_True;
|
IsAccept = Standard_True;
|
||||||
|
myArrIndices(Last) = theObj;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (myFVertex.IsSame(V2)){
|
if (myFVertex.IsSame(V2)){
|
||||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3);
|
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3);
|
||||||
IsAccept = Standard_True;
|
IsAccept = Standard_True;
|
||||||
|
myArrIndices(First) = theObj;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (myFVertex.IsSame(V1)){
|
if (myFVertex.IsSame(V1)){
|
||||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4);
|
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4);
|
||||||
IsAccept = Standard_True;
|
IsAccept = Standard_True;
|
||||||
|
myArrIndices(First) = theObj;
|
||||||
}
|
}
|
||||||
else myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
else myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||||
|
|
||||||
@ -77,7 +86,8 @@ Standard_Boolean ShapeAnalysis_BoxBndTreeSelector::
|
|||||||
|
|
||||||
if (IsAccept){
|
if (IsAccept){
|
||||||
SetNb(theObj);
|
SetNb(theObj);
|
||||||
myStop = Standard_True;
|
if(myArrIndices(Last))
|
||||||
|
myStop = Standard_True;
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
else myStop = Standard_False;
|
else myStop = Standard_False;
|
||||||
@ -102,32 +112,39 @@ Standard_Boolean ShapeAnalysis_BoxBndTreeSelector::
|
|||||||
if (min3d > myMin3d)
|
if (min3d > myMin3d)
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
|
|
||||||
|
Standard_Integer minInd = (dm1 > dm2 ? First : Last );
|
||||||
|
Standard_Integer maxInd = (dm1 > dm2 ? Last : First);
|
||||||
|
myArrIndices(minInd) = theObj;
|
||||||
|
if((min3d - myMin3d) > RealSmall())
|
||||||
|
myArrIndices(maxInd) = 0;
|
||||||
|
|
||||||
myMin3d = min3d;
|
myMin3d = min3d;
|
||||||
if (min3d > myTol)
|
if (min3d > myTol)
|
||||||
{
|
{
|
||||||
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetNb(theObj);
|
|
||||||
|
|
||||||
if (min3d == 0)
|
Standard_Integer anObj = (myArrIndices(Last) ? myArrIndices(Last) : myArrIndices(First));
|
||||||
|
SetNb(anObj);
|
||||||
|
|
||||||
|
if (min3d == 0 && minInd == Last)
|
||||||
myStop = Standard_True;
|
myStop = Standard_True;
|
||||||
|
|
||||||
if (dm1 > dm2)
|
if (dm1 > dm2)
|
||||||
{
|
{
|
||||||
dm1 = dm2;
|
dm1 = dm2;
|
||||||
result = res2 + 2;
|
result = res2 + 2;
|
||||||
}
|
}
|
||||||
|
if(anObj == theObj)
|
||||||
|
{
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case 0: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); break;
|
case 0: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE1); break;
|
||||||
case 1: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); break;
|
case 1: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE2); break;
|
||||||
case 2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3); break;
|
case 2: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE3); break;
|
||||||
case 3: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4); break;
|
case 3: myStatus = ShapeExtend::EncodeStatus (ShapeExtend_DONE4); break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <ShapeExtend_Status.hxx>
|
#include <ShapeExtend_Status.hxx>
|
||||||
#include <TopoDS_Vertex.hxx>
|
#include <TopoDS_Vertex.hxx>
|
||||||
#include <TColStd_MapOfInteger.hxx>
|
#include <TColStd_MapOfInteger.hxx>
|
||||||
|
#include <TColStd_Array1OfInteger.hxx>
|
||||||
|
|
||||||
typedef NCollection_UBTree <Standard_Integer , Bnd_Box> ShapeAnalysis_BoxBndTree;
|
typedef NCollection_UBTree <Standard_Integer , Bnd_Box> ShapeAnalysis_BoxBndTree;
|
||||||
|
|
||||||
@ -26,12 +27,18 @@ class ShapeAnalysis_BoxBndTreeSelector
|
|||||||
ShapeAnalysis_BoxBndTreeSelector
|
ShapeAnalysis_BoxBndTreeSelector
|
||||||
(Handle (TopTools_HArray1OfShape) theSeq,
|
(Handle (TopTools_HArray1OfShape) theSeq,
|
||||||
Standard_Boolean theShared)
|
Standard_Boolean theShared)
|
||||||
: mySeq(theSeq), myShared(theShared), myNb(0), myTol(1e-7), myMin3d(1e-7),
|
: mySeq(theSeq), myShared(theShared), myNb(0), myTol(1e-7), myMin3d(1e-7),myArrIndices(1,2),
|
||||||
myStatus(ShapeExtend::EncodeStatus (ShapeExtend_OK)){}
|
myStatus(ShapeExtend::EncodeStatus (ShapeExtend_OK))
|
||||||
|
{
|
||||||
|
myArrIndices.Init(0);
|
||||||
|
}
|
||||||
|
|
||||||
void DefineBoxes (const Bnd_Box& theFBox, const Bnd_Box& theLBox)
|
void DefineBoxes (const Bnd_Box& theFBox, const Bnd_Box& theLBox)
|
||||||
{ myFBox = theFBox;
|
{ myFBox = theFBox;
|
||||||
myLBox = theLBox; }
|
myLBox = theLBox;
|
||||||
|
myArrIndices.Init(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void DefineVertexes (TopoDS_Vertex theVf, TopoDS_Vertex theVl)
|
void DefineVertexes (TopoDS_Vertex theVf, TopoDS_Vertex theVl)
|
||||||
{ myFVertex = theVf;
|
{ myFVertex = theVf;
|
||||||
@ -87,6 +94,7 @@ class ShapeAnalysis_BoxBndTreeSelector
|
|||||||
TColStd_MapOfInteger myList;
|
TColStd_MapOfInteger myList;
|
||||||
Standard_Real myTol;
|
Standard_Real myTol;
|
||||||
Standard_Real myMin3d;
|
Standard_Real myMin3d;
|
||||||
|
TColStd_Array1OfInteger myArrIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user