X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYBRIDPlugin%2FHYBRIDPlugin_Hypothesis.cxx;h=fb18c5958dd3c3e15b98ce24448c8a6f99a3f5b5;hb=d65687cff09317795b1562b4a52e4ac84871fd66;hp=673d63597e564b4e744cd6560c1ac40d110a753f;hpb=3b6e65d4354246ee45b961a556c1362acf0b45f5;p=plugins%2Fhybridplugin.git diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx index 673d635..fb18c59 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -27,7 +27,7 @@ #include -#include +#include #ifdef WIN32 #include @@ -62,6 +62,7 @@ HYBRIDPlugin_Hypothesis::HYBRIDPlugin_Hypothesis(int hypId, SMESH_Gen * gen) mySmoothNormals(DefaultSmoothNormals()), myHeightFirstLayer(DefaultHeightFirstLayer()), myBoundaryLayersProgression(DefaultBoundaryLayersProgression()), + myCoreSize(DefaultCoreSize()), myMultinormalsAngle(DefaultMultinormalsAngle()), myNbOfBoundaryLayers(DefaultNbOfBoundaryLayers()), _enfVertexList(DefaultHYBRIDEnforcedVertexList()), @@ -102,6 +103,84 @@ bool HYBRIDPlugin_Hypothesis::GetLayersOnAllWrap(bool checkFreeOption) const return myLayersOnAllWrap; } +//======================================================================= +//function : SetFacesWithLayers +//purpose : Set IDs of faces to grow the layers on +//======================================================================= + +bool HYBRIDPlugin_Hypothesis::SetFacesWithLayers(const std::vector& theVal) +{ + if ( myFacesWithLayers != theVal ) + { + myFacesWithLayers = theVal; + NotifySubMeshesHypothesisModification(); + return true; + } + return false; +} + +//======================================================================= +//function : GetFacesWithLayers +//purpose : Return IDs of faces to grow the layers on +//======================================================================= + +const std::vector& HYBRIDPlugin_Hypothesis::GetFacesWithLayers() const +{ + return myFacesWithLayers; +} + +//======================================================================= +//function : SetFacesWithImprinting +//purpose : Set IDs of faces to grow the layers on +//======================================================================= + +bool HYBRIDPlugin_Hypothesis::SetFacesWithImprinting(const std::vector& theVal) +{ + if ( myFacesWithImprinting != theVal ) + { + myFacesWithImprinting = theVal; + NotifySubMeshesHypothesisModification(); + return true; + } + return false; +} + +//======================================================================= +//function : GetFacesWithImprinting +//purpose : Return IDs of faces to grow the layers on +//======================================================================= + +const std::vector& HYBRIDPlugin_Hypothesis::GetFacesWithImprinting() const +{ + return myFacesWithImprinting; +} + +//======================================================================= +//function : SetFacesWithSnapping +//purpose : Set IDs of faces that already have surface layers +//======================================================================= + +bool HYBRIDPlugin_Hypothesis::SetFacesWithSnapping(const std::vector& theVal) +{ + if ( myFacesWithSnapping != theVal ) + { + myFacesWithSnapping = theVal; + NotifySubMeshesHypothesisModification(); + return true; + } + return false; +} + +//======================================================================= +//function : GetFacesWithSnapping +//purpose : Return IDs of faces that already have surface layers +//======================================================================= + +const std::vector& HYBRIDPlugin_Hypothesis::GetFacesWithSnapping() const +{ + return myFacesWithSnapping; +} + //======================================================================= //function : SetToMeshHoles //======================================================================= @@ -365,6 +444,27 @@ double HYBRIDPlugin_Hypothesis::GetBoundaryLayersProgression() const return myBoundaryLayersProgression; } +//======================================================================= +//function : SetCoreSize +//======================================================================= + +void HYBRIDPlugin_Hypothesis::SetCoreSize(double toCoreSize) +{ + if ( myCoreSize != toCoreSize ) { + myCoreSize = toCoreSize; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetCoreSize +//======================================================================= + +double HYBRIDPlugin_Hypothesis::GetCoreSize() const +{ + return myCoreSize; +} + //======================================================================= //function : SetMultinormalsAngle //======================================================================= @@ -399,7 +499,7 @@ void HYBRIDPlugin_Hypothesis::SetNbOfBoundaryLayers(short toNbOfBoundaryLayers) } //======================================================================= -//function : GetMultinormalsAngle +//function : GetCoreSize //======================================================================= short HYBRIDPlugin_Hypothesis::GetNbOfBoundaryLayers() const @@ -649,9 +749,6 @@ bool HYBRIDPlugin_Hypothesis::GetRemoveLogOnSuccess() const bool HYBRIDPlugin_Hypothesis::SetEnforcedVertex(std::string theName, std::string theEntry, std::string theGroupName, double size, double x, double y, double z, bool isCompound) { - MESSAGE("HYBRIDPlugin_Hypothesis::SetEnforcedVertex(\""<< theName << "\", \""<< theEntry << "\", \"" << theGroupName << "\", " - << size << ", " << x << ", " << y << ", " << z << ", "<< isCompound << ")"); - bool toNotify = false; bool toCreate = true; @@ -675,19 +772,15 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedVertex(std::string theName, std::string if (it != _enfVertexList.end()) { toCreate = false; oldEnVertex = (*it); - MESSAGE("Enforced Vertex was found => Update"); if (oldEnVertex->name != theName) { - MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theName << "\""); oldEnVertex->name = theName; toNotify = true; } if (oldEnVertex->groupName != theGroupName) { - MESSAGE("Update group name from \"" << oldEnVertex->groupName << "\" to \"" << theGroupName << "\""); oldEnVertex->groupName = theGroupName; toNotify = true; } if (oldEnVertex->size != size) { - MESSAGE("Update size from \"" << oldEnVertex->size << "\" to \"" << size << "\""); oldEnVertex->size = size; toNotify = true; } @@ -709,7 +802,6 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedVertex(std::string theName, std::string // //////// CREATE //////////// if (toCreate) { toNotify = true; - MESSAGE("Creating new enforced vertex"); _enfVertexList.insert(newEnfVertex); if (theEntry == "") { _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex; @@ -724,7 +816,6 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedVertex(std::string theName, std::string if (toNotify) NotifySubMeshesHypothesisModification(); - MESSAGE("HYBRIDPlugin_Hypothesis::SetEnforcedVertex END"); return toNotify; } @@ -738,7 +829,6 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::Elemen SMDS_ElemIteratorPtr eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType)); while ( eIt->more() ) theElemSet.insert( eIt->next() ); - MESSAGE("Add "<length() == 0 ){MESSAGE("The source group is empty");} for ( CORBA::ULong i = 0; i < theIDs->length(); i++) { @@ -788,7 +877,6 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SM // while ( it->more() ) // theElemSet.insert( it->next() ); - MESSAGE("Add "<X()<<","<Y()<<","<Z()<< ") with ID " << node->GetID() <<" added ? " << msg); } else { SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); @@ -846,14 +932,6 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, S elemRet = _enfEdges.insert(make_pair(elem,groupName)); added = added && elemRet.second; } - else if (elem->GetType() > SMDSAbs_Edge) { - SMDS_ElemIteratorPtr it = elem->edgesIterator(); - for (;it->more();) { - const SMDS_MeshElement* anEdge = it->next(); - elemRet = _enfEdges.insert(make_pair(anEdge,groupName)); - added = added && elemRet.second; - } - } break; case SMESH::FACE: if (elem->GetType() == SMDSAbs_Face) @@ -863,16 +941,6 @@ bool HYBRIDPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, S added = added && elemRet.second; } } - else if (elem->GetType() > SMDSAbs_Face) { // Group of faces - SMDS_ElemIteratorPtr it = elem->facesIterator(); - for (;it->more();) { - const SMDS_MeshElement* aFace = it->next(); - if (aFace->NbCornerNodes() == 3) { - elemRet = _enfTriangles.insert(make_pair(aFace,groupName)); - added = added && elemRet.second; - } - } - } break; default: break; @@ -932,28 +1000,23 @@ bool HYBRIDPlugin_Hypothesis::RemoveEnforcedVertex(double x, double y, double z, TGeomEntryHYBRIDEnforcedVertexMap::iterator it_enfVertexEntry = _geomEntryEnfVertexMap.find(theEntry); if (it_enfVertexEntry != _geomEntryEnfVertexMap.end()) { // Success - MESSAGE("Found enforced vertex with geom entry " << theEntry); oldEnfVertex = it_enfVertexEntry->second; _geomEntryEnfVertexMap.erase(it_enfVertexEntry); } else { // Fail - MESSAGE("Enforced vertex with geom entry " << theEntry << " not found"); // check that enf vertex with given coords exists TCoordsHYBRIDEnforcedVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords); if (it_coords_enf != _coordsEnfVertexMap.end()) { // Success - MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z); oldEnfVertex = it_coords_enf->second; _coordsEnfVertexMap.erase(it_coords_enf); _enfVertexCoordsSizeList.erase(_enfVertexCoordsSizeList.find(coords)); } else { // Fail - MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found"); throw std::invalid_argument(msg.str()); } } - MESSAGE("Remove enf vertex from _enfVertexList"); // update _enfVertexList THYBRIDEnforcedVertexList::iterator it = _enfVertexList.find(oldEnfVertex); @@ -962,7 +1025,6 @@ bool HYBRIDPlugin_Hypothesis::RemoveEnforcedVertex(double x, double y, double z, _groupsToRemove.insert((*it)->groupName); _enfVertexList.erase(it); toNotify = true; - MESSAGE("Done"); } if (toNotify) @@ -1070,22 +1132,15 @@ bool HYBRIDPlugin_Hypothesis::DefaultToMakeGroupsOfDomains() //function : DefaultMaximumMemory //======================================================================= -#ifndef WIN32 -#include -#else +#if defined(WIN32) #include +#elif !defined(__APPLE__) +#include #endif double HYBRIDPlugin_Hypothesis::DefaultMaximumMemory() { -#ifndef WIN32 - struct sysinfo si; - int err = sysinfo( &si ); - if ( err == 0 ) { - int ramMB = si.totalram * si.mem_unit / 1024 / 1024; - return ( 0.7 * ramMB ); - } -#else +#if defined(WIN32) // See http://msdn.microsoft.com/en-us/library/aa366589.aspx MEMORYSTATUSEX statex; statex.dwLength = sizeof (statex); @@ -1097,6 +1152,13 @@ double HYBRIDPlugin_Hypothesis::DefaultMaximumMemory() statex.ullTotalVirtual / 1024 / 1024; return ( 0.7 * totMB ); } +#elif !defined(__APPLE__) + struct sysinfo si; + int err = sysinfo( &si ); + if ( err == 0 ) { + int ramMB = si.totalram * si.mem_unit / 1024 / 1024; + return ( 0.7 * ramMB ); + } #endif return 1024; } @@ -1148,7 +1210,7 @@ short HYBRIDPlugin_Hypothesis::DefaultOptimizationLevel() std::string HYBRIDPlugin_Hypothesis::DefaultWorkingDirectory() { - TCollection_AsciiString aTmpDir; + std::string aTmpDir; char *Tmp_dir = getenv("SALOME_TMP_DIR"); if(Tmp_dir != NULL) { @@ -1156,12 +1218,12 @@ std::string HYBRIDPlugin_Hypothesis::DefaultWorkingDirectory() } else { #ifdef WIN32 - aTmpDir = TCollection_AsciiString("C:\\"); + aTmpDir = "C:\\"; #else - aTmpDir = TCollection_AsciiString("/tmp/"); + aTmpDir = "/tmp/"; #endif } - return aTmpDir.ToCString(); + return aTmpDir; } //======================================================================= @@ -1287,6 +1349,14 @@ double HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersProgression() return 1.0; } +//======================================================================= +//function : DefaultCoreSize +//======================================================================= +double HYBRIDPlugin_Hypothesis::DefaultCoreSize() +{ + return 0.0; +} + //======================================================================= //function : DefaultMultinormalsAngle //======================================================================= @@ -1323,12 +1393,14 @@ std::ostream & HYBRIDPlugin_Hypothesis::SaveTo(std::ostream & save) save << (int) myKeepFiles << " "; save << myWorkingDirectory << " "; save << myVerboseLevel << " "; + save << myCoreSize << " "; + if (!myTextOption.empty()) { save << "__OPTIONS_BEGIN__ "; save << myTextOption << " "; save << "__OPTIONS_END__ "; } - + THYBRIDEnforcedVertexList::iterator it = _enfVertexList.begin(); if (it != _enfVertexList.end()) { @@ -1397,6 +1469,19 @@ std::ostream & HYBRIDPlugin_Hypothesis::SaveTo(std::ostream & save) } save << " " << "__ENFORCED_MESHES_END__ "; } + + save << " " << myFacesWithLayers.size(); + for ( size_t i = 0; i < myFacesWithLayers.size(); ++i ) + save << " " << myFacesWithLayers[i]; + + save << " " << myFacesWithImprinting.size(); + for ( size_t i = 0; i < myFacesWithImprinting.size(); ++i ) + save << " " << myFacesWithImprinting[i]; + + save << " " << myFacesWithSnapping.size(); + for ( size_t i = 0; i < myFacesWithSnapping.size(); ++i ) + save << " " << myFacesWithSnapping[i]; + return save; } @@ -1490,6 +1575,11 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) else load.clear(ios::badbit | load.rdstate()); + isOK = static_cast(load >> d); + if (isOK) + myCoreSize = d; + else + load.clear(ios::badbit | load.rdstate()); std::string separator; bool hasOptions = false; @@ -1584,7 +1674,6 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) name += txt; } } - MESSAGE("name: " <(load >> txt); // __END_ENTRY__ if (txt != "__END_ENTRY__") throw std::exception(); - MESSAGE("entry: " << entry); } if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__ @@ -1605,7 +1693,6 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) groupName += txt; } } - MESSAGE("groupName: " << groupName); } if (txt == "__BEGIN_COORDS__") { // __BEGIN_COORDS__ @@ -1614,7 +1701,6 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) isOK = static_cast(load >> txt); // __END_COORDS__ if (txt != "__END_COORDS__") throw std::exception(); - MESSAGE("coords: " << coords[0] <<","<< coords[1] <<","<< coords[2]); } if (txt == "__BEGIN_SIZE__") { // __BEGIN_ENTRY__ @@ -1623,7 +1709,6 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) if (txt != "__END_SIZE__") { throw std::exception(); } - MESSAGE("size: " << size); } } isOK = static_cast(load >> txt); // __BEGIN_VERTEX__ @@ -1675,7 +1760,6 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) name += txt; } } - MESSAGE("name: " <(load >> txt); // __END_ENTRY__ if (txt != "__END_ENTRY__") throw std::exception(); - MESSAGE("entry: " << entry); } if (txt == "__BEGIN_ELEM_TYPE__") { // __BEGIN_ELEM_TYPE__ @@ -1691,7 +1774,6 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) isOK = static_cast(load >> txt); // __END_ELEM_TYPE__ if (txt != "__END_ELEM_TYPE__") throw std::exception(); - MESSAGE("elementType: " << elementType); } if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__ @@ -1703,12 +1785,10 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) groupName += txt; } } // while - MESSAGE("groupName: " << groupName); } // if if (txt == "__PERSIST_ID__") { isOK = static_cast(load >> persistID); - MESSAGE("persistID: " << persistID); } std::cout << "isOK: " << isOK << std::endl; } // while @@ -1717,6 +1797,50 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) } // while } // if + if ( hasEnforcedMeshes ) + isOK = static_cast(load >> separator); + + if ( isOK ) + { + i = atoi( separator.c_str() ); + isOK = ( i >= 0 ); + if ( isOK ) + { + myFacesWithLayers.reserve( i ); + while (( myFacesWithLayers.size() < myFacesWithLayers.capacity() ) && + ( isOK = static_cast(load >> i)) ) + myFacesWithLayers.push_back( i ); + } + } + + isOK = static_cast(load >> separator); + if ( isOK ) + { + i = atoi( separator.c_str() ); + isOK = ( i >= 0 ); + if ( isOK ) + { + myFacesWithImprinting.reserve( i ); + while (( myFacesWithImprinting.size() < myFacesWithImprinting.capacity() ) && + ( isOK = static_cast(load >> i)) ) + myFacesWithImprinting.push_back( i ); + } + } + + isOK = static_cast(load >> separator); + if ( isOK ) + { + i = atoi( separator.c_str() ); + isOK = ( i >= 0 ); + if ( isOK ) + { + myFacesWithSnapping.reserve( i ); + while (( myFacesWithSnapping.size() < myFacesWithSnapping.capacity() ) && + ( isOK = static_cast(load >> i)) ) + myFacesWithSnapping.push_back( i ); + } + } + return load; } @@ -1750,31 +1874,29 @@ bool HYBRIDPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, //================================================================================ std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* hyp, - const bool hasShapeToMesh) + SMESH_Mesh& mesh) { - TCollection_AsciiString cmd = GetExeName().c_str(); + SMESH_Comment cmd = GetExeName(); // check if any option is overridden by hyp->myTextOption - bool p_h = ( hyp && hyp->myTextOption.find("-h") != std::string::npos ); - bool p_v = ( hyp && hyp->myTextOption.find("-v ") != std::string::npos ); - bool p_i = ( hyp && hyp->myTextOption.find("-i") != std::string::npos ); - bool p_o = ( hyp && hyp->myTextOption.find("-o") != std::string::npos ); - bool p_mnot = ( hyp && hyp->myTextOption.find("--max_number_of_threads ") != std::string::npos ); - bool p_blsi = ( hyp && hyp->myTextOption.find("--boundary_layer_surface_tags ") != std::string::npos ); - bool p_blii = ( hyp && hyp->myTextOption.find("--boundary_layer_imprint_tags ") != std::string::npos ); - bool p_blsd = ( hyp && hyp->myTextOption.find("--normal_direction ") != std::string::npos ); - bool p_hotfl = ( hyp && hyp->myTextOption.find("--boundary_layer_global_initial_height ") != std::string::npos ); - bool p_nobl = ( hyp && hyp->myTextOption.find("--number_of_boundary_layers ") != std::string::npos ); - bool p_blgp = ( hyp && hyp->myTextOption.find("--boundary_layer_geometric_progression ") != std::string::npos ); - bool p_eg = ( hyp && hyp->myTextOption.find("--element_generation ") != std::string::npos ); - bool p_cm = ( hyp && hyp->myTextOption.find("--collision_mode ") != std::string::npos ); - bool p_am = ( hyp && hyp->myTextOption.find("--add_multinormals ") != std::string::npos ); - bool p_mat = ( hyp && hyp->myTextOption.find("--multinormal_angle_threshold ") != std::string::npos ); - bool p_sn = ( hyp && hyp->myTextOption.find("--smooth_normals ") != std::string::npos ); + bool p_h = ( hyp && hyp->myTextOption.find("-h") != std::string::npos ); + bool p_v = ( hyp && hyp->myTextOption.find("-v") != std::string::npos ); + bool p_i = ( hyp && hyp->myTextOption.find("-i") != std::string::npos ); + bool p_o = ( hyp && hyp->myTextOption.find("-o") != std::string::npos ); + bool p_mnot = ( hyp && hyp->myTextOption.find("--max_number_of_threads ") != std::string::npos ); + bool p_blsi = ( hyp && hyp->myTextOption.find("--boundary_layer_surface_tags ") != std::string::npos ); + bool p_blii = ( hyp && hyp->myTextOption.find("--boundary_layer_imprint_tags ") != std::string::npos ); + bool p_blsd = ( hyp && hyp->myTextOption.find("--normal_direction ") != std::string::npos ); + bool p_hotfl = ( hyp && hyp->myTextOption.find("--boundary_layer_global_initial_height ") != std::string::npos ); + bool p_nobl = ( hyp && hyp->myTextOption.find("--number_of_boundary_layers ") != std::string::npos ); + bool p_blgp = ( hyp && hyp->myTextOption.find("--boundary_layer_geometric_progression ") != std::string::npos ); + bool p_eg = ( hyp && hyp->myTextOption.find("--element_generation ") != std::string::npos ); + bool p_cm = ( hyp && hyp->myTextOption.find("--collision_mode ") != std::string::npos ); + bool p_am = ( hyp && hyp->myTextOption.find("--add_multinormals ") != std::string::npos ); + bool p_cs = ( hyp && hyp->myTextOption.find("--global_physical_size ") != std::string::npos ); + bool p_mat = ( hyp && hyp->myTextOption.find("--multinormal_angle_threshold ") != std::string::npos ); + bool p_sn = ( hyp && hyp->myTextOption.find("--smooth_normals ") != std::string::npos ); //missing options : - //- global_physical_size - //- boundary_layer_size_mode - //- boundary_layer_initial_height_on_surface_tags //- boundary_layer_max_element_angle bool nolayers = false; @@ -1782,34 +1904,20 @@ std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* //help mode if ( p_h ) { - cmd += " --help "; + cmd << " --help "; #ifdef WIN32 - cmd += " < NUL"; + cmd << " < NUL"; #endif - std::cout << "!!!!! CommandToRun help only !!!! " << cmd.ToCString() << std::endl; - return cmd.ToCString(); + std::cout << "!!!!! CommandToRun help only !!!! " << cmd << std::endl; + return cmd; } - if ( !p_v && hyp ) { - cmd += " --verbose "; - cmd += hyp->myVerboseLevel; - } + if ( !p_v && hyp ) + cmd << " --verbose " << hyp->myVerboseLevel; + + if ( !p_mnot && hyp ) + cmd << " --max_number_of_threads " << 8; //TODO getenv NB CPU - if ( !p_mnot && hyp ) { - cmd += " --max_number_of_threads "; - cmd += 8; //TODO getenv NB CPU - } - - //if ( !p_blsi && hyp ) { - // cmd += " --boundary_layers_surface_ids "; - // cmd += 0; //TODO hyp->my; - //} - - //if ( !p_blii && hyp ) { - // cmd += " --boundary_layers_imprint_ids "; - // cmd += 0; //TODO hyp->my; - //} - //no layers? if ( !p_nobl && hyp ) { if ( hyp->myNbOfBoundaryLayers < 1 ) nolayers = true; @@ -1820,81 +1928,102 @@ std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* if ( !p_blsd && hyp ) { if ( hyp->myBoundaryLayersGrowth >= 0 && hyp->myBoundaryLayersGrowth <= 1 ) { - const char* value[] = { "1" , "-1" }; - cmd += " --normal_direction "; - cmd += value[ hyp->myBoundaryLayersGrowth ]; + const char* value[] = { "-1" , "1" }; // -1 == inside + cmd << " --normal_direction " << value[ hyp->myBoundaryLayersGrowth ]; } } if ( !p_hotfl && hyp ) { - cmd += " --boundary_layer_global_initial_height "; - cmd += hyp->myHeightFirstLayer; + cmd << " --boundary_layer_global_initial_height " << hyp->myHeightFirstLayer; } if ( !p_nobl && hyp ) { - cmd += " --number_of_boundary_layers "; - if ( nolayers ) - cmd += 0; - else - cmd += hyp->myNbOfBoundaryLayers; + cmd << " --number_of_boundary_layers " << ( nolayers ? 0 : hyp->myNbOfBoundaryLayers ); } - + if ( !p_blgp && hyp ) { - cmd += " --boundary_layer_geometric_progression "; - cmd += hyp->myBoundaryLayersProgression; + cmd << " --boundary_layer_geometric_progression " << hyp->myBoundaryLayersProgression; } - //--boundary_layers_surface_ids 5 #for all wrap shell - //--boundary_layers_surface_ids 6 #for all enfMeshList - //TODO? if ( !nolayers ) cmd += " --boundary_layers_surface_ids 5,6 "; //as all wrap shell and triangles of enforced mesh - if ( !nolayers ) { - if (layersOnAllWrap) - cmd += " --boundary_layer_surface_tags 5 "; //as triangles of all wrap - else - cmd += " --boundary_layer_surface_tags 6 "; //as triangles of enforced mesh + if ( !nolayers && hyp ) + { + cmd << " --boundary_layer_size_mode " << ( layersOnAllWrap ? "global" : "local" ); + + if ( !layersOnAllWrap ) + { + // faces with layers + const std::vector& faceLayersIDs = hyp->GetFacesWithLayers(); + if ( !faceLayersIDs.empty() ) + cmd << " --boundary_layer_surface_tags "; + for ( size_t i = 0; i < faceLayersIDs.size(); ++i ) + cmd << faceLayersIDs[i] << ","; + if ( !faceLayersIDs.empty() ) + cmd << " --boundary_layer_initial_height_on_surface_tags "; + for ( size_t i = 0; i < faceLayersIDs.size(); ++i ) + cmd << hyp->myHeightFirstLayer << ","; + + // faces with imprinting + const std::vector& faceImprintingIDs = hyp->GetFacesWithImprinting(); + if ( !faceImprintingIDs.empty() ) + cmd << " --boundary_layer_imprinting yes --boundary_layer_imprinting_tags "; + for ( size_t i = 0; i < faceImprintingIDs.size(); ++i ) + cmd << faceImprintingIDs[i] << ","; + + // faces with snapping + const std::vector& faceSnappingIDs = hyp->GetFacesWithSnapping(); + if ( !faceSnappingIDs.empty() ) + cmd << " --boundary_layer_snapping yes --boundary_layer_snapping_tags "; + for ( size_t i = 0; i < faceSnappingIDs.size(); ++i ) + cmd << faceSnappingIDs[i] << ","; + } } if ( !p_eg && hyp ) { - if ( hyp->myElementGeneration >= 0 && hyp->myElementGeneration <= 1 ) { - const char* value[] = { "tetra-dominant" , "hexa-dominant" }; - cmd += " --element_generation "; - cmd += value[ hyp->myElementGeneration ]; + if ( hyp->myElementGeneration >= 0 && hyp->myElementGeneration <= 2 ) { + const char* value[] = { "tetra-dominant" , "hexa-dominant", "cartesian_core" }; + cmd << " --element_generation " << value[ hyp->myElementGeneration ]; } } - + + if ( !p_cs && hyp ) { + if ( hyp->myCoreSize >= 0 ) { + cmd << " --global_physical_size " << hyp->myCoreSize; + } + } + if ( !p_cm && hyp ) { if ( hyp->myCollisionMode >= 0 && hyp->myCollisionMode <= 1 ) { const char* value[] = { "decrease" , "stop" }; - cmd += " --collision_mode "; - cmd += value[ hyp->myCollisionMode ]; + cmd << " --collision_mode " << value[ hyp->myCollisionMode ]; } } if ( !p_am && hyp ) { int res = hyp->myAddMultinormals ? 0 : 1 ; const char* value[] = { "yes" , "no" }; - cmd += " --add_multinormals "; - cmd += value[ res ]; + cmd << " --add_multinormals " << value[ res ]; } if ( !p_mat && hyp ) { - cmd += " --multinormal_angle_threshold "; - cmd += hyp->myMultinormalsAngle; + cmd << " --multinormal_angle_threshold " << hyp->myMultinormalsAngle; } if ( !p_sn && hyp ) { int res = hyp->mySmoothNormals ? 0 : 1 ; const char* value[] = { "yes" , "no" }; - cmd += " --smooth_normals "; - cmd += value[ res ]; + cmd << " --smooth_normals " << value[ res ]; + } + + // options as text + if ( hyp && !hyp->myTextOption.empty() ) { + cmd += " " + hyp->myTextOption; } - #ifdef WIN32 - cmd += " < NUL"; + cmd << " < NUL"; #endif - //std::cout << "!!!!!CommandToRun end " << cmd.ToCString() << std::endl; + //std::cout << "!!!!!CommandToRun end " << cmd << std::endl; - return cmd.ToCString(); + return cmd; } //================================================================================ @@ -1908,18 +2037,18 @@ std::string HYBRIDPlugin_Hypothesis::GetFileName(const HYBRIDPlugin_Hypothesis* std::string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory(); const char lastChar = *aTmpDir.rbegin(); #ifdef WIN32 - if(lastChar != '\\') aTmpDir+='\\'; + if(lastChar != '\\') aTmpDir+='\\'; #else - if(lastChar != '/') aTmpDir+='/'; + if(lastChar != '/') aTmpDir+='/'; #endif - TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str(); - aGenericName += "HYBRID_"; - aGenericName += getpid(); - aGenericName += "_"; - aGenericName += Abs((Standard_Integer)(long) aGenericName.ToCString()); + SMESH_Comment aGenericName = aTmpDir; + aGenericName << "HYBRID_"; + aGenericName << getpid(); + aGenericName << "_"; + aGenericName << Abs((Standard_Integer)(long) aGenericName.c_str()); - return aGenericName.ToCString(); + return aGenericName; } //================================================================================