1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : GEOMAlgo_AlgoTools.cxx
24 // Author : Peter KURNEV
26 #include <GEOMAlgo_AlgoTools.hxx>
28 #include <Basics_OCCTVersion.hxx>
31 #include <gp_Pnt2d.hxx>
32 #include <gp_Dir2d.hxx>
33 #include <Bnd_Box.hxx>
35 #include <Geom2d_Curve.hxx>
36 #include <Geom2d_TrimmedCurve.hxx>
37 #include <Geom2d_Line.hxx>
38 #include <Geom2d_TrimmedCurve.hxx>
40 #include <Geom2dHatch_Intersector.hxx>
41 #include <Geom2dHatch_Hatcher.hxx>
43 #include <Geom2dAdaptor_Curve.hxx>
44 #include <HatchGen_Domain.hxx>
46 #include <Geom_Curve.hxx>
47 #include <Geom_Surface.hxx>
49 #include <GeomAdaptor_Surface.hxx>
51 #include <GeomAPI_ProjectPointOnSurf.hxx>
52 #include <GeomAPI_ProjectPointOnCurve.hxx>
54 #include <Poly_Triangulation.hxx>
56 #include <TopAbs_Orientation.hxx>
58 #include <TopLoc_Location.hxx>
61 #include <TopoDS_Iterator.hxx>
62 #include <TopoDS_Face.hxx>
63 #include <TopoDS_Edge.hxx>
65 #include <TopExp_Explorer.hxx>
67 #include <BRep_Tool.hxx>
68 #include <BRep_Builder.hxx>
70 #include <BRepTools.hxx>
71 #include <BRepBndLib.hxx>
72 #include <BRepMesh_IncrementalMesh.hxx>
74 #include <IntTools_Tools.hxx>
76 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
77 #include <TopTools_ListOfShape.hxx>
79 #include <TopTools_ListIteratorOfListOfShape.hxx>
80 #include <TopTools_IndexedMapOfShape.hxx>
81 #include <TopAbs_ShapeEnum.hxx>
83 #include <IntTools_Tools.hxx>
85 #include <BOPTools_AlgoTools3D.hxx>
86 #include <BOPTools_AlgoTools2D.hxx>
88 #include <GEOMAlgo_PassKeyShape.hxx>
92 void GetCount(const TopoDS_Shape& aS,
93 Standard_Integer& iCnt);
95 void CopySource(const TopoDS_Shape& aS,
96 TopTools_IndexedDataMapOfShapeShape& aMapSS,
99 //=======================================================================
100 //function : CopyShape
102 //=======================================================================
103 void GEOMAlgo_AlgoTools::CopyShape(const TopoDS_Shape& aS,
106 TopTools_IndexedDataMapOfShapeShape aMapSS;
108 CopySource(aS, aMapSS, aSC);
110 //=======================================================================
111 //function : CopyShape
113 //=======================================================================
114 void GEOMAlgo_AlgoTools::CopyShape(const TopoDS_Shape& aS,
116 TopTools_IndexedDataMapOfShapeShape& aMapSS)
118 CopySource(aS, aMapSS, aSC);
120 //=======================================================================
121 //function : CopySource
123 //=======================================================================
124 void CopySource(const TopoDS_Shape& aS,
125 TopTools_IndexedDataMapOfShapeShape& aMapSS,
128 Standard_Boolean bFree;
136 if (aMapSS.Contains(aS)) {
137 aSC=aMapSS.ChangeFromKey(aS);
138 aSC.Orientation(aS.Orientation());
142 aSC=aS.EmptyCopied();
147 aSC.Free(Standard_True);
149 if (aT==TopAbs_EDGE){
150 TopAbs_Orientation aOr;
152 aOr=aS.Orientation();
153 if(aOr==TopAbs_INTERNAL) {
154 aSF.Orientation(TopAbs_FORWARD);
158 for (; aIt.More(); aIt.Next()) {
161 const TopoDS_Shape& aSx=aIt.Value();
163 CopySource (aSx, aMapSS, aSCx);
165 aSCx.Orientation(aSx.Orientation());
170 //=======================================================================
171 //function : FaceNormal
173 //=======================================================================
174 void GEOMAlgo_AlgoTools::FaceNormal (const TopoDS_Face& aF,
175 const Standard_Real U,
176 const Standard_Real V,
181 Handle(Geom_Surface) aSurface;
183 aSurface=BRep_Tool::Surface(aF);
184 aSurface->D1 (U, V, aPnt, aD1U, aD1V);
185 aN=aD1U.Crossed(aD1V);
187 if (aF.Orientation() == TopAbs_REVERSED){
192 //=======================================================================
193 //function : BuildPCurveForEdgeOnFace
195 //=======================================================================
196 Standard_Integer GEOMAlgo_AlgoTools::BuildPCurveForEdgeOnFace
197 (const TopoDS_Edge& aEold,
198 const TopoDS_Edge& aEnew,
199 const TopoDS_Face& aF,
200 #if OCC_VERSION_LARGE > 0x06070100
201 const Handle(IntTools_Context)& aCtx
203 const Handle(BOPInt_Context)& aCtx
207 Standard_Boolean bIsClosed, bUClosed, bHasOld;
208 Standard_Integer iRet, aNbPoints;
209 Standard_Real aTS, aTS1, aTS2, aT, aT1, aT2, aScPr, aTol;
210 Standard_Real aU, aV, aUS1, aVS1, aUS2, aVS2;
212 gp_Pnt2d aP2DS1, aP2DS2, aP2D;
213 gp_Vec2d aV2DS1, aV2DS2;
214 Handle(Geom2d_Curve) aC2D, aC2DS1, aC2DS2;
215 Handle(Geom_Surface) aS;
220 bHasOld=BOPTools_AlgoTools2D::HasCurveOnSurface(aEnew, aF, aC2D, aT1, aT2, aTol);
225 #if OCC_VERSION_LARGE > 0x06080000
226 // Try to copy PCurve from old edge to the new one.
227 iRet = BOPTools_AlgoTools2D::AttachExistingPCurve(aEold, aEnew, aF, aCtx);
230 // Do PCurve using projection algorithm.
233 // The PCurve is attached successfully.
238 BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aEnew, aF);
239 aC2D=BRep_Tool::CurveOnSurface(aEnew, aF, aT1, aT2);
245 bIsClosed=BRep_Tool::IsClosed(aEold, aF);
252 // 1. bUClosed - direction of closeness
255 aES.Orientation(TopAbs_FORWARD);
256 aC2DS1=BRep_Tool::CurveOnSurface(aES, aF, aTS1, aTS2);
258 aES.Orientation(TopAbs_REVERSED);
259 aC2DS2=BRep_Tool::CurveOnSurface(aES, aF, aTS1, aTS2);
261 aTS=IntTools_Tools::IntermediatePoint(aTS1, aTS2);
263 aC2DS1->D1(aTS, aP2DS1, aV2DS1);
264 aC2DS2->D1(aTS, aP2DS2, aV2DS2);
266 gp_Vec2d aV2DS12(aP2DS1, aP2DS2);
267 gp_Dir2d aD2DS12(aV2DS12);
268 const gp_Dir2d& aD2DX=gp::DX2d();
271 bUClosed=Standard_True;
272 if (fabs(aScPr) < aTol) {
276 // 2. aP2D - point on curve aC2D, that corresponds to aP2DS1
277 aP2DS1.Coord(aUS1, aVS1);
278 aP2DS2.Coord(aUS2, aVS2);
280 aS=BRep_Tool::Surface(aF);
281 aS->D0(aUS1, aVS1, aP);
283 GeomAPI_ProjectPointOnCurve& aProjPC=aCtx->ProjPC(aEnew);
286 aNbPoints=aProjPC.NbPoints();
292 aT=aProjPC.LowerDistanceParameter();
295 // 3. Build the second 2D curve
296 Standard_Boolean bRevOrder;
297 gp_Vec2d aV2DT, aV2D;
298 Handle(Geom2d_Curve) aC2Dnew;
299 Handle(Geom2d_TrimmedCurve) aC2DTnew;
302 aC2D->D1(aT, aP2D, aV2D);
305 aC2Dnew=Handle(Geom2d_Curve)::DownCast(aC2D->Copy());
306 aC2DTnew = new Geom2d_TrimmedCurve(aC2Dnew, aT1, aT2);
309 if (!bUClosed) { // V Closed
310 if (fabs(aV-aVS2)<aTol) {
315 if (fabs(aU-aUS2)<aTol) {
320 aC2DTnew->Translate(aV2DT);
322 // 4 Order the 2D curves
323 bRevOrder=Standard_False;
326 bRevOrder=!bRevOrder;
329 // 5. Update the edge
330 aTol=BRep_Tool::Tolerance(aEnew);
332 aBB.UpdateEdge(aEnew, aC2D, aC2DTnew, aF, aTol);
335 aBB.UpdateEdge(aEnew, aC2DTnew, aC2D , aF, aTol);
340 //////////////////////////////////////////////////////////////////////////
341 //=======================================================================
342 // function: MakeContainer
344 //=======================================================================
345 void GEOMAlgo_AlgoTools::MakeContainer(const TopAbs_ShapeEnum theType,
351 case TopAbs_COMPOUND:{
353 aBB.MakeCompound(aC);
358 case TopAbs_COMPSOLID:{
359 TopoDS_CompSolid aCS;
360 aBB.MakeCompSolid(aCS);
367 aBB.MakeSolid(aSolid);
375 aBB.MakeShell(aShell);
391 //=======================================================================
392 //function : IsUPeriodic
394 //=======================================================================
395 Standard_Boolean GEOMAlgo_AlgoTools::IsUPeriodic(const Handle(Geom_Surface) &aS)
397 Standard_Boolean bRet;
398 GeomAbs_SurfaceType aType;
399 GeomAdaptor_Surface aGAS;
402 aType=aGAS.GetType();
403 bRet=(aType==GeomAbs_Cylinder||
404 aType==GeomAbs_Cone ||
405 aType==GeomAbs_Sphere);
410 //=======================================================================
411 //function : RefinePCurveForEdgeOnFace
413 //=======================================================================
414 void GEOMAlgo_AlgoTools::RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
415 const TopoDS_Face& aF,
416 const Standard_Real aUMin,
417 const Standard_Real aUMax)
419 Standard_Real aT1, aT2, aTx, aUx, aTol;
421 Handle(Geom_Surface) aS;
422 Handle(Geom2d_Curve) aC2D;
425 aC2D=BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2);
426 if (!aC2D.IsNull()) {
427 if (BRep_Tool::IsClosed(aE, aF)) {
430 aTx=IntTools_Tools::IntermediatePoint(aT1, aT2);
433 if (aUx < aUMin || aUx > aUMax) {
435 Handle(Geom2d_Curve) aC2Dx;
437 aTol=BRep_Tool::Tolerance(aE);
438 aBB.UpdateEdge(aE, aC2Dx, aF, aTol);
442 //=======================================================================
443 //function :IsSplitToReverse
445 //=======================================================================
446 Standard_Boolean GEOMAlgo_AlgoTools::IsSplitToReverse
447 (const TopoDS_Edge& aEF1,
448 const TopoDS_Edge& aEF2,
449 #if OCC_VERSION_LARGE > 0x06070100
450 const Handle(IntTools_Context)& aContext
452 const Handle(BOPInt_Context)& aContext
456 Standard_Boolean aFlag;
457 Standard_Real aT1, aT2, aScPr, a, b;
462 Handle(Geom_Curve)aC1=BRep_Tool::Curve(aEF1, a, b);
463 aT1=IntTools_Tools::IntermediatePoint(a, b);
465 aFlag=BOPTools_AlgoTools2D::EdgeTangent(aEF1, aT1, aV1);
468 return Standard_False;
473 aFlag=aContext->ProjectPointOnEdge(aP, aEF2, aT2);
475 return Standard_False;
478 aFlag=BOPTools_AlgoTools2D::EdgeTangent(aEF2, aT2, aV2);
480 return Standard_False;
491 //=======================================================================
492 //function : ProjectPointOnShape
494 //=======================================================================
495 Standard_Boolean GEOMAlgo_AlgoTools::ProjectPointOnShape
497 const TopoDS_Shape& aS,
499 #if OCC_VERSION_LARGE > 0x06070100
500 const Handle(IntTools_Context)& aCtx
502 const Handle(BOPInt_Context)& aCtx
506 Standard_Boolean bIsDone = Standard_False;
508 TopAbs_ShapeEnum aType;
510 aType = aS.ShapeType();
515 const TopoDS_Edge& aE2 = TopoDS::Edge(aS);
517 if (BRep_Tool::Degenerated(aE2)) { // jfa
518 return Standard_True;
522 Handle(Geom_Curve) aC3D = BRep_Tool::Curve (aE2, f, l);
524 return Standard_True;
526 bIsDone = aCtx->ProjectPointOnEdge(aP1, aE2, aT2);
532 GEOMAlgo_AlgoTools::PointOnEdge(aE2, aT2, aP2);
538 const TopoDS_Face& aF2 = TopoDS::Face(aS);
539 GeomAPI_ProjectPointOnSurf& aProj = aCtx->ProjPS(aF2);
542 bIsDone = aProj.IsDone();
547 aP2 = aProj.NearestPoint();
557 //=======================================================================
558 //function : PointOnEdge
560 //=======================================================================
561 void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
564 Standard_Real aTx, aT1, aT2;
566 BRep_Tool::Curve(aE, aT1, aT2);
567 aTx=IntTools_Tools::IntermediatePoint(aT1, aT2);
568 GEOMAlgo_AlgoTools::PointOnEdge(aE, aTx, aP3D);
570 //=======================================================================
571 //function : PointOnEdge
573 //=======================================================================
574 void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
575 const Standard_Real aT,
578 Standard_Real aT1, aT2;
579 Handle(Geom_Curve) aC3D;
581 aC3D=BRep_Tool::Curve(aE, aT1, aT2);
584 //=======================================================================
585 //function : PointOnFace
587 //=======================================================================
588 void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
589 const Standard_Real aU,
590 const Standard_Real aV,
593 Handle(Geom_Surface) aS;
595 aS=BRep_Tool::Surface(aF);
596 aS->D0(aU, aV, aP3D);
598 //=======================================================================
599 //function : PointOnFace
601 //=======================================================================
602 void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
605 Standard_Real aU, aV, aUMin, aUMax, aVMin, aVMax;
607 BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
609 aU=IntTools_Tools::IntermediatePoint(aUMin, aUMax);
610 aV=IntTools_Tools::IntermediatePoint(aVMin, aVMax);
612 GEOMAlgo_AlgoTools::PointOnFace(aF, aU, aV, aP3D);
614 //=======================================================================
615 //function : PointOnShape
617 //=======================================================================
618 void GEOMAlgo_AlgoTools::PointOnShape(const TopoDS_Shape& aS,
621 TopAbs_ShapeEnum aType;
623 aP3D.SetCoord(99.,99.,99.);
624 aType=aS.ShapeType();
627 const TopoDS_Edge& aE=TopoDS::Edge(aS);
628 GEOMAlgo_AlgoTools::PointOnEdge(aE, aP3D);
633 const TopoDS_Face& aF=TopoDS::Face(aS);
634 GEOMAlgo_AlgoTools::PointOnFace(aF, aP3D);
642 //=======================================================================
643 //function : FindSDShapes
645 //=======================================================================
646 Standard_Integer GEOMAlgo_AlgoTools::FindSDShapes
647 (const TopoDS_Shape& aE1,
648 const TopTools_ListOfShape& aLE,
649 const Standard_Real aTol,
650 TopTools_ListOfShape& aLESD,
651 #if OCC_VERSION_LARGE > 0x06070100
652 const Handle(IntTools_Context)& aCtx
654 const Handle(BOPInt_Context)& aCtx
658 Standard_Boolean bIsDone;
659 Standard_Real aTol2, aD2;
661 TopTools_ListIteratorOfListOfShape aIt;
664 GEOMAlgo_AlgoTools::PointOnShape(aE1, aP1);
667 for (; aIt.More(); aIt.Next()) {
668 const TopoDS_Shape& aE2=aIt.Value();
669 if (aE2.IsSame(aE1)) {
673 bIsDone=GEOMAlgo_AlgoTools::ProjectPointOnShape(aP1, aE2, aP2, aCtx);
676 continue; // jfa BUG 20361
678 aD2=aP1.SquareDistance(aP2);
687 //=======================================================================
688 //function : FindSDShapes
690 //=======================================================================
691 Standard_Integer GEOMAlgo_AlgoTools::FindSDShapes
692 (const TopTools_ListOfShape& aLE,
693 const Standard_Real aTol,
694 TopTools_IndexedDataMapOfShapeListOfShape& aMEE,
695 #if OCC_VERSION_LARGE > 0x06070100
696 const Handle(IntTools_Context)& aCtx
698 const Handle(BOPInt_Context)& aCtx
702 Standard_Integer aNbE, aNbEProcessed, aNbESD, iErr;
703 TopTools_ListOfShape aLESD;
704 TopTools_ListIteratorOfListOfShape aIt, aIt1;
705 TopTools_IndexedMapOfShape aMProcessed;
706 TopAbs_ShapeEnum aType;
713 return 0; // Nothing to do
717 aNbEProcessed=aMProcessed.Extent();
718 if (aNbEProcessed==aNbE) {
723 for (; aIt.More(); aIt.Next()) {
724 const TopoDS_Shape& aS=aIt.Value();
726 if (aMProcessed.Contains(aS)) {
730 aType=aS.ShapeType();
731 if (aType==TopAbs_EDGE) {
732 const TopoDS_Edge& aE=TopoDS::Edge(aS);
733 if (BRep_Tool::Degenerated(aE)) {
740 iErr=GEOMAlgo_AlgoTools::FindSDShapes(aS, aLE, aTol, aLESD, aCtx);
745 aNbESD=aLESD.Extent();
752 aIt1.Initialize(aLESD);
753 for (; aIt1.More(); aIt1.Next()) {
754 const TopoDS_Shape& aE1=aIt1.Value();
755 aMProcessed.Add(aE1);
761 //=======================================================================
762 //function : RefineSDShapes
764 //=======================================================================
765 Standard_Integer GEOMAlgo_AlgoTools::RefineSDShapes
766 (GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMPKLE,
767 const Standard_Real aTol,
768 #if OCC_VERSION_LARGE > 0x06070100
769 const Handle(IntTools_Context)& aCtx
771 const Handle(BOPInt_Context)& aCtx
775 Standard_Integer i, aNbE, iErr, j, aNbEE, aNbToAdd;
776 TopTools_IndexedDataMapOfShapeListOfShape aMEE, aMSDE, aMEToAdd;
780 aNbE=aMPKLE.Extent();
781 for (i=1; i<=aNbE; ++i) {
782 TopTools_ListOfShape& aLSDE=aMPKLE.ChangeFromIndex(i);
785 iErr=GEOMAlgo_AlgoTools::FindSDShapes(aLSDE, aTol, aMEE, aCtx);
792 continue; // nothing to do
795 for (j=1; j<=aNbEE; ++j) {
796 TopTools_ListOfShape& aLEE=aMEE.ChangeFromIndex(j);
803 const TopoDS_Shape& aE1=aLEE.First();
804 aMEToAdd.Add(aE1, aLEE);
809 aNbToAdd=aMEToAdd.Extent();
814 for (i=1; i<=aNbToAdd; ++i) {
815 GEOMAlgo_PassKeyShape aPKE1;
817 const TopoDS_Shape& aE1=aMEToAdd.FindKey(i);
818 const TopTools_ListOfShape& aLE=aMEToAdd(i);
820 aPKE1.SetShapes(aE1);
821 aMPKLE.Add(aPKE1, aLE);
826 //=======================================================================
827 //function : BuildTriangulation
829 //=======================================================================
831 GEOMAlgo_AlgoTools::BuildTriangulation (const TopoDS_Shape& theShape)
833 // calculate deflection
834 Standard_Real aDeviationCoefficient = 0.001;
837 BRepBndLib::Add(theShape, B);
838 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
839 B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
841 Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin;
842 Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4;
843 Standard_Real aHLRAngle = 0.349066;
845 // build triangulation
846 BRepMesh_IncrementalMesh Inc (theShape, aDeflection, Standard_False, aHLRAngle);
848 // check triangulation
849 bool isTriangulation = true;
851 TopExp_Explorer exp (theShape, TopAbs_FACE);
854 TopLoc_Location aTopLoc;
855 Handle(Poly_Triangulation) aTRF;
856 aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc);
858 isTriangulation = false;
861 else // no faces, try edges
863 TopExp_Explorer expe (theShape, TopAbs_EDGE);
865 isTriangulation = false;
868 TopLoc_Location aLoc;
869 Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc);
871 isTriangulation = false;
875 return isTriangulation;
878 //=======================================================================
879 //function : IsCompositeShape
881 //=======================================================================
882 Standard_Boolean GEOMAlgo_AlgoTools::IsCompositeShape(const TopoDS_Shape& aS)
884 Standard_Boolean bRet;
885 Standard_Integer iCnt;
894 //=======================================================================
895 //function : GetCount
897 //=======================================================================
898 void GetCount(const TopoDS_Shape& aS,
899 Standard_Integer& iCnt)
902 TopAbs_ShapeEnum aTS;
906 if (aTS==TopAbs_SHAPE) {
909 if (aTS!=TopAbs_COMPOUND) {
915 for (; aIt.More(); aIt.Next()) {
916 const TopoDS_Shape& aSx=aIt.Value();
920 //=======================================================================
921 //function : PntInFace
923 //=======================================================================
924 Standard_Integer GEOMAlgo_AlgoTools::PntInFace(const TopoDS_Face& aF,
928 Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint;
929 Standard_Integer iErr, aIx, aNbDomains, i;
930 Standard_Real aUMin, aUMax, aVMin, aVMax;
931 Standard_Real aVx, aUx, aV1, aV2, aU1, aU2, aEpsT;
932 Standard_Real aTotArcIntr, aTolTangfIntr, aTolHatch2D, aTolHatch3D;
933 gp_Dir2d aD2D (0., 1.);
936 Handle(Geom2d_Curve) aC2D;
937 Handle(Geom2d_TrimmedCurve) aCT2D;
938 Handle(Geom2d_Line) aL2D;
939 Handle(Geom_Surface) aS;
940 TopAbs_Orientation aOrE;
942 TopExp_Explorer aExp;
947 aTolTangfIntr=1.e-10;
949 Geom2dHatch_Intersector aIntr(aTotArcIntr, aTolTangfIntr);
950 Geom2dHatch_Hatcher aHatcher(aIntr,
951 aTolHatch2D, aTolHatch3D,
952 Standard_True, Standard_False);
958 aFF.Orientation (TopAbs_FORWARD);
960 aS=BRep_Tool::Surface(aFF);
961 BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax);
964 aExp.Init (aFF, TopAbs_EDGE);
965 for (; aExp.More() ; aExp.Next()) {
966 const TopoDS_Edge& aE=*((TopoDS_Edge*)&aExp.Current());
967 aOrE=aE.Orientation();
969 aC2D=BRep_Tool::CurveOnSurface (aE, aFF, aU1, aU2);
970 if (aC2D.IsNull() ) {
974 if (fabs(aU1-aU2) < aEpsT) {
979 aCT2D=new Geom2d_TrimmedCurve(aC2D, aU1, aU2);
980 aHatcher.AddElement(aCT2D, aOrE);
981 }// for (; aExp.More() ; aExp.Next()) {
984 aUx=IntTools_Tools::IntermediatePoint(aUMin, aUMax);
985 aP2D.SetCoord(aUx, 0.);
986 aL2D=new Geom2d_Line (aP2D, aD2D);
987 Geom2dAdaptor_Curve aHCur(aL2D);
989 aIx=aHatcher.AddHatching(aHCur) ;
993 bIsDone=aHatcher.TrimDone(aIx);
999 aHatcher.ComputeDomains(aIx);
1000 bIsDone=aHatcher.IsDone(aIx);
1008 aNbDomains=aHatcher.NbDomains(aIx);
1015 const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
1016 bHasFirstPoint=aDomain.HasFirstPoint();
1017 if (!bHasFirstPoint) {
1022 aV1=aDomain.FirstPoint().Parameter();
1024 bHasSecondPoint=aDomain.HasSecondPoint();
1025 if (!bHasSecondPoint) {
1030 aV2=aDomain.SecondPoint().Parameter();
1032 aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
1034 aS->D0(aUx, aVx, aPx);
1036 theP2D.SetCoord(aUx, aVx);