1 // Copyright (C) 2007-2008 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
22 // NETGENPlugin : C++ implementation
23 // File : NETGENPlugin_SimpleHypothesis_3D.cxx
24 // Author : Edward AGAPOV
26 //=============================================================================
28 #include "NETGENPlugin_SimpleHypothesis_3D.hxx"
29 #include "NETGENPlugin_Hypothesis.hxx"
31 #include <SMESH_ControlsDef.hxx>
32 #include <SMESH_Mesh.hxx>
33 #include <SMESH_subMesh.hxx>
35 #include <TopExp_Explorer.hxx>
37 #include <utilities.h>
41 //=============================================================================
45 //=============================================================================
46 NETGENPlugin_SimpleHypothesis_3D::NETGENPlugin_SimpleHypothesis_3D (int hypId,
49 : NETGENPlugin_SimpleHypothesis_2D(hypId, studyId, gen),
52 _name = "NETGEN_SimpleParameters_3D";
56 //=============================================================================
60 //=============================================================================
61 void NETGENPlugin_SimpleHypothesis_3D::LengthFromFaces()
63 if (_volume > DBL_MIN )
66 NotifySubMeshesHypothesisModification();
70 //=============================================================================
74 //=============================================================================
75 void NETGENPlugin_SimpleHypothesis_3D::SetMaxElementVolume(double value)
77 if ( value < DBL_MIN )
82 NotifySubMeshesHypothesisModification();
86 //=============================================================================
90 //=============================================================================
91 ostream & NETGENPlugin_SimpleHypothesis_3D::SaveTo(ostream & save)
93 NETGENPlugin_SimpleHypothesis_2D::SaveTo( save );
94 save << " " << _volume;
99 //=============================================================================
103 //=============================================================================
104 istream & NETGENPlugin_SimpleHypothesis_3D::LoadFrom(istream & load)
106 NETGENPlugin_SimpleHypothesis_2D::LoadFrom(load);
111 isOK = (load >> val);
115 load.clear(ios::badbit | load.rdstate());
120 //================================================================================
122 * \brief Does nothing
123 * \param theMesh - the built mesh
124 * \param theShape - the geometry of interest
125 * \retval bool - always false
127 //================================================================================
128 bool NETGENPlugin_SimpleHypothesis_3D::SetParametersByMesh(const SMESH_Mesh* theMesh,
129 const TopoDS_Shape& theShape)
131 if ( NETGENPlugin_SimpleHypothesis_2D::SetParametersByMesh(theMesh, theShape) )
133 // Find out max volume
135 SMESH::Controls::Volume volControl;
136 volControl.SetMesh( ((SMESH_Mesh*)theMesh)->GetMeshDS() );
137 const int nbElemToCheck = 100;
138 for ( TopExp_Explorer exp( theShape, TopAbs_SOLID ); exp.More(); exp.Next() ) {
139 SMESH_subMesh* sm = theMesh->GetSubMeshContaining( exp.Current() );
140 if ( sm && !sm->IsEmpty() ) {
141 SMDS_ElemIteratorPtr fIt = sm->GetSubMeshDS()->GetElements();
142 int nbCheckedElems = 0;
143 while ( fIt->more() && nbCheckedElems++ < nbElemToCheck ) {
144 const SMDS_MeshElement* elem = fIt->next();
145 _volume = max( _volume, volControl.GetValue( elem->GetID() ));
149 return int( _volume );