1 // Copyright (C) 2007-2014 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 BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aEnew, aF);
226 aC2D=BRep_Tool::CurveOnSurface(aEnew, aF, aT1, aT2);
232 bIsClosed=BRep_Tool::IsClosed(aEold, aF);
239 // 1. bUClosed - direction of closeness
242 aES.Orientation(TopAbs_FORWARD);
243 aC2DS1=BRep_Tool::CurveOnSurface(aES, aF, aTS1, aTS2);
245 aES.Orientation(TopAbs_REVERSED);
246 aC2DS2=BRep_Tool::CurveOnSurface(aES, aF, aTS1, aTS2);
248 aTS=IntTools_Tools::IntermediatePoint(aTS1, aTS2);
250 aC2DS1->D1(aTS, aP2DS1, aV2DS1);
251 aC2DS2->D1(aTS, aP2DS2, aV2DS2);
253 gp_Vec2d aV2DS12(aP2DS1, aP2DS2);
254 gp_Dir2d aD2DS12(aV2DS12);
255 const gp_Dir2d& aD2DX=gp::DX2d();
258 bUClosed=Standard_True;
259 if (fabs(aScPr) < aTol) {
263 // 2. aP2D - point on curve aC2D, that corresponds to aP2DS1
264 aP2DS1.Coord(aUS1, aVS1);
265 aP2DS2.Coord(aUS2, aVS2);
267 aS=BRep_Tool::Surface(aF);
268 aS->D0(aUS1, aVS1, aP);
270 GeomAPI_ProjectPointOnCurve& aProjPC=aCtx->ProjPC(aEnew);
273 aNbPoints=aProjPC.NbPoints();
279 aT=aProjPC.LowerDistanceParameter();
282 // 3. Build the second 2D curve
283 Standard_Boolean bRevOrder;
284 gp_Vec2d aV2DT, aV2D;
285 Handle(Geom2d_Curve) aC2Dnew;
286 Handle(Geom2d_TrimmedCurve) aC2DTnew;
289 aC2D->D1(aT, aP2D, aV2D);
292 aC2Dnew=Handle(Geom2d_Curve)::DownCast(aC2D->Copy());
293 aC2DTnew = new Geom2d_TrimmedCurve(aC2Dnew, aT1, aT2);
296 if (!bUClosed) { // V Closed
297 if (fabs(aV-aVS2)<aTol) {
302 if (fabs(aU-aUS2)<aTol) {
307 aC2DTnew->Translate(aV2DT);
309 // 4 Order the 2D curves
310 bRevOrder=Standard_False;
313 bRevOrder=!bRevOrder;
316 // 5. Update the edge
317 aTol=BRep_Tool::Tolerance(aEnew);
319 aBB.UpdateEdge(aEnew, aC2D, aC2DTnew, aF, aTol);
322 aBB.UpdateEdge(aEnew, aC2DTnew, aC2D , aF, aTol);
327 //////////////////////////////////////////////////////////////////////////
328 //=======================================================================
329 // function: MakeContainer
331 //=======================================================================
332 void GEOMAlgo_AlgoTools::MakeContainer(const TopAbs_ShapeEnum theType,
338 case TopAbs_COMPOUND:{
340 aBB.MakeCompound(aC);
345 case TopAbs_COMPSOLID:{
346 TopoDS_CompSolid aCS;
347 aBB.MakeCompSolid(aCS);
354 aBB.MakeSolid(aSolid);
362 aBB.MakeShell(aShell);
378 //=======================================================================
379 //function : IsUPeriodic
381 //=======================================================================
382 Standard_Boolean GEOMAlgo_AlgoTools::IsUPeriodic(const Handle(Geom_Surface) &aS)
384 Standard_Boolean bRet;
385 GeomAbs_SurfaceType aType;
386 GeomAdaptor_Surface aGAS;
389 aType=aGAS.GetType();
390 bRet=(aType==GeomAbs_Cylinder||
391 aType==GeomAbs_Cone ||
392 aType==GeomAbs_Sphere);
397 //=======================================================================
398 //function : RefinePCurveForEdgeOnFace
400 //=======================================================================
401 void GEOMAlgo_AlgoTools::RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,
402 const TopoDS_Face& aF,
403 const Standard_Real aUMin,
404 const Standard_Real aUMax)
406 Standard_Real aT1, aT2, aTx, aUx, aTol;
408 Handle(Geom_Surface) aS;
409 Handle(Geom2d_Curve) aC2D;
412 aC2D=BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2);
413 if (!aC2D.IsNull()) {
414 if (BRep_Tool::IsClosed(aE, aF)) {
417 aTx=IntTools_Tools::IntermediatePoint(aT1, aT2);
420 if (aUx < aUMin || aUx > aUMax) {
422 Handle(Geom2d_Curve) aC2Dx;
424 aTol=BRep_Tool::Tolerance(aE);
425 aBB.UpdateEdge(aE, aC2Dx, aF, aTol);
429 //=======================================================================
430 //function :IsSplitToReverse
432 //=======================================================================
433 Standard_Boolean GEOMAlgo_AlgoTools::IsSplitToReverse
434 (const TopoDS_Edge& aEF1,
435 const TopoDS_Edge& aEF2,
436 #if OCC_VERSION_LARGE > 0x06070100
437 const Handle(IntTools_Context)& aContext
439 const Handle(BOPInt_Context)& aContext
443 Standard_Boolean aFlag;
444 Standard_Real aT1, aT2, aScPr, a, b;
449 Handle(Geom_Curve)aC1=BRep_Tool::Curve(aEF1, a, b);
450 aT1=IntTools_Tools::IntermediatePoint(a, b);
452 aFlag=BOPTools_AlgoTools2D::EdgeTangent(aEF1, aT1, aV1);
455 return Standard_False;
460 aFlag=aContext->ProjectPointOnEdge(aP, aEF2, aT2);
462 return Standard_False;
465 aFlag=BOPTools_AlgoTools2D::EdgeTangent(aEF2, aT2, aV2);
467 return Standard_False;
478 //=======================================================================
479 //function : ProjectPointOnShape
481 //=======================================================================
482 Standard_Boolean GEOMAlgo_AlgoTools::ProjectPointOnShape
484 const TopoDS_Shape& aS,
486 #if OCC_VERSION_LARGE > 0x06070100
487 const Handle(IntTools_Context)& aCtx
489 const Handle(BOPInt_Context)& aCtx
493 Standard_Boolean bIsDone = Standard_False;
495 TopAbs_ShapeEnum aType;
497 aType = aS.ShapeType();
502 const TopoDS_Edge& aE2 = TopoDS::Edge(aS);
504 if (BRep_Tool::Degenerated(aE2)) { // jfa
505 return Standard_True;
509 Handle(Geom_Curve) aC3D = BRep_Tool::Curve (aE2, f, l);
511 return Standard_True;
513 bIsDone = aCtx->ProjectPointOnEdge(aP1, aE2, aT2);
519 GEOMAlgo_AlgoTools::PointOnEdge(aE2, aT2, aP2);
525 const TopoDS_Face& aF2 = TopoDS::Face(aS);
526 GeomAPI_ProjectPointOnSurf& aProj = aCtx->ProjPS(aF2);
529 bIsDone = aProj.IsDone();
534 aP2 = aProj.NearestPoint();
544 //=======================================================================
545 //function : PointOnEdge
547 //=======================================================================
548 void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
551 Standard_Real aTx, aT1, aT2;
553 BRep_Tool::Curve(aE, aT1, aT2);
554 aTx=IntTools_Tools::IntermediatePoint(aT1, aT2);
555 GEOMAlgo_AlgoTools::PointOnEdge(aE, aTx, aP3D);
557 //=======================================================================
558 //function : PointOnEdge
560 //=======================================================================
561 void GEOMAlgo_AlgoTools::PointOnEdge(const TopoDS_Edge& aE,
562 const Standard_Real aT,
565 Standard_Real aT1, aT2;
566 Handle(Geom_Curve) aC3D;
568 aC3D=BRep_Tool::Curve(aE, aT1, aT2);
571 //=======================================================================
572 //function : PointOnFace
574 //=======================================================================
575 void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
576 const Standard_Real aU,
577 const Standard_Real aV,
580 Handle(Geom_Surface) aS;
582 aS=BRep_Tool::Surface(aF);
583 aS->D0(aU, aV, aP3D);
585 //=======================================================================
586 //function : PointOnFace
588 //=======================================================================
589 void GEOMAlgo_AlgoTools::PointOnFace(const TopoDS_Face& aF,
592 Standard_Real aU, aV, aUMin, aUMax, aVMin, aVMax;
594 BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
596 aU=IntTools_Tools::IntermediatePoint(aUMin, aUMax);
597 aV=IntTools_Tools::IntermediatePoint(aVMin, aVMax);
599 GEOMAlgo_AlgoTools::PointOnFace(aF, aU, aV, aP3D);
601 //=======================================================================
602 //function : PointOnShape
604 //=======================================================================
605 void GEOMAlgo_AlgoTools::PointOnShape(const TopoDS_Shape& aS,
608 TopAbs_ShapeEnum aType;
610 aP3D.SetCoord(99.,99.,99.);
611 aType=aS.ShapeType();
614 const TopoDS_Edge& aE=TopoDS::Edge(aS);
615 GEOMAlgo_AlgoTools::PointOnEdge(aE, aP3D);
620 const TopoDS_Face& aF=TopoDS::Face(aS);
621 GEOMAlgo_AlgoTools::PointOnFace(aF, aP3D);
629 //=======================================================================
630 //function : FindSDShapes
632 //=======================================================================
633 Standard_Integer GEOMAlgo_AlgoTools::FindSDShapes
634 (const TopoDS_Shape& aE1,
635 const TopTools_ListOfShape& aLE,
636 const Standard_Real aTol,
637 TopTools_ListOfShape& aLESD,
638 #if OCC_VERSION_LARGE > 0x06070100
639 const Handle(IntTools_Context)& aCtx
641 const Handle(BOPInt_Context)& aCtx
645 Standard_Boolean bIsDone;
646 Standard_Real aTol2, aD2;
648 TopTools_ListIteratorOfListOfShape aIt;
651 GEOMAlgo_AlgoTools::PointOnShape(aE1, aP1);
654 for (; aIt.More(); aIt.Next()) {
655 const TopoDS_Shape& aE2=aIt.Value();
656 if (aE2.IsSame(aE1)) {
660 bIsDone=GEOMAlgo_AlgoTools::ProjectPointOnShape(aP1, aE2, aP2, aCtx);
663 continue; // jfa BUG 20361
665 aD2=aP1.SquareDistance(aP2);
674 //=======================================================================
675 //function : FindSDShapes
677 //=======================================================================
678 Standard_Integer GEOMAlgo_AlgoTools::FindSDShapes
679 (const TopTools_ListOfShape& aLE,
680 const Standard_Real aTol,
681 TopTools_IndexedDataMapOfShapeListOfShape& aMEE,
682 #if OCC_VERSION_LARGE > 0x06070100
683 const Handle(IntTools_Context)& aCtx
685 const Handle(BOPInt_Context)& aCtx
689 Standard_Integer aNbE, aNbEProcessed, aNbESD, iErr;
690 TopTools_ListOfShape aLESD;
691 TopTools_ListIteratorOfListOfShape aIt, aIt1;
692 TopTools_IndexedMapOfShape aMProcessed;
693 TopAbs_ShapeEnum aType;
700 return 0; // Nothing to do
704 aNbEProcessed=aMProcessed.Extent();
705 if (aNbEProcessed==aNbE) {
710 for (; aIt.More(); aIt.Next()) {
711 const TopoDS_Shape& aS=aIt.Value();
713 if (aMProcessed.Contains(aS)) {
717 aType=aS.ShapeType();
718 if (aType==TopAbs_EDGE) {
719 const TopoDS_Edge& aE=TopoDS::Edge(aS);
720 if (BRep_Tool::Degenerated(aE)) {
727 iErr=GEOMAlgo_AlgoTools::FindSDShapes(aS, aLE, aTol, aLESD, aCtx);
732 aNbESD=aLESD.Extent();
739 aIt1.Initialize(aLESD);
740 for (; aIt1.More(); aIt1.Next()) {
741 const TopoDS_Shape& aE1=aIt1.Value();
742 aMProcessed.Add(aE1);
748 //=======================================================================
749 //function : RefineSDShapes
751 //=======================================================================
752 Standard_Integer GEOMAlgo_AlgoTools::RefineSDShapes
753 (GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMPKLE,
754 const Standard_Real aTol,
755 #if OCC_VERSION_LARGE > 0x06070100
756 const Handle(IntTools_Context)& aCtx
758 const Handle(BOPInt_Context)& aCtx
762 Standard_Integer i, aNbE, iErr, j, aNbEE, aNbToAdd;
763 TopTools_IndexedDataMapOfShapeListOfShape aMEE, aMSDE, aMEToAdd;
767 aNbE=aMPKLE.Extent();
768 for (i=1; i<=aNbE; ++i) {
769 TopTools_ListOfShape& aLSDE=aMPKLE.ChangeFromIndex(i);
772 iErr=GEOMAlgo_AlgoTools::FindSDShapes(aLSDE, aTol, aMEE, aCtx);
779 continue; // nothing to do
782 for (j=1; j<=aNbEE; ++j) {
783 TopTools_ListOfShape& aLEE=aMEE.ChangeFromIndex(j);
790 const TopoDS_Shape& aE1=aLEE.First();
791 aMEToAdd.Add(aE1, aLEE);
796 aNbToAdd=aMEToAdd.Extent();
801 for (i=1; i<=aNbToAdd; ++i) {
802 GEOMAlgo_PassKeyShape aPKE1;
804 const TopoDS_Shape& aE1=aMEToAdd.FindKey(i);
805 const TopTools_ListOfShape& aLE=aMEToAdd(i);
807 aPKE1.SetShapes(aE1);
808 aMPKLE.Add(aPKE1, aLE);
813 //=======================================================================
814 //function : BuildTriangulation
816 //=======================================================================
818 GEOMAlgo_AlgoTools::BuildTriangulation (const TopoDS_Shape& theShape)
820 // calculate deflection
821 Standard_Real aDeviationCoefficient = 0.001;
824 BRepBndLib::Add(theShape, B);
825 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
826 B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
828 Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin;
829 Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4;
830 Standard_Real aHLRAngle = 0.349066;
832 // build triangulation
833 BRepMesh_IncrementalMesh Inc (theShape, aDeflection, Standard_False, aHLRAngle);
835 // check triangulation
836 bool isTriangulation = true;
838 TopExp_Explorer exp (theShape, TopAbs_FACE);
841 TopLoc_Location aTopLoc;
842 Handle(Poly_Triangulation) aTRF;
843 aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc);
845 isTriangulation = false;
848 else // no faces, try edges
850 TopExp_Explorer expe (theShape, TopAbs_EDGE);
852 isTriangulation = false;
855 TopLoc_Location aLoc;
856 Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc);
858 isTriangulation = false;
862 return isTriangulation;
865 //=======================================================================
866 //function : IsCompositeShape
868 //=======================================================================
869 Standard_Boolean GEOMAlgo_AlgoTools::IsCompositeShape(const TopoDS_Shape& aS)
871 Standard_Boolean bRet;
872 Standard_Integer iCnt;
881 //=======================================================================
882 //function : GetCount
884 //=======================================================================
885 void GetCount(const TopoDS_Shape& aS,
886 Standard_Integer& iCnt)
889 TopAbs_ShapeEnum aTS;
893 if (aTS==TopAbs_SHAPE) {
896 if (aTS!=TopAbs_COMPOUND) {
902 for (; aIt.More(); aIt.Next()) {
903 const TopoDS_Shape& aSx=aIt.Value();
907 //=======================================================================
908 //function : PntInFace
910 //=======================================================================
911 Standard_Integer GEOMAlgo_AlgoTools::PntInFace(const TopoDS_Face& aF,
915 Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint;
916 Standard_Integer iErr, aIx, aNbDomains, i;
917 Standard_Real aUMin, aUMax, aVMin, aVMax;
918 Standard_Real aVx, aUx, aV1, aV2, aU1, aU2, aEpsT;
919 Standard_Real aTotArcIntr, aTolTangfIntr, aTolHatch2D, aTolHatch3D;
920 gp_Dir2d aD2D (0., 1.);
923 Handle(Geom2d_Curve) aC2D;
924 Handle(Geom2d_TrimmedCurve) aCT2D;
925 Handle(Geom2d_Line) aL2D;
926 Handle(Geom_Surface) aS;
927 TopAbs_Orientation aOrE;
929 TopExp_Explorer aExp;
934 aTolTangfIntr=1.e-10;
936 Geom2dHatch_Intersector aIntr(aTotArcIntr, aTolTangfIntr);
937 Geom2dHatch_Hatcher aHatcher(aIntr,
938 aTolHatch2D, aTolHatch3D,
939 Standard_True, Standard_False);
945 aFF.Orientation (TopAbs_FORWARD);
947 aS=BRep_Tool::Surface(aFF);
948 BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax);
951 aExp.Init (aFF, TopAbs_EDGE);
952 for (; aExp.More() ; aExp.Next()) {
953 const TopoDS_Edge& aE=*((TopoDS_Edge*)&aExp.Current());
954 aOrE=aE.Orientation();
956 aC2D=BRep_Tool::CurveOnSurface (aE, aFF, aU1, aU2);
957 if (aC2D.IsNull() ) {
961 if (fabs(aU1-aU2) < aEpsT) {
966 aCT2D=new Geom2d_TrimmedCurve(aC2D, aU1, aU2);
967 aHatcher.AddElement(aCT2D, aOrE);
968 }// for (; aExp.More() ; aExp.Next()) {
971 aUx=IntTools_Tools::IntermediatePoint(aUMin, aUMax);
972 aP2D.SetCoord(aUx, 0.);
973 aL2D=new Geom2d_Line (aP2D, aD2D);
974 Geom2dAdaptor_Curve aHCur(aL2D);
976 aIx=aHatcher.AddHatching(aHCur) ;
980 bIsDone=aHatcher.TrimDone(aIx);
986 aHatcher.ComputeDomains(aIx);
987 bIsDone=aHatcher.IsDone(aIx);
994 aNbDomains=aHatcher.NbDomains(aIx);
995 for (i=1; i<=aNbDomains; ++i) {
996 const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
997 bHasFirstPoint=aDomain.HasFirstPoint();
998 if (!bHasFirstPoint) {
1003 aV1=aDomain.FirstPoint().Parameter();
1005 bHasSecondPoint=aDomain.HasSecondPoint();
1006 if (!bHasSecondPoint) {
1011 aV2=aDomain.SecondPoint().Parameter();
1013 aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
1018 aS->D0(aUx, aVx, aPx);
1020 theP2D.SetCoord(aUx, aVx);