0030754: Coding - the array of weights should begin with Lower, not the constant...
[occt.git] / src / BRepMesh / BRepMesh_DelaunayNodeInsertionMeshAlgo.hxx
CommitLineData
7bd071ed 1// Created on: 2016-07-07
2// Copyright (c) 2016 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_DelaunayNodeInsertionMeshAlgo_HeaderFile
17#define _BRepMesh_DelaunayNodeInsertionMeshAlgo_HeaderFile
18
19#include <BRepMesh_NodeInsertionMeshAlgo.hxx>
20#include <BRepMesh_GeomTool.hxx>
21
22//! Extends base Delaunay meshing algo in order to enable possibility
23//! of addition of free vertices and internal nodes into the mesh.
24template<class RangeSplitter>
25class BRepMesh_DelaunayNodeInsertionMeshAlgo : public BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo>
26{
27private:
28 // Typedef for OCCT RTTI
29 typedef BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BRepMesh_DelaunayBaseMeshAlgo> InsertionBaseClass;
30
31public:
32
33 //! Constructor.
34 BRepMesh_DelaunayNodeInsertionMeshAlgo()
35 {
36 }
37
38 //! Destructor.
39 virtual ~BRepMesh_DelaunayNodeInsertionMeshAlgo()
40 {
41 }
42
43protected:
44
45 //! Returns size of cell to be used by acceleration circles grid structure.
46 virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer theVerticesNb) Standard_OVERRIDE
47 {
48 return BRepMesh_GeomTool::CellsCount (this->getDFace()->GetSurface(), theVerticesNb,
46478ffe 49 this->getDFace()->GetDeflection(),
50 &this->getRangeSplitter());
7bd071ed 51 }
52
53 //! Perfroms processing of generated mesh. Generates surface nodes and inserts them into structure.
54 virtual void postProcessMesh(BRepMesh_Delaun& theMesher) Standard_OVERRIDE
55 {
56 InsertionBaseClass::postProcessMesh(theMesher);
57
58 const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
59 this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
60
61 insertNodes(aSurfaceNodes, theMesher);
62 }
63
64 //! Inserts nodes into mesh.
65 Standard_Boolean insertNodes(
66 const Handle(IMeshData::ListOfPnt2d)& theNodes,
67 BRepMesh_Delaun& theMesher)
68 {
69 if (theNodes.IsNull() || theNodes->IsEmpty())
70 {
71 return Standard_False;
72 }
73
74 IMeshData::VectorOfInteger aVertexIndexes(theNodes->Size(), this->getAllocator());
75 IMeshData::ListOfPnt2d::Iterator aNodesIt(*theNodes);
76 for (Standard_Integer aNodeIt = 1; aNodesIt.More(); aNodesIt.Next(), ++aNodeIt)
77 {
78 const gp_Pnt2d& aPnt2d = aNodesIt.Value();
79 if (this->getClassifier()->Perform(aPnt2d) == TopAbs_IN)
80 {
81 aVertexIndexes.Append(this->registerNode(this->getRangeSplitter().Point(aPnt2d),
82 aPnt2d, BRepMesh_Free, Standard_False));
83 }
84 }
85
86 theMesher.AddVertices(aVertexIndexes);
87 return !aVertexIndexes.IsEmpty();
88 }
89};
90
91#endif