1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0027909: Modeling Algorithms - Exception during offset computation

Added function ChFi3d::IsTangentFaces for more accurate definition of connection type.
Test cases have been changed according to the current behavior.
This commit is contained in:
akaftasev
2020-05-12 12:21:59 +03:00
committed by bugmaster
parent e8e8b273bb
commit 3f54cc41a8
35 changed files with 212 additions and 189 deletions

View File

@@ -31,6 +31,11 @@
#include <TopoDS_Edge.hxx>
#include <BRepTools.hxx>
#include <IntTools_Tools.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRepTopAdaptor_TopolTool.hxx>
#include <LocalAnalysis_SurfaceContinuity.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
static void Correct2dPoint(const TopoDS_Face& theF, gp_Pnt2d& theP2d);
//
@@ -101,7 +106,6 @@ ChFiDS_TypeOfConcavity ChFi3d::DefineConnectType(const TopoDS_Edge& E,
gp_Vec ProVec = DN1^DN2;
Standard_Real NormProVec = ProVec.Magnitude();
if (NormProVec < SinTol) {
// plane
if (DN1.Dot(DN2) > 0) {
@@ -131,6 +135,95 @@ ChFiDS_TypeOfConcavity ChFi3d::DefineConnectType(const TopoDS_Edge& E,
}
}
//=======================================================================
//function : IsTangentFaces
//purpose :
//=======================================================================
Standard_Boolean ChFi3d::IsTangentFaces(const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace1,
const TopoDS_Face& theFace2,
const GeomAbs_Shape Order)
{
if (Order == GeomAbs_G1 && BRep_Tool::Continuity(theEdge, theFace1, theFace2) != GeomAbs_C0)
return Standard_True;
Standard_Real TolC0 = Max(0.001, 1.5*BRep_Tool::Tolerance(theEdge));
Standard_Real aFirst;
Standard_Real aLast;
// Obtaining of pcurves of edge on two faces.
const Handle(Geom2d_Curve) aC2d1 = BRep_Tool::CurveOnSurface
(theEdge, theFace1, aFirst, aLast);
//For the case of seam edge
TopoDS_Edge EE = theEdge;
if (theFace1.IsSame(theFace2))
EE.Reverse();
const Handle(Geom2d_Curve) aC2d2 = BRep_Tool::CurveOnSurface
(EE, theFace2, aFirst, aLast);
if (aC2d1.IsNull() || aC2d2.IsNull())
return Standard_False;
// Obtaining of two surfaces from adjacent faces.
Handle(Geom_Surface) aSurf1 = BRep_Tool::Surface(theFace1);
Handle(Geom_Surface) aSurf2 = BRep_Tool::Surface(theFace2);
if (aSurf1.IsNull() || aSurf2.IsNull())
return Standard_False;
// Computation of the number of samples on the edge.
BRepAdaptor_Surface aBAS1(theFace1);
BRepAdaptor_Surface aBAS2(theFace2);
Handle(BRepAdaptor_HSurface) aBAHS1 = new BRepAdaptor_HSurface(aBAS1);
Handle(BRepAdaptor_HSurface) aBAHS2 = new BRepAdaptor_HSurface(aBAS2);
Handle(BRepTopAdaptor_TopolTool) aTool1 = new BRepTopAdaptor_TopolTool(aBAHS1);
Handle(BRepTopAdaptor_TopolTool) aTool2 = new BRepTopAdaptor_TopolTool(aBAHS2);
Standard_Integer aNbSamples1 = aTool1->NbSamples();
Standard_Integer aNbSamples2 = aTool2->NbSamples();
Standard_Integer aNbSamples = Max(aNbSamples1, aNbSamples2);
// Computation of the continuity.
Standard_Real aPar;
Standard_Real aDelta = (aLast - aFirst) / (aNbSamples - 1);
Standard_Integer i, nbNotDone = 0;
for (i = 1, aPar = aFirst; i <= aNbSamples; i++, aPar += aDelta) {
if (i == aNbSamples) aPar = aLast;
LocalAnalysis_SurfaceContinuity aCont(aC2d1, aC2d2, aPar,
aSurf1, aSurf2, Order,
0.001, TolC0, 0.1, 0.1, 0.1);
if (!aCont.IsDone())
{
nbNotDone++;
continue;
}
if (Order == GeomAbs_G1)
{
if (!aCont.IsG1())
return Standard_False;
}
else if (!aCont.IsG2())
return Standard_False;
}
if (nbNotDone == aNbSamples)
return Standard_False;
//Compare normals of tangent faces in the middle point
Standard_Real MidPar = (aFirst + aLast) / 2.;
gp_Pnt2d uv1 = aC2d1->Value(MidPar);
gp_Pnt2d uv2 = aC2d2->Value(MidPar);
gp_Dir normal1, normal2;
TopOpeBRepTool_TOOL::Nt(uv1, theFace1, normal1);
TopOpeBRepTool_TOOL::Nt(uv2, theFace2, normal2);
Standard_Real dot = normal1.Dot(normal2);
if (dot < 0.)
return Standard_False;
return Standard_True;
}
//=======================================================================
//function : ConcaveSide
//purpose : calculate the concave face at the neighborhood of the border of

View File

@@ -25,6 +25,7 @@
#include <TopAbs_Orientation.hxx>
#include <Standard_Boolean.hxx>
#include <ChFiDS_TypeOfConcavity.hxx>
#include <GeomAbs_Shape.hxx>
class BRepAdaptor_Surface;
class TopoDS_Edge;
class TopoDS_Face;
@@ -47,7 +48,13 @@ public:
const TopoDS_Face& F2,
const Standard_Real SinTol,
const Standard_Boolean CorrectPoint);
//! Returns true if theEdge between theFace1 and theFace2 is tangent
Standard_EXPORT static Standard_Boolean IsTangentFaces (const TopoDS_Edge& theEdge,
const TopoDS_Face& theFace1,
const TopoDS_Face& theFace2,
const GeomAbs_Shape Order = GeomAbs_G1);
//! Returns Reversed in Or1 and(or) Or2 if
//! the concave edge defined by the interior of faces F1 and F2,
//! in the neighbourhood of their boundary E is of the edge opposite to the

View File

@@ -4594,93 +4594,6 @@ void ChFi3d_ChercheBordsLibres(const ChFiDS_Map & myVEMap,
}
}
Standard_Boolean ChFi3d_isTangentFaces(const TopoDS_Edge &theEdge,
const TopoDS_Face &theFace1,
const TopoDS_Face &theFace2,
const GeomAbs_Shape Order)
{
if (Order == GeomAbs_G1 &&
BRep_Tool::Continuity( theEdge, theFace1, theFace2 ) != GeomAbs_C0)
return Standard_True;
Standard_Real TolC0 = Max(0.001, 1.5*BRep_Tool::Tolerance(theEdge));
Standard_Real aFirst;
Standard_Real aLast;
// Obtaining of pcurves of edge on two faces.
const Handle(Geom2d_Curve) aC2d1 = BRep_Tool::CurveOnSurface
(theEdge, theFace1, aFirst, aLast);
//For the case of seam edge
TopoDS_Edge EE = theEdge;
if (theFace1.IsSame(theFace2))
EE.Reverse();
const Handle(Geom2d_Curve) aC2d2 = BRep_Tool::CurveOnSurface
(EE, theFace2, aFirst, aLast);
if (aC2d1.IsNull() || aC2d2.IsNull())
return Standard_False;
// Obtaining of two surfaces from adjacent faces.
Handle(Geom_Surface) aSurf1 = BRep_Tool::Surface(theFace1);
Handle(Geom_Surface) aSurf2 = BRep_Tool::Surface(theFace2);
if (aSurf1.IsNull() || aSurf2.IsNull())
return Standard_False;
// Computation of the number of samples on the edge.
BRepAdaptor_Surface aBAS1(theFace1);
BRepAdaptor_Surface aBAS2(theFace2);
Handle(BRepAdaptor_HSurface) aBAHS1 = new BRepAdaptor_HSurface(aBAS1);
Handle(BRepAdaptor_HSurface) aBAHS2 = new BRepAdaptor_HSurface(aBAS2);
Handle(BRepTopAdaptor_TopolTool) aTool1 = new BRepTopAdaptor_TopolTool(aBAHS1);
Handle(BRepTopAdaptor_TopolTool) aTool2 = new BRepTopAdaptor_TopolTool(aBAHS2);
Standard_Integer aNbSamples1 = aTool1->NbSamples();
Standard_Integer aNbSamples2 = aTool2->NbSamples();
Standard_Integer aNbSamples = Max(aNbSamples1, aNbSamples2);
// Computation of the continuity.
Standard_Real aPar;
Standard_Real aDelta = (aLast - aFirst)/(aNbSamples - 1);
Standard_Integer i, nbNotDone = 0;
for (i = 1, aPar = aFirst; i <= aNbSamples; i++, aPar += aDelta) {
if (i == aNbSamples) aPar = aLast;
LocalAnalysis_SurfaceContinuity aCont(aC2d1, aC2d2, aPar,
aSurf1, aSurf2, Order,
0.001, TolC0, 0.1, 0.1, 0.1);
if (!aCont.IsDone())
{
nbNotDone++;
continue;
}
if (Order == GeomAbs_G1)
{
if (!aCont.IsG1())
return Standard_False;
}
else if (!aCont.IsG2())
return Standard_False;
}
if (nbNotDone == aNbSamples)
return Standard_False;
//Compare normals of tangent faces in the middle point
Standard_Real MidPar = (aFirst + aLast)/2.;
gp_Pnt2d uv1 = aC2d1->Value(MidPar);
gp_Pnt2d uv2 = aC2d2->Value(MidPar);
gp_Dir normal1, normal2;
TopOpeBRepTool_TOOL::Nt( uv1, theFace1, normal1 );
TopOpeBRepTool_TOOL::Nt( uv2, theFace2, normal2 );
Standard_Real dot = normal1.Dot(normal2);
if (dot < 0.)
return Standard_False;
return Standard_True;
}
//=======================================================================
//function : NbNotDegeneratedEdges
//purpose : calculate the number of non-degenerated edges of Map VEMap(Vtx)
@@ -4698,6 +4611,7 @@ Standard_Integer ChFi3d_NbNotDegeneratedEdges (const TopoDS_Vertex& Vtx,
return nba;
}
//=======================================================================
//function : NbSharpEdges
//purpose : calculate the number of sharp edges of Map VEMap(Vtx)
@@ -4716,7 +4630,7 @@ Standard_Integer ChFi3d_NbSharpEdges (const TopoDS_Vertex& Vtx,
{
TopoDS_Face F1, F2;
ChFi3d_conexfaces(cur, F1, F2, EFMap);
if (!F2.IsNull() && ChFi3d_isTangentFaces(cur, F1, F2, GeomAbs_G2))
if (!F2.IsNull() && ChFi3d::IsTangentFaces(cur, F1, F2, GeomAbs_G2))
nba--;
}
}

View File

@@ -552,11 +552,6 @@ void ChFi3d_ChercheBordsLibres(const ChFiDS_Map & myVEMap,
TopoDS_Edge & edgelibre1,
TopoDS_Edge & edgelibre2);
Standard_Boolean ChFi3d_isTangentFaces(const TopoDS_Edge &theEdge,
const TopoDS_Face &theFace1,
const TopoDS_Face &theFace2,
const GeomAbs_Shape Order = GeomAbs_G1);
Standard_Integer ChFi3d_NbNotDegeneratedEdges (const TopoDS_Vertex& Vtx,
const ChFiDS_Map& VEMap);
Standard_Integer ChFi3d_NumberOfEdges(const TopoDS_Vertex& Vtx,

View File

@@ -591,7 +591,7 @@ Standard_Boolean ChFi3d_Builder::FaceTangency(const TopoDS_Edge& E0,
if(Nbf < 2) return Standard_False;
// Modified by Sergey KHROMOV - Fri Dec 21 17:44:19 2001 Begin
//if (BRep_Tool::Continuity(E1,F[0],F[1]) != GeomAbs_C0) {
if (ChFi3d_isTangentFaces(E1,F[0],F[1])) {
if (ChFi3d::IsTangentFaces(E1,F[0],F[1])) {
// Modified by Sergey KHROMOV - Fri Dec 21 17:44:21 2001 End
return Standard_False;
}
@@ -610,7 +610,7 @@ Standard_Boolean ChFi3d_Builder::FaceTangency(const TopoDS_Edge& E0,
if(Nbf < 2) return Standard_False;
// Modified by Sergey KHROMOV - Tue Dec 18 18:10:40 2001 Begin
// if (BRep_Tool::Continuity(Ec,F[0],F[1]) < GeomAbs_G1) {
if (!ChFi3d_isTangentFaces(Ec,F[0],F[1])) {
if (!ChFi3d::IsTangentFaces(Ec,F[0],F[1])) {
// Modified by Sergey KHROMOV - Tue Dec 18 18:10:41 2001 End
return Standard_False;
}
@@ -736,7 +736,7 @@ void ChFi3d_Builder::PerformExtremity (const Handle(ChFiDS_Spine)& Spine)
continue;
TopoDS_Face F1, F2;
ChFi3d_conexfaces(anEdge, F1, F2, myEFMap);
if (!F2.IsNull() && ChFi3d_isTangentFaces(anEdge, F1, F2, GeomAbs_G2)) //smooth edge
if (!F2.IsNull() && ChFi3d::IsTangentFaces(anEdge, F1, F2, GeomAbs_G2)) //smooth edge
{
if (!F1.IsSame(F2))
NbG1Connections++;
@@ -853,7 +853,7 @@ Standard_Boolean ChFi3d_Builder::PerformElement(const Handle(ChFiDS_Spine)& Spin
if(ff1.IsNull() || ff2.IsNull()) return 0;
// Modified by Sergey KHROMOV - Fri Dec 21 17:46:22 2001 End
//if(BRep_Tool::Continuity(Ec,ff1,ff2) != GeomAbs_C0) return 0;
if (ChFi3d_isTangentFaces(Ec,ff1,ff2)) return 0;
if (ChFi3d::IsTangentFaces(Ec,ff1,ff2)) return 0;
// Modified by Sergey KHROMOV - Fri Dec 21 17:46:24 2001 Begin
TopoDS_Face FirstFace = ff1;

View File

@@ -250,7 +250,7 @@ static Standard_Boolean BonVoisin(const gp_Pnt& Point,
// Modified by Sergey KHROMOV - Fri Dec 21 17:12:48 2001 Begin
// Standard_Boolean istg =
// BRep_Tool::Continuity(ecur,ff,F) != GeomAbs_C0;
Standard_Boolean istg = ChFi3d_isTangentFaces(ecur,ff,F);
Standard_Boolean istg = ChFi3d::IsTangentFaces(ecur,ff,F);
// Modified by Sergey KHROMOV - Fri Dec 21 17:12:51 2001 End
if((!issame || (issame && isreallyclosed)) && istg) {
found = 1;
@@ -456,7 +456,7 @@ Standard_Boolean IsG1(const ChFiDS_Map& TheMap,
FVoi = TopoDS::Face(It.Value());
// Modified by Sergey KHROMOV - Fri Dec 21 17:09:32 2001 Begin
// if (BRep_Tool::Continuity(E,FRef,FVoi) != GeomAbs_C0) {
if (ChFi3d_isTangentFaces(E,FRef,FVoi)) {
if (ChFi3d::IsTangentFaces(E,FRef,FVoi)) {
// Modified by Sergey KHROMOV - Fri Dec 21 17:09:33 2001 End
return Standard_True;
}
@@ -476,7 +476,7 @@ Standard_Boolean IsG1(const ChFiDS_Map& TheMap,
FVoi = FRef;
// Modified by Sergey KHROMOV - Fri Dec 21 17:15:12 2001 Begin
// if (BRep_Tool::Continuity(E,FRef,FRef) >= GeomAbs_G1) {
if (ChFi3d_isTangentFaces(E,FRef,FRef)) {
if (ChFi3d::IsTangentFaces(E,FRef,FRef)) {
// Modified by Sergey KHROMOV - Fri Dec 21 17:15:16 2001 End
return Standard_True;
}

View File

@@ -334,7 +334,7 @@ static Standard_Boolean IntersUpdateOnSame(Handle(GeomAdaptor_HSurface)& HGs,
if ( Update(HBs,Hc3df,FIop,CPop,FprolUV,isFirst,c3dU) )
return Standard_True;
if (!ChFi3d_isTangentFaces(Eprol,Fprol,Fop))
if (!ChFi3d::IsTangentFaces(Eprol,Fprol,Fop))
return Standard_False;
Handle(Geom2d_Curve) gpcprol = BRep_Tool::CurveOnSurface(Eprol,Fprol,uf,ul);
@@ -1639,14 +1639,14 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
ChFi3d_edge_common_faces(myEFMap(Eadj1),Fga,Fdr);
// Modified by Sergey KHROMOV - Fri Dec 21 17:57:32 2001 Begin
// reg1=BRep_Tool::Continuity(Eadj1,Fga,Fdr)!=GeomAbs_C0;
reg1 = ChFi3d_isTangentFaces(Eadj1,Fga,Fdr);
reg1 = ChFi3d::IsTangentFaces(Eadj1,Fga,Fdr);
// Modified by Sergey KHROMOV - Fri Dec 21 17:57:33 2001 End
if (F2.IsSame(facecouture)) Eadj2=edgecouture;
else ChFi3d_cherche_element(Vtx,EdgeSpine,F2,Eadj2,Vbid1);
ChFi3d_edge_common_faces(myEFMap(Eadj2),Fga,Fdr);
// Modified by Sergey KHROMOV - Fri Dec 21 17:58:22 2001 Begin
// reg2=BRep_Tool::Continuity(Eadj2,Fga,Fdr)!=GeomAbs_C0;
reg2 = ChFi3d_isTangentFaces(Eadj2,Fga,Fdr);
reg2 = ChFi3d::IsTangentFaces(Eadj2,Fga,Fdr);
// Modified by Sergey KHROMOV - Fri Dec 21 17:58:24 2001 End
// two faces common to the edge are found
@@ -2067,9 +2067,9 @@ void ChFi3d_Builder::PerformIntersectionAtEnd(const Standard_Integer Index)
else if (nbarete==5) {
//pro15368
// Modified by Sergey KHROMOV - Fri Dec 21 18:07:43 2001 End
Standard_Boolean isTangent0 = ChFi3d_isTangentFaces(Edge[0],F1,Face[0]);
Standard_Boolean isTangent1 = ChFi3d_isTangentFaces(Edge[1],Face[0],Face[1]);
Standard_Boolean isTangent2 = ChFi3d_isTangentFaces(Edge[2],Face[1],Face[2]);
Standard_Boolean isTangent0 = ChFi3d::IsTangentFaces(Edge[0],F1,Face[0]);
Standard_Boolean isTangent1 = ChFi3d::IsTangentFaces(Edge[1],Face[0],Face[1]);
Standard_Boolean isTangent2 = ChFi3d::IsTangentFaces(Edge[2],Face[1],Face[2]);
if ((isTangent0 || isTangent2) && isTangent1) {
// GeomAbs_Shape cont0,cont1,cont2;
// cont0=BRep_Tool::Continuity(Edge[0],F1,Face[0]);
@@ -3970,7 +3970,7 @@ void ChFi3d_Builder::IntersectMoreCorner(const Standard_Integer Index)
inters = Update(HBs,Hc3df,FiopArc,CPopArc,p2dbout,isfirst,wop);
// Modified by Sergey KHROMOV - Fri Dec 21 18:08:27 2001 Begin
// if(!inters && BRep_Tool::Continuity(Arcprol,Fv,Fop) != GeomAbs_C0){
if(!inters && ChFi3d_isTangentFaces(Arcprol,Fv,Fop)){
if(!inters && ChFi3d::IsTangentFaces(Arcprol,Fv,Fop)){
// Modified by Sergey KHROMOV - Fri Dec 21 18:08:29 2001 End
// Arcprol is an edge of tangency, ultimate adjustment by an extrema curve/curve is attempted.
Standard_Real ff,ll;

View File

@@ -144,6 +144,7 @@
#include <TopOpeBRepDS_Transition.hxx>
#include <TopTools_Array2OfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <ChFi3d.hxx>
// performances
#ifdef OCCT_DEBUG
@@ -1261,7 +1262,7 @@ void ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
// Modified by Sergey KHROMOV - Fri Dec 21 18:11:02 2001 Begin
// regul.SetValue(ic,BRep_Tool::Continuity(TopoDS::Edge(Evive.Value(ic)),F1,F2)
// !=GeomAbs_C0);
regul.SetValue(ic, ChFi3d_isTangentFaces(TopoDS::Edge(Evive.Value(ic)),F1,F2));
regul.SetValue(ic, ChFi3d::IsTangentFaces(TopoDS::Edge(Evive.Value(ic)),F1,F2));
// Modified by Sergey KHROMOV - Fri Dec 21 18:11:07 2001 End
}
}