1 // NETGENPlugin : C++ implementation
3 // Copyright (C) 2006 OPEN CASCADE, CEA/DEN, EDF R&D
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : NETGENPlugin_NETGEN_2D3D.cxx
23 // Author : Michael Sazonov (OCN)
27 //=============================================================================
30 #include "NETGENPlugin_NETGEN_2D3D.hxx"
31 #include "NETGENPlugin_Hypothesis.hxx"
32 #include "NETGENPlugin_Mesher.hxx"
34 #include <SMESH_Gen.hxx>
35 #include <SMESH_Mesh.hxx>
36 #include <SMESH_ControlsDef.hxx>
37 #include <SMESHDS_Mesh.hxx>
38 #include <utilities.h>
42 //=============================================================================
46 //=============================================================================
48 NETGENPlugin_NETGEN_2D3D::NETGENPlugin_NETGEN_2D3D(int hypId, int studyId,
50 : SMESH_3D_Algo(hypId, studyId, gen)
52 MESSAGE("NETGENPlugin_NETGEN_2D3D::NETGENPlugin_NETGEN_2D3D");
53 _name = "NETGEN_2D3D";
54 _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
55 _compatibleHypothesis.push_back("NETGEN_Parameters");
56 _requireDescretBoundary = false;
57 _onlyUnaryInput = false;
61 //=============================================================================
65 //=============================================================================
67 NETGENPlugin_NETGEN_2D3D::~NETGENPlugin_NETGEN_2D3D()
69 MESSAGE("NETGENPlugin_NETGEN_2D3D::~NETGENPlugin_NETGEN_2D3D");
72 //=============================================================================
76 //=============================================================================
78 bool NETGENPlugin_NETGEN_2D3D::CheckHypothesis
80 const TopoDS_Shape& aShape,
81 SMESH_Hypothesis::Hypothesis_Status& aStatus)
83 MESSAGE("NETGENPlugin_NETGEN_2D3D::CheckHypothesis");
87 list<const SMESHDS_Hypothesis*>::const_iterator itl;
88 const SMESHDS_Hypothesis* theHyp;
90 const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
91 int nbHyp = hyps.size();
94 aStatus = SMESH_Hypothesis::HYP_OK;
95 return true; // can work with no hypothesis
99 theHyp = (*itl); // use only the first hypothesis
101 string hypName = theHyp->GetName();
103 if (hypName == "NETGEN_Parameters")
105 _hypothesis = static_cast<const NETGENPlugin_Hypothesis*> (theHyp);
107 aStatus = SMESH_Hypothesis::HYP_OK;
110 aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
112 return aStatus == SMESH_Hypothesis::HYP_OK;
115 //=============================================================================
117 *Here we are going to use the NETGEN mesher
119 //=============================================================================
121 bool NETGENPlugin_NETGEN_2D3D::Compute(SMESH_Mesh& aMesh,
122 const TopoDS_Shape& aShape)
124 SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
126 NETGENPlugin_Mesher mesher(meshDS, aShape, true);
127 mesher.SetParameters(_hypothesis);
128 return mesher.Compute();
131 //=============================================================================
135 //=============================================================================
137 ostream & NETGENPlugin_NETGEN_2D3D::SaveTo(ostream & save)
142 //=============================================================================
146 //=============================================================================
148 istream & NETGENPlugin_NETGEN_2D3D::LoadFrom(istream & load)
153 //=============================================================================
157 //=============================================================================
159 ostream & operator << (ostream & save, NETGENPlugin_NETGEN_2D3D & hyp)
161 return hyp.SaveTo( save );
164 //=============================================================================
168 //=============================================================================
170 istream & operator >> (istream & load, NETGENPlugin_NETGEN_2D3D & hyp)
172 return hyp.LoadFrom( load );