1 // Copyright (C) 2007-2013 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.hxx>
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>
45 //=======================================================================
46 // function: PreparePaveBlocks
48 //=======================================================================
49 void NMTTools_CheckerSI::PreparePaveBlocks(const TopAbs_ShapeEnum aType1,
50 const TopAbs_ShapeEnum aType2)
52 NMTTools_PaveFiller::PreparePaveBlocks(aType1, aType2);
54 //=======================================================================
55 // function: PreparePaveBlocks
57 //=======================================================================
58 void NMTTools_CheckerSI::PreparePaveBlocks(const Standard_Integer nE)
60 //Standard_Boolean bIsValid;
61 Standard_Integer nV1, nV2, iErr;
62 Standard_Real aT1, aT2;
64 TopoDS_Vertex aV1, aV2;
66 myIsDone=Standard_False;
68 BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
70 aE=TopoDS::Edge(myDS->Shape(nE));
71 if (BRep_Tool::Degenerated(aE)) {
72 myIsDone=Standard_True;
76 BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE));
78 BOPTools_PaveBlockIterator aPBIt(nE, aPS);
79 for (; aPBIt.More(); aPBIt.Next()) {
80 BOPTools_PaveBlock& aPB=aPBIt.Value();
81 const IntTools_Range& aRange=aPB.Range();
83 const BOPTools_Pave& aPave1=aPB.Pave1();
85 aV1=TopoDS::Vertex(myDS->Shape(nV1));
88 const BOPTools_Pave& aPave2=aPB.Pave2();
90 aV2=TopoDS::Vertex(myDS->Shape(nV2));
93 //modified by NIZNHY-PKV Thu Nov 01 13:46:00 2012f
94 //w/a: http://salome.mantis.opencascade.com/view.php?id=21835
96 bIsValid=Standard_True;
98 bIsValid=IsValid(aE, aV1, aT1, aT2);
104 //modified by NIZNHY-PKV Thu Nov 01 13:46:09 2012t
106 IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext);
107 iErr=aSR.ErrorStatus();
109 aSR.SetShrunkRange(aRange);
112 CorrectShrunkRanges (0, aPave1, aSR);
113 CorrectShrunkRanges (1, aPave2, aSR);
115 aPB.SetShrunkRange(aSR);
117 } //for (; aPBIt.More(); aPBIt.Next())
118 myIsDone=Standard_True;
120 //modified by NIZNHY-PKV Thu Nov 01 13:46:55 2012f
121 //w/a: http://salome.mantis.opencascade.com/view.php?id=21835
123 //=======================================================================
126 //=======================================================================
127 Standard_Boolean IsValid(const TopoDS_Edge& aE,
128 const TopoDS_Vertex& aV,
129 const Standard_Real aTV1,
130 const Standard_Real aTV2)
132 Standard_Boolean bRet;
133 Standard_Integer i, aNbP, aNbP1;
134 Standard_Real aTolV2, aTC1, aTC2, dT, aTC, aD2;
135 Handle(Geom_Curve) aC;
139 aTolV2=BRep_Tool::Tolerance(aV);
140 aTolV2=aTolV2*aTolV2;
141 aPV=BRep_Tool::Pnt(aV);
142 aC=BRep_Tool::Curve(aE, aTC1, aTC2);
145 dT=(aTV2-aTV1)/aNbP1;
147 for (i=1; i<aNbP-1 && !bRet ; ++i) {
150 aD2=aPV.SquareDistance(aPC);
156 //modified by NIZNHY-PKV Thu Nov 01 13:47:07 2012t