File indexing completed on 2026-08-23 09:16:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _BRepMesh_DelaunayNodeInsertionMeshAlgo_HeaderFile
0017 #define _BRepMesh_DelaunayNodeInsertionMeshAlgo_HeaderFile
0018
0019 #include <BRepMesh_NodeInsertionMeshAlgo.hxx>
0020 #include <BRepMesh_GeomTool.hxx>
0021
0022
0023
0024 template <class RangeSplitter, class BaseAlgo>
0025 class BRepMesh_DelaunayNodeInsertionMeshAlgo
0026 : public BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BaseAlgo>
0027 {
0028 private:
0029
0030 typedef BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BaseAlgo> InsertionBaseClass;
0031
0032 public:
0033
0034 BRepMesh_DelaunayNodeInsertionMeshAlgo()
0035 : myIsPreProcessSurfaceNodes(Standard_False)
0036 {
0037 }
0038
0039
0040 virtual ~BRepMesh_DelaunayNodeInsertionMeshAlgo() {}
0041
0042
0043 Standard_Boolean IsPreProcessSurfaceNodes() const { return myIsPreProcessSurfaceNodes; }
0044
0045
0046
0047
0048 void SetPreProcessSurfaceNodes(const Standard_Boolean isPreProcessSurfaceNodes)
0049 {
0050 myIsPreProcessSurfaceNodes = isPreProcessSurfaceNodes;
0051 }
0052
0053 protected:
0054
0055 virtual Standard_Boolean initDataStructure() Standard_OVERRIDE
0056 {
0057 if (!InsertionBaseClass::initDataStructure())
0058 {
0059 return Standard_False;
0060 }
0061
0062 if (myIsPreProcessSurfaceNodes)
0063 {
0064 const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
0065 this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
0066
0067 registerSurfaceNodes(aSurfaceNodes);
0068 }
0069
0070 return Standard_True;
0071 }
0072
0073
0074 virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount(
0075 const Standard_Integer theVerticesNb) Standard_OVERRIDE
0076 {
0077 return BRepMesh_GeomTool::CellsCount(this->getDFace()->GetSurface(),
0078 theVerticesNb,
0079 this->getDFace()->GetDeflection(),
0080 &this->getRangeSplitter());
0081 }
0082
0083
0084
0085 virtual void postProcessMesh(BRepMesh_Delaun& theMesher,
0086 const Message_ProgressRange& theRange) Standard_OVERRIDE
0087 {
0088 if (!theRange.More())
0089 {
0090 return;
0091 }
0092
0093 InsertionBaseClass::postProcessMesh (theMesher, Message_ProgressRange());
0094
0095
0096 if (!myIsPreProcessSurfaceNodes)
0097 {
0098 const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
0099 this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
0100
0101 insertNodes(aSurfaceNodes, theMesher, theRange);
0102 }
0103 }
0104
0105
0106 Standard_Boolean insertNodes(const Handle(IMeshData::ListOfPnt2d)& theNodes,
0107 BRepMesh_Delaun& theMesher,
0108 const Message_ProgressRange& theRange)
0109 {
0110 if (theNodes.IsNull() || theNodes->IsEmpty())
0111 {
0112 return Standard_False;
0113 }
0114
0115 IMeshData::VectorOfInteger aVertexIndexes(theNodes->Size(), this->getAllocator());
0116 IMeshData::ListOfPnt2d::Iterator aNodesIt(*theNodes);
0117 for (Standard_Integer aNodeIt = 1; aNodesIt.More(); aNodesIt.Next(), ++aNodeIt)
0118 {
0119 const gp_Pnt2d& aPnt2d = aNodesIt.Value();
0120 if (this->getClassifier()->Perform(aPnt2d) == TopAbs_IN)
0121 {
0122 aVertexIndexes.Append(this->registerNode(this->getRangeSplitter().Point(aPnt2d),
0123 aPnt2d,
0124 BRepMesh_Free,
0125 Standard_False));
0126 }
0127 }
0128
0129 theMesher.AddVertices(aVertexIndexes, theRange);
0130 if (!theRange.More())
0131 {
0132 return Standard_False;
0133 }
0134 return !aVertexIndexes.IsEmpty();
0135 }
0136
0137 private:
0138
0139 Standard_Boolean registerSurfaceNodes(const Handle(IMeshData::ListOfPnt2d)& theNodes)
0140 {
0141 if (theNodes.IsNull() || theNodes->IsEmpty())
0142 {
0143 return Standard_False;
0144 }
0145
0146 Standard_Boolean isAdded = Standard_False;
0147 IMeshData::ListOfPnt2d::Iterator aNodesIt(*theNodes);
0148 for (Standard_Integer aNodeIt = 1; aNodesIt.More(); aNodesIt.Next(), ++aNodeIt)
0149 {
0150 const gp_Pnt2d& aPnt2d = aNodesIt.Value();
0151 if (this->getClassifier()->Perform(aPnt2d) == TopAbs_IN)
0152 {
0153 isAdded = Standard_True;
0154 this->registerNode(this->getRangeSplitter().Point(aPnt2d),
0155 aPnt2d,
0156 BRepMesh_Free,
0157 Standard_False);
0158 }
0159 }
0160
0161 return isAdded;
0162 }
0163
0164 private:
0165 Standard_Boolean myIsPreProcessSurfaceNodes;
0166 };
0167
0168 #endif