1 // Copyright (C) 2007-2008 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.
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: NMTTools_CheckerSI.cxx
23 // Created: Mon Feb 19 11:32:08 2007
24 // Author: Peter KURNEV
27 #include <NMTTools_CheckerSI.ixx>
28 #include <NMTDS_ShapesDataStructure.hxx>
29 #include <NMTDS_IteratorCheckerSI.hxx>
31 #include <NMTDS_InterfPool.hxx>
32 #include <TopoDS_Edge.hxx>
33 #include <TopoDS_Vertex.hxx>
34 #include <BOPTools_ListOfPaveBlock.hxx>
36 #include <BRep_Tool.hxx>
37 #include <BOPTools_PaveSet.hxx>
38 #include <BOPTools_PaveBlockIterator.hxx>
39 #include <BOPTools_PaveBlock.hxx>
40 #include <IntTools_Range.hxx>
41 #include <BOPTools_Pave.hxx>
42 #include <IntTools_ShrunkRange.hxx>
43 #include <BOPTColStd_Failure.hxx>
44 #include <BOPTColStd_Dump.hxx>
45 #include <Geom_Curve.hxx>
51 Standard_Boolean IsValid(const TopoDS_Edge& aE,
52 const TopoDS_Vertex& aV,
53 const Standard_Real aTV1,
54 const Standard_Real aTV2);
56 //=======================================================================
57 // function: PreparePaveBlocks
59 //=======================================================================
60 void NMTTools_CheckerSI::PreparePaveBlocks(const TopAbs_ShapeEnum aType1,
61 const TopAbs_ShapeEnum aType2)
63 NMTTools_PaveFiller::PreparePaveBlocks(aType1, aType2);
65 //=======================================================================
66 // function: PreparePaveBlocks
68 //=======================================================================
69 void NMTTools_CheckerSI::PreparePaveBlocks(const Standard_Integer nE)
71 myIsDone=Standard_False;
74 Standard_Boolean bIsValid;
75 Standard_Integer nV1, nV2, iErr;
76 Standard_Real aT1, aT2;
78 TopoDS_Vertex aV1, aV2;
80 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
82 aE=TopoDS::Edge(myDS->Shape(nE));
83 if (BRep_Tool::Degenerated(aE)) {
84 myIsDone=Standard_True;
88 BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE));
90 BOPTools_PaveBlockIterator aPBIt(nE, aPS);
91 for (; aPBIt.More(); aPBIt.Next()) {
92 BOPTools_PaveBlock& aPB=aPBIt.Value();
93 const IntTools_Range& aRange=aPB.Range();
95 const BOPTools_Pave& aPave1=aPB.Pave1();
97 aV1=TopoDS::Vertex(myDS->Shape(nV1));
100 const BOPTools_Pave& aPave2=aPB.Pave2();
102 aV2=TopoDS::Vertex(myDS->Shape(nV2));
105 bIsValid=Standard_True;
107 bIsValid=IsValid(aE, aV1, aT1, aT2);
109 //printf(" pb SR: nV nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2);
114 IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext);
115 iErr=aSR.ErrorStatus();
117 //printf(" pb SR: Done nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2);
118 aSR.SetShrunkRange(aRange);
119 //throw BOPTColStd_Failure(buf) ;
122 CorrectShrunkRanges (0, aPave1, aSR);
123 CorrectShrunkRanges (1, aPave2, aSR);
125 aPB.SetShrunkRange(aSR);
127 } //for (; aPBIt.More(); aPBIt.Next())
128 myIsDone=Standard_True;
131 //=======================================================================
134 //=======================================================================
135 Standard_Boolean IsValid(const TopoDS_Edge& aE,
136 const TopoDS_Vertex& aV,
137 const Standard_Real aTV1,
138 const Standard_Real aTV2)
140 Standard_Boolean bRet;
141 Standard_Integer i, aNbP, aNbP1;
142 Standard_Real aTolV2, aTC1, aTC2, dT, aTC, aD2;
143 Handle(Geom_Curve) aC;
147 aTolV2=BRep_Tool::Tolerance(aV);
148 aTolV2=aTolV2*aTolV2;
149 aPV=BRep_Tool::Pnt(aV);
150 aC=BRep_Tool::Curve(aE, aTC1, aTC2);
153 dT=(aTV2-aTV1)/aNbP1;
155 for (i=1; i<aNbP-1 && !bRet ; ++i) {
158 aD2=aPV.SquareDistance(aPC);