Back to index

salome-geom  6.5.0
NMTTools_PaveFiller_3.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_3.cxx
00024 // Created:     Mon Dec  8 16:06:56 2003
00025 // Author:      Peter KURNEV
00026 //              <pkv@irinox>
00027 //
00028 #include <NMTTools_PaveFiller.hxx>
00029 
00030 #include <TopoDS.hxx>
00031 #include <TopoDS_Shape.hxx>
00032 #include <TopoDS_Vertex.hxx>
00033 #include <TopoDS_Face.hxx>
00034 
00035 #include <TopExp_Explorer.hxx>
00036 
00037 #include <BOPTools_VSInterference.hxx>
00038 #include <BOPTools_CArray1OfVSInterference.hxx>
00039 
00040 #include <NMTDS_Iterator.hxx>
00041 #include <NMTDS_ShapesDataStructure.hxx>
00042 #include <NMTDS_InterfPool.hxx>
00043 #include <IntTools_Context.hxx>
00044 
00045 
00046 static
00047   Standard_Boolean Contains(const TopoDS_Face& aF,
00048                             const TopoDS_Vertex& aV);
00049 
00050 //=======================================================================
00051 // function: PerformVF
00052 // purpose:
00053 //=======================================================================
00054   void NMTTools_PaveFiller::PerformVF()
00055 {
00056   myIsDone=Standard_False;
00057   //
00058   Standard_Boolean aJustAdd;
00059   Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVSs, aBlockLength, iSDV;
00060   Standard_Real aU, aV;
00061   TopoDS_Vertex aV1;
00062   TopoDS_Face aF2;
00063   //
00064   BOPTools_CArray1OfVSInterference& aVSs=myIP->VSInterferences();
00065   //
00066   // V/E Interferences
00067   myDSIt->Initialize(TopAbs_VERTEX, TopAbs_FACE);
00068   //
00069   // BlockLength correction
00070   aNbVSs=myDSIt->BlockLength();
00071   aBlockLength=aVSs.BlockLength();
00072   if (aNbVSs > aBlockLength) {
00073     aVSs.SetBlockLength(aNbVSs);
00074   }
00075   //
00076   for (; myDSIt->More(); myDSIt->Next()) {
00077     myDSIt->Current(n1, n2, aJustAdd);
00078     if (! IsSuccessorsComputed(n1, n2)) {
00079       anIndexIn=0;
00080       aWhat=n1; // Vertex
00081       aWith=n2; // Face
00082       if (myDS->GetShapeType(n1)==TopAbs_FACE) {
00083         aWhat=n2;
00084         aWith=n1;
00085       }
00086       //
00087       iSDV=FindSDVertex(aWhat);
00088         //
00089       if(aJustAdd) {
00090         //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn);
00091         continue;
00092       }
00093       //
00094       aV1=TopoDS::Vertex(myDS->Shape(aWhat));
00095       if (iSDV) {
00096         aV1=TopoDS::Vertex(myDS->Shape(iSDV));
00097       }
00098         //
00099       aF2=TopoDS::Face(myDS->Shape(aWith));
00100       //
00101       // Modified  Thu Sep 14 14:35:18 2006
00102       // Contribution of Samtech www.samcef.com BEGIN
00103       if (Contains(aF2, aV1)) {
00104         continue;
00105       }
00106       // Contribution of Samtech www.samcef.com END
00107       //
00108       aFlag=myContext->ComputeVS (aV1, aF2, aU, aV);
00109       //
00110       if (!aFlag) {
00111         //
00112         // Add Interference to the Pool
00113         BOPTools_VSInterference anInterf (aWhat, aWith, aU, aV);
00114         anIndexIn=aVSs.Append(anInterf);
00115         //
00116         // SetState for Vertex in DS;
00117         myDS->SetState (aWhat, BooleanOperations_ON);
00118         // Insert Vertex in Interference Object
00119         BOPTools_VSInterference& aVS=aVSs(anIndexIn);
00120         aVS.SetNewShape(aWhat);
00121         // qqf
00122         {
00123           myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VF);
00124         }
00125         // qqt
00126       }
00127       //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn);
00128     }
00129   }
00130   myIsDone=Standard_True;
00131 }
00132 // Modified  Thu Sep 14 14:35:18 2006
00133 // Contribution of Samtech www.samcef.com BEGIN
00134 //=======================================================================
00135 //function : Contains
00136 //purpose  :
00137 //=======================================================================
00138 Standard_Boolean Contains(const TopoDS_Face& aF,
00139                           const TopoDS_Vertex& aV)
00140 {
00141   Standard_Boolean bRet;
00142   TopExp_Explorer aExp;
00143   //
00144   bRet=Standard_False;
00145   aExp.Init(aF, TopAbs_VERTEX);
00146   for (; aExp.More(); aExp.Next()) {
00147     const TopoDS_Shape& aVF=aExp.Current();
00148     if (aVF.IsSame(aV)) {
00149       bRet=!bRet;
00150       break;
00151     }
00152   }
00153   return bRet;
00154 }
00155 // Contribution of Samtech www.samcef.com END