1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: NMTTools_CheckerSI.cxx
21 // Created: Mon Feb 19 11:32:08 2007
22 // Author: Peter KURNEV
24 #include <NMTTools_CheckerSI.ixx>
25 #include <NMTDS_ShapesDataStructure.hxx>
26 #include <NMTDS_IteratorCheckerSI.hxx>
28 #include <NMTDS_InterfPool.hxx>
29 #include <TopoDS_Edge.hxx>
30 #include <TopoDS_Vertex.hxx>
31 #include <BOPTools_ListOfPaveBlock.hxx>
33 #include <BRep_Tool.hxx>
34 #include <BOPTools_PaveSet.hxx>
35 #include <BOPTools_PaveBlockIterator.hxx>
36 #include <BOPTools_PaveBlock.hxx>
37 #include <IntTools_Range.hxx>
38 #include <BOPTools_Pave.hxx>
39 #include <IntTools_ShrunkRange.hxx>
40 #include <BOPTColStd_Failure.hxx>
41 #include <BOPTColStd_Dump.hxx>
42 #include <Geom_Curve.hxx>
48 Standard_Boolean IsValid(const TopoDS_Edge& aE,
49 const TopoDS_Vertex& aV,
50 const Standard_Real aTV1,
51 const Standard_Real aTV2);
53 //=======================================================================
54 // function: PreparePaveBlocks
56 //=======================================================================
57 void NMTTools_CheckerSI::PreparePaveBlocks(const TopAbs_ShapeEnum aType1,
58 const TopAbs_ShapeEnum aType2)
60 NMTTools_PaveFiller::PreparePaveBlocks(aType1, aType2);
62 //=======================================================================
63 // function: PreparePaveBlocks
65 //=======================================================================
66 void NMTTools_CheckerSI::PreparePaveBlocks(const Standard_Integer nE)
68 myIsDone=Standard_False;
70 // char buf[32]={"SR"};
71 Standard_Boolean bIsValid;
72 Standard_Integer nV1, nV2, iErr;
73 Standard_Real aT1, aT2;
75 TopoDS_Vertex aV1, aV2;
77 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
79 aE=TopoDS::Edge(myDS->Shape(nE));
80 if (BRep_Tool::Degenerated(aE)) {
81 myIsDone=Standard_True;
85 BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE));
87 BOPTools_PaveBlockIterator aPBIt(nE, aPS);
88 for (; aPBIt.More(); aPBIt.Next()) {
89 BOPTools_PaveBlock& aPB=aPBIt.Value();
90 const IntTools_Range& aRange=aPB.Range();
92 const BOPTools_Pave& aPave1=aPB.Pave1();
94 aV1=TopoDS::Vertex(myDS->Shape(nV1));
97 const BOPTools_Pave& aPave2=aPB.Pave2();
99 aV2=TopoDS::Vertex(myDS->Shape(nV2));
102 bIsValid=Standard_True;
104 bIsValid=IsValid(aE, aV1, aT1, aT2);
106 //printf(" pb SR: nV nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2);
111 IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext);
112 iErr=aSR.ErrorStatus();
114 //printf(" pb SR: Done nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2);
115 aSR.SetShrunkRange(aRange);
116 //throw BOPTColStd_Failure(buf) ;
119 CorrectShrunkRanges (0, aPave1, aSR);
120 CorrectShrunkRanges (1, aPave2, aSR);
122 aPB.SetShrunkRange(aSR);
124 } //for (; aPBIt.More(); aPBIt.Next())
125 myIsDone=Standard_True;
128 //=======================================================================
131 //=======================================================================
132 Standard_Boolean IsValid(const TopoDS_Edge& aE,
133 const TopoDS_Vertex& aV,
134 const Standard_Real aTV1,
135 const Standard_Real aTV2)
137 Standard_Boolean bRet;
138 Standard_Integer i, aNbP, aNbP1;
139 Standard_Real aTolV2, aTC1, aTC2, dT, aTC, aD2;
140 Handle(Geom_Curve) aC;
144 aTolV2=BRep_Tool::Tolerance(aV);
145 aTolV2=aTolV2*aTolV2;
146 aPV=BRep_Tool::Pnt(aV);
147 aC=BRep_Tool::Curve(aE, aTC1, aTC2);
150 dT=(aTV2-aTV1)/aNbP1;
152 for (i=1; i<aNbP-1 && !bRet ; ++i) {
155 aD2=aPV.SquareDistance(aPC);