Warning, file /include/opencascade/BRepMesh_Delaun.hxx was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _BRepMesh_Delaun_HeaderFile
0015 #define _BRepMesh_Delaun_HeaderFile
0016
0017 #include <Standard.hxx>
0018 #include <Standard_DefineAlloc.hxx>
0019 #include <Standard_Macro.hxx>
0020
0021 #include <BRepMesh_CircleTool.hxx>
0022 #include <BRepMesh_Triangle.hxx>
0023 #include <BRepMesh_Edge.hxx>
0024 #include <IMeshData_Types.hxx>
0025 #include <BRepMesh_DataStructureOfDelaun.hxx>
0026 #include <BRepMesh_GeomTool.hxx>
0027 #include <Message_ProgressRange.hxx>
0028
0029 class Bnd_Box2d;
0030 class BRepMesh_Vertex;
0031
0032
0033 class BRepMesh_Delaun
0034 {
0035 public:
0036 DEFINE_STANDARD_ALLOC
0037
0038
0039 Standard_EXPORT BRepMesh_Delaun(const occ::handle<BRepMesh_DataStructureOfDelaun>& theOldMesh,
0040 const int theCellsCountU,
0041 const int theCellsCountV,
0042 const bool isFillCircles);
0043
0044
0045 Standard_EXPORT BRepMesh_Delaun(IMeshData::Array1OfVertexOfDelaun& theVertices);
0046
0047
0048 Standard_EXPORT BRepMesh_Delaun(const occ::handle<BRepMesh_DataStructureOfDelaun>& theOldMesh,
0049 IMeshData::Array1OfVertexOfDelaun& theVertices);
0050
0051
0052 Standard_EXPORT BRepMesh_Delaun(const occ::handle<BRepMesh_DataStructureOfDelaun>& theOldMesh,
0053 IMeshData::VectorOfInteger& theVertexIndices);
0054
0055
0056 Standard_EXPORT BRepMesh_Delaun(const occ::handle<BRepMesh_DataStructureOfDelaun>& theOldMesh,
0057 IMeshData::VectorOfInteger& theVertexIndices,
0058 const int theCellsCountU,
0059 const int theCellsCountV);
0060
0061
0062 Standard_EXPORT void Init(IMeshData::Array1OfVertexOfDelaun& theVertices);
0063
0064
0065 Standard_EXPORT void InitCirclesTool(const int theCellsCountU, const int theCellsCountV);
0066
0067
0068 Standard_EXPORT void RemoveVertex(const BRepMesh_Vertex& theVertex);
0069
0070
0071 Standard_EXPORT void AddVertices(IMeshData::VectorOfInteger& theVerticesIndices,
0072 const Message_ProgressRange& theRange = Message_ProgressRange());
0073
0074
0075
0076 Standard_EXPORT bool UseEdge(const int theEdge);
0077
0078
0079 const occ::handle<BRepMesh_DataStructureOfDelaun>& Result() const { return myMeshData; }
0080
0081
0082 void ProcessConstraints()
0083 {
0084 insertInternalEdges();
0085
0086
0087 frontierAdjust();
0088 }
0089
0090
0091 Handle(IMeshData::MapOfInteger) Frontier() const { return getEdgesByType(BRepMesh_Frontier); }
0092
0093
0094 Handle(IMeshData::MapOfInteger) InternalEdges() const { return getEdgesByType(BRepMesh_Fixed); }
0095
0096
0097 Handle(IMeshData::MapOfInteger) FreeEdges() const { return getEdgesByType(BRepMesh_Free); }
0098
0099
0100 const BRepMesh_Vertex& GetVertex(const int theIndex) const
0101 {
0102 return myMeshData->GetNode(theIndex);
0103 }
0104
0105
0106 const BRepMesh_Edge& GetEdge(const int theIndex) const { return myMeshData->GetLink(theIndex); }
0107
0108
0109 const BRepMesh_Triangle& GetTriangle(const int theIndex) const
0110 {
0111 return myMeshData->GetElement(theIndex);
0112 }
0113
0114
0115 const BRepMesh_CircleTool& Circles() const { return myCircles; }
0116
0117
0118
0119
0120
0121 Standard_EXPORT bool Contains(const int theTriangleId,
0122 const BRepMesh_Vertex& theVertex,
0123 const double theSqTolerance,
0124 int& theEdgeOn) const;
0125
0126
0127 inline void SetAuxVertices(const IMeshData::VectorOfInteger& theSupVert)
0128 {
0129 mySupVert = theSupVert;
0130 }
0131
0132
0133
0134
0135 Standard_EXPORT void RemoveAuxElements();
0136
0137 private:
0138 enum ReplaceFlag
0139 {
0140 Replace,
0141 InsertAfter,
0142 InsertBefore
0143 };
0144
0145 typedef NCollection_DataMap<int, IMeshData::MapOfInteger> DataMapOfMap;
0146
0147
0148 void initCirclesTool(const Bnd_Box2d& theBox, const int theCellsCountU, const int theCellsCountV);
0149
0150
0151
0152 void fillBndBox(IMeshData::SequenceOfBndB2d& theBoxes,
0153 const BRepMesh_Vertex& theV1,
0154 const BRepMesh_Vertex& theV2);
0155
0156
0157
0158
0159 Handle(IMeshData::MapOfInteger) getEdgesByType(const BRepMesh_DegreeOfFreedom theEdgeType) const;
0160
0161
0162 void perform(IMeshData::VectorOfInteger& theVertexIndices,
0163 const int theCellsCountU = -1,
0164 const int theCellsCountV = -1);
0165
0166
0167 void superMesh(const Bnd_Box2d& theBox);
0168
0169
0170
0171 void compute(IMeshData::VectorOfInteger& theVertexIndices);
0172
0173
0174 void frontierAdjust();
0175
0176
0177 bool meshLeftPolygonOf(const int theEdgeIndex,
0178 const bool isForward,
0179 Handle(IMeshData::MapOfInteger) theSkipped = nullptr);
0180
0181
0182
0183
0184
0185
0186 int findNextPolygonLink(const int& theFirstNode,
0187 const int& thePivotNode,
0188 const BRepMesh_Vertex& thePivotVertex,
0189 const gp_Vec2d& theRefLinkDir,
0190 const IMeshData::SequenceOfBndB2d& theBoxes,
0191 const IMeshData::SequenceOfInteger& thePolygon,
0192 const Handle(IMeshData::MapOfInteger)& theSkipped,
0193 const bool& isSkipLeprous,
0194 IMeshData::MapOfInteger& theLeprousLinks,
0195 IMeshData::MapOfInteger& theDeadLinks,
0196 int& theNextPivotNode,
0197 gp_Vec2d& theNextLinkDir,
0198 Bnd_B2d& theNextLinkBndBox);
0199
0200
0201
0202 bool checkIntersection(const BRepMesh_Edge& theLink,
0203 const IMeshData::SequenceOfInteger& thePolygon,
0204 const IMeshData::SequenceOfBndB2d& thePolyBoxes,
0205 const bool isConsiderEndPointTouch,
0206 const bool isConsiderPointOnEdge,
0207 const bool isSkipLastEdge,
0208 Bnd_B2d& theLinkBndBox) const;
0209
0210
0211
0212
0213 void meshPolygon(IMeshData::SequenceOfInteger& thePolygon,
0214 IMeshData::SequenceOfBndB2d& thePolyBoxes,
0215 Handle(IMeshData::MapOfInteger) theSkipped = nullptr);
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227 void decomposeSimplePolygon(IMeshData::SequenceOfInteger& thePolygon,
0228 IMeshData::SequenceOfBndB2d& thePolyBoxes,
0229 IMeshData::SequenceOfInteger& thePolygonCut,
0230 IMeshData::SequenceOfBndB2d& thePolyBoxesCut);
0231
0232
0233 bool meshElementaryPolygon(const IMeshData::SequenceOfInteger& thePolygon);
0234
0235
0236 void createTriangles(const int theVertexIndex, IMeshData::MapOfIntegerInteger& thePoly);
0237
0238
0239 void addTriangle(const int (&theEdgesId)[3],
0240 const bool (&theEdgesOri)[3],
0241 const int (&theNodesId)[3]);
0242
0243
0244
0245 void deleteTriangle(const int theIndex, IMeshData::MapOfIntegerInteger& theLoopEdges);
0246
0247
0248 void getOrientedNodes(const BRepMesh_Edge& theEdge, const bool isForward, int* theNodes) const;
0249
0250
0251
0252 void processLoop(const int theLinkFrom,
0253 const int theLinkTo,
0254 const IMeshData::SequenceOfInteger& thePolygon,
0255 const IMeshData::SequenceOfBndB2d& thePolyBoxes);
0256
0257
0258 int createAndReplacePolygonLink(const int theNodes[],
0259 const gp_Pnt2d thePnts[],
0260 const int theRootIndex,
0261 const ReplaceFlag theReplaceFlag,
0262 IMeshData::SequenceOfInteger& thePolygon,
0263 IMeshData::SequenceOfBndB2d& thePolyBoxes);
0264
0265
0266 void createTrianglesOnNewVertices(IMeshData::VectorOfInteger& theVertexIndices,
0267 const Message_ProgressRange& theRange);
0268
0269
0270 void cleanupMesh();
0271
0272
0273
0274
0275 bool isBoundToFrontier(const int theRefNodeId, const int theRefLinkId);
0276
0277
0278 void cleanupPolygon(const IMeshData::SequenceOfInteger& thePolygon,
0279 const IMeshData::SequenceOfBndB2d& thePolyBoxes);
0280
0281
0282 bool isVertexInsidePolygon(const int& theVertexId,
0283 const IMeshData::VectorOfInteger& thePolygonVertices) const;
0284
0285
0286 void killTrianglesAroundVertex(const int theZombieNodeId,
0287 const IMeshData::VectorOfInteger& thePolyVertices,
0288 const IMeshData::MapOfInteger& thePolyVerticesFindMap,
0289 const IMeshData::SequenceOfInteger& thePolygon,
0290 const IMeshData::SequenceOfBndB2d& thePolyBoxes,
0291 IMeshData::MapOfInteger& theSurvivedLinks,
0292 IMeshData::MapOfIntegerInteger& theLoopEdges,
0293 IMeshData::VectorOfInteger& theVictimNodes);
0294
0295
0296
0297
0298 void killTrianglesOnIntersectingLinks(const int& theLinkToCheckId,
0299 const BRepMesh_Edge& theLinkToCheck,
0300 const int& theEndPoint,
0301 const IMeshData::SequenceOfInteger& thePolygon,
0302 const IMeshData::SequenceOfBndB2d& thePolyBoxes,
0303 IMeshData::MapOfInteger& theSurvivedLinks,
0304 IMeshData::MapOfIntegerInteger& theLoopEdges);
0305
0306
0307 void killLinkTriangles(const int& theLinkId, IMeshData::MapOfIntegerInteger& theLoopEdges);
0308
0309
0310 double calculateDist(const gp_XY theVEdges[3],
0311 const gp_XY thePoints[3],
0312 const BRepMesh_Vertex& theVertex,
0313 double theDistance[3],
0314 double theSqModulus[3],
0315 int& theEdgeOn) const;
0316
0317
0318 BRepMesh_GeomTool::IntFlag intSegSeg(const BRepMesh_Edge& theEdge1,
0319 const BRepMesh_Edge& theEdge2,
0320 const bool isConsiderEndPointTouch,
0321 const bool isConsiderPointOnEdge,
0322 gp_Pnt2d& theIntPnt) const;
0323
0324
0325 double polyArea(const IMeshData::SequenceOfInteger& thePolygon,
0326 const int theStartIndex,
0327 const int theEndIndex) const;
0328
0329
0330 void insertInternalEdges();
0331
0332
0333 bool isSupVertex(const int theVertexIdx) const
0334 {
0335 for (IMeshData::VectorOfInteger::Iterator aIt(mySupVert); aIt.More(); aIt.Next())
0336 {
0337 if (theVertexIdx == aIt.Value())
0338 {
0339 return true;
0340 }
0341 }
0342
0343 return false;
0344 }
0345
0346 private:
0347 occ::handle<BRepMesh_DataStructureOfDelaun> myMeshData;
0348 BRepMesh_CircleTool myCircles;
0349 IMeshData::VectorOfInteger mySupVert;
0350 bool myInitCircles;
0351 BRepMesh_Triangle mySupTrian;
0352 };
0353
0354 #endif