From be76d37abe12364bd0a977943bc054533917beb2 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 18 Sep 2018 14:58:42 +0300 Subject: [PATCH] 23586: [EDF] HYDRO: Copy mesh to new geometry --- src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx | 16 ++------ src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx | 2 - src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx | 46 ++++++++++++++++++++++ src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx | 19 +++++++-- src/GMSHPlugin/GMSHPlugin_Mesher.cxx | 8 ++-- src/GMSHPlugin/GMSHPlugin_Mesher.hxx | 12 +++--- 6 files changed, 74 insertions(+), 29 deletions(-) diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx index c8a698e..2937a1d 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx @@ -39,8 +39,8 @@ GMSHPlugin_Hypothesis::GMSHPlugin_Hypothesis (int hypId, _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 0fe8db8..48b271a 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 2fc0a5d..312b762 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.cxx @@ -342,3 +342,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 716ad95..2686f71 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis_i.hxx @@ -94,10 +94,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); @@ -163,6 +163,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 b36bcaf..da965f6 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx @@ -212,7 +212,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); @@ -223,7 +223,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); @@ -238,7 +238,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); @@ -295,7 +295,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 ebbcae6..486a360 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.hxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.hxx @@ -91,14 +91,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); }; }; -- 2.39.2