From bda8360543a67cb7e3df4a27acfd9eae732bd68c Mon Sep 17 00:00:00 2001 From: jgv Date: Fri, 12 Jul 2013 12:24:21 +0400 Subject: [PATCH] 0023625: New functionality building reflect lines on a shape Adding test case for this fix; Small corrections --- adm/UDLIST | 1 + src/BRep/BRep_Tool.cdl | 7 + src/BRep/BRep_Tool.cxx | 19 +++ src/Contap/Contap_ContourGen_2.gxx | 3 +- src/HLRAppli/HLRAppli.cdl | 34 +++++ src/HLRAppli/HLRAppli_ReflectLines.cdl | 60 +++++++++ src/HLRAppli/HLRAppli_ReflectLines.cxx | 93 +++++++++++++ src/HLRBRep/HLRBRep.cdl | 4 + src/HLRBRep/HLRBRep.cxx | 53 ++++++++ src/HLRBRep/HLRBRep_Data.cdl | 3 +- src/HLRBRep/HLRBRep_HLRToShape.cdl | 14 +- src/HLRBRep/HLRBRep_HLRToShape.cxx | 42 ++++-- src/HLRBRep/HLRBRep_HLRToShape.lxx | 8 ++ src/HLRBRep/HLRBRep_Hider.cxx | 28 +++- src/HLRTest/HLRTest.cxx | 44 ++++++ src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx | 109 ++++++++++++++- src/IntStart/IntStart_SearchOnBoundaries.cdl | 3 +- .../IntStart_SearchOnBoundaries_1.gxx | 125 ++++++++++++++++-- .../IntStart_SearchOnBoundaries_2.gxx | 5 +- src/TKHLR/PACKAGES | 1 + tests/bugs/modalg_5/bug23625_1 | 20 +++ tests/bugs/modalg_5/bug23625_2 | 20 +++ tests/bugs/modalg_5/bug23625_3 | 20 +++ tests/bugs/modalg_5/bug23625_4 | 20 +++ tests/bugs/modalg_5/bug23625_5 | 20 +++ 25 files changed, 715 insertions(+), 41 deletions(-) create mode 100644 src/HLRAppli/HLRAppli.cdl create mode 100644 src/HLRAppli/HLRAppli_ReflectLines.cdl create mode 100644 src/HLRAppli/HLRAppli_ReflectLines.cxx create mode 100755 tests/bugs/modalg_5/bug23625_1 create mode 100755 tests/bugs/modalg_5/bug23625_2 create mode 100755 tests/bugs/modalg_5/bug23625_3 create mode 100755 tests/bugs/modalg_5/bug23625_4 create mode 100755 tests/bugs/modalg_5/bug23625_5 diff --git a/adm/UDLIST b/adm/UDLIST index 5e4bd9427b..eb7824cb39 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -146,6 +146,7 @@ p GeomPlate p HLRAlgo p HLRBRep p HLRTopoBRep +p HLRAppli p Hatch p HatchGen p IntCurve diff --git a/src/BRep/BRep_Tool.cdl b/src/BRep/BRep_Tool.cdl index 559b5710b8..f0e300d238 100755 --- a/src/BRep/BRep_Tool.cdl +++ b/src/BRep/BRep_Tool.cdl @@ -528,6 +528,13 @@ is raises NullObject from Standard; -- If the edge or the faces are null. + HasContinuity(myclass; E : Edge from TopoDS) + returns Boolean + + ---Purpose: Returns True if the edge has regularity on some + -- two surfaces + raises + NullObject from Standard; -- If the edge is null. ----------------------------------------------------------- ----------------------------------------------------------- diff --git a/src/BRep/BRep_Tool.cxx b/src/BRep/BRep_Tool.cxx index 387796fe7e..4241e38d41 100755 --- a/src/BRep/BRep_Tool.cxx +++ b/src/BRep/BRep_Tool.cxx @@ -1117,6 +1117,25 @@ GeomAbs_Shape BRep_Tool::Continuity(const TopoDS_Edge& E, return GeomAbs_C0; } +//======================================================================= +//function : HasContinuity +//purpose : Returns True if the edge is on some two surfaces. +//======================================================================= + +Standard_Boolean BRep_Tool::HasContinuity(const TopoDS_Edge& E) +{ + BRep_ListIteratorOfListOfCurveRepresentation itcr + ((*((Handle(BRep_TEdge)*)&E.TShape()))->Curves()); + + for (; itcr.More(); itcr.Next()) + { + const Handle(BRep_CurveRepresentation)& CR = itcr.Value(); + if (CR->IsRegularity()) + return Standard_True; + } + return Standard_False; +} + //======================================================================= //function : Pnt //purpose : Returns the 3d point. diff --git a/src/Contap/Contap_ContourGen_2.gxx b/src/Contap/Contap_ContourGen_2.gxx index a047c3c6ba..52fbbd3e9f 100755 --- a/src/Contap/Contap_ContourGen_2.gxx +++ b/src/Contap/Contap_ContourGen_2.gxx @@ -1288,7 +1288,8 @@ void Contap_ContourGen::Perform //jag 940616 SFunc.Set(1.e-8); // tolerance sur la fonction mySFunc.Set(Precision::Confusion()); // tolerance sur la fonction - solrst.Perform(myAFunc,Domain,TolArc,TolArc); + Standard_Boolean RecheckOnRegularity = Standard_True; + solrst.Perform(myAFunc,Domain,TolArc,TolArc,RecheckOnRegularity); if (!solrst.IsDone()) { return; diff --git a/src/HLRAppli/HLRAppli.cdl b/src/HLRAppli/HLRAppli.cdl new file mode 100644 index 0000000000..e80dda9c78 --- /dev/null +++ b/src/HLRAppli/HLRAppli.cdl @@ -0,0 +1,34 @@ +-- File: HLRAppli.cdl +-- Created: 05.12.12 15:50:05 +-- Created by: Julia GERASIMOVA +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +package HLRAppli + + ---Purpose : This package represents applications + -- of Hidden Lines Removal algorithm + +uses + TopoDS, + HLRAlgo + +is + class ReflectLines; + +end HLRAppli; diff --git a/src/HLRAppli/HLRAppli_ReflectLines.cdl b/src/HLRAppli/HLRAppli_ReflectLines.cdl new file mode 100644 index 0000000000..94448d43b5 --- /dev/null +++ b/src/HLRAppli/HLRAppli_ReflectLines.cdl @@ -0,0 +1,60 @@ +-- File: HLRAppli_ReflectLines.cdl +-- Created: 05.12.12 15:53:35 +-- Created by: Julia GERASIMOVA +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + + +class ReflectLines from HLRAppli + + ---Purpose : This class builds reflect lines on a shape + -- according to the axes of view defined by user. + -- Reflect lines are represented by edges in 3d. + + +uses + Shape from TopoDS, + Projector from HLRAlgo + +is + Create(aShape : Shape from TopoDS) + ---Purpose: Constructor + -- + returns ReflectLines from HLRAppli; + + SetAxes(me: in out; + Nx, Ny, Nz : Real from Standard; + XAt, YAt, ZAt : Real from Standard; + XUp, YUp, ZUp : Real from Standard); + ---Purpose: Sets the normal to the plane of visualisation, + -- the coordinates of the view point and + -- the coordinates of the vertical direction vector. + + Perform(me: in out); + + GetResult(me) + returns Shape from TopoDS; + ---Purpose: returns resulting compound of reflect lines + -- represented by edges in 3d + +fields + + myProjector : Projector from HLRAlgo; + myShape : Shape from TopoDS; + myCompound : Shape from TopoDS; + +end ReflectLines; diff --git a/src/HLRAppli/HLRAppli_ReflectLines.cxx b/src/HLRAppli/HLRAppli_ReflectLines.cxx new file mode 100644 index 0000000000..096b98a794 --- /dev/null +++ b/src/HLRAppli/HLRAppli_ReflectLines.cxx @@ -0,0 +1,93 @@ +// File: HLRAppli_ReflectLines.cxx +// Created: 05.12.12 12:55:50 +// Created by: Julia GERASIMOVA +// Copyright (c) 2001-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include +#include +#include +#include +#include + +//======================================================================= +//function : HLRAppli_ReflectLines +//purpose : Constructor +//======================================================================= + +HLRAppli_ReflectLines::HLRAppli_ReflectLines(const TopoDS_Shape& aShape) +{ + myShape = aShape; +} + +//======================================================================= +//function : SetAxes +//purpose : +//======================================================================= + +void HLRAppli_ReflectLines::SetAxes(const Standard_Real Nx, + const Standard_Real Ny, + const Standard_Real Nz, + const Standard_Real XAt, + const Standard_Real YAt, + const Standard_Real ZAt, + const Standard_Real XUp, + const Standard_Real YUp, + const Standard_Real ZUp) +{ + Standard_Boolean IsPerspective = Standard_False; + Standard_Real aFocus = 1; + //Prs3d_Projector aPrs3dProjector(IsPerspective, aFocus, Nx, Ny, Nz, XAt, YAt, ZAt, XUp, YUp, ZUp); + + gp_Pnt At (XAt,YAt,ZAt); + gp_Dir Zpers (Nx,Ny,Nz); + gp_Dir Ypers (XUp,YUp,ZUp); + gp_Dir Xpers = Ypers.Crossed(Zpers); + gp_Ax3 Axe (At, Zpers, Xpers); + gp_Trsf T; + T.SetTransformation(Axe); + + //myProjector = aPrs3dProjector.Projector(); + myProjector = HLRAlgo_Projector(T,IsPerspective,aFocus); +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +void HLRAppli_ReflectLines::Perform() +{ + Handle(HLRBRep_Algo) aHLRAlgo = new HLRBRep_Algo(); + aHLRAlgo->Add( myShape, 0 ); + aHLRAlgo->Projector( myProjector ); + aHLRAlgo->Update(); + aHLRAlgo->Hide(); + HLRBRep_HLRToShape aHLRToShape( aHLRAlgo ); + + myCompound = aHLRToShape.OutLineVCompound3d(); +} + +//======================================================================= +//function : GetResult +//purpose : +//======================================================================= + +TopoDS_Shape HLRAppli_ReflectLines::GetResult() const +{ + return myCompound; +} diff --git a/src/HLRBRep/HLRBRep.cdl b/src/HLRBRep/HLRBRep.cdl index ab56d13cd3..9f1037cd34 100755 --- a/src/HLRBRep/HLRBRep.cdl +++ b/src/HLRBRep/HLRBRep.cdl @@ -148,6 +148,10 @@ is U1,U2 : Real from Standard) returns Edge from TopoDS; + MakeEdge3d(ec : Curve from HLRBRep; + U1,U2 : Real from Standard) + returns Edge from TopoDS; + PolyHLRAngleAndDeflection(InAngl : Real from Standard; OutAngl, OutDefl : out Real from Standard); diff --git a/src/HLRBRep/HLRBRep.cxx b/src/HLRBRep/HLRBRep.cxx index e84a9668e2..f46f12ded3 100755 --- a/src/HLRBRep/HLRBRep.cxx +++ b/src/HLRBRep/HLRBRep.cxx @@ -166,6 +166,59 @@ TopoDS_Edge HLRBRep::MakeEdge (const HLRBRep_Curve& ec, return Edg; } +//======================================================================= +//function : MakeEdge3d +//purpose : +//======================================================================= + +TopoDS_Edge HLRBRep::MakeEdge3d(const HLRBRep_Curve& ec, + const Standard_Real U1, + const Standard_Real U2) +{ + TopoDS_Edge Edg; + //const Standard_Real sta = ec.Parameter2d(U1); + //const Standard_Real end = ec.Parameter2d(U2); + + TopoDS_Edge anEdge = ec.GetCurve().Edge(); + Standard_Real fpar, lpar; + //BRep_Tool::Range(anEdge, fpar, lpar); + //Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, fpar, lpar); + BRepAdaptor_Curve BAcurve(anEdge); + fpar = BAcurve.FirstParameter(); + lpar = BAcurve.LastParameter(); + + Edg = TopoDS::Edge(anEdge.EmptyCopied()); + Edg.Orientation(TopAbs_FORWARD); + BRep_Builder BB; + BB.Range(Edg, U1, U2); + + //Share vertices if possible + TopoDS_Vertex V1, V2, V1new, V2new; + TopExp::Vertices(anEdge, V1, V2); + + Standard_Real Tol = Precision::PConfusion(); + if (Abs(fpar - U1) <= Tol) + V1new = V1; + else + { + gp_Pnt aPnt = BAcurve.Value(U1); + V1new = BRepLib_MakeVertex(aPnt); + } + if (Abs(lpar - U2) <= Tol) + V2new = V2; + else + { + gp_Pnt aPnt = BAcurve.Value(U2); + V2new = BRepLib_MakeVertex(aPnt); + } + + V1new.Orientation(TopAbs_FORWARD); + V2new.Orientation(TopAbs_REVERSED); + BB.Add(Edg, V1new); + BB.Add(Edg, V2new); + return Edg; +} + //======================================================================= //function : PolyHLRAngleAndDeflection //purpose : diff --git a/src/HLRBRep/HLRBRep_Data.cdl b/src/HLRBRep/HLRBRep_Data.cdl index ca9c0502ce..5b67b74527 100755 --- a/src/HLRBRep/HLRBRep_Data.cdl +++ b/src/HLRBRep/HLRBRep_Data.cdl @@ -285,9 +285,8 @@ is LevelFlag : Boolean from Standard; Level : out Integer from Standard; param : Real from Standard) - returns State from TopAbs + returns State from TopAbs; ---Purpose: Classification of an edge. - is static private; RejectedPoint(me : mutable; PInter : IntersectionPoint from IntRes2d; BoundOri : Orientation from TopAbs; diff --git a/src/HLRBRep/HLRBRep_HLRToShape.cdl b/src/HLRBRep/HLRBRep_HLRToShape.cdl index 1e5ed362b1..f88338c858 100755 --- a/src/HLRBRep/HLRBRep_HLRToShape.cdl +++ b/src/HLRBRep/HLRBRep_HLRToShape.cdl @@ -96,6 +96,10 @@ is ---C++: inline is static; + OutLineVCompound3d(me : in out) returns Shape from TopoDS + ---C++: inline + is static; + OutLineVCompound(me : in out; S : Shape from TopoDS) returns Shape from TopoDS ---C++: inline @@ -157,7 +161,8 @@ is InternalCompound(me : in out; typ : Integer from Standard; visible : Boolean from Standard; - S : Shape from TopoDS) + S : Shape from TopoDS; + In3d : Boolean from Standard = Standard_False) returns Shape from TopoDS is static private; @@ -166,7 +171,8 @@ is iface : Integer from Standard; DS : out Data from HLRBRep; Result : out Shape from TopoDS; - added : out Boolean from Standard) + added : out Boolean from Standard; + In3d : Boolean from Standard = Standard_False) is static private; DrawEdge(me; visible : Boolean from Standard; @@ -174,10 +180,12 @@ is typ : Integer from Standard; ed : out EdgeData from HLRBRep; Result : out Shape from TopoDS; - added : out Boolean from Standard) + added : out Boolean from Standard; + In3d : Boolean from Standard = Standard_False) is static private; fields + myAlgo : Algo from HLRBRep; end HLRToShape; diff --git a/src/HLRBRep/HLRBRep_HLRToShape.cxx b/src/HLRBRep/HLRBRep_HLRToShape.cxx index 941ee90085..04e9a10d94 100755 --- a/src/HLRBRep/HLRBRep_HLRToShape.cxx +++ b/src/HLRBRep/HLRBRep_HLRToShape.cxx @@ -46,7 +46,8 @@ myAlgo(A) TopoDS_Shape HLRBRep_HLRToShape::InternalCompound (const Standard_Integer typ, const Standard_Boolean visible, - const TopoDS_Shape& S) + const TopoDS_Shape& S, + const Standard_Boolean In3d) { Standard_Boolean added = Standard_False; TopoDS_Shape Result; @@ -87,7 +88,8 @@ HLRBRep_HLRToShape::InternalCompound (const Standard_Integer typ, Exp.More(); Exp.Next()) { Standard_Integer iface = Faces.FindIndex(Exp.Current()); - if (iface != 0) DrawFace(visible,typ,iface,DS,Result,added); + if (iface != 0) + DrawFace(visible,typ,iface,DS,Result,added,In3d); } if (typ >= 3) { @@ -98,7 +100,7 @@ HLRBRep_HLRToShape::InternalCompound (const Standard_Integer typ, if (ie != 0) { HLRBRep_EdgeData& ed = DS->EDataArray().ChangeValue(ie); if (!ed.Used()) { - DrawEdge(visible,Standard_False,typ,ed,Result,added); + DrawEdge(visible,Standard_False,typ,ed,Result,added,In3d); ed.Used(Standard_True); } } @@ -108,7 +110,7 @@ HLRBRep_HLRToShape::InternalCompound (const Standard_Integer typ, else { for (Standard_Integer iface = f1; iface <= f2; iface++) - DrawFace(visible,typ,iface,DS,Result,added); + DrawFace(visible,typ,iface,DS,Result,added,In3d); if (typ >= 3) { HLRBRep_EdgeData* ed = &(DS->EDataArray().ChangeValue(e1 - 1)); @@ -116,7 +118,7 @@ HLRBRep_HLRToShape::InternalCompound (const Standard_Integer typ, for (Standard_Integer ie = e1; ie <= e2; ie++) { ed++; if (!ed->Used()) { - DrawEdge(visible,Standard_False,typ,*ed,Result,added); + DrawEdge(visible,Standard_False,typ,*ed,Result,added,In3d); ed->Used(Standard_True); } } @@ -139,7 +141,8 @@ HLRBRep_HLRToShape::DrawFace (const Standard_Boolean visible, const Standard_Integer iface, Handle(HLRBRep_Data)& DS, TopoDS_Shape& Result, - Standard_Boolean& added) const + Standard_Boolean& added, + const Standard_Boolean In3d) const { HLRBRep_FaceIterator Itf; @@ -151,7 +154,13 @@ HLRBRep_HLRToShape::DrawFace (const Standard_Boolean visible, if (!edf.Used()) { Standard_Boolean todraw; if (typ == 1) todraw = Itf.IsoLine(); - else if (typ == 2) todraw = Itf.Internal(); + else if (typ == 2) //outlines + { + if (In3d) + todraw = Itf.Internal() || Itf.OutLine(); + else + todraw = Itf.Internal(); + } else if (typ == 3) todraw = edf.Rg1Line() && !edf.RgNLine() && !Itf.OutLine(); else if (typ == 4) todraw = edf.RgNLine() && !Itf.OutLine(); @@ -161,11 +170,13 @@ HLRBRep_HLRToShape::DrawFace (const Standard_Boolean visible, (edf.Rg1Line() && !Itf.OutLine())); if (todraw) { - DrawEdge(visible,Standard_True,typ,edf,Result,added); + DrawEdge(visible,Standard_True,typ,edf,Result,added,In3d); edf.Used(Standard_True); } else { - if(typ > 4 && (edf.Rg1Line() && !Itf.OutLine())) { + if((typ > 4 || typ == 2) && //sharp or outlines + (edf.Rg1Line() && !Itf.OutLine())) + { Standard_Integer hc = edf.HideCount(); if(hc > 0) { edf.Used(Standard_True); @@ -194,7 +205,8 @@ HLRBRep_HLRToShape::DrawEdge (const Standard_Boolean visible, const Standard_Integer typ, HLRBRep_EdgeData& ed, TopoDS_Shape& Result, - Standard_Boolean& added) const + Standard_Boolean& added, + const Standard_Boolean In3d) const { Standard_Boolean todraw = Standard_False; if (inFace) todraw = Standard_True; @@ -212,7 +224,10 @@ HLRBRep_HLRToShape::DrawEdge (const Standard_Boolean visible, { for (It.InitVisible(ed.Status()); It.MoreVisible(); It.NextVisible()) { It.Visible(sta,tolsta,end,tolend); - E = HLRBRep::MakeEdge(ed.Geometry(),sta,end); + if (!In3d) + E = HLRBRep::MakeEdge(ed.Geometry(),sta,end); + else + E = HLRBRep::MakeEdge3d(ed.Geometry(),sta,end); if (!E.IsNull()) { B.Add(Result,E); @@ -224,7 +239,10 @@ HLRBRep_HLRToShape::DrawEdge (const Standard_Boolean visible, { for (It.InitHidden(ed.Status()); It.MoreHidden(); It.NextHidden()) { It.Hidden(sta,tolsta,end,tolend); - E = HLRBRep::MakeEdge(ed.Geometry(),sta,end); + if (!In3d) + E = HLRBRep::MakeEdge(ed.Geometry(),sta,end); + else + E = HLRBRep::MakeEdge3d(ed.Geometry(),sta,end); if (!E.IsNull()) { B.Add(Result,E); diff --git a/src/HLRBRep/HLRBRep_HLRToShape.lxx b/src/HLRBRep/HLRBRep_HLRToShape.lxx index 36048d666c..aefa6c8a67 100755 --- a/src/HLRBRep/HLRBRep_HLRToShape.lxx +++ b/src/HLRBRep/HLRBRep_HLRToShape.lxx @@ -80,6 +80,14 @@ HLRBRep_HLRToShape::RgNLineVCompound(const TopoDS_Shape& S) inline TopoDS_Shape HLRBRep_HLRToShape::OutLineVCompound() { return InternalCompound(2,Standard_True,TopoDS_Shape()); } +//======================================================================= +//function : OutLineVCompound3d +//purpose : +//======================================================================= + +inline TopoDS_Shape HLRBRep_HLRToShape::OutLineVCompound3d() +{ return InternalCompound(2,Standard_True,TopoDS_Shape(),Standard_True); } + //======================================================================= //function : OutLineVCompound //purpose : diff --git a/src/HLRBRep/HLRBRep_Hider.cxx b/src/HLRBRep/HLRBRep_Hider.cxx index 44b8338305..6528b16709 100755 --- a/src/HLRBRep/HLRBRep_Hider.cxx +++ b/src/HLRBRep/HLRBRep_Hider.cxx @@ -34,6 +34,7 @@ #include #include + //======================================================================= //function : HLRBRep_Hider //purpose : @@ -386,7 +387,7 @@ void HLRBRep_Hider::Hide(const Standard_Integer FI, //IFV TopAbs_State aBuildIN = TopAbs_IN; - Standard_Boolean IsSuspision = Standard_True; + Standard_Boolean IsSuspicion = Standard_True; Standard_Real pmax, pmin; Standard_Boolean allInt = Standard_False; @@ -450,9 +451,11 @@ void HLRBRep_Hider::Hide(const Standard_Integer FI, } TopAbs_State aTestState = TopAbs_IN; - if(IsSuspision) { - Standard_Integer aNbp = 1; - aTestState = myDS->SimplClassify(E, ed, aNbp, p1, p2); + if(IsSuspicion) { + //Standard_Integer aNbp = 1; + //aTestState = myDS->SimplClassify(E, ed, aNbp, p1, p2); + Standard_Integer tmplevel = 0; + aTestState = myDS->Classify(E,ed,Standard_True,tmplevel,(p1+p2)/2.); } if(aTestState != TopAbs_OUT) { @@ -483,9 +486,20 @@ void HLRBRep_Hider::Hide(const Standard_Integer FI, } EB.NextVertex(); } - ES.Hide(p1,tol1,p2,tol2, - Standard_False, // under the Face - Standard_True); // on the boundary + + TopAbs_State aTestState = TopAbs_IN; + if(IsSuspicion) { + //Standard_Integer aNbp = 1; + //aTestState = myDS->SimplClassify(E, ed, aNbp, p1, p2); + Standard_Integer tmplevel = 0; + aTestState = myDS->Classify(E,ed,Standard_True,tmplevel,(p1+p2)/2.); + } + + if(aTestState != TopAbs_OUT) + ES.Hide(p1,tol1,p2,tol2, + Standard_False, // under the Face + Standard_True); // on the boundary + EB.NextEdge(); } } diff --git a/src/HLRTest/HLRTest.cxx b/src/HLRTest/HLRTest.cxx index 244b11dad1..affe40d662 100755 --- a/src/HLRTest/HLRTest.cxx +++ b/src/HLRTest/HLRTest.cxx @@ -29,6 +29,8 @@ #include #include #include +#include + static Handle(HLRBRep_Algo) hider; #ifdef WNT Standard_IMPORT Draw_Viewer dout; @@ -413,6 +415,43 @@ hres (Draw_Interpretor& , Standard_Integer n, const char** a) return 0; } +//======================================================================= +//function : reflectlines +//purpose : +//======================================================================= + +static Standard_Integer reflectlines(Draw_Interpretor& , Standard_Integer n, const char** a) +{ + if (n < 6) + return 1; + + TopoDS_Shape aShape = DBRep::Get(a[2]); + if (aShape.IsNull()) + return 1; + + Standard_Real anAISViewProjX = atof(a[3]); + Standard_Real anAISViewProjY = atof(a[4]); + Standard_Real anAISViewProjZ = atof(a[5]); + + gp_Pnt anOrigin(0.,0.,0.); + gp_Dir aNormal(anAISViewProjX, anAISViewProjY, anAISViewProjZ); + gp_Ax2 theAxes(anOrigin, aNormal); + gp_Dir aDX = theAxes.XDirection(); + + HLRAppli_ReflectLines Reflector(aShape); + + Reflector.SetAxes(aNormal.X(), aNormal.Y(), aNormal.Z(), + anOrigin.X(), anOrigin.Y(), anOrigin.Z(), + aDX.X(), aDX.Y(), aDX.Z()); + + Reflector.Perform(); + + TopoDS_Shape Result = Reflector.GetResult(); + DBRep::Set(a[1], Result); + + return 0; +} + //======================================================================= //function : Commands //purpose : @@ -436,6 +475,11 @@ void HLRTest::Commands (Draw_Interpretor& theCommands) theCommands.Add("hdebug" ,"hdebug" ,__FILE__,hdbg,g); theCommands.Add("hnullify" ,"hnullify" ,__FILE__,hnul,g); theCommands.Add("hres2d" ,"hres2d" ,__FILE__,hres,g); + + theCommands.Add("reflectlines", + "reflectlines res shape proj_X proj_Y proj_Z", + __FILE__, reflectlines, g); + hider = new HLRBRep_Algo(); } diff --git a/src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx b/src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx index e9030b5456..a576ffa469 100755 --- a/src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx +++ b/src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx @@ -55,11 +55,70 @@ #include #include #include +#include +#include +#include +#include +#include #define INTERPOLATE 0 #define BRISE 0 #define APPROX 1 + +static Standard_Boolean IntLineRisesFromRegularity(const TopoDS_Edge& anIntLine, + const TopoDS_Edge& anEdge, + const TopoDS_Face& aFace, + const TopTools_ListOfShape& aList) +{ + TopoDS_Vertex Ver [2]; + TopExp::Vertices(anIntLine, Ver[0], Ver[1]); + + //find min param and max param + Standard_Real MinPar = RealLast(), MaxPar = RealFirst(); + TopTools_ListIteratorOfListOfShape itl(aList); + for (; itl.More(); itl.Next()) + { + const TopoDS_Edge& anOutLine = TopoDS::Edge(itl.Value()); + Standard_Real aFirst, aLast; + BRep_Tool::Range(anOutLine, aFirst, aLast); + if (aFirst < MinPar) + MinPar = aFirst; + if (aLast > MaxPar) + MaxPar = aLast; + } + + Standard_Real theTol = BRep_Tool::Tolerance(anEdge); + Standard_Real ParamTol = Precision::Confusion(); + + Standard_Integer i, j; + for (i = 0; i < 2; i++) + { + BRepExtrema_ExtPC anExtPC(Ver[i], anEdge); + if (!anExtPC.IsDone()) + continue; + Standard_Integer NbExt = anExtPC.NbExt(); + if (NbExt == 0) + continue; + Standard_Integer jmin = 1; + for (j = 2; j <= NbExt; j++) + if (anExtPC.SquareDistance(j) < anExtPC.SquareDistance(jmin)) + jmin = j; + Standard_Real aDist = anExtPC.SquareDistance(jmin); + aDist = Sqrt(aDist); + if (aDist > theTol) + continue; + + Standard_Real theParam = anExtPC.Parameter(jmin); + if (theParam > MinPar + ParamTol && + theParam < MaxPar - ParamTol) + return Standard_True; + } + + return Standard_False; +} + + //======================================================================= //function : Insert //purpose : explore the faces and insert them @@ -95,7 +154,7 @@ void HLRTopoBRep_DSFiller::Insert (const TopoDS_Shape& S, Domain = BRT.GetTopolTool(); Surface = BRT.GetSurface(); } - FO.Perform(Surface,Domain); + FO.Perform(Surface, Domain); if (FO.IsDone()) { if (!FO.IsEmpty()) InsertFace(f,S1,FO,DS,withPCurve); @@ -140,8 +199,8 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer FI, */ const Standard_Integer NbLines = FO.NbLines(); - Standard_Integer CurLine = 1; - for (; CurLine <= NbLines; CurLine++) + Standard_Integer CurLine; + for (CurLine = 1; CurLine <= NbLines; CurLine++) { const Contap_TheLineOfContour& Line = FO.Line(CurLine); const Standard_Integer NbPoints = Line.NbVertex(); @@ -447,6 +506,50 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer FI, } } } + + //jgv: correction of internal outlines: remove those that rise from middle of boundary outlines + TopTools_ListIteratorOfListOfShape itl(IntL); + while (itl.More()) + { + TopoDS_Edge anIntLine = TopoDS::Edge(itl.Value()); + Standard_Real found = Standard_False; + TopExp_Explorer Explo(F, TopAbs_EDGE); + for (; Explo.More(); Explo.Next()) + { + TopoDS_Edge anEdge = TopoDS::Edge(Explo.Current()); + if (!BRep_Tool::HasContinuity(anEdge)) + continue; + + TopLoc_Location RegLoc; + Standard_Real fpar, lpar; + Handle(Geom_Curve) RegCurve = BRep_Tool::Curve(anEdge, RegLoc, fpar, lpar); + TopTools_ListOfShape thelist; + TopTools_ListIteratorOfListOfShape itoutl(OutL); + for (; itoutl.More(); itoutl.Next()) + { + TopoDS_Edge anOutLine = TopoDS::Edge(itoutl.Value()); + TopLoc_Location aLoc; + Standard_Real aFirst, aLast; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anOutLine, aLoc, aFirst, aLast); + if (aCurve == RegCurve && aLoc == RegLoc) + thelist.Append(anOutLine); + } + + if (thelist.IsEmpty()) + continue; + + if (IntLineRisesFromRegularity(anIntLine, anEdge, F, thelist)) + { + IntL.Remove(itl); + found = Standard_True; + break; + } + } + + if (!found) + itl.Next(); + } + /////////////////////////////////////////////////// } //======================================================================= diff --git a/src/IntStart/IntStart_SearchOnBoundaries.cdl b/src/IntStart/IntStart_SearchOnBoundaries.cdl index f916ac6e79..4b39ccc221 100755 --- a/src/IntStart/IntStart_SearchOnBoundaries.cdl +++ b/src/IntStart/IntStart_SearchOnBoundaries.cdl @@ -71,7 +71,8 @@ is Perform(me : in out; F : in out TheFunction; Domain: TheTopolTool; - TolBoundary,TolTangency : Real from Standard) + TolBoundary,TolTangency : Real from Standard; + RecheckOnRegularity : Boolean from Standard = Standard_False) ---Purpose: Algorithm to find the points and parts of curves of Domain -- (domain of of restriction of a surface) which verify diff --git a/src/IntStart/IntStart_SearchOnBoundaries_1.gxx b/src/IntStart/IntStart_SearchOnBoundaries_1.gxx index 606ac41f30..aa5b9e3216 100755 --- a/src/IntStart/IntStart_SearchOnBoundaries_1.gxx +++ b/src/IntStart/IntStart_SearchOnBoundaries_1.gxx @@ -73,6 +73,10 @@ static const Standard_Real TolBoundary, IntStart_SequenceOfPathPoint& pnt); +static + Standard_Boolean IsRegularity(const TheArc& A, + const Handle(TheTopolTool)& aDomain); + //======================================================================= //function : FindVertex @@ -131,7 +135,8 @@ void BoundedArc (const TheArc& A, IntStart_SequenceOfSegment& seg, const Standard_Real TolBoundary, const Standard_Real TolTangency, - Standard_Boolean& Arcsol) + Standard_Boolean& Arcsol, + const Standard_Boolean RecheckOnRegularity) { // Recherche des points solutions et des bouts d arc solution sur un arc donne. @@ -139,7 +144,6 @@ void BoundedArc (const TheArc& A, // des arcs ayant un point debut et un point de fin (intervalle ferme de // parametrage). - Standard_Integer i,Nbi,Nbp; gp_Pnt ptdeb,ptfin; @@ -254,6 +258,71 @@ void BoundedArc (const TheArc& A, if (!Sol.IsDone()) {Standard_Failure::Raise();} Nbp=Sol.NbPoints(); + + //jgv: build solution on the whole boundary + if (RecheckOnRegularity && Nbp > 0 && IsRegularity(A, Domain)) + { + //Standard_Real theTol = Domain->MaxTolerance(A); + //theTol += theTol; + Standard_Real theTol = 5.e-4; + math_FunctionAllRoots SolAgain(Func,Echant,EpsX,theTol,theTol); //-- TolBoundary,nTolTangency); + + if (!SolAgain.IsDone()) {Standard_Failure::Raise();} + + Standard_Integer Nbp_again = SolAgain.NbPoints(); + Standard_Integer Nbi_again = SolAgain.NbIntervals(); + + if (Nbi_again > 0) + { + Standard_Integer NbSamples = 10; + Standard_Real delta = (Pfin - Pdeb)/NbSamples; + Standard_Real GlobalTol = theTol*10; + Standard_Boolean SolOnBoundary = Standard_True; + for (i = 0; i <= NbSamples; i++) + { + Standard_Real aParam = Pdeb + i*delta; + Standard_Real aValue; + Func.Value(aParam, aValue); + if (Abs(aValue) > GlobalTol) + { + SolOnBoundary = Standard_False; + break; + } + } + + if (SolOnBoundary) + { + for (i = 1; i <= Nbi_again; i++) + { + IntStart_TheSegment newseg; + newseg.SetValue(A); + // Recuperer point debut et fin, et leur parametre. + SolAgain.GetInterval(i,pardeb,parfin); + + if (Abs(pardeb - Pdeb) <= Precision::PConfusion()) + pardeb = Pdeb; + if (Abs(parfin - Pfin) <= Precision::PConfusion()) + parfin = Pfin; + + SolAgain.GetIntervalState(i,ideb,ifin); + + //-- cout<<" Debug : IntStart_SearchOnBoundaries_1.gxx : i= "<0 0 <- Nbi "<0.001) TOL=0.001; - - ptsol.SetValue(Pt,TOL,A,Para); - pnt.Append(ptsol); - Range = pnt.Length(); + //jgv: do not add segment's extremities if they already exist + Standard_Boolean found_internal = Standard_False; + for (k = 1; k <= pnt.Length(); k++) + { + ptsol = pnt.Value(k); + if (ptsol.Arc() != A || + !ptsol.IsNew()) //vertex + continue; + if (Abs(ptsol.Parameter()-Para) <= Precision::PConfusion()) + { + found_internal = Standard_True; + Range = k; + } + } + ///////////////////////////////////////////////////////////// + + if (!found_internal) + { + Standard_Real TOL=Tol; + TOL*=1000.0; + if(TOL>0.001) TOL=0.001; + + ptsol.SetValue(Pt,TOL,A,Para); + pnt.Append(ptsol); + Range = pnt.Length(); + } } } @@ -734,6 +822,23 @@ void PointProcess (const gp_Pnt& Pt, #include #include +//======================================================================= +//function : IsRegularity +//purpose : +//======================================================================= +Standard_Boolean IsRegularity(const TheArc& A, + const Handle(TheTopolTool)& aDomain) +{ + Standard_Address anEAddress=aDomain->Edge(); + if (anEAddress==NULL) { + return Standard_False; + } + + TopoDS_Edge* anE=(TopoDS_Edge*)anEAddress; + + return (BRep_Tool::HasContinuity(*anE)); +} + //======================================================================= //function : TreatLC //purpose : diff --git a/src/IntStart/IntStart_SearchOnBoundaries_2.gxx b/src/IntStart/IntStart_SearchOnBoundaries_2.gxx index 157f27644b..fb0e92b3ea 100755 --- a/src/IntStart/IntStart_SearchOnBoundaries_2.gxx +++ b/src/IntStart/IntStart_SearchOnBoundaries_2.gxx @@ -33,7 +33,8 @@ IntStart_SearchOnBoundaries::IntStart_SearchOnBoundaries () void IntStart_SearchOnBoundaries::Perform (TheFunction& Func, const Handle(TheTopolTool)& Domain, const Standard_Real TolBoundary, - const Standard_Real TolTangency) + const Standard_Real TolTangency, + const Standard_Boolean RecheckOnRegularity) { done = Standard_False; @@ -68,7 +69,7 @@ IntStart_SearchOnBoundaries::IntStart_SearchOnBoundaries () } else { BoundedArc(A,Domain,PDeb,PFin,Func,spnt,sseg, - TolBoundary,TolTangency,Arcsol); + TolBoundary,TolTangency,Arcsol,RecheckOnRegularity); } all = (all && Arcsol); } diff --git a/src/TKHLR/PACKAGES b/src/TKHLR/PACKAGES index b331ab6125..f5b5d69f97 100755 --- a/src/TKHLR/PACKAGES +++ b/src/TKHLR/PACKAGES @@ -1,6 +1,7 @@ HLRTopoBRep HLRBRep HLRAlgo +HLRAppli Intrv TopBas TopCnx diff --git a/tests/bugs/modalg_5/bug23625_1 b/tests/bugs/modalg_5/bug23625_1 new file mode 100755 index 0000000000..08c4ec0867 --- /dev/null +++ b/tests/bugs/modalg_5/bug23625_1 @@ -0,0 +1,20 @@ +puts "============" +puts "OCC23625" +puts "============" +puts "" +###################################################### +# New functionality building reflect lines on a shape +###################################################### + +smallview + +restore [locate_data_file bug23625_a1.brep] a + +front +fit + +reflectlines result a 0 1 0 + +set length 3877.8 + +set only_screen_axo 1 diff --git a/tests/bugs/modalg_5/bug23625_2 b/tests/bugs/modalg_5/bug23625_2 new file mode 100755 index 0000000000..96302582e6 --- /dev/null +++ b/tests/bugs/modalg_5/bug23625_2 @@ -0,0 +1,20 @@ +puts "============" +puts "OCC23625" +puts "============" +puts "" +###################################################### +# New functionality building reflect lines on a shape +###################################################### + +smallview + +restore [locate_data_file bug23625_a2.brep] a + +front +fit + +reflectlines result a 0 1 0 + +set length 4022.72 + +set only_screen_axo 1 diff --git a/tests/bugs/modalg_5/bug23625_3 b/tests/bugs/modalg_5/bug23625_3 new file mode 100755 index 0000000000..9798883fed --- /dev/null +++ b/tests/bugs/modalg_5/bug23625_3 @@ -0,0 +1,20 @@ +puts "============" +puts "OCC23625" +puts "============" +puts "" +###################################################### +# New functionality building reflect lines on a shape +###################################################### + +smallview + +restore [locate_data_file bug23625_a3.brep] a + +top +fit + +reflectlines result a 0 0 1 + +set length 4843.56 + +set only_screen_axo 1 diff --git a/tests/bugs/modalg_5/bug23625_4 b/tests/bugs/modalg_5/bug23625_4 new file mode 100755 index 0000000000..3b084ad1c3 --- /dev/null +++ b/tests/bugs/modalg_5/bug23625_4 @@ -0,0 +1,20 @@ +puts "============" +puts "OCC23625" +puts "============" +puts "" +###################################################### +# New functionality building reflect lines on a shape +###################################################### + +smallview + +restore [locate_data_file bug23625_a4.brep] a + +right +fit + +reflectlines result a 1 0 0 + +set length 4207.74 + +set only_screen_axo 1 diff --git a/tests/bugs/modalg_5/bug23625_5 b/tests/bugs/modalg_5/bug23625_5 new file mode 100755 index 0000000000..fae70f7c2b --- /dev/null +++ b/tests/bugs/modalg_5/bug23625_5 @@ -0,0 +1,20 @@ +puts "============" +puts "OCC23625" +puts "============" +puts "" +###################################################### +# New functionality building reflect lines on a shape +###################################################### + +smallview + +restore [locate_data_file bug23625_a4.brep] a + +right +fit + +reflectlines result a 0 0 1 + +set length 6361.07 + +set only_screen_axo 1