In Compute with a geometry, rool back to previous methods WriteFaces and WritePoints.
Bug: the enforced vertices do not work in this case. It seems to come from the version of Ghs3d.
*/
module GHS3DPlugin
{
+ typedef sequence<double,3> TCoords;
struct GHS3DEnforcedVertex {
- double x;
- double y;
- double z;
+ string name;
+ string geomEntry;
+ TCoords coords;
+ string groupName;
double size;
};
*/
interface GHS3DPlugin_GHS3D : SMESH::SMESH_3D_Algo
{
- boolean importGMFMesh(in string aGMFFileName);
+ SMESH::SMESH_Mesh importGMFMesh(in string aGMFFileName);
};
/*!
/*!
* To set an enforced vertex
*/
- void SetEnforcedVertex(in double x, in double y, in double z, in double size);
+ boolean SetEnforcedVertex(in double x, in double y, in double z, in double size) raises (SALOME::SALOME_Exception);
+ boolean SetEnforcedVertexGeom(in GEOM::GEOM_Object theVertex, in double size) raises (SALOME::SALOME_Exception);
+ boolean SetEnforcedVertexGeomWithGroup(in GEOM::GEOM_Object theVertex, in double size, in string groupName) raises (SALOME::SALOME_Exception);
double GetEnforcedVertex(in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
- void RemoveEnforcedVertex(in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
+ double GetEnforcedVertexGeom(in GEOM::GEOM_Object theVertex) raises (SALOME::SALOME_Exception);
+ boolean RemoveEnforcedVertex(in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
+ boolean RemoveEnforcedVertexGeom(in GEOM::GEOM_Object theVertex) raises (SALOME::SALOME_Exception);
GHS3DEnforcedVertexList GetEnforcedVertices();
void ClearEnforcedVertices();
- void SetEnforcedMesh(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType) raises (SALOME::SALOME_Exception);
- void SetEnforcedMeshSize(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, in double size) raises (SALOME::SALOME_Exception);
+ boolean SetEnforcedMesh(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType) raises (SALOME::SALOME_Exception);
+ boolean SetEnforcedMeshSize(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, in double size) raises (SALOME::SALOME_Exception);
void ClearEnforcedMeshes();
};
};
TIDSortedElemSet & theEnforcedEdges,
TIDSortedElemSet & theEnforcedTriangles,
// TIDSortedElemSet & theEnforcedQuadrangles,
- GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices)
+ GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues & theEnforcedVertices)
{
MESSAGE("writeGMFFile w/o geometry");
int idx, idxRequired, idxSol;
const int dummyint = 0;
- GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
+ GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues::const_iterator vertexIt;
std::vector<double> enfVertexSizes;
const SMDS_MeshElement* elem;
TIDSortedElemSet anElemSet, theKeptEnforcedEdges, theKeptEnforcedTriangles/*, theKeptEnforcedQuadrangles*/;
theRequiredNodes.push_back(node);
}
- int requiredNodes = theRequiredNodes.size();
+// int requiredNodes = theRequiredNodes.size();
int solSize = 0;
std::vector<std::vector<double> > ReqVerTab;
if (nbEnforcedVertices) {
// GmfVertices
std::cout << "Begin writting required nodes in GmfVertices" << std::endl;
- GmfSetKwd(idx, GmfVertices, theOrderedNodes.size()+solSize);
+ GmfSetKwd(idx, GmfVertices, theOrderedNodes.size()/*+solSize*/);
for (ghs3dNodeIt = theOrderedNodes.begin();ghs3dNodeIt != theOrderedNodes.end();++ghs3dNodeIt)
GmfSetLin(idx, GmfVertices, (*ghs3dNodeIt)->X(), (*ghs3dNodeIt)->Y(), (*ghs3dNodeIt)->Z(), dummyint);
- for (int i=0;i<solSize;i++) {
- std::cout << ReqVerTab[i][0] <<" "<< ReqVerTab[i][1] << " "<< ReqVerTab[i][2] << std::endl;
- GmfSetLin(idx, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
- }
+// for (int i=0;i<solSize;i++) {
+// std::cout << ReqVerTab[i][0] <<" "<< ReqVerTab[i][1] << " "<< ReqVerTab[i][2] << std::endl;
+// GmfSetLin(idx, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
+// }
std::cout << "End writting required nodes in GmfVertices" << std::endl;
- if (requiredNodes + solSize) {
- GmfSetKwd(idx, GmfRequiredVertices, requiredNodes+solSize);
- if (requiredNodes) {
- std::cout << "Begin writting required nodes in GmfRequiredVertices" << std::endl;
- int startId = theOrderedNodes.size()-requiredNodes+1;
- std::cout << "startId: " << startId << std::endl;
- for (int i=0;i<requiredNodes;i++)
- GmfSetLin(idx, GmfRequiredVertices, startId+i);
- std::cout << "End writting required nodes in GmfRequiredVertices" << std::endl;
+// if (requiredNodes + solSize) {
+// GmfSetKwd(idx, GmfRequiredVertices, requiredNodes+solSize);
+// if (requiredNodes) {
+// std::cout << "Begin writting required nodes in GmfRequiredVertices" << std::endl;
+// int startId = theOrderedNodes.size()-requiredNodes+1;
+// std::cout << "startId: " << startId << std::endl;
+// for (int i=0;i<requiredNodes;i++)
+// GmfSetLin(idx, GmfRequiredVertices, startId+i);
+// std::cout << "End writting required nodes in GmfRequiredVertices" << std::endl;
+// }
+ if (solSize) {
+
+// std::cout << "Begin writting required vertices in GmfRequiredVertices" << std::endl;
+// int startId = theOrderedNodes.size()+1;
+// std::cout << "startId: " << startId << std::endl;
+// for (int i=0;i<solSize;i++)
+// GmfSetLin(idx, GmfRequiredVertices, startId+i);
+// std::cout << "End writting required vertices in GmfRequiredVertices" << std::endl;
+
+ std::cout << "Begin writting in sol file" << std::endl;
+ idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
+ if (!idxRequired) {
+ GmfCloseMesh(idx);
+ return false;
}
- if (solSize) {
- std::cout << "Begin writting required vertices in GmfRequiredVertices" << std::endl;
- int startId = theOrderedNodes.size()+1;
- std::cout << "startId: " << startId << std::endl;
- for (int i=0;i<solSize;i++)
- GmfSetLin(idx, GmfRequiredVertices, startId+i);
- std::cout << "End writting required vertices in GmfRequiredVertices" << std::endl;
-
- std::cout << "Begin writting in sol file" << std::endl;
- idxSol = GmfOpenMesh(theSolFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
- if (!idxSol) {
- GmfCloseMesh(idx);
- if (idxRequired)
- GmfCloseMesh(idxRequired);
- return false;
- }
- int TypTab[] = {GmfSca};
- GmfSetKwd(idxSol, GmfSolAtVertices, solSize, 1, TypTab);
- for (int i=0;i<solSize;i++) {
- std::cout << "enfVertexSizes.at(i): " << enfVertexSizes.at(i) << std::endl;
- double solTab[] = {enfVertexSizes.at(i)};
- GmfSetLin(idxSol, GmfSolAtVertices, solTab);
- }
- std::cout << "End writting in sol file" << std::endl;
+ idxSol = GmfOpenMesh(theSolFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
+ if (!idxSol) {
+ GmfCloseMesh(idx);
+ if (idxRequired)
+ GmfCloseMesh(idxRequired);
+ return false;
}
+ int TypTab[] = {GmfSca};
+ GmfSetKwd(idxRequired, GmfVertices, solSize);
+ GmfSetKwd(idxSol, GmfSolAtVertices, solSize, 1, TypTab);
+ for (int i=0;i<solSize;i++) {
+ std::cout << ReqVerTab[i][0] <<" "<< ReqVerTab[i][1] << " "<< ReqVerTab[i][2] << std::endl;
+ std::cout << "enfVertexSizes.at("<<i<<"): " << enfVertexSizes.at(i) << std::endl;
+ double solTab[] = {enfVertexSizes.at(i)};
+ GmfSetLin(idxRequired, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
+ GmfSetLin(idxSol, GmfSolAtVertices, solTab);
+ }
+ std::cout << "End writting in sol file" << std::endl;
}
+// }
// // GmfRequiredVertices + GmfSolAtVertices
//// std::cout << "theRequiredNodes.size() + solSize: " << theRequiredNodes.size()+ solSize << std::endl;
}
-static bool writeGMFFile(const char* theMeshFileName,
- const char* theRequiredFileName,
- const char* theSolFileName,
- SMESH_MesherHelper& theHelper,
- const SMESH_ProxyMesh& theProxyMesh,
- std::map <int,int> & theNodeId2NodeIndexMap,
- std::map <int,int> & theSmdsToGhs3dIdMap,
- std::map <int,const SMDS_MeshNode*> & theGhs3dIdToNodeMap,
- TIDSortedNodeSet & theEnforcedNodes,
- TIDSortedElemSet & theEnforcedEdges,
- TIDSortedElemSet & theEnforcedTriangles,
-// TIDSortedElemSet & theEnforcedQuadrangles,
- GHS3DPlugin_Hypothesis::TEnforcedVertexValues & theEnforcedVertices)
+// static bool writeGMFFile(const char* theMeshFileName,
+// const char* theRequiredFileName,
+// const char* theSolFileName,
+// SMESH_MesherHelper& theHelper,
+// const SMESH_ProxyMesh& theProxyMesh,
+// std::map <int,int> & theNodeId2NodeIndexMap,
+// std::map <int,int> & theSmdsToGhs3dIdMap,
+// std::map <int,const SMDS_MeshNode*> & theGhs3dIdToNodeMap,
+// TIDSortedNodeSet & theEnforcedNodes,
+// TIDSortedElemSet & theEnforcedEdges,
+// TIDSortedElemSet & theEnforcedTriangles,
+// // TIDSortedElemSet & theEnforcedQuadrangles,
+// GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues & theEnforcedVertices)
+// {
+// MESSAGE("writeGMFFile with geometry");
+// int idx, idxRequired, idxSol;
+// int nbv, nbev, nben, aGhs3dID = 0;
+// const int dummyint = 0;
+// GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues::const_iterator vertexIt;
+// std::vector<double> enfVertexSizes;
+// TIDSortedNodeSet::const_iterator enfNodeIt;
+// const SMDS_MeshNode* node;
+// SMDS_NodeIteratorPtr nodeIt;
+//
+// idx = GmfOpenMesh(theMeshFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
+// if (!idx)
+// return false;
+//
+// SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS();
+//
+// /* ========================== NODES ========================== */
+// // NB_NODES
+// nbv = theMeshDS->NbNodes();
+// if ( nbv == 0 )
+// return false;
+// nbev = theEnforcedVertices.size();
+// nben = theEnforcedNodes.size();
+//
+// // Issue 020674: EDF 870 SMESH: Mesh generated by Netgen not usable by GHS3D
+// // The problem is in nodes on degenerated edges, we need to skip nodes which are free
+// // and replace not-free nodes on edges by the node on vertex
+// TNodeNodeMap n2nDegen; // map a node on degenerated edge to a node on vertex
+// TNodeNodeMap::iterator n2nDegenIt;
+// if ( theHelper.HasDegeneratedEdges() )
+// {
+// set<int> checkedSM;
+// for (TopExp_Explorer e(theMeshDS->ShapeToMesh(), TopAbs_EDGE ); e.More(); e.Next())
+// {
+// SMESH_subMesh* sm = theHelper.GetMesh()->GetSubMesh( e.Current() );
+// if ( checkedSM.insert( sm->GetId() ).second && theHelper.IsDegenShape(sm->GetId() ))
+// {
+// if ( SMESHDS_SubMesh* smDS = sm->GetSubMeshDS() )
+// {
+// TopoDS_Shape vertex = TopoDS_Iterator( e.Current() ).Value();
+// const SMDS_MeshNode* vNode = SMESH_Algo::VertexNode( TopoDS::Vertex( vertex ), theMeshDS);
+// {
+// SMDS_NodeIteratorPtr nIt = smDS->GetNodes();
+// while ( nIt->more() )
+// n2nDegen.insert( make_pair( nIt->next(), vNode ));
+// }
+// }
+// }
+// }
+// }
+//
+// const bool isQuadMesh =
+// theHelper.GetMesh()->NbEdges( ORDER_QUADRATIC ) ||
+// theHelper.GetMesh()->NbFaces( ORDER_QUADRATIC ) ||
+// theHelper.GetMesh()->NbVolumes( ORDER_QUADRATIC );
+//
+// std::vector<std::vector<double> > VerTab;
+// std::set<std::vector<double> > VerMap;
+// VerTab.clear();
+// std::vector<double> aVerTab;
+// // Loop from 1 to NB_NODES
+//
+// nodeIt = theMeshDS->nodesIterator();
+//
+// while ( nodeIt->more() )
+// {
+// node = nodeIt->next();
+// if ( isQuadMesh && theHelper.IsMedium( node )) // Issue 0021238
+// continue;
+// if ( n2nDegen.count( node ) ) // Issue 0020674
+// continue;
+//
+// std::vector<double> coords;
+// coords.push_back(node->X());
+// coords.push_back(node->Y());
+// coords.push_back(node->Z());
+// if (VerMap.find(coords) != VerMap.end()) {
+// aGhs3dID = theSmdsToGhs3dIdMap[node->GetID()];
+// theGhs3dIdToNodeMap[theSmdsToGhs3dIdMap[node->GetID()]] = node;
+// continue;
+// }
+// VerTab.push_back(coords);
+// VerMap.insert(coords);
+// aGhs3dID++;
+// theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID ));
+// theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node ));
+// }
+//
+//
+// /* ENFORCED NODES ========================== */
+// if (nben) {
+// std::cout << "Add " << nben << " enforced nodes to input .mesh file" << std::endl;
+// for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt) {
+// double x = (*enfNodeIt)->X();
+// double y = (*enfNodeIt)->Y();
+// double z = (*enfNodeIt)->Z();
+// // Test if point is inside shape to mesh
+// gp_Pnt myPoint(x,y,z);
+// BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
+// scl.Perform(myPoint, 1e-7);
+// TopAbs_State result = scl.State();
+// if ( result != TopAbs_IN )
+// continue;
+// std::vector<double> coords;
+// coords.push_back(x);
+// coords.push_back(y);
+// coords.push_back(z);
+// if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
+// continue;
+// if (VerMap.find(coords) != VerMap.end())
+// continue;
+// VerTab.push_back(coords);
+// VerMap.insert(coords);
+// aGhs3dID++;
+// theNodeId2NodeIndexMap.insert( make_pair( (*enfNodeIt)->GetID(), aGhs3dID ));
+// }
+// }
+//
+//
+// /* ENFORCED VERTICES ========================== */
+// int solSize = 0;
+// std::vector<std::vector<double> > ReqVerTab;
+// ReqVerTab.clear();
+// if (nbev) {
+// std::cout << "Add " << nbev << " enforced vertices to input .mesh file" << std::endl;
+// for(vertexIt = theEnforcedVertices.begin() ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) {
+// double x = vertexIt->first[0];
+// double y = vertexIt->first[1];
+// double z = vertexIt->first[2];
+// // Test if point is inside shape to mesh
+// gp_Pnt myPoint(x,y,z);
+// BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
+// scl.Perform(myPoint, 1e-7);
+// TopAbs_State result = scl.State();
+// if ( result != TopAbs_IN )
+// continue;
+// enfVertexSizes.push_back(vertexIt->second);
+// std::vector<double> coords;
+// coords.push_back(x);
+// coords.push_back(y);
+// coords.push_back(z);
+// if (VerMap.find(coords) != VerMap.end())
+// continue;
+// ReqVerTab.push_back(coords);
+// VerMap.insert(coords);
+// solSize++;
+// }
+// }
+//
+//
+// /* ========================== FACES ========================== */
+//
+// int nbTriangles = 0/*, nbQuadrangles = 0*/, aSmdsID;
+// TopTools_IndexedMapOfShape facesMap, trianglesMap/*, quadranglesMap*/;
+// TIDSortedElemSet::const_iterator elemIt;
+// const SMESHDS_SubMesh* theSubMesh;
+// TopoDS_Shape aShape;
+// SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace;
+// const SMDS_MeshElement* aFace;
+// map<int,int>::const_iterator itOnMap;
+// std::vector<std::vector<int> > tt, qt,et;
+// tt.clear();
+// qt.clear();
+// et.clear();
+// std::vector<int> att, aqt, aet;
+//
+// TopExp::MapShapes( theMeshDS->ShapeToMesh(), TopAbs_FACE, facesMap );
+//
+// for ( int i = 1; i <= facesMap.Extent(); ++i )
+// if (( theSubMesh = theProxyMesh.GetSubMesh( facesMap(i))))
+// {
+// SMDS_ElemIteratorPtr it = theSubMesh->GetElements();
+// while (it->more())
+// {
+// const SMDS_MeshElement *elem = it->next();
+// int nbCornerNodes = elem->NbCornerNodes();
+// if (nbCornerNodes == 3)
+// {
+// trianglesMap.Add(facesMap(i));
+// nbTriangles ++;
+// }
+// // else if (nbCornerNodes == 4)
+// // {
+// // quadranglesMap.Add(facesMap(i));
+// // nbQuadrangles ++;
+// // }
+// }
+// }
+//
+// /* TRIANGLES ========================== */
+// if (nbTriangles) {
+// for ( int i = 1; i <= trianglesMap.Extent(); i++ )
+// {
+// aShape = trianglesMap(i);
+// theSubMesh = theProxyMesh.GetSubMesh(aShape);
+// if ( !theSubMesh ) continue;
+// itOnSubMesh = theSubMesh->GetElements();
+// while ( itOnSubMesh->more() )
+// {
+// aFace = itOnSubMesh->next();
+// itOnSubFace = aFace->nodesIterator();
+// att.clear();
+// for ( int j = 0; j < 3; ++j ) {
+// // find GHS3D ID
+// node = castToNode( itOnSubFace->next() );
+// if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() )
+// node = n2nDegenIt->second;
+// aSmdsID = node->GetID();
+// itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
+// ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
+// att.push_back((*itOnMap).second);
+// }
+// tt.push_back(att);
+// }
+// }
+// }
+//
+// if (theEnforcedTriangles.size()) {
+// std::cout << "Add " << theEnforcedTriangles.size() << " enforced triangles to input .mesh file" << std::endl;
+// // Iterate over the enforced triangles
+// for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
+// aFace = (*elemIt);
+// itOnSubFace = aFace->nodesIterator();
+// bool isOK = true;
+// att.clear();
+//
+// for ( int j = 0; j < 3; ++j ) {
+// node = castToNode( itOnSubFace->next() );
+// if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() )
+// node = n2nDegenIt->second;
+// // std::cout << node;
+// double x = node->X();
+// double y = node->Y();
+// double z = node->Z();
+// // Test if point is inside shape to mesh
+// gp_Pnt myPoint(x,y,z);
+// BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
+// scl.Perform(myPoint, 1e-7);
+// TopAbs_State result = scl.State();
+// if ( result != TopAbs_IN ) {
+// isOK = false;
+// theEnforcedTriangles.erase(elemIt);
+// continue;
+// }
+// std::vector<double> coords;
+// coords.push_back(x);
+// coords.push_back(y);
+// coords.push_back(z);
+// if (VerMap.find(coords) != VerMap.end()) {
+// att.push_back(theNodeId2NodeIndexMap[node->GetID()]);
+// continue;
+// }
+// VerTab.push_back(coords);
+// VerMap.insert(coords);
+// aGhs3dID++;
+// theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aGhs3dID ));
+// att.push_back(aGhs3dID);
+// }
+// if (isOK)
+// tt.push_back(att);
+// }
+// }
+//
+//
+// /* ========================== EDGES ========================== */
+//
+// if (theEnforcedEdges.size()) {
+// // Iterate over the enforced edges
+// std::cout << "Add " << theEnforcedEdges.size() << " enforced edges to input .mesh file" << std::endl;
+// for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) {
+// aFace = (*elemIt);
+// bool isOK = true;
+// itOnSubFace = aFace->nodesIterator();
+// aet.clear();
+// for ( int j = 0; j < 2; ++j ) {
+// node = castToNode( itOnSubFace->next() );
+// if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() )
+// node = n2nDegenIt->second;
+// double x = node->X();
+// double y = node->Y();
+// double z = node->Z();
+// // Test if point is inside shape to mesh
+// gp_Pnt myPoint(x,y,z);
+// BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
+// scl.Perform(myPoint, 1e-7);
+// TopAbs_State result = scl.State();
+// if ( result != TopAbs_IN ) {
+// isOK = false;
+// theEnforcedEdges.erase(elemIt);
+// continue;
+// }
+// std::vector<double> coords;
+// coords.push_back(x);
+// coords.push_back(y);
+// coords.push_back(z);
+// if (VerMap.find(coords) != VerMap.end()) {
+// aet.push_back(theNodeId2NodeIndexMap[node->GetID()]);
+// continue;
+// }
+// VerTab.push_back(coords);
+// VerMap.insert(coords);
+//
+// aGhs3dID++;
+// theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aGhs3dID ));
+// aet.push_back(aGhs3dID);
+// }
+// if (isOK)
+// et.push_back(aet);
+// }
+// }
+//
+//
+// /* Write vertices number */
+// MESSAGE("Number of vertices: "<<aGhs3dID);
+// MESSAGE("Size of vector: "<<VerTab.size());
+// GmfSetKwd(idx, GmfVertices, aGhs3dID/*+solSize*/);
+// for (int i=0;i<aGhs3dID;i++)
+// GmfSetLin(idx, GmfVertices, VerTab[i][0], VerTab[i][1], VerTab[i][2], dummyint);
+// // for (int i=0;i<solSize;i++) {
+// // std::cout << ReqVerTab[i][0] <<" "<< ReqVerTab[i][1] << " "<< ReqVerTab[i][2] << std::endl;
+// // GmfSetLin(idx, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
+// // }
+//
+// if (solSize) {
+// idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
+// if (!idxRequired) {
+// GmfCloseMesh(idx);
+// return false;
+// }
+// idxSol = GmfOpenMesh(theSolFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
+// if (!idxSol){
+// GmfCloseMesh(idx);
+// if (idxRequired)
+// GmfCloseMesh(idxRequired);
+// return false;
+// }
+//
+// int TypTab[] = {GmfSca};
+// GmfSetKwd(idxRequired, GmfVertices, solSize);
+// GmfSetKwd(idxSol, GmfSolAtVertices, solSize, 1, TypTab);
+//
+// for (int i=0;i<solSize;i++) {
+// double solTab[] = {enfVertexSizes.at(i)};
+// GmfSetLin(idxRequired, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
+// GmfSetLin(idxSol, GmfSolAtVertices, solTab);
+// }
+// GmfCloseMesh(idxRequired);
+// GmfCloseMesh(idxSol);
+// }
+//
+// /* Write triangles number */
+// if (tt.size()) {
+// GmfSetKwd(idx, GmfTriangles, tt.size());
+// for (int i=0;i<tt.size();i++)
+// GmfSetLin(idx, GmfTriangles, tt[i][0], tt[i][1], tt[i][2], dummyint);
+// }
+//
+// /* Write edges number */
+// if (et.size()) {
+// GmfSetKwd(idx, GmfEdges, et.size());
+// for (int i=0;i<et.size();i++)
+// GmfSetLin(idx, GmfEdges, et[i][0], et[i][1], dummyint);
+// }
+//
+// /* QUADRANGLES ========================== */
+// // TODO: add pyramids ?
+// // if (nbQuadrangles) {
+// // for ( int i = 1; i <= quadranglesMap.Extent(); i++ )
+// // {
+// // aShape = quadranglesMap(i);
+// // theSubMesh = theProxyMesh.GetSubMesh(aShape);
+// // if ( !theSubMesh ) continue;
+// // itOnSubMesh = theSubMesh->GetElements();
+// // for ( int j = 0; j < 4; ++j )
+// // {
+// // aFace = itOnSubMesh->next();
+// // itOnSubFace = aFace->nodesIterator();
+// // aqt.clear();
+// // while ( itOnSubFace->more() ) {
+// // // find GHS3D ID
+// // aSmdsID = itOnSubFace->next()->GetID();
+// // itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
+// // ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
+// // aqt.push_back((*itOnMap).second);
+// // }
+// // qt.push_back(aqt);
+// // }
+// // }
+// // }
+// //
+// // if (theEnforcedQuadrangles.size()) {
+// // // Iterate over the enforced triangles
+// // for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) {
+// // aFace = (*elemIt);
+// // bool isOK = true;
+// // itOnSubFace = aFace->nodesIterator();
+// // aqt.clear();
+// // for ( int j = 0; j < 4; ++j ) {
+// // int aNodeID = itOnSubFace->next()->GetID();
+// // itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
+// // if (itOnMap != theNodeId2NodeIndexMap.end())
+// // aqt.push_back((*itOnMap).second);
+// // else {
+// // isOK = false;
+// // theEnforcedQuadrangles.erase(elemIt);
+// // break;
+// // }
+// // }
+// // if (isOK)
+// // qt.push_back(aqt);
+// // }
+// // }
+// //
+//
+// // /* Write quadrilaterals number */
+// // if (qt.size()) {
+// // GmfSetKwd(idx, GmfQuadrilaterals, qt.size());
+// // for (int i=0;i<qt.size();i++)
+// // GmfSetLin(idx, GmfQuadrilaterals, qt[i][0], qt[i][1], qt[i][2], qt[i][3], dummyint);
+// // }
+//
+// GmfCloseMesh(idx);
+// return true;
+// }
+
+
+//=======================================================================
+//function : writeFaces
+//purpose :
+//=======================================================================
+
+static bool writeFaces (ofstream & theFile,
+ const SMESH_ProxyMesh& theMesh,
+ const TopoDS_Shape& theShape,
+ const map <int,int> & theSmdsToGhs3dIdMap,
+ const map <int,int> & theEnforcedNodeIdToGhs3dIdMap,
+ TIDSortedElemSet & theEnforcedEdges,
+ TIDSortedElemSet & theEnforcedTriangles)
{
- MESSAGE("writeGMFFile with geometry");
- int idx, nbv, nbev, nben, aGhs3dID = 0;
- const int dummyint = 0;
- GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
- std::vector<double> enfVertexSizes;
- TIDSortedNodeSet::const_iterator enfNodeIt;
- const SMDS_MeshNode* node;
- SMDS_NodeIteratorPtr nodeIt;
+ // record structure:
+ //
+ // NB_ELEMS DUMMY_INT
+ // Loop from 1 to NB_ELEMS
+ // NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT
- idx = GmfOpenMesh(theMeshFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
- if (!idx)
- return false;
+ TopoDS_Shape aShape;
+ const SMESHDS_SubMesh* theSubMesh;
+ const SMDS_MeshElement* aFace;
+ const char* space = " ";
+ const int dummyint = 0;
+ map<int,int>::const_iterator itOnMap;
+ SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace;
+ int nbNodes, aSmdsID;
+
+ TIDSortedElemSet::const_iterator elemIt;
+ int nbEnforcedEdges = theEnforcedEdges.size();
+ int nbEnforcedTriangles = theEnforcedTriangles.size();
+
+ // count triangles bound to geometry
+ int nbTriangles = 0;
+
+ TopTools_IndexedMapOfShape facesMap, trianglesMap;
+ TopExp::MapShapes( theShape, TopAbs_FACE, facesMap );
+
+ for ( int i = 1; i <= facesMap.Extent(); ++i )
+ if (( theSubMesh = theMesh.GetSubMesh( facesMap(i))))
+ nbTriangles += theSubMesh->NbElements();
+
+ std::cout << " " << facesMap.Extent() << " shapes of 2D dimension and" << std::endl;
+ if (nbEnforcedEdges+nbEnforcedTriangles)
+ std::cout << " " << nbEnforcedEdges+nbEnforcedTriangles
+ << " enforced shapes:" << std::endl;
+ if (nbEnforcedEdges)
+ std::cout << " " << nbEnforcedEdges << " enforced edges" << std::endl;
+ if (nbEnforcedTriangles)
+ std::cout << " " << nbEnforcedTriangles << " enforced triangles" << std::endl;
+ std::cout << std::endl;
+
+// theFile << space << nbTriangles << space << dummyint << std::endl;
+ std::ostringstream globalStream, localStream, aStream;
+
+ for ( int i = 1; i <= facesMap.Extent(); i++ )
+ {
+ aShape = facesMap(i);
+ theSubMesh = theMesh.GetSubMesh(aShape);
+ if ( !theSubMesh ) continue;
+ itOnSubMesh = theSubMesh->GetElements();
+ while ( itOnSubMesh->more() )
+ {
+ aFace = itOnSubMesh->next();
+ nbNodes = aFace->NbCornerNodes();
+
+ localStream << nbNodes << space;
+
+ itOnSubFace = aFace->nodesIterator();
+ for ( int j = 0; j < 3; ++j ) {
+ // find GHS3D ID
+ aSmdsID = itOnSubFace->next()->GetID();
+ itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
+ // if ( itOnMap == theSmdsToGhs3dIdMap.end() ) {
+ // cout << "not found node: " << aSmdsID << endl;
+ // return false;
+ // }
+ ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
+
+ localStream << (*itOnMap).second << space ;
+ }
+
+ // (NB_NODES + 1) times: DUMMY_INT
+ for ( int j=0; j<=nbNodes; j++)
+ localStream << dummyint << space ;
+
+ localStream << std::endl;
+ }
+ }
- SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS();
+ globalStream << localStream.str();
+ localStream.str("");
+
+ //
+ // FACES : END
+ //
+
+// //
+// // ENFORCED EDGES : BEGIN
+// //
+//
+// // Iterate over the enforced edges
+// int usedEnforcedEdges = 0;
+// bool isOK;
+// for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) {
+// aFace = (*elemIt);
+// isOK = true;
+// itOnSubFace = aFace->nodesIterator();
+// aStream.str("");
+// aStream << "2" << space ;
+// for ( int j = 0; j < 2; ++j ) {
+// aSmdsID = itOnSubFace->next()->GetID();
+// itOnMap = theEnforcedNodeIdToGhs3dIdMap.find(aSmdsID);
+// if (itOnMap != theEnforcedNodeIdToGhs3dIdMap.end())
+// aStream << (*itOnMap).second << space;
+// else {
+// isOK = false;
+// break;
+// }
+// }
+// if (isOK) {
+// for ( int j=0; j<=2; j++)
+// aStream << dummyint << space ;
+// // aStream << dummyint << space << dummyint;
+// localStream << aStream.str() << std::endl;
+// usedEnforcedEdges++;
+// }
+// }
+//
+// if (usedEnforcedEdges) {
+// globalStream << localStream.str();
+// localStream.str("");
+// }
+//
+// //
+// // ENFORCED EDGES : END
+// //
+// //
+//
+// //
+// // ENFORCED TRIANGLES : BEGIN
+// //
+// // Iterate over the enforced triangles
+// int usedEnforcedTriangles = 0;
+// for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
+// aFace = (*elemIt);
+// nbNodes = aFace->NbCornerNodes();
+// isOK = true;
+// itOnSubFace = aFace->nodesIterator();
+// aStream.str("");
+// aStream << nbNodes << space ;
+// for ( int j = 0; j < 3; ++j ) {
+// aSmdsID = itOnSubFace->next()->GetID();
+// itOnMap = theEnforcedNodeIdToGhs3dIdMap.find(aSmdsID);
+// if (itOnMap != theEnforcedNodeIdToGhs3dIdMap.end())
+// aStream << (*itOnMap).second << space;
+// else {
+// isOK = false;
+// break;
+// }
+// }
+// if (isOK) {
+// for ( int j=0; j<=3; j++)
+// aStream << dummyint << space ;
+// localStream << aStream.str() << std::endl;
+// usedEnforcedTriangles++;
+// }
+// }
+//
+// if (usedEnforcedTriangles) {
+// globalStream << localStream.str();
+// localStream.str("");
+// }
+//
+// //
+// // ENFORCED TRIANGLES : END
+// //
- /* ========================== NODES ========================== */
+ theFile
+ << nbTriangles/*+usedEnforcedTriangles+usedEnforcedEdges*/
+ << " 0" << std::endl
+ << globalStream.str();
+
+ return true;
+}
+
+//=======================================================================
+//function : writePoints
+//purpose :
+//=======================================================================
+
+static bool writePoints (ofstream & theFile,
+ SMESH_MesherHelper& theHelper,
+ map <int,int> & theSmdsToGhs3dIdMap,
+ map <int,int> & theEnforcedNodeIdToGhs3dIdMap,
+ map <int,const SMDS_MeshNode*> & theGhs3dIdToNodeMap,
+ GHS3DPlugin_Hypothesis::TID2SizeMap & theNodeIDToSizeMap,
+ GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues & theEnforcedVertices,
+ TIDSortedNodeSet & theEnforcedNodes,
+ TIDSortedElemSet & theEnforcedEdges,
+ TIDSortedElemSet & theEnforcedTriangles)
+{
+ // record structure:
+ //
// NB_NODES
- nbv = theMeshDS->NbNodes();
- if ( nbv == 0 )
+ // Loop from 1 to NB_NODES
+ // X Y Z DUMMY_INT
+
+ SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS();
+ int nbNodes = theMeshDS->NbNodes();
+ if ( nbNodes == 0 )
return false;
- nbev = theEnforcedVertices.size();
- nben = theEnforcedNodes.size();
+ int nbEnforcedVertices = theEnforcedVertices.size();
+ int nbEnforcedNodes = theEnforcedNodes.size();
+
+ const TopoDS_Shape shapeToMesh = theMeshDS->ShapeToMesh();
+
+ int aGhs3dID = 1;
+ SMDS_NodeIteratorPtr it = theMeshDS->nodesIterator();
+ const SMDS_MeshNode* node;
+//
// Issue 020674: EDF 870 SMESH: Mesh generated by Netgen not usable by GHS3D
// The problem is in nodes on degenerated edges, we need to skip nodes which are free
// and replace not-free nodes on edges by the node on vertex
TNodeNodeMap::iterator n2nDegenIt;
if ( theHelper.HasDegeneratedEdges() )
{
+
set<int> checkedSM;
for (TopExp_Explorer e(theMeshDS->ShapeToMesh(), TopAbs_EDGE ); e.More(); e.Next())
{
theHelper.GetMesh()->NbFaces( ORDER_QUADRATIC ) ||
theHelper.GetMesh()->NbVolumes( ORDER_QUADRATIC );
- std::vector<std::vector<double> > VerTab;
- std::set<std::vector<double> > VerMap;
- VerTab.clear();
- std::vector<double> aVerTab;
+
+ const char* space = " ";
+ const int dummyint = 0;
+
+ // NB_NODES
+ std::cout << std::endl;
+ std::cout << "The initial 2D mesh contains :" << std::endl;
+ std::cout << " " << nbNodes << " nodes" << std::endl;
+ if (nbEnforcedVertices > 0)
+ std::cout << " " << nbEnforcedVertices << " enforced vertices" << std::endl;
+ if (nbEnforcedNodes > 0)
+ std::cout << " " << nbEnforcedNodes << " enforced nodes" << std::endl;
+ std::cout << std::endl;
+ std::cout << "Start writing in 'points' file ..." << std::endl;
+ theFile << nbNodes << std::endl;
+
// Loop from 1 to NB_NODES
- nodeIt = theMeshDS->nodesIterator();
-
- while ( nodeIt->more() )
+ while ( it->more() )
{
- node = nodeIt->next();
+ node = it->next();
if ( isQuadMesh && theHelper.IsMedium( node )) // Issue 0021238
continue;
if ( n2nDegen.count( node ) ) // Issue 0020674
continue;
- std::vector<double> coords;
- coords.push_back(node->X());
- coords.push_back(node->Y());
- coords.push_back(node->Z());
- if (VerMap.find(coords) != VerMap.end()) {
- aGhs3dID = theSmdsToGhs3dIdMap[node->GetID()];
- theGhs3dIdToNodeMap[theSmdsToGhs3dIdMap[node->GetID()]] = node;
- continue;
- }
- VerTab.push_back(coords);
- VerMap.insert(coords);
- aGhs3dID++;
theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID ));
theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node ));
+ aGhs3dID++;
+
+ // X Y Z DUMMY_INT
+ theFile
+ << node->X() << space
+ << node->Y() << space
+ << node->Z() << space
+ << dummyint;
+
+ theFile << std::endl;
+
}
-
- /* ENFORCED NODES ========================== */
- if (nben) {
- std::cout << "Add " << nben << " enforced nodes to input .mesh file" << std::endl;
- for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt) {
- double x = (*enfNodeIt)->X();
- double y = (*enfNodeIt)->Y();
- double z = (*enfNodeIt)->Z();
+ // Iterate over the enforced nodes
+ std::map<int,double> enfVertexIndexSizeMap;
+ if (nbEnforcedNodes) {
+ TIDSortedNodeSet::const_iterator nodeIt = theEnforcedNodes.begin();
+ for( ; nodeIt != theEnforcedNodes.end() ; ++nodeIt) {
+ double x = (*nodeIt)->X();
+ double y = (*nodeIt)->Y();
+ double z = (*nodeIt)->Z();
// Test if point is inside shape to mesh
gp_Pnt myPoint(x,y,z);
- BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
+ BRepClass3d_SolidClassifier scl(shapeToMesh);
scl.Perform(myPoint, 1e-7);
TopAbs_State result = scl.State();
if ( result != TopAbs_IN )
coords.push_back(z);
if (theEnforcedVertices.find(coords) != theEnforcedVertices.end())
continue;
- if (VerMap.find(coords) != VerMap.end())
- continue;
- VerTab.push_back(coords);
- VerMap.insert(coords);
+
+ double size = theNodeIDToSizeMap.find((*nodeIt)->GetID())->second;
+ // theGhs3dIdToNodeMap.insert( make_pair( nbNodes + i, (*nodeIt) ));
+ // MESSAGE("Adding enforced node (" << x << "," << y <<"," << z << ")");
+ // X Y Z PHY_SIZE DUMMY_INT
+ theFile
+ << x << space
+ << y << space
+ << z << space
+ << size << space
+ << dummyint << space;
+ theFile << std::endl;
+ theEnforcedNodeIdToGhs3dIdMap.insert( make_pair( (*nodeIt)->GetID(), aGhs3dID ));
+ enfVertexIndexSizeMap[aGhs3dID] = -1;
aGhs3dID++;
- theNodeId2NodeIndexMap.insert( make_pair( (*enfNodeIt)->GetID(), aGhs3dID ));
+ // else
+ // MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added ");
}
}
-
- /* ENFORCED VERTICES ========================== */
- if (nbev) {
- std::cout << "Add " << nbev << " enforced vertices to input .mesh file" << std::endl;
- std::vector<std::vector<double> > ReqVerTab;
- ReqVerTab.clear();
- std::vector<double> aReqVerTab;
- int solSize = 0;
- for(vertexIt = theEnforcedVertices.begin() ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) {
+ if (nbEnforcedVertices) {
+ // Iterate over the enforced vertices
+ GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues::const_iterator vertexIt = theEnforcedVertices.begin();
+ for( ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) {
double x = vertexIt->first[0];
double y = vertexIt->first[1];
double z = vertexIt->first[2];
// Test if point is inside shape to mesh
gp_Pnt myPoint(x,y,z);
- BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
+ BRepClass3d_SolidClassifier scl(shapeToMesh);
scl.Perform(myPoint, 1e-7);
TopAbs_State result = scl.State();
if ( result != TopAbs_IN )
continue;
- enfVertexSizes.push_back(vertexIt->second);
- std::vector<double> coords;
- coords.push_back(x);
- coords.push_back(y);
- coords.push_back(z);
- if (VerMap.find(coords) != VerMap.end())
- continue;
- ReqVerTab.push_back(coords);
- VerMap.insert(coords);
- solSize++;
- }
-
- if (solSize) {
- int idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
- if (!idxRequired)
- return false;
- int idxSol = GmfOpenMesh(theSolFileName, GmfWrite, GMFVERSION, GMFDIMENSION);
- if (!idxSol)
- return false;
-
- int TypTab[] = {GmfSca};
- GmfSetKwd(idxRequired, GmfVertices, solSize);
- GmfSetKwd(idxSol, GmfSolAtVertices, solSize, 1, TypTab);
-
- for (int i=0;i<solSize;i++) {
- double solTab[] = {enfVertexSizes.at(i)};
- GmfSetLin(idxRequired, GmfVertices, ReqVerTab[i][0], ReqVerTab[i][1], ReqVerTab[i][2], dummyint);
- GmfSetLin(idxSol, GmfSolAtVertices, solTab);
- }
- GmfCloseMesh(idxRequired);
- GmfCloseMesh(idxSol);
- }
- }
-
-
- /* ========================== FACES ========================== */
-
- int nbTriangles = 0/*, nbQuadrangles = 0*/, aSmdsID;
- TopTools_IndexedMapOfShape facesMap, trianglesMap/*, quadranglesMap*/;
- TIDSortedElemSet::const_iterator elemIt;
- const SMESHDS_SubMesh* theSubMesh;
- TopoDS_Shape aShape;
- SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace;
- const SMDS_MeshElement* aFace;
- map<int,int>::const_iterator itOnMap;
- std::vector<std::vector<int> > tt, qt,et;
- tt.clear();
- qt.clear();
- et.clear();
- std::vector<int> att, aqt, aet;
-
- TopExp::MapShapes( theMeshDS->ShapeToMesh(), TopAbs_FACE, facesMap );
-
- for ( int i = 1; i <= facesMap.Extent(); ++i )
- if (( theSubMesh = theProxyMesh.GetSubMesh( facesMap(i))))
- {
- SMDS_ElemIteratorPtr it = theSubMesh->GetElements();
- while (it->more())
- {
- const SMDS_MeshElement *elem = it->next();
- int nbCornerNodes = elem->NbCornerNodes();
- if (nbCornerNodes == 3)
- {
- trianglesMap.Add(facesMap(i));
- nbTriangles ++;
- }
-// else if (nbCornerNodes == 4)
-// {
-// quadranglesMap.Add(facesMap(i));
-// nbQuadrangles ++;
-// }
- }
- }
-
- /* TRIANGLES ========================== */
- if (nbTriangles) {
- for ( int i = 1; i <= trianglesMap.Extent(); i++ )
- {
- aShape = trianglesMap(i);
- theSubMesh = theProxyMesh.GetSubMesh(aShape);
- if ( !theSubMesh ) continue;
- itOnSubMesh = theSubMesh->GetElements();
- while ( itOnSubMesh->more() )
- {
- aFace = itOnSubMesh->next();
- itOnSubFace = aFace->nodesIterator();
- att.clear();
- for ( int j = 0; j < 3; ++j ) {
- // find GHS3D ID
- node = castToNode( itOnSubFace->next() );
- if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() )
- node = n2nDegenIt->second;
- aSmdsID = node->GetID();
- itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
- ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
- att.push_back((*itOnMap).second);
- }
- tt.push_back(att);
- }
- }
- }
-
- if (theEnforcedTriangles.size()) {
- std::cout << "Add " << theEnforcedTriangles.size() << " enforced triangles to input .mesh file" << std::endl;
- // Iterate over the enforced triangles
- for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) {
- aFace = (*elemIt);
- itOnSubFace = aFace->nodesIterator();
- bool isOK = true;
- att.clear();
-
- for ( int j = 0; j < 3; ++j ) {
- node = castToNode( itOnSubFace->next() );
- if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() )
- node = n2nDegenIt->second;
-// std::cout << node;
- double x = node->X();
- double y = node->Y();
- double z = node->Z();
- // Test if point is inside shape to mesh
- gp_Pnt myPoint(x,y,z);
- BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
- scl.Perform(myPoint, 1e-7);
- TopAbs_State result = scl.State();
- if ( result != TopAbs_IN ) {
- isOK = false;
- theEnforcedTriangles.erase(elemIt);
- continue;
- }
- std::vector<double> coords;
- coords.push_back(x);
- coords.push_back(y);
- coords.push_back(z);
- if (VerMap.find(coords) != VerMap.end()) {
- att.push_back(theNodeId2NodeIndexMap[node->GetID()]);
- continue;
- }
- VerTab.push_back(coords);
- VerMap.insert(coords);
- aGhs3dID++;
- theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aGhs3dID ));
- att.push_back(aGhs3dID);
- }
- if (isOK)
- tt.push_back(att);
- }
- }
-
-
- /* ========================== EDGES ========================== */
-
- if (theEnforcedEdges.size()) {
- // Iterate over the enforced edges
- std::cout << "Add " << theEnforcedEdges.size() << " enforced edges to input .mesh file" << std::endl;
- for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) {
- aFace = (*elemIt);
- bool isOK = true;
- itOnSubFace = aFace->nodesIterator();
- aet.clear();
- for ( int j = 0; j < 2; ++j ) {
- node = castToNode( itOnSubFace->next() );
- if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() )
- node = n2nDegenIt->second;
- double x = node->X();
- double y = node->Y();
- double z = node->Z();
- // Test if point is inside shape to mesh
- gp_Pnt myPoint(x,y,z);
- BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh());
- scl.Perform(myPoint, 1e-7);
- TopAbs_State result = scl.State();
- if ( result != TopAbs_IN ) {
- isOK = false;
- theEnforcedEdges.erase(elemIt);
- continue;
- }
- std::vector<double> coords;
- coords.push_back(x);
- coords.push_back(y);
- coords.push_back(z);
- if (VerMap.find(coords) != VerMap.end()) {
- aet.push_back(theNodeId2NodeIndexMap[node->GetID()]);
- continue;
- }
- VerTab.push_back(coords);
- VerMap.insert(coords);
-
- aGhs3dID++;
- theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aGhs3dID ));
- aet.push_back(aGhs3dID);
- }
- if (isOK)
- et.push_back(aet);
+ MESSAGE("Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second);
+ // X Y Z PHY_SIZE DUMMY_INT
+ theFile
+ << x << space
+ << y << space
+ << z << space
+ << vertexIt->second << space
+ << dummyint << space;
+ theFile << std::endl;
+ enfVertexIndexSizeMap[aGhs3dID] = vertexIt->second;
+ aGhs3dID++;
}
}
-
-
- /* Write vertices number */
- MESSAGE("Number of vertices: "<<aGhs3dID);
- MESSAGE("Size of vector: "<<VerTab.size());
- GmfSetKwd(idx, GmfVertices, aGhs3dID);
- for (int i=0;i<aGhs3dID;i++)
- GmfSetLin(idx, GmfVertices, VerTab[i][0], VerTab[i][1], VerTab[i][2], dummyint);
- /* Write triangles number */
- if (tt.size()) {
- GmfSetKwd(idx, GmfTriangles, tt.size());
- for (int i=0;i<tt.size();i++)
- GmfSetLin(idx, GmfTriangles, tt[i][0], tt[i][1], tt[i][2], dummyint);
- }
-
- /* Write edges number */
- if (et.size()) {
- GmfSetKwd(idx, GmfEdges, et.size());
- for (int i=0;i<et.size();i++)
- GmfSetLin(idx, GmfEdges, et[i][0], et[i][1], dummyint);
- }
-
- /* QUADRANGLES ========================== */
- // TODO: add pyramids ?
-// if (nbQuadrangles) {
-// for ( int i = 1; i <= quadranglesMap.Extent(); i++ )
-// {
-// aShape = quadranglesMap(i);
-// theSubMesh = theProxyMesh.GetSubMesh(aShape);
-// if ( !theSubMesh ) continue;
-// itOnSubMesh = theSubMesh->GetElements();
-// for ( int j = 0; j < 4; ++j )
-// {
-// aFace = itOnSubMesh->next();
-// itOnSubFace = aFace->nodesIterator();
-// aqt.clear();
-// while ( itOnSubFace->more() ) {
-// // find GHS3D ID
-// aSmdsID = itOnSubFace->next()->GetID();
-// itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
-// ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
-// aqt.push_back((*itOnMap).second);
-// }
-// qt.push_back(aqt);
-// }
-// }
-// }
-//
-// if (theEnforcedQuadrangles.size()) {
-// // Iterate over the enforced triangles
-// for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) {
-// aFace = (*elemIt);
-// bool isOK = true;
-// itOnSubFace = aFace->nodesIterator();
-// aqt.clear();
-// for ( int j = 0; j < 4; ++j ) {
-// int aNodeID = itOnSubFace->next()->GetID();
-// itOnMap = theNodeId2NodeIndexMap.find(aNodeID);
-// if (itOnMap != theNodeId2NodeIndexMap.end())
-// aqt.push_back((*itOnMap).second);
-// else {
-// isOK = false;
-// theEnforcedQuadrangles.erase(elemIt);
-// break;
-// }
-// }
-// if (isOK)
-// qt.push_back(aqt);
-// }
-// }
-//
-// /* Write quadrilaterals number */
-// if (qt.size()) {
-// GmfSetKwd(idx, GmfQuadrilaterals, qt.size());
-// for (int i=0;i<qt.size();i++)
-// GmfSetLin(idx, GmfQuadrilaterals, qt[i][0], qt[i][1], qt[i][2], qt[i][3], dummyint);
-// }
+ std::cout << std::endl;
+ std::cout << "End writing in 'points' file." << std::endl;
- GmfCloseMesh(idx);
return true;
}
-
//=======================================================================
//function : readResultFile
//purpose : readResultFile with geometry
TCollection_AsciiString aResultFileName;
TCollection_AsciiString aLogFileName = aGenericName + ".log"; // log
- TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName;
- TCollection_AsciiString aResultGMFFileName;
-
-#ifdef _DEBUG_
- aGMFFileName = aGenericName + ".mesh"; // GMF mesh file
// The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2)
- aResultGMFFileName = aGenericName + "Vol.mesh"; // GMF mesh file
- aResultFileName = aGenericName + ".noboite";// out points and volumes
+// TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName;
+// TCollection_AsciiString aGenericNameRequired = aGenericName + "_required";
+// #ifdef _DEBUG_
+// aGMFFileName = aGenericName + ".mesh"; // GMF mesh file
// aResultFileName = aGenericName + "Vol.mesh"; // GMF mesh file
- aRequiredVerticesFileName = aGenericName + "_required.mesh"; // GMF required vertices mesh file
- aSolFileName = aGenericName + "_required.sol"; // GMF solution file
-#else
- aGMFFileName = aGenericName + ".mesh"; // GMF mesh file
+// aRequiredVerticesFileName = aGenericNameRequired + ".mesh"; // GMF required vertices mesh file
+// aSolFileName = aGenericName + "_required.sol"; // GMF solution file
+// #else
// aGMFFileName = aGenericName + ".meshb"; // GMF mesh file
- // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2)
- aResultGMFFileName = aGenericName + "Vol.meshb"; // GMF mesh file
- aResultFileName = aGenericName + ".noboite";// out points and volumes
// aResultFileName = aGenericName + "Vol.meshb"; // GMF mesh file
- aRequiredVerticesFileName = aGenericName + "_required.meshb"; // GMF required vertices mesh file
- aSolFileName = aGenericName + "_required.solb"; // GMF solution file
-#endif
+// aRequiredVerticesFileName = aGenericNameRequired + ".meshb"; // GMF required vertices mesh file
+// aSolFileName = aGenericName + "_required.solb"; // GMF solution file
+// #endif
+
+ TCollection_AsciiString aFacesFileName, aPointsFileName, aBadResFileName, aBbResFileName;
+
+ aFacesFileName = aGenericName + ".faces"; // in faces
+ aPointsFileName = aGenericName + ".points"; // in points
+ aResultFileName = aGenericName + ".noboite";// out points and volumes
+ aBadResFileName = aGenericName + ".boite"; // out bad result
+ aBbResFileName = aGenericName + ".bb"; // out vertex stepsize
+
+ // -----------------
+ // make input files
+ // -----------------
+
+ ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out);
+ ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out);
+
+ Ok =
+ aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
+ if (!Ok) {
+ INFOS( "Can't write into " << aFacesFileName);
+ return error(SMESH_Comment("Can't write into ") << aFacesFileName);
+ }
+
std::map <int,int> aNodeId2NodeIndexMap, aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap;
std::map <int,const SMDS_MeshNode*> aGhs3dIdToNodeMap;
std::map <int, int> nodeID2nodeIndexMap;
- GHS3DPlugin_Hypothesis::TEnforcedVertexValues enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
+ GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVerticesCoordsSize(_hyp);
TIDSortedNodeSet enforcedNodes = GHS3DPlugin_Hypothesis::GetEnforcedNodes(_hyp);
TIDSortedElemSet enforcedEdges = GHS3DPlugin_Hypothesis::GetEnforcedEdges(_hyp);
TIDSortedElemSet enforcedTriangles = GHS3DPlugin_Hypothesis::GetEnforcedTriangles(_hyp);
return false;
}
- Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(),
- helper, *proxyMesh,
- aNodeId2NodeIndexMap, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap,
- enforcedNodes, enforcedEdges, enforcedTriangles, /*enforcedQuadrangles,*/
- enforcedVertices);
+ Ok = (writePoints( aPointsFile, helper,
+ aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, aGhs3dIdToNodeMap,
+ nodeIDToSizeMap,
+ enforcedVertices, enforcedNodes, enforcedEdges, enforcedTriangles)
+ &&
+ writeFaces ( aFacesFile, *proxyMesh, theShape,
+ aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap,
+ enforcedEdges, enforcedTriangles ));
+// Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(),
+// helper, *proxyMesh,
+// aNodeId2NodeIndexMap, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap,
+// enforcedNodes, enforcedEdges, enforcedTriangles, /*enforcedQuadrangles,*/
+// enforcedVertices);
}
// Write aSmdsToGhs3dIdMap to temp file
}
aIdsFile.close();
+ aFacesFile.close();
+ aPointsFile.close();
if ( ! Ok ) {
if ( !_keepFiles ) {
- removeFile( aGMFFileName );
- removeFile( aRequiredVerticesFileName );
- removeFile( aSolFileName );
+// removeFile( aGMFFileName );
+// removeFile( aRequiredVerticesFileName );
+// removeFile( aSolFileName );
+ removeFile( aFacesFileName );
+ removeFile( aPointsFileName );
removeFile( aSmdsToGhs3dIdMapFileName );
}
return error(COMPERR_BAD_INPUT_MESH);
// -----------------
TCollection_AsciiString cmd = TCollection_AsciiString((char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() );
- // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2)
cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
- cmd += TCollection_AsciiString(" -IM ");
+ cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
+ // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2)
// cmd += TCollection_AsciiString(" --in ") + aGenericName;
-// cmd += TCollection_AsciiString(" --required_vertices ") + aRequiredVerticesFileName;
-// cmd += TCollection_AsciiString(" --out ") + aGenericName;
- cmd += TCollection_AsciiString(" -Om 1>" ) + aLogFileName; // dump into file
+// cmd += TCollection_AsciiString(" --required_vertices ") + aGenericNameRequired;
+// cmd += TCollection_AsciiString(" --out ") + aResultGMFFileName;
+// cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
std::cout << std::endl;
std::cout << "Ghs3d execution..." << std::endl;
}
if ( !_keepFiles ) {
- removeFile( aSmdsToGhs3dIdMapFileName );
- // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2)
-
#ifdef WITH_SMESH_CANCEL_COMPUTE
if (! Ok)
if(_compute_canceled)
removeFile( aLogFileName );
#endif
+ removeFile( aFacesFileName );
+ removeFile( aPointsFileName );
+ removeFile( aResultFileName );
+ removeFile( aBadResFileName );
+ removeFile( aBbResFileName );
+ removeFile( aSmdsToGhs3dIdMapFileName );
}
std::cout << "<" << aResultFileName.ToCString() << "> GHS3D output file ";
if ( !Ok )
// to avoid access to the same files by eg different users
TCollection_AsciiString aGenericName
= (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
+ TCollection_AsciiString aGenericNameRequired = aGenericName + "_required";
TCollection_AsciiString aLogFileName = aGenericName + ".log"; // log
TCollection_AsciiString aResultFileName;
#ifdef _DEBUG_
aGMFFileName = aGenericName + ".mesh"; // GMF mesh file
aResultFileName = aGenericName + "Vol.mesh"; // GMF mesh file
- aRequiredVerticesFileName = aGenericName + "_required.mesh"; // GMF required vertices mesh file
- aSolFileName = aGenericName + "_required.sol"; // GMF solution file
+ aRequiredVerticesFileName = aGenericNameRequired + ".mesh"; // GMF required vertices mesh file
+ aSolFileName = aGenericNameRequired + ".sol"; // GMF solution file
#else
aGMFFileName = aGenericName + ".meshb"; // GMF mesh file
aResultFileName = aGenericName + "Vol.meshb"; // GMF mesh file
- aRequiredVerticesFileName = aGenericName + "_required.meshb"; // GMF required vertices mesh file
- aSolFileName = aGenericName + ".solb"; // GMF solution file
+ aRequiredVerticesFileName = aGenericNameRequired + ".meshb"; // GMF required vertices mesh file
+ aSolFileName = aGenericNameRequired + ".solb"; // GMF solution file
#endif
std::map <int, int> nodeID2nodeIndexMap;
- GHS3DPlugin_Hypothesis::TEnforcedVertexValues enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
+ GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVerticesCoordsSize(_hyp);
TIDSortedNodeSet enforcedNodes = GHS3DPlugin_Hypothesis::GetEnforcedNodes(_hyp);
TIDSortedElemSet enforcedEdges = GHS3DPlugin_Hypothesis::GetEnforcedEdges(_hyp);
TIDSortedElemSet enforcedTriangles = GHS3DPlugin_Hypothesis::GetEnforcedTriangles(_hyp);
TCollection_AsciiString cmd = TCollection_AsciiString((char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp, false ).c_str());
cmd += TCollection_AsciiString(" --in ") + aGenericName;
-// cmd += TCollection_AsciiString(" --required_vertices ") + aRequiredVerticesFileName;
+ if ( nbEnforcedVertices + nbEnforcedVertices)
+ cmd += TCollection_AsciiString(" --required_vertices ") + aGenericNameRequired;
cmd += TCollection_AsciiString(" --out ") + aResultFileName;
cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
*/
//=============================================================================
-bool GHS3DPlugin_GHS3D_i::importGMFMesh(const char* theGMFFileName)
+SMESH::SMESH_Mesh_ptr GHS3DPlugin_GHS3D_i::importGMFMesh(const char* theGMFFileName)
{
MESSAGE( "GHS3DPlugin_GHS3D_i::importGMFMesh" );
-
- SMESH::SMESH_Mesh_ptr theMesh = SMESH_Gen_i::GetSMESHGen()->CreateEmptyMesh();
- SMESH_Gen_i::GetSMESHGen()->RemoveLastFromPythonScript(SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy()->StudyId());
- SALOMEDS::SObject_ptr theSMesh = SMESH_Gen_i::GetSMESHGen()->ObjectToSObject(SMESH_Gen_i::GetSMESHGen()->GetCurrentStudy(), theMesh);
+ SMESH_Gen_i* smeshGen = SMESH_Gen_i::GetSMESHGen();
+ SMESH::SMESH_Mesh_ptr theMesh = smeshGen->CreateEmptyMesh();
+ smeshGen->RemoveLastFromPythonScript(smeshGen->GetCurrentStudy()->StudyId());
+ SALOMEDS::SObject_ptr theSMesh = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(), theMesh);
#ifdef WINNT
#define SEP '\\'
#else
string strFileName (theGMFFileName);
strFileName = strFileName.substr(strFileName.rfind(SEP)+1);
strFileName.erase(strFileName.rfind('.'));
- SMESH_Gen_i::GetSMESHGen()->SetName(theSMesh, strFileName.c_str());
- SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetSMESHGen()->GetServant( theMesh ).in() );
+ smeshGen->SetName(theSMesh, strFileName.c_str());
+ SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( smeshGen->GetServant( theMesh ).in() );
ASSERT( meshServant );
if ( meshServant ) {
- bool res = GetImpl()->importGMFMesh(theGMFFileName, meshServant->GetImpl());
- SMESH::TPythonDump() << "isDone = " << _this() << ".importGMFMesh( \"" << theGMFFileName << "\")";
- return res;
+ if (GetImpl()->importGMFMesh(theGMFFileName, meshServant->GetImpl()))
+ SMESH::TPythonDump() << theSMesh << " = " << _this() << ".importGMFMesh( \"" << theGMFFileName << "\")";
}
- return false;
+ return theMesh;
}
// Get implementation
::GHS3DPlugin_GHS3D* GetImpl();
- virtual bool importGMFMesh(const char* theGMFFileName);
+ virtual SMESH::SMESH_Mesh_ptr importGMFMesh(const char* theGMFFileName);
};
#endif
myToUseBoundaryRecoveryVersion(DefaultToUseBoundaryRecoveryVersion()),
myToUseFemCorrection(DefaultToUseFEMCorrection()),
myToRemoveCentralPoint(DefaultToRemoveCentralPoint()),
- myEnforcedVertices(DefaultEnforcedVertices()),
+ _enfVertexList(DefaultGHS3DEnforcedVertexList()),
+ _enfVertexCoordsSizeList(DefaultGHS3DEnforcedVertexCoordsValues()),
+ _enfVertexEntrySizeList(DefaultGHS3DEnforcedVertexEntryValues()),
+ _coordsEnfVertexMap(DefaultCoordsGHS3DEnforcedVertexMap()),
+ _geomEntryEnfVertexMap(DefaultGeomEntryGHS3DEnforcedVertexMap()),
_enfNodes(DefaultIDSortedNodeSet()),
_enfEdges(DefaultIDSortedElemSet()),
_enfTriangles(DefaultIDSortedElemSet()),
_nodeIDToSizeMap(DefaultID2SizeMap()),
_elementIDToSizeMap(DefaultID2SizeMap())
-// _enfQuadrangles(DefaultIDSortedElemSet())
{
_name = "GHS3D_Parameters";
_param_algo_dim = 3;
-// _edgeID2nodeIDMap.clear();
-// _triID2nodeIDMap.clear();
-// _quadID2nodeIDMap.clear();
}
//=======================================================================
//function : SetEnforcedVertex
//=======================================================================
-void GHS3DPlugin_Hypothesis::SetEnforcedVertex(double x, double y, double z, double size)
+bool GHS3DPlugin_Hypothesis::SetEnforcedVertex(std::string theName, std::string theEntry, std::string theGroupName,
+ double size, double x, double y, double z)
{
- std::vector<double> coord(3);
- coord[0] = x;
- coord[1] = y;
- coord[2] = z;
- myEnforcedVertices[coord] = size;
- NotifySubMeshesHypothesisModification();
+ MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedVertex("<< theName << ", "<< theEntry << ", " << theGroupName << ", "
+ << size << ", " << x << ", " << y << ", " << z << ")");
+
+ bool toNotify = false;
+ bool toCreate = true;
+
+ TGHS3DEnforcedVertex *oldEnVertex;
+ TGHS3DEnforcedVertex *newEnfVertex = new TGHS3DEnforcedVertex();
+ newEnfVertex->name = theName;
+ newEnfVertex->geomEntry = theEntry;
+ newEnfVertex->coords.clear();
+ if (theEntry == "") {
+ newEnfVertex->coords.push_back(x);
+ newEnfVertex->coords.push_back(y);
+ newEnfVertex->coords.push_back(z);
+ }
+ newEnfVertex->groupName = theGroupName;
+ newEnfVertex->size = size;
+
+
+ // update _enfVertexList
+ TGHS3DEnforcedVertexList::iterator it = _enfVertexList.find(newEnfVertex);
+ 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;
+ }
+ if (toNotify) {
+ // update map coords / enf vertex if needed
+ if (oldEnVertex->coords.size()) {
+ _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
+ _enfVertexCoordsSizeList[oldEnVertex->coords] = size;
+ }
+
+ // update map geom entry / enf vertex if needed
+ if (oldEnVertex->geomEntry != "") {
+ _geomEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
+ _enfVertexEntrySizeList[oldEnVertex->geomEntry] = size;
+ }
+ }
+ }
+
+// //////// CREATE ////////////
+ if (toCreate) {
+ toNotify = true;
+ MESSAGE("Creating new enforced vertex");
+ _enfVertexList.insert(newEnfVertex);
+ if (theEntry == "") {
+ _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
+ _enfVertexCoordsSizeList[newEnfVertex->coords] = size;
+ }
+ else {
+ _geomEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
+ _enfVertexEntrySizeList[newEnfVertex->geomEntry] = size;
+ }
+ }
+
+ if (toNotify)
+ NotifySubMeshesHypothesisModification();
+
+ MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedVertex END");
+ return toNotify;
}
//=======================================================================
//function : SetEnforcedMesh
//=======================================================================
-void GHS3DPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, double size)
+bool GHS3DPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, double size)
{
TIDSortedElemSet theElemSet;
SMDS_ElemIteratorPtr eIt;
-/*
- if ((elementType == SMESH::FACE) && (theMesh.NbQuadrangles() > 0)) {
- SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh ));
-
- StdMeshers_QuadToTriaAdaptor* aQuad2Trias = new StdMeshers_QuadToTriaAdaptor;
- aQuad2Trias->Compute( theMesh );
- proxyMesh.reset(aQuad2Trias );
-
-// std::cout << "proxyMesh->NbFaces(): " << proxyMesh->NbFaces() << std::endl;
-// eIt = proxyMesh->GetFaces();
-// if (eIt)
-// while ( eIt->more() )
-// theElemSet.insert( eIt->next() );
-// else {
-// std::cout << "********************** eIt == 0 *****************" << std::endl;
- eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType));
- while ( eIt->more() ) {
- const SMDS_MeshElement* elem = eIt->next();
- theElemSet.insert( elem );
- }
- }
-
- else
- {
- */
- eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType));
- while ( eIt->more() )
- theElemSet.insert( eIt->next() );
-/*
- }
-*/
+ eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType));
+ while ( eIt->more() )
+ theElemSet.insert( eIt->next() );
MESSAGE("Add "<<theElemSet.size()<<" types["<<elementType<<"] from source mesh");
-
- SetEnforcedElements( theElemSet, elementType, size);
-
+ return SetEnforcedElements( theElemSet, elementType, size);
}
//=======================================================================
//function : SetEnforcedElements
//=======================================================================
-void GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, double size)
+bool GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, double size)
{
MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedElements");
TIDSortedElemSet::const_iterator it = theElemSet.begin();
const SMDS_MeshElement* elem;
+ const SMDS_MeshNode* node;
bool added = false;
for (;it != theElemSet.end();++it)
{
elem = (*it);
-// MESSAGE("Element ID: " << (*it)->GetID());
- const SMDS_MeshNode* node = dynamic_cast<const SMDS_MeshNode*>(elem);
switch (elementType) {
case SMESH::NODE:
+ node = dynamic_cast<const SMDS_MeshNode*>(elem);
if (node) {
_enfNodes.insert(node);
_nodeIDToSizeMap.insert(make_pair(node->GetID(), size));
if (elem->GetType() == SMDSAbs_Edge) {
_enfEdges.insert(elem);
_elementIDToSizeMap.insert(make_pair(elem->GetID(), size));
-// SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
-// for (int j = 0; j < 2; ++j) {
-// node = dynamic_cast<const SMDS_MeshNode*>(nodeIt->next());
-// _edgeID2nodeIDMap[elem->GetID()].push_back(node->GetID());
-// _nodeIDToSizeMap.insert(make_pair(node->GetID(), size));
-// }
added = true;
}
else if (elem->GetType() > SMDSAbs_Edge) {
const SMDS_MeshElement* anEdge = it->next();
_enfEdges.insert(anEdge);
_elementIDToSizeMap.insert(make_pair(anEdge->GetID(), size));
-// SMDS_ElemIteratorPtr nodeIt = anEdge->nodesIterator();
-// for (int j = 0; j < 2; ++j) {
-// node = dynamic_cast<const SMDS_MeshNode*>(nodeIt->next());
-// _edgeID2nodeIDMap[anEdge->GetID()].push_back(node->GetID());
-// _nodeIDToSizeMap.insert(make_pair(node->GetID(), size));
-// }
}
added = true;
}
if (elem->NbCornerNodes() == 3) {
_enfTriangles.insert(elem);
_elementIDToSizeMap.insert(make_pair(elem->GetID(), size));
-// SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
-// for ( int j = 0; j < 3; ++j ) {
-// node = dynamic_cast<const SMDS_MeshNode*>(nodeIt->next());
-// _triID2nodeIDMap[elem->GetID()].push_back(node->GetID());
-// _nodeIDToSizeMap.insert(make_pair(node->GetID(), size));
-// }
added = true;
}
}
if (aFace->NbCornerNodes() == 3) {
_enfTriangles.insert(aFace);
_elementIDToSizeMap.insert(make_pair(aFace->GetID(), size));
-// SMDS_ElemIteratorPtr nodeIt = aFace->nodesIterator();
-// for (int j = 0; j < 3; ++j) {
-// node = dynamic_cast<const SMDS_MeshNode*>(nodeIt->next());
-// _triID2nodeIDMap[aFace->GetID()].push_back(node->GetID());
-// _nodeIDToSizeMap.insert(make_pair(node->GetID(), size));
-// }
added = true;
}
}
}
break;
+ default:
+ break;
};
}
if (added)
NotifySubMeshesHypothesisModification();
+ return added;
}
+
//=======================================================================
//function : GetEnforcedVertex
//=======================================================================
-double GHS3DPlugin_Hypothesis::GetEnforcedVertex(double x, double y, double z)
+GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* GHS3DPlugin_Hypothesis::GetEnforcedVertex(double x, double y, double z)
throw (std::invalid_argument)
{
std::vector<double> coord(3);
coord[0] = x;
coord[1] = y;
coord[2] = z;
- if (myEnforcedVertices.count(coord)>0)
- return myEnforcedVertices[coord];
+ if (_coordsEnfVertexMap.count(coord)>0)
+ return _coordsEnfVertexMap[coord];
std::ostringstream msg ;
msg << "No enforced vertex at " << x << ", " << y << ", " << z;
throw std::invalid_argument(msg.str());
}
+GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* GHS3DPlugin_Hypothesis::GetEnforcedVertex(const std::string theEntry)
+ throw (std::invalid_argument)
+{
+ if (_geomEntryEnfVertexMap.count(theEntry)>0)
+ return _geomEntryEnfVertexMap[theEntry];
+
+ std::ostringstream msg ;
+ msg << "No enforced vertex with entry " << theEntry;
+ throw std::invalid_argument(msg.str());
+}
+
//=======================================================================
//function : RemoveEnforcedVertex
//=======================================================================
-void GHS3DPlugin_Hypothesis::RemoveEnforcedVertex(double x, double y, double z)
+bool GHS3DPlugin_Hypothesis::RemoveEnforcedVertex(double x, double y, double z, const std::string theEntry)
throw (std::invalid_argument)
{
- std::vector<double> coord(3);
- coord[0] = x;
- coord[1] = y;
- coord[2] = z;
- TEnforcedVertexValues::iterator it = myEnforcedVertices.find(coord);
- if (it != myEnforcedVertices.end()) {
- myEnforcedVertices.erase(it);
- NotifySubMeshesHypothesisModification();
- return;
+ bool toNotify = false;
+ std::ostringstream msg;
+ TGHS3DEnforcedVertex *oldEnfVertex;
+ std::vector<double> coords(3);
+ coords[0] = x;
+ coords[1] = y;
+ coords[2] = z;
+
+ // check that enf vertex with given enf vertex entry exists
+ TGeomEntryGHS3DEnforcedVertexMap::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
+ TCoordsGHS3DEnforcedVertexMap::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());
}
- std::ostringstream msg ;
- msg << "No enforced vertex at " << x << ", " << y << ", " << z;
- throw std::invalid_argument(msg.str());
+ }
+
+ MESSAGE("Remove enf vertex from _enfVertexList");
+
+ // update _enfVertexList
+ TGHS3DEnforcedVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
+ if (it != _enfVertexList.end()) {
+ _enfVertexList.erase(it);
+ toNotify = true;
+ MESSAGE("Done");
+ }
+
+ if (toNotify)
+ NotifySubMeshesHypothesisModification();
+
+ return toNotify;
}
//=======================================================================
//=======================================================================
void GHS3DPlugin_Hypothesis::ClearEnforcedVertices()
{
- myEnforcedVertices.clear();
+ _enfVertexList.clear();
+ _coordsEnfVertexMap.clear();
+ _geomEntryEnfVertexMap.clear();
+ _enfVertexCoordsSizeList.clear();
+ _enfVertexEntrySizeList.clear();
NotifySubMeshesHypothesisModification();
}
_enfNodes.clear();
_enfEdges.clear();
_enfTriangles.clear();
-// _enfQuadrangles.clear();
-// _edgeID2nodeIDMap.clear();
-// _triID2nodeIDMap.clear();
-// _quadID2nodeIDMap.clear();
_nodeIDToSizeMap.clear();
_elementIDToSizeMap.clear();
NotifySubMeshesHypothesisModification();
}
//=======================================================================
-//function : DefaultEnforcedVertices
+//function : DefaultIDSortedNodeSet
//=======================================================================
-GHS3DPlugin_Hypothesis::TEnforcedVertexValues GHS3DPlugin_Hypothesis::DefaultEnforcedVertices()
-{
- return GHS3DPlugin_Hypothesis::TEnforcedVertexValues();
-}
-
TIDSortedNodeSet GHS3DPlugin_Hypothesis::DefaultIDSortedNodeSet()
{
return TIDSortedNodeSet();
}
+//=======================================================================
+//function : DefaultIDSortedElemSet
+//=======================================================================
+
TIDSortedElemSet GHS3DPlugin_Hypothesis::DefaultIDSortedElemSet()
{
return TIDSortedElemSet();
}
+//=======================================================================
+//function : DefaultID2SizeMap
+//=======================================================================
+
GHS3DPlugin_Hypothesis::TID2SizeMap GHS3DPlugin_Hypothesis::DefaultID2SizeMap()
{
return GHS3DPlugin_Hypothesis::TID2SizeMap();
}
+
//=======================================================================
//function : SaveTo
//=======================================================================
}
- TEnforcedVertexValues::iterator it = myEnforcedVertices.begin();
- if (it != myEnforcedVertices.end()) {
+ TGHS3DEnforcedVertexList::iterator it = _enfVertexList.begin();
+ if (it != _enfVertexList.end()) {
save << "__ENFORCED_VERTICES_BEGIN__ ";
- for ( ; it != myEnforcedVertices.end(); ++it ) {
- save << it->first[0] << " "
- << it->first[1] << " "
- << it->first[2] << " "
- << it->second << " ";
+ for ( ; it != _enfVertexList.end(); ++it ) {
+ TGHS3DEnforcedVertex *enfVertex = (*it);
+ save << " " << "__BEGIN_VERTEX__";
+ if (!enfVertex->name.empty()) {
+ save << " " << "__BEGIN_NAME__";
+ save << " " << enfVertex->name;
+ save << " " << "__END_NAME__";
+ }
+ if (!enfVertex->geomEntry.empty()) {
+ save << " " << "__BEGIN_ENTRY__";
+ save << " " << enfVertex->geomEntry;
+ save << " " << "__END_ENTRY__";
+ }
+ if (!enfVertex->groupName.empty()) {
+ save << " " << "__BEGIN_GROUP__";
+ save << " " << enfVertex->groupName;
+ save << " " << "__END_GROUP__";
+ }
+ if (enfVertex->coords.size()) {
+ save << " " << "__BEGIN_COORDS__";
+ for (int i=0;i<enfVertex->coords.size();i++)
+ save << " " << enfVertex->coords[i];
+ save << " " << "__END_COORDS__";
+ }
+ save << " " << "__BEGIN_SIZE__";
+ save << " " << enfVertex->size;
+ save << " " << "__BEGIN_SIZE__";
+ save << " " << "__END_VERTEX__";
}
save << "__ENFORCED_VERTICES_END__ ";
}
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();
- }
+ 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
- load.clear(ios::badbit | load.rdstate());
-
- if ( !myWorkingDirectory.empty() ) {
- isOK = (load >> i);
- if (isOK)
- myKeepFiles = i;
- else
- load.clear(ios::badbit | load.rdstate());
+ else if ( myWorkingDirectory == "1" ) {
+ myKeepFiles = true;
+ myWorkingDirectory.clear();
}
-
- 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());
-
+ }
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ if ( !myWorkingDirectory.empty() ) {
isOK = (load >> i);
if (isOK)
- myToRemoveCentralPoint = (bool) i;
+ myKeepFiles = 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;
- }
+ 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;
+ }
- 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) {
+ 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)
- if (separator == "__ENFORCED_VERTICES_BEGIN__")
- hasEnforcedVertices = true;
- }
+ if (hasOptions) {
+ isOK = (load >> separator);
+ if (isOK && separator == "__ENFORCED_VERTICES_BEGIN__")
+ hasEnforcedVertices = true;
+ }
- if (hasEnforcedVertices) {
- std::string txt;
- double x,y,z,size;
+ if (hasEnforcedVertices) {
+ std::string txt, name, entry, groupName;
+ double size, coords[3];
+ 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 (isOK) {
- if (txt == "__ENFORCED_VERTICES_END__") {
- isOK = false;
- break;
- }
- x = atof(txt.c_str());
- isOK = (load >> y >> z >> size);
+ isOK = (load >> txt);
+ if (txt == "__END_VERTEX__") {
+ enfVertex->name = name;
+ enfVertex->geomEntry = entry;
+ 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;
+ }
}
- if (isOK) {
- std::vector<double> coord;
- coord.push_back(x);
- coord.push_back(y);
- coord.push_back(z);
- myEnforcedVertices[ coord ] = size;
+ 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_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);
+ }
}
+ }
}
+ }
return load;
}
*/
//================================================================================
-GHS3DPlugin_Hypothesis::TEnforcedVertexValues GHS3DPlugin_Hypothesis::GetEnforcedVertices(const GHS3DPlugin_Hypothesis* hyp)
+GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList GHS3DPlugin_Hypothesis::GetEnforcedVertices(const GHS3DPlugin_Hypothesis* hyp)
{
- return hyp ? hyp->_GetEnforcedVertices():DefaultEnforcedVertices();
+ return hyp ? hyp->_GetEnforcedVertices():DefaultGHS3DEnforcedVertexList();
+}
+
+GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues GHS3DPlugin_Hypothesis::GetEnforcedVerticesCoordsSize (const GHS3DPlugin_Hypothesis* hyp)
+{
+ return hyp ? hyp->_GetEnforcedVerticesCoordsSize(): DefaultGHS3DEnforcedVertexCoordsValues();
+}
+
+GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexEntryValues GHS3DPlugin_Hypothesis::GetEnforcedVerticesEntrySize (const GHS3DPlugin_Hypothesis* hyp)
+{
+ return hyp ? hyp->_GetEnforcedVerticesEntrySize(): DefaultGHS3DEnforcedVertexEntryValues();
+}
+
+GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap GHS3DPlugin_Hypothesis::GetEnforcedVerticesByCoords (const GHS3DPlugin_Hypothesis* hyp)
+{
+ return hyp ? hyp->_GetEnforcedVerticesByCoords(): DefaultCoordsGHS3DEnforcedVertexMap();
+}
+
+GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap GHS3DPlugin_Hypothesis::GetEnforcedVerticesByEntry (const GHS3DPlugin_Hypothesis* hyp)
+{
+ return hyp ? hyp->_GetEnforcedVerticesByEntry(): DefaultGeomEntryGHS3DEnforcedVertexMap();
}
TIDSortedNodeSet GHS3DPlugin_Hypothesis::GetEnforcedNodes(const GHS3DPlugin_Hypothesis* hyp)
{
- return hyp ? hyp->_GetEnforcedNodes():DefaultIDSortedNodeSet();
+ return hyp ? hyp->_GetEnforcedNodes():DefaultIDSortedNodeSet();
}
TIDSortedElemSet GHS3DPlugin_Hypothesis::GetEnforcedEdges(const GHS3DPlugin_Hypothesis* hyp)
{
- return hyp ? hyp->_GetEnforcedEdges():DefaultIDSortedElemSet();
+ return hyp ? hyp->_GetEnforcedEdges():DefaultIDSortedElemSet();
}
TIDSortedElemSet GHS3DPlugin_Hypothesis::GetEnforcedTriangles(const GHS3DPlugin_Hypothesis* hyp)
{
- return hyp ? hyp->_GetEnforcedTriangles():DefaultIDSortedElemSet();
+ return hyp ? hyp->_GetEnforcedTriangles():DefaultIDSortedElemSet();
}
-// TIDSortedElemSet GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(const GHS3DPlugin_Hypothesis* hyp)
-// {
-// return hyp ? hyp->_GetEnforcedQuadrangles():DefaultIDSortedElemSet();
-// }
-
-// GHS3DPlugin_Hypothesis::TElemID2NodeIDMap GHS3DPlugin_Hypothesis::GetEdgeID2NodeIDMap(const GHS3DPlugin_Hypothesis* hyp)
-// {
-// return hyp ? hyp->_GetEdgeID2NodeIDMap(): GHS3DPlugin_Hypothesis::TElemID2NodeIDMap();
-// }
-//
-// GHS3DPlugin_Hypothesis::TElemID2NodeIDMap GHS3DPlugin_Hypothesis::GetTri2NodeMap(const GHS3DPlugin_Hypothesis* hyp)
-// {
-// return hyp ? hyp->_GetTri2NodeMap(): GHS3DPlugin_Hypothesis::TElemID2NodeIDMap();
-// }
-
-// GHS3DPlugin_Hypothesis::TElemID2NodeIDMap GHS3DPlugin_Hypothesis::GetQuad2NodeMap(const GHS3DPlugin_Hypothesis* hyp)
-// {
-// return hyp ? hyp->_GetQuad2NodeMap(): GHS3DPlugin_Hypothesis::TElemID2NodeIDMap();
-// }
-
GHS3DPlugin_Hypothesis::TID2SizeMap GHS3DPlugin_Hypothesis::GetNodeIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp)
{
- return hyp ? hyp->_GetNodeIDToSizeMap(): DefaultID2SizeMap();
+ return hyp ? hyp->_GetNodeIDToSizeMap(): DefaultID2SizeMap();
}
GHS3DPlugin_Hypothesis::TID2SizeMap GHS3DPlugin_Hypothesis::GetElementIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp)
{
- return hyp ? hyp->_GetElementIDToSizeMap(): DefaultID2SizeMap();
+ return hyp ? hyp->_GetElementIDToSizeMap(): DefaultID2SizeMap();
}
GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
+ typedef std::map<std::vector<double>,double> TGHS3DEnforcedVertexCoordsValues;
+ typedef std::map<std::string,double> TGHS3DEnforcedVertexEntryValues;
+
+ struct TGHS3DEnforcedVertex {
+ std::string name;
+ std::string geomEntry;
+ std::vector<double> coords;
+ std::string groupName;
+ double size;
+ };
+
+ struct CompareGHS3DEnforcedVertex {
+ bool operator () (const TGHS3DEnforcedVertex* e1, const TGHS3DEnforcedVertex* e2) const {
+ if (e1 && e2) {
+ if (e1->coords.size() && e2->coords.size())
+ return (e1->coords < e2->coords);
+ else
+ return (e1->geomEntry < e2->geomEntry);
+ }
+ return false;
+ }
+ };
+ typedef std::set< TGHS3DEnforcedVertex*, CompareGHS3DEnforcedVertex > TGHS3DEnforcedVertexList;
+ // Map Coords / Enforced node
+ typedef std::map< std::vector<double>, TGHS3DEnforcedVertex* > TCoordsGHS3DEnforcedVertexMap;
+ // Map geom entry / Enforced ndoe
+ typedef std::map< std::string, TGHS3DEnforcedVertex* > TGeomEntryGHS3DEnforcedVertexMap;
+ // Map groupName / Enforced ndoe
+ typedef std::map< std::string, TGHS3DEnforcedVertex* > TGroupNameGHS3DEnforcedVertexMap;
+
+ typedef std::map<int,double> TID2SizeMap;
+
/*!
* To mesh "holes" in a solid or not. Default is to mesh.
*/
*/
void SetTextOption(const std::string& option);
std::string GetTextOption() const;
- /*!
- * To set an enforced vertex
- */
-// struct TEnforcedNode {
-// std::vector<double> coords;
-// double size;
-// std::string geomEntry;
-// std::string groupName;
-// };
-//
-// struct CompareEnfNodes {
-// bool operator () (const TEnforcedNode* e1, const TEnforcedNode* e2) const {
-// if (e1 && e2) {
-// if (e1->coords.size() && e2->coords.size())
-// return (e1->coords < e2->coords);
-// else
-// return (e1->geomEntry < e2->geomEntry);
-// }
-// return false;
-// }
-// };
-// typedef std::set< TEnforcedNode*, CompareEnfNodes > TEnforcedNodeList;
-// // Map Coords / Enforced node
-// typedef std::map< std::vector<double>, TEnforcedNode* > TCoordsEnfNodeMap;
-// // Map geom entry / Enforced ndoe
-// typedef std::map< std::string, TEnforcedNode* > TGeomEntryEnfNodeMap;
-//
-//
+
+
// struct TEnforcedEdge {
// long ID;
// long node1;
// std::string groupName;
// };
-
- typedef std::map<std::vector<double>,double> TEnforcedVertexValues;
- void SetEnforcedVertex(double x, double y, double z, double size);
- double GetEnforcedVertex(double x, double y, double z) throw (std::invalid_argument);
- void RemoveEnforcedVertex(double x, double y, double z) throw (std::invalid_argument);
- const TEnforcedVertexValues _GetEnforcedVertices() const { return myEnforcedVertices; }
+
+ /*!
+ * \brief Return command to run ghs3d mesher excluding file prefix (-f)
+ */
+ static std::string CommandToRun(const GHS3DPlugin_Hypothesis* hyp,
+ const bool hasShapeToMesh=true);
+ /*!
+ * \brief Return a unique file name
+ */
+ static std::string GetFileName(const GHS3DPlugin_Hypothesis* hyp);
+
+ /*!
+ * To set an enforced vertex
+ */
+ bool SetEnforcedVertex(std::string aName, std::string anEntry, std::string aGroupName,
+ double size, double x=0.0, double y=0.0, double z=0.0);
+ TGHS3DEnforcedVertex* GetEnforcedVertex(double x, double y, double z) throw (std::invalid_argument);
+ TGHS3DEnforcedVertex* GetEnforcedVertex(const std::string anEntry) throw (std::invalid_argument);
+ bool RemoveEnforcedVertex(double x=0.0, double y=0.0, double z=0.0, const std::string anEntry="" ) throw (std::invalid_argument);
+ const TGHS3DEnforcedVertexCoordsValues _GetEnforcedVerticesCoordsSize() const {return _enfVertexCoordsSizeList; }
+ const TGHS3DEnforcedVertexEntryValues _GetEnforcedVerticesEntrySize() const {return _enfVertexEntrySizeList; }
+ const TGHS3DEnforcedVertexList _GetEnforcedVertices() const { return _enfVertexList; }
+ const TCoordsGHS3DEnforcedVertexMap _GetEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; }
+ const TGeomEntryGHS3DEnforcedVertexMap _GetEnforcedVerticesByEntry() const { return _geomEntryEnfVertexMap; }
void ClearEnforcedVertices();
/*!
* To set enforced elements
*/
- void SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, double size);
- void SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, double size);
+ bool SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, double size);
+ bool SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, double size);
void ClearEnforcedMeshes();
const TIDSortedNodeSet _GetEnforcedNodes() const { return _enfNodes; }
const TIDSortedElemSet _GetEnforcedEdges() const { return _enfEdges; }
const TIDSortedElemSet _GetEnforcedTriangles() const { return _enfTriangles; }
-// const TIDSortedElemSet _GetEnforcedQuadrangles() const { return _enfQuadrangles; }
-// typedef std::map<int,std::vector<int> > TElemID2NodeIDMap;
-// const TElemID2NodeIDMap _GetEdgeID2NodeIDMap() const {return _edgeID2nodeIDMap; }
-// const TElemID2NodeIDMap _GetTri2NodeMap() const {return _triID2nodeIDMap; }
-// const TElemID2NodeIDMap _GetQuad2NodeMap() const {return _quadID2nodeIDMap; }
- typedef std::map<int,double> TID2SizeMap;
const TID2SizeMap _GetNodeIDToSizeMap() const {return _nodeIDToSizeMap; }
const TID2SizeMap _GetElementIDToSizeMap() const {return _elementIDToSizeMap; }
-
+ /*!
+ * \brief Return the enforced vertices
+ */
+ static TGHS3DEnforcedVertexList GetEnforcedVertices(const GHS3DPlugin_Hypothesis* hyp);
+ static TGHS3DEnforcedVertexCoordsValues GetEnforcedVerticesCoordsSize(const GHS3DPlugin_Hypothesis* hyp);
+ static TGHS3DEnforcedVertexEntryValues GetEnforcedVerticesEntrySize(const GHS3DPlugin_Hypothesis* hyp);
+ static TCoordsGHS3DEnforcedVertexMap GetEnforcedVerticesByCoords(const GHS3DPlugin_Hypothesis* hyp);
+ static TGeomEntryGHS3DEnforcedVertexMap GetEnforcedVerticesByEntry(const GHS3DPlugin_Hypothesis* hyp);
+ static TIDSortedNodeSet GetEnforcedNodes(const GHS3DPlugin_Hypothesis* hyp);
+ static TIDSortedElemSet GetEnforcedEdges(const GHS3DPlugin_Hypothesis* hyp);
+ static TIDSortedElemSet GetEnforcedTriangles(const GHS3DPlugin_Hypothesis* hyp);
+ static TID2SizeMap GetNodeIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp);
+ static TID2SizeMap GetElementIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp);
+
static bool DefaultMeshHoles();
static short DefaultMaximumMemory();
static short DefaultInitialMemory();
static bool DefaultToUseBoundaryRecoveryVersion();
static bool DefaultToUseFEMCorrection();
static bool DefaultToRemoveCentralPoint();
- static TEnforcedVertexValues DefaultEnforcedVertices();
+ static TGHS3DEnforcedVertex DefaultGHS3DEnforcedVertex() {return TGHS3DEnforcedVertex();}
+ static TGHS3DEnforcedVertexList DefaultGHS3DEnforcedVertexList() {return TGHS3DEnforcedVertexList();}
+ static TGHS3DEnforcedVertexCoordsValues DefaultGHS3DEnforcedVertexCoordsValues() {return TGHS3DEnforcedVertexCoordsValues();}
+ static TGHS3DEnforcedVertexEntryValues DefaultGHS3DEnforcedVertexEntryValues() {return TGHS3DEnforcedVertexEntryValues();}
+ static TCoordsGHS3DEnforcedVertexMap DefaultCoordsGHS3DEnforcedVertexMap() {return TCoordsGHS3DEnforcedVertexMap();}
+ static TGeomEntryGHS3DEnforcedVertexMap DefaultGeomEntryGHS3DEnforcedVertexMap() {return TGeomEntryGHS3DEnforcedVertexMap();}
+ static TGroupNameGHS3DEnforcedVertexMap DefaultGroupNameGHS3DEnforcedVertexMap() {return TGroupNameGHS3DEnforcedVertexMap();}
static TIDSortedNodeSet DefaultIDSortedNodeSet();
static TIDSortedElemSet DefaultIDSortedElemSet();
static TID2SizeMap DefaultID2SizeMap();
-
- /*!
- * \brief Return command to run ghs3d mesher excluding file prefix (-f)
- */
- static std::string CommandToRun(const GHS3DPlugin_Hypothesis* hyp,
- const bool hasShapeToMesh=true);
- /*!
- * \brief Return a unique file name
- */
- static std::string GetFileName(const GHS3DPlugin_Hypothesis* hyp);
- /*!
- * \brief Return the enforced vertices
- */
- static TEnforcedVertexValues GetEnforcedVertices(const GHS3DPlugin_Hypothesis* hyp);
- static TIDSortedNodeSet GetEnforcedNodes(const GHS3DPlugin_Hypothesis* hyp);
- static TIDSortedElemSet GetEnforcedEdges(const GHS3DPlugin_Hypothesis* hyp);
- static TIDSortedElemSet GetEnforcedTriangles(const GHS3DPlugin_Hypothesis* hyp);
-// static TIDSortedElemSet GetEnforcedQuadrangles(const GHS3DPlugin_Hypothesis* hyp);
-// static TElemID2NodeIDMap GetEdgeID2NodeIDMap(const GHS3DPlugin_Hypothesis* hyp);
-// static TElemID2NodeIDMap GetTri2NodeMap(const GHS3DPlugin_Hypothesis* hyp);
-// static TElemID2NodeIDMap GetQuad2NodeMap(const GHS3DPlugin_Hypothesis* hyp);
- static TID2SizeMap GetNodeIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp);
- static TID2SizeMap GetElementIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp);
// Persistence
virtual std::ostream & SaveTo(std::ostream & save);
bool myToUseFemCorrection;
bool myToRemoveCentralPoint;
std::string myTextOption;
- TEnforcedVertexValues myEnforcedVertices;
+ TGHS3DEnforcedVertexList _enfVertexList;
+ TGHS3DEnforcedVertexCoordsValues _enfVertexCoordsSizeList;
+ TGHS3DEnforcedVertexEntryValues _enfVertexEntrySizeList;
+ // map to get "manual" enf vertex (through the coordinates)
+ TCoordsGHS3DEnforcedVertexMap _coordsEnfVertexMap;
+ // map to get "geom" enf vertex (through the geom entries)
+ TGeomEntryGHS3DEnforcedVertexMap _geomEntryEnfVertexMap;
TIDSortedNodeSet _enfNodes;
TIDSortedElemSet _enfEdges;
TIDSortedElemSet _enfTriangles;
-// TIDSortedElemSet _enfQuadrangles;
-// TElemID2NodeIDMap _edgeID2nodeIDMap;
-// TElemID2NodeIDMap _triID2nodeIDMap;
-// TElemID2NodeIDMap _quadID2nodeIDMap;
TID2SizeMap _nodeIDToSizeMap;
TID2SizeMap _elementIDToSizeMap;
};
//function : SetEnforcedVertex
//=======================================================================
-void GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
-{
+bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
+ throw (SALOME::SALOME_Exception) {
+ ASSERT(myBaseImpl);
+ MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
+ return _SetEnforcedVertex(size, x, y, z);
+}
+
+bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
+ throw (SALOME::SALOME_Exception) {
+ ASSERT(myBaseImpl);
+ MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
+ return _SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
+}
+
+bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
+ throw (SALOME::SALOME_Exception) {
+ ASSERT(myBaseImpl);
+
+ if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
+ MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
+ THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
+ }
+
+ string theVertexEntry = theVertex->GetStudyEntry();
+ if (theVertexEntry.empty()) {
+ GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+ SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+ string aName;
+ if (theVertex->GetShapeType() == GEOM::VERTEX)
+ aName = "Vertex_";
+ if (theVertex->GetShapeType() == GEOM::COMPOUND)
+ aName = "Compound_";
+ aName += theVertex->GetEntry();
+ SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
+ if (!theSVertex->_is_nil())
+ theVertexEntry = theSVertex->GetID();
+ }
+ if (theVertexEntry.empty())
+ THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+
+ string theVertexName = theVertex->GetName();
+ MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
+
+ return _SetEnforcedVertex(size, 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str());
+}
+
+bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
+ throw (SALOME::SALOME_Exception) {
+ ASSERT(myBaseImpl);
+
+ if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
+ MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
+ THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
+ }
+
+ string theVertexEntry = theVertex->GetStudyEntry();
+ if (theVertexEntry.empty()) {
+ GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+ SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+ string aName;
+ if (theVertex->GetShapeType() == GEOM::VERTEX)
+ aName = "Vertex_";
+ if (theVertex->GetShapeType() == GEOM::COMPOUND)
+ aName = "Compound_";
+ aName += theVertex->GetEntry();
+ SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
+ if (!theSVertex->_is_nil())
+ theVertexEntry = theSVertex->GetID();
+ }
+ if (theVertexEntry.empty())
+ THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+
+ string theVertexName = theVertex->GetName();
+ MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
+
+ return _SetEnforcedVertex(size, 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName);
+}
+
+bool GHS3DPlugin_Hypothesis_i:: _SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
+ const char* theVertexName, const char* theVertexEntry, const char* theGroupName)
+ throw (SALOME::SALOME_Exception) {
ASSERT(myBaseImpl);
- this->GetImpl()->SetEnforcedVertex(x,y,z,size);
- SMESH::TPythonDump() << _this() << ".SetEnforcedVertex( " << x << ", " << y << ", " << z << ", " << size << " )";
+ MESSAGE("IDL : _SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\")");
+ bool newValue = false;
+
+ if (string(theVertexEntry).empty()) {
+ ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
+ std::vector<double> coords;
+ coords.push_back(x);
+ coords.push_back(y);
+ coords.push_back(z);
+ if (coordsList.find(coords) == coordsList.end()) {
+ MESSAGE("Coords not found: add it in coordsList");
+ newValue = true;
+ } else {
+ MESSAGE("Coords already found, compare names");
+ ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
+ if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
+ MESSAGE("The names or size are different: update");
+// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
+ newValue = true;
+ }
+ else {
+ MESSAGE("The names and size are identical");
+ }
+ }
+
+ if (newValue) {
+ if (string(theVertexName).empty()) {
+ if (string(theGroupName).empty())
+ SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
+ else
+ SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
+// else
+// if (string(theGroupName).empty())
+// SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamed(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\")";
+// else
+// SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamedWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \""
+// << theVertexName << "\", \"" << theGroupName << "\")";
+ }
+ }
+ } else {
+ ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
+// ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
+ if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
+ MESSAGE("Geom entry not found: add it in enfVertexEntryList");
+ newValue = true;
+ }
+ else {
+ MESSAGE("Geom entry already found, compare names");
+ ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry);
+ if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
+ MESSAGE("The names or size are different: update");
+// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
+ newValue = true;
+ }
+ else {
+ MESSAGE("The names and size are identical");
+ }
+ }
+
+ if (newValue) {
+ if (string(theGroupName).empty())
+ SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")";
+ else
+ SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")";
+ }
+ }
+
+ if (newValue)
+ this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z);
+
+ MESSAGE("IDL : SetEnforcedVertexEntry END");
+ return newValue;
}
//=======================================================================
{
ASSERT(myBaseImpl);
try {
- return this->GetImpl()->GetEnforcedVertex(x,y,z);
+ return this->GetImpl()->GetEnforcedVertex(x,y,z)->size;
}
catch (const std::invalid_argument& ex) {
SALOME::ExceptionStruct ExDescription;
return 0;
}
+//=======================================================================
+//function : GetEnforcedVertex
+//=======================================================================
+
+CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
+ throw (SALOME::SALOME_Exception)
+{
+ ASSERT(myBaseImpl);
+
+ if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
+ MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
+ THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
+ }
+
+ string theVertexEntry = theVertex->GetStudyEntry();
+ if (theVertexEntry.empty()) {
+ GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+ SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+ string aName;
+ if (theVertex->GetShapeType() == GEOM::VERTEX)
+ aName = "Vertex_";
+ if (theVertex->GetShapeType() == GEOM::COMPOUND)
+ aName = "Compound_";
+ aName += theVertex->GetEntry();
+ SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
+ if (!theSVertex->_is_nil())
+ theVertexEntry = theSVertex->GetID();
+ }
+ if (theVertexEntry.empty())
+ THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+
+ string theVertexName = theVertex->GetName();
+
+ try {
+ return this->GetImpl()->GetEnforcedVertex(theVertexName)->size;
+ }
+ catch (const std::invalid_argument& ex) {
+ SALOME::ExceptionStruct ExDescription;
+ ExDescription.text = ex.what();
+ ExDescription.type = SALOME::BAD_PARAM;
+ ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::GetEnforcedVertexGeom(theVertex)";
+ ExDescription.lineNumber = 0;
+ throw SALOME::SALOME_Exception(ExDescription);
+ }
+ catch (SALOME_Exception& ex) {
+ THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+ }
+}
+
//=======================================================================
//function : GetEnforcedVertices
//=======================================================================
ASSERT(myBaseImpl);
GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
- const ::GHS3DPlugin_Hypothesis::TEnforcedVertexValues sizeMaps = this->GetImpl()->_GetEnforcedVertices();
- int size = sizeMaps.size();
- result->length( size );
-
- ::GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator it;
- int i = 0;
- for (it = sizeMaps.begin() ; it != sizeMaps.end(); it++ ) {
- GHS3DPlugin::GHS3DEnforcedVertex_var myVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
- myVertex->x = it->first[0];
- myVertex->y = it->first[1];
- myVertex->z = it->first[2];
- myVertex->size = it->second;
- result[i]=myVertex;
- i++;
+ const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices();
+ result->length( enfVertexList.size() );
+
+ ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin();
+
+ for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) {
+ ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it);
+ GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
+ // Name
+ enfVertex->name = CORBA::string_dup(currentVertex->name.c_str());
+ // Geom Vertex Entry
+ enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str());
+ // Coords
+ GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords();
+ coords->length(currentVertex->coords.size());
+ for (int ind = 0; ind < currentVertex->coords.size(); ind++)
+ coords[ind] = currentVertex->coords[ind];
+ enfVertex->coords = coords;
+ // Group Name
+ enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
+ // Size
+ enfVertex->size = currentVertex->size;
+
+ result[i]=enfVertex;
}
return result._retn();
//function : RemoveEnforcedVertex
//=======================================================================
-void GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
+bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
throw (SALOME::SALOME_Exception)
{
ASSERT(myBaseImpl);
+ bool res = false;
+ try {
+ res = this->GetImpl()->RemoveEnforcedVertex(x,y,z);
+ SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
+ }
+ catch (const std::invalid_argument& ex) {
+ SALOME::ExceptionStruct ExDescription;
+ ExDescription.text = ex.what();
+ ExDescription.type = SALOME::BAD_PARAM;
+ ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::RemoveEnforcedVertex(x,y,z)";
+ ExDescription.lineNumber = 408;
+ throw SALOME::SALOME_Exception(ExDescription);
+ }
+ catch (SALOME_Exception& ex) {
+ THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+ }
+ return res;
+}
+
+bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
+ throw (SALOME::SALOME_Exception)
+{
+ ASSERT(myBaseImpl);
+
+ if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
+ MESSAGE("theVertex shape type is not VERTEX or COMPOUND");
+ THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
+ }
+
+ string theVertexEntry = theVertex->GetStudyEntry();
+ if (theVertexEntry.empty()) {
+ GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+ SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+ string aName;
+ if (theVertex->GetShapeType() == GEOM::VERTEX)
+ aName = "Vertex_";
+ if (theVertex->GetShapeType() == GEOM::COMPOUND)
+ aName = "Compound_";
+ aName += theVertex->GetEntry();
+ SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
+ if (!theSVertex->_is_nil())
+ theVertexEntry = theSVertex->GetID();
+ }
+ if (theVertexEntry.empty())
+ THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+
+ bool res = false;
try {
- this->GetImpl()->RemoveEnforcedVertex(x,y,z);
- SMESH::TPythonDump() << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
+ res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str());
+ SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )";
}
catch (const std::invalid_argument& ex) {
SALOME::ExceptionStruct ExDescription;
catch (SALOME_Exception& ex) {
THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
}
+ return res;
}
//=======================================================================
/*!
* \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource.
*/
-void GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
+bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
throw (SALOME::SALOME_Exception)
{
#if GHS3D_VERSION >= 42
- _SetEnforcedMesh(theSource, theType, -1.0);
+ bool res = _SetEnforcedMesh(theSource, theType, -1.0);
SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
if (theGroup_i)
SMESH::TPythonDump () << _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.
*/
-void GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
+bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
throw (SALOME::SALOME_Exception)
{
if (theSize <= 0) {
throw SALOME::SALOME_Exception(ExDescription);
}
- _SetEnforcedMesh(theSource, theType, theSize);
+ bool res = _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);
if (theGroup_i)
SMESH::TPythonDump () << _this() << ".SetEnforcedMeshSize( "
<< theSource << ".GetMesh(), " << theType << ", " << theSize << " )";
}
+ return res;
}
-void GHS3DPlugin_Hypothesis_i::_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
+bool GHS3DPlugin_Hypothesis_i::_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
throw (SALOME::SALOME_Exception)
{
ASSERT(myBaseImpl);
if (anImplPtr)
theMeshDS = anImplPtr->GetImpl().GetMeshDS();
else
- return;
+ return false;
SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
if (theMesh_i)
{
try {
- this->GetImpl()->SetEnforcedMesh(anImplPtr->GetImpl(), theType, theSize);
+ return this->GetImpl()->SetEnforcedMesh(anImplPtr->GetImpl(), theType, theSize);
}
catch (const std::invalid_argument& ex) {
SALOME::ExceptionStruct ExDescription;
MESSAGE("Add "<<theElemSet.size()<<" types["<<theType<<"] from source group "<< theGroup_i->GetName());
try {
- this->GetImpl()->SetEnforcedElements(theElemSet, theType, theSize);
+ return this->GetImpl()->SetEnforcedElements(theElemSet, theType, theSize);
}
catch (const std::invalid_argument& ex) {
SALOME::ExceptionStruct ExDescription;
THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
}
}
+ return false;
}
//=============================================================================
/*!
/*!
* To set an enforced vertex
*/
- void SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size);
+ bool _SetEnforcedVertex(CORBA::Double size, CORBA::Double x = 0, CORBA::Double y = 0, CORBA::Double z = 0,
+ const char* theVertexName = "", const char* theVertexEntry = "", const char* theGroupName = "")
+ throw (SALOME::SALOME_Exception);
+ bool SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size) throw (SALOME::SALOME_Exception);
+ bool SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName) throw (SALOME::SALOME_Exception);
+ bool SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size) throw (SALOME::SALOME_Exception); // TODO
+ bool SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName) throw (SALOME::SALOME_Exception); // TODO
CORBA::Double GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception);
- void RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception);
+ CORBA::Double GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex) throw (SALOME::SALOME_Exception); // TODO
+ bool RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception);
+ bool RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex) throw (SALOME::SALOME_Exception); // TODO
GHS3DPlugin::GHS3DEnforcedVertexList* GetEnforcedVertices();
void ClearEnforcedVertices();
/*!
* To set an enforced mesh
*/
- void SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType) throw (SALOME::SALOME_Exception);
- void SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, double size) throw (SALOME::SALOME_Exception);
- void _SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, double size) throw (SALOME::SALOME_Exception);
+ bool SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType) throw (SALOME::SALOME_Exception);
+ bool SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, double size) throw (SALOME::SALOME_Exception);
void ClearEnforcedMeshes();
// Get implementation
// Verify whether hypothesis supports given entity type
CORBA::Boolean IsDimSupported( SMESH::Dimension type );
+
+ private:
+
+ bool _SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, double size) throw (SALOME::SALOME_Exception);
};
#endif
myFEMCorrectionCheck ->setChecked ( data.myFEMCorrection );
myTextOption ->setText ( data.myTextOption );
- TEnforcedVertexValues::const_iterator it;
+ TEnfVertexList::const_iterator it;
int row = 0;
for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
{
- double x = it->at(0);
- double y = it->at(1);
- double z = it->at(2);
- double size = it->at(3);
- // ENF_VER_X_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_X_COLUMN),x);
- mySmpModel->setItem( row, ENF_VER_X_COLUMN, new QStandardItem(QString::number(x)) );
- mySmpModel->item( row, ENF_VER_X_COLUMN )->setFlags( Qt::ItemIsSelectable );
- // ENF_VER_Y_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_Y_COLUMN),y);
- mySmpModel->setItem( row, ENF_VER_Y_COLUMN, new QStandardItem(QString::number(y)) );
- mySmpModel->item( row, ENF_VER_Y_COLUMN )->setFlags( Qt::ItemIsSelectable );
- // ENF_VER_Z_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_Z_COLUMN),z);
- mySmpModel->setItem( row, ENF_VER_Z_COLUMN, new QStandardItem(QString::number(z)) );
- mySmpModel->item( row, ENF_VER_Z_COLUMN )->setFlags( Qt::ItemIsSelectable );
- // ENF_VER_SIZE_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_SIZE_COLUMN),size);
- mySmpModel->setItem( row, ENF_VER_SIZE_COLUMN, new QStandardItem(QString::number(size)) );
-
- MESSAGE("Row " << row << ": (" << x << ","<< y << ","<< z << ") ="<< size);
- row++;
+ TEnfVertex* enfVertex = (*it);
+ if (enfVertex->coords.size()) {
+ double x = enfVertex->coords.at(0);
+ double y = enfVertex->coords.at(1);
+ double z = enfVertex->coords.at(2);
+ double size = enfVertex->size;
+ // ENF_VER_X_COLUMN
+ mySmpModel->setData(mySmpModel->index(row, ENF_VER_X_COLUMN),x);
+ mySmpModel->setItem( row, ENF_VER_X_COLUMN, new QStandardItem(QString::number(x)) );
+ mySmpModel->item( row, ENF_VER_X_COLUMN )->setFlags( Qt::ItemIsSelectable );
+ // ENF_VER_Y_COLUMN
+ mySmpModel->setData(mySmpModel->index(row, ENF_VER_Y_COLUMN),y);
+ mySmpModel->setItem( row, ENF_VER_Y_COLUMN, new QStandardItem(QString::number(y)) );
+ mySmpModel->item( row, ENF_VER_Y_COLUMN )->setFlags( Qt::ItemIsSelectable );
+ // ENF_VER_Z_COLUMN
+ mySmpModel->setData(mySmpModel->index(row, ENF_VER_Z_COLUMN),z);
+ mySmpModel->setItem( row, ENF_VER_Z_COLUMN, new QStandardItem(QString::number(z)) );
+ mySmpModel->item( row, ENF_VER_Z_COLUMN )->setFlags( Qt::ItemIsSelectable );
+ // ENF_VER_SIZE_COLUMN
+ mySmpModel->setData(mySmpModel->index(row, ENF_VER_SIZE_COLUMN),size);
+ mySmpModel->setItem( row, ENF_VER_SIZE_COLUMN, new QStandardItem(QString::number(size)) );
+
+ MESSAGE("Row " << row << ": (" << x << ","<< y << ","<< z << ") ="<< size);
+ row++;
+ }
}
GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
MESSAGE("vertices->length(): " << vertices->length());
h_data.myEnforcedVertices.clear();
for (int i=0 ; i<vertices->length() ; i++) {
- GHS3DEnforcedVertex myVertex;
- myVertex.push_back(vertices[i].x);
- myVertex.push_back(vertices[i].y);
- myVertex.push_back(vertices[i].z);
- myVertex.push_back(vertices[i].size);
- MESSAGE("Add enforced vertex ("<< myVertex[0] << ","<< myVertex[1] << ","<< myVertex[2] << ") ="<< myVertex[3]);
- h_data.myEnforcedVertices.push_back(myVertex);
+ TEnfVertex* myVertex;
+ myVertex->name = vertices[i].name;
+ myVertex->geomEntry = vertices[i].geomEntry;
+ myVertex->groupName = vertices[i].groupName;
+ myVertex->size = vertices[i].size;
+ if (vertices[i].coords.length()) {
+ for (int c = 0; c < vertices[i].coords.length() ; c++)
+ myVertex->coords.push_back(vertices[i].coords[c]);
+ MESSAGE("Add enforced vertex ("<< myVertex->coords.at(0) << ","<< myVertex->coords.at(1) << ","<< myVertex->coords.at(2) << ") ="<< myVertex->size);
+ }
+ h_data.myEnforcedVertices.insert(myVertex);
}
return true;
}
// else {
// iterate over vertices of hypo
for(int i = 0 ; i <nbVertexHyp ; i++) {
- double x = vertexHyp[i].x;
- double y = vertexHyp[i].y;
- double z = vertexHyp[i].z;
+ double x = vertexHyp[i].coords[0];
+ double y = vertexHyp[i].coords[1];
+ double z = vertexHyp[i].coords[2];
// vertex is removed
if (!smpVertexExists(x,y,z))
h->RemoveEnforcedVertex(x,y,z);
// }
}
- TEnforcedVertexValues::const_iterator it;
+ TEnfVertexList::const_iterator it;
for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
- double x = it->at(0);
- double y = it->at(1);
- double z = it->at(2);
- double size = it->at(3);
+ TEnfVertex* enfVertex = (*it);
+ double x = enfVertex->coords.at(0);
+ double y = enfVertex->coords.at(1);
+ double z = enfVertex->coords.at(2);
+ double size = enfVertex->size;
MESSAGE("(" << x << ", "
<< y << ", "
<< z << ") = "
}
catch (...) {
MESSAGE("Setting new size: " << size);
- h->SetEnforcedVertex(x,y,z,size);
+ h->SetEnforcedVertex( x, y, z, size);
}
}
}
h_data.myEnforcedVertices.clear();
for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
- GHS3DEnforcedVertex myVertex;
- myVertex.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble());
- myVertex.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble());
- myVertex.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble());
- myVertex.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble());
- MESSAGE("Add new enforced vertex (" << myVertex[0] << ", "
- << myVertex[1] << ", "
- << myVertex[2] << ") = "
- << myVertex[3]);
- h_data.myEnforcedVertices.push_back(myVertex);
+ TEnfVertex *myVertex;
+ myVertex->coords.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble());
+ myVertex->coords.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble());
+ myVertex->coords.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble());
+ myVertex->size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
+ MESSAGE("Add new enforced vertex (" << myVertex->coords.at(0) << ", "
+ << myVertex->coords.at(1) << ", "
+ << myVertex->coords.at(2) << ") = "
+ << myVertex->size);
+ h_data.myEnforcedVertices.insert(myVertex);
}
return true;
#include <QItemDelegate>
#include <map>
#include <vector>
+#include <set>
#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm)
class QWidget;
class LightApp_SelectionMgr;
-typedef std::vector<double> GHS3DEnforcedVertex;
-typedef std::vector<GHS3DEnforcedVertex> TEnforcedVertexValues;
+// Enforced vertex
+struct TEnfVertex{
+ std::string name;
+ std::string geomEntry;
+ std::vector<double> coords;
+ std::string groupName;
+ double size;
+};
+
+struct CompareEnfVertices
+{
+ bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
+ if (e1 && e2) {
+ if (e1->coords.size() && e2->coords.size())
+ return (e1->coords < e2->coords);
+ else
+ return (e1->geomEntry < e2->geomEntry);
+ }
+ return false;
+ }
+};
+
+// List of enforced vertices
+typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
+
+// typedef std::vector<GHS3DEnforcedVertex> TEnforcedVertexCoordsValues;
typedef struct
{
int myMaximumMemory,myInitialMemory,myOptimizationLevel;
QString myName,myWorkingDir,myTextOption;
short myVerboseLevel;
- TEnforcedVertexValues myEnforcedVertices;
+ TEnfVertexList myEnforcedVertices;
} GHS3DHypothesisData;
/*!