From c19dd45ee077314e34dd93bc1e7f359d25d41726 Mon Sep 17 00:00:00 2001 From: jgv Date: Thu, 2 Oct 2014 13:36:12 +0400 Subject: [PATCH] 0025298: New option of BRepOffsetAPI_MakeOffset algorithm: processing of sharp corners in mode GeomAbs_Intersection Test cases for issue CR25298 --- src/BRepFill/BRepFill_OffsetWire.cdl | 17 +- src/BRepFill/BRepFill_OffsetWire.cxx | 190 +++++++++-------- src/BRepMAT2d/BRepMAT2d.cdl | 1 + src/BRepMAT2d/BRepMAT2d_BisectingLocus.cdl | 2 + src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx | 4 +- src/BRepTest/BRepTest_CurveCommands.cxx | 23 +- src/BRepTest/BRepTest_MatCommands.cxx | 14 +- src/MAT2d/MAT2d.cdl | 2 +- src/MAT2d/MAT2d_Circuit.cdl | 13 +- src/MAT2d/MAT2d_Circuit.cxx | 231 ++++++++++++--------- src/MAT2d/MAT2d_Tool2d.cdl | 6 +- src/MAT2d/MAT2d_Tool2d.cxx | 13 ++ tests/bugs/modalg_5/bug25298_01 | 36 ++++ tests/bugs/modalg_5/bug25298_02 | 36 ++++ tests/bugs/modalg_5/bug25298_03 | 36 ++++ tests/bugs/modalg_5/bug25298_04 | 36 ++++ tests/bugs/modalg_5/bug25298_05 | 36 ++++ tests/bugs/modalg_5/bug25298_06 | 40 ++++ tests/bugs/modalg_5/bug25298_07 | 40 ++++ tests/bugs/modalg_5/bug25298_08 | 36 ++++ tests/bugs/modalg_5/bug25298_09 | 36 ++++ tests/bugs/modalg_5/bug25298_10 | 36 ++++ tests/bugs/modalg_5/bug25298_11 | 36 ++++ tests/bugs/modalg_5/bug25298_12 | 36 ++++ tests/bugs/modalg_5/bug25298_13 | 36 ++++ tests/bugs/modalg_5/bug25298_14 | 36 ++++ tests/bugs/modalg_5/bug25298_15 | 36 ++++ tests/bugs/modalg_5/bug25298_16 | 36 ++++ 28 files changed, 891 insertions(+), 209 deletions(-) create mode 100755 tests/bugs/modalg_5/bug25298_01 create mode 100755 tests/bugs/modalg_5/bug25298_02 create mode 100755 tests/bugs/modalg_5/bug25298_03 create mode 100755 tests/bugs/modalg_5/bug25298_04 create mode 100755 tests/bugs/modalg_5/bug25298_05 create mode 100755 tests/bugs/modalg_5/bug25298_06 create mode 100755 tests/bugs/modalg_5/bug25298_07 create mode 100755 tests/bugs/modalg_5/bug25298_08 create mode 100755 tests/bugs/modalg_5/bug25298_09 create mode 100755 tests/bugs/modalg_5/bug25298_10 create mode 100755 tests/bugs/modalg_5/bug25298_11 create mode 100755 tests/bugs/modalg_5/bug25298_12 create mode 100755 tests/bugs/modalg_5/bug25298_13 create mode 100755 tests/bugs/modalg_5/bug25298_14 create mode 100755 tests/bugs/modalg_5/bug25298_15 create mode 100755 tests/bugs/modalg_5/bug25298_16 diff --git a/src/BRepFill/BRepFill_OffsetWire.cdl b/src/BRepFill/BRepFill_OffsetWire.cdl index 00bd8e63ac..092db05eeb 100644 --- a/src/BRepFill/BRepFill_OffsetWire.cdl +++ b/src/BRepFill/BRepFill_OffsetWire.cdl @@ -25,10 +25,15 @@ uses Shape from TopoDS, JoinType from GeomAbs, ListOfShape from TopTools, + SequenceOfShape from TopTools, + SequenceOfPnt from TColgp, DataMapOfShapeShape from TopTools, IndexedDataMapOfOrientedShapeListOfShape from BRepFill, + DataMapOfOrientedShapeListOfShape from BRepFill, BisectingLocus from BRepMAT2d, - LinkTopoBilo from BRepMAT2d + LinkTopoBilo from BRepMAT2d, + Bisec from Bisector, + TrimEdgeTool from BRepFill raises ConstructionError from Standard, @@ -116,6 +121,16 @@ is ---Purpose: Add the OffsetWire to and update is static private; + UpdateDetromp (me; Detromp : in out DataMapOfOrientedShapeListOfShape from BRepFill; + Shape1, Shape2 : Shape from TopoDS; + Vertices : SequenceOfShape from TopTools; + Params : SequenceOfPnt from TColgp; + Bisec : Bisec from Bisector; + SOnE : Boolean from Standard; + EOnE : Boolean from Standard; + Trim : TrimEdgeTool from BRepFill) + is static private; + MakeWires (me : in out) ---Purpose: Constructs the wires with the trimmed offset edges. is static private; diff --git a/src/BRepFill/BRepFill_OffsetWire.cxx b/src/BRepFill/BRepFill_OffsetWire.cxx index 77e45e39a6..6d3af0ed0b 100644 --- a/src/BRepFill/BRepFill_OffsetWire.cxx +++ b/src/BRepFill/BRepFill_OffsetWire.cxx @@ -168,15 +168,6 @@ static void EdgeVertices (const TopoDS_Edge& E, } } -static void UpdateDetromp (TopTools_ListOfShape& Detromp1, - TopTools_ListOfShape& Detromp2, - const TopTools_SequenceOfShape& Vertices, - const TColgp_SequenceOfPnt& Params, - const Bisector_Bisec& Bisec, - const Standard_Boolean SOnE, - const Standard_Boolean EOnE, - const BRepFill_TrimEdgeTool& Trim); - static Standard_Boolean VertexFromNode (const Handle(MAT_Node)& aNode, const Standard_Real Offset, @@ -377,9 +368,6 @@ void BRepFill_OffsetWire::Init(const TopoDS_Face& Spine, const GeomAbs_JoinType Join, const Standard_Boolean IsOpenResult) { - Standard_NotImplemented_Raise_if(Join > GeomAbs_Arc, - "Only GeomAbs_Arc is implemented"); - myIsDone = Standard_False; TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD); mySpine = TopoDS::Face(aLocalShape); @@ -420,8 +408,8 @@ void BRepFill_OffsetWire::Init(const TopoDS_Face& Spine, // static BRepMAT2d_Explorer Exp; // Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 End Exp.Perform(myWorkSpine); - myBilo.Compute(Exp,1,MAT_Left,myIsOpenResult); - myLink.Perform(Exp,myBilo); + myBilo.Compute(Exp, 1 ,MAT_Left, myJoinType, myIsOpenResult); + myLink.Perform(Exp, myBilo); } @@ -648,7 +636,7 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset, newExp.Perform(myWorkSpine); BRepMAT2d_BisectingLocus newBilo; BRepMAT2d_LinkTopoBilo newLink; - newBilo.Compute(newExp,1,MAT_Left,myIsOpenResult); + newBilo.Compute(newExp, 1, MAT_Left, myJoinType, myIsOpenResult); if(!newBilo.IsDone()) { @@ -748,9 +736,6 @@ void BRepFill_OffsetWire::PerformWithBiLo const GeomAbs_JoinType Join, const Standard_Real Alt) { - Standard_NotImplemented_Raise_if (Join > GeomAbs_Arc, - "Only GeomAbs_Arc is implemented"); - myIsDone = Standard_False; TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD); myWorkSpine = TopoDS::Face(aLocalShape); @@ -983,7 +968,7 @@ void BRepFill_OffsetWire::PerformWithBiLo if (!Detromp.IsBound(S[1])) Detromp.Bind(S[1],EmptyList); - UpdateDetromp (Detromp(S[0]), Detromp(S[1]), Vertices, Params, + UpdateDetromp (Detromp, S[0], S[1], Vertices, Params, Bisec, StartOnEdge, EndOnEdge, Trim); //---------------------------------------------- // Storage of vertices on parallel edges. @@ -1259,6 +1244,102 @@ void BRepFill_OffsetWire::PrepareSpine() } +//======================================================================= +//function : UpdateDetromp +//purpose : For each interval on bissectrice defined by parameters +// test if the medium point is at a distance > offset +// in this case vertices corresponding to the extremities of the interval +// are ranked in the proofing. +// => If the same vertex appears in the proofing, the +// border of the zone of proximity is tangent to the offset . +//======================================================================= + +void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfShape& Detromp, + const TopoDS_Shape& Shape1, + const TopoDS_Shape& Shape2, + const TopTools_SequenceOfShape& Vertices, + const TColgp_SequenceOfPnt& Params, + const Bisector_Bisec& Bisec, + const Standard_Boolean SOnE, + const Standard_Boolean EOnE, + const BRepFill_TrimEdgeTool& Trim) const +{ + if (myJoinType == GeomAbs_Intersection && + Vertices.Length() == 1 && + !EOnE) + { + TopTools_IndexedMapOfShape Vmap1, Vmap2; + TopExp::MapShapes(Shape1, TopAbs_VERTEX, Vmap1); + TopExp::MapShapes(Shape2, TopAbs_VERTEX, Vmap2); + Standard_Boolean Adjacent = Standard_False; + for (Standard_Integer i = 1; i <= Vmap1.Extent(); i++) + for (Standard_Integer j = 1; j <= Vmap2.Extent(); j++) + if (Vmap1(i).IsSame(Vmap2(j))) + { + Adjacent = Standard_True; + break; + } + if (Adjacent) + { + Detromp(Shape1).Append(Vertices.First()); + Detromp(Shape2).Append(Vertices.First()); + return; + } + } + + Standard_Integer ii = 1; + Standard_Real U1,U2; + TopoDS_Vertex V1,V2; + + Handle(Geom2d_Curve) Bis = Bisec.Value(); + + U1 = Bis->FirstParameter(); + + if (SOnE) { + // the first point of the bissectrice is on the offset + V1 = TopoDS::Vertex(Vertices.Value(ii)); + ii++; + } + + while (ii <= Vertices.Length()) { + U2 = Params.Value(ii).X(); + V2 = TopoDS::Vertex(Vertices.Value(ii)); + + gp_Pnt2d P = Bis->Value((U2 + U1)*0.5); + if (!Trim.IsInside(P)) { + if (!V1.IsNull()) { + Detromp(Shape1).Append(V1); + Detromp(Shape2).Append(V1); + } + Detromp(Shape1).Append(V2); + Detromp(Shape2).Append(V2); + } + U1 = U2; + V1 = V2; + ii ++; + } + + // test medium point between the last parameter and the end of the bissectrice. + U2 = Bis->LastParameter(); + if (!EOnE) { + if (!Precision::IsInfinite(U2)) { + gp_Pnt2d P = Bis->Value((U2 + U1)*0.5); + if (!Trim.IsInside(P)) { + if (!V1.IsNull()) { + Detromp(Shape1).Append(V1); + Detromp(Shape2).Append(V1); + } + } + } + else { + if (!V1.IsNull()) { + Detromp(Shape1).Append(V1); + Detromp(Shape2).Append(V1); + } + } + } +} + //======================================================================= //function : MakeWires //purpose : @@ -1994,77 +2075,6 @@ void MakeOffset (const TopoDS_Edge& E, } } -//======================================================================= -//function : UpdateDetromp -//purpose : For each interval on bissectrice defined by parameters -// test if the medium point is at a distance > offset -// in this case vertices corresponding to the extremities of the interval -// are ranked in the proofing. -// => If the same vertex appears in the proofing, the -// border of the zone of proximity is tangent to the offset . -//======================================================================= - -void UpdateDetromp (TopTools_ListOfShape& Detromp1, - TopTools_ListOfShape& Detromp2, - const TopTools_SequenceOfShape& Vertices, - const TColgp_SequenceOfPnt& Params, - const Bisector_Bisec& Bisec, - const Standard_Boolean SOnE, - const Standard_Boolean EOnE, - const BRepFill_TrimEdgeTool& Trim) -{ - Standard_Integer ii = 1; - Standard_Real U1,U2; - TopoDS_Vertex V1,V2; - - Handle(Geom2d_Curve) Bis = Bisec.Value(); - - U1 = Bis->FirstParameter(); - - if (SOnE) { - // the first point of the bissectrice is on the offset - V1 = TopoDS::Vertex(Vertices.Value(ii)); - ii++; - } - - while (ii <= Vertices.Length()) { - U2 = Params.Value(ii).X(); - V2 = TopoDS::Vertex(Vertices.Value(ii)); - - gp_Pnt2d P = Bis->Value((U2 + U1)*0.5); - if (!Trim.IsInside(P)) { - if (!V1.IsNull()) { - Detromp1.Append(V1); - Detromp2.Append(V1); - } - Detromp1.Append(V2); - Detromp2.Append(V2); - } - U1 = U2; - V1 = V2; - ii ++; - } - - // test medium point between the last parameter and the end of the bissectrice. - U2 = Bis->LastParameter(); - if (!EOnE) { - if (!Precision::IsInfinite(U2)) { - gp_Pnt2d P = Bis->Value((U2 + U1)*0.5); - if (!Trim.IsInside(P)) { - if (!V1.IsNull()) { - Detromp1.Append(V1); - Detromp2.Append(V1); - } - } - } - else { - if (!V1.IsNull()) { - Detromp1.Append(V1); - Detromp2.Append(V1); - } - } - } -} //======================================================================= //function : VertexFromNode diff --git a/src/BRepMAT2d/BRepMAT2d.cdl b/src/BRepMAT2d/BRepMAT2d.cdl index afff536d3d..5674253632 100644 --- a/src/BRepMAT2d/BRepMAT2d.cdl +++ b/src/BRepMAT2d/BRepMAT2d.cdl @@ -19,6 +19,7 @@ package BRepMAT2d ---Purpose: uses + GeomAbs, MAT2d, MAT, TCollection, diff --git a/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cdl b/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cdl index 85884e49b9..9d258ba1d7 100644 --- a/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cdl +++ b/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cdl @@ -52,6 +52,7 @@ class BisectingLocus from BRepMAT2d -- - The Nodes are the extremities of the arcs. uses + JoinType from GeomAbs, Graph from MAT, Arc from MAT, BasicElt from MAT, @@ -74,6 +75,7 @@ is anExplo : in out Explorer from BRepMAT2d; LineIndex : Integer = 1; aSide : Side from MAT = MAT_Left; + aJoinType : JoinType from GeomAbs = GeomAbs_Arc; IsOpenResult : Boolean = Standard_False) --- Purpose : Computation of the Bisector_Locus in a set of Lines -- defined in . diff --git a/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx b/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx index 1ed1a7ea76..fa5d0e3372 100644 --- a/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx +++ b/src/BRepMAT2d/BRepMAT2d_BisectingLocus.cxx @@ -58,6 +58,7 @@ BRepMAT2d_BisectingLocus::BRepMAT2d_BisectingLocus() void BRepMAT2d_BisectingLocus::Compute(BRepMAT2d_Explorer& anExplo, const Standard_Integer IndexLine, const MAT_Side aSide, + const GeomAbs_JoinType aJoinType, const Standard_Boolean IsOpenResult) { MAT2d_Mat2d TheMAT; @@ -87,7 +88,7 @@ void BRepMAT2d_BisectingLocus::Compute(BRepMAT2d_Explorer& anExplo, //---------------------------------------------------------- // Construction du circuit sur lequel est calcule la carte. //---------------------------------------------------------- - Handle(MAT2d_Circuit) ACircuit = new MAT2d_Circuit(IsOpenResult); + Handle(MAT2d_Circuit) ACircuit = new MAT2d_Circuit(aJoinType, IsOpenResult); // Modified by Sergey KHROMOV - Wed Mar 6 17:43:47 2002 Begin // ACircuit->Perform(Figure,IndexLine,(aSide == MAT_Left)); ACircuit->Perform(Figure,anExplo.GetIsClosed(), IndexLine,(aSide == MAT_Left)); @@ -97,6 +98,7 @@ void BRepMAT2d_BisectingLocus::Compute(BRepMAT2d_Explorer& anExplo, // Initialistion du Tool. // ----------------------- theTool.Sense(aSide); + theTool.SetJoinType(aJoinType); theTool.InitItems(ACircuit); // -------------------------------------------- diff --git a/src/BRepTest/BRepTest_CurveCommands.cxx b/src/BRepTest/BRepTest_CurveCommands.cxx index 481fd1aebd..ad290cccfc 100644 --- a/src/BRepTest/BRepTest_CurveCommands.cxx +++ b/src/BRepTest/BRepTest_CurveCommands.cxx @@ -1501,15 +1501,18 @@ Standard_Integer mkoffset(Draw_Interpretor& di, if (n < 5) return 1; char name[100]; - BRepOffsetAPI_MakeOffset Paral; - Paral.Init(GeomAbs_Arc); + BRepOffsetAPI_MakeOffset Paral; + GeomAbs_JoinType theJoinType = GeomAbs_Arc; + if (n >= 6 && strcmp(a[5], "i") == 0) + theJoinType = GeomAbs_Intersection; + Paral.Init(theJoinType); TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_FACE); if ( Base.IsNull()) { Base = DBRep::Get(a[2]); if (Base.IsNull()) return 1; - Paral.Init(GeomAbs_Arc); + Paral.Init(theJoinType); TopExp_Explorer exp; for (exp.Init(Base,TopAbs_WIRE); exp.More(); exp.Next()) { @@ -1529,8 +1532,8 @@ Standard_Integer mkoffset(Draw_Interpretor& di, Nb = Draw::Atoi(a[3]); Standard_Real Alt = 0.; - if ( n == 6) - Alt = Draw::Atof(a[5]); + if ( n == 7) + Alt = Draw::Atof(a[6]); Standard_Integer Compt = 1; @@ -1568,8 +1571,12 @@ Standard_Integer openoffset(Draw_Interpretor& di, TopoDS_Shape Base = DBRep::Get(a[2], TopAbs_WIRE); - BRepOffsetAPI_MakeOffset Paral(TopoDS::Wire(Base), GeomAbs_Arc, Standard_True); + GeomAbs_JoinType theJoinType = GeomAbs_Arc; + if (n == 6 && strcmp(a[5], "i") == 0) + theJoinType = GeomAbs_Intersection; + BRepOffsetAPI_MakeOffset Paral(TopoDS::Wire(Base), theJoinType, Standard_True); + Standard_Real U, dU; Standard_Integer Nb; dU = Draw::Atof(a[4]); @@ -1861,11 +1868,11 @@ void BRepTest::CurveCommands(Draw_Interpretor& theCommands) profile2d,g); theCommands.Add("mkoffset", - "mkoffset result face/compound of wires nboffset stepoffset [alt]",__FILE__, + "mkoffset result face/compound of wires nboffset stepoffset [jointype(a/i) [alt]]",__FILE__, mkoffset); theCommands.Add("openoffset", - "openoffset result wire nboffset stepoffset",__FILE__, + "openoffset result wire nboffset stepoffset [jointype(a/i)]",__FILE__, openoffset); theCommands.Add("mkedge", diff --git a/src/BRepTest/BRepTest_MatCommands.cxx b/src/BRepTest/BRepTest_MatCommands.cxx index cc47a85220..c8ae4e4095 100644 --- a/src/BRepTest/BRepTest_MatCommands.cxx +++ b/src/BRepTest/BRepTest_MatCommands.cxx @@ -100,9 +100,17 @@ static Standard_Integer drawcont(Draw_Interpretor& , Standard_Integer , const ch // calculate the map of locations bisector on the contour defined by // the explorer. //========================================================================== -static Standard_Integer mat(Draw_Interpretor& , Standard_Integer, const char**) +static Standard_Integer mat(Draw_Interpretor&, Standard_Integer n, const char** a) { - MapBiLo.Compute(anExplo,1,SideOfMat); + GeomAbs_JoinType theJoinType = GeomAbs_Arc; + if (n >= 2 && strcmp(a[1], "i") == 0) + theJoinType = GeomAbs_Intersection; + + Standard_Boolean IsOpenResult = Standard_False; + if (n == 3 && strcmp(a[2], "o") == 0) + IsOpenResult = Standard_True; + + MapBiLo.Compute(anExplo, 1, SideOfMat, theJoinType, IsOpenResult); LinkComputed = Standard_False; return 0; @@ -266,7 +274,7 @@ void BRepTest::MatCommands (Draw_Interpretor& theCommands) { theCommands.Add("topoload","load face",__FILE__,topoload); theCommands.Add("drawcont","display current contour",__FILE__,drawcont); - theCommands.Add("mat","computes the mat",__FILE__,mat); + theCommands.Add("mat","computes the mat: mat [a/i [o]]",__FILE__,mat); theCommands.Add("side","side left/right",__FILE__,side); theCommands.Add("result","result",__FILE__,result); theCommands.Add("zone","zone edge or vertex",__FILE__,zone); diff --git a/src/MAT2d/MAT2d.cdl b/src/MAT2d/MAT2d.cdl index 08cecae47b..71ec72cd5b 100644 --- a/src/MAT2d/MAT2d.cdl +++ b/src/MAT2d/MAT2d.cdl @@ -20,7 +20,7 @@ package MAT2d -- Set of geometrys from Geom2d. uses - + GeomAbs, MMgt, gp, Geom2d, diff --git a/src/MAT2d/MAT2d_Circuit.cdl b/src/MAT2d/MAT2d_Circuit.cdl index c2b5251f52..6cbb70bd00 100644 --- a/src/MAT2d/MAT2d_Circuit.cdl +++ b/src/MAT2d/MAT2d_Circuit.cdl @@ -26,7 +26,7 @@ inherits -- uses - + JoinType from GeomAbs, SequenceOfInteger from TColStd, Geometry from Geom2d, SequenceOfGeometry from TColGeom2d, @@ -41,7 +41,8 @@ uses is - Create(IsOpenResult : Boolean from Standard = Standard_False) + Create(aJoinType : JoinType from GeomAbs = GeomAbs_Arc; + IsOpenResult : Boolean from Standard = Standard_False) returns Circuit from MAT2d; ---Category: Computation @@ -53,6 +54,11 @@ is Trigo : Boolean) is static; + IsSharpCorner(me; Geom1, Geom2 : Geometry from Geom2d; + Direction : Real from Standard) + returns Boolean + is static private; + PassByLast(me ; C1,C2 : Connexion from MAT2d) returns Boolean is static private; @@ -130,7 +136,8 @@ fields connexionMap : DataMapOfIntegerConnexion from MAT2d; linkRefEqui : DataMapOfBiIntSequenceOfInteger from MAT2d; linesLength : SequenceOfInteger from TColStd; - myIsOpenResult : Boolean from Standard; + myJoinType : JoinType from GeomAbs; + myIsOpenResult : Boolean from Standard; end Circuit; diff --git a/src/MAT2d/MAT2d_Circuit.cxx b/src/MAT2d/MAT2d_Circuit.cxx index b8810625d4..49bfa1b5e3 100644 --- a/src/MAT2d/MAT2d_Circuit.cxx +++ b/src/MAT2d/MAT2d_Circuit.cxx @@ -67,16 +67,15 @@ static Standard_Real CrossProd(const Handle(Geom2d_Geometry)& Geom1, const Handle(Geom2d_Geometry)& Geom2, Standard_Real& DotProd); -static Standard_Boolean IsSharpCorner (const Handle(Geom2d_Geometry)& Geom1, - const Handle(Geom2d_Geometry)& Geom2, - const Standard_Real& Direction); //============================================================================= //function : Constructor //purpose : //============================================================================= -MAT2d_Circuit::MAT2d_Circuit(const Standard_Boolean IsOpenResult) +MAT2d_Circuit::MAT2d_Circuit(const GeomAbs_JoinType aJoinType, + const Standard_Boolean IsOpenResult) { + myJoinType = aJoinType; myIsOpenResult = IsOpenResult; } @@ -204,6 +203,133 @@ void MAT2d_Circuit::Perform ConstructCircuit(FigItem,IndRefLine,Road); } +//======================================================================= +//function : IsSharpCorner +//purpose : Return True Si le point commun entre et est +// une cassure saillante par rapport +//======================================================================= + +Standard_Boolean MAT2d_Circuit::IsSharpCorner(const Handle(Geom2d_Geometry)& Geom1, + const Handle(Geom2d_Geometry)& Geom2, + const Standard_Real Direction) const +{ + Standard_Real DotProd; + Standard_Real ProVec = CrossProd (Geom1,Geom2,DotProd); + Standard_Integer NbTest = 1; + Standard_Real DU = Precision::Confusion(); + Handle(Geom2d_TrimmedCurve) C1,C2; + + C1= Handle(Geom2d_TrimmedCurve)::DownCast(Geom1); + C2= Handle(Geom2d_TrimmedCurve)::DownCast(Geom2); +// Modified by Sergey KHROMOV - Thu Oct 24 19:02:46 2002 Begin +// Add the same criterion as it is in MAT2d_Circuit::InitOpen(..) +// Standard_Real TolAng = 1.E-5; + Standard_Real TolAng = 1.E-8; +// Modified by Sergey KHROMOV - Thu Oct 24 19:02:47 2002 End + + if (myJoinType == GeomAbs_Arc) + { + while (NbTest <= 10) { + if ((ProVec)*Direction < -TolAng) + return Standard_True; // Saillant. + if ((ProVec)*Direction > TolAng) + return Standard_False; // Rentrant. + else { + if (DotProd > 0) { + return Standard_False; // Plat. + } + TolAng = 1.E-8; + Standard_Real U1 = C1->LastParameter() - NbTest*DU; + Standard_Real U2 = C2->FirstParameter() + NbTest*DU; + gp_Dir2d Dir1(C1->DN(U1,1)); + gp_Dir2d Dir2(C2->DN(U2,1)); + DotProd = Dir1.Dot(Dir2); + ProVec = Dir1^Dir2; + NbTest++; + } + } + + + + // Rebroussement. + // on calculde des paralleles aux deux courbes du cote du domaine + // de calcul + // Si pas dintersection => saillant. + // Sinon => rentrant. + Standard_Real D ; + Standard_Real Tol = Precision::Confusion(); + Standard_Real MilC1 = (C1->LastParameter() + C1->FirstParameter())*0.5; + Standard_Real MilC2 = (C2->LastParameter() + C2->FirstParameter())*0.5; + gp_Pnt2d P = C1->Value(C1->LastParameter()); + gp_Pnt2d P1 = C1->Value(MilC1); + gp_Pnt2d P2 = C2->Value(MilC2); + + D = Min(P1.Distance(P),P2.Distance(P)); + D /= 10; + + if (Direction > 0.) D = -D; + + Handle(Geom2dAdaptor_HCurve) HC1 = new Geom2dAdaptor_HCurve(C1); + Handle(Geom2dAdaptor_HCurve) HC2 = new Geom2dAdaptor_HCurve(C2); + Adaptor3d_OffsetCurve OC1(HC1,D,MilC1,C1->LastParameter()); + Adaptor3d_OffsetCurve OC2(HC2,D,C2->FirstParameter(),MilC2); + Geom2dInt_GInter Intersect; + Intersect.Perform(OC1,OC2,Tol,Tol); + +#ifdef DEB + static Standard_Boolean Affich = 0; + if (Affich) { +#ifdef DRAW + Standard_Real DU1 = (OC1.LastParameter() - OC1.FirstParameter())/9.; + Standard_Real DU2 = (OC2.LastParameter() - OC2.FirstParameter())/9.; + for (Standard_Integer ki = 0; ki <= 9; ki++) { + gp_Pnt2d P1 = OC1.Value(OC1.FirstParameter()+ki*DU1); + gp_Pnt2d P2 = OC2.Value(OC2.FirstParameter()+ki*DU2); + Handle(Draw_Marker2D) dr1 = new Draw_Marker2D(P1,Draw_Plus,Draw_vert); + Handle(Draw_Marker2D) dr2 = new Draw_Marker2D(P2,Draw_Plus,Draw_rouge); + dout << dr1; + dout << dr2; + } + dout.Flush(); +#endif + } +#endif + + if (Intersect.IsDone() && !Intersect.IsEmpty()) { + return Standard_False; + } + else { + return Standard_True; + } + } //end of if (myJoinType == GeomAbs_Arc) + else if (myJoinType == GeomAbs_Intersection) + { + if (Abs(ProVec) <= TolAng && + DotProd < 0) + { + while (NbTest <= 10) + { + Standard_Real U1 = C1->LastParameter() - NbTest*DU; + Standard_Real U2 = C2->FirstParameter() + NbTest*DU; + gp_Dir2d Dir1(C1->DN(U1,1)); + gp_Dir2d Dir2(C2->DN(U2,1)); + DotProd = Dir1.Dot(Dir2); + ProVec = Dir1^Dir2; + if ((ProVec)*Direction < -TolAng) + return Standard_True; // Saillant. + if ((ProVec)*Direction > TolAng) + return Standard_False; // Rentrant. + + NbTest++; + } + return Standard_False; + } + else + return Standard_False; + } + return Standard_False; +} + //======================================================================= //function : SubSequence //purpose : @@ -736,103 +862,6 @@ static Standard_Real CrossProd(const Handle(Geom2d_Geometry)& Geom1, } -//======================================================================= -//function : IsSharpCorner -//purpose : Return True Si le point commun entre et est -// une cassure saillante par rapport -//======================================================================= - -static Standard_Boolean IsSharpCorner (const Handle(Geom2d_Geometry)& Geom1, - const Handle(Geom2d_Geometry)& Geom2, - const Standard_Real& Direction) -{ - Standard_Real DotProd; - Standard_Real ProVec = CrossProd (Geom1,Geom2,DotProd); - Standard_Integer NbTest = 1; - Standard_Real DU = Precision::Confusion(); - Handle(Geom2d_TrimmedCurve) C1,C2; - - C1= Handle(Geom2d_TrimmedCurve)::DownCast(Geom1); - C2= Handle(Geom2d_TrimmedCurve)::DownCast(Geom2); -// Modified by Sergey KHROMOV - Thu Oct 24 19:02:46 2002 Begin -// Add the same criterion as it is in MAT2d_Circuit::InitOpen(..) -// Standard_Real TolAng = 1.E-5; - Standard_Real TolAng = 1.E-8; -// Modified by Sergey KHROMOV - Thu Oct 24 19:02:47 2002 End - - while (NbTest <= 10) { - if ((ProVec)*Direction < -TolAng) - return Standard_True; // Saillant. - if ((ProVec)*Direction > TolAng) - return Standard_False; // Rentrant. - else { - if (DotProd > 0) { - return Standard_False; // Plat. - } - TolAng = 1.E-8; - Standard_Real U1 = C1->LastParameter() - NbTest*DU; - Standard_Real U2 = C2->FirstParameter() + NbTest*DU; - gp_Dir2d Dir1(C1->DN(U1,1)); - gp_Dir2d Dir2(C2->DN(U2,1)); - DotProd = Dir1.Dot(Dir2); - ProVec = Dir1^Dir2; - NbTest++; - } - } - - - - // Rebroussement. - // on calculde des paralleles aux deux courbes du cote du domaine - // de calcul - // Si pas dintersection => saillant. - // Sinon => rentrant. - Standard_Real D ; - Standard_Real Tol = Precision::Confusion(); - Standard_Real MilC1 = (C1->LastParameter() + C1->FirstParameter())*0.5; - Standard_Real MilC2 = (C2->LastParameter() + C2->FirstParameter())*0.5; - gp_Pnt2d P = C1->Value(C1->LastParameter()); - gp_Pnt2d P1 = C1->Value(MilC1); - gp_Pnt2d P2 = C2->Value(MilC2); - - D = Min(P1.Distance(P),P2.Distance(P)); - D /= 10; - - if (Direction > 0.) D = -D; - - Handle(Geom2dAdaptor_HCurve) HC1 = new Geom2dAdaptor_HCurve(C1); - Handle(Geom2dAdaptor_HCurve) HC2 = new Geom2dAdaptor_HCurve(C2); - Adaptor3d_OffsetCurve OC1(HC1,D,MilC1,C1->LastParameter()); - Adaptor3d_OffsetCurve OC2(HC2,D,C2->FirstParameter(),MilC2); - Geom2dInt_GInter Intersect; - Intersect.Perform(OC1,OC2,Tol,Tol); - -#ifdef DEB - static Standard_Boolean Affich = 0; - if (Affich) { -#ifdef DRAW - Standard_Real DU1 = (OC1.LastParameter() - OC1.FirstParameter())/9.; - Standard_Real DU2 = (OC2.LastParameter() - OC2.FirstParameter())/9.; - for (Standard_Integer ki = 0; ki <= 9; ki++) { - gp_Pnt2d P1 = OC1.Value(OC1.FirstParameter()+ki*DU1); - gp_Pnt2d P2 = OC2.Value(OC2.FirstParameter()+ki*DU2); - Handle(Draw_Marker2D) dr1 = new Draw_Marker2D(P1,Draw_Plus,Draw_vert); - Handle(Draw_Marker2D) dr2 = new Draw_Marker2D(P2,Draw_Plus,Draw_rouge); - dout << dr1; - dout << dr2; - } - dout.Flush(); -#endif - } -#endif - - if (Intersect.IsDone() && !Intersect.IsEmpty()) { - return Standard_False; - } - else { - return Standard_True; - } -} diff --git a/src/MAT2d/MAT2d_Tool2d.cdl b/src/MAT2d/MAT2d_Tool2d.cdl index 1b6cc0c818..a5740f072a 100644 --- a/src/MAT2d/MAT2d_Tool2d.cdl +++ b/src/MAT2d/MAT2d_Tool2d.cdl @@ -21,7 +21,7 @@ class Tool2d from MAT2d uses - + JoinType from GeomAbs, Bisec from Bisector, Side from MAT, Bisector from MAT, @@ -47,6 +47,9 @@ is --- Purpose :