1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // NETGENPlugin : C++ implementation
24 // File : NETGENPlugin_NETGEN_2D.cxx
25 // Author : Michael Sazonov (OCN)
28 //=============================================================================
30 #include "NETGENPlugin_NETGEN_2D.hxx"
31 #include "NETGENPlugin_Hypothesis_2D.hxx"
32 #include "NETGENPlugin_SimpleHypothesis_2D.hxx"
33 #include "NETGENPlugin_Mesher.hxx"
35 #include <SMESHDS_Mesh.hxx>
36 #include <SMESH_ControlsDef.hxx>
37 #include <SMESH_Gen.hxx>
38 #include <SMESH_Mesh.hxx>
39 #include <StdMeshers_ViscousLayers2D.hxx>
40 #include <utilities.h>
44 #ifdef WITH_SMESH_CANCEL_COMPUTE
48 #include <meshing.hpp>
53 //=============================================================================
57 //=============================================================================
59 NETGENPlugin_NETGEN_2D::NETGENPlugin_NETGEN_2D(int hypId, int studyId,
61 : SMESH_2D_Algo(hypId, studyId, gen)
63 MESSAGE("NETGENPlugin_NETGEN_2D::NETGENPlugin_NETGEN_2D");
65 _shapeType = (1 << TopAbs_FACE); // 1 bit /shape type
66 _compatibleHypothesis.push_back("NETGEN_Parameters_2D");
67 _compatibleHypothesis.push_back("NETGEN_SimpleParameters_2D");
68 _compatibleHypothesis.push_back( StdMeshers_ViscousLayers2D::GetHypType() );
69 _requireDiscreteBoundary = false;
70 _onlyUnaryInput = false;
72 _supportSubmeshes = true;
75 //=============================================================================
79 //=============================================================================
81 NETGENPlugin_NETGEN_2D::~NETGENPlugin_NETGEN_2D()
83 MESSAGE("NETGENPlugin_NETGEN_2D::~NETGENPlugin_NETGEN_2D");
86 //=============================================================================
90 //=============================================================================
92 bool NETGENPlugin_NETGEN_2D::CheckHypothesis (SMESH_Mesh& aMesh,
93 const TopoDS_Shape& aShape,
94 Hypothesis_Status& aStatus)
97 _isViscousLayers2D = false;
100 // can work with no hypothesis
101 aStatus = SMESH_Hypothesis::HYP_OK;
103 const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape, /*skipAux=*/false);
104 list<const SMESHDS_Hypothesis*>::const_iterator h = hyps.begin();
105 for ( ; h != hyps.end(); ++h )
107 const SMESHDS_Hypothesis* theHyp = *h;
108 string hypName = theHyp->GetName();
109 if ( hypName == StdMeshers_ViscousLayers2D::GetHypType() )
110 _isViscousLayers2D = true;
111 else if ( _hypothesis )
112 aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
114 _hypothesis = theHyp;
117 return aStatus == SMESH_Hypothesis::HYP_OK;
120 //=============================================================================
124 //=============================================================================
126 bool NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh& aMesh,
127 const TopoDS_Shape& aShape)
129 netgen::multithread.terminate = 0;
131 NETGENPlugin_Mesher mesher(&aMesh, aShape, /*is3D = */false);
132 mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
133 mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
134 mesher.SetViscousLayers2DAssigned( _isViscousLayers2D );
135 mesher.SetSelfPointer( &_mesher );
136 return mesher.Compute();
139 //=============================================================================
141 * Terminate Compute()
143 //=============================================================================
145 void NETGENPlugin_NETGEN_2D::CancelCompute()
147 SMESH_Algo::CancelCompute();
148 netgen::multithread.terminate = 1;
151 //================================================================================
153 * \brief Return progress of Compute() [0.,1]
155 //================================================================================
157 double NETGENPlugin_NETGEN_2D::GetProgress() const
159 return _mesher ? _mesher->GetProgress(this, &_progressTic, &_progress) : 0;
162 //=============================================================================
166 //=============================================================================
168 bool NETGENPlugin_NETGEN_2D::Evaluate(SMESH_Mesh& aMesh,
169 const TopoDS_Shape& aShape,
170 MapShapeNbElems& aResMap)
173 NETGENPlugin_Mesher mesher(&aMesh, aShape, false);
174 mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
175 mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
176 return mesher.Evaluate(aResMap);