1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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_2D3D.cxx
25 // Author : Michael Sazonov (OCN)
28 //=============================================================================
30 #include "NETGENPlugin_NETGEN_2D3D.hxx"
31 #include "NETGENPlugin_Hypothesis.hxx"
32 #include "NETGENPlugin_SimpleHypothesis_3D.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_ViscousLayers.hxx>
41 #include <utilities.h>
48 #include <meshing.hpp>
52 //=============================================================================
56 //=============================================================================
58 NETGENPlugin_NETGEN_2D3D::NETGENPlugin_NETGEN_2D3D(int hypId,
60 : SMESH_3D_Algo(hypId, gen)
62 //MESSAGE("NETGENPlugin_NETGEN_2D3D::NETGENPlugin_NETGEN_2D3D");
63 _name = "NETGEN_2D3D";
64 _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
65 _compatibleHypothesis.push_back("NETGEN_Parameters");
66 _compatibleHypothesis.push_back("NETGEN_SimpleParameters_3D");
67 _compatibleHypothesis.push_back( StdMeshers_ViscousLayers::GetHypType() );
68 _requireDiscreteBoundary = false;
69 _onlyUnaryInput = false;
71 _supportSubmeshes = true;
74 //=============================================================================
78 //=============================================================================
80 NETGENPlugin_NETGEN_2D3D::~NETGENPlugin_NETGEN_2D3D()
82 //MESSAGE("NETGENPlugin_NETGEN_2D3D::~NETGENPlugin_NETGEN_2D3D");
85 //=============================================================================
89 //=============================================================================
91 bool NETGENPlugin_NETGEN_2D3D::CheckHypothesis (SMESH_Mesh& aMesh,
92 const TopoDS_Shape& aShape,
93 Hypothesis_Status& aStatus)
96 _viscousLayersHyp = NULL;
99 const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape, /*noAux=*/false);
102 aStatus = SMESH_Hypothesis::HYP_OK;
103 return true; // can work with no hypothesis
106 list<const SMESHDS_Hypothesis*>::const_iterator h = hyps.begin();
107 for ( ; h != hyps.end(); ++h )
109 const SMESHDS_Hypothesis* aHyp = *h;
110 std::string hypName = aHyp->GetName();
112 if ( std::find( _compatibleHypothesis.begin(), _compatibleHypothesis.end(),
113 hypName ) != _compatibleHypothesis.end() )
115 if ( hypName == StdMeshers_ViscousLayers::GetHypType() )
116 _viscousLayersHyp = dynamic_cast<const StdMeshers_ViscousLayers*>( aHyp );
119 aStatus = SMESH_Hypothesis::HYP_OK;
123 aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
128 return aStatus == SMESH_Hypothesis::HYP_OK;
131 //=============================================================================
133 * Here we are going to use the NETGEN mesher
135 //=============================================================================
137 bool NETGENPlugin_NETGEN_2D3D::Compute(SMESH_Mesh& aMesh,
138 const TopoDS_Shape& aShape)
140 netgen::multithread.terminate = 0;
142 NETGENPlugin_Mesher mesher(&aMesh, aShape, true);
143 mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
144 mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_3D*>(_hypothesis));
145 mesher.SetParameters(_viscousLayersHyp);
146 mesher.SetSelfPointer( &_mesher );
147 return mesher.Compute();
150 //=============================================================================
154 //=============================================================================
156 void NETGENPlugin_NETGEN_2D3D::CancelCompute()
158 SMESH_Algo::CancelCompute();
159 netgen::multithread.terminate = 1;
162 //================================================================================
164 * \brief Return progress of Compute() [0.,1]
166 //================================================================================
168 double NETGENPlugin_NETGEN_2D3D::GetProgress() const
170 double & progress = (double &)_progress;
172 progress = _mesher->GetProgress(this, &_progressTic, &_progress);
173 else if ( _progress > 0.001 )
179 //=============================================================================
183 //=============================================================================
185 bool NETGENPlugin_NETGEN_2D3D::Evaluate(SMESH_Mesh& aMesh,
186 const TopoDS_Shape& aShape,
187 MapShapeNbElems& aResMap)
189 NETGENPlugin_Mesher mesher(&aMesh, aShape, true);
190 mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
191 mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
192 return mesher.Evaluate(aResMap);