-// 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
//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 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
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;
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 << " ";
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());
+ isOK = static_cast<bool>(load >> d);
+ if (isOK)
+ myCoreSize = d;
+ else
+ load.clear(ios::badbit | load.rdstate());
std::string separator;
bool hasOptions = false;
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;
}
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;
if ( !nolayers && hyp )
{
cmd << " --boundary_layer_size_mode " << ( layersOnAllWrap ? "global" : "local" );
- cmd << " --boundary_layer_surface_tags ";
- if ( layersOnAllWrap )
- {
- cmd << " 3 ";
- }
- else
+
+ if ( !layersOnAllWrap )
{
- const std::vector<int>& faceIDs = hyp->GetFacesWithLayers();
- const bool hasEnforcedTria = !HYBRIDPlugin_Hypothesis::GetEnforcedTriangles(hyp).empty();
- for ( size_t i = 0; i < faceIDs.size(); ++i )
- cmd << faceIDs[i] << ",";
- if ( hasEnforcedTria )
- cmd << EnforcedTag();
- cmd << " --boundary_layer_initial_height_on_surface_tags ";
- for ( size_t i = 0; i < faceIDs.size() + hasEnforcedTria; ++i )
+ // 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" };
+ 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" };
const char* value[] = { "yes" , "no" };
cmd << " --smooth_normals " << value[ res ];
}
-
+
+ // options as text
+ if ( hyp && !hyp->myTextOption.empty() ) {
+ cmd += " " + hyp->myTextOption;
+ }
#ifdef WIN32
cmd << " < NUL";
#endif