1 // Copyright (C) 2006 SAMTECH
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
19 // File: NMTTools_CheckerSI.cxx
20 // Created: Mon Feb 19 11:32:08 2007
21 // Author: Peter KURNEV
25 #include <NMTTools_CheckerSI.ixx>
26 #include <NMTDS_ShapesDataStructure.hxx>
27 #include <NMTDS_IteratorCheckerSI.hxx>
29 #include <NMTDS_InterfPool.hxx>
30 #include <TopoDS_Edge.hxx>
31 #include <TopoDS_Vertex.hxx>
32 #include <BOPTools_ListOfPaveBlock.hxx>
34 #include <BRep_Tool.hxx>
35 #include <BOPTools_PaveSet.hxx>
36 #include <BOPTools_PaveBlockIterator.hxx>
37 #include <BOPTools_PaveBlock.hxx>
38 #include <IntTools_Range.hxx>
39 #include <BOPTools_Pave.hxx>
40 #include <IntTools_ShrunkRange.hxx>
41 #include <BOPTColStd_Failure.hxx>
42 #include <BOPTColStd_Dump.hxx>
43 #include <Geom_Curve.hxx>
49 Standard_Boolean IsValid(const TopoDS_Edge& aE,
50 const TopoDS_Vertex& aV,
51 const Standard_Real aTV1,
52 const Standard_Real aTV2);
54 //=======================================================================
55 // function: PreparePaveBlocks
57 //=======================================================================
58 void NMTTools_CheckerSI::PreparePaveBlocks(const TopAbs_ShapeEnum aType1,
59 const TopAbs_ShapeEnum aType2)
61 NMTTools_PaveFiller::PreparePaveBlocks(aType1, aType2);
63 //=======================================================================
64 // function: PreparePaveBlocks
66 //=======================================================================
67 void NMTTools_CheckerSI::PreparePaveBlocks(const Standard_Integer nE)
69 myIsDone=Standard_False;
72 Standard_Boolean bIsValid;
73 Standard_Integer nV1, nV2, iErr;
74 Standard_Real aT1, aT2;
76 TopoDS_Vertex aV1, aV2;
78 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
80 aE=TopoDS::Edge(myDS->Shape(nE));
81 if (BRep_Tool::Degenerated(aE)) {
82 myIsDone=Standard_True;
86 BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE));
88 BOPTools_PaveBlockIterator aPBIt(nE, aPS);
89 for (; aPBIt.More(); aPBIt.Next()) {
90 BOPTools_PaveBlock& aPB=aPBIt.Value();
91 const IntTools_Range& aRange=aPB.Range();
93 const BOPTools_Pave& aPave1=aPB.Pave1();
95 aV1=TopoDS::Vertex(myDS->Shape(nV1));
98 const BOPTools_Pave& aPave2=aPB.Pave2();
100 aV2=TopoDS::Vertex(myDS->Shape(nV2));
103 bIsValid=Standard_True;
105 bIsValid=IsValid(aE, aV1, aT1, aT2);
107 //printf(" pb SR: nV nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2);
112 IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext);
113 iErr=aSR.ErrorStatus();
115 //printf(" pb SR: Done nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2);
116 aSR.SetShrunkRange(aRange);
117 //throw BOPTColStd_Failure(buf) ;
120 CorrectShrunkRanges (0, aPave1, aSR);
121 CorrectShrunkRanges (1, aPave2, aSR);
123 aPB.SetShrunkRange(aSR);
125 } //for (; aPBIt.More(); aPBIt.Next())
126 myIsDone=Standard_True;
129 //=======================================================================
132 //=======================================================================
133 Standard_Boolean IsValid(const TopoDS_Edge& aE,
134 const TopoDS_Vertex& aV,
135 const Standard_Real aTV1,
136 const Standard_Real aTV2)
138 Standard_Boolean bRet;
139 Standard_Integer i, aNbP, aNbP1;
140 Standard_Real aTolV2, aTC1, aTC2, dT, aTC, aD2;
141 Handle(Geom_Curve) aC;
145 aTolV2=BRep_Tool::Tolerance(aV);
146 aTolV2=aTolV2*aTolV2;
147 aPV=BRep_Tool::Pnt(aV);
148 aC=BRep_Tool::Curve(aE, aTC1, aTC2);
151 dT=(aTV2-aTV1)/aNbP1;
153 for (i=1; i<aNbP-1 && !bRet ; ++i) {
156 aD2=aPV.SquareDistance(aPC);