From: eap Date: Wed, 29 Jun 2016 13:34:40 +0000 (+0300) Subject: Fix compilation after changes in SMESH headers X-Git-Tag: V8_1_0a1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bd2d56ffc0403c066ed5f25d3eb722c3c55029a6;p=plugins%2Fhybridplugin.git Fix compilation after changes in SMESH headers --- diff --git a/src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx b/src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx index e9152d1..1855b12 100644 --- a/src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx @@ -68,41 +68,41 @@ #include -namespace { - -#ifdef WIN32 -#include -#else -#include -#endif - - int maxAvailableMemory() - { -#ifdef WIN32 - // See http://msdn.microsoft.com/en-us/library/aa366589.aspx - MEMORYSTATUSEX statex; - statex.dwLength = sizeof (statex); - int err = GlobalMemoryStatusEx (&statex); - if (err != 0) { - int totMB = - statex.ullTotalPhys / 1024 / 1024 + - statex.ullTotalPageFile / 1024 / 1024 + - statex.ullTotalVirtual / 1024 / 1024; - return (int) ( 0.7 * totMB ); - } -#else - struct sysinfo si; - int err = sysinfo( &si ); - if ( err == 0 ) { - int totMB = - si.totalram * si.mem_unit / 1024 / 1024 + - si.totalswap * si.mem_unit / 1024 / 1024 ; - return (int) ( 0.7 * totMB ); - } -#endif - return 0; - } -} +// namespace { + +// #ifdef WIN32 +// #include +// #else +// #include +// #endif + +// int maxAvailableMemory() +// { +// #ifdef WIN32 +// // See http://msdn.microsoft.com/en-us/library/aa366589.aspx +// MEMORYSTATUSEX statex; +// statex.dwLength = sizeof (statex); +// int err = GlobalMemoryStatusEx (&statex); +// if (err != 0) { +// int totMB = +// statex.ullTotalPhys / 1024 / 1024 + +// statex.ullTotalPageFile / 1024 / 1024 + +// statex.ullTotalVirtual / 1024 / 1024; +// return (int) ( 0.7 * totMB ); +// } +// #else +// struct sysinfo si; +// int err = sysinfo( &si ); +// if ( err == 0 ) { +// int totMB = +// si.totalram * si.mem_unit / 1024 / 1024 + +// si.totalswap * si.mem_unit / 1024 / 1024 ; +// return (int) ( 0.7 * totMB ); +// } +// #endif +// return 0; +// } +// } // // BEGIN EnforcedVertexTableWidgetDelegate @@ -1804,7 +1804,7 @@ bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices(); MESSAGE("vertices->length(): " << vertices->length()); h_data.myEnforcedVertices.clear(); - for (int i=0 ; ilength() ; i++) { + for (CORBA::ULong i=0 ; ilength() ; i++) { TEnfVertex* myVertex = new TEnfVertex(); myVertex->name = CORBA::string_dup(vertices[i].name.in()); myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in()); @@ -1812,7 +1812,7 @@ bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData myVertex->size = vertices[i].size; myVertex->isCompound = vertices[i].isCompound; if (vertices[i].coords.length()) { - for (int c = 0; c < vertices[i].coords.length() ; c++) + for (CORBA::ULong 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); } @@ -1822,7 +1822,7 @@ bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes(); MESSAGE("enfMeshes->length(): " << enfMeshes->length()); h_data.myEnforcedMeshes.clear(); - for (int i=0 ; ilength() ; i++) { + for (CORBA::ULong i=0 ; ilength() ; i++) { TEnfMesh* myEnfMesh = new TEnfMesh(); myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in()); myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in()); diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx index 06ea9f3..4bd0a04 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx @@ -26,10 +26,10 @@ #include "HYBRIDPlugin_Hypothesis.hxx" #include -#include -#include +#include #include #include +#include #include #include #include @@ -276,38 +276,38 @@ TopoDS_Shape HYBRIDPlugin_HYBRID::entryToShape(std::string entry) */ //================================================================================ -static bool isTmpFace(const SMDS_MeshNode* node1, - const SMDS_MeshNode* node2, - const SMDS_MeshNode* node3) -{ - // find a pyramid sharing the 3 nodes - //const SMDS_MeshElement* pyram = 0; - SMDS_ElemIteratorPtr vIt1 = node1->GetInverseElementIterator(SMDSAbs_Volume); - while ( vIt1->more() ) - { - const SMDS_MeshElement* pyram = vIt1->next(); - if ( pyram->NbCornerNodes() != 5 ) continue; - int i2, i3; - if ( (i2 = pyram->GetNodeIndex( node2 )) >= 0 && - (i3 = pyram->GetNodeIndex( node3 )) >= 0 ) - { - // Triangle defines sub-domian inside the pyramid if it's - // normal points out of the pyram - - // make i2 and i3 hold indices of base nodes of the pyram while - // keeping the nodes order in the triangle - const int iApex = 4; - if ( i2 == iApex ) - i2 = i3, i3 = pyram->GetNodeIndex( node1 ); - else if ( i3 == iApex ) - i3 = i2, i2 = pyram->GetNodeIndex( node1 ); - - int i3base = (i2+1) % 4; // next index after i2 within the pyramid base - return ( i3base != i3 ); - } - } - return false; -} +// static bool isTmpFace(const SMDS_MeshNode* node1, +// const SMDS_MeshNode* node2, +// const SMDS_MeshNode* node3) +// { +// // find a pyramid sharing the 3 nodes +// //const SMDS_MeshElement* pyram = 0; +// SMDS_ElemIteratorPtr vIt1 = node1->GetInverseElementIterator(SMDSAbs_Volume); +// while ( vIt1->more() ) +// { +// const SMDS_MeshElement* pyram = vIt1->next(); +// if ( pyram->NbCornerNodes() != 5 ) continue; +// int i2, i3; +// if ( (i2 = pyram->GetNodeIndex( node2 )) >= 0 && +// (i3 = pyram->GetNodeIndex( node3 )) >= 0 ) +// { +// // Triangle defines sub-domian inside the pyramid if it's +// // normal points out of the pyram + +// // make i2 and i3 hold indices of base nodes of the pyram while +// // keeping the nodes order in the triangle +// const int iApex = 4; +// if ( i2 == iApex ) +// i2 = i3, i3 = pyram->GetNodeIndex( node1 ); +// else if ( i3 == iApex ) +// i3 = i2, i2 = pyram->GetNodeIndex( node1 ); + +// int i3base = (i2+1) % 4; // next index after i2 within the pyramid base +// return ( i3base != i3 ); +// } +// } +// return false; +// } //======================================================================= //function : findShapeID @@ -318,150 +318,150 @@ static bool isTmpFace(const SMDS_MeshNode* node1, // points out of the domain it is associated to //======================================================================= -static int findShapeID(SMESH_Mesh& mesh, - const SMDS_MeshNode* node1, - const SMDS_MeshNode* node2, - const SMDS_MeshNode* node3, - const bool toMeshHoles) -{ - const int invalidID = 0; - SMESHDS_Mesh* meshDS = mesh.GetMeshDS(); - - // face the nodes belong to - std::vector nodes(3); - nodes[0] = node1; - nodes[1] = node2; - nodes[2] = node3; - const SMDS_MeshElement * face = meshDS->FindElement( nodes, SMDSAbs_Face, /*noMedium=*/true); - if ( !face ) - return isTmpFace(node1, node2, node3) ? HOLE_ID : invalidID; -#ifdef _DEBUG_ - std::cout << "bnd face " << face->GetID() << " - "; -#endif - // geom face the face assigned to - SMESH_MeshEditor editor(&mesh); - int geomFaceID = editor.FindShape( face ); - if ( !geomFaceID ) - return isTmpFace(node1, node2, node3) ? HOLE_ID : invalidID; - TopoDS_Shape shape = meshDS->IndexToShape( geomFaceID ); - if ( shape.IsNull() || shape.ShapeType() != TopAbs_FACE ) - return invalidID; - TopoDS_Face geomFace = TopoDS::Face( shape ); - - // solids bounded by geom face - TopTools_IndexedMapOfShape solids, shells; - TopTools_ListIteratorOfListOfShape ansIt = mesh.GetAncestors(geomFace); - for ( ; ansIt.More(); ansIt.Next() ) { - switch ( ansIt.Value().ShapeType() ) { - case TopAbs_SOLID: - solids.Add( ansIt.Value() ); break; - case TopAbs_SHELL: - shells.Add( ansIt.Value() ); break; - default:; - } - } - // analyse found solids - if ( solids.Extent() == 0 || shells.Extent() == 0) - return invalidID; +// static int findShapeID(SMESH_Mesh& mesh, +// const SMDS_MeshNode* node1, +// const SMDS_MeshNode* node2, +// const SMDS_MeshNode* node3, +// const bool toMeshHoles) +// { +// const int invalidID = 0; +// SMESHDS_Mesh* meshDS = mesh.GetMeshDS(); + +// // face the nodes belong to +// std::vector nodes(3); +// nodes[0] = node1; +// nodes[1] = node2; +// nodes[2] = node3; +// const SMDS_MeshElement * face = meshDS->FindElement( nodes, SMDSAbs_Face, /*noMedium=*/true); +// if ( !face ) +// return isTmpFace(node1, node2, node3) ? HOLE_ID : invalidID; +// #ifdef _DEBUG_ +// std::cout << "bnd face " << face->GetID() << " - "; +// #endif +// // geom face the face assigned to +// SMESH_MeshEditor editor(&mesh); +// int geomFaceID = editor.FindShape( face ); +// if ( !geomFaceID ) +// return isTmpFace(node1, node2, node3) ? HOLE_ID : invalidID; +// TopoDS_Shape shape = meshDS->IndexToShape( geomFaceID ); +// if ( shape.IsNull() || shape.ShapeType() != TopAbs_FACE ) +// return invalidID; +// TopoDS_Face geomFace = TopoDS::Face( shape ); + +// // solids bounded by geom face +// TopTools_IndexedMapOfShape solids, shells; +// TopTools_ListIteratorOfListOfShape ansIt = mesh.GetAncestors(geomFace); +// for ( ; ansIt.More(); ansIt.Next() ) { +// switch ( ansIt.Value().ShapeType() ) { +// case TopAbs_SOLID: +// solids.Add( ansIt.Value() ); break; +// case TopAbs_SHELL: +// shells.Add( ansIt.Value() ); break; +// default:; +// } +// } +// // analyse found solids +// if ( solids.Extent() == 0 || shells.Extent() == 0) +// return invalidID; - const TopoDS_Solid& solid1 = TopoDS::Solid( solids(1) ); - if ( solids.Extent() == 1 ) - { - if ( toMeshHoles ) - return meshDS->ShapeToIndex( solid1 ); - - // - Are we at a hole boundary face? - if ( shells(1).IsSame( BRepClass3d::OuterShell( solid1 )) ) - { // - No, but maybe a hole is bound by two shapes? Does shells(1) touches another shell? - bool touch = false; - TopExp_Explorer eExp( shells(1), TopAbs_EDGE ); - // check if any edge of shells(1) belongs to another shell - for ( ; eExp.More() && !touch; eExp.Next() ) { - ansIt = mesh.GetAncestors( eExp.Current() ); - for ( ; ansIt.More() && !touch; ansIt.Next() ) { - if ( ansIt.Value().ShapeType() == TopAbs_SHELL ) - touch = ( !ansIt.Value().IsSame( shells(1) )); - } - } - if (!touch) - return meshDS->ShapeToIndex( solid1 ); - } - } - // find orientation of geom face within the first solid - TopExp_Explorer fExp( solid1, TopAbs_FACE ); - for ( ; fExp.More(); fExp.Next() ) - if ( geomFace.IsSame( fExp.Current() )) { - geomFace = TopoDS::Face( fExp.Current() ); - break; - } - if ( !fExp.More() ) - return invalidID; // face not found - - // normale to triangle - gp_Pnt node1Pnt ( node1->X(), node1->Y(), node1->Z() ); - gp_Pnt node2Pnt ( node2->X(), node2->Y(), node2->Z() ); - gp_Pnt node3Pnt ( node3->X(), node3->Y(), node3->Z() ); - gp_Vec vec12( node1Pnt, node2Pnt ); - gp_Vec vec13( node1Pnt, node3Pnt ); - gp_Vec meshNormal = vec12 ^ vec13; - if ( meshNormal.SquareMagnitude() < DBL_MIN ) - return invalidID; - - // get normale to geomFace at any node - bool geomNormalOK = false; - gp_Vec geomNormal; - SMESH_MesherHelper helper( mesh ); helper.SetSubShape( geomFace ); - for ( int i = 0; !geomNormalOK && i < 3; ++i ) - { - // find UV of i-th node on geomFace - const SMDS_MeshNode* nNotOnSeamEdge = 0; - if ( helper.IsSeamShape( nodes[i]->getshapeId() )) { - if ( helper.IsSeamShape( nodes[(i+1)%3]->getshapeId() )) - nNotOnSeamEdge = nodes[(i+2)%3]; - else - nNotOnSeamEdge = nodes[(i+1)%3]; - } - bool uvOK; - gp_XY uv = helper.GetNodeUV( geomFace, nodes[i], nNotOnSeamEdge, &uvOK ); - // check that uv is correct - if (uvOK) { - double tol = 1e-6; - TopoDS_Shape nodeShape = helper.GetSubShapeByNode( nodes[i], meshDS ); - if ( !nodeShape.IsNull() ) - switch ( nodeShape.ShapeType() ) - { - case TopAbs_FACE: tol = BRep_Tool::Tolerance( TopoDS::Face( nodeShape )); break; - case TopAbs_EDGE: tol = BRep_Tool::Tolerance( TopoDS::Edge( nodeShape )); break; - case TopAbs_VERTEX: tol = BRep_Tool::Tolerance( TopoDS::Vertex( nodeShape )); break; - default:; - } - gp_Pnt nodePnt ( nodes[i]->X(), nodes[i]->Y(), nodes[i]->Z() ); - BRepAdaptor_Surface surface( geomFace ); - uvOK = ( nodePnt.Distance( surface.Value( uv.X(), uv.Y() )) < 2 * tol ); - if ( uvOK ) { - // normale to geomFace at UV - gp_Vec du, dv; - surface.D1( uv.X(), uv.Y(), nodePnt, du, dv ); - geomNormal = du ^ dv; - if ( geomFace.Orientation() == TopAbs_REVERSED ) - geomNormal.Reverse(); - geomNormalOK = ( geomNormal.SquareMagnitude() > DBL_MIN * 1e3 ); - } - } - } - if ( !geomNormalOK) - return invalidID; +// const TopoDS_Solid& solid1 = TopoDS::Solid( solids(1) ); +// if ( solids.Extent() == 1 ) +// { +// if ( toMeshHoles ) +// return meshDS->ShapeToIndex( solid1 ); + +// // - Are we at a hole boundary face? +// if ( shells(1).IsSame( BRepClass3d::OuterShell( solid1 )) ) +// { // - No, but maybe a hole is bound by two shapes? Does shells(1) touches another shell? +// bool touch = false; +// TopExp_Explorer eExp( shells(1), TopAbs_EDGE ); +// // check if any edge of shells(1) belongs to another shell +// for ( ; eExp.More() && !touch; eExp.Next() ) { +// ansIt = mesh.GetAncestors( eExp.Current() ); +// for ( ; ansIt.More() && !touch; ansIt.Next() ) { +// if ( ansIt.Value().ShapeType() == TopAbs_SHELL ) +// touch = ( !ansIt.Value().IsSame( shells(1) )); +// } +// } +// if (!touch) +// return meshDS->ShapeToIndex( solid1 ); +// } +// } +// // find orientation of geom face within the first solid +// TopExp_Explorer fExp( solid1, TopAbs_FACE ); +// for ( ; fExp.More(); fExp.Next() ) +// if ( geomFace.IsSame( fExp.Current() )) { +// geomFace = TopoDS::Face( fExp.Current() ); +// break; +// } +// if ( !fExp.More() ) +// return invalidID; // face not found + +// // normale to triangle +// gp_Pnt node1Pnt ( node1->X(), node1->Y(), node1->Z() ); +// gp_Pnt node2Pnt ( node2->X(), node2->Y(), node2->Z() ); +// gp_Pnt node3Pnt ( node3->X(), node3->Y(), node3->Z() ); +// gp_Vec vec12( node1Pnt, node2Pnt ); +// gp_Vec vec13( node1Pnt, node3Pnt ); +// gp_Vec meshNormal = vec12 ^ vec13; +// if ( meshNormal.SquareMagnitude() < DBL_MIN ) +// return invalidID; + +// // get normale to geomFace at any node +// bool geomNormalOK = false; +// gp_Vec geomNormal; +// SMESH_MesherHelper helper( mesh ); helper.SetSubShape( geomFace ); +// for ( int i = 0; !geomNormalOK && i < 3; ++i ) +// { +// // find UV of i-th node on geomFace +// const SMDS_MeshNode* nNotOnSeamEdge = 0; +// if ( helper.IsSeamShape( nodes[i]->getshapeId() )) { +// if ( helper.IsSeamShape( nodes[(i+1)%3]->getshapeId() )) +// nNotOnSeamEdge = nodes[(i+2)%3]; +// else +// nNotOnSeamEdge = nodes[(i+1)%3]; +// } +// bool uvOK; +// gp_XY uv = helper.GetNodeUV( geomFace, nodes[i], nNotOnSeamEdge, &uvOK ); +// // check that uv is correct +// if (uvOK) { +// double tol = 1e-6; +// TopoDS_Shape nodeShape = helper.GetSubShapeByNode( nodes[i], meshDS ); +// if ( !nodeShape.IsNull() ) +// switch ( nodeShape.ShapeType() ) +// { +// case TopAbs_FACE: tol = BRep_Tool::Tolerance( TopoDS::Face( nodeShape )); break; +// case TopAbs_EDGE: tol = BRep_Tool::Tolerance( TopoDS::Edge( nodeShape )); break; +// case TopAbs_VERTEX: tol = BRep_Tool::Tolerance( TopoDS::Vertex( nodeShape )); break; +// default:; +// } +// gp_Pnt nodePnt ( nodes[i]->X(), nodes[i]->Y(), nodes[i]->Z() ); +// BRepAdaptor_Surface surface( geomFace ); +// uvOK = ( nodePnt.Distance( surface.Value( uv.X(), uv.Y() )) < 2 * tol ); +// if ( uvOK ) { +// // normale to geomFace at UV +// gp_Vec du, dv; +// surface.D1( uv.X(), uv.Y(), nodePnt, du, dv ); +// geomNormal = du ^ dv; +// if ( geomFace.Orientation() == TopAbs_REVERSED ) +// geomNormal.Reverse(); +// geomNormalOK = ( geomNormal.SquareMagnitude() > DBL_MIN * 1e3 ); +// } +// } +// } +// if ( !geomNormalOK) +// return invalidID; - // compare normals - bool isReverse = ( meshNormal * geomNormal ) < 0; - if ( !isReverse ) - return meshDS->ShapeToIndex( solid1 ); +// // compare normals +// bool isReverse = ( meshNormal * geomNormal ) < 0; +// if ( !isReverse ) +// return meshDS->ShapeToIndex( solid1 ); - if ( solids.Extent() == 1 ) - return HOLE_ID; // we are inside a hole - else - return meshDS->ShapeToIndex( solids(2) ); -} +// if ( solids.Extent() == 1 ) +// return HOLE_ID; // we are inside a hole + +// return meshDS->ShapeToIndex( solids(2) ); +// } //======================================================================= diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx index 8f4e31a..22fef3c 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx @@ -24,9 +24,8 @@ //============================================================================= // #include "HYBRIDPlugin_Hypothesis.hxx" -#include -#include -#include + +#include #include