Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:15:11

0001 // Created on: 2019-06-07
0002 // Copyright (c) 2019 OPEN CASCADE SAS
0003 // Created by: Oleg AGASHIN
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _BRepMesh_CustomBaseMeshAlgo_HeaderFile
0017 #define _BRepMesh_CustomBaseMeshAlgo_HeaderFile
0018 
0019 #include <BRepMesh_ConstrainedBaseMeshAlgo.hxx>
0020 #include <NCollection_Shared.hxx>
0021 
0022 #include <BRepMesh_Delaun.hxx>
0023 #include <BRepMesh_MeshTool.hxx>
0024 
0025 //! Class provides base functionality to build face triangulation using custom triangulation
0026 //! algorithm. Performs generation of mesh using raw data from model.
0027 class BRepMesh_CustomBaseMeshAlgo : public BRepMesh_ConstrainedBaseMeshAlgo
0028 {
0029 public:
0030   //! Constructor.
0031   BRepMesh_CustomBaseMeshAlgo() = default;
0032 
0033   //! Destructor.
0034   ~BRepMesh_CustomBaseMeshAlgo() override = default;
0035 
0036   DEFINE_STANDARD_RTTIEXT(BRepMesh_CustomBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
0037 
0038 protected:
0039   //! Generates mesh for the contour stored in data structure.
0040   void generateMesh(const Message_ProgressRange& theRange) override
0041   {
0042     const occ::handle<BRepMesh_DataStructureOfDelaun>& aStructure = this->getStructure();
0043     const int                                          aNodesNb   = aStructure->NbNodes();
0044 
0045     buildBaseTriangulation();
0046 
0047     std::pair<int, int> aCellsCount = this->getCellsCount(aStructure->NbNodes());
0048     BRepMesh_Delaun     aMesher(aStructure, aCellsCount.first, aCellsCount.second, false);
0049 
0050     const int  aNewNodesNb = aStructure->NbNodes();
0051     const bool isRemoveAux = aNewNodesNb > aNodesNb;
0052     if (isRemoveAux)
0053     {
0054       IMeshData::VectorOfInteger aAuxVertices(aNewNodesNb - aNodesNb);
0055       for (int aExtNodesIt = aNodesNb + 1; aExtNodesIt <= aNewNodesNb; ++aExtNodesIt)
0056       {
0057         aAuxVertices.Append(aExtNodesIt);
0058       }
0059 
0060       // Set aux vertices if there are some to clean up mesh correctly.
0061       aMesher.SetAuxVertices(aAuxVertices);
0062     }
0063 
0064     aMesher.ProcessConstraints();
0065 
0066     // Destruction of triangles containing aux vertices added (possibly) during base mesh
0067     // computation.
0068     if (isRemoveAux)
0069     {
0070       aMesher.RemoveAuxElements();
0071     }
0072 
0073     BRepMesh_MeshTool aCleaner(aStructure);
0074     aCleaner.EraseFreeLinks();
0075 
0076     postProcessMesh(aMesher, theRange);
0077   }
0078 
0079 protected:
0080   //! Builds base triangulation using custom triangulation algorithm.
0081   Standard_EXPORT virtual void buildBaseTriangulation() = 0;
0082 };
0083 
0084 #endif