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>
22 #include <BRepMesh_Delaun.hxx>
23 #include <BRepMesh_MeshTool.hxx>
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
33 BRepMesh_CustomBaseMeshAlgo ()
38 virtual ~BRepMesh_CustomBaseMeshAlgo ()
42 DEFINE_STANDARD_RTTIEXT(BRepMesh_CustomBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
46 //! Generates mesh for the contour stored in data structure.
47 virtual void generateMesh (const Message_ProgressRange& theRange) Standard_OVERRIDE
49 const Handle (BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure ();
50 const Standard_Integer aNodesNb = aStructure->NbNodes ();
52 buildBaseTriangulation ();
54 std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes ());
55 BRepMesh_Delaun aMesher (aStructure, aCellsCount.first, aCellsCount.second, Standard_False);
57 const Standard_Integer aNewNodesNb = aStructure->NbNodes ();
58 const Standard_Boolean isRemoveAux = aNewNodesNb > aNodesNb;
61 IMeshData::VectorOfInteger aAuxVertices (aNewNodesNb - aNodesNb);
62 for (Standard_Integer aExtNodesIt = aNodesNb + 1; aExtNodesIt <= aNewNodesNb; ++aExtNodesIt)
64 aAuxVertices.Append (aExtNodesIt);
67 // Set aux vertices if there are some to clean up mesh correctly.
68 aMesher.SetAuxVertices (aAuxVertices);
71 aMesher.ProcessConstraints ();
73 // Destruction of triangles containing aux vertices added (possibly) during base mesh computation.
76 aMesher.RemoveAuxElements ();
79 BRepMesh_MeshTool aCleaner (aStructure);
80 aCleaner.EraseFreeLinks ();
82 postProcessMesh (aMesher, theRange);
87 //! Builds base triangulation using custom triangulation algorithm.
88 Standard_EXPORT virtual void buildBaseTriangulation() = 0;