Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:13

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 
0026 //! Class provides base functionality to build face triangulation using custom triangulation algorithm.
0027 //! Performs generation of mesh using raw data from model.
0028 class BRepMesh_CustomBaseMeshAlgo : public BRepMesh_ConstrainedBaseMeshAlgo
0029 {
0030 public:
0031 
0032   //! Constructor.
0033   BRepMesh_CustomBaseMeshAlgo ()
0034   {
0035   }
0036 
0037   //! Destructor.
0038   virtual ~BRepMesh_CustomBaseMeshAlgo ()
0039   {
0040   }
0041 
0042   DEFINE_STANDARD_RTTIEXT(BRepMesh_CustomBaseMeshAlgo, BRepMesh_ConstrainedBaseMeshAlgo)
0043 
0044 protected:
0045 
0046   //! Generates mesh for the contour stored in data structure.
0047   virtual void generateMesh (const Message_ProgressRange& theRange) Standard_OVERRIDE
0048   {
0049     const Handle (BRepMesh_DataStructureOfDelaun)& aStructure = this->getStructure ();
0050     const Standard_Integer aNodesNb = aStructure->NbNodes ();
0051 
0052     buildBaseTriangulation ();
0053 
0054     std::pair<Standard_Integer, Standard_Integer> aCellsCount = this->getCellsCount (aStructure->NbNodes ());
0055     BRepMesh_Delaun aMesher (aStructure, aCellsCount.first, aCellsCount.second, Standard_False);
0056 
0057     const Standard_Integer aNewNodesNb = aStructure->NbNodes ();
0058     const Standard_Boolean isRemoveAux = aNewNodesNb > aNodesNb;
0059     if (isRemoveAux)
0060     {
0061       IMeshData::VectorOfInteger aAuxVertices (aNewNodesNb - aNodesNb);
0062       for (Standard_Integer aExtNodesIt = aNodesNb + 1; aExtNodesIt <= aNewNodesNb; ++aExtNodesIt)
0063       {
0064         aAuxVertices.Append (aExtNodesIt);
0065       }
0066 
0067       // Set aux vertices if there are some to clean up mesh correctly.
0068       aMesher.SetAuxVertices (aAuxVertices);
0069     }
0070 
0071     aMesher.ProcessConstraints ();
0072 
0073     // Destruction of triangles containing aux vertices added (possibly) during base mesh computation.
0074     if (isRemoveAux)
0075     {
0076       aMesher.RemoveAuxElements ();
0077     }
0078 
0079     BRepMesh_MeshTool aCleaner (aStructure);
0080     aCleaner.EraseFreeLinks ();
0081 
0082     postProcessMesh (aMesher, theRange);
0083   }
0084 
0085 protected:
0086 
0087   //! Builds base triangulation using custom triangulation algorithm.
0088   Standard_EXPORT virtual void buildBaseTriangulation() = 0;
0089 };
0090 
0091 #endif