1 // Copyright (C) 2007-2012 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 <SMESH_Gen.hxx>
36 #include <SMESH_Mesh.hxx>
37 #include <SMESH_ControlsDef.hxx>
38 #include <SMESHDS_Mesh.hxx>
39 #include <utilities.h>
43 #ifdef WITH_SMESH_CANCEL_COMPUTE
47 #include <meshing.hpp>
52 //=============================================================================
56 //=============================================================================
58 NETGENPlugin_NETGEN_2D::NETGENPlugin_NETGEN_2D(int hypId, int studyId,
60 : SMESH_2D_Algo(hypId, studyId, gen)
62 MESSAGE("NETGENPlugin_NETGEN_2D::NETGENPlugin_NETGEN_2D");
64 _shapeType = (1 << TopAbs_FACE); // 1 bit /shape type
65 _compatibleHypothesis.push_back("NETGEN_Parameters_2D");
66 _compatibleHypothesis.push_back("NETGEN_SimpleParameters_2D");
67 _requireDiscreteBoundary = false;
68 _onlyUnaryInput = false;
70 _supportSubmeshes = true;
73 //=============================================================================
77 //=============================================================================
79 NETGENPlugin_NETGEN_2D::~NETGENPlugin_NETGEN_2D()
81 MESSAGE("NETGENPlugin_NETGEN_2D::~NETGENPlugin_NETGEN_2D");
84 //=============================================================================
88 //=============================================================================
90 bool NETGENPlugin_NETGEN_2D::CheckHypothesis
92 const TopoDS_Shape& aShape,
93 SMESH_Hypothesis::Hypothesis_Status& aStatus)
97 const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
98 int nbHyp = hyps.size();
101 aStatus = SMESH_Hypothesis::HYP_OK;
102 return true; // can work with no hypothesis
104 // use only the first hypothesis
105 const SMESHDS_Hypothesis* theHyp = hyps.front();
107 string hypName = theHyp->GetName();
108 if ( find( _compatibleHypothesis.begin(), _compatibleHypothesis.end(),
109 hypName ) != _compatibleHypothesis.end() )
111 _hypothesis = theHyp;
112 aStatus = SMESH_Hypothesis::HYP_OK;
116 aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
119 return aStatus == SMESH_Hypothesis::HYP_OK;
122 //=============================================================================
126 //=============================================================================
128 bool NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh& aMesh,
129 const TopoDS_Shape& aShape)
131 #ifdef WITH_SMESH_CANCEL_COMPUTE
132 netgen::multithread.terminate = 0;
135 NETGENPlugin_Mesher mesher(&aMesh, aShape, false);
136 mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
137 mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
138 return mesher.Compute();
141 #ifdef WITH_SMESH_CANCEL_COMPUTE
142 void NETGENPlugin_NETGEN_2D::CancelCompute()
144 SMESH_Algo::CancelCompute();
145 netgen::multithread.terminate = 1;
149 //=============================================================================
153 //=============================================================================
155 bool NETGENPlugin_NETGEN_2D::Evaluate(SMESH_Mesh& aMesh,
156 const TopoDS_Shape& aShape,
157 MapShapeNbElems& aResMap)
160 NETGENPlugin_Mesher mesher(&aMesh, aShape, false);
161 mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
162 mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
163 return mesher.Evaluate(aResMap);