1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // NETGENPlugin : C++ implementation
21 // File : NETGENPlugin_SimpleHypothesis_3D.cxx
22 // Author : Edward AGAPOV
24 //=============================================================================
26 #include "NETGENPlugin_SimpleHypothesis_3D.hxx"
27 #include "NETGENPlugin_Hypothesis.hxx"
29 #include <SMESH_ControlsDef.hxx>
30 #include <SMESH_Mesh.hxx>
31 #include <SMESH_subMesh.hxx>
33 #include <TopExp_Explorer.hxx>
35 #include <utilities.h>
39 //=============================================================================
43 //=============================================================================
44 NETGENPlugin_SimpleHypothesis_3D::NETGENPlugin_SimpleHypothesis_3D (int hypId,
47 : NETGENPlugin_SimpleHypothesis_2D(hypId, studyId, gen),
50 _name = "NETGEN_SimpleParameters_3D";
54 //=============================================================================
58 //=============================================================================
59 void NETGENPlugin_SimpleHypothesis_3D::LengthFromFaces()
61 if (_volume > DBL_MIN )
64 NotifySubMeshesHypothesisModification();
68 //=============================================================================
72 //=============================================================================
73 void NETGENPlugin_SimpleHypothesis_3D::SetMaxElementVolume(double value)
75 if ( value < DBL_MIN )
80 NotifySubMeshesHypothesisModification();
84 //=============================================================================
88 //=============================================================================
89 ostream & NETGENPlugin_SimpleHypothesis_3D::SaveTo(ostream & save)
91 NETGENPlugin_SimpleHypothesis_2D::SaveTo( save );
92 save << " " << _volume;
97 //=============================================================================
101 //=============================================================================
102 istream & NETGENPlugin_SimpleHypothesis_3D::LoadFrom(istream & load)
104 NETGENPlugin_SimpleHypothesis_2D::LoadFrom(load);
109 isOK = (load >> val);
113 load.clear(ios::badbit | load.rdstate());
118 //================================================================================
120 * \brief Does nothing
121 * \param theMesh - the built mesh
122 * \param theShape - the geometry of interest
123 * \retval bool - always false
125 //================================================================================
126 bool NETGENPlugin_SimpleHypothesis_3D::SetParametersByMesh(const SMESH_Mesh* theMesh,
127 const TopoDS_Shape& theShape)
129 if ( NETGENPlugin_SimpleHypothesis_2D::SetParametersByMesh(theMesh, theShape) )
131 // Find out max volume
133 SMESH::Controls::Volume volControl;
134 volControl.SetMesh( ((SMESH_Mesh*)theMesh)->GetMeshDS() );
135 const int nbElemToCheck = 100;
136 for ( TopExp_Explorer exp( theShape, TopAbs_SOLID ); exp.More(); exp.Next() ) {
137 SMESH_subMesh* sm = theMesh->GetSubMeshContaining( exp.Current() );
138 if ( sm && !sm->IsEmpty() ) {
139 SMDS_ElemIteratorPtr fIt = sm->GetSubMeshDS()->GetElements();
140 int nbCheckedElems = 0;
141 while ( fIt->more() && nbCheckedElems++ < nbElemToCheck ) {
142 const SMDS_MeshElement* elem = fIt->next();
143 _volume = max( _volume, volControl.GetValue( elem->GetID() ));
147 return int( _volume );