0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / BRepMesh / BRepMesh_FaceDiscret.cxx
CommitLineData
7bd071ed 1// Created on: 2016-04-19
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#include <BRepMesh_FaceDiscret.hxx>
17#include <IMeshData_Model.hxx>
18#include <IMeshData_Face.hxx>
19#include <IMeshData_Wire.hxx>
20#include <IMeshData_Edge.hxx>
21#include <IMeshTools_MeshAlgo.hxx>
22#include <OSD_Parallel.hxx>
23
24//=======================================================================
25// Function: Constructor
26// Purpose :
27//=======================================================================
28BRepMesh_FaceDiscret::BRepMesh_FaceDiscret(
29 const Handle(IMeshTools_MeshAlgoFactory)& theAlgoFactory)
30 : myAlgoFactory(theAlgoFactory)
31{
32}
33
34//=======================================================================
35// Function: Destructor
36// Purpose :
37//=======================================================================
38BRepMesh_FaceDiscret::~BRepMesh_FaceDiscret()
39{
40}
41
42//=======================================================================
43// Function: Perform
44// Purpose :
45//=======================================================================
c2a25d52 46Standard_Boolean BRepMesh_FaceDiscret::performInternal(
7bd071ed 47 const Handle(IMeshData_Model)& theModel,
48 const IMeshTools_Parameters& theParameters)
49{
50 myModel = theModel;
51 myParameters = theParameters;
52 if (myModel.IsNull())
53 {
54 return Standard_False;
55 }
56
57 OSD_Parallel::For(0, myModel->FacesNb(), *this, !(myParameters.InParallel && myModel->FacesNb() > 1));
58
59 myModel.Nullify(); // Do not hold link to model.
60 return Standard_True;
61}
62
63//=======================================================================
64// Function: process
65// Purpose :
66//=======================================================================
67void BRepMesh_FaceDiscret::process(const Standard_Integer theFaceIndex) const
68{
69 const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex);
70 if (aDFace->IsSet(IMeshData_Failure) ||
71 aDFace->IsSet(IMeshData_Reused))
72 {
73 return;
74 }
75
c2a25d52 76 try
77 {
78 OCC_CATCH_SIGNALS
7bd071ed 79
c2a25d52 80 Handle(IMeshTools_MeshAlgo) aMeshingAlgo =
81 myAlgoFactory->GetAlgo(aDFace->GetSurface()->GetType(), myParameters);
82
83 if (aMeshingAlgo.IsNull())
84 {
85 aDFace->SetStatus(IMeshData_Failure);
86 return;
87 }
88
89 aMeshingAlgo->Perform(aDFace, myParameters);
90 }
91 catch (Standard_Failure const&)
7bd071ed 92 {
c2a25d52 93 aDFace->SetStatus (IMeshData_Failure);
7bd071ed 94 }
7bd071ed 95}