*) echo "Installing $${filen}" ; cp -rp $${filen} $(DESTDIR)$(docdir)/gui/GHS3DPLUGIN ;; \
esac ; \
done ;
- cp -rp $(srcdir)/images/head.png $(DESTDIR)$(docdir)/gui/GHS3DPLUGIN/ghs3dpluginpy_doc/ ;
+ cp -rfp $(srcdir)/images/head.png $(DESTDIR)$(docdir)/gui/GHS3DPLUGIN/ghs3dpluginpy_doc/ ;
uninstall-local:
rm -rf $(DESTDIR)$(docdir)/gui/GHS3DPLUGIN
- NODE
- EDGE
- FACE
-- If a size is given, the mesh will be refined around the enforced
-elements given the size (not available yet)
- If a group name is given, the enforced elements will be added to
the group. If the group does not exist, it is created.
string entry;
SMESH::ElementType elementType;
string groupName;
- double size;
};
typedef sequence<GHS3DEnforcedMesh> GHS3DEnforcedMeshList;
boolean SetEnforcedMesh(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType) raises (SALOME::SALOME_Exception);
boolean SetEnforcedMeshWithGroup(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, in string groupName) raises (SALOME::SALOME_Exception);
+
+ /* OBSOLETE FUNCTIONS */
boolean SetEnforcedMeshSize(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, in double size) raises (SALOME::SALOME_Exception);
boolean SetEnforcedMeshSizeWithGroup(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, in double size, in string groupName) raises (SALOME::SALOME_Exception);
+ /* OBSOLETE FUNCTIONS */
+
GHS3DEnforcedMeshList GetEnforcedMeshes();
void ClearEnforcedMeshes();
/*!
* Set/get/unset an enforced vertex (private method for GUI)
*/
- boolean p_SetEnforcedMesh(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType,
- in double size, in string groupName) raises (SALOME::SALOME_Exception);
+ boolean p_SetEnforcedMesh(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, in string name, in string groupName) raises (SALOME::SALOME_Exception);
};
};
groupDone = true;
}
if (!groupDone)
- throw SALOME_Exception(LOCALIZED("A enforced vertex node was not added to a group"));
+ throw SALOME_Exception(LOCALIZED("A given element was not added to a group"));
}
if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
continue;
- double size = theNodeIDToSizeMap.find(nodeIt->first->GetID())->second;
+// double size = theNodeIDToSizeMap.find(nodeIt->first->GetID())->second;
// theGhs3dIdToNodeMap.insert( make_pair( nbNodes + i, (*nodeIt) ));
// MESSAGE("Adding enforced node (" << x << "," << y <<"," << z << ")");
// X Y Z PHY_SIZE DUMMY_INT
<< x << space
<< y << space
<< z << space
- << size << space
+ << -1 << space
<< dummyint << space;
theFile << std::endl;
theEnforcedNodeIdToGhs3dIdMap.insert( make_pair( nodeIt->first->GetID(), aGhs3dID ));
_enfEdges(TIDSortedElemGroupMap()),
_enfTriangles(TIDSortedElemGroupMap()),
_nodeIDToSizeMap(DefaultID2SizeMap()),
- _elementIDToSizeMap(DefaultID2SizeMap()),
_groupsToRemove(DefaultGroupsToRemove())
{
_name = "GHS3D_Parameters";
//=======================================================================
//function : SetEnforcedMesh
//=======================================================================
-bool GHS3DPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, std::string name, std::string entry, double size, std::string groupName)
+bool GHS3DPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName)
{
TIDSortedElemSet theElemSet;
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, size, groupName);
+ bool added = SetEnforcedElements( theElemSet, elementType, groupName);
if (added) {
TGHS3DEnforcedMesh* newEnfMesh = new TGHS3DEnforcedMesh();
newEnfMesh->name = name;
newEnfMesh->entry = entry;
newEnfMesh->elementType = elementType;
- newEnfMesh->size = size;
newEnfMesh->groupName = groupName;
TGHS3DEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh);
//=======================================================================
//function : SetEnforcedGroup
//=======================================================================
-bool GHS3DPlugin_Hypothesis::SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, double size, std::string groupName)
+bool GHS3DPlugin_Hypothesis::SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName)
{
MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedGroup");
TIDSortedElemSet theElemSet;
// theElemSet.insert( it->next() );
MESSAGE("Add "<<theElemSet.size()<<" types["<<elementType<<"] from source group ");
- bool added = SetEnforcedElements( theElemSet, elementType, size, groupName);
+ bool added = SetEnforcedElements( theElemSet, elementType, groupName);
if (added) {
TGHS3DEnforcedMesh* newEnfMesh = new TGHS3DEnforcedMesh();
newEnfMesh->name = name;
newEnfMesh->entry = entry;
newEnfMesh->elementType = elementType;
- newEnfMesh->size = size;
newEnfMesh->groupName = groupName;
TGHS3DEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh);
//=======================================================================
//function : SetEnforcedElements
//=======================================================================
-bool GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, double size, std::string groupName)
+bool GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, std::string groupName)
{
MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedElements");
TIDSortedElemSet::const_iterator it = theElemSet.begin();
const SMDS_MeshElement* elem;
const SMDS_MeshNode* node;
- bool added = false;
+ bool added = true;
+ pair<TIDSortedNodeGroupMap::iterator,bool> nodeRet;
+ pair<TIDSortedElemGroupMap::iterator,bool> elemRet;
+
for (;it != theElemSet.end();++it)
{
elem = (*it);
case SMESH::NODE:
node = dynamic_cast<const SMDS_MeshNode*>(elem);
if (node) {
- _enfNodes.insert(make_pair(node,groupName));
- _nodeIDToSizeMap.insert(make_pair(node->GetID(), size));
- added = true;
+ nodeRet = _enfNodes.insert(make_pair(node,groupName));
+ added = added && nodeRet.second;
+ 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();
for (;nodeIt->more();) {
node = dynamic_cast<const SMDS_MeshNode*>(nodeIt->next());
- _enfNodes.insert(make_pair(node,groupName));
- _nodeIDToSizeMap.insert(make_pair(node->GetID(), size));
+ nodeRet = _enfNodes.insert(make_pair(node,groupName));
+ added = added && nodeRet.second;
}
- added = true;
+// added = true;s
}
break;
case SMESH::EDGE:
if (elem->GetType() == SMDSAbs_Edge) {
- _enfEdges.insert(make_pair(elem,groupName));
- _elementIDToSizeMap.insert(make_pair(elem->GetID(), size));
- added = true;
+ 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();
- _enfEdges.insert(make_pair(anEdge,groupName));
- _elementIDToSizeMap.insert(make_pair(anEdge->GetID(), size));
+ elemRet = _enfEdges.insert(make_pair(anEdge,groupName));
+ added = added && elemRet.second;
}
- added = true;
}
break;
case SMESH::FACE:
if (elem->GetType() == SMDSAbs_Face)
{
if (elem->NbCornerNodes() == 3) {
- _enfTriangles.insert(make_pair(elem,groupName));
- _elementIDToSizeMap.insert(make_pair(elem->GetID(), size));
- added = true;
+ elemRet = _enfTriangles.insert(make_pair(elem,groupName));
+ added = added && elemRet.second;
}
}
else if (elem->GetType() > SMDSAbs_Face) { // Group of faces
for (;it->more();) {
const SMDS_MeshElement* aFace = it->next();
if (aFace->NbCornerNodes() == 3) {
- _enfTriangles.insert(make_pair(aFace,groupName));
- _elementIDToSizeMap.insert(make_pair(aFace->GetID(), size));
- added = true;
+ elemRet = _enfTriangles.insert(make_pair(aFace,groupName));
+ added = added && elemRet.second;
}
}
}
_enfEdges.clear();
_enfTriangles.clear();
_nodeIDToSizeMap.clear();
- _elementIDToSizeMap.clear();
_enfMeshList.clear();
_entryEnfMeshMap.clear();
NotifySubMeshesHypothesisModification();
TGHS3DEnforcedVertexList::iterator it = _enfVertexList.begin();
if (it != _enfVertexList.end()) {
- save << "__ENFORCED_VERTICES_BEGIN__ ";
+ save << " " << "__ENFORCED_VERTICES_BEGIN__ ";
for ( ; it != _enfVertexList.end(); ++it ) {
TGHS3DEnforcedVertex *enfVertex = (*it);
save << " " << "__BEGIN_VERTEX__";
save << " " << "__END_SIZE__";
save << " " << "__END_VERTEX__";
}
- save << "__ENFORCED_VERTICES_END__ ";
+ save << " " << "__ENFORCED_VERTICES_END__ ";
}
+ TGHS3DEnforcedMeshList::iterator it_mesh = _enfMeshList.begin();
+ if (it_mesh != _enfMeshList.end()) {
+ save << " " << "__ENFORCED_MESHES_BEGIN__ ";
+ for ( ; it_mesh != _enfMeshList.end(); ++it_mesh ) {
+ TGHS3DEnforcedMesh *enfMesh = (*it_mesh);
+ save << " " << "__BEGIN_ENF_MESH__";
+
+ save << " " << "__BEGIN_NAME__";
+ save << " " << enfMesh->name;
+ save << " " << "__END_NAME__";
+
+ save << " " << "__BEGIN_ENTRY__";
+ save << " " << enfMesh->entry;
+ save << " " << "__END_ENTRY__";
+
+ save << " " << "__BEGIN_ELEM_TYPE__";
+ save << " " << (int)enfMesh->elementType;
+ save << " " << "__END_ELEM_TYPE__";
+
+ if (!enfMesh->groupName.empty()) {
+ save << " " << "__BEGIN_GROUP__";
+ save << " " << enfMesh->groupName;
+ save << " " << "__END_GROUP__";
+ }
+ save << " " << "__END_ENF_MESH__";
+ std::cout << "Saving of enforced mesh " << enfMesh->name.c_str() << " done" << std::endl;
+ }
+ save << " " << "__ENFORCED_MESHES_END__ ";
+ }
return save;
}
std::istream & GHS3DPlugin_Hypothesis::LoadFrom(std::istream & load)
{
- bool isOK = true;
- int i;
-
- isOK = (load >> i);
- if (isOK)
- myToMeshHoles = i;
- else
- load.clear(ios::badbit | load.rdstate());
-
- isOK = (load >> i);
- if (isOK)
- myMaximumMemory = i;
- else
- load.clear(ios::badbit | load.rdstate());
-
- isOK = (load >> i);
- if (isOK)
- myInitialMemory = i;
- else
- load.clear(ios::badbit | load.rdstate());
-
- isOK = (load >> i);
- if (isOK)
- myOptimizationLevel = i;
- else
- load.clear(ios::badbit | load.rdstate());
-
- isOK = (load >> myWorkingDirectory);
- if (isOK) {
- if ( myWorkingDirectory == "0") { // myWorkingDirectory was empty
- myKeepFiles = false;
- myWorkingDirectory.clear();
- }
- else if ( myWorkingDirectory == "1" ) {
- myKeepFiles = true;
- myWorkingDirectory.clear();
- }
- }
- else
- load.clear(ios::badbit | load.rdstate());
-
- if ( !myWorkingDirectory.empty() ) {
- isOK = (load >> i);
- if (isOK)
- myKeepFiles = i;
- else
- load.clear(ios::badbit | load.rdstate());
- }
-
- isOK = (load >> i);
- if (isOK)
- myVerboseLevel = (short) i;
- else
- load.clear(ios::badbit | load.rdstate());
-
- isOK = (load >> i);
- if (isOK)
- myToCreateNewNodes = (bool) i;
- else
- load.clear(ios::badbit | load.rdstate());
-
- isOK = (load >> i);
- if (isOK)
- myToUseBoundaryRecoveryVersion = (bool) i;
- else
- load.clear(ios::badbit | load.rdstate());
-
- isOK = (load >> i);
- if (isOK)
- myToUseFemCorrection = (bool) i;
- else
- load.clear(ios::badbit | load.rdstate());
-
- isOK = (load >> i);
- if (isOK)
- myToRemoveCentralPoint = (bool) i;
- else
- load.clear(ios::badbit | load.rdstate());
-
- std::string separator;
- bool hasOptions = false;
- bool hasEnforcedVertices = false;
- isOK = (load >> separator);
-
- if (isOK) {
- if (separator == "__OPTIONS_BEGIN__")
- hasOptions = true;
- else if (separator == "__ENFORCED_VERTICES_BEGIN__")
- hasEnforcedVertices = true;
- }
+ bool isOK = true;
+ int i;
+
+ isOK = (load >> i);
+ if (isOK)
+ myToMeshHoles = i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ isOK = (load >> i);
+ if (isOK)
+ myMaximumMemory = i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ isOK = (load >> i);
+ if (isOK)
+ myInitialMemory = i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ isOK = (load >> i);
+ if (isOK)
+ myOptimizationLevel = i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ isOK = (load >> myWorkingDirectory);
+ if (isOK) {
+ if ( myWorkingDirectory == "0") { // myWorkingDirectory was empty
+ myKeepFiles = false;
+ myWorkingDirectory.clear();
+ }
+ else if ( myWorkingDirectory == "1" ) {
+ myKeepFiles = true;
+ myWorkingDirectory.clear();
+ }
+ }
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ if ( !myWorkingDirectory.empty() ) {
+ isOK = (load >> i);
+ if (isOK)
+ myKeepFiles = i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+ }
+
+ isOK = (load >> i);
+ if (isOK)
+ myVerboseLevel = (short) i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ isOK = (load >> i);
+ if (isOK)
+ myToCreateNewNodes = (bool) i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ isOK = (load >> i);
+ if (isOK)
+ myToUseBoundaryRecoveryVersion = (bool) i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ isOK = (load >> i);
+ if (isOK)
+ myToUseFemCorrection = (bool) i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ isOK = (load >> i);
+ if (isOK)
+ myToRemoveCentralPoint = (bool) i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ std::string separator;
+ bool hasOptions = false;
+ bool hasEnforcedVertices = false;
+ bool hasEnforcedMeshes = false;
+ isOK = (load >> separator);
+
+ if (isOK) {
+ if (separator == "__OPTIONS_BEGIN__")
+ hasOptions = true;
+ else if (separator == "__ENFORCED_VERTICES_BEGIN__")
+ hasEnforcedVertices = true;
+ else if (separator == "__ENFORCED_MESHES_BEGIN__")
+ hasEnforcedMeshes = true;
+ }
+
+ if (hasOptions) {
+ std::string txt;
+ while (isOK) {
+ isOK = (load >> txt);
+ if (isOK) {
+ if (txt == "__OPTIONS_END__") {
+ if (!myTextOption.empty()) {
+ // Remove last space
+ myTextOption.erase(myTextOption.end()-1);
+ }
+ isOK = false;
+ break;
+ }
+ myTextOption += txt;
+ myTextOption += " ";
+ }
+ }
+ }
+
+ if (hasOptions) {
+ isOK = (load >> separator);
+ if (isOK && separator == "__ENFORCED_VERTICES_BEGIN__")
+ hasEnforcedVertices = true;
+ if (isOK && separator == "__ENFORCED_MESHES_BEGIN__")
+ hasEnforcedMeshes = true;
+ }
- if (hasOptions) {
- std::string txt;
- while (isOK) {
- isOK = (load >> txt);
- if (isOK) {
- if (txt == "__OPTIONS_END__") {
- if (!myTextOption.empty()) {
- // Remove last space
- myTextOption.erase(myTextOption.end()-1);
- }
- isOK = false;
- break;
- }
- myTextOption += txt;
- myTextOption += " ";
- }
- }
- }
-
- if (hasOptions) {
- isOK = (load >> separator);
- if (isOK && separator == "__ENFORCED_VERTICES_BEGIN__")
- hasEnforcedVertices = true;
+ if (hasEnforcedVertices) {
+ std::string txt, name, entry, groupName;
+ double size, coords[3];
+ bool isCompound;
+ bool hasCoords = false;
+ isOK = (load >> txt); // __BEGIN_VERTEX__
+ while (isOK) {
+ if (txt == "__ENFORCED_VERTICES_END__")
+ isOK = false;
+
+ TGHS3DEnforcedVertex *enfVertex = new TGHS3DEnforcedVertex();
+ while (isOK) {
+ isOK = (load >> txt);
+ if (txt == "__END_VERTEX__") {
+ enfVertex->name = name;
+ enfVertex->geomEntry = entry;
+ enfVertex->isCompound = isCompound;
+ enfVertex->groupName = groupName;
+ enfVertex->coords.clear();
+ if (hasCoords)
+ enfVertex->coords.assign(coords,coords+3);
+
+ _enfVertexList.insert(enfVertex);
+
+ if (enfVertex->coords.size())
+ _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
+ if (!enfVertex->geomEntry.empty())
+ _geomEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
+
+ name.clear();
+ entry.clear();
+ groupName.clear();
+ hasCoords = false;
+ isOK = false;
+ }
+
+ if (txt == "__BEGIN_NAME__") { // __BEGIN_NAME__
+ while (isOK && (txt != "__END_NAME__")) {
+ isOK = (load >> txt);
+ if (txt != "__END_NAME__") {
+ if (!name.empty())
+ name += " ";
+ name += txt;
+ }
+ }
+ MESSAGE("name: " <<name);
+ }
+
+ if (txt == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
+ isOK = (load >> entry);
+ isOK = (load >> isCompound);
+ isOK = (load >> txt); // __END_ENTRY__
+ if (txt != "__END_ENTRY__")
+ throw std::exception();
+ MESSAGE("entry: " << entry);
+ }
+
+ if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
+ while (isOK && (txt != "__END_GROUP__")) {
+ isOK = (load >> txt);
+ if (txt != "__END_GROUP__") {
+ if (!groupName.empty())
+ groupName += " ";
+ groupName += txt;
+ }
+ }
+ MESSAGE("groupName: " << groupName);
+ }
+
+ if (txt == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
+ hasCoords = true;
+ isOK = (load >> coords[0] >> coords[1] >> coords[2]);
+ isOK = (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__
+ isOK = (load >> size);
+ isOK = (load >> txt); // __END_ENTRY__
+ if (txt != "__END_SIZE__") {
+ throw std::exception();
+ }
+ MESSAGE("size: " << size);
+ }
+ }
+ isOK = (load >> txt); // __BEGIN_VERTEX__
+ }
}
if (hasEnforcedVertices) {
- std::string txt, name, entry, groupName;
- double size, coords[3];
- bool isCompound;
- bool hasCoords = false;
- while (isOK) {
- isOK = (load >> txt); // __BEGIN_VERTEX__
- if (isOK) {
- if (txt == "__ENFORCED_VERTICES_END__")
- isOK = false;
-
- TGHS3DEnforcedVertex *enfVertex = new TGHS3DEnforcedVertex();
- while (isOK) {
- isOK = (load >> txt);
- if (txt == "__END_VERTEX__") {
- enfVertex->name = name;
- enfVertex->geomEntry = entry;
- enfVertex->isCompound = isCompound;
- enfVertex->groupName = groupName;
- enfVertex->coords.clear();
- if (hasCoords)
- enfVertex->coords.assign(coords,coords+3);
-
- _enfVertexList.insert(enfVertex);
-
- if (enfVertex->coords.size())
- _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
- if (!enfVertex->geomEntry.empty())
- _geomEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
-
- name.clear();
- entry.clear();
- groupName.clear();
- hasCoords = false;
- isOK = false;
- }
-
- if (txt == "__BEGIN_NAME__") { // __BEGIN_NAME__
- while (isOK && (txt != "__END_NAME__")) {
- isOK = (load >> txt);
- if (txt != "__END_NAME__") {
- if (!name.empty())
- name += " ";
- name += txt;
- }
- }
- MESSAGE("name: " <<name);
- }
-
- if (txt == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
- isOK = (load >> entry);
- isOK = (load >> isCompound);
- isOK = (load >> txt); // __END_ENTRY__
- if (txt != "__END_ENTRY__")
- throw std::exception();
- MESSAGE("entry: " << entry);
- }
-
- if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
- while (isOK && (txt != "__END_GROUP__")) {
- isOK = (load >> txt);
- if (txt != "__END_GROUP__") {
- if (!groupName.empty())
- groupName += " ";
- groupName += txt;
- }
- }
- MESSAGE("groupName: " << groupName);
- }
-
- if (txt == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
- hasCoords = true;
- isOK = (load >> coords[0] >> coords[1] >> coords[2]);
- isOK = (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__
- isOK = (load >> size);
- isOK = (load >> txt); // __END_ENTRY__
- if (txt != "__END_SIZE__") {
- throw std::exception();
- }
- MESSAGE("size: " << size);
- }
- }
- }
- }
+ isOK = (load >> separator);
+ if (isOK && separator == "__ENFORCED_MESHES_BEGIN__")
+ hasEnforcedMeshes = true;
}
+ if (hasEnforcedMeshes) {
+ std::string txt, name, entry, groupName;
+ int elementType = -1;
+ isOK = (load >> txt); // __BEGIN_ENF_MESH__
+ while (isOK) {
+// if (isOK) {
+ if (txt == "__ENFORCED_MESHES_END__")
+ isOK = false;
+
+ TGHS3DEnforcedMesh *enfMesh = new TGHS3DEnforcedMesh();
+ while (isOK) {
+ isOK = (load >> txt);
+ if (txt == "__END_ENF_MESH__") {
+ enfMesh->name = name;
+ enfMesh->entry = entry;
+ enfMesh->elementType = (SMESH::ElementType)elementType;
+ enfMesh->groupName = groupName;
+
+ _enfMeshList.insert(enfMesh);
+ std::cout << "Restoring of enforced mesh " <<name << " done" << std::endl;
+
+ name.clear();
+ entry.clear();
+ elementType = -1;
+ groupName.clear();
+ isOK = false;
+ }
+
+ if (txt == "__BEGIN_NAME__") { // __BEGIN_NAME__
+ while (isOK && (txt != "__END_NAME__")) {
+ isOK = (load >> txt);
+ if (txt != "__END_NAME__") {
+ if (!name.empty())
+ name += " ";
+ name += txt;
+ }
+ }
+ MESSAGE("name: " <<name);
+ }
+
+ if (txt == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
+ isOK = (load >> entry);
+ isOK = (load >> txt); // __END_ENTRY__
+ if (txt != "__END_ENTRY__")
+ throw std::exception();
+ MESSAGE("entry: " << entry);
+ }
+
+ if (txt == "__BEGIN_ELEM_TYPE__") { // __BEGIN_ELEM_TYPE__
+ isOK = (load >> elementType);
+ isOK = (load >> txt); // __END_ELEM_TYPE__
+ if (txt != "__END_ELEM_TYPE__")
+ throw std::exception();
+ MESSAGE("elementType: " << elementType);
+ }
+
+ if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
+ while (isOK && (txt != "__END_GROUP__")) {
+ isOK = (load >> txt);
+ if (txt != "__END_GROUP__") {
+ if (!groupName.empty())
+ groupName += " ";
+ groupName += txt;
+ }
+ } // while
+ MESSAGE("groupName: " << groupName);
+ } // if
+ std::cout << "isOK: " << isOK << std::endl;
+ } // while
+// } // if
+ isOK = (load >> txt); // __BEGIN_ENF_MESH__
+ } // while
+ } // if
+
return load;
}
return hyp ? hyp->_GetNodeIDToSizeMap(): DefaultID2SizeMap();
}
-GHS3DPlugin_Hypothesis::TID2SizeMap GHS3DPlugin_Hypothesis::GetElementIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp)
-{
- return hyp ? hyp->_GetElementIDToSizeMap(): DefaultID2SizeMap();
-}
-
GHS3DPlugin_Hypothesis::TSetStrings GHS3DPlugin_Hypothesis::GetGroupsToRemove(const GHS3DPlugin_Hypothesis* hyp)
{
return hyp ? hyp->_GetGroupsToRemove(): DefaultGroupsToRemove();
struct TGHS3DEnforcedMesh {
std::string name;
std::string entry;
- SMESH::ElementType elementType;
std::string groupName;
- double size;
+ SMESH::ElementType elementType;
};
struct CompareGHS3DEnforcedMesh {
};
typedef std::set< TGHS3DEnforcedMesh*, CompareGHS3DEnforcedMesh > TGHS3DEnforcedMeshList;
// Map mesh entry / Enforced mesh list
- // ex: 0:1:2:1 -> [ ("Mesh_1", "0:1:2:1", TopAbs_NODE, "", -1),
- // ("Mesh_1", "0:1:2:1", TopAbs_EDGE, "edge group", 5)]
+ // ex: 0:1:2:1 -> [ ("Mesh_1", "0:1:2:1", TopAbs_NODE, ""),
+ // ("Mesh_1", "0:1:2:1", TopAbs_EDGE, "edge group")]
typedef std::map< std::string, TGHS3DEnforcedMeshList > TEntryGHS3DEnforcedMeshListMap;
typedef std::map<int,double> TID2SizeMap;
+
+ struct TIDMeshIDCompare {
+ bool operator () (const SMDS_MeshElement* e1, const SMDS_MeshElement* e2) const
+ { return e1->getMeshId() == e2->getMeshId() ? e1->GetID() < e2->GetID() : e1->getMeshId() < e2->getMeshId() ; }
+ };
- typedef std::map<const SMDS_MeshElement*, std::string, TIDCompare > TIDSortedElemGroupMap;
- typedef std::map<const SMDS_MeshNode*, std::string, TIDCompare > TIDSortedNodeGroupMap;
+ typedef std::map<const SMDS_MeshElement*, std::string, TIDMeshIDCompare > TIDSortedElemGroupMap;
+ typedef std::map<const SMDS_MeshNode*, std::string, TIDMeshIDCompare > TIDSortedNodeGroupMap;
typedef std::set<std::string> TSetStrings;
static const char* GetHypType() { return "GHS3D_Parameters"; }
/*!
* To set enforced elements
*/
- bool SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, std::string name, std::string entry, double size, std::string groupName = "");
- bool SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, double size, std::string groupName = "");
- bool SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, double size, std::string groupName = "");
+ bool SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName = "");
+ bool SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName = "");
+ bool SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, std::string groupName = "");
const TGHS3DEnforcedMeshList _GetEnforcedMeshes() const { return _enfMeshList; }
const TEntryGHS3DEnforcedMeshListMap _GetEnforcedMeshesByEntry() const { return _entryEnfMeshMap; }
void ClearEnforcedMeshes();
const TIDSortedElemGroupMap _GetEnforcedEdges() const { return _enfEdges; }
const TIDSortedElemGroupMap _GetEnforcedTriangles() const { return _enfTriangles; }
const TID2SizeMap _GetNodeIDToSizeMap() const {return _nodeIDToSizeMap; }
- const TID2SizeMap _GetElementIDToSizeMap() const {return _elementIDToSizeMap; }
const TSetStrings _GetGroupsToRemove() const {return _groupsToRemove; }
/*!
* \brief Return the enforced vertices
static TIDSortedElemGroupMap GetEnforcedEdges(const GHS3DPlugin_Hypothesis* hyp);
static TIDSortedElemGroupMap GetEnforcedTriangles(const GHS3DPlugin_Hypothesis* hyp);
static TID2SizeMap GetNodeIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp);
- static TID2SizeMap GetElementIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp);
static TSetStrings GetGroupsToRemove(const GHS3DPlugin_Hypothesis* hyp);
void ClearGroupsToRemove();
TIDSortedElemGroupMap _enfEdges;
TIDSortedElemGroupMap _enfTriangles;
TID2SizeMap _nodeIDToSizeMap;
- TID2SizeMap _elementIDToSizeMap;
std::map<std::string, TIDSortedElemSet > _entryToElemsMap;
TSetStrings _groupsToRemove;
enfMesh->elementType = currentMesh->elementType;
// Group Name
enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
- // Size
- enfMesh->size = currentMesh->size;
result[i]=enfMesh;
}
throw (SALOME::SALOME_Exception)
{
#if GHS3D_VERSION >= 42
- return p_SetEnforcedMesh(theSource, theType, -1.0, theGroupName);
-// bool res = p_SetEnforcedMesh(theSource, theType, -1.0, theGroupName);
-// SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
-// SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
-// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
-// if (theGroup_i || theGroupOnGeom_i)
-// {
-// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
-// << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
-// }
-// else if (theMesh_i)
-// {
-// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
-// << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
-// }
-// return res;
+ return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
#else
SALOME::ExceptionStruct ExDescription;
ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
// MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
#if GHS3D_VERSION >= 42
return p_SetEnforcedMesh(theSource, theType);
-// bool res = p_SetEnforcedMesh(theSource, theType);
-// SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
-// SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
-// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
-// if (theGroup_i || theGroupOnGeom_i)
-// {
-// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
-// << theSource << ", " << theType << " )";
-// }
-// else if (theMesh_i)
-// {
-// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
-// << theSource << ".GetMesh(), " << theType << " )";
-// }
-// return res;
#else
SALOME::ExceptionStruct ExDescription;
ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
}
/*!
- * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size. The elements will be grouped in theGroupName.
+ * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size. The elements will be grouped in theGroupName.
*/
bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
throw (SALOME::SALOME_Exception)
{
#if GHS3D_VERSION >= 42
- if (theSize < 0) {
- SALOME::ExceptionStruct ExDescription;
- ExDescription.text = "Size cannot be negative";
- ExDescription.type = SALOME::BAD_PARAM;
- ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
- ExDescription.lineNumber = 781;
- throw SALOME::SALOME_Exception(ExDescription);
- }
-
- return p_SetEnforcedMesh(theSource, theType, theSize, theGroupName);
-// bool res = p_SetEnforcedMesh(theSource, theType, theSize, theGroupName);
-// SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
-// SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
-// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
-// if (theGroup_i || theGroupOnGeom_i)
-// {
-// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
-// << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
-// }
-// else if (theMesh_i)
-// {
-// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
-// << theSource << ".GetMesh(), " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
-// }
-// return res;
+ return p_SetEnforcedMesh(theSource, theType, "", theGroupName);
#else
SALOME::ExceptionStruct ExDescription;
ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
}
/*!
- * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
+ * \brief OBSOLETE FUNCTION - Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size.
*/
bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
throw (SALOME::SALOME_Exception)
{
#if GHS3D_VERSION >= 42
- if (theSize < 0) {
- SALOME::ExceptionStruct ExDescription;
- ExDescription.text = "Size cannot be negative";
- ExDescription.type = SALOME::BAD_PARAM;
- ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
- ExDescription.lineNumber = 781;
- throw SALOME::SALOME_Exception(ExDescription);
- }
- return p_SetEnforcedMesh(theSource, theType, theSize);
-// bool res = p_SetEnforcedMesh(theSource, theType, theSize);
-// SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
-// SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
-// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
-// if (theGroup_i || theGroupOnGeom_i)
-// {
-// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
-// << theSource << ", " << theType << ", " << theSize << " )";
-// }
-// else if (theMesh_i)
-// {
-// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
-// << theSource << ".GetMesh(), " << theType << ", " << theSize << " )";
-// }
-// return res;
+ return p_SetEnforcedMesh(theSource, theType);
#else
SALOME::ExceptionStruct ExDescription;
ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
#endif
}
-bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
+bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
throw (SALOME::SALOME_Exception)
{
MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
throw SALOME::SALOME_Exception(ExDescription);
}
- if ((theType != SMESH::NODE) && (theType != SMESH::EDGE) && (theType != SMESH::FACE))
- {
- return false;
-// SALOME::ExceptionStruct ExDescription;
-// ExDescription.text = "Bad elementType";
-// ExDescription.type = SALOME::BAD_PARAM;
-// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-// ExDescription.lineNumber = 840;
-// throw SALOME::SALOME_Exception(ExDescription);
- }
-
- SMESH::array_of_ElementType_var types = theSource->GetTypes();
switch (theType) {
case SMESH::NODE:
MESSAGE("Required type is NODE");
MESSAGE("Required type is FACE");
break;
default:
- break;
+ MESSAGE("Incompatible required type: " << theType);
+ return false;
}
// MESSAGE("Required type is "<<theType);
+ SMESH::array_of_ElementType_var types = theSource->GetTypes();
MESSAGE("Available types:");
for (int i=0;i<types->length();i++){MESSAGE(types[i]);}
if ( types->length() >= 1 && types[types->length()-1] < theType)
{
+ MESSAGE("Required type not available");
return false;
// SALOME::ExceptionStruct ExDescription;
// ExDescription.text = "The source mesh has bad type";
// throw SALOME::SALOME_Exception(ExDescription);
}
+
+ SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
+
SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
- TIDSortedElemSet theElemSet;
- SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
+
+ string enfMeshName = theName;
+ if (enfMeshName.empty())
+ enfMeshName = SObj->GetName();
+
if (theMesh_i)
{
try {
- bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, SObj->GetName() , SObj->GetID(), theSize, theGroupName);
- if (theSize > 0) {
- if (theGroupName != "") {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
- << theSource << ".GetMesh(), " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
- }
- else {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
- << theSource << ".GetMesh(), " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
- }
- }
- else {
- if (theGroupName != "") {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
- << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
- }
- else {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
- << theSource << ".GetMesh(), " << theType << " )";
- }
- }
+ bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, enfMeshName , SObj->GetID(), theGroupName);
+ if (theGroupName != "") {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
+ << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
+ }
+ else {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
+ << theSource << ".GetMesh(), " << theType << " )";
+ }
+
return res;
}
catch (const std::invalid_argument& ex) {
THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
}
}
- else if (theGroup_i && types->length() == 1 && types[0] == theType)
+ else if (theGroup_i)// && types->length() == 1 && types[0] == theType)
{
MESSAGE("The source is a group")
try {
- bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, SObj->GetName() , SObj->GetID(), theSize, theGroupName);
- if (theSize > 0) {
- if (theGroupName != "") {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
- << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
- }
- else {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
- << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
- }
- }
- else {
+ bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
if (theGroupName != "") {
SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
<< theSource << ", " << theType << ", \"" << theGroupName << "\" )";
SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
<< theSource << ", " << theType << " )";
}
- }
return res;
}
catch (const std::invalid_argument& ex) {
THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
}
}
- else if (theGroupOnGeom_i && types->length() == 1 && types[0] == theType)
+ else if (theGroupOnGeom_i)// && types->length() == 1 && types[0] == theType)
{
MESSAGE("The source is a group on geom")
try {
- bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, SObj->GetName() , SObj->GetID(), theSize, theGroupName);
- if (theSize > 0) {
- if (theGroupName != "") {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
- << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
- }
- else {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
- << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
- }
- }
- else {
+ bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, enfMeshName , SObj->GetID(), theGroupName);
if (theGroupName != "") {
SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
<< theSource << ", " << theType << ", \"" << theGroupName << "\" )";
SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
<< theSource << ", " << theType << " )";
}
- }
return res;
}
catch (const std::invalid_argument& ex) {
/*!
* To set an enforced mesh
*/
- bool p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, double size = -1, const char* theGroupName="") throw (SALOME::SALOME_Exception);
+ bool p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, const char* theName="", const char* theGroupName="") throw (SALOME::SALOME_Exception);
bool SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType) throw (SALOME::SALOME_Exception);
bool SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, const char* theGroupName) throw (SALOME::SALOME_Exception);
+
+ /* OBSOLETE FUNCTIONS */
bool SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, double size) throw (SALOME::SALOME_Exception);
bool SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, double size, const char* theGroupName) throw (SALOME::SALOME_Exception);
+ /* OBSOLETE FUNCTIONS */
+
GHS3DPlugin::GHS3DEnforcedMeshList* GetEnforcedMeshes();
void ClearEnforcedMeshes();
ENF_MESH_NAME_COLUMN = 0,
ENF_MESH_ENTRY_COLUMN,
ENF_MESH_CONSTRAINT_COLUMN,
- ENF_MESH_SIZE_COLUMN,
ENF_MESH_GROUP_COLUMN,
ENF_MESH_NB_COLUMNS
};
ENF_MESH_WARNING = 0,
ENF_MESH_MESH /*= 0*/,
ENF_MESH_CONSTRAINT,
- ENF_MESH_SIZE,
ENF_MESH_GROUP,
ENF_MESH_BTN,
ENF_MESH_NB_LINES
QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem & option ,
const QModelIndex & index ) const
-{
- if (index.column() == ENF_MESH_SIZE_COLUMN) {
- SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
- editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
- return editor;
- }
+{
return QItemDelegate::createEditor(parent, option, index);
}
void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
- if (index.column() == ENF_MESH_SIZE_COLUMN) {
- SMESHGUI_SpinBox *spinBox = qobject_cast<SMESHGUI_SpinBox*>(editor);
- spinBox->SetValue(index.data().toDouble());
- }
- else
- QItemDelegate::setEditorData(editor, index);
+ QItemDelegate::setEditorData(editor, index);
}
void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
- if (index.column() == ENF_MESH_SIZE_COLUMN)
- {
- SMESHGUI_SpinBox *spinBox = qobject_cast<SMESHGUI_SpinBox*>(editor);
- const double newsize = spinBox->GetValue();
- if (newsize > 0)
- model->setData(index, newsize, Qt::EditRole);
- }
- else
- QItemDelegate::setModelData(editor, model, index);
+ QItemDelegate::setModelData(editor, model, index);
}
enforcedMeshHeaders << tr( "GHS3D_ENF_NAME_COLUMN" )
<< tr( "GHS3D_ENF_ENTRY_COLUMN" )
<< tr( "GHS3D_ENF_MESH_CONSTRAINT_COLUMN" )
- << tr( "GHS3D_ENF_SIZE_COLUMN" )
<< tr( "GHS3D_ENF_GROUP_COLUMN" );
myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
myEnfMeshConstraint->setEditable(false);
myEnfMeshConstraint->setCurrentIndex(0);
-
- QLabel* myMeshSizeLabel = new QLabel( tr( "GHS3D_ENF_SIZE_LABEL" ), myEnfMeshGroup );
- myMeshSizeValue = new SMESHGUI_SpinBox(myEnfMeshGroup);
- myMeshSizeValue->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
QLabel* myMeshGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfMeshGroup );
myMeshGroupName = new QLineEdit(myEnfMeshGroup);
anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
- anEnfMeshLayout2->addWidget(myMeshSizeLabel, ENF_MESH_SIZE, 0, 1, 1);
- anEnfMeshLayout2->addWidget(myMeshSizeValue, ENF_MESH_SIZE, 1, 1, 1);
anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
// connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
// connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
-// connect( myMeshSizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkEnfMeshIsDefined() ) );
// connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
return fr;
**/
void GHS3DPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
{
- emit enfMeshDefined((!myMeshSizeValue->GetString().isEmpty() && !myEnfVertexWdg->NbObjects() == 0));
+ emit enfMeshDefined( myEnfVertexWdg->NbObjects() != 0);
}
/**
/** GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName)
This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
*/
-void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, double size, std::string groupName)
+void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName)
{
- MESSAGE("addEnforcedMesh(\"" << name << ", \"" << entry << "\", " << elementType << ", " << size << ", \"" << groupName << "\")");
+ MESSAGE("addEnforcedMesh(\"" << name << ", \"" << entry << "\", " << elementType << ", \"" << groupName << "\")");
bool okToCreate = true;
QString itemEntry = "";
int itemElementType = 0;
break;
if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
-// // update size
-// if (itemSize != size) {
-// MESSAGE("Size is updated from \"" << itemSize << "\" to \"" << size << "\"");
-// myEnforcedMeshTableWidget->item(row, ENF_MESH_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
-// }
// // update group name
// if (itemGroupName.toStdString() != groupName) {
// MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
myEnforcedMeshTableWidget->setItem(rowCount,col,item);
break;
- case ENF_MESH_SIZE_COLUMN:
- item->setData( 0, size );
- MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
- myEnforcedMeshTableWidget->setItem(rowCount,col,item);
- break;
case ENF_MESH_GROUP_COLUMN:
item->setData( 0, groupName.c_str() );
MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
groupName = "";
- double size = -1;
- if (!myMeshSizeValue->GetString().isEmpty())
- size = myMeshSizeValue->GetValue();
-// if (size < 0)
-// return;
-
int elementType = myEnfMeshConstraint->currentIndex();
CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
if (!CORBA::is_nil(anObj)) {
// SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
- addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, size, groupName);
+ addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
}
}
else
CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
if (!CORBA::is_nil(anObj)) {
// SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
- addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, size, groupName);
+ addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
}
}
}
TEnfVertexList::const_iterator it;
int rowCount = 0;
+ myEnforcedTableWidget->clear();
myEnforcedTableWidget->setSortingEnabled(false);
myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
// Update Enforced meshes QTableWidget
TEnfMeshList::const_iterator itMesh;
rowCount = 0;
+ myEnforcedMeshTableWidget->clear();
myEnforcedMeshTableWidget->setSortingEnabled(false);
// myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
myEnforcedMeshTableWidget->setItem(rowCount,col,item);
break;
- case ENF_MESH_SIZE_COLUMN:
- item->setData( 0, enfMesh->size );
- MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
- myEnforcedMeshTableWidget->setItem(rowCount,col,item);
- break;
case ENF_MESH_GROUP_COLUMN:
item->setData( 0, enfMesh->groupName.c_str() );
MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
- myEnfMesh->size = enfMeshes[i].size;
switch (enfMeshes[i].elementType) {
case SMESH::NODE:
myEnfMesh->elementType = 0;
h->ClearEnforcedMeshes();
TEnfMeshList::const_iterator itEnfMesh;
+
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+
for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
TEnfMesh* enfMesh = (*itEnfMesh);
-
+
_PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
- SMESH::ElementType elementType;
+
MESSAGE("enfMesh->elementType: " << enfMesh->elementType);
+ SMESH::ElementType elementType;
switch(enfMesh->elementType) {
case 0:
elementType = SMESH::NODE;
break;
}
- ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->size, enfMesh->groupName.c_str());
+ std::cout << "h->p_SetEnforcedMesh(theSource, "<< elementType <<", \""<< enfMesh->name << "\", \"" << enfMesh->groupName.c_str() <<"\")"<<std::endl;
+ ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->name.c_str(), enfMesh->groupName.c_str());
} // for
} // try
// catch(const std::exception& ex) {
MESSAGE("Entry is \"" << myEnfMesh->entry << "\"" );
myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
MESSAGE("Group name is \"" << myEnfMesh->groupName << "\"" );
- myEnfMesh->size = myEnforcedMeshTableWidget->item(row,ENF_MESH_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
- MESSAGE("Size is " << myEnfMesh->size);
QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
myEnfMesh->elementType = combo->currentIndex();
MESSAGE("Element type: " << myEnfMesh->elementType);
h_data.myEnforcedMeshes.insert(myEnfMesh);
+ std::cout << "h_data.myEnforcedMeshes.size(): " << h_data.myEnforcedMeshes.size() << std::endl;
}
return true;
std::string entry;
int elementType;
std::string groupName;
- double size;
};
struct CompareEnfMeshes
void checkVertexIsDefined();
void clearEnfVertexSelection();
- void addEnforcedMesh(std::string name, std::string entry, int elementType, double size = 0, std::string groupName = "");
+ void addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
void onAddEnforcedMesh();
void onRemoveEnforcedMesh();
//void synchronizeEnforcedMesh();
QStringList myEnfMeshConstraintLabels;
// SMESH::mesh_array_var myEnfMeshArray;
QTableWidget* myEnforcedMeshTableWidget;
- SMESHGUI_SpinBox* myMeshSizeValue;
QLineEdit* myMeshGroupName;
QPushButton* addEnfMeshButton;
QPushButton* removeEnfMeshButton;