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
26 #include <NMTTools_CheckerSI.ixx>
27 #include <NMTDS_ShapesDataStructure.hxx>
28 #include <NMTDS_IteratorCheckerSI.hxx>
30 #include <NMTDS_InterfPool.hxx>
31 #include <TopoDS_Edge.hxx>
32 #include <TopoDS_Vertex.hxx>
33 #include <BOPTools_ListOfPaveBlock.hxx>
35 #include <BRep_Tool.hxx>
36 #include <BOPTools_PaveSet.hxx>
37 #include <BOPTools_PaveBlockIterator.hxx>
38 #include <BOPTools_PaveBlock.hxx>
39 #include <IntTools_Range.hxx>
40 #include <BOPTools_Pave.hxx>
41 #include <IntTools_ShrunkRange.hxx>
42 #include <BOPTColStd_Failure.hxx>
43 #include <BOPTColStd_Dump.hxx>
44 #include <Geom_Curve.hxx>
50 Standard_Boolean IsValid(const TopoDS_Edge& aE,
51 const TopoDS_Vertex& aV,
52 const Standard_Real aTV1,
53 const Standard_Real aTV2);
55 //=======================================================================
56 // function: PreparePaveBlocks
58 //=======================================================================
59 void NMTTools_CheckerSI::PreparePaveBlocks(const TopAbs_ShapeEnum aType1,
60 const TopAbs_ShapeEnum aType2)
62 NMTTools_PaveFiller::PreparePaveBlocks(aType1, aType2);
64 //=======================================================================
65 // function: PreparePaveBlocks
67 //=======================================================================
68 void NMTTools_CheckerSI::PreparePaveBlocks(const Standard_Integer nE)
70 myIsDone=Standard_False;
73 Standard_Boolean bIsValid;
74 Standard_Integer nV1, nV2, iErr;
75 Standard_Real aT1, aT2;
77 TopoDS_Vertex aV1, aV2;
79 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
81 aE=TopoDS::Edge(myDS->Shape(nE));
82 if (BRep_Tool::Degenerated(aE)) {
83 myIsDone=Standard_True;
87 BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE));
89 BOPTools_PaveBlockIterator aPBIt(nE, aPS);
90 for (; aPBIt.More(); aPBIt.Next()) {
91 BOPTools_PaveBlock& aPB=aPBIt.Value();
92 const IntTools_Range& aRange=aPB.Range();
94 const BOPTools_Pave& aPave1=aPB.Pave1();
96 aV1=TopoDS::Vertex(myDS->Shape(nV1));
99 const BOPTools_Pave& aPave2=aPB.Pave2();
101 aV2=TopoDS::Vertex(myDS->Shape(nV2));
104 bIsValid=Standard_True;
106 bIsValid=IsValid(aE, aV1, aT1, aT2);
108 //printf(" pb SR: nV nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2);
113 IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext);
114 iErr=aSR.ErrorStatus();
116 //printf(" pb SR: Done nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2);
117 aSR.SetShrunkRange(aRange);
118 //throw BOPTColStd_Failure(buf) ;
121 CorrectShrunkRanges (0, aPave1, aSR);
122 CorrectShrunkRanges (1, aPave2, aSR);
124 aPB.SetShrunkRange(aSR);
126 } //for (; aPBIt.More(); aPBIt.Next())
127 myIsDone=Standard_True;
130 //=======================================================================
133 //=======================================================================
134 Standard_Boolean IsValid(const TopoDS_Edge& aE,
135 const TopoDS_Vertex& aV,
136 const Standard_Real aTV1,
137 const Standard_Real aTV2)
139 Standard_Boolean bRet;
140 Standard_Integer i, aNbP, aNbP1;
141 Standard_Real aTolV2, aTC1, aTC2, dT, aTC, aD2;
142 Handle(Geom_Curve) aC;
146 aTolV2=BRep_Tool::Tolerance(aV);
147 aTolV2=aTolV2*aTolV2;
148 aPV=BRep_Tool::Pnt(aV);
149 aC=BRep_Tool::Curve(aE, aTC1, aTC2);
152 dT=(aTV2-aTV1)/aNbP1;
154 for (i=1; i<aNbP-1 && !bRet ; ++i) {
157 aD2=aPV.SquareDistance(aPC);