From: eap Date: Tue, 18 Sep 2018 14:25:15 +0000 (+0300) Subject: 23586: [EDF] HYDRO: Copy mesh to new geometry X-Git-Tag: HYDRO_V2_0_0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=045dc238b67af6854a0e0f16b3f48b45e1c07cde;p=plugins%2Fgmshplugin.git 23586: [EDF] HYDRO: Copy mesh to new geometry --- diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx index 2b414c9..3bdf217 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx @@ -39,8 +39,8 @@ GMSHPlugin_Hypothesis::GMSHPlugin_Hypothesis (int hypId, int studyId, _remeshPara (harmonic), _smouthSteps (1), _sizeFactor (1), - _maxSize (1e22), _minSize (0), + _maxSize (1e22), _secondOrder (false), _useIncomplElem (true) { @@ -322,17 +322,6 @@ istream & GMSHPlugin_Hypothesis::LoadFrom(istream & load) return load; } -ostream & operator <<(ostream & save, GMSHPlugin_Hypothesis & hyp) -{ - return hyp.SaveTo( save ); -} - -istream & operator >>(istream & load, GMSHPlugin_Hypothesis & hyp) -{ - return hyp.LoadFrom( load ); -} - - //================================================================================ /*! * \brief Does nothing @@ -355,7 +344,7 @@ bool GMSHPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, //================================================================================ bool GMSHPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, - const SMESH_Mesh* theMesh) + const SMESH_Mesh* theMesh) { //_nbSegPerEdge = dflts._nbSegments; //_maxSize = dflts._elemLength; @@ -366,4 +355,5 @@ bool GMSHPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, // _minSize = GMSHPlugin_Mesher::GetDefaultMinSize( theMesh->GetShapeToMesh(), _maxSize ); //return _nbSegPerEdge && _maxSize > 0; + return false; } diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx index dde0eb2..c3fbdfb 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx @@ -133,8 +133,6 @@ public: // Persistence virtual ostream & SaveTo(ostream & save); virtual istream & LoadFrom(istream & load); - friend GMSHPLUGIN_EXPORT ostream & operator <<(ostream & save, GMSHPlugin_Hypothesis & hyp); - friend GMSHPLUGIN_EXPORT istream & operator >>(istream & load, GMSHPlugin_Hypothesis & hyp); /*! * \brief Does nothing diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx index 453074b..a686700 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx @@ -344,3 +344,49 @@ std::string GMSHPlugin_Hypothesis_i::getMethodOfParameter(const int paramIndex, } return ""; } + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +GMSHPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + typedef ::GMSHPlugin_Hypothesis THyp; + const THyp* impl = static_cast( myBaseImpl ); + + const THyp::TCompound& compounds = impl->GetCompoundOnEntries(); + entryArray.assign( compounds.cbegin(), compounds.cend() ); + + return true; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +GMSHPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + typedef ::GMSHPlugin_Hypothesis THyp; + THyp* impl = static_cast< THyp* >( myBaseImpl ); + + size_t iEnt = 0; + + THyp::TCompound& compoundsNew = const_cast< THyp::TCompound& > ( impl->GetCompoundOnEntries() ); + THyp::TCompound compounds; + compounds.swap( compoundsNew ); + + THyp::TCompound::const_iterator entry = compounds.cbegin(); + for ( ; entry != compounds.cend(); ++entry, ++iEnt ) + if ( !entryArray[ iEnt ].empty() ) + compoundsNew.insert( entryArray[ iEnt ]); + + return true; +} diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx index 98817aa..cdb9a03 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx @@ -95,10 +95,10 @@ class GMSHPLUGIN_EXPORT GMSHPlugin_Hypothesis_i: void SetNbSegPerRadius(CORBA::Double theVal); CORBA::Double GetNbSegPerRadius(); - void SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double localSize); - void SetLocalSizeOnEntry(const char* entry, CORBA::Double localSize); - CORBA::Double GetLocalSizeOnEntry(const char* entry); - GMSHPlugin::string_array* GetLocalSizeEntries(); + // void SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double localSize); + // void SetLocalSizeOnEntry(const char* entry, CORBA::Double localSize); + // CORBA::Double GetLocalSizeOnEntry(const char* entry); + // GMSHPlugin::string_array* GetLocalSizeEntries(); void UnsetLocalSizeOnEntry(const char* entry); @@ -164,6 +164,17 @@ class GMSHPLUGIN_EXPORT GMSHPlugin_Hypothesis_i: // into myMethod2VarParams. It should return a method name for an index of // variable parameters. Index is countered from zero virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; + + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); }; #endif diff --git a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx index 6e2ccf1..8159c75 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx @@ -216,7 +216,7 @@ void GMSHPlugin_Mesher::CreateGmshCompounds() geomShape = smeshGen_i->GeomObjectToShape( aGeomObj.in() ); TopAbs_ShapeEnum geomType = geomShape.ShapeType(); - if (geomShape.ShapeType() == TopAbs_COMPOUND)// voir s'il ne faut pas mettre une erreur dans le cas contraire + if ( geomType == TopAbs_COMPOUND)// voir s'il ne faut pas mettre une erreur dans le cas contraire { MESSAGE("shapeType == TopAbs_COMPOUND"); TopoDS_Iterator it(geomShape); @@ -227,7 +227,7 @@ void GMSHPlugin_Mesher::CreateGmshCompounds() MESSAGE(" shapeType == TopAbs_EDGE :"); int num = _gModel->getNumEdges()+1; Curve *curve = CreateCurve(num, MSH_SEGM_COMPOUND, 1, NULL, NULL, -1, -1, 0., 1.); - for (it; it.More(); it.Next()) + for ( ; it.More(); it.Next()) { TopoDS_Shape topoShape = it.Value(); ASSERT(topoShape.ShapeType() == shapeType); @@ -242,7 +242,7 @@ void GMSHPlugin_Mesher::CreateGmshCompounds() MESSAGE(" shapeType == TopAbs_FACE :"); int num = _gModel->getNumFaces()+1; Surface *surface = CreateSurface(num, MSH_SURF_COMPOUND); - for (it; it.More(); it.Next()) + for ( ; it.More(); it.Next()) { TopoDS_Shape topoShape = it.Value(); ASSERT(topoShape.ShapeType() == shapeType); @@ -299,7 +299,7 @@ void GMSHPlugin_Mesher::FillSMesh() std::vector verts; e->getVertices(verts); ASSERT(verts.size()==1); - SMDS_Mesh0DElement* zeroDElement = 0; + //SMDS_Mesh0DElement* zeroDElement = 0; // WE DONT ADD 0D ELEMENTS because it does not follow the salome meshers philosophy //zeroDElement = meshDS->Add0DElementWithID(verts[0]->getNum(),e->getNum()); //meshDS->SetMeshElementOnShape(zeroDElement, topoVertex); diff --git a/src/GMSHPlugin/GMSHPlugin_Mesher.hxx b/src/GMSHPlugin/GMSHPlugin_Mesher.hxx index 6da9164..0f787ce 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.hxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.hxx @@ -92,14 +92,14 @@ class GMSHPLUGIN_EXPORT GMSHPlugin_Mesher void CreateGmshCompounds(); void FillSMesh(); float DistBoundingBox(SBoundingBox3d& bounds,SPoint3& point); - + class mymsg : public GmshMessage { - private: - GModel* _gModel; - public: - mymsg(GModel* _gModel) : _gModel(_gModel), GmshMessage() {} - void operator()(std::string level, std::string msg); + private: + GModel* _gModel; + public: + mymsg(GModel* _gModel) : GmshMessage(), _gModel(_gModel) {} + void operator()(std::string level, std::string msg); }; };