1 // Created on: 2019-06-07
2 // Copyright (c) 2019 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _BRepMesh_CustomBaseMeshAlgo_HeaderFile
17 #define _BRepMesh_CustomBaseMeshAlgo_HeaderFile
19 #include <BRepMesh_ConstrainedBaseMeshAlgo.hxx>
20 #include <NCollection_Shared.hxx>
21 #include <IMeshTools_Parameters.hxx>
23 #include <BRepMesh_Delaun.hxx>
24 #include <BRepMesh_MeshTool.hxx>
27 //! Class provides base functionality to build face triangulation using custom triangulation algorithm.
28 //! Performs generation of mesh using raw data from model.
29 class BRepMesh_CustomBaseMeshAlgo : public BRepMesh_ConstrainedBaseMeshAlgo
34 BRepMesh_CustomBaseMeshAlgo ()
39 virtual ~BRepMesh_CustomBaseMeshAlgo ()
43 DEFINE_STANDARD_RTTIEXT(BRepMesh_CustomBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
47 //! Generates mesh for the contour stored in data structure.
48 virtual void generateMesh (const Message_ProgressRange& theRange) Standard_OVERRIDE
50 const Handle (BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure ();
51 const Standard_Integer aNodesNb = aStructure->NbNodes ();
53 buildBaseTriangulation ();
55 std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes ());
56 BRepMesh_Delaun aMesher (aStructure, aCellsCount.first, aCellsCount.second, Standard_False);
58 const Standard_Integer aNewNodesNb = aStructure->NbNodes ();
59 const Standard_Boolean isRemoveAux = aNewNodesNb > aNodesNb;
62 IMeshData::VectorOfInteger aAuxVertices (aNewNodesNb - aNodesNb);
63 for (Standard_Integer aExtNodesIt = aNodesNb + 1; aExtNodesIt <= aNewNodesNb; ++aExtNodesIt)
65 aAuxVertices.Append (aExtNodesIt);
68 // Set aux vertices if there are some to clean up mesh correctly.
69 aMesher.SetAuxVertices (aAuxVertices);
72 aMesher.ProcessConstraints ();
74 // Destruction of triangles containing aux vertices added (possibly) during base mesh computation.
77 aMesher.RemoveAuxElements ();
80 BRepMesh_MeshTool aCleaner (aStructure);
81 aCleaner.EraseFreeLinks ();
83 postProcessMesh (aMesher, theRange);
88 //! Builds base triangulation using custom triangulation algorithm.
89 Standard_EXPORT virtual void buildBaseTriangulation() = 0;