0024699: Visualization - prototype interoperation of TKOpenGl viewer with Direct3D...
[occt.git] / src / BRepMesh / BRepMesh_IncrementalMesh.cxx
CommitLineData
b311480e 1// Created on: 1995-06-20
2// Created by: Stagiaire Alain JOURDAIN
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
9bdafcbe 17#include <BRepMesh_IncrementalMesh.hxx>
7fd59977 18
fc9b36d6 19#include <Precision.hxx>
ceb418e1 20#include <Standard_ErrorHandler.hxx>
fc9b36d6 21
22#include <BRepMesh_FaceChecker.hxx>
23#include <BRepMesh_ShapeTool.hxx>
7fd59977 24#include <BRepMesh_Edge.hxx>
0b97567d 25#include <BRepMesh_PluginMacro.hxx>
7fd59977 26
27#include <Bnd_Box.hxx>
28#include <BRep_Builder.hxx>
29#include <BRep_Tool.hxx>
9bdafcbe 30#include <BRepTools.hxx>
7fd59977 31#include <BRepLib.hxx>
32#include <BRepBndLib.hxx>
33#include <BRepAdaptor_Curve.hxx>
fc9b36d6 34
35#include <Poly_Triangulation.hxx>
36#include <Poly_Polygon3D.hxx>
37#include <Poly_PolygonOnTriangulation.hxx>
38
39#include <TopoDS.hxx>
40#include <TopoDS_Edge.hxx>
41#include <TopoDS_Face.hxx>
42#include <TopoDS_Shape.hxx>
43#include <TopAbs.hxx>
7fd59977 44#include <TopExp.hxx>
45#include <TopExp_Explorer.hxx>
fc9b36d6 46
7fd59977 47#include <TopTools_ListIteratorOfListOfShape.hxx>
48#include <TColgp_Array1OfPnt.hxx>
ceb418e1 49#include <TColgp_Array1OfPnt2d.hxx>
7fd59977 50#include <TColStd_Array1OfReal.hxx>
7fd59977 51#include <TopTools_HArray1OfShape.hxx>
ceb418e1 52#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
fc9b36d6 53
54#include <GCPnts_TangentialDeflection.hxx>
7fd59977 55
7fd59977 56#ifdef HAVE_TBB
0b97567d
K
57 // paralleling using Intel TBB
58 #include <tbb/parallel_for_each.h>
7fd59977 59#endif
60
0b97567d
K
61namespace
62{
63 //! Default flag to control parallelization for BRepMesh_IncrementalMesh
64 //! tool returned for Mesh Factory
65 static Standard_Boolean IS_IN_PARALLEL = Standard_False;
66};
67
9bdafcbe 68IMPLEMENT_STANDARD_HANDLE (BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot)
69IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot)
70
71//=======================================================================
fc9b36d6 72//function : Default constructor
9bdafcbe 73//purpose :
74//=======================================================================
fc9b36d6 75BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
0b97567d 76: myRelative (Standard_False),
9bdafcbe 77 myInParallel (Standard_False)
7fd59977 78{
7fd59977 79}
80
81//=======================================================================
fc9b36d6 82//function : Constructor
7fd59977 83//purpose :
84//=======================================================================
fc9b36d6 85BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(
86 const TopoDS_Shape& theShape,
14434f3e 87 const Standard_Real theLinDeflection,
88 const Standard_Boolean isRelative,
89 const Standard_Real theAngDeflection,
90 const Standard_Boolean isInParallel)
91 : myRelative (isRelative),
92 myInParallel(isInParallel)
7fd59977 93{
ceb418e1 94 myDeflection = theLinDeflection;
95 myAngle = theAngDeflection;
96 myShape = theShape;
97
0b97567d 98 Perform();
7fd59977 99}
100
101//=======================================================================
fc9b36d6 102//function : Destructor
7fd59977 103//purpose :
104//=======================================================================
fc9b36d6 105BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
7fd59977 106{
107}
108
109//=======================================================================
fc9b36d6 110//function : init
7fd59977 111//purpose :
112//=======================================================================
fc9b36d6 113void BRepMesh_IncrementalMesh::init()
7fd59977 114{
fc9b36d6 115 myStatus = 0;
9bdafcbe 116 myModified = Standard_False;
7fd59977 117
fc9b36d6 118 myEdgeDeflection.Clear();
fc9b36d6 119 myFaces.clear();
7fd59977 120
fc9b36d6 121 setDone();
9bdafcbe 122
123 if (!isCorrectPolyData())
124 BRepTools::Clean(myShape);
125
7fd59977 126 Bnd_Box aBox;
fc9b36d6 127 BRepBndLib::Add(myShape, aBox, Standard_False);
128
129 if (aBox.IsVoid())
130 {
131 // Nothing to mesh.
ceb418e1 132 myMesh.Nullify();
fc9b36d6 133 return;
8e3006e4 134 }
fc9b36d6 135
136 BRepMesh_ShapeTool::BoxMaxDimension(aBox, myMaxShapeSize);
fc9b36d6 137
ceb418e1 138 myMesh = new BRepMesh_FastDiscret(myDeflection, myAngle, aBox,
fc9b36d6 139 Standard_True, Standard_True, myRelative, Standard_True, myInParallel);
ceb418e1 140
141 myMesh->InitSharedFaces(myShape);
7fd59977 142}
143
8e3006e4 144//=======================================================================
fc9b36d6 145//function : isCorrectPolyData
8e3006e4
O
146//purpose :
147//=======================================================================
fc9b36d6 148Standard_Boolean BRepMesh_IncrementalMesh::isCorrectPolyData()
8e3006e4 149{
fc9b36d6 150 collectFaces();
151
152 BRepMesh_FaceChecker aFaceChecker(myInParallel);
153
154#ifdef HAVE_TBB
155 if (myInParallel)
156 {
157 // check faces in parallel threads using TBB
158 tbb::parallel_for_each(myFaces.begin(), myFaces.end(), aFaceChecker);
159 }
160 else
161 {
162#endif
163 std::vector<TopoDS_Face>::iterator aFaceIt = myFaces.begin();
164 for (; aFaceIt != myFaces.end(); aFaceIt++)
165 aFaceChecker(*aFaceIt);
166#ifdef HAVE_TBB
167 }
168#endif
169
170 return aFaceChecker.IsValid();
8e3006e4 171}
7fd59977 172
173//=======================================================================
9bdafcbe 174//function : collectFaces
175//purpose :
176//=======================================================================
177void BRepMesh_IncrementalMesh::collectFaces()
178{
179 TopTools_ListOfShape aFaceList;
180 BRepLib::ReverseSortFaces(myShape, aFaceList);
181 TopTools_MapOfShape aFaceMap;
182 myFaces.reserve(aFaceList.Extent());
183
184 // make array of faces suitable for processing (excluding faces without surface)
185 TopLoc_Location aDummyLoc;
186 const TopLoc_Location aEmptyLoc;
187 TopTools_ListIteratorOfListOfShape aFaceIter(aFaceList);
188 for (; aFaceIter.More(); aFaceIter.Next())
189 {
190 TopoDS_Shape aFaceNoLoc = aFaceIter.Value();
191 aFaceNoLoc.Location(aEmptyLoc);
192 if (!aFaceMap.Add (aFaceNoLoc))
193 continue; // already processed
194
195 TopoDS_Face aFace = TopoDS::Face(aFaceIter.Value());
196 const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(aFace, aDummyLoc);
197 if (aSurf.IsNull())
198 continue;
199
200 myFaces.push_back(aFace);
201 }
202}
203
204//=======================================================================
fc9b36d6 205//function : Perform
206//purpose :
7fd59977 207//=======================================================================
fc9b36d6 208void BRepMesh_IncrementalMesh::Perform()
7fd59977 209{
fc9b36d6 210 init();
7fd59977 211
ceb418e1 212 if (myMesh.IsNull())
7fd59977 213 return;
0d36f7e4 214
fc9b36d6 215 update();
216}
217
218//=======================================================================
219//function : update()
220//purpose :
221//=======================================================================
222void BRepMesh_IncrementalMesh::update()
223{
224 // Update edges data
225 TopExp_Explorer aExplorer(myShape, TopAbs_EDGE);
226 for (; aExplorer.More(); aExplorer.Next())
227 {
228 const TopoDS_Edge& aEdge = TopoDS::Edge(aExplorer.Current());
229 if(!BRep_Tool::IsGeometric(aEdge))
230 continue;
231
232 update(aEdge);
7fd59977 233 }
234
fc9b36d6 235 // Update faces data
9bdafcbe 236 std::vector<TopoDS_Face>::iterator aFaceIt(myFaces.begin());
237 for (; aFaceIt != myFaces.end(); aFaceIt++)
fc9b36d6 238 update(*aFaceIt);
7fd59977 239
fc9b36d6 240 // Mesh faces
241#ifdef HAVE_TBB
0b97567d
K
242 if (myInParallel)
243 {
ceb418e1 244 tbb::parallel_for_each(myFaces.begin(), myFaces.end(), *myMesh);
0b97567d 245 }
7fd59977 246 else
0b97567d 247 {
fc9b36d6 248#endif
249 for (aFaceIt = myFaces.begin(); aFaceIt != myFaces.end(); aFaceIt++)
ceb418e1 250 myMesh->Process(*aFaceIt);
fc9b36d6 251#ifdef HAVE_TBB
0b97567d 252 }
fc9b36d6 253#endif
7fd59977 254
ceb418e1 255 commit();
fc9b36d6 256}
7fd59977 257
fc9b36d6 258//=======================================================================
259//function : discretizeFreeEdges
260//purpose :
261//=======================================================================
262void BRepMesh_IncrementalMesh::discretizeFreeEdges()
263{
264 TopExp_Explorer aExplorer(myShape ,TopAbs_EDGE, TopAbs_FACE);
265 for (; aExplorer.More(); aExplorer.Next())
266 {
267 const TopoDS_Edge& aEdge = TopoDS::Edge(aExplorer.Current());
268 if(!BRep_Tool::IsGeometric(aEdge))
7fd59977 269 continue;
7fd59977 270
fc9b36d6 271 TopLoc_Location aLoc;
272 Standard_Real aEdgeDeflection = edgeDeflection(aEdge);
273 Handle(Poly_Polygon3D) aPoly3D = BRep_Tool::Polygon3D(aEdge, aLoc);
274 if (!aPoly3D.IsNull() && aPoly3D->Deflection() < 1.1 * aEdgeDeflection)
275 continue;
276
277 BRepAdaptor_Curve aCurve(aEdge);
278 GCPnts_TangentialDeflection aDiscret(aCurve, aCurve.FirstParameter(),
279 aCurve.LastParameter(), myAngle, aEdgeDeflection, 2);
280
281 Standard_Integer aNodesNb = aDiscret.NbPoints();
282 TColgp_Array1OfPnt aNodes (1, aNodesNb);
283 TColStd_Array1OfReal aUVNodes(1, aNodesNb);
284 for (Standard_Integer i = 1; i <= aNodesNb; ++i)
285 {
286 aNodes (i) = aDiscret.Value(i);
287 aUVNodes(i) = aDiscret.Parameter(i);
7fd59977 288 }
fc9b36d6 289
290 aPoly3D = new Poly_Polygon3D(aNodes, aUVNodes);
291 aPoly3D->Deflection(myDeflection);
7fd59977 292
fc9b36d6 293 BRep_Builder aBuilder;
294 aBuilder.UpdateEdge(aEdge, aPoly3D);
7fd59977 295 }
0b97567d
K
296}
297
7fd59977 298//=======================================================================
fc9b36d6 299//function : edgeDeflection
300//purpose :
7fd59977 301//=======================================================================
fc9b36d6 302Standard_Real BRepMesh_IncrementalMesh::edgeDeflection(
303 const TopoDS_Edge& theEdge)
7fd59977 304{
fc9b36d6 305 if (myEdgeDeflection.IsBound(theEdge))
306 return myEdgeDeflection(theEdge);
7fd59977 307
fc9b36d6 308 Standard_Real aEdgeDeflection;
309 if (myRelative)
310 {
311 Standard_Real aScale;
312 aEdgeDeflection = BRepMesh_ShapeTool::RelativeEdgeDeflection(theEdge,
313 myDeflection, myMaxShapeSize, aScale);
314 }
315 else
316 aEdgeDeflection = myDeflection;
317
318 myEdgeDeflection.Bind(theEdge, aEdgeDeflection);
319 return aEdgeDeflection;
7fd59977 320}
321
fc9b36d6 322//=======================================================================
323//function : faceDeflection
324//purpose :
325//=======================================================================
326Standard_Real BRepMesh_IncrementalMesh::faceDeflection(
327 const TopoDS_Face& theFace)
328{
329 if (!myRelative)
330 return myDeflection;
331
332 Standard_Integer aEdgesNb = 0;
333 Standard_Real aFaceDeflection = 0.;
334
335 TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE);
336 for (; aEdgeIt.More(); aEdgeIt.Next(), ++aEdgesNb)
337 {
338 const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
339 aFaceDeflection += edgeDeflection(aEdge);
340 }
341
342 return (aEdgesNb == 0) ? myDeflection : (aFaceDeflection / aEdgesNb);
343}
7fd59977 344
345//=======================================================================
fc9b36d6 346//function : update(edge)
347//purpose :
7fd59977 348//=======================================================================
fc9b36d6 349void BRepMesh_IncrementalMesh::update(const TopoDS_Edge& theEdge)
7fd59977 350{
fc9b36d6 351 Standard_Integer aPolyIndex = 1;
352 Standard_Real aEdgeDeflection = edgeDeflection(theEdge);
353 Handle(Poly_PolygonOnTriangulation) aPolygon;
354 do
355 {
356 TopLoc_Location aLoc;
357 Handle(Poly_Triangulation) aTriangulation;
358 BRep_Tool::PolygonOnTriangulation(theEdge, aPolygon,
359 aTriangulation, aLoc, aPolyIndex++);
360
361 if (!aTriangulation.IsNull() && !aPolygon.IsNull())
362 {
ceb418e1 363 if (aPolygon->Deflection() < 1.1 * aEdgeDeflection &&
364 aPolygon->HasParameters())
365 {
fc9b36d6 366 continue;
ceb418e1 367 }
fc9b36d6 368
369 myModified = Standard_True;
370 BRepMesh_ShapeTool::NullifyEdge(theEdge, aTriangulation, aLoc);
7fd59977 371 }
fc9b36d6 372
373 if (!myEmptyEdges.IsBound(theEdge))
848fa7e3 374 myEmptyEdges.Bind(theEdge, BRepMesh::MapOfTriangulation());
fc9b36d6 375
ceb418e1 376 if (!aTriangulation.IsNull())
377 myEmptyEdges(theEdge).Add(aTriangulation);
7fd59977 378 }
fc9b36d6 379 while (!aPolygon.IsNull());
380}
7fd59977 381
fc9b36d6 382//=======================================================================
383//function : isToBeMeshed
384//purpose :
385//=======================================================================
386Standard_Boolean BRepMesh_IncrementalMesh::toBeMeshed(
387 const TopoDS_Face& theFace,
388 const Standard_Boolean isWithCheck)
389{
390 TopLoc_Location aLoc;
391 Handle(Poly_Triangulation) aTriangulation =
392 BRep_Tool::Triangulation(theFace, aLoc);
393
394 if (aTriangulation.IsNull())
395 return Standard_True;
396
397 if (isWithCheck)
ab58a62b 398 {
fc9b36d6 399 Standard_Real aFaceDeflection = faceDeflection(theFace);
400 if (aTriangulation->Deflection() < 1.1 * aFaceDeflection)
ab58a62b 401 {
fc9b36d6 402 Standard_Boolean isEdgesConsistent = Standard_True;
403 TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE);
404 for (; aEdgeIt.More() && isEdgesConsistent; aEdgeIt.Next())
ab58a62b 405 {
fc9b36d6 406 const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
407 if (!myEmptyEdges.IsBound(aEdge))
408 continue;
409
848fa7e3 410 BRepMesh::MapOfTriangulation& aTriMap = myEmptyEdges(aEdge);
ceb418e1 411 isEdgesConsistent &= !aTriMap.IsEmpty() && !aTriMap.Contains(aTriangulation);
7fd59977 412 }
fc9b36d6 413
414 if (isEdgesConsistent)
415 return Standard_False;
ab58a62b 416 }
7fd59977 417 }
418
fc9b36d6 419 // Nullify edges
420 TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE);
421 for (; aEdgeIt.More(); aEdgeIt.Next())
422 {
423 const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
424 BRepMesh_ShapeTool::NullifyEdge(aEdge, aTriangulation, aLoc);
425 }
7fd59977 426
fc9b36d6 427 BRepMesh_ShapeTool::NullifyFace(theFace);
428 return Standard_True;
429}
7fd59977 430
fc9b36d6 431//=======================================================================
432//function : update(face)
433//purpose :
434//=======================================================================
435void BRepMesh_IncrementalMesh::update(const TopoDS_Face& theFace)
436{
437 if (!toBeMeshed(theFace, Standard_True))
438 return;
439
440 myModified = Standard_True;
ceb418e1 441 Standard_Integer aStatus = myMesh->Add(theFace);
fc9b36d6 442
ceb418e1 443 myStatus |= aStatus;
fc9b36d6 444 if (aStatus != BRepMesh_ReMesh)
445 return;
446
848fa7e3 447 BRepMesh::MapOfShape aUsedFaces;
fc9b36d6 448 aUsedFaces.Add(theFace);
449
ceb418e1 450 const TopTools_IndexedDataMapOfShapeListOfShape& aMapOfSharedFaces =
451 myMesh->SharedFaces();
452
fc9b36d6 453 TopExp_Explorer aEdgeIt(theFace, TopAbs_EDGE);
454 for (; aEdgeIt.More(); aEdgeIt.Next())
455 {
456 const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Current());
ceb418e1 457 if (aMapOfSharedFaces.FindIndex(aEdge) == 0)
fc9b36d6 458 continue;
459
ceb418e1 460 const TopTools_ListOfShape& aSharedFaces = aMapOfSharedFaces.FindFromKey(aEdge);
fc9b36d6 461 TopTools_ListIteratorOfListOfShape aSharedFaceIt(aSharedFaces);
462 for (; aSharedFaceIt.More(); aSharedFaceIt.Next())
463 {
464 const TopoDS_Face& aFace = TopoDS::Face(aSharedFaceIt.Value());
465 if (aUsedFaces.Contains(aFace))
466 continue;
467
468 aUsedFaces.Add(aFace);
469 toBeMeshed(aFace, Standard_False);
470
ceb418e1 471 myStatus |= myMesh->Add(aFace);
472 }
473 }
474}
475
476//=======================================================================
477//function : commit
478//purpose :
479//=======================================================================
480void BRepMesh_IncrementalMesh::commit()
481{
482 std::vector<TopoDS_Face>::iterator aFaceIt(myFaces.begin());
483 for (; aFaceIt != myFaces.end(); aFaceIt++)
484 commitFace(*aFaceIt);
485
486 discretizeFreeEdges();
487}
488
489//=======================================================================
490//function : commitFace
491//purpose :
492//=======================================================================
493void BRepMesh_IncrementalMesh::commitFace(const TopoDS_Face& theFace)
494{
495 TopoDS_Face aFace = theFace;
496 aFace.Orientation(TopAbs_FORWARD);
497
498 Handle(BRepMesh_FaceAttribute) aFaceAttribute;
499 if (!myMesh->GetFaceAttribute(aFace, aFaceAttribute))
500 return;
501
502 BRepMesh_ShapeTool::NullifyFace(aFace);
503
504 if (!aFaceAttribute->IsValid())
505 {
506 myStatus |= aFaceAttribute->GetStatus();
507 return;
508 }
509
510 TopLoc_Location aLoc = aFace.Location();
511 Handle(Poly_Triangulation) aOldTriangulation = BRep_Tool::Triangulation(aFace, aLoc);
512
513 try
514 {
515 OCC_CATCH_SIGNALS
516
517 Handle(BRepMesh_DataStructureOfDelaun)& aStructure = aFaceAttribute->ChangeStructure();
848fa7e3 518 const BRepMesh::MapOfInteger& aTriangles = aStructure->ElementsOfDomain();
ceb418e1 519 if (aTriangles.IsEmpty())
520 return;
521
848fa7e3 522 BRepMesh::HIMapOfInteger& aVetrexEdgeMap = aFaceAttribute->ChangeVertexEdgeMap();
ceb418e1 523
524 // Store triangles
525 Standard_Integer aVerticesNb = aVetrexEdgeMap->Extent();
526 Standard_Integer aTrianglesNb = aTriangles.Extent();
527 Handle(Poly_Triangulation) aNewTriangulation =
528 new Poly_Triangulation(aVerticesNb, aTrianglesNb, Standard_True);
529
530 Poly_Array1OfTriangle& aPolyTrianges = aNewTriangulation->ChangeTriangles();
531
532 Standard_Integer aTriangeId = 1;
848fa7e3 533 BRepMesh::MapOfInteger::Iterator aTriIt(aTriangles);
ceb418e1 534 for (; aTriIt.More(); aTriIt.Next())
535 {
536 const BRepMesh_Triangle& aCurElem = aStructure->GetElement(aTriIt.Key());
537
538 Standard_Integer aNode[3];
539 aStructure->ElementNodes(aCurElem, aNode);
540
541 Standard_Integer aNodeId[3];
542 for (Standard_Integer i = 0; i < 3; ++i)
543 aNodeId[i] = aVetrexEdgeMap->FindIndex(aNode[i]);
544
545 aPolyTrianges(aTriangeId++).Set(aNodeId[0], aNodeId[1], aNodeId[2]);
546 }
547
548 // Store mesh nodes
549 TColgp_Array1OfPnt& aNodes = aNewTriangulation->ChangeNodes();
550 TColgp_Array1OfPnt2d& aNodes2d = aNewTriangulation->ChangeUVNodes();
551
552 for (Standard_Integer i = 1; i <= aVerticesNb; ++i)
553 {
554 Standard_Integer aVertexId = aVetrexEdgeMap->FindKey(i);
555 const BRepMesh_Vertex& aVertex = aStructure->GetNode(aVertexId);
556 const gp_Pnt& aPoint = aFaceAttribute->GetPoint(aVertex);
557
558 aNodes(i) = aPoint;
559 aNodes2d(i) = aVertex.Coord();
7fd59977 560 }
ceb418e1 561
562 aNewTriangulation->Deflection(aFaceAttribute->GetDefFace());
563 BRepMesh_ShapeTool::AddInFace(aFace, aNewTriangulation);
564
565 // Store discretization of edges
848fa7e3 566 BRepMesh::HDMapOfShapePairOfPolygon& aInternalEdges = aFaceAttribute->ChangeInternalEdges();
567 BRepMesh::DMapOfShapePairOfPolygon::Iterator aEdgeIt(*aInternalEdges);
ceb418e1 568 for (; aEdgeIt.More(); aEdgeIt.Next())
569 {
570 const TopoDS_Edge& aEdge = TopoDS::Edge(aEdgeIt.Key());
571 const BRepMesh_PairOfPolygon& aPolyPair = aEdgeIt.Value();
572 const Handle(Poly_PolygonOnTriangulation)& aPolygon1 = aPolyPair.First();
573 const Handle(Poly_PolygonOnTriangulation)& aPolygon2 = aPolyPair.Last();
574
575 BRepMesh_ShapeTool::NullifyEdge(aEdge, aOldTriangulation, aLoc);
576 if (aPolygon1 == aPolygon2)
577 BRepMesh_ShapeTool::UpdateEdge(aEdge, aPolygon1, aNewTriangulation, aLoc);
578 else
579 BRepMesh_ShapeTool::UpdateEdge(aEdge, aPolygon1, aPolygon2, aNewTriangulation, aLoc);
580 }
581 }
582 catch (Standard_Failure)
583 {
584 myStatus |= BRepMesh_Failure;
7fd59977 585 }
586}
0b97567d
K
587
588//=======================================================================
589//function : Discret
590//purpose :
591//=======================================================================
fc9b36d6 592Standard_Integer BRepMesh_IncrementalMesh::Discret(
593 const TopoDS_Shape& theShape,
594 const Standard_Real theDeflection,
595 const Standard_Real theAngle,
ceb418e1 596 BRepMesh_DiscretRoot* &theAlgo)
0b97567d
K
597{
598 BRepMesh_IncrementalMesh* anAlgo = new BRepMesh_IncrementalMesh();
fc9b36d6 599 anAlgo->SetDeflection(theDeflection);
600 anAlgo->SetAngle (theAngle);
601 anAlgo->SetShape (theShape);
602 anAlgo->SetParallel (IS_IN_PARALLEL);
0b97567d
K
603 theAlgo = anAlgo;
604 return 0; // no error
605}
606
607//=======================================================================
608//function : IsParallelDefault
609//purpose :
610//=======================================================================
611Standard_Boolean BRepMesh_IncrementalMesh::IsParallelDefault()
612{
613#ifdef HAVE_TBB
614 return IS_IN_PARALLEL;
615#else
616 // no alternative parallelization yet - flag has no meaning
617 return Standard_False;
618#endif
619}
620
621//=======================================================================
622//function : Discret
623//purpose :
624//=======================================================================
fc9b36d6 625void BRepMesh_IncrementalMesh::SetParallelDefault(
626 const Standard_Boolean theInParallel)
0b97567d
K
627{
628 IS_IN_PARALLEL = theInParallel;
629}
630
631//! Export Mesh Plugin entry function
632DISCRETPLUGIN(BRepMesh_IncrementalMesh)