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_2D.cxx
23 // Author : Michael Sazonov (OCN)
27 //=============================================================================
30 #include "NETGENPlugin_NETGEN_2D.hxx"
31 #include "NETGENPlugin_Hypothesis_2D.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_2D::NETGENPlugin_NETGEN_2D(int hypId, int studyId,
50 : SMESH_2D_Algo(hypId, studyId, gen)
52 MESSAGE("NETGENPlugin_NETGEN_2D::NETGENPlugin_NETGEN_2D");
54 _shapeType = (1 << TopAbs_FACE); // 1 bit /shape type
55 _compatibleHypothesis.push_back("NETGEN_Parameters_2D");
56 _requireDescretBoundary = false;
57 _onlyUnaryInput = false;
61 //=============================================================================
65 //=============================================================================
67 NETGENPlugin_NETGEN_2D::~NETGENPlugin_NETGEN_2D()
69 MESSAGE("NETGENPlugin_NETGEN_2D::~NETGENPlugin_NETGEN_2D");
72 //=============================================================================
76 //=============================================================================
78 bool NETGENPlugin_NETGEN_2D::CheckHypothesis
80 const TopoDS_Shape& aShape,
81 SMESH_Hypothesis::Hypothesis_Status& aStatus)
85 list<const SMESHDS_Hypothesis*>::const_iterator itl;
86 const SMESHDS_Hypothesis* theHyp;
88 const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
89 int nbHyp = hyps.size();
92 aStatus = SMESH_Hypothesis::HYP_OK;
93 return true; // can work with no hypothesis
97 theHyp = (*itl); // use only the first hypothesis
99 string hypName = theHyp->GetName();
101 if (hypName == "NETGEN_Parameters_2D")
103 _hypothesis = static_cast<const NETGENPlugin_Hypothesis_2D*> (theHyp);
105 aStatus = SMESH_Hypothesis::HYP_OK;
108 aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
110 return aStatus == SMESH_Hypothesis::HYP_OK;
113 //=============================================================================
117 //=============================================================================
119 bool NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh& aMesh,
120 const TopoDS_Shape& aShape)
122 SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
124 NETGENPlugin_Mesher mesher(meshDS, aShape, false);
125 mesher.SetParameters(_hypothesis);
126 return mesher.Compute();
129 //=============================================================================
133 //=============================================================================
135 ostream & NETGENPlugin_NETGEN_2D::SaveTo(ostream & save)
140 //=============================================================================
144 //=============================================================================
146 istream & NETGENPlugin_NETGEN_2D::LoadFrom(istream & load)
151 //=============================================================================
155 //=============================================================================
157 ostream & operator << (ostream & save, NETGENPlugin_NETGEN_2D & hyp)
159 return hyp.SaveTo( save );
162 //=============================================================================
166 //=============================================================================
168 istream & operator >> (istream & load, NETGENPlugin_NETGEN_2D & hyp)
170 return hyp.LoadFrom( load );