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_SimpleHypothesis_3D.cxx
23 // Author : Edward AGAPOV
25 //=============================================================================
27 #include "NETGENPlugin_SimpleHypothesis_3D.hxx"
28 #include "NETGENPlugin_Hypothesis.hxx"
30 #include <SMESH_ControlsDef.hxx>
31 #include <SMESH_Mesh.hxx>
32 #include <SMESH_subMesh.hxx>
34 #include <TopExp_Explorer.hxx>
36 #include <utilities.h>
40 //=============================================================================
44 //=============================================================================
45 NETGENPlugin_SimpleHypothesis_3D::NETGENPlugin_SimpleHypothesis_3D (int hypId,
48 : NETGENPlugin_SimpleHypothesis_2D(hypId, studyId, gen),
51 _name = "NETGEN_SimpleParameters_3D";
55 //=============================================================================
59 //=============================================================================
60 void NETGENPlugin_SimpleHypothesis_3D::LengthFromFaces()
62 if (_volume > DBL_MIN )
65 NotifySubMeshesHypothesisModification();
69 //=============================================================================
73 //=============================================================================
74 void NETGENPlugin_SimpleHypothesis_3D::SetMaxElementVolume(double value)
76 if ( value < DBL_MIN )
81 NotifySubMeshesHypothesisModification();
85 //=============================================================================
89 //=============================================================================
90 ostream & NETGENPlugin_SimpleHypothesis_3D::SaveTo(ostream & save)
92 NETGENPlugin_SimpleHypothesis_2D::SaveTo( save );
93 save << " " << _volume;
98 //=============================================================================
102 //=============================================================================
103 istream & NETGENPlugin_SimpleHypothesis_3D::LoadFrom(istream & load)
105 NETGENPlugin_SimpleHypothesis_2D::LoadFrom(load);
110 isOK = (load >> val);
114 load.clear(ios::badbit | load.rdstate());
119 //================================================================================
121 * \brief Does nothing
122 * \param theMesh - the built mesh
123 * \param theShape - the geometry of interest
124 * \retval bool - always false
126 //================================================================================
127 bool NETGENPlugin_SimpleHypothesis_3D::SetParametersByMesh(const SMESH_Mesh* theMesh,
128 const TopoDS_Shape& theShape)
130 if ( NETGENPlugin_SimpleHypothesis_2D::SetParametersByMesh(theMesh, theShape) )
132 // Find out max volume
134 SMESH::Controls::Volume volControl;
135 volControl.SetMesh( ((SMESH_Mesh*)theMesh)->GetMeshDS() );
136 const int nbElemToCheck = 100;
137 for ( TopExp_Explorer exp( theShape, TopAbs_SOLID ); exp.More(); exp.Next() ) {
138 SMESH_subMesh* sm = theMesh->GetSubMeshContaining( exp.Current() );
139 if ( sm && !sm->IsEmpty() ) {
140 SMDS_ElemIteratorPtr fIt = sm->GetSubMeshDS()->GetElements();
141 int nbCheckedElems = 0;
142 while ( fIt->more() && nbCheckedElems++ < nbElemToCheck ) {
143 const SMDS_MeshElement* elem = fIt->next();
144 _volume = max( _volume, volControl.GetValue( elem->GetID() ));
148 return int( _volume );