-// Copyright (C) 2007-2015 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
//=============================================================================
//
#include "HYBRIDPlugin_Hypothesis.hxx"
-#include <SMESH_ProxyMesh.hxx>
-#include <SMESH_Group.hxx>
-#include <StdMeshers_QuadToTriaAdaptor.hxx>
-#include <TCollection_AsciiString.hxx>
+#include <SMESHDS_Mesh.hxx>
+
+#include <TopExp_Explorer.hxx>
#ifdef WIN32
#include <process.h>
//function : HYBRIDPlugin_Hypothesis
//=======================================================================
-HYBRIDPlugin_Hypothesis::HYBRIDPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen)
- : SMESH_Hypothesis(hypId, studyId, gen),
+HYBRIDPlugin_Hypothesis::HYBRIDPlugin_Hypothesis(int hypId, SMESH_Gen * gen)
+ : SMESH_Hypothesis(hypId, gen),
myToMeshHoles(DefaultMeshHoles()),
myLayersOnAllWrap(DefaultLayersOnAllWrap()),
myToMakeGroupsOfDomains(DefaultToMakeGroupsOfDomains()),
mySmoothNormals(DefaultSmoothNormals()),
myHeightFirstLayer(DefaultHeightFirstLayer()),
myBoundaryLayersProgression(DefaultBoundaryLayersProgression()),
+ myCoreSize(DefaultCoreSize()),
myMultinormalsAngle(DefaultMultinormalsAngle()),
myNbOfBoundaryLayers(DefaultNbOfBoundaryLayers()),
_enfVertexList(DefaultHYBRIDEnforcedVertexList()),
return myLayersOnAllWrap;
}
+//=======================================================================
+//function : SetFacesWithLayers
+//purpose : Set IDs of faces to grow the layers on
+//=======================================================================
+
+bool HYBRIDPlugin_Hypothesis::SetFacesWithLayers(const std::vector<int>& 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<int>& 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<int>& 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<int>& 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<int>& 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<int>& HYBRIDPlugin_Hypothesis::GetFacesWithSnapping() const
+{
+ return myFacesWithSnapping;
+}
+
//=======================================================================
//function : SetToMeshHoles
//=======================================================================
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
//=======================================================================
}
//=======================================================================
-//function : GetMultinormalsAngle
+//function : GetCoreSize
//=======================================================================
short HYBRIDPlugin_Hypothesis::GetNbOfBoundaryLayers() const
}
//=======================================================================
-//function : SetTextOption
+//function : SetAdvancedOption
//=======================================================================
-void HYBRIDPlugin_Hypothesis::SetTextOption(const std::string& option)
+void HYBRIDPlugin_Hypothesis::SetAdvancedOption(const std::string& option)
{
if ( myTextOption != option ) {
myTextOption = option;
}
//=======================================================================
-//function : GetTextOption
+//function : GetAdvancedOption
//=======================================================================
-std::string HYBRIDPlugin_Hypothesis::GetTextOption() const
+std::string HYBRIDPlugin_Hypothesis::GetAdvancedOption() const
{
return myTextOption;
}
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;
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;
}
// //////// CREATE ////////////
if (toCreate) {
toNotify = true;
- MESSAGE("Creating new enforced vertex");
_enfVertexList.insert(newEnfVertex);
if (theEntry == "") {
_coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
if (toNotify)
NotifySubMeshesHypothesisModification();
- MESSAGE("HYBRIDPlugin_Hypothesis::SetEnforcedVertex END");
return toNotify;
}
SMDS_ElemIteratorPtr eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType));
while ( eIt->more() )
theElemSet.insert( eIt->next() );
- MESSAGE("Add "<<theElemSet.size()<<" types["<<elementType<<"] from source mesh");
bool added = SetEnforcedElements( theElemSet, elementType, groupName);
if (added) {
THYBRIDEnforcedMesh* newEnfMesh = new THYBRIDEnforcedMesh();
//=======================================================================
bool HYBRIDPlugin_Hypothesis::SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName)
{
- MESSAGE("HYBRIDPlugin_Hypothesis::SetEnforcedGroup");
TIDSortedElemSet theElemSet;
if ( theIDs->length() == 0 ){MESSAGE("The source group is empty");}
for ( CORBA::ULong i = 0; i < theIDs->length(); i++) {
// while ( it->more() )
// theElemSet.insert( it->next() );
- MESSAGE("Add "<<theElemSet.size()<<" types["<<elementType<<"] from source group ");
bool added = SetEnforcedElements( theElemSet, elementType, groupName);
if (added) {
THYBRIDEnforcedMesh* newEnfMesh = new THYBRIDEnforcedMesh();
//=======================================================================
bool HYBRIDPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, std::string groupName)
{
- MESSAGE("HYBRIDPlugin_Hypothesis::SetEnforcedElements");
TIDSortedElemSet::const_iterator it = theElemSet.begin();
const SMDS_MeshElement* elem;
const SMDS_MeshNode* node;
nodeRet = _enfNodes.insert(make_pair(node,groupName));
added = added && nodeRet.second;
std::string msg = added ? "yes":"no";
- MESSAGE( "Node (" <<node->X()<<","<<node->Y()<<","<<node->Z()<< ") with ID " << node->GetID() <<" added ? " << msg);
}
else {
SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
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)
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;
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);
_groupsToRemove.insert((*it)->groupName);
_enfVertexList.erase(it);
toNotify = true;
- MESSAGE("Done");
}
if (toNotify)
//function : DefaultMaximumMemory
//=======================================================================
-#ifndef WIN32
-#include <sys/sysinfo.h>
-#else
+#if defined(WIN32)
#include <windows.h>
+#elif !defined(__APPLE__)
+#include <sys/sysinfo.h>
#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);
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;
}
std::string HYBRIDPlugin_Hypothesis::DefaultWorkingDirectory()
{
- TCollection_AsciiString aTmpDir;
+ std::string aTmpDir;
char *Tmp_dir = getenv("SALOME_TMP_DIR");
if(Tmp_dir != NULL) {
}
else {
#ifdef WIN32
- aTmpDir = TCollection_AsciiString("C:\\");
+ aTmpDir = "C:\\";
#else
- aTmpDir = TCollection_AsciiString("/tmp/");
+ aTmpDir = "/tmp/";
#endif
}
- return aTmpDir.ToCString();
+ return aTmpDir;
}
//=======================================================================
return 1.0;
}
+//=======================================================================
+//function : DefaultCoreSize
+//=======================================================================
+double HYBRIDPlugin_Hypothesis::DefaultCoreSize()
+{
+ return 0.0;
+}
+
//=======================================================================
//function : DefaultMultinormalsAngle
//=======================================================================
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()) {
}
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;
}
else
load.clear(ios::badbit | load.rdstate());
- if ( !myWorkingDirectory.empty() ) {
- isOK = static_cast<bool>(load >> i);
- if (isOK)
- myKeepFiles = i;
- else
- load.clear(ios::badbit | load.rdstate());
- }
-
isOK = static_cast<bool>(load >> i);
if (isOK)
myVerboseLevel = (short) i;
else
load.clear(ios::badbit | load.rdstate());
+ isOK = static_cast<bool>(load >> d);
+ if (isOK)
+ myCoreSize = d;
+ else
+ load.clear(ios::badbit | load.rdstate());
std::string separator;
bool hasOptions = false;
name += txt;
}
}
- MESSAGE("name: " <<name);
}
if (txt == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
isOK = static_cast<bool>(load >> txt); // __END_ENTRY__
if (txt != "__END_ENTRY__")
throw std::exception();
- MESSAGE("entry: " << entry);
}
if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
groupName += txt;
}
}
- MESSAGE("groupName: " << groupName);
}
if (txt == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
isOK = static_cast<bool>(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__
if (txt != "__END_SIZE__") {
throw std::exception();
}
- MESSAGE("size: " << size);
}
}
isOK = static_cast<bool>(load >> txt); // __BEGIN_VERTEX__
name += txt;
}
}
- MESSAGE("name: " <<name);
}
if (txt == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
isOK = static_cast<bool>(load >> txt); // __END_ENTRY__
if (txt != "__END_ENTRY__")
throw std::exception();
- MESSAGE("entry: " << entry);
}
if (txt == "__BEGIN_ELEM_TYPE__") { // __BEGIN_ELEM_TYPE__
isOK = static_cast<bool>(load >> txt); // __END_ELEM_TYPE__
if (txt != "__END_ELEM_TYPE__")
throw std::exception();
- MESSAGE("elementType: " << elementType);
}
if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
groupName += txt;
}
} // while
- MESSAGE("groupName: " << groupName);
} // if
if (txt == "__PERSIST_ID__") {
isOK = static_cast<bool>(load >> persistID);
- MESSAGE("persistID: " << persistID);
}
std::cout << "isOK: " << isOK << std::endl;
} // while
} // while
} // if
+ if ( hasEnforcedMeshes )
+ isOK = static_cast<bool>(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<bool>(load >> i)) )
+ myFacesWithLayers.push_back( i );
+ }
+ }
+
+ isOK = static_cast<bool>(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<bool>(load >> i)) )
+ myFacesWithImprinting.push_back( i );
+ }
+ }
+
+ isOK = static_cast<bool>(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<bool>(load >> i)) )
+ myFacesWithSnapping.push_back( i );
+ }
+ }
+
return load;
}
//================================================================================
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->myTextOption.find("-h") != std::string::npos );
- bool p_v = ( hyp->myTextOption.find("-v ") != std::string::npos );
- //bool p_i = ( hyp->myTextOption.find("-i") != std::string::npos );
- //bool p_o = ( hyp->myTextOption.find("-o") != std::string::npos );
- bool p_mnot = ( hyp->myTextOption.find("--max_number_of_threads ") != std::string::npos );
- bool p_blsi = ( hyp->myTextOption.find("--boundary_layer_surface_tags ") != std::string::npos );
- bool p_blii = ( hyp->myTextOption.find("--boundary_layer_imprint_tags ") != std::string::npos );
- bool p_blsd = ( hyp->myTextOption.find("--normal_direction ") != std::string::npos );
- bool p_hotfl = ( hyp->myTextOption.find("--boundary_layer_global_initial_height ") != std::string::npos );
- bool p_nobl = ( hyp->myTextOption.find("--number_of_boundary_layers ") != std::string::npos );
- bool p_blgp = ( hyp->myTextOption.find("--boundary_layer_geometric_progression ") != std::string::npos );
- bool p_eg = ( hyp->myTextOption.find("--element_generation ") != std::string::npos );
- bool p_cm = ( hyp->myTextOption.find("--collision_mode ") != std::string::npos );
- bool p_am = ( hyp->myTextOption.find("--add_multinormals ") != std::string::npos );
- bool p_mat = ( hyp->myTextOption.find("--multinormal_angle_threshold ") != std::string::npos );
- bool p_sn = ( 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 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 :
+ //- boundary_layer_max_element_angle
bool nolayers = false;
- bool layersOnAllWrap = hyp->myLayersOnAllWrap;
-
+ bool layersOnAllWrap = hyp ? hyp->myLayersOnAllWrap : DefaultLayersOnAllWrap();
+
//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();
- }
-
- if ( !p_v && hyp ) {
- cmd += " --verbose ";
- cmd += hyp->myVerboseLevel;
+ std::cout << "!!!!! CommandToRun help only !!!! " << cmd << std::endl;
+ return cmd;
}
- 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;
- //}
-
+ if ( !p_v && hyp )
+ cmd << " --verbose " << hyp->myVerboseLevel;
+
+ if ( !p_mnot && hyp )
+ cmd << " --max_number_of_threads " << 8; //TODO getenv NB CPU
+
//no layers?
if ( !p_nobl && hyp ) {
if ( hyp->myNbOfBoundaryLayers < 1 ) nolayers = true;
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<int>& 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<int>& 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<int>& 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;
}
//================================================================================
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;
}
//================================================================================
std::string HYBRIDPlugin_Hypothesis::GetExeName()
{
//call mg-hybrid.bash is script which assumes new project version(s) mg-hybrid.exe in the prerequisite base and special? licence.
+#ifdef WIN32
+ return "mg-hybrid.exe";
+#else
return "mg-hybrid.bash";
+#endif
}
//================================================================================