diff --git a/src/BRepMesh/BRepMesh_CircleTool.hxx b/src/BRepMesh/BRepMesh_CircleTool.hxx index 2a36e1a368..3f5701d63d 100644 --- a/src/BRepMesh/BRepMesh_CircleTool.hxx +++ b/src/BRepMesh/BRepMesh_CircleTool.hxx @@ -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 index 0000000000..7edd4aac23 --- /dev/null +++ b/src/BRepMesh/BRepMesh_ConstrainedBaseMeshAlgo.hxx @@ -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 +#include +#include + +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 getCellsCount (const Standard_Integer /*theVerticesNb*/) + { + return std::pair (-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 index 0000000000..e175091de9 --- /dev/null +++ b/src/BRepMesh/BRepMesh_CustomBaseMeshAlgo.hxx @@ -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 +#include +#include + +#include +#include + +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 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 index 0000000000..6bde7b90a8 --- /dev/null +++ b/src/BRepMesh/BRepMesh_CustomDelaunayBaseMeshAlgo.hxx @@ -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 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 aCellsCount = this->getCellsCount (aStructure->NbNodes()); + theMesher.InitCirclesTool (aCellsCount.first, aCellsCount.second); + } +}; + +#endif diff --git a/src/BRepMesh/BRepMesh_Delaun.cxx b/src/BRepMesh/BRepMesh_Delaun.cxx index 8b6e96d334..c87bc6ce62 100644 --- a/src/BRepMesh/BRepMesh_Delaun.cxx +++ b/src/BRepMesh/BRepMesh_Delaun.cxx @@ -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(); } //======================================================================= diff --git a/src/BRepMesh/BRepMesh_Delaun.hxx b/src/BRepMesh/BRepMesh_Delaun.hxx index 320d882da6..f03a333a11 100755 --- a/src/BRepMesh/BRepMesh_Delaun.hxx +++ b/src/BRepMesh/BRepMesh_Delaun.hxx @@ -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 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. diff --git a/src/BRepMesh/BRepMesh_DelaunayBaseMeshAlgo.hxx b/src/BRepMesh/BRepMesh_DelaunayBaseMeshAlgo.hxx index 1ae2661909..81bfdc7c9f 100644 --- a/src/BRepMesh/BRepMesh_DelaunayBaseMeshAlgo.hxx +++ b/src/BRepMesh/BRepMesh_DelaunayBaseMeshAlgo.hxx @@ -16,7 +16,7 @@ #ifndef _BRepMesh_DelaunayBaseMeshAlgo_HeaderFile #define _BRepMesh_DelaunayBaseMeshAlgo_HeaderFile -#include +#include #include #include @@ -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 getCellsCount (const Standard_Integer /*theVerticesNb*/) - { - return std::pair (-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 diff --git a/src/BRepMesh/BRepMesh_DelaunayDeflectionControlMeshAlgo.hxx b/src/BRepMesh/BRepMesh_DelaunayDeflectionControlMeshAlgo.hxx index 78689d114d..04f4708d66 100644 --- a/src/BRepMesh/BRepMesh_DelaunayDeflectionControlMeshAlgo.hxx +++ b/src/BRepMesh/BRepMesh_DelaunayDeflectionControlMeshAlgo.hxx @@ -22,12 +22,12 @@ //! Extends node insertion Delaunay meshing algo in order to control //! deflection of generated trianges. Splits triangles failing the check. -template -class BRepMesh_DelaunayDeflectionControlMeshAlgo : public BRepMesh_DelaunayNodeInsertionMeshAlgo +template +class BRepMesh_DelaunayDeflectionControlMeshAlgo : public BRepMesh_DelaunayNodeInsertionMeshAlgo { private: // Typedef for OCCT RTTI - typedef BRepMesh_DelaunayNodeInsertionMeshAlgo DelaunayInsertionBaseClass; + typedef BRepMesh_DelaunayNodeInsertionMeshAlgo DelaunayInsertionBaseClass; public: diff --git a/src/BRepMesh/BRepMesh_DelaunayNodeInsertionMeshAlgo.hxx b/src/BRepMesh/BRepMesh_DelaunayNodeInsertionMeshAlgo.hxx index 23863b74bd..ccbe55278e 100644 --- a/src/BRepMesh/BRepMesh_DelaunayNodeInsertionMeshAlgo.hxx +++ b/src/BRepMesh/BRepMesh_DelaunayNodeInsertionMeshAlgo.hxx @@ -21,17 +21,18 @@ //! Extends base Delaunay meshing algo in order to enable possibility //! of addition of free vertices and internal nodes into the mesh. -template -class BRepMesh_DelaunayNodeInsertionMeshAlgo : public BRepMesh_NodeInsertionMeshAlgo +template +class BRepMesh_DelaunayNodeInsertionMeshAlgo : public BRepMesh_NodeInsertionMeshAlgo { private: // Typedef for OCCT RTTI - typedef BRepMesh_NodeInsertionMeshAlgo InsertionBaseClass; + typedef BRepMesh_NodeInsertionMeshAlgo 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 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 diff --git a/src/BRepMesh/BRepMesh_FaceChecker.cxx b/src/BRepMesh/BRepMesh_FaceChecker.cxx index 080e555c3b..cc2491df70 100644 --- a/src/BRepMesh/BRepMesh_FaceChecker.cxx +++ b/src/BRepMesh/BRepMesh_FaceChecker.cxx @@ -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 diff --git a/src/BRepMesh/BRepMesh_IncrementalMesh.cxx b/src/BRepMesh/BRepMesh_IncrementalMesh.cxx index 34f471bbbe..24d3fd3658 100644 --- a/src/BRepMesh/BRepMesh_IncrementalMesh.cxx +++ b/src/BRepMesh/BRepMesh_IncrementalMesh.cxx @@ -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); diff --git a/src/BRepMesh/BRepMesh_IncrementalMesh.hxx b/src/BRepMesh/BRepMesh_IncrementalMesh.hxx index 3940eab4d0..4831ffa434 100644 --- a/src/BRepMesh/BRepMesh_IncrementalMesh.hxx +++ b/src/BRepMesh/BRepMesh_IncrementalMesh.hxx @@ -16,6 +16,7 @@ #include #include +#include //! 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. diff --git a/src/BRepMesh/BRepMesh_MeshAlgoFactory.cxx b/src/BRepMesh/BRepMesh_MeshAlgoFactory.cxx index f73e95dbcd..891448a1cf 100644 --- a/src/BRepMesh/BRepMesh_MeshAlgoFactory.cxx +++ b/src/BRepMesh/BRepMesh_MeshAlgoFactory.cxx @@ -35,13 +35,13 @@ namespace template struct NodeInsertionMeshAlgo { - typedef BRepMesh_DelaunayNodeInsertionMeshAlgo Type; + typedef BRepMesh_DelaunayNodeInsertionMeshAlgo Type; }; template struct DeflectionControlMeshAlgo { - typedef BRepMesh_DelaunayDeflectionControlMeshAlgo Type; + typedef BRepMesh_DelaunayDeflectionControlMeshAlgo Type; }; } @@ -82,7 +82,9 @@ Handle(IMeshTools_MeshAlgo) BRepMesh_MeshAlgoFactory::GetAlgo( break; case GeomAbs_Cylinder: - return new NodeInsertionMeshAlgo::Type; + return theParameters.InternalVerticesMode ? + new NodeInsertionMeshAlgo::Type : + new BaseMeshAlgo::Type; break; case GeomAbs_Cone: diff --git a/src/BRepMesh/FILES b/src/BRepMesh/FILES index a5a8d22c0e..a37a4504e4 100755 --- a/src/BRepMesh/FILES +++ b/src/BRepMesh/FILES @@ -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