Back to index

salome-geom  6.5.0
NMTTools_PaveFiller_9.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_9.cxx
00024 // Created:     Fri Dec 19 11:15:53 2003
00025 // Author:      Peter KURNEV
00026 //              <pkv@irinox>
00027 //
00028 #include <NMTTools_PaveFiller.hxx>
00029 
00030 #include <Geom_Surface.hxx>
00031 
00032 #include <TopLoc_Location.hxx>
00033 #include <TopAbs_Orientation.hxx>
00034 
00035 #include <TopoDS.hxx>
00036 #include <TopoDS_Face.hxx>
00037 #include <TopoDS_Wire.hxx>
00038 #include <TopoDS_Edge.hxx>
00039 #include <TopoDS_Shape.hxx>
00040 
00041 #include <BRep_Builder.hxx>
00042 #include <BRep_Tool.hxx>
00043 
00044 #include <TopExp_Explorer.hxx>
00045 
00046 #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
00047 #include <BOPTools_ListOfPaveBlock.hxx>
00048 #include <BOPTools_PaveBlock.hxx>
00049 #include <BOPTools_Tools3D.hxx>
00050 
00051 #include <NMTDS_ShapesDataStructure.hxx>
00052 
00053 #include <NMTTools_CommonBlockAPI.hxx>
00054 #include <NMTTools_CommonBlock.hxx>
00055 
00056 
00057 //=======================================================================
00058 // function: PrepareFace
00059 // purpose:
00060 //=======================================================================
00061   void NMTTools_PaveFiller::PrepareFace(const Standard_Integer nF,
00062                                         TopoDS_Face& newFace)
00063 {
00064   Standard_Boolean bToReverse, bIsDegenerated;
00065   Standard_Integer iRankF, nE, nSp, aNbPB;
00066   Standard_Real aTol;
00067   TopLoc_Location aLoc;
00068   TopoDS_Face aF;
00069   TopoDS_Wire newWire;
00070   TopoDS_Edge aSp;
00071   TopAbs_Orientation anOrF, anOrE;
00072   BRep_Builder aBB;
00073   TopExp_Explorer aExpW, aExpE;
00074   BOPTools_ListIteratorOfListOfPaveBlock aItPB;
00075   //
00076   iRankF=myDS->Rank(nF);
00077   aF=TopoDS::Face(myDS->Shape(nF));
00078   anOrF=aF.Orientation();
00079   aF.Orientation(TopAbs_FORWARD);
00080   //
00081   Handle(Geom_Surface) aS=BRep_Tool::Surface(aF, aLoc);
00082   aTol=BRep_Tool::Tolerance(aF);
00083   //
00084   aBB.MakeFace (newFace, aS, aLoc, aTol);
00085   //
00086   aExpW.Init(aF, TopAbs_WIRE);
00087   for (; aExpW.More(); aExpW.Next()) {
00088     const TopoDS_Shape& aW=aExpW.Current();
00089     aBB.MakeWire(newWire);
00090     //
00091     aExpE.Init(aW, TopAbs_EDGE);
00092     for (; aExpE.More(); aExpE.Next()) {
00093       const TopoDS_Edge& aE=TopoDS::Edge(aExpE.Current());
00094       bIsDegenerated=BRep_Tool::Degenerated(aE);
00095       anOrE=aE.Orientation();
00096       //
00097       nE=myDS->ShapeIndex(aE, iRankF);
00098       const BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE));
00099       aNbPB=aLPB.Extent();
00100       if (!aNbPB) {
00101         aBB.Add(newWire, aE);
00102         continue;
00103       }
00104       //
00105       aItPB.Initialize(aLPB);
00106       for (; aItPB.More(); aItPB.Next()) {
00107         const BOPTools_PaveBlock& aPB=aItPB.Value();
00108         const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB);
00109         nSp=aPBR.Edge();
00110         //
00111         aSp=TopoDS::Edge(myDS->Shape(nSp));
00112         if (!bIsDegenerated) {
00113           bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, myContext);
00114           if (bToReverse) {
00115             aSp.Reverse();
00116           }
00117         }
00118         else {
00119          aSp.Orientation(anOrE);
00120         }
00121         aBB.Add(newWire, aSp);
00122       }
00123     }
00124     aBB.Add(newFace, newWire);
00125   }
00126   newFace.Orientation(anOrF);
00127 }