1 // Copyright (C) 2012-2015 ALNEOS
2 // Copyright (C) 2016-2024 EDF
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.alneos.com/ or email : contact@alneos.fr
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "GMSHPlugin_GMSH_3D.hxx"
22 #include "GMSHPlugin_Hypothesis_2D.hxx"
24 #include <SMESH_Gen.hxx>
25 #include <SMESH_ControlsDef.hxx>
26 #include <SMESHDS_Mesh.hxx>
27 #include <utilities.h>
33 //=============================================================================
37 //=============================================================================
39 GMSHPlugin_GMSH_3D::GMSHPlugin_GMSH_3D(int hypId, SMESH_Gen* gen)
40 : SMESH_3D_Algo(hypId, gen)
42 MESSAGE("GMSHPlugin_GMSH_3D::GMSHPlugin_GMSH_3D");
44 _shapeType = (1 << TopAbs_SOLID); // 1 bit /shape type
45 _compatibleHypothesis.push_back("GMSH_Parameters_3D");
46 _onlyUnaryInput = false;
48 _supportSubmeshes = true;
50 _requireShape = false; // can work without shape
53 //=============================================================================
57 //=============================================================================
59 GMSHPlugin_GMSH_3D::~GMSHPlugin_GMSH_3D()
61 MESSAGE("GMSHPlugin_GMSH_3D::~GMSHPlugin_GMSH_3D");
64 //=============================================================================
68 //=============================================================================
70 bool GMSHPlugin_GMSH_3D::CheckHypothesis
72 const TopoDS_Shape& aShape,
73 SMESH_Hypothesis::Hypothesis_Status& aStatus)
75 MESSAGE("GMSHPlugin_GMSH::CheckHypothesis");
78 const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
79 int nbHyp = hyps.size();
82 aStatus = SMESH_Hypothesis::HYP_OK;
83 return true; // can work with no hypothesis
85 // use only the first hypothesis
86 const SMESHDS_Hypothesis* theHyp = hyps.front();
88 string hypName = theHyp->GetName();
89 if ( find( _compatibleHypothesis.begin(), _compatibleHypothesis.end(),
90 hypName ) != _compatibleHypothesis.end() )
93 aStatus = SMESH_Hypothesis::HYP_OK;
97 aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
100 return aStatus == SMESH_Hypothesis::HYP_OK;
103 //=============================================================================
105 *Here we are going to use the GMSH mesher
107 //=============================================================================
109 bool GMSHPlugin_GMSH_3D::Compute(SMESH_Mesh& aMesh,
110 const TopoDS_Shape& aShape)
112 GMSHPlugin_Mesher mesher(&aMesh, aShape,/*2d=*/false, true);
113 mesher.SetParameters(dynamic_cast<const GMSHPlugin_Hypothesis*>(_hypothesis));
115 return mesher.Compute();
118 #ifdef WITH_SMESH_CANCEL_COMPUTE
119 void GMSHPlugin_GMSH_3D::CancelCompute()
123 //=============================================================================
127 //=============================================================================
129 bool GMSHPlugin_GMSH_3D::Evaluate(SMESH_Mesh& aMesh,
130 const TopoDS_Shape& aShape,
131 MapShapeNbElems& aResMap)
133 std::vector<smIdType> aResVec(SMDSEntity_Last);
134 for(smIdType i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
135 SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
136 aResMap.insert(std::make_pair(sm,aResVec));
137 SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
138 smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Evaluation is not implemented",this));