0032603: Coding - get rid of unsused forward declarations
[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 #include <IMeshTools_Parameters.hxx>
22
23 #include <BRepMesh_Delaun.hxx>
24 #include <BRepMesh_MeshTool.hxx>
25
26
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
30 {
31 public:
32
33   //! Constructor.
34   BRepMesh_CustomBaseMeshAlgo ()
35   {
36   }
37
38   //! Destructor.
39   virtual ~BRepMesh_CustomBaseMeshAlgo ()
40   {
41   }
42
43   DEFINE_STANDARD_RTTIEXT(BRepMesh_CustomBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
44
45 protected:
46
47   //! Generates mesh for the contour stored in data structure.
48   virtual void generateMesh (const Message_ProgressRange& theRange) Standard_OVERRIDE
49   {
50     const Handle (BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure ();
51     const Standard_Integer aNodesNb = aStructure->NbNodes ();
52
53     buildBaseTriangulation ();
54
55     std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes ());
56     BRepMesh_Delaun aMesher (aStructure, aCellsCount.first, aCellsCount.second, Standard_False);
57
58     const Standard_Integer aNewNodesNb = aStructure->NbNodes ();
59     const Standard_Boolean isRemoveAux = aNewNodesNb > aNodesNb;
60     if (isRemoveAux)
61     {
62       IMeshData::VectorOfInteger aAuxVertices (aNewNodesNb - aNodesNb);
63       for (Standard_Integer aExtNodesIt = aNodesNb + 1; aExtNodesIt <= aNewNodesNb; ++aExtNodesIt)
64       {
65         aAuxVertices.Append (aExtNodesIt);
66       }
67
68       // Set aux vertices if there are some to clean up mesh correctly.
69       aMesher.SetAuxVertices (aAuxVertices);
70     }
71
72     aMesher.ProcessConstraints ();
73
74     // Destruction of triangles containing aux vertices added (possibly) during base mesh computation.
75     if (isRemoveAux)
76     {
77       aMesher.RemoveAuxElements ();
78     }
79
80     BRepMesh_MeshTool aCleaner (aStructure);
81     aCleaner.EraseFreeLinks ();
82
83     postProcessMesh (aMesher, theRange);
84   }
85
86 protected:
87
88   //! Builds base triangulation using custom triangulation algorithm.
89   Standard_EXPORT virtual void buildBaseTriangulation() = 0;
90 };
91
92 #endif