X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNMTTools%2FNMTTools_Tools.cxx;h=e7c1d73c47b20eb3a2c08e50378fa682c2deebf8;hb=ccaa4673b9493057cce545295f1d9023024eb72d;hp=40cc24aab62696bad6646fb85ed841ecf2c4e16a;hpb=d3dd282390888d7dc091ba2c2ffe7923bd7458e6;p=modules%2Fgeom.git diff --git a/src/NMTTools/NMTTools_Tools.cxx b/src/NMTTools/NMTTools_Tools.cxx index 40cc24aab..e7c1d73c4 100644 --- a/src/NMTTools/NMTTools_Tools.cxx +++ b/src/NMTTools/NMTTools_Tools.cxx @@ -1,9 +1,30 @@ -// File: NMTTools_Tools.cxx -// Created: Mon Dec 8 10:35:15 2003 -// Author: Peter KURNEV -// - +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File: NMTTools_Tools.cxx +// Created: Mon Dec 8 10:35:15 2003 +// Author: Peter KURNEV +// +// #include #include @@ -48,26 +69,94 @@ #include #include #include +// +#include +#include +#include static void ProcessBlock(const Standard_Integer iV, - const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, - TColStd_IndexedMapOfInteger& aProcessed, - TColStd_IndexedMapOfInteger& aChain); + const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, + TColStd_IndexedMapOfInteger& aProcessed, + TColStd_IndexedMapOfInteger& aChain); static void ProcessBlock(const TopoDS_Shape& aF, - const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, - TopTools_IndexedMapOfShape& aProcessed, - TopTools_IndexedMapOfShape& aChain); + const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, + TopTools_IndexedMapOfShape& aProcessed, + TopTools_IndexedMapOfShape& aChain); +//modified by NIZNHY-PKV Thu Nov 16 10:46:53 2006f SKL/PartC5 +//======================================================================= +// function: UpdateEdge +// purpose: +//======================================================================= + void NMTTools_Tools::UpdateEdge(const TopoDS_Edge& aE, + const Standard_Real aTolR) +{ + Standard_Real aTolE, aTolES, aTolV; + TopoDS_Iterator aIt; + BRep_Builder aBB; + // + aTolE=BRep_Tool::Tolerance(aE); + aTolES=Max(aTolR, aTolE); + aBB.UpdateEdge(aE, aTolES); + // + aIt.Initialize(aE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aIt.Value()); + aTolV=BRep_Tool::Tolerance(aV); + if (aTolVIsPeriodic()) { + BOPTools_Tools2D::AdjustPCurveOnFace(aFFWD, aT1, aT2, aC2D, aC2DA); + } + else { + BOPTools_Tools2D::AdjustPCurveOnFace(aFFWD, aC3DETrim, aC2D, aC2DA); + } + // + aBB.UpdateEdge(aE, aC2DA, aFFWD, aTolE); + BRepLib::SameParameter(aE); +} +/* //======================================================================= // function: MakePCurve // purpose: //======================================================================= void NMTTools_Tools::MakePCurve(const TopoDS_Edge& aE, - const TopoDS_Face& aF, - const Handle(Geom2d_Curve)& aC2Dx, - const Standard_Real aTolR2D) + const TopoDS_Face& aF, + const Handle(Geom2d_Curve)& aC2Dx, + const Standard_Real aTolR2D) { Standard_Integer k, aNbV; Standard_Real aTolEdge, aTolFact, aTolV, aTolVmax; @@ -118,14 +207,15 @@ static aBB.UpdateEdge(aE, aC2DA, aFFWD, aTolFact); BRepLib::SameParameter(aE); } - +*/ +//modified by NIZNHY-PKV Thu Nov 16 10:46:55 2006t //======================================================================= // function: IsSplitInOnFace // purpose: //======================================================================= Standard_Boolean NMTTools_Tools::IsSplitInOnFace(const TopoDS_Edge& aE, - const TopoDS_Face& aF, - IntTools_Context& aContext) + const TopoDS_Face& aF, + IntTools_Context& aContext) { Standard_Boolean bFlag; Standard_Real aT, aTolE, aTolF, aTol, aDist, aU, aV; @@ -163,7 +253,7 @@ static // purpose : //======================================================================= void NMTTools_Tools::MakeNewVertex(const TopTools_ListOfShape& aLVs, - TopoDS_Vertex& aNewVertex) + TopoDS_Vertex& aNewVertex) { Standard_Integer aNb; Standard_Real aTi, aDi, aDmax=-1.e5; @@ -206,7 +296,7 @@ static // purpose : //======================================================================= void NMTTools_Tools::FindChains(const BOPTools_CArray1OfSSInterference& FFs, - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) { Standard_Boolean bIsTangentFaces; Standard_Integer j, aNb, anIndex1, anIndex2; @@ -254,7 +344,7 @@ static // purpose : //======================================================================= void NMTTools_Tools::FindChains(const BOPTools_CArray1OfVVInterference& VVs, - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) { Standard_Integer j, aNb, anIndex1, anIndex2; BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMCV; @@ -296,7 +386,7 @@ static // purpose : //======================================================================= void NMTTools_Tools::FindChains(const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, - BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) { Standard_Integer i, j, aNbCV, aNbV, iV, iVx; TColStd_IndexedMapOfInteger aProcessed, aChain; @@ -326,9 +416,9 @@ static // purpose: //======================================================================= void ProcessBlock(const Standard_Integer iV, - const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, - TColStd_IndexedMapOfInteger& aProcessed, - TColStd_IndexedMapOfInteger& aChain) + const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, + TColStd_IndexedMapOfInteger& aProcessed, + TColStd_IndexedMapOfInteger& aChain) { Standard_Integer j, aNbV, iVx; // @@ -350,25 +440,53 @@ void ProcessBlock(const Standard_Integer iV, // purpose : //======================================================================= Standard_Boolean NMTTools_Tools::AreFacesSameDomain(const TopoDS_Face& aF1x, - const TopoDS_Face& aF2y, - IntTools_Context& aCtx) + const TopoDS_Face& aF2y, + IntTools_Context& aCtx) { Standard_Boolean bFlag; - Standard_Integer i, aNbE1, aNbE2; - - TopTools_IndexedMapOfShape aME1, aME2; - TopoDS_Edge aEF1, aEF2; + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + Standard_Integer aNbE1, aNbE2; + Standard_Real aTolF1, aTolF2, aTol; + gp_Pnt2d aP2D; + gp_Pnt aP; TopoDS_Face aF1, aF2; + TopExp_Explorer aExp; + TopTools_MapOfShape aME1, aME2; + TopTools_MapIteratorOfMapOfShape aIt; + // + bFlag=Standard_False; + // Contribution of Samtech www.samcef.com END // aF1=aF1x; aF1.Orientation(TopAbs_FORWARD); aF2=aF2y; aF2.Orientation(TopAbs_FORWARD); // - TopExp::MapShapes(aF1, TopAbs_EDGE, aME1); - TopExp::MapShapes(aF2, TopAbs_EDGE, aME2); + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN // - bFlag=Standard_False; + // 1 + aExp.Init(aF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); + if (!BRep_Tool::Degenerated(aE)) { + aME1.Add(aE); + } + } + // + aExp.Init(aF2, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); + if (!BRep_Tool::Degenerated(aE)) { + if (!aME1.Contains(aE)) { + return bFlag; + } + aME2.Add(aE); + } + } + // + // Contribution of Samtech www.samcef.com END // aNbE1=aME1.Extent(); aNbE2=aME2.Extent(); @@ -381,72 +499,18 @@ void ProcessBlock(const Standard_Integer iV, return bFlag; } // - for (i=1; i<=aNbE1; ++i) { - const TopoDS_Edge& aE1=TopoDS::Edge(aME1(i)); - if (BRep_Tool::Degenerated(aE1)) { - // not try to compare deg edges because it - // can not have same TShape on different faces at all - continue; - } - if (!aME2.Contains(aE1)) { - return bFlag; - } - } - // - Standard_Real aTolF1, aTolF2, aTol; - gp_Pnt2d aP2D; - gp_Pnt aP; - TopExp_Explorer anExp; - // - aTolF1=BRep_Tool::Tolerance(aF1); - aTolF2=BRep_Tool::Tolerance(aF2); - aTol=aTolF1+aTolF2; - // - anExp.Init(aF1, TopAbs_EDGE); - for (; anExp.More(); anExp.Next()) { - const TopoDS_Edge& aE1=TopoDS::Edge(anExp.Current()); - if (!BRep_Tool::Degenerated(aE1)) { - BOPTools_Tools3D::PointNearEdge(aE1, aF1, aP2D, aP); - bFlag=aCtx.IsValidPointForFace(aP, aF2, aTol); - break; - } - } - return bFlag; - /* - // - Standard_Real aU1, aU2, aV1, aV2; - Standard_Real dU, dV, aU, aV; - Standard_Integer aNbP=5, aNbP1, j; - gp_Pnt2d aP2D; - gp_Pnt aP; - // + // 2 aTolF1=BRep_Tool::Tolerance(aF1); aTolF2=BRep_Tool::Tolerance(aF2); aTol=aTolF1+aTolF2; // - BRepTools::UVBounds(aF1, aU1, aU2, aV1, aV2); - Handle(Geom_Surface) aS1=BRep_Tool::Surface(aF1); - // - aNbP1=aNbP+1; - dU=(aU2-aU1)/aNbP1; - dV=(aV2-aV1)/aNbP1; - // - for (i=1; i<=aNbP; ++i) { - aU=aU1+i*dU; - for (j=1; j<=aNbP; ++j) { - aV=aV1+j*dV; - aP2D.SetCoord(aU, aV); - // - if(aCtx.IsPointInFace(aF1, aP2D)) { - aP=aS1->Value(aU, aV); - bFlag=aCtx.IsValidPointForFace(aP, aF2, aTol); - if (!bFlag) { - return bFlag; - } - } - } + aIt.Initialize(aME1); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aIt.Key()); + BOPTools_Tools3D::PointNearEdge(aE, aF1, aP2D, aP); + bFlag=aCtx.IsValidPointForFace(aP, aF2, aTol); + break; } - */ // return bFlag; } @@ -455,7 +519,7 @@ void ProcessBlock(const Standard_Integer iV, // purpose : //======================================================================= void NMTTools_Tools::FindChains(const NMTTools_ListOfCoupleOfShape& aLCS, - NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains) + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains) { NMTTools_ListIteratorOfListOfCoupleOfShape aItCS; NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMCV; @@ -499,7 +563,7 @@ void ProcessBlock(const Standard_Integer iV, // purpose : //======================================================================= void NMTTools_Tools::FindChains(const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, - NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains) + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains) { Standard_Integer i, j, aNbCV, aNbV; TopTools_IndexedMapOfShape aProcessed, aChain; @@ -529,9 +593,9 @@ void ProcessBlock(const Standard_Integer iV, // purpose: //======================================================================= void ProcessBlock(const TopoDS_Shape& aF, - const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, - TopTools_IndexedMapOfShape& aProcessed, - TopTools_IndexedMapOfShape& aChain) + const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, + TopTools_IndexedMapOfShape& aProcessed, + TopTools_IndexedMapOfShape& aChain) { Standard_Integer j, aNbV; //