File indexing completed on 2025-01-18 10:03:14
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 : public BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BaseAlgo>
0026 {
0027 private:
0028
0029 typedef BRepMesh_NodeInsertionMeshAlgo<RangeSplitter, BaseAlgo> InsertionBaseClass;
0030
0031 public:
0032
0033
0034 BRepMesh_DelaunayNodeInsertionMeshAlgo()
0035 : myIsPreProcessSurfaceNodes (Standard_False)
0036 {
0037 }
0038
0039
0040 virtual ~BRepMesh_DelaunayNodeInsertionMeshAlgo()
0041 {
0042 }
0043
0044
0045 Standard_Boolean IsPreProcessSurfaceNodes () const
0046 {
0047 return myIsPreProcessSurfaceNodes;
0048 }
0049
0050
0051
0052
0053 void SetPreProcessSurfaceNodes (const Standard_Boolean isPreProcessSurfaceNodes)
0054 {
0055 myIsPreProcessSurfaceNodes = isPreProcessSurfaceNodes;
0056 }
0057
0058 protected:
0059
0060
0061 virtual Standard_Boolean initDataStructure() Standard_OVERRIDE
0062 {
0063 if (!InsertionBaseClass::initDataStructure())
0064 {
0065 return Standard_False;
0066 }
0067
0068 if (myIsPreProcessSurfaceNodes)
0069 {
0070 const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
0071 this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
0072
0073 registerSurfaceNodes (aSurfaceNodes);
0074 }
0075
0076 return Standard_True;
0077 }
0078
0079
0080 virtual std::pair<Standard_Integer, Standard_Integer> getCellsCount (const Standard_Integer theVerticesNb) Standard_OVERRIDE
0081 {
0082 return BRepMesh_GeomTool::CellsCount (this->getDFace()->GetSurface(), theVerticesNb,
0083 this->getDFace()->GetDeflection(),
0084 &this->getRangeSplitter());
0085 }
0086
0087
0088 virtual void postProcessMesh (BRepMesh_Delaun& theMesher,
0089 const Message_ProgressRange& theRange) Standard_OVERRIDE
0090 {
0091 if (!theRange.More())
0092 {
0093 return;
0094 }
0095 InsertionBaseClass::postProcessMesh (theMesher, Message_ProgressRange());
0096
0097 if (!myIsPreProcessSurfaceNodes)
0098 {
0099 const Handle(IMeshData::ListOfPnt2d) aSurfaceNodes =
0100 this->getRangeSplitter().GenerateSurfaceNodes(this->getParameters());
0101
0102 insertNodes(aSurfaceNodes, theMesher, theRange);
0103 }
0104 }
0105
0106
0107 Standard_Boolean insertNodes(
0108 const Handle(IMeshData::ListOfPnt2d)& theNodes,
0109 BRepMesh_Delaun& theMesher,
0110 const Message_ProgressRange& theRange)
0111 {
0112 if (theNodes.IsNull() || theNodes->IsEmpty())
0113 {
0114 return Standard_False;
0115 }
0116
0117 IMeshData::VectorOfInteger aVertexIndexes(theNodes->Size(), this->getAllocator());
0118 IMeshData::ListOfPnt2d::Iterator aNodesIt(*theNodes);
0119 for (Standard_Integer aNodeIt = 1; aNodesIt.More(); aNodesIt.Next(), ++aNodeIt)
0120 {
0121 const gp_Pnt2d& aPnt2d = aNodesIt.Value();
0122 if (this->getClassifier()->Perform(aPnt2d) == TopAbs_IN)
0123 {
0124 aVertexIndexes.Append(this->registerNode(this->getRangeSplitter().Point(aPnt2d),
0125 aPnt2d, BRepMesh_Free, 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
0140 Standard_Boolean registerSurfaceNodes(
0141 const Handle(IMeshData::ListOfPnt2d)& theNodes)
0142 {
0143 if (theNodes.IsNull() || theNodes->IsEmpty())
0144 {
0145 return Standard_False;
0146 }
0147
0148 Standard_Boolean isAdded = Standard_False;
0149 IMeshData::ListOfPnt2d::Iterator aNodesIt(*theNodes);
0150 for (Standard_Integer aNodeIt = 1; aNodesIt.More(); aNodesIt.Next(), ++aNodeIt)
0151 {
0152 const gp_Pnt2d& aPnt2d = aNodesIt.Value();
0153 if (this->getClassifier()->Perform(aPnt2d) == TopAbs_IN)
0154 {
0155 isAdded = Standard_True;
0156 this->registerNode(this->getRangeSplitter().Point(aPnt2d),
0157 aPnt2d, BRepMesh_Free, Standard_False);
0158 }
0159 }
0160
0161 return isAdded;
0162 }
0163
0164 private:
0165
0166 Standard_Boolean myIsPreProcessSurfaceNodes;
0167 };
0168
0169 #endif