1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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 <SMDS_Mesh.hxx>
30 #include <SMESHDS_Mesh.hxx>
31 #include <SMESHDS_SubMesh.hxx>
32 #include <SMESH_ControlsDef.hxx>
33 #include <SMESH_Mesh.hxx>
34 #include <SMESH_subMesh.hxx>
36 #include <TopExp_Explorer.hxx>
38 #include <utilities.h>
42 //=============================================================================
46 //=============================================================================
47 NETGENPlugin_SimpleHypothesis_3D::NETGENPlugin_SimpleHypothesis_3D (int hypId,
50 : NETGENPlugin_SimpleHypothesis_2D(hypId, studyId, gen),
53 _name = "NETGEN_SimpleParameters_3D";
57 //=============================================================================
61 //=============================================================================
62 void NETGENPlugin_SimpleHypothesis_3D::LengthFromFaces()
64 if (_volume > DBL_MIN )
67 NotifySubMeshesHypothesisModification();
71 //=============================================================================
75 //=============================================================================
76 void NETGENPlugin_SimpleHypothesis_3D::SetMaxElementVolume(double value)
78 if ( value < DBL_MIN )
83 NotifySubMeshesHypothesisModification();
87 //=============================================================================
91 //=============================================================================
92 ostream & NETGENPlugin_SimpleHypothesis_3D::SaveTo(ostream & save)
94 NETGENPlugin_SimpleHypothesis_2D::SaveTo( save );
95 save << " " << _volume;
100 //=============================================================================
104 //=============================================================================
105 istream & NETGENPlugin_SimpleHypothesis_3D::LoadFrom(istream & load)
107 NETGENPlugin_SimpleHypothesis_2D::LoadFrom(load);
112 isOK = static_cast<bool>(load >> val);
116 load.clear(ios::badbit | load.rdstate());
121 //================================================================================
123 * \brief Does nothing
124 * \param theMesh - the built mesh
125 * \param theShape - the geometry of interest
126 * \retval bool - always false
128 //================================================================================
129 bool NETGENPlugin_SimpleHypothesis_3D::SetParametersByMesh(const SMESH_Mesh* theMesh,
130 const TopoDS_Shape& theShape)
132 if ( NETGENPlugin_SimpleHypothesis_2D::SetParametersByMesh(theMesh, theShape) )
134 // Find out max volume
136 SMESH::Controls::Volume volControl;
137 volControl.SetMesh( ((SMESH_Mesh*)theMesh)->GetMeshDS() );
138 const int nbElemToCheck = 100;
139 for ( TopExp_Explorer exp( theShape, TopAbs_SOLID ); exp.More(); exp.Next() ) {
140 SMESH_subMesh* sm = theMesh->GetSubMeshContaining( exp.Current() );
141 if ( sm && !sm->IsEmpty() ) {
142 SMDS_ElemIteratorPtr fIt = sm->GetSubMeshDS()->GetElements();
143 int nbCheckedElems = 0;
144 while ( fIt->more() && nbCheckedElems++ < nbElemToCheck ) {
145 const SMDS_MeshElement* elem = fIt->next();
146 _volume = max( _volume, volControl.GetValue( elem->GetID() ));
150 return int( _volume );