From 1a2bebb5ff22e73c6928779490ef288cd2395926 Mon Sep 17 00:00:00 2001 From: nadir Date: Thu, 16 Oct 2003 13:37:09 +0000 Subject: [PATCH] first update of those files to administrate the integration of Netgen in the SMESH Engine. --- src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx | 6 ++ src/SMESH/Makefile.in | 9 ++ src/SMESH/SMESH_HypothesisFactory.cxx | 5 +- src/SMESH/SMESH_MaxElementVolume.cxx | 108 +++++++++++++++++++++ src/SMESH/SMESH_MaxElementVolume.hxx | 28 ++++++ src/SMESHGUI/SMESHGUI.cxx | 11 ++- src/SMESHGUI/SMESHGUI_icons.po | 4 + src/SMESH_I/Makefile.in | 5 + src/SMESH_I/SMESH_Gen_i.cxx | 20 +++- src/SMESH_I/SMESH_HypothesisFactory_i.cxx | 4 + src/SMESH_I/SMESH_MEDMesh_i.cxx | 2 +- src/SMESH_I/SMESH_MEDMesh_i.hxx | 2 +- src/SMESH_I/SMESH_MaxElementVolume_i.cxx | 70 +++++++++++++ src/SMESH_I/SMESH_MaxElementVolume_i.hxx | 30 ++++++ src/SMESH_SWIG/Makefile.in | 11 ++- 15 files changed, 307 insertions(+), 8 deletions(-) diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index 1c602e378..845985436 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -361,6 +361,12 @@ void DriverMED_W_SMESHDS_Mesh::Add() nmailles[9]++; break; } + case 4 : + { + elem_Id[7].push_back(elem->GetID()); + nmailles[7]++; + break; + } } } diff --git a/src/SMESH/Makefile.in b/src/SMESH/Makefile.in index 2d94ab908..8de62e1ea 100644 --- a/src/SMESH/Makefile.in +++ b/src/SMESH/Makefile.in @@ -95,5 +95,14 @@ CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR LDFLAGS+= $(HDF5_LIBS) $(MED2_LIBS) -lOpUtil -lSMESHDS -lSMDS -lMEFISTO2D -lMeshDriverDAT -lMeshDriverMED -lMeshDriverUNV -L${KERNEL_ROOT_DIR}/lib/salome +ifeq (@WITHNETGEN@,yes) + EXPORT_HEADERS+= SMESH_Tetra_3D.hxx + LIB_SRC+= SMESH_Tetra_3D.cxx + NETGEN_INCLUDES=@NETGEN_INCLUDES@ + CPPFLAGS+= $(NETGEN_INCLUDES) + CXXFLAGS+= $(NETGEN_INCLUDES) + LDFLAGS+= -lNETGEN +endif + @CONCLUDE@ diff --git a/src/SMESH/SMESH_HypothesisFactory.cxx b/src/SMESH/SMESH_HypothesisFactory.cxx index ec9b492ef..c7ad83a10 100644 --- a/src/SMESH/SMESH_HypothesisFactory.cxx +++ b/src/SMESH/SMESH_HypothesisFactory.cxx @@ -41,10 +41,12 @@ using namespace std; #include "SMESH_LengthFromEdges.hxx" #include "SMESH_NumberOfSegments.hxx" #include "SMESH_MaxElementArea.hxx" +#include "SMESH_MaxElementVolume.hxx" #include "SMESH_Regular_1D.hxx" #include "SMESH_MEFISTO_2D.hxx" #include "SMESH_Quadrangle_2D.hxx" #include "SMESH_Hexa_3D.hxx" +#include "SMESH_Tetra_3D.hxx" //--------------------------------------- @@ -87,11 +89,12 @@ _creatorMap["LocalLength"] = new SMESH_HypothesisCreator; _creatorMap["NumberOfSegments"] = new SMESH_HypothesisCreator; _creatorMap["LengthFromEdges"] = new SMESH_HypothesisCreator; _creatorMap["MaxElementArea"] = new SMESH_HypothesisCreator; +_creatorMap["MaxElementVolume"] = new SMESH_HypothesisCreator; _creatorMap["Regular_1D"] = new SMESH_HypothesisCreator; _creatorMap["MEFISTO_2D"] = new SMESH_HypothesisCreator; _creatorMap["Quadrangle_2D"] = new SMESH_HypothesisCreator; _creatorMap["Hexa_3D"] = new SMESH_HypothesisCreator; - +_creatorMap["Tetra_3D"] = new SMESH_HypothesisCreator; //--------------------------------------- } diff --git a/src/SMESH/SMESH_MaxElementVolume.cxx b/src/SMESH/SMESH_MaxElementVolume.cxx index cd77ebe8e..cb25383d7 100644 --- a/src/SMESH/SMESH_MaxElementVolume.cxx +++ b/src/SMESH/SMESH_MaxElementVolume.cxx @@ -27,3 +27,111 @@ // $Header$ using namespace std; + +#include "SMESH_MaxElementVolume.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESH_MaxElementVolume::SMESH_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_Hypothesis(hypId, studyId, gen) +{ + _maxVolume =1.; + _name = "MaxElementVolume"; +// SCRUTE(_name); + SCRUTE(&_name); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESH_MaxElementVolume::~SMESH_MaxElementVolume() +{ + MESSAGE("SMESH_MaxElementVolume::~SMESH_MaxElementVolume"); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void SMESH_MaxElementVolume::SetMaxVolume(double maxVolume) + throw (SALOME_Exception) +{ + double oldVolume = _maxVolume; + if (maxVolume <= 0) + throw SALOME_Exception(LOCALIZED("maxVolume must be positive")); + _maxVolume = maxVolume; + if (_maxVolume != oldVolume) + NotifySubMeshesHypothesisModification(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double SMESH_MaxElementVolume::GetMaxVolume() const +{ + return _maxVolume; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & SMESH_MaxElementVolume::SaveTo(ostream & save) +{ + return save << this; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & SMESH_MaxElementVolume::LoadFrom(istream & load) +{ + return load >> (*this); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator << (ostream & save, SMESH_MaxElementVolume & hyp) +{ + save << hyp._maxVolume; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >> (istream & load, SMESH_MaxElementVolume & hyp) +{ + bool isOK = true; + double a; + isOK = (load >> a); + if (isOK) hyp._maxVolume = a; + else load.clear(ios::badbit | load.rdstate()); + return load; +} + diff --git a/src/SMESH/SMESH_MaxElementVolume.hxx b/src/SMESH/SMESH_MaxElementVolume.hxx index fe530497f..f69fb7747 100644 --- a/src/SMESH/SMESH_MaxElementVolume.hxx +++ b/src/SMESH/SMESH_MaxElementVolume.hxx @@ -26,3 +26,31 @@ // Module : SMESH // $Header$ +#ifndef _SMESH_MAXELEMENTVOLUME_HXX_ +#define _SMESH_MAXELEMENTVOLUME_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class SMESH_MaxElementVolume: + public SMESH_Hypothesis +{ +public: + SMESH_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen); + virtual ~SMESH_MaxElementVolume(); + + void SetMaxVolume(double maxVolume) + throw (SALOME_Exception); + + double GetMaxVolume() const; + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream & operator << (ostream & save, SMESH_MaxElementVolume & hyp); + friend istream & operator >> (istream & load, SMESH_MaxElementVolume & hyp); + +protected: + double _maxVolume; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index dcb6d7c98..f87fa2546 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -846,6 +846,8 @@ void SMESHGUI::CreateAlgorithm( QString TypeAlgo, QString NameAlgo ) Hyp = myComponentMesh->CreateHypothesis( TypeAlgo, myStudyId ); else if ( TypeAlgo.compare("Hexa_3D") == 0 ) Hyp = myComponentMesh->CreateHypothesis( TypeAlgo, myStudyId ); + else if ( TypeAlgo.compare("Tetra_3D") == 0 ) + Hyp = myComponentMesh->CreateHypothesis( TypeAlgo, myStudyId ); if ( !Hyp->_is_nil() ) { SALOMEDS::SObject_var SHyp = myStudyAPI.AddNewAlgorithms( Hyp ); @@ -2283,7 +2285,7 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) double beforeMaxVolume = MEV->GetMaxElementVolume() ; double MaxVolume = smeshGUI->Parameter( res, beforeMaxVolume, - tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"), + tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"), tr("SMESH_VALUE"), 1.0E-5, 1E6, 6 ) ; if ( res && MaxVolume != beforeMaxVolume ) { @@ -2487,7 +2489,12 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) } case 5020: { - smeshGUI->CreateAlgorithm("Hexa_3D","Hexaedral (i,j,k)"); + smeshGUI->CreateAlgorithm("Hexa_3D","Hexahedral (i,j,k)"); + break; + } + case 5021: + { + smeshGUI->CreateAlgorithm("Tetra_3D","Tetrahedral (Netgen)"); break; } diff --git a/src/SMESHGUI/SMESHGUI_icons.po b/src/SMESHGUI/SMESHGUI_icons.po index 2ccb593df..32b840bbc 100644 --- a/src/SMESHGUI/SMESHGUI_icons.po +++ b/src/SMESHGUI/SMESHGUI_icons.po @@ -168,6 +168,10 @@ msgstr "mesh_tree_algo_mefisto.png" msgid "ICON_SMESH_TREE_ALGO_Quadrangle_2D" msgstr "mesh_tree_algo_quad.png" +#mesh_tree_algo_tetra +msgid "ICON_SMESH_TREE_ALGO_Tetra_3D" +msgstr "mesh_tree_algo_tetra.png" + #mesh_tree_hypo msgid "ICON_SMESH_TREE_HYPO" msgstr "mesh_tree_hypo.png" diff --git a/src/SMESH_I/Makefile.in b/src/SMESH_I/Makefile.in index 2ed45ada3..a1667387e 100644 --- a/src/SMESH_I/Makefile.in +++ b/src/SMESH_I/Makefile.in @@ -78,5 +78,10 @@ CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR LDFLAGS+= $(HDF5_LIBS) $(MED2_LIBS) -lSMESHimpl -lSalomeContainer -lSalomeNS -lSalomeDS -lRegistry -lSalomeHDFPersist -lOpUtil -lGEOMClient -lSMESHDS -lSMDS -lMEFISTO2D -lMeshDriverMED -lSalomeLifeCycleCORBA -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome +ifeq (@WITHNETGEN@,yes) + LIB_SRC += SMESH_Tetra_3D_i.cxx + LDFLAGS += -lNETGEN +endif + @CONCLUDE@ diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index fa5152ed2..d9c404cd9 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -53,6 +53,7 @@ using namespace std; #include "SMESH_LocalLength_i.hxx" #include "SMESH_NumberOfSegments_i.hxx" #include "SMESH_MaxElementArea_i.hxx" +#include "SMESH_MaxElementVolume_i.hxx" #include "SMESHDS_Document.hxx" @@ -465,7 +466,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, //************branch 1 : hypothesis if (gotBranch->Tag()==Tag_HypothesisRoot) { //hypothesis = tag 1 - double length,maxElementsArea; + double length,maxElementsArea,maxElementsVolume; int numberOfSegments; destFile = fopen( hypofile.ToCString() ,"w"); @@ -495,6 +496,11 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, maxElementsArea = MEA->GetMaxElementArea(); fprintf(destFile,"%f\n",maxElementsArea); } + else if (strcmp(myHyp->GetName(),"MaxElementVolume")==0) { + SMESH::SMESH_MaxElementVolume_var MEV = SMESH::SMESH_MaxElementVolume::_narrow( myHyp ); + maxElementsVolume = MEV->GetMaxElementVolume(); + fprintf(destFile,"%f\n",maxElementsVolume); + } } } fclose(destFile); @@ -945,7 +951,7 @@ bool SMESH_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, //*************** if (strcmp(name,"Hypothesis")==0) { - double length,maxElementsArea; + double length,maxElementsArea,maxElementsVolume; int numberOfSegments; hdf_group[Tag_HypothesisRoot] = new HDFgroup(name,hdf_file); @@ -1000,6 +1006,16 @@ bool SMESH_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, sprintf(objectId,"%d",MEA->GetId()); _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString; } + else if (strcmp(aLine,"MaxElementVolume")==0) { + SMESH::SMESH_Hypothesis_var myHyp = this->CreateHypothesis(aLine,studyId); + SMESH::SMESH_MaxElementVolume_var MEV = SMESH::SMESH_MaxElementVolume::_narrow( myHyp ); + fscanf(loadedFile,"%s",aLine); + maxElementsVolume = atof(aLine); + MEV->SetMaxElementVolume(maxElementsVolume); + string iorString = _orb->object_to_string(MEV); + sprintf(objectId,"%d",MEV->GetId()); + _SMESHCorbaObj[string("Hypo_")+string(objectId)] = iorString; + } } diff --git a/src/SMESH_I/SMESH_HypothesisFactory_i.cxx b/src/SMESH_I/SMESH_HypothesisFactory_i.cxx index d292a78fc..c7bff6394 100644 --- a/src/SMESH_I/SMESH_HypothesisFactory_i.cxx +++ b/src/SMESH_I/SMESH_HypothesisFactory_i.cxx @@ -39,10 +39,12 @@ using namespace std; #include "SMESH_LocalLength_i.hxx" #include "SMESH_NumberOfSegments_i.hxx" #include "SMESH_MaxElementArea_i.hxx" +#include "SMESH_MaxElementVolume_i.hxx" #include "SMESH_Regular_1D_i.hxx" #include "SMESH_MEFISTO_2D_i.hxx" #include "SMESH_Quadrangle_2D_i.hxx" #include "SMESH_Hexa_3D_i.hxx" +#include "SMESH_Tetra_3D_i.hxx" //--------------------------------------- @@ -83,10 +85,12 @@ SMESH_HypothesisFactory_i::SMESH_HypothesisFactory_i() _creatorMap["LocalLength"] = new HypothesisCreator_i; _creatorMap["NumberOfSegments"] = new HypothesisCreator_i; _creatorMap["MaxElementArea"] = new HypothesisCreator_i; +_creatorMap["MaxElementVolume"] = new HypothesisCreator_i; _creatorMap["Regular_1D"] = new HypothesisCreator_i; _creatorMap["MEFISTO_2D"] = new HypothesisCreator_i; _creatorMap["Quadrangle_2D"] = new HypothesisCreator_i; _creatorMap["Hexa_3D"] = new HypothesisCreator_i; +_creatorMap["Tetra_3D"] = new HypothesisCreator_i; //--------------------------------------- } diff --git a/src/SMESH_I/SMESH_MEDMesh_i.cxx b/src/SMESH_I/SMESH_MEDMesh_i.cxx index e4ca92bf5..f652c6da5 100644 --- a/src/SMESH_I/SMESH_MEDMesh_i.cxx +++ b/src/SMESH_I/SMESH_MEDMesh_i.cxx @@ -196,7 +196,7 @@ SMESH_MEDMesh_i::existConnectivity(SALOME_MED::medConnectivity connectivityType, * CORBA: Accessor for Coordinate */ //============================================================================= -double SMESH_MEDMesh_i::getCoordinate(CORBA::Long Number, CORBA::Long Axis) +CORBA::Double SMESH_MEDMesh_i::getCoordinate(CORBA::Long Number, CORBA::Long Axis) throw (SALOME::SALOME_Exception) { MESSAGE("!!!!!! NOT YET IMPLEMENTED !!!!"); diff --git a/src/SMESH_I/SMESH_MEDMesh_i.hxx b/src/SMESH_I/SMESH_MEDMesh_i.hxx index 0f7f1523a..5e275446d 100644 --- a/src/SMESH_I/SMESH_MEDMesh_i.hxx +++ b/src/SMESH_I/SMESH_MEDMesh_i.hxx @@ -91,7 +91,7 @@ class SMESH_MEDMesh_i: SALOME_MED::double_array * getCoordinates(SALOME_MED::medModeSwitch typeSwitch) throw(SALOME::SALOME_Exception); - double getCoordinate(CORBA::Long Number, CORBA::Long Axis) + CORBA::Double getCoordinate(CORBA::Long Number, CORBA::Long Axis) throw (SALOME::SALOME_Exception); SALOME_MED::string_array * getCoordinatesNames() diff --git a/src/SMESH_I/SMESH_MaxElementVolume_i.cxx b/src/SMESH_I/SMESH_MaxElementVolume_i.cxx index dfbb37b80..9ed53a08d 100644 --- a/src/SMESH_I/SMESH_MaxElementVolume_i.cxx +++ b/src/SMESH_I/SMESH_MaxElementVolume_i.cxx @@ -27,3 +27,73 @@ // $Header$ using namespace std; + +#include "SMESH_MaxElementVolume_i.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_HypothesisFactory.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * Constructor: + * _name is related to the class name: prefix = SMESH_ ; suffix = _i . + */ +//============================================================================= + +SMESH_MaxElementVolume_i::SMESH_MaxElementVolume_i(const char* anHyp, + int studyId, + ::SMESH_Gen* genImpl) +{ + MESSAGE("SMESH_MaxElementVolume_i::SMESH_MaxElementVolume_i"); + _impl = new ::SMESH_MaxElementVolume(genImpl->_hypothesisFactory.GetANewId(), + studyId, + genImpl); + _baseImpl = _impl; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESH_MaxElementVolume_i::~SMESH_MaxElementVolume_i() +{ + MESSAGE("SMESH_MaxElementVolume_i::~SMESH_MaxElementVolume_i()"); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void SMESH_MaxElementVolume_i::SetMaxElementVolume(CORBA::Double volume) + throw (SALOME::SALOME_Exception) +{ + ASSERT(_impl); + try + { + _impl->SetMaxVolume(volume); + } + catch (SALOME_Exception& S_ex) + { + THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), \ + SALOME::BAD_PARAM); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Double SMESH_MaxElementVolume_i::GetMaxElementVolume() +{ + ASSERT(_impl); + return _impl->GetMaxVolume(); +} + diff --git a/src/SMESH_I/SMESH_MaxElementVolume_i.hxx b/src/SMESH_I/SMESH_MaxElementVolume_i.hxx index 8ffd245d7..c59fd65b1 100644 --- a/src/SMESH_I/SMESH_MaxElementVolume_i.hxx +++ b/src/SMESH_I/SMESH_MaxElementVolume_i.hxx @@ -26,3 +26,33 @@ // Module : SMESH // $Header$ +#ifndef _SMESH_MAXELEMENTVOLUME_I_HXX_ +#define _SMESH_MAXELEMENTVOLUME_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" + +#include "SMESH_MaxElementVolume.hxx" + +class SMESH_MaxElementVolume_i: + public POA_SMESH::SMESH_MaxElementVolume, + public SMESH_Hypothesis_i +{ +public: + SMESH_MaxElementVolume_i(const char* anHyp, + int studyId, + ::SMESH_Gen* genImpl); + virtual ~SMESH_MaxElementVolume_i(); + + void SetMaxElementVolume(CORBA::Double volume) + throw (SALOME::SALOME_Exception); + + CORBA::Double GetMaxElementVolume(); + +protected: + ::SMESH_MaxElementVolume* _impl; +}; + +#endif diff --git a/src/SMESH_SWIG/Makefile.in b/src/SMESH_SWIG/Makefile.in index f2a1c7025..3750b92f2 100644 --- a/src/SMESH_SWIG/Makefile.in +++ b/src/SMESH_SWIG/Makefile.in @@ -39,7 +39,16 @@ LIB_SRC = SWIG_DEF = libSMESH_Swig.i EXPORT_PYSCRIPTS = libSMESH_Swig.py \ - SMESH_test0.py SMESH_test1.py SMESH_test2.py SMESH_test3.py SMESH_mechanic.py SMESH_fixation.py batchmode_smesh.py + SMESH_test0.py\ + SMESH_test1.py \ + SMESH_test2.py \ + SMESH_test3.py \ + SMESH_mechanic.py \ + SMESH_mechanic_tetra.py \ + SMESH_fixation.py \ + batchmode_smesh.py \ + SMESH_box_tetra.py \ + SMESH_box2_tetra.py LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_Exception.idl \ -- 2.39.2