Salome HOME
Mantis issue 0021772: EDF 2336 GEOM: Non valid face created from two circles
[modules/geom.git] / src / NMTTools / NMTTools_PaveFiller.cxx
index 231482f3845ab6f4d3bb7d307ffaeeefc7673cb3..b98bc4fa6b4fa273d9d1b1006b8e19e7e6682de9 100644 (file)
-// File:       NMTTools_PaveFiller.cxx
-// Created:    Fri Dec  5 14:58:54 2003
-// Author:     Peter KURNEV
-//             <pkv@irinox>
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-#include <NMTTools_PaveFiller.ixx>
+// 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_PaveFiller.cxx
+// Created:     Fri Dec  5 14:58:54 2003
+// Author:      Peter KURNEV
+//              <pkv@irinox>
+//
+#include <NMTTools_PaveFiller.hxx>
 //
 #include <BOPTColStd_Failure.hxx>
+#include <IntTools_Context.hxx>
 #include <NMTDS_ShapesDataStructure.hxx>
 #include <NMTTools_DEProcessor.hxx>
-#include "utilities.h"
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_InterfPool.hxx>
 
 //=======================================================================
 // function: NMTTools_PaveFiller::NMTTools_PaveFiller
-// purpose: 
+// purpose:
 //=======================================================================
   NMTTools_PaveFiller::NMTTools_PaveFiller()
 {
-  myIntrPool=NULL;
   myDS=NULL;
+  myDSIt=NULL;
   myIsDone=Standard_False;
   myNbSources=0;
   myNbEdges=0;
+  myIP=NULL;
 }
 //=======================================================================
-// function:NMTTools_PaveFiller::NMTTools_PaveFiller
-// purpose: 
+// function: ~
+// purpose:
 //=======================================================================
-  NMTTools_PaveFiller::NMTTools_PaveFiller(const BOPTools_InterferencePool& aIP)
+  NMTTools_PaveFiller::~NMTTools_PaveFiller()
 {
-  SetInterferencePool(aIP);
+  Clear();
 }
 //=======================================================================
-// function: Destroy
-// purpose: 
+// function: Clear
+// purpose:
 //=======================================================================
-  void NMTTools_PaveFiller::Destroy()
+  void NMTTools_PaveFiller::Clear()
 {
+  if (myDSIt) {
+    delete myDSIt;
+  }
+  if (myDS) {
+    delete myDS;
+  }
+  myDSIt=NULL;
+  myDS=NULL;
+
+  if (myIP) {
+    delete myIP;
+  }
+  myIP=NULL;
 }
 //=======================================================================
-// function: SetInterferencePool
-// purpose: 
+// function: SetCompositeShape
+// purpose:
 //=======================================================================
-  void NMTTools_PaveFiller::SetInterferencePool(const BOPTools_InterferencePool& aIP)
+  void NMTTools_PaveFiller::SetCompositeShape(const TopoDS_Shape& aS)
 {
-  myIsDone=Standard_False;
-  //
-  myIntrPool=(BOPTools_InterferencePool*)&aIP;
-  myDS=(NMTDS_ShapesDataStructure*)myIntrPool->DS();
-  myNbSources=myDS->NumberOfShapesOfTheObject()+myDS->NumberOfShapesOfTheTool();
-  myNbEdges=myDS->NbEdges();
+  myCompositeShape=aS;
 }
 //=======================================================================
-// function:  InterfPool
-// purpose: 
+// function: CompositeShape
+// purpose:
 //=======================================================================
-  BOPTools_PInterferencePool NMTTools_PaveFiller::InterfPool()
+  const TopoDS_Shape& NMTTools_PaveFiller::CompositeShape()const
 {
-  return myIntrPool;
+  return myCompositeShape;
 }
 //=======================================================================
-// function:IsDone
-// purpose: 
+// function:  DS
+// purpose:
 //=======================================================================
-  Standard_Boolean NMTTools_PaveFiller::IsDone() const
+  NMTDS_PShapesDataStructure NMTTools_PaveFiller::DS()
 {
-  return myIsDone;
+  return myDS;
 }
 //=======================================================================
-// function:  DS
-// purpose: 
+// function: DSIt
+// purpose:
 //=======================================================================
-  NMTDS_PShapesDataStructure NMTTools_PaveFiller::DS()
+  NMTDS_PIterator NMTTools_PaveFiller::DSIt()
 {
-  return myDS;
+  return myDSIt;
 }
 //=======================================================================
-// function: Context
-// purpose: 
+// function:  IP
+// purpose:
 //=======================================================================
-  const IntTools_Context& NMTTools_PaveFiller::Context() const
+  NMTDS_PInterfPool NMTTools_PaveFiller::IP()
 {
-  return myContext;
+  return myIP;
+}
+//=======================================================================
+// function:IsDone
+// purpose:
+//=======================================================================
+  Standard_Boolean NMTTools_PaveFiller::IsDone() const
+{
+  return myIsDone;
 }
 //=======================================================================
-// function: ChangeContext
-// purpose: 
+// function: Context
+// purpose:
 //=======================================================================
-  IntTools_Context& NMTTools_PaveFiller::ChangeContext() 
+  const Handle(IntTools_Context)& NMTTools_PaveFiller::Context() const
 {
   return myContext;
 }
 //=======================================================================
 // function: PavePool
-// purpose: 
+// purpose:
 //=======================================================================
   const BOPTools_PavePool& NMTTools_PaveFiller::PavePool() const
 {
 }
 //=======================================================================
 // function: ChangePavePool
-// purpose: 
+// purpose:
 //=======================================================================
   BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePool()
 {
   return myPavePool;
 }
 //=======================================================================
+// function: ChangePavePoolNew
+// purpose:
+//=======================================================================
+  BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePoolNew()
+{
+  return myPavePoolNew;
+}
+//=======================================================================
 // function:  CommonBlockPool
-// purpose: 
+// purpose:
 //=======================================================================
   const NMTTools_CommonBlockPool& NMTTools_PaveFiller::CommonBlockPool() const
 {
 }
 //=======================================================================
 // function:  ChangeCommonBlockPool
-// purpose: 
+// purpose:
 //=======================================================================
   NMTTools_CommonBlockPool& NMTTools_PaveFiller::ChangeCommonBlockPool()
 {
 }
 //=======================================================================
 // function:  SplitShapesPool
-// purpose: 
+// purpose:
 //=======================================================================
   const BOPTools_SplitShapesPool& NMTTools_PaveFiller::SplitShapesPool() const
 {
   return mySplitShapesPool;
 }
-
 //=======================================================================
 // function:  ChangeSplitShapesPool
-// purpose: 
+// purpose:
 //=======================================================================
   BOPTools_SplitShapesPool& NMTTools_PaveFiller::ChangeSplitShapesPool()
 {
 }
 //=======================================================================
 // function: Init
-// purpose: 
+// purpose:
 //=======================================================================
   void NMTTools_PaveFiller::Init()
 {
-  myDSIt.SetDS(myDS);
+  myIsDone=Standard_False;
+  if (myCompositeShape.IsNull()) {
+    return;
+  }
+  //
+  Clear();
+  // 1.
+  myDS=new NMTDS_ShapesDataStructure;
+  myDS->SetCompositeShape(myCompositeShape);
+  myDS->Init();
+  //
+  // 2.
+  myDSIt=new NMTDS_Iterator;
+  myDSIt->SetDS(myDS);
+  myDSIt->Prepare();
+  //
+  // 3.
+  myNbSources=myDS->NumberOfShapesOfTheObject()+
+              myDS->NumberOfShapesOfTheTool();
+  myNbEdges=myDS->NbEdges();
+  //
+  // 4
+  myIP=new NMTDS_InterfPool;
+  //
+  // 5
+  myContext=new IntTools_Context;
 }
+
 //=======================================================================
 // function: Perform
-// purpose: 
+// purpose:
 //=======================================================================
   void NMTTools_PaveFiller::Perform()
 {
+  myIsDone=Standard_False;
+  //
+  //----------------
   try {
     // 0.
-    Init();//myDSIt.SetDS(myDS);
-    //
+    Init();
     //1.VV
+    //
     PerformVV();
-    PerformNewVertices();
     //
     // 2.VE
     myPavePool.Resize (myNbEdges);
+
     PrepareEdges();
+
     PerformVE();
     //
     // 3.VF
     myCommonBlockPool.Resize (myNbEdges);
     mySplitShapesPool.Resize (myNbEdges);
     myPavePoolNew    .Resize (myNbEdges);
-    
+
     PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE);
     PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE);
     //
     myPavePoolNew.Destroy();
     myPavePoolNew.Resize (myNbEdges);
     //
+    //modified by NIZNHY-PKV Mon Dec 12 09:13:53 2011f
+    UpdateCommonBlocks(0);
+    //modified by NIZNHY-PKV Mon Dec 12 09:13:56 2011t
+    //
     // 5.EF
     PreparePaveBlocks(TopAbs_EDGE, TopAbs_FACE);
     PerformEF();
+    //
     RefinePavePool();
     //
     myPavePoolNew.Destroy();
+
     MakeSplitEdges();
+
     UpdateCommonBlocks();
     //
     // 6. FF
     PerformFF ();
+    //
     MakeBlocks();
+    //
     MakePCurves();
     //
-    // 7.Postprocessing 
+    // 7.Postprocessing
     UpdatePaveBlocks();
     //
     NMTTools_DEProcessor aDEP(*this);
     aDEP.Do();
     //
+    MakeAloneVertices();
+    //
+    //modified by NIZNHY-PKV Mon Dec 12 09:14:23 2011f
+    myIP->Purge();
+    //modified by NIZNHY-PKV Mon Dec 12 09:14:27 2011t
+    myIsDone=Standard_True;
   }
-  catch (BOPTColStd_Failure& x) {
-    MESSAGE(x.Message() << flush);
+  catch (BOPTColStd_Failure& ) {
   }
 }