]> OCCT Git - occt.git/commitdiff
0030827: Add common functionality allowing to switch triangulation algorithm in runtime
authoroan <oan@opencascade.com>
Wed, 3 Jul 2019 08:45:18 +0000 (11:45 +0300)
committeroan <oan@opencascade.com>
Mon, 8 Jul 2019 12:40:36 +0000 (15:40 +0300)
New classes BRepMesh_ConstrainedBaseMeshAlgo, BRepMesh_CustomBaseMeshAlgo and BRepMesh_CustomDelaunayBaseMeshAlgo are added.
These classes allow to add any custom triangulation algorithm to BRepMesh and perform post-processing and optimization of base mesh generated by those algorithms.
BRepMesh_Delaun: added possibility to process constraints when base mesh is generated by different algorithm.
BRepMesh_DelaunayNodeInsertionMeshAlgo: added PreProcessSurfaceNodes flag controlling addition of surface nodes (either before creation of base mesh or after) to gain maximum performance from triangulation algorithms.

Minor changes:
Use simple algorithm for cylinders when internal vertices mode is switched off to speed up computations.
BRepMesh_IncrementalMesh: added Perform method allowing to execute algorithm using manually created Context.

14 files changed:
src/BRepMesh/BRepMesh_CircleTool.hxx
src/BRepMesh/BRepMesh_ConstrainedBaseMeshAlgo.hxx [new file with mode: 0644]
src/BRepMesh/BRepMesh_CustomBaseMeshAlgo.hxx [new file with mode: 0644]
src/BRepMesh/BRepMesh_CustomDelaunayBaseMeshAlgo.hxx [new file with mode: 0644]
src/BRepMesh/BRepMesh_Delaun.cxx
src/BRepMesh/BRepMesh_Delaun.hxx
src/BRepMesh/BRepMesh_DelaunayBaseMeshAlgo.hxx
src/BRepMesh/BRepMesh_DelaunayDeflectionControlMeshAlgo.hxx
src/BRepMesh/BRepMesh_DelaunayNodeInsertionMeshAlgo.hxx
src/BRepMesh/BRepMesh_FaceChecker.cxx
src/BRepMesh/BRepMesh_IncrementalMesh.cxx
src/BRepMesh/BRepMesh_IncrementalMesh.hxx
src/BRepMesh/BRepMesh_MeshAlgoFactory.cxx
src/BRepMesh/FILES

index 2a36e1a368319c680e31b56963444eff9d0803d9..3f5701d63dfb423dfbadaeac7d03a6243966c48e 100644 (file)
@@ -83,6 +83,12 @@ public:
     myFaceMax = theMax;
   }
 
+  //! Retruns true if cell filter contains no circle.
+  inline Standard_Boolean IsEmpty () const
+  {
+    return mySelector.Circles ().IsEmpty ();
+  }
+
   //! Binds the circle to the tool.
   //! @param theIndex index a circle should be bound with.
   //! @param theCircle circle to be bound.
diff --git a/src/BRepMesh/BRepMesh_ConstrainedBaseMeshAlgo.hxx b/src/BRepMesh/BRepMesh_ConstrainedBaseMeshAlgo.hxx
new file mode 100644 (file)
index 0000000..7edd4aa
--- /dev/null
@@ -0,0 +1,60 @@
+// Created on: 2019-07-08
+// Copyright (c) 2019 OPEN CASCADE SAS
+// Created by: Oleg AGASHIN
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _BRepMesh_ConstrainedBaseMeshAlgo_HeaderFile
+#define _BRepMesh_ConstrainedBaseMeshAlgo_HeaderFile
+
+#include <BRepMesh_BaseMeshAlgo.hxx>
+#include <NCollection_Shared.hxx>
+#include <IMeshTools_Parameters.hxx>
+
+class BRepMesh_DataStructureOfDelaun;
+class BRepMesh_Delaun;
+
+//! Class provides base fuctionality to build face triangulation using Dealunay approach.
+//! Performs generation of mesh using raw data from model.
+class BRepMesh_ConstrainedBaseMeshAlgo : public BRepMesh_BaseMeshAlgo
+{
+public:
+
+  //! Constructor.
+  BRepMesh_ConstrainedBaseMeshAlgo ()
+  {
+  }
+
+  //! Destructor.
+  virtual ~BRepMesh_ConstrainedBaseMeshAlgo ()
+  {
+  }
+
+  DEFINE_STANDARD_RTTI_INLINE(BRepMesh_ConstrainedBaseMeshAlgo, BRepMesh_BaseMeshAlgo)
+
+protected:
+
+  //! Returns size of cell to be used by acceleration circles grid structure.
+  virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer /*theVerticesNb*/)
+  {
+    return std::pair<Standard_Integer, Standard_Integer> (-1, -1);
+  }
+
+  //! Perfroms processing of generated mesh.
+  //! By default does nothing.
+  //! Expected to be called from method generateMesh() in successor classes.
+  virtual void postProcessMesh (BRepMesh_Delaun& /*theMesher*/)
+  {
+  }
+};
+
+#endif
diff --git a/src/BRepMesh/BRepMesh_CustomBaseMeshAlgo.hxx b/src/BRepMesh/BRepMesh_CustomBaseMeshAlgo.hxx
new file mode 100644 (file)
index 0000000..e175091
--- /dev/null
@@ -0,0 +1,70 @@
+// Created on: 2019-06-07
+// Copyright (c) 2019 OPEN CASCADE SAS
+// Created by: Oleg AGASHIN
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _BRepMesh_CustomBaseMeshAlgo_HeaderFile
+#define _BRepMesh_CustomBaseMeshAlgo_HeaderFile
+
+#include <BRepMesh_ConstrainedBaseMeshAlgo.hxx>
+#include <NCollection_Shared.hxx>
+#include <IMeshTools_Parameters.hxx>
+
+#include <BRepMesh_Delaun.hxx>
+#include <BRepMesh_MeshTool.hxx>
+
+class BRepMesh_DataStructureOfDelaun;
+
+//! Class provides base fuctionality to build face triangulation using custom triangulation algorithm.
+//! Performs generation of mesh using raw data from model.
+class BRepMesh_CustomBaseMeshAlgo : public BRepMesh_ConstrainedBaseMeshAlgo
+{
+public:
+
+  //! Constructor.
+  Standard_EXPORT BRepMesh_CustomBaseMeshAlgo ()
+  {
+  }
+
+  //! Destructor.
+  Standard_EXPORT virtual ~BRepMesh_CustomBaseMeshAlgo ()
+  {
+  }
+
+  DEFINE_STANDARD_RTTI_INLINE(BRepMesh_CustomBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
+
+protected:
+
+  //! Generates mesh for the contour stored in data structure.
+  Standard_EXPORT virtual void generateMesh () Standard_OVERRIDE
+  {
+    const Handle (BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure ();
+    buildBaseTriangulation ();
+
+    std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes ());
+    BRepMesh_Delaun aMesher (aStructure, aCellsCount.first, aCellsCount.second, Standard_False);
+    aMesher.ProcessConstraints ();
+
+    BRepMesh_MeshTool aCleaner (aStructure);
+    aCleaner.EraseFreeLinks ();
+
+    postProcessMesh (aMesher);
+  }
+
+protected:
+
+  //! Builds base triangulation using custom triangulation algorithm.
+  Standard_EXPORT virtual void buildBaseTriangulation() = 0;
+};
+
+#endif
diff --git a/src/BRepMesh/BRepMesh_CustomDelaunayBaseMeshAlgo.hxx b/src/BRepMesh/BRepMesh_CustomDelaunayBaseMeshAlgo.hxx
new file mode 100644 (file)
index 0000000..6bde7b9
--- /dev/null
@@ -0,0 +1,53 @@
+// Created on: 2019-06-07
+// Copyright (c) 2019 OPEN CASCADE SAS
+// Created by: Oleg AGASHIN
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _BRepMesh_CustomDelaunayBaseMeshAlgo_HeaderFile
+#define _BRepMesh_CustomDelaunayBaseMeshAlgo_HeaderFile
+
+class BRepMesh_DataStructureOfDelaun;
+class BRepMesh_Delaun;
+
+//! Class provides base fuctionality to build face triangulation using custom
+//! triangulation algorithm with possibility to modify final mesh.
+//! Performs generation of mesh using raw data from model.
+template<class BaseAlgo>
+class BRepMesh_CustomDelaunayBaseMeshAlgo : public BaseAlgo
+{
+public:
+
+  //! Constructor.
+  BRepMesh_CustomDelaunayBaseMeshAlgo ()
+  {
+  } 
+
+  //! Destructor.
+  virtual ~BRepMesh_CustomDelaunayBaseMeshAlgo ()
+  {
+  }
+
+protected:
+
+  //! Perfroms processing of generated mesh.
+  virtual void postProcessMesh(BRepMesh_Delaun& theMesher)
+  {
+    BaseAlgo::postProcessMesh (theMesher);
+
+    const Handle(BRepMesh_DataStructureOfDelaun)& aStructure  = this->getStructure();
+    std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes());
+    theMesher.InitCirclesTool (aCellsCount.first, aCellsCount.second);
+  }
+};
+
+#endif
index 8b6e96d3340b568fd9190be125cc8664f60db460..c87bc6ce62121fe0e2d6e897048e26ec00f75c1b 100644 (file)
@@ -78,6 +78,25 @@ namespace {
   }
 } // anonymous namespace
 
+//=======================================================================
+//function : BRepMesh_Delaun
+//purpose  : 
+//=======================================================================
+BRepMesh_Delaun::BRepMesh_Delaun (
+  const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
+  const Standard_Integer                        theCellsCountU,
+  const Standard_Integer                        theCellsCountV,
+  const Standard_Boolean                        isFillCircles)
+: myMeshData ( theOldMesh ),
+  myCircles (new NCollection_IncAllocator(
+             IMeshData::MEMORY_BLOCK_SIZE_HUGE))
+{
+  if (isFillCircles)
+  {
+    InitCirclesTool (theCellsCountU, theCellsCountV);
+  }
+}
+
 //=======================================================================
 //function : BRepMesh_Delaun
 //purpose  : Creates the triangulation with an empty Mesh data structure
@@ -103,7 +122,8 @@ BRepMesh_Delaun::BRepMesh_Delaun(
   const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
   IMeshData::Array1OfVertexOfDelaun&            theVertices)
 : myMeshData( theOldMesh ),
-  myCircles ( theVertices.Length(), theOldMesh->Allocator() )
+  myCircles ( theVertices.Length(), new NCollection_IncAllocator(
+             IMeshData::MEMORY_BLOCK_SIZE_HUGE))
 {
   if ( theVertices.Length() > 2 )
   {
@@ -119,7 +139,8 @@ BRepMesh_Delaun::BRepMesh_Delaun(
   const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
   IMeshData::VectorOfInteger&                   theVertexIndices)
 : myMeshData( theOldMesh ),
-  myCircles ( theVertexIndices.Length(), theOldMesh->Allocator() )
+  myCircles ( theVertexIndices.Length(), new NCollection_IncAllocator(
+             IMeshData::MEMORY_BLOCK_SIZE_HUGE))
 {
   perform(theVertexIndices);
 }
@@ -133,7 +154,8 @@ BRepMesh_Delaun::BRepMesh_Delaun (const Handle (BRepMesh_DataStructureOfDelaun)&
                                   const Standard_Integer                         theCellsCountU,
                                   const Standard_Integer                         theCellsCountV)
 : myMeshData (theOldMesh),
-  myCircles (theVertexIndices.Length (), theOldMesh->Allocator ())
+  myCircles (theVertexIndices.Length (), new NCollection_IncAllocator(
+             IMeshData::MEMORY_BLOCK_SIZE_HUGE))
 {
   perform (theVertexIndices, theCellsCountU, theCellsCountV);
 }
@@ -157,6 +179,63 @@ void BRepMesh_Delaun::Init(IMeshData::Array1OfVertexOfDelaun& theVertices)
   perform( aVertexIndexes );
 }
 
+//=======================================================================
+//function : InitCirclesTool
+//purpose  : 
+//=======================================================================
+void BRepMesh_Delaun::InitCirclesTool (const Standard_Integer theCellsCountU,
+                                       const Standard_Integer theCellsCountV)
+{
+  Bnd_Box2d aBox;
+  for (Standard_Integer aNodeIt = 1; aNodeIt <= myMeshData->NbNodes(); ++aNodeIt)
+  {
+    aBox.Add (gp_Pnt2d (GetVertex (aNodeIt).Coord ()));
+  }
+  aBox.Enlarge (Precision);
+
+  initCirclesTool (aBox, theCellsCountU, theCellsCountV);
+
+  IMeshData::IteratorOfMapOfInteger aTriangleIt (myMeshData->ElementsOfDomain());
+  for (; aTriangleIt.More(); aTriangleIt.Next())
+  {
+    Standard_Integer aNodesIndices[3];
+    const BRepMesh_Triangle& aTriangle = myMeshData->GetElement (aTriangleIt.Key());
+    myMeshData->ElementNodes (aTriangle, aNodesIndices);
+    myCircles.Bind (aTriangleIt.Key(),
+                    GetVertex( aNodesIndices[0] ).Coord(), 
+                    GetVertex( aNodesIndices[1] ).Coord(),
+                    GetVertex( aNodesIndices[2] ).Coord());
+  }
+}
+
+//=======================================================================
+//function : initCirclesTool
+//purpose  : 
+//=======================================================================
+void BRepMesh_Delaun::initCirclesTool (const Bnd_Box2d&       theBox,
+                                       const Standard_Integer theCellsCountU,
+                                       const Standard_Integer theCellsCountV)
+{
+  Standard_Real aMinX, aMinY, aMaxX, aMaxY;
+  theBox.Get  ( aMinX, aMinY, aMaxX, aMaxY );
+  const Standard_Real aDeltaX = aMaxX - aMinX;
+  const Standard_Real aDeltaY = aMaxY - aMinY;
+
+  Standard_Integer aScaler = 2;
+  if ( myMeshData->NbNodes() > 100 )
+  {
+    aScaler = 5;
+  }
+  else if( myMeshData->NbNodes() > 1000 )
+  {
+    aScaler = 7;
+  }
+
+  myCircles.SetMinMaxSize( gp_XY( aMinX, aMinY ), gp_XY( aMaxX, aMaxY ) );
+  myCircles.SetCellSize  ( aDeltaX / Max (theCellsCountU, aScaler),
+                           aDeltaY / Max (theCellsCountV, aScaler));
+}
+
 //=======================================================================
 //function : perform
 //purpose  : Create super mesh and run triangulation procedure
@@ -180,18 +259,8 @@ void BRepMesh_Delaun::perform(IMeshData::VectorOfInteger& theVertexIndices,
 
   aBox.Enlarge (Precision);
 
-  Standard_Integer aScaler = 2;
-  if ( myMeshData->NbNodes() > 100 )
-  {
-    aScaler = 5;
-  }
-  else if( myMeshData->NbNodes() > 1000 )
-  {
-    aScaler = 7;
-  }
-
-  superMesh (aBox, Max (theCellsCountU, aScaler),
-                   Max (theCellsCountV, aScaler));
+  initCirclesTool (aBox, theCellsCountU, theCellsCountV);
+  superMesh       (aBox);
 
   ComparatorOfIndexedVertexOfDelaun aCmp(myMeshData);
   std::make_heap(theVertexIndices.begin(), theVertexIndices.end(), aCmp);
@@ -204,9 +273,7 @@ void BRepMesh_Delaun::perform(IMeshData::VectorOfInteger& theVertexIndices,
 //function : superMesh
 //purpose  : Build the super mesh
 //=======================================================================
-void BRepMesh_Delaun::superMesh(const Bnd_Box2d&       theBox,
-                                const Standard_Integer theCellsCountU,
-                                const Standard_Integer theCellsCountV)
+void BRepMesh_Delaun::superMesh(const Bnd_Box2d& theBox)
 {
   Standard_Real aMinX, aMinY, aMaxX, aMaxY;
   theBox.Get  ( aMinX, aMinY, aMaxX, aMaxY );
@@ -217,9 +284,6 @@ void BRepMesh_Delaun::superMesh(const Bnd_Box2d&       theBox,
   Standard_Real aDeltaMax = Max( aDeltaX, aDeltaY );
   Standard_Real aDelta    = aDeltaX + aDeltaY;
 
-  myCircles.SetMinMaxSize( gp_XY( aMinX, aMinY ), gp_XY( aMaxX, aMaxY ) );
-  myCircles.SetCellSize( aDeltaX / theCellsCountU, aDeltaY / theCellsCountV);
-
   mySupVert[0] = myMeshData->AddNode(
     BRepMesh_Vertex( ( aMinX + aMaxX ) / 2, aMaxY + aDeltaMax, BRepMesh_Free ) );
 
@@ -254,7 +318,10 @@ void BRepMesh_Delaun::superMesh(const Bnd_Box2d&       theBox,
 void BRepMesh_Delaun::deleteTriangle(const Standard_Integer          theIndex, 
                                      IMeshData::MapOfIntegerInteger& theLoopEdges )
 {
-  myCircles.Delete( theIndex );
+  if (!myCircles.IsEmpty())
+  {
+    myCircles.Delete (theIndex);
+  }
 
   const BRepMesh_Triangle& aElement = GetTriangle(theIndex);
   const Standard_Integer(&e)[3] = aElement.myEdges;
@@ -279,8 +346,11 @@ void BRepMesh_Delaun::deleteTriangle(const Standard_Integer          theIndex,
 //=======================================================================
 void BRepMesh_Delaun::compute(IMeshData::VectorOfInteger& theVertexIndexes)
 {
-  // Insertion of edges of super triangles in the list of free edges: 
-  IMeshData::MapOfIntegerInteger aLoopEdges(10, myMeshData->Allocator());
+  // Insertion of edges of super triangles in the list of free edges:
+  Handle(NCollection_IncAllocator) aAllocator = new NCollection_IncAllocator(
+    IMeshData::MEMORY_BLOCK_SIZE_HUGE);
+
+  IMeshData::MapOfIntegerInteger aLoopEdges(10, aAllocator);
   const Standard_Integer(&e)[3] = mySupTrian.myEdges;
                     
   aLoopEdges.Bind( e[0], Standard_True );
@@ -531,10 +601,7 @@ void BRepMesh_Delaun::createTrianglesOnNewVertices(
     }
   }
 
-  insertInternalEdges();
-
-  // Adjustment of meshes to boundary edges
-  frontierAdjust();
+  ProcessConstraints();
 }
 
 //=======================================================================
index 320d882da6f6b662b8c53ba71f522438f31c2a5e..f03a333a1120121a43a2b3363bc67daf564dfbb3 100755 (executable)
@@ -41,6 +41,12 @@ public:
 
   DEFINE_STANDARD_ALLOC
 
+  //! Creates instance of triangulator, but do not run the algorithm automatically.
+  Standard_EXPORT BRepMesh_Delaun (const Handle(BRepMesh_DataStructureOfDelaun)& theOldMesh,
+                                   const Standard_Integer                        theCellsCountU,
+                                   const Standard_Integer                        theCellsCountV,
+                                   const Standard_Boolean                        isFillCircles);
+
   //! Creates the triangulation with an empty Mesh data structure.
   Standard_EXPORT BRepMesh_Delaun (IMeshData::Array1OfVertexOfDelaun& theVertices);
 
@@ -61,6 +67,10 @@ public:
   //! Initializes the triangulation with an array of vertices.
   Standard_EXPORT void Init (IMeshData::Array1OfVertexOfDelaun& theVertices);
 
+  //! Forces initialization of circles cell filter using working structure.
+  Standard_EXPORT void InitCirclesTool (const Standard_Integer theCellsCountU,
+                                        const Standard_Integer theCellsCountV);
+
   //! Removes a vertex from the triangulation.
   Standard_EXPORT void RemoveVertex (const BRepMesh_Vertex& theVertex);
 
@@ -77,6 +87,15 @@ public:
     return myMeshData;
   }
 
+  //! Forces insertion of constraint edges into the base triangulation. 
+  inline void ProcessConstraints()
+  {
+    insertInternalEdges();
+
+    // Adjustment of meshes to boundary edges
+    frontierAdjust();
+  }
+
   //! Gives the list of frontier edges.
   inline Handle(IMeshData::MapOfInteger) Frontier() const
   {
@@ -139,6 +158,11 @@ private:
 
   typedef NCollection_DataMap<Standard_Integer, IMeshData::MapOfInteger> DataMapOfMap;
 
+  //! Performs initialization of circles cell filter tool.
+  void initCirclesTool (const Bnd_Box2d&       theBox,
+                        const Standard_Integer theCellsCountU,
+                        const Standard_Integer theCellsCountV);
+
   //! Add boundig box for edge defined by start & end point to
   //! the given vector of bounding boxes for triangulation edges.
   void fillBndBox (IMeshData::SequenceOfBndB2d&  theBoxes,
@@ -156,9 +180,7 @@ private:
                 const Standard_Integer      theCellsCountV = -1);
 
   //! Build the super mesh.
-  void superMesh (const Bnd_Box2d&       theBox,
-                  const Standard_Integer theCellsCountU,
-                  const Standard_Integer theCellsCountV);
+  void superMesh (const Bnd_Box2d& theBox);
 
   //! Computes the triangulation and adds the vertices,
   //! edges and triangles to the Mesh data structure.
index 1ae266190995fdf6ef82b6e127031f5b9b121b65..81bfdc7c9fd7465e1d11beaf8492686027ce5d80 100644 (file)
@@ -16,7 +16,7 @@
 #ifndef _BRepMesh_DelaunayBaseMeshAlgo_HeaderFile
 #define _BRepMesh_DelaunayBaseMeshAlgo_HeaderFile
 
-#include <BRepMesh_BaseMeshAlgo.hxx>
+#include <BRepMesh_ConstrainedBaseMeshAlgo.hxx>
 #include <NCollection_Shared.hxx>
 #include <IMeshTools_Parameters.hxx>
 
@@ -25,7 +25,7 @@ class BRepMesh_Delaun;
 
 //! Class provides base fuctionality to build face triangulation using Dealunay approach.
 //! Performs generation of mesh using raw data from model.
-class BRepMesh_DelaunayBaseMeshAlgo : public BRepMesh_BaseMeshAlgo
+class BRepMesh_DelaunayBaseMeshAlgo : public BRepMesh_ConstrainedBaseMeshAlgo
 {
 public:
 
@@ -35,24 +35,12 @@ public:
   //! Destructor.
   Standard_EXPORT virtual ~BRepMesh_DelaunayBaseMeshAlgo();
 
-  DEFINE_STANDARD_RTTI_INLINE(BRepMesh_DelaunayBaseMeshAlgo, BRepMesh_BaseMeshAlgo)
+  DEFINE_STANDARD_RTTI_INLINE(BRepMesh_DelaunayBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
 
 protected:
 
-  //! Returns size of cell to be used by acceleration circles grid structure.
-  virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer /*theVerticesNb*/)
-  {
-    return std::pair<Standard_Integer, Standard_Integer> (-1, -1);
-  }
-
   //! Generates mesh for the contour stored in data structure.
   Standard_EXPORT virtual void generateMesh() Standard_OVERRIDE;
-
-  //! Perfroms processing of generated mesh.
-  //! By default does nothing.
-  virtual void postProcessMesh(BRepMesh_Delaun& /*theMesher*/)
-  {
-  }
 };
 
 #endif
index 78689d114d04c7c4aae9435d595d10e616ed7b9c..04f4708d661dd3b9b38a62245eabaa43de540e78 100644 (file)
 
 //! Extends node insertion Delaunay meshing algo in order to control 
 //! deflection of generated trianges. Splits triangles failing the check.
-template<class RangeSplitter>
-class BRepMesh_DelaunayDeflectionControlMeshAlgo : public BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter>
+template<class RangeSplitter, class BaseAlgo>
+class BRepMesh_DelaunayDeflectionControlMeshAlgo : public BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BaseAlgo>
 {
 private:
   // Typedef for OCCT RTTI
-  typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter> DelaunayInsertionBaseClass;
+  typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BaseAlgo> DelaunayInsertionBaseClass;
 
 public:
 
index 23863b74bdd6df18480d505fa4b45de15b5bead1..ccbe55278e2013b386dd0c0825b60ed782a6bb4a 100644 (file)
 
 //! Extends base Delaunay meshing algo in order to enable possibility 
 //! of addition of free vertices and internal nodes into the mesh.
-template<class RangeSplitter>
-class BRepMesh_DelaunayNodeInsertionMeshAlgo : public BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo>
+template<class RangeSplitter, class BaseAlgo>
+class BRepMesh_DelaunayNodeInsertionMeshAlgo : public BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BaseAlgo>
 {
 private:
   // Typedef for OCCT RTTI
-  typedef BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> InsertionBaseClass;
+  typedef BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BaseAlgo> InsertionBaseClass;
 
 public:
 
   //! Constructor.
   BRepMesh_DelaunayNodeInsertionMeshAlgo()
+    : myIsPreProcessSurfaceNodes (Standard_False)
   {
   }
 
@@ -40,8 +41,41 @@ public:
   {
   }
 
+  //! Returns PreProcessSurfaceNodes flag. 
+  inline Standard_Boolean IsPreProcessSurfaceNodes () const
+  {
+    return myIsPreProcessSurfaceNodes;
+  }
+
+  //! Sets PreProcessSurfaceNodes flag.
+  //! If TRUE, registers surface nodes before generation of base mesh.
+  //! If FALSE, inserts surface nodes after generation of base mesh. 
+  inline void SetPreProcessSurfaceNodes (const Standard_Boolean isPreProcessSurfaceNodes)
+  {
+    myIsPreProcessSurfaceNodes = isPreProcessSurfaceNodes;
+  }
+
 protected:
 
+  //! Performs initialization of data structure using existing model data.
+  virtual Standard_Boolean initDataStructure() Standard_OVERRIDE
+  {
+    if (!InsertionBaseClass::initDataStructure())
+    {
+      return Standard_False;
+    }
+
+    if (myIsPreProcessSurfaceNodes)
+    {
+      const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
+        this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
+
+      registerSurfaceNodes (aSurfaceNodes);
+    }
+
+    return Standard_True;
+  }
+
   //! Returns size of cell to be used by acceleration circles grid structure.
   virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer theVerticesNb) Standard_OVERRIDE
   {
@@ -55,10 +89,13 @@ protected:
   {
     InsertionBaseClass::postProcessMesh(theMesher);
 
-    const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
-      this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
+    if (!myIsPreProcessSurfaceNodes)
+    {
+      const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
+        this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
 
-    insertNodes(aSurfaceNodes, theMesher);
+      insertNodes(aSurfaceNodes, theMesher);
+    }
   }
 
   //! Inserts nodes into mesh.
@@ -86,6 +123,37 @@ protected:
     theMesher.AddVertices(aVertexIndexes);
     return !aVertexIndexes.IsEmpty();
   }
+
+private:
+  
+  //! Registers surface nodes in data structure.
+  Standard_Boolean registerSurfaceNodes(
+    const Handle(IMeshData::ListOfPnt2d)& theNodes)
+  {
+    if (theNodes.IsNull() || theNodes->IsEmpty())
+    {
+      return Standard_False;
+    }
+
+    Standard_Boolean isAdded = Standard_False;
+    IMeshData::ListOfPnt2d::Iterator aNodesIt(*theNodes);
+    for (Standard_Integer aNodeIt = 1; aNodesIt.More(); aNodesIt.Next(), ++aNodeIt)
+    {
+      const gp_Pnt2d& aPnt2d = aNodesIt.Value();
+      if (this->getClassifier()->Perform(aPnt2d) == TopAbs_IN)
+      {
+        isAdded = Standard_True;
+        this->registerNode(this->getRangeSplitter().Point(aPnt2d),
+                           aPnt2d, BRepMesh_Free, Standard_False);
+      }
+    }
+
+    return isAdded;
+  }
+
+private:
+
+  Standard_Boolean myIsPreProcessSurfaceNodes;
 };
 
 #endif
index 080e555c3b0698c73e8d1270f2e61b581f6b1035..cc2491df7029fc6f069e992e082903ea5b3b5659 100644 (file)
@@ -94,8 +94,6 @@ namespace
     Handle(BRepMesh_FaceChecker::ArrayOfBndBoxTree)& myWiresBndBoxTree;
   };
 
-  //! Selector.
-  //! Used to identify segments with overlapped bounding boxes.
   //! Selector.
   //! Used to identify segments with overlapped bounding boxes.
   class BndBox2dTreeSelector : public IMeshData::BndBox2dTree::Selector
index 34f471bbbeb5ee6c2f1f0b1003b6e58f69015779..24d3fd3658a3ff5b536ad882989a3e7857a8e3cf 100644 (file)
@@ -86,19 +86,28 @@ BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
 //purpose  : 
 //=======================================================================
 void BRepMesh_IncrementalMesh::Perform()
+{
+  Handle(BRepMesh_Context) aContext = new BRepMesh_Context;
+  Perform (aContext);
+}
+
+//=======================================================================
+//function : Perform
+//purpose  : 
+//=======================================================================
+void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theContext)
 {
   initParameters();
 
-  Handle(BRepMesh_Context) aContext = new BRepMesh_Context;
-  aContext->SetShape(Shape());
-  aContext->ChangeParameters()            = myParameters;
-  aContext->ChangeParameters().CleanModel = Standard_False;
+  theContext->SetShape(Shape());
+  theContext->ChangeParameters()            = myParameters;
+  theContext->ChangeParameters().CleanModel = Standard_False;
 
-  IMeshTools_MeshBuilder aIncMesh(aContext);
+  IMeshTools_MeshBuilder aIncMesh(theContext);
   aIncMesh.Perform();
 
   myStatus = IMeshData_NoError;
-  const Handle(IMeshData_Model)& aModel = aContext->GetModel();
+  const Handle(IMeshData_Model)& aModel = theContext->GetModel();
   for (Standard_Integer aFaceIt = 0; aFaceIt < aModel->FacesNb(); ++aFaceIt)
   {
     const IMeshData::IFaceHandle& aDFace = aModel->GetFace(aFaceIt);
index 3940eab4d05555a8610128c0e97adab91dc2b581..4831ffa43463402f80673190b4807ed7f3311386 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <BRepMesh_DiscretRoot.hxx>
 #include <IMeshTools_Parameters.hxx>
+#include <IMeshTools_Context.hxx>
 
 //! Builds the mesh of a shape with respect of their 
 //! correctly triangulated parts 
@@ -51,8 +52,11 @@ public: //! @name mesher API
   Standard_EXPORT BRepMesh_IncrementalMesh(const TopoDS_Shape&          theShape,
                                            const IMeshTools_Parameters& theParameters);
 
-//! Performs meshing ot the shape.
+  //! Performs meshing ot the shape.
   Standard_EXPORT virtual void Perform() Standard_OVERRIDE;
+
+  //! Performs meshing using custom context;
+  Standard_EXPORT void Perform(const Handle(IMeshTools_Context)& theContext);
   
 public: //! @name accessing to parameters.
 
index f73e95dbcd8e71cdec1424874113af316c8774a9..891448a1cf12d4b9d817d5e2b27b5903b1f5cad7 100644 (file)
@@ -35,13 +35,13 @@ namespace
   template<class RangeSplitter>
   struct NodeInsertionMeshAlgo
   {
-    typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter> Type;
+    typedef BRepMesh_DelaunayNodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> Type;
   };
 
   template<class RangeSplitter>
   struct DeflectionControlMeshAlgo
   {
-    typedef BRepMesh_DelaunayDeflectionControlMeshAlgo<RangeSplitter> Type;
+    typedef BRepMesh_DelaunayDeflectionControlMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> Type;
   };
 }
 
@@ -82,7 +82,9 @@ Handle(IMeshTools_MeshAlgo) BRepMesh_MeshAlgoFactory::GetAlgo(
     break;
 
   case GeomAbs_Cylinder:
-    return new NodeInsertionMeshAlgo<BRepMesh_CylinderRangeSplitter>::Type;
+    return theParameters.InternalVerticesMode ?
+      new NodeInsertionMeshAlgo<BRepMesh_CylinderRangeSplitter>::Type :
+      new BaseMeshAlgo::Type;
     break;
 
   case GeomAbs_Cone:
index a5a8d22c0e7ccd05a3b8c13b76131118356a15db..a37a4504e43404e644f1bca6f0935dbc2f5f8c42 100755 (executable)
@@ -1,5 +1,6 @@
 BRepMesh_BaseMeshAlgo.cxx
 BRepMesh_BaseMeshAlgo.hxx
+BRepMesh_ConstrainedBaseMeshAlgo.hxx
 BRepMesh_BoundaryParamsRangeSplitter.hxx
 BRepMesh_Circle.hxx
 BRepMesh_CircleInspector.hxx
@@ -82,4 +83,6 @@ BRepMesh_UVParamRangeSplitter.hxx
 BRepMesh_Vertex.hxx
 BRepMesh_VertexInspector.hxx
 BRepMesh_VertexTool.cxx
-BRepMesh_VertexTool.hxx
\ No newline at end of file
+BRepMesh_VertexTool.hxx
+BRepMesh_CustomBaseMeshAlgo.hxx
+BRepMesh_CustomDelaunayBaseMeshAlgo.hxx