Back to index

salome-geom  6.5.0
NMTTools_PaveFiller_2.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:        NMTTools_PaveFiller_2.cxx
00024 // Created:     Mon Dec  8 12:02:56 2003
00025 // Author:      Peter KURNEV
00026 
00027 #include <Standard_Version.hxx>
00028 
00029 #include <NMTTools_PaveFiller.hxx>
00030 
00031 #include <Basics_OCCTVersion.hxx>
00032 
00033 #include <Precision.hxx>
00034 
00035 #include <gp_Pnt.hxx>
00036 
00037 #include <Geom_Curve.hxx>
00038 
00039 #include <TopAbs_Orientation.hxx>
00040 
00041 #include <TopoDS.hxx>
00042 #include <TopoDS_Edge.hxx>
00043 #include <TopoDS_Vertex.hxx>
00044 #include <TopoDS_Iterator.hxx>
00045 
00046 #include <BRep_Builder.hxx>
00047 #include <BRep_Tool.hxx>
00048 
00049 #include <BOPTools_Pave.hxx>
00050 #include <BOPTools_PaveSet.hxx>
00051 #include <BOPTools_CArray1OfVEInterference.hxx>
00052 #include <BOPTools_VEInterference.hxx>
00053 
00054 #include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
00055 
00056 #include <NMTDS_Iterator.hxx>
00057 #include <NMTDS_ShapesDataStructure.hxx>
00058 #include <NMTDS_InterfPool.hxx>
00059 
00060 
00061 #include <BOPTools_IndexedMapOfCoupleOfInteger.hxx>
00062 #include <BOPTools_CoupleOfInteger.hxx>
00063 #include <BooleanOperations_OnceExplorer.hxx>
00064 
00065 #include <IntTools_Context.hxx>
00066 
00067 static
00068   Standard_Boolean Contains(const TopoDS_Edge& aE,
00069                             const TopoDS_Vertex& aV);
00070 
00071 //=======================================================================
00072 // function: PerformVE
00073 // purpose:
00074 //=======================================================================
00075 void NMTTools_PaveFiller::PerformVE()
00076 {
00077   myIsDone=Standard_False;
00078   //
00079   Standard_Boolean bJustAdd;
00080   Standard_Integer n1, n2, anIndexIn, aFlag, aWhat;
00081   Standard_Integer aWith, aNbVEs, aBlockLength, iSDV, nV1;
00082   Standard_Real aT;
00083 #if OCC_VERSION_LARGE > 0x06030008
00084   // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method
00085   Standard_Boolean bToUpdateVertex;
00086   Standard_Real aDist;
00087 #endif
00088   TopoDS_Vertex aV1;
00089   TopoDS_Edge aE2;
00090   BOPTools_IndexedMapOfCoupleOfInteger aSnareMap;
00091   BOPTools_CoupleOfInteger aCouple;
00092   //
00093   BOPTools_CArray1OfVEInterference& aVEs=myIP->VEInterferences();
00094   //
00095   myDSIt->Initialize (TopAbs_VERTEX, TopAbs_EDGE);
00096   //
00097   // BlockLength correction
00098   aNbVEs=myDSIt->BlockLength();
00099   aBlockLength=aVEs.BlockLength();
00100   if (aNbVEs > aBlockLength) {
00101     aVEs.SetBlockLength(aNbVEs);
00102   }
00103   //
00104   for (; myDSIt->More(); myDSIt->Next()) {
00105     myDSIt->Current(n1, n2, bJustAdd);
00106     if (!IsSuccessorsComputed(n1, n2)) {
00107       anIndexIn=0;
00108       aWhat=n1; // Vertex
00109       aWith=n2; // Edge
00110       if (myDS->GetShapeType(n1)==TopAbs_EDGE) {
00111         aWhat=n2;
00112         aWith=n1;
00113       }
00114       //
00115       if(bJustAdd) {
00116         continue;
00117       }
00118       // Edge
00119       aE2=TopoDS::Edge(myDS->Shape(aWith));
00120       if (BRep_Tool::Degenerated(aE2)){
00121         continue;
00122       }
00123       // Vertex
00124       nV1=aWhat;
00125       aV1=TopoDS::Vertex(myDS->Shape(aWhat));
00126       //
00127       iSDV=FindSDVertex(aWhat);
00128       if (iSDV) {
00129         nV1=iSDV;
00130         aV1=TopoDS::Vertex(myDS->Shape(nV1));
00131         // Modified to find same domain vertex Thu Sep 14 14:35:18 2006
00132         // Contribution of Samtech www.samcef.com BEGIN
00133         Standard_Integer nVE, iSDVE, iRet;
00134         //
00135         BooleanOperations_OnceExplorer aExp(*myDS);
00136         iRet=0;
00137         aExp.Init(aWith, TopAbs_VERTEX);
00138         for (; aExp.More(); aExp.Next()) {
00139           nVE=aExp.Current();
00140           iSDVE=FindSDVertex(nVE);
00141           if (iSDVE==iSDV) {
00142             iRet=1;
00143             break;
00144           }
00145         }
00146         if (iRet) {
00147           continue;
00148         }
00149       }
00150       else {
00151         if (Contains(aE2, aV1)) {
00152           continue;
00153         }
00154         // Contribution of Samtech www.samcef.com END
00155       }
00156       //
00157       //modified by NIZNHY-PKV Mon Dec 28 08:58:05 2009f
00158 #if OCC_VERSION_LARGE > 0x06030008
00159       // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method
00160       aFlag = myContext->ComputeVE (aV1, aE2, aT, bToUpdateVertex, aDist);
00161 #else
00162       aFlag = myContext->ComputeVE (aV1, aE2, aT);
00163 #endif
00164       //modified by NIZNHY-PKV Mon Dec 28 08:58:13 2009t
00165       //
00166       if (!aFlag) {
00167         // Add Interference to the Pool
00168         BOPTools_VEInterference anInterf (aWhat, aWith, aT);
00169         anIndexIn=aVEs.Append(anInterf);
00170         //
00171         // Add Pave to the Edge's myPavePool
00172         aCouple.SetCouple(nV1, aWith);
00173         if (!aSnareMap.Contains(aCouple)){
00174           aSnareMap.Add(aCouple);
00175           //
00176           BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge);
00177           aPave.SetInterference(anIndexIn);
00178           BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith));
00179           aPaveSet.Append(aPave);
00180         }
00181         //
00182         // State for the Vertex in DS;
00183         myDS->SetState (aWhat, BooleanOperations_ON);
00184         // Insert Vertex in Interference Object
00185         BOPTools_VEInterference& aVE=aVEs(anIndexIn);
00186         aVE.SetNewShape(aWhat);
00187         //
00188         myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VE);
00189         //
00190         //modified by NIZNHY-PKV Mon Dec 28 09:00:54 2009f
00191 #if OCC_VERSION_LARGE > 0x06030008
00192         // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method
00193         if (bToUpdateVertex) {
00194           BRep_Builder aBB;
00195           //
00196           aBB.UpdateVertex(aV1, aDist);
00197         }
00198 #endif
00199         //modified by NIZNHY-PKV Mon Dec 28 09:00:57 2009t
00200         //
00201       } //if (!aFlag) {
00202     }
00203   }
00204   myIsDone=Standard_True;
00205 }
00206 
00207 //=======================================================================
00208 // function: PrepareEdges
00209 // purpose:
00210 //=======================================================================
00211 void NMTTools_PaveFiller::PrepareEdges()
00212 {
00213   Standard_Integer  i, nV, ii, aNBSuc, ip, aNbShapesObject;
00214   Standard_Real aT;
00215   TopAbs_Orientation anOr;
00216   TopoDS_Edge   aE;
00217   TopoDS_Vertex aV;
00218   //
00219   aNbShapesObject=myDS->NumberOfShapesOfTheObject();
00220   for (i=1; i<=myNbSources; ++i) {
00221     if (myDS->GetShapeType(i)==TopAbs_EDGE) {
00222       aE=TopoDS::Edge(myDS->Shape(i));
00223       //
00224       if (BRep_Tool::Degenerated(aE)){
00225         continue;
00226       }
00227       //
00228       BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i));
00229       //
00230       // A <-
00231       aNBSuc=myDS->NumberOfSuccessors(i);
00232       for (ii=1; ii <=aNBSuc; ii++) {
00233         nV=myDS->GetSuccessor(i, ii);
00234         anOr=myDS->GetOrientation(i, ii);
00235         aV=TopoDS::Vertex(myDS->Shape(nV));
00236         aV.Orientation(anOr);
00237         aT=BRep_Tool::Parameter(aV, aE);
00238         //
00239         ip=FindSDVertex(nV);
00240         if (ip) {
00241           aV=TopoDS::Vertex(myDS->Shape(ip));
00242           aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result
00243           nV=ip;
00244         }
00245         //
00246         BOPTools_Pave aPave(nV, aT);
00247         aPaveSet.Append (aPave);
00248       }
00249     }
00250   }
00251 }
00252 
00253 // Modified  Thu Sep 14 14:35:18 2006
00254 // Contribution of Samtech www.samcef.com BEGIN
00255 //=======================================================================
00256 //function : Contains
00257 //purpose  :
00258 //=======================================================================
00259 Standard_Boolean Contains(const TopoDS_Edge& aE,
00260                           const TopoDS_Vertex& aV)
00261 {
00262   Standard_Boolean bRet;
00263   TopoDS_Iterator aIt;
00264   //
00265   bRet=Standard_False;
00266   aIt.Initialize(aE);
00267   for (; aIt.More(); aIt.Next()) {
00268     const TopoDS_Shape& aVE=aIt.Value();
00269     if (aVE.IsSame(aV)) {
00270       bRet=!bRet;
00271       break;
00272     }
00273   }
00274   return bRet;
00275 }
00276 // Contribution of Samtech www.samcef.com END