#include <boost/algorithm/string.hpp>
-namespace {
-
-#ifdef WIN32
-#include <windows.h>
-#else
-#include <sys/sysinfo.h>
-#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 <windows.h>
+// #else
+// #include <sys/sysinfo.h>
+// #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
HYBRIDPlugin::HYBRIDEnforcedVertexList_var vertices = h->GetEnforcedVertices();
MESSAGE("vertices->length(): " << vertices->length());
h_data.myEnforcedVertices.clear();
- for (int i=0 ; i<vertices->length() ; i++) {
+ for (CORBA::ULong i=0 ; i<vertices->length() ; i++) {
TEnfVertex* myVertex = new TEnfVertex();
myVertex->name = CORBA::string_dup(vertices[i].name.in());
myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
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);
}
HYBRIDPlugin::HYBRIDEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
MESSAGE("enfMeshes->length(): " << enfMeshes->length());
h_data.myEnforcedMeshes.clear();
- for (int i=0 ; i<enfMeshes->length() ; i++) {
+ for (CORBA::ULong i=0 ; i<enfMeshes->length() ; i++) {
TEnfMesh* myEnfMesh = new TEnfMesh();
myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
#include "HYBRIDPlugin_Hypothesis.hxx"
#include <SMDS_FaceOfNodes.hxx>
-#include <SMDS_MeshElement.hxx>
-#include <SMDS_MeshNode.hxx>
+#include <SMDS_LinearEdge.hxx>
#include <SMDS_VolumeOfNodes.hxx>
#include <SMESHDS_Group.hxx>
+#include <SMESHDS_Mesh.hxx>
#include <SMESH_Comment.hxx>
#include <SMESH_Group.hxx>
#include <SMESH_HypoFilter.hxx>
*/
//================================================================================
-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
// 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<const SMDS_MeshNode *> 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<const SMDS_MeshNode *> 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) );
+// }
//=======================================================================