0032781: Coding - get rid of unused headers [BRepCheck to ChFiKPart]
[occt.git] / src / BRepMesh / BRepMesh_CustomBaseMeshAlgo.hxx
1 // Created on: 2019-06-07
2 // Copyright (c) 2019 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _BRepMesh_CustomBaseMeshAlgo_HeaderFile
17 #define _BRepMesh_CustomBaseMeshAlgo_HeaderFile
18
19 #include <BRepMesh_ConstrainedBaseMeshAlgo.hxx>
20 #include <NCollection_Shared.hxx>
21
22 #include <BRepMesh_Delaun.hxx>
23 #include <BRepMesh_MeshTool.hxx>
24
25
26 //! Class provides base functionality to build face triangulation using custom triangulation algorithm.
27 //! Performs generation of mesh using raw data from model.
28 class BRepMesh_CustomBaseMeshAlgo : public BRepMesh_ConstrainedBaseMeshAlgo
29 {
30 public:
31
32   //! Constructor.
33   BRepMesh_CustomBaseMeshAlgo ()
34   {
35   }
36
37   //! Destructor.
38   virtual ~BRepMesh_CustomBaseMeshAlgo ()
39   {
40   }
41
42   DEFINE_STANDARD_RTTIEXT(BRepMesh_CustomBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
43
44 protected:
45
46   //! Generates mesh for the contour stored in data structure.
47   virtual void generateMesh (const Message_ProgressRange& theRange) Standard_OVERRIDE
48   {
49     const Handle (BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure ();
50     const Standard_Integer aNodesNb = aStructure->NbNodes ();
51
52     buildBaseTriangulation ();
53
54     std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes ());
55     BRepMesh_Delaun aMesher (aStructure, aCellsCount.first, aCellsCount.second, Standard_False);
56
57     const Standard_Integer aNewNodesNb = aStructure->NbNodes ();
58     const Standard_Boolean isRemoveAux = aNewNodesNb > aNodesNb;
59     if (isRemoveAux)
60     {
61       IMeshData::VectorOfInteger aAuxVertices (aNewNodesNb - aNodesNb);
62       for (Standard_Integer aExtNodesIt = aNodesNb + 1; aExtNodesIt <= aNewNodesNb; ++aExtNodesIt)
63       {
64         aAuxVertices.Append (aExtNodesIt);
65       }
66
67       // Set aux vertices if there are some to clean up mesh correctly.
68       aMesher.SetAuxVertices (aAuxVertices);
69     }
70
71     aMesher.ProcessConstraints ();
72
73     // Destruction of triangles containing aux vertices added (possibly) during base mesh computation.
74     if (isRemoveAux)
75     {
76       aMesher.RemoveAuxElements ();
77     }
78
79     BRepMesh_MeshTool aCleaner (aStructure);
80     aCleaner.EraseFreeLinks ();
81
82     postProcessMesh (aMesher, theRange);
83   }
84
85 protected:
86
87   //! Builds base triangulation using custom triangulation algorithm.
88   Standard_EXPORT virtual void buildBaseTriangulation() = 0;
89 };
90
91 #endif