Delete usaged StdMeshers_Helper. Fix bug 11772

This commit is contained in:
eap 2006-03-03 14:03:44 +00:00
parent 0e55a67f3c
commit afa9c16791
13 changed files with 303 additions and 351 deletions

View File

@ -24,78 +24,47 @@
//purpose : //purpose :
//======================================================================= //=======================================================================
bool StdMeshers_Helper::IsQuadraticSubMesh(const TopoDS_Shape& aSh, bool StdMeshers_Helper::IsQuadraticSubMesh(const TopoDS_Shape& aSh)
const bool QuadMode)
{ {
SMESHDS_Mesh* meshDS = GetMesh()->GetMeshDS(); SMESHDS_Mesh* meshDS = GetMesh()->GetMeshDS();
myShapeID = meshDS->ShapeToIndex(aSh); myShapeID = meshDS->ShapeToIndex(aSh);
myCreateQuadratic = false; // we can create quadratic elements only if all elements
if(QuadMode) { // created on given shape are quadratic
// we can create quadratic elements only if each elements
// created on given shape is quadratic
// also we have to fill myNLinkNodeMap // also we have to fill myNLinkNodeMap
myCreateQuadratic = true; myCreateQuadratic = true;
if(aSh.ShapeType()!=TopAbs_FACE) { TopAbs_ShapeEnum subType( aSh.ShapeType()==TopAbs_FACE ? TopAbs_EDGE : TopAbs_FACE );
for (TopExp_Explorer exp(aSh, TopAbs_FACE); exp.More() && myCreateQuadratic; exp.Next()) { SMDSAbs_ElementType elemType( subType==TopAbs_FACE ? SMDSAbs_Face : SMDSAbs_Edge );
const TopoDS_Face& F = TopoDS::Face(exp.Current());
SMDS_ElemIteratorPtr itf = GetMesh()->GetSubMesh(F)->GetSubMeshDS()->GetElements(); TopExp_Explorer exp( aSh, subType );
while(itf->more()) { for (; exp.More() && myCreateQuadratic; exp.Next()) {
const SMDS_MeshElement* f = itf->next(); if ( SMESHDS_SubMesh * subMesh = meshDS->MeshElements( exp.Current() )) {
if( f->GetType()==SMDSAbs_Face && !f->IsQuadratic() ) { if ( SMDS_ElemIteratorPtr it = subMesh->GetElements() ) {
myCreateQuadratic = false;
break;
}
SMDS_ElemIteratorPtr itn = f->nodesIterator();
if(f->NbNodes()==6) {
const SMDS_MeshNode* Ns[6];
int i = 0;
while(itn->more()) {
Ns[i++] = static_cast<const SMDS_MeshNode*>( itn->next() );
}
AddNLinkNode(Ns[0],Ns[1],Ns[3]);
AddNLinkNode(Ns[1],Ns[2],Ns[4]);
AddNLinkNode(Ns[2],Ns[0],Ns[5]);
}
else if(f->NbNodes()==8) {
const SMDS_MeshNode* Ns[8];
int i = 0;
while(itn->more()) {
Ns[i++] = static_cast<const SMDS_MeshNode*>( itn->next() );
}
AddNLinkNode(Ns[0],Ns[1],Ns[4]);
AddNLinkNode(Ns[1],Ns[2],Ns[5]);
AddNLinkNode(Ns[2],Ns[3],Ns[6]);
AddNLinkNode(Ns[3],Ns[0],Ns[7]);
}
}
}
}
else {
TopTools_MapOfShape aMap;
// check edges
const TopoDS_Face& F = TopoDS::Face(aSh);
const TopoDS_Wire& W = BRepTools::OuterWire(F);
BRepTools_WireExplorer wexp (W, F);
for (wexp.Init(W, F); wexp.More() && myCreateQuadratic; wexp.Next()) {
const TopoDS_Edge& E = wexp.Current();
if(aMap.Contains(E))
continue;
aMap.Add(E);
SMDS_ElemIteratorPtr it = GetMesh()->GetSubMesh(E)->GetSubMeshDS()->GetElements();
while(it->more()) { while(it->more()) {
const SMDS_MeshElement* e = it->next(); const SMDS_MeshElement* e = it->next();
if( e->GetType()==SMDSAbs_Edge && !e->IsQuadratic() ) { if ( e->GetType() != elemType || !e->IsQuadratic() ) {
myCreateQuadratic = false; myCreateQuadratic = false;
break; break;
} }
else {
// fill NLinkNodeMap // fill NLinkNodeMap
SMDS_ElemIteratorPtr nodeIt = e->nodesIterator(); switch ( e->NbNodes() ) {
const SMDS_MeshNode* n1 = static_cast<const SMDS_MeshNode*>( nodeIt->next() ); case 3:
const SMDS_MeshNode* n2 = static_cast<const SMDS_MeshNode*>( nodeIt->next() ); AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(2)); break;
const SMDS_MeshNode* n3 = static_cast<const SMDS_MeshNode*>( nodeIt->next() ); case 6:
NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 )); AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(3));
myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n3)); AddNLinkNode(e->GetNode(1),e->GetNode(2),e->GetNode(4));
myNLinkNodeMap[link] = n3; AddNLinkNode(e->GetNode(2),e->GetNode(0),e->GetNode(5)); break;
case 8:
AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(4));
AddNLinkNode(e->GetNode(1),e->GetNode(2),e->GetNode(5));
AddNLinkNode(e->GetNode(2),e->GetNode(3),e->GetNode(6));
AddNLinkNode(e->GetNode(3),e->GetNode(0),e->GetNode(7));
break;
default:
myCreateQuadratic = false;
break;
}
}
} }
} }
} }
@ -114,14 +83,18 @@ bool StdMeshers_Helper::IsQuadraticSubMesh(const TopoDS_Shape& aSh,
//purpose : //purpose :
//======================================================================= //=======================================================================
bool StdMeshers_Helper::IsMedium(const SMDS_MeshNode* n) bool StdMeshers_Helper::IsMedium(const SMDS_MeshNode* node,
const SMDSAbs_ElementType typeToCheck)
{ {
SMDS_ElemIteratorPtr it = n->GetInverseElementIterator(); bool isMedium = false;
SMDS_ElemIteratorPtr it = node->GetInverseElementIterator();
while (it->more()) { while (it->more()) {
const SMDS_MeshElement* elem = it->next(); const SMDS_MeshElement* elem = it->next();
return elem->IsMediumNode(n); isMedium = elem->IsMediumNode(node);
if ( typeToCheck == SMDSAbs_All || elem->GetType() == typeToCheck )
break;
} }
return false; return isMedium;
} }
@ -136,12 +109,10 @@ void StdMeshers_Helper::AddNLinkNode(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2, const SMDS_MeshNode* n2,
const SMDS_MeshNode* n12) const SMDS_MeshNode* n12)
{ {
NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 )); NLink link( n1, n2 );
ItNLinkNode itLN = myNLinkNodeMap.find( link ); if ( n1 > n2 ) link = NLink( n2, n1 );
if ( itLN == myNLinkNodeMap.end() ) {
// add new record to map // add new record to map
myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n12)); myNLinkNodeMap.insert( make_pair(link,n12));
}
} }

View File

@ -19,8 +19,14 @@ typedef pair<const SMDS_MeshNode*, const SMDS_MeshNode*> NLink;
typedef map<NLink, const SMDS_MeshNode*> NLinkNodeMap; typedef map<NLink, const SMDS_MeshNode*> NLinkNodeMap;
typedef map<NLink, const SMDS_MeshNode*>::iterator ItNLinkNode; typedef map<NLink, const SMDS_MeshNode*>::iterator ItNLinkNode;
/// Class StdMeshers_Helper /*!
// * \brief It helps meshers to add elements
*
* It allow meshers not to care about creation of medium nodes
* when filling a quadratic mesh. Helper does it itself.
* It defines degree of elements to create when IsQuadraticSubMesh()
* is called.
*/
class StdMeshers_Helper class StdMeshers_Helper
{ {
@ -42,17 +48,21 @@ class StdMeshers_Helper
/** /**
* Check submesh for given shape * Check submesh for given shape
* If QuadMode is true: check if all elements on this shape * Check if all elements on this shape
* are quadratic, if yes => set true to myCreateQuadratic * are quadratic, if yes => set true to myCreateQuadratic
* (default value is false). Also fill myNLinkNodeMap * (default value is false). Also fill myNLinkNodeMap
* Returns myCreateQuadratic * Returns myCreateQuadratic
*/ */
bool IsQuadraticSubMesh(const TopoDS_Shape& aSh, const bool QuadMode); bool IsQuadraticSubMesh(const TopoDS_Shape& theShape);
/** /*!
* Returns true if given node is medium * \brief Returns true if given node is medium
* \param n - node to check
* \param typeToCheck - type of elements containing the node to ask about node status
* \retval bool - check result
*/ */
bool IsMedium(const SMDS_MeshNode* n); static bool IsMedium(const SMDS_MeshNode* node,
const SMDSAbs_ElementType typeToCheck = SMDSAbs_All);
/** /**
* Auxilary function for filling myNLinkNodeMap * Auxilary function for filling myNLinkNodeMap

View File

@ -75,11 +75,10 @@ StdMeshers_Hexa_3D::StdMeshers_Hexa_3D(int hypId, int studyId,
{ {
MESSAGE("StdMeshers_Hexa_3D::StdMeshers_Hexa_3D"); MESSAGE("StdMeshers_Hexa_3D::StdMeshers_Hexa_3D");
_name = "Hexa_3D"; _name = "Hexa_3D";
// _shapeType = TopAbs_SOLID;
_shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
// MESSAGE("_shapeType octal " << oct << _shapeType);
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
_quads[i] = 0; _quads[i] = 0;
myTool = 0;
} }
//============================================================================= //=============================================================================
@ -91,10 +90,28 @@ StdMeshers_Hexa_3D::StdMeshers_Hexa_3D(int hypId, int studyId,
StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D() StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D()
{ {
MESSAGE("StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D"); MESSAGE("StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D");
ClearAndReturn(true);
}
//================================================================================
/*!
* \brief Clear fields and return the argument
* \param res - the value to return
* \retval bool - the argument value
*/
//================================================================================
bool StdMeshers_Hexa_3D::ClearAndReturn(const bool res)
{
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
StdMeshers_Quadrangle_2D::QuadDelete(_quads[i]); StdMeshers_Quadrangle_2D::QuadDelete(_quads[i]);
if ( myTool )
delete myTool;
myTool = 0;
return res;
} }
//============================================================================= //=============================================================================
/*! /*!
* *
@ -166,20 +183,12 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
MESSAGE("StdMeshers_Hexa_3D::Compute"); MESSAGE("StdMeshers_Hexa_3D::Compute");
//bool isOk = false;
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
//SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
//const SMESHDS_SubMesh *& subMeshDS = theSubMesh->GetSubMeshDS();
// 0. - shape and face mesh verification // 0. - shape and face mesh verification
// 0.1 - shape must be a solid (or a shell) with 6 faces // 0.1 - shape must be a solid (or a shell) with 6 faces
//MESSAGE("---"); //MESSAGE("---");
bool QuadMode = true;
myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
vector < SMESH_subMesh * >meshFaces; vector < SMESH_subMesh * >meshFaces;
for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) { for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
SMESH_subMesh *aSubMesh = aMesh.GetSubMeshContaining(exp.Current()); SMESH_subMesh *aSubMesh = aMesh.GetSubMeshContaining(exp.Current());
@ -188,13 +197,15 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
} }
if (meshFaces.size() != 6) { if (meshFaces.size() != 6) {
SCRUTE(meshFaces.size()); SCRUTE(meshFaces.size());
// ASSERT(0);
return false; return false;
} }
// 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges) // 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges)
//MESSAGE("---"); //MESSAGE("---");
myTool = new StdMeshers_Helper(aMesh);
_quadraticMesh = myTool->IsQuadraticSubMesh(aShape);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
TopoDS_Shape aFace = meshFaces[i]->GetSubShape(); TopoDS_Shape aFace = meshFaces[i]->GetSubShape();
SMESH_Algo *algo = _gen->GetAlgo(aMesh, aFace); SMESH_Algo *algo = _gen->GetAlgo(aMesh, aFace);
@ -207,39 +218,23 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
SMDS_ElemIteratorPtr eIt = sm->GetElements(); SMDS_ElemIteratorPtr eIt = sm->GetElements();
while ( isAllQuad && eIt->more() ) { while ( isAllQuad && eIt->more() ) {
const SMDS_MeshElement* elem = eIt->next(); const SMDS_MeshElement* elem = eIt->next();
isAllQuad = ( elem->NbNodes()==4 ||(myCreateQuadratic && elem->NbNodes()==8) ); isAllQuad = ( elem->NbNodes()==4 ||(_quadraticMesh && elem->NbNodes()==8) );
} }
} }
} }
if ( ! isAllQuad ) { if ( ! isAllQuad ) {
//modified by NIZNHY-PKV Wed Nov 17 15:31:37 2004 f //modified by NIZNHY-PKV Wed Nov 17 15:31:37 2004 f
bool bIsOk; bool bIsOk = ComputePentahedralMesh(aMesh, aShape);
// return ClearAndReturn( bIsOk );
bIsOk = ComputePentahedralMesh(aMesh, aShape);
if (bIsOk) {
return true;
}
//modified by NIZNHY-PKV Wed Nov 17 15:31:42 2004 t
SCRUTE(algoName);
// ASSERT(0);
return false;
} }
StdMeshers_Quadrangle_2D *quadAlgo = StdMeshers_Quadrangle_2D *quadAlgo =
dynamic_cast < StdMeshers_Quadrangle_2D * >(algo); dynamic_cast < StdMeshers_Quadrangle_2D * >(algo);
ASSERT(quadAlgo); ASSERT(quadAlgo);
try { try {
_quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aFace, myCreateQuadratic); _quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aFace, _quadraticMesh);
// add links created in quadAlgo into myNLinkNodeMap
// NLinkNodeMap aMap = quadAlgo->GetNLinkNodeMap();
// myNLinkNodeMap.insert(aMap.begin(), aMap.end());
myTool->AddNLinkNodeMap(quadAlgo->GetNLinkNodeMap());
// *** to delete after usage
} }
catch(SALOME_Exception & S_ex) { catch(SALOME_Exception & S_ex) {
// *** delete _quads return ClearAndReturn( false );
// *** throw exception
// ASSERT(0);
return false;
} }
// 0.2.1 - number of points on the opposite edges must be the same // 0.2.1 - number of points on the opposite edges must be the same
@ -247,7 +242,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
_quads[i]->nbPts[1] != _quads[i]->nbPts[3]) { _quads[i]->nbPts[1] != _quads[i]->nbPts[3]) {
MESSAGE("different number of points on the opposite edges of face " << i); MESSAGE("different number of points on the opposite edges of face " << i);
// ASSERT(0); // ASSERT(0);
return false; return ClearAndReturn( false );
} }
} }
@ -748,7 +743,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
} }
if ( np ) delete [] np; if ( np ) delete [] np;
//MESSAGE("End of StdMeshers_Hexa_3D::Compute()"); //MESSAGE("End of StdMeshers_Hexa_3D::Compute()");
return true; return ClearAndReturn( true );
} }
//============================================================================= //=============================================================================

View File

@ -129,6 +129,8 @@ protected:
Point3DStruct *np, Point3DStruct *np,
const SMESHDS_Mesh* meshDS); const SMESHDS_Mesh* meshDS);
bool ClearAndReturn(const bool res);
CubeStruct _cube; CubeStruct _cube;
FaceQuadStruct* _quads[6]; FaceQuadStruct* _quads[6];
int _indX0; int _indX0;

View File

@ -76,7 +76,6 @@ StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D(int hypId, int studyId,
{ {
MESSAGE("StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D"); MESSAGE("StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D");
_name = "MEFISTO_2D"; _name = "MEFISTO_2D";
// _shapeType = TopAbs_FACE;
_shapeType = (1 << TopAbs_FACE); _shapeType = (1 << TopAbs_FACE);
_compatibleHypothesis.push_back("MaxElementArea"); _compatibleHypothesis.push_back("MaxElementArea");
_compatibleHypothesis.push_back("LengthFromEdges"); _compatibleHypothesis.push_back("LengthFromEdges");
@ -85,6 +84,7 @@ StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D(int hypId, int studyId,
_maxElementArea = 0; _maxElementArea = 0;
_hypMaxElementArea = NULL; _hypMaxElementArea = NULL;
_hypLengthFromEdges = NULL; _hypLengthFromEdges = NULL;
myTool = 0;
} }
//============================================================================= //=============================================================================
@ -220,15 +220,15 @@ bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
int iw = 1; int iw = 1;
int nbpnt = 0; int nbpnt = 0;
bool QuadMode = true;
myTool = new StdMeshers_Helper(aMesh); myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode); _quadraticMesh = myTool->IsQuadraticSubMesh(aShape);
myOuterWire = BRepTools::OuterWire(F); myOuterWire = BRepTools::OuterWire(F);
nbpnt += NumberOfPoints(aMesh, myOuterWire); nbpnt += NumberOfPoints(aMesh, myOuterWire);
if ( nbpnt < 3 ) // ex: a circle with 2 segments if ( nbpnt < 3 ) { // ex: a circle with 2 segments
delete myTool; myTool = 0;
return false; return false;
}
nudslf[iw++] = nbpnt; nudslf[iw++] = nbpnt;
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) { for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) {
@ -252,8 +252,10 @@ bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
map<int, const SMDS_MeshNode*> mefistoToDS; // correspondence mefisto index--> points IDNodes map<int, const SMDS_MeshNode*> mefistoToDS; // correspondence mefisto index--> points IDNodes
if ( !LoadPoints(aMesh, F, myOuterWire, uvslf, m, if ( !LoadPoints(aMesh, F, myOuterWire, uvslf, m,
mefistoToDS, scalex, scaley, VWMap) ) mefistoToDS, scalex, scaley, VWMap) ) {
delete myTool; myTool = 0;
return false; return false;
}
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{ {
@ -261,10 +263,12 @@ bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
if (!myOuterWire.IsSame(W)) if (!myOuterWire.IsSame(W))
{ {
if (! LoadPoints(aMesh, F, W, uvslf, m, if (! LoadPoints(aMesh, F, W, uvslf, m,
mefistoToDS, scalex, scaley, VWMap )) mefistoToDS, scalex, scaley, VWMap )) {
delete myTool; myTool = 0;
return false; return false;
} }
} }
}
uvst = NULL; uvst = NULL;
nust = NULL; nust = NULL;
@ -292,6 +296,8 @@ bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
delete[]uvst; delete[]uvst;
if (nust != NULL) if (nust != NULL)
delete[]nust; delete[]nust;
delete myTool; myTool = 0;
return isOk; return isOk;
} }
@ -422,22 +428,9 @@ static bool fixCommonVertexUV (gp_Pnt2d & theUV,
else { else {
while ( nIt->more() ) { while ( nIt->more() ) {
const SMDS_MeshNode* node = nIt->next(); const SMDS_MeshNode* node = nIt->next();
if(CreateQuadratic) {
// check if node is medium // check if node is medium
bool IsMedium = false; if ( CreateQuadratic && StdMeshers_Helper::IsMedium( node, SMDSAbs_Edge ))
SMDS_ElemIteratorPtr itn = node->GetInverseElementIterator();
while (itn->more()) {
const SMDS_MeshElement* elem = itn->next();
if ( elem->GetType() != SMDSAbs_Edge )
continue; continue;
if(elem->IsMediumNode(node)) {
IsMedium = true;
break;
}
}
if(IsMedium)
continue;
}
const SMDS_EdgePosition* epos = const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get()); static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double u = epos->GetUParameter(); double u = epos->GetUParameter();
@ -530,24 +523,9 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
} }
const SMDS_MeshNode* idLast = lid->next(); const SMDS_MeshNode* idLast = lid->next();
// --- edge internal IDNodes (relies on good order storage, not checked)
// if(myCreateQuadratic) {
// fill myNLinkNodeMap
// SMDS_ElemIteratorPtr iter = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetElements();
// while(iter->more()) {
// const SMDS_MeshElement* elem = iter->next();
// SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
// const SMDS_MeshNode* n1 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// const SMDS_MeshNode* n2 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// const SMDS_MeshNode* n3 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 ));
// myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n3));
// myNLinkNodeMap[link] = n3;
// }
// }
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if ( _quadraticMesh )
nbPoints /= 2;
double f, l; double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
@ -557,39 +535,15 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
//bool isForward = (E.Orientation() == TopAbs_FORWARD); //bool isForward = (E.Orientation() == TopAbs_FORWARD);
map<double, const SMDS_MeshNode*> params; map<double, const SMDS_MeshNode*> params;
if(!myCreateQuadratic) {
while(ite->more()) { while(ite->more()) {
const SMDS_MeshNode * node = ite->next(); const SMDS_MeshNode * node = ite->next();
const SMDS_EdgePosition* epos = if ( _quadraticMesh && StdMeshers_Helper::IsMedium( node, SMDSAbs_Edge ))
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double param = epos->GetUParameter();
params[param] = node;
}
}
else {
nbPoints = nbPoints/2;
while(ite->more()) {
const SMDS_MeshNode* node = ite->next();
// check if node is medium
bool IsMedium = false;
SMDS_ElemIteratorPtr itn = node->GetInverseElementIterator();
while (itn->more()) {
const SMDS_MeshElement* elem = itn->next();
if ( elem->GetType() != SMDSAbs_Edge )
continue;
if(elem->IsMediumNode(node)) {
IsMedium = true;
break;
}
}
if(IsMedium)
continue; continue;
const SMDS_EdgePosition* epos = const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get()); static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double param = epos->GetUParameter(); double param = epos->GetUParameter();
params[param] = node; params[param] = node;
} }
}
if ( nbPoints != params.size()) { if ( nbPoints != params.size()) {
MESSAGE( "BAD NODE ON EDGE POSITIONS" ); MESSAGE( "BAD NODE ON EDGE POSITIONS" );
@ -602,13 +556,13 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
// add IDNodes in mefistoToDS map // add IDNodes in mefistoToDS map
if (E.Orientation() == TopAbs_FORWARD) { if (E.Orientation() == TopAbs_FORWARD) {
gp_Pnt2d p = C2d->Value(f).XY().Multiplied( scale ); // first point = Vertex Forward gp_Pnt2d p = C2d->Value(f).XY().Multiplied( scale ); // first point = Vertex Forward
if ( fixCommonVertexUV( p, VFirst, W, myOuterWire, F, VWMap, aMesh, myCreateQuadratic )) if ( fixCommonVertexUV( p, VFirst, W, myOuterWire, F, VWMap, aMesh, _quadraticMesh ))
myNodesOnCommonV.push_back( idFirst ); myNodesOnCommonV.push_back( idFirst );
uvslf[m].x = p.X(); uvslf[m].x = p.X();
uvslf[m].y = p.Y(); uvslf[m].y = p.Y();
mefistoToDS[m + 1] = idFirst; mefistoToDS[m + 1] = idFirst;
//MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]); // MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
//MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y); // MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++; m++;
map<double, const SMDS_MeshNode*>::iterator itp = params.begin(); map<double, const SMDS_MeshNode*>::iterator itp = params.begin();
for (int i = 1; i <= nbPoints; i++) { // nbPoints internal for (int i = 1; i <= nbPoints; i++) { // nbPoints internal
@ -617,21 +571,21 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
uvslf[m].x = p.X(); uvslf[m].x = p.X();
uvslf[m].y = p.Y(); uvslf[m].y = p.Y();
mefistoToDS[m + 1] = (*itp).second; mefistoToDS[m + 1] = (*itp).second;
//MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]); // MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
//MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y); // MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++; m++;
itp++; itp++;
} }
} }
else { else {
gp_Pnt2d p = C2d->Value(l).XY().Multiplied( scale ); // last point = Vertex Reversed gp_Pnt2d p = C2d->Value(l).XY().Multiplied( scale ); // last point = Vertex Reversed
if ( fixCommonVertexUV( p, VLast, W, myOuterWire, F, VWMap, aMesh, myCreateQuadratic )) if ( fixCommonVertexUV( p, VLast, W, myOuterWire, F, VWMap, aMesh, _quadraticMesh ))
myNodesOnCommonV.push_back( idLast ); myNodesOnCommonV.push_back( idLast );
uvslf[m].x = p.X(); uvslf[m].x = p.X();
uvslf[m].y = p.Y(); uvslf[m].y = p.Y();
mefistoToDS[m + 1] = idLast; mefistoToDS[m + 1] = idLast;
//MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]); // MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
//MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y); // MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++; m++;
map<double, const SMDS_MeshNode*>::reverse_iterator itp = params.rbegin(); map<double, const SMDS_MeshNode*>::reverse_iterator itp = params.rbegin();
for (int i = nbPoints; i >= 1; i--) for (int i = nbPoints; i >= 1; i--)
@ -641,23 +595,27 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
uvslf[m].x = p.X(); uvslf[m].x = p.X();
uvslf[m].y = p.Y(); uvslf[m].y = p.Y();
mefistoToDS[m + 1] = (*itp).second; mefistoToDS[m + 1] = (*itp).second;
//MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]); // MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
//MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y); // MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++; m++;
itp++; itp++;
} }
} }
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/// !!!!!!! HERE IS A BUG with fixOverlappedLinkUV !!!!!!!!!!!
// !!!!!!! Correct version is in the CVS head !!!!!!!!!!
/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// prevent failure on overlapped adjacent links // prevent failure on overlapped adjacent links
if ( iEdge > 0 ) // if ( iEdge > 0 )
fixOverlappedLinkUV (uvslf[ mFirst - 1], // fixOverlappedLinkUV (uvslf[ mFirst - 1],
uvslf[ mFirst ], // uvslf[ mFirst ],
uvslf[ mFirst + 1 ]); // uvslf[ mFirst + 1 ]);
} // for wexp } // for wexp
fixOverlappedLinkUV (uvslf[ m - 1], // fixOverlappedLinkUV (uvslf[ m - 1],
uvslf[ mInit ], // uvslf[ mInit ],
uvslf[ mInit + 1 ]); // uvslf[ mInit + 1 ]);
return true; return true;
} }
@ -859,17 +817,14 @@ double StdMeshers_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh & aMesh,
//MESSAGE("StdMeshers_MEFISTO_2D::ComputeEdgeElementLength"); //MESSAGE("StdMeshers_MEFISTO_2D::ComputeEdgeElementLength");
// **** a mettre dans SMESH_2D_Algo ? // **** a mettre dans SMESH_2D_Algo ?
const TopoDS_Face & FF = TopoDS::Face(aShape); //const TopoDS_Face & FF = TopoDS::Face(aShape);
//bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); //bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); //TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
double meanElementLength = 100; double meanElementLength = 100;
double wireLength = 0; double wireLength = 0;
int wireElementsNumber = 0; int wireElementsNumber = 0;
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) for (TopExp_Explorer expe(aShape, TopAbs_EDGE); expe.More(); expe.Next())
{
const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
for (TopExp_Explorer expe(W, TopAbs_EDGE); expe.More(); expe.Next())
{ {
const TopoDS_Edge & E = TopoDS::Edge(expe.Current()); const TopoDS_Edge & E = TopoDS::Edge(expe.Current());
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
@ -877,7 +832,6 @@ double StdMeshers_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh & aMesh,
wireLength += length; wireLength += length;
wireElementsNumber += nb; wireElementsNumber += nb;
} }
}
if (wireElementsNumber) if (wireElementsNumber)
meanElementLength = wireLength / wireElementsNumber; meanElementLength = wireLength / wireElementsNumber;
//SCRUTE(meanElementLength); //SCRUTE(meanElementLength);

View File

@ -73,8 +73,19 @@ StdMeshers_Penta_3D::StdMeshers_Penta_3D()
myTol3D=0.1; myTol3D=0.1;
myWallNodesMaps.resize( SMESH_Block::NbFaces() ); myWallNodesMaps.resize( SMESH_Block::NbFaces() );
myShapeXYZ.resize( SMESH_Block::NbSubShapes() ); myShapeXYZ.resize( SMESH_Block::NbSubShapes() );
myTool = 0;
} }
//=======================================================================
//function : ~StdMeshers_Penta_3D
//purpose :
//=======================================================================
StdMeshers_Penta_3D::~StdMeshers_Penta_3D()
{
if ( myTool )
delete myTool;
}
//======================================================================= //=======================================================================
//function : Compute //function : Compute
@ -97,24 +108,25 @@ bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh,
return bOK; return bOK;
} }
bool QuadMode = true;
myTool = new StdMeshers_Helper(aMesh); myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode); myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape);
// //
MakeBlock(); MakeBlock();
if (myErrorStatus){ if (myErrorStatus){
delete myTool; myTool = 0;
return bOK; return bOK;
} }
// //
ClearMeshOnFxy1(); ClearMeshOnFxy1();
if (myErrorStatus) { if (myErrorStatus) {
delete myTool; myTool = 0;
return bOK; return bOK;
} }
// //
MakeNodes(); MakeNodes();
if (myErrorStatus){ if (myErrorStatus){
delete myTool; myTool = 0;
return bOK; return bOK;
} }
// //
@ -122,11 +134,13 @@ bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh,
// //
MakeMeshOnFxy1(); MakeMeshOnFxy1();
if (myErrorStatus) { if (myErrorStatus) {
delete myTool; myTool = 0;
return bOK; return bOK;
} }
// //
MakeVolumeMesh(); MakeVolumeMesh();
// //
delete myTool; myTool = 0;
return !bOK; return !bOK;
} }

View File

@ -168,7 +168,7 @@ class StdMeshers_Penta_3D {
public: // methods public: // methods
StdMeshers_Penta_3D(); StdMeshers_Penta_3D();
//~StdMeshers_Penta_3D(); ~StdMeshers_Penta_3D();
bool Compute(SMESH_Mesh& , const TopoDS_Shape& ); bool Compute(SMESH_Mesh& , const TopoDS_Shape& );

View File

@ -38,7 +38,7 @@ StdMeshers_Propagation::StdMeshers_Propagation (int hypId, int studyId,
: SMESH_Hypothesis(hypId, studyId, gen) : SMESH_Hypothesis(hypId, studyId, gen)
{ {
_name = GetName(); _name = GetName();
_param_algo_dim = -2; _param_algo_dim = -1; // 1D auxiliary
} }
//============================================================================= //=============================================================================

View File

@ -81,6 +81,7 @@ StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, SMES
_name = "Quadrangle_2D"; _name = "Quadrangle_2D";
_shapeType = (1 << TopAbs_FACE); _shapeType = (1 << TopAbs_FACE);
_compatibleHypothesis.push_back("QuadranglePreference"); _compatibleHypothesis.push_back("QuadranglePreference");
myTool = 0;
} }
//============================================================================= //=============================================================================
@ -92,6 +93,8 @@ StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, SMES
StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D() StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D()
{ {
MESSAGE("StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D"); MESSAGE("StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D");
if ( myTool )
delete myTool;
} }
//============================================================================= //=============================================================================
@ -129,16 +132,17 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
aMesh.GetSubMesh(aShape); aMesh.GetSubMesh(aShape);
bool QuadMode = true; if ( !myTool )
myTool = new StdMeshers_Helper(aMesh); myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode); _quadraticMesh = myTool->IsQuadraticSubMesh(aShape);
//FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape); //FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
FaceQuadStruct* quad = CheckNbEdges(aMesh, aShape); FaceQuadStruct* quad = CheckNbEdges(aMesh, aShape);
if (!quad) if (!quad) {
delete myTool; myTool = 0;
return false; return false;
}
if(myQuadranglePreference) { if(myQuadranglePreference) {
int n1 = quad->nbPts[0]; int n1 = quad->nbPts[0];
@ -150,14 +154,18 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
ntmp = ntmp*2; ntmp = ntmp*2;
if( nfull==ntmp && ( (n1!=n3) || (n2!=n4) ) ) { if( nfull==ntmp && ( (n1!=n3) || (n2!=n4) ) ) {
// special path for using only quandrangle faces // special path for using only quandrangle faces
return ComputeQuadPref(aMesh, aShape, quad); bool ok = ComputeQuadPref(aMesh, aShape, quad);
delete myTool; myTool = 0;
return ok;
} }
} }
// set normalized grid on unit square in parametric domain // set normalized grid on unit square in parametric domain
SetNormalizedGrid(aMesh, aShape, quad); SetNormalizedGrid(aMesh, aShape, quad);
if (!quad) if (!quad) {
delete myTool; myTool = 0;
return false; return false;
}
// --- compute 3D values on points, store points & quadrangles // --- compute 3D values on points, store points & quadrangles
@ -542,6 +550,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
} }
QuadDelete(quad); QuadDelete(quad);
delete myTool; myTool = 0;
bool isOk = true; bool isOk = true;
return isOk; return isOk;
} }
@ -581,7 +591,7 @@ FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbEdges < 4) { if (nbEdges < 4) {
quad->edge[nbEdges] = E; quad->edge[nbEdges] = E;
if(!myCreateQuadratic) { if(!_quadraticMesh) {
quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
} }
else { else {
@ -601,23 +611,6 @@ FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
return quad; return quad;
} }
//=============================================================================
/*!
* CheckAnd2Dcompute
*/
//=============================================================================
FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) throw(SALOME_Exception)
{
bool QuadMode = true;
myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
return CheckAnd2Dcompute(aMesh,aShape,myCreateQuadratic);
}
//============================================================================= //=============================================================================
/*! /*!
* CheckAnd2Dcompute * CheckAnd2Dcompute
@ -631,7 +624,7 @@ FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
{ {
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
myCreateQuadratic = CreateQuadratic; _quadraticMesh = CreateQuadratic;
FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape); FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
@ -1437,7 +1430,7 @@ UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints2 (SMESH_Mesh & aMesh,
// --- edge internal IDNodes (relies on good order storage, not checked) // --- edge internal IDNodes (relies on good order storage, not checked)
// if(myCreateQuadratic) { // if(_quadraticMesh) {
// fill myNLinkNodeMap // fill myNLinkNodeMap
// SMDS_ElemIteratorPtr iter = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetElements(); // SMDS_ElemIteratorPtr iter = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetElements();
// while(iter->more()) { // while(iter->more()) {
@ -1456,7 +1449,7 @@ UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints2 (SMESH_Mesh & aMesh,
SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes(); SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if(!myCreateQuadratic) { if(!_quadraticMesh) {
while(ite->more()) { while(ite->more()) {
const SMDS_MeshNode* node = ite->next(); const SMDS_MeshNode* node = ite->next();
const SMDS_EdgePosition* epos = const SMDS_EdgePosition* epos =
@ -1619,7 +1612,7 @@ UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints (SMESH_Mesh & aMesh,
// --- edge internal IDNodes (relies on good order storage, not checked) // --- edge internal IDNodes (relies on good order storage, not checked)
// if(myCreateQuadratic) { // if(_quadraticMesh) {
// fill myNLinkNodeMap // fill myNLinkNodeMap
// SMDS_ElemIteratorPtr iter = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetElements(); // SMDS_ElemIteratorPtr iter = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetElements();
// while(iter->more()) { // while(iter->more()) {
@ -1638,7 +1631,7 @@ UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints (SMESH_Mesh & aMesh,
SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes(); SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if(!myCreateQuadratic) { if(!_quadraticMesh) {
while(ite->more()) { while(ite->more()) {
const SMDS_MeshNode* node = ite->next(); const SMDS_MeshNode* node = ite->next();
const SMDS_EdgePosition* epos = const SMDS_EdgePosition* epos =

View File

@ -78,10 +78,6 @@ public:
const TopoDS_Shape& aShape) const TopoDS_Shape& aShape)
throw (SALOME_Exception); throw (SALOME_Exception);
FaceQuadStruct* CheckAnd2Dcompute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
throw (SALOME_Exception);
FaceQuadStruct* CheckAnd2Dcompute(SMESH_Mesh& aMesh, FaceQuadStruct* CheckAnd2Dcompute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape, const TopoDS_Shape& aShape,
const bool CreateQuadratic) const bool CreateQuadratic)

View File

@ -42,10 +42,7 @@ StdMeshers_QuadraticMesh::StdMeshers_QuadraticMesh(int hypId,
:SMESH_Hypothesis(hypId, studyId, gen) :SMESH_Hypothesis(hypId, studyId, gen)
{ {
_name = "QuadraticMesh"; _name = "QuadraticMesh";
// only one hypo of the same dim can be assigned to the shape so _param_algo_dim = -1; // it means auxiliary, dim = 1
// we use -3 in order to distingush from any usual 1D hypothsis and
// from "NotConformAllowed" (-1) and "Propagation" (-2)
_param_algo_dim = -3;
} }
//============================================================================= //=============================================================================

View File

@ -90,6 +90,8 @@ StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId,
_compatibleHypothesis.push_back("Deflection1D"); _compatibleHypothesis.push_back("Deflection1D");
_compatibleHypothesis.push_back("Arithmetic1D"); _compatibleHypothesis.push_back("Arithmetic1D");
_compatibleHypothesis.push_back("AutomaticLength"); _compatibleHypothesis.push_back("AutomaticLength");
_compatibleHypothesis.push_back("QuadraticMesh"); // auxiliary !!!
} }
//============================================================================= //=============================================================================
@ -114,17 +116,32 @@ bool StdMeshers_Regular_1D::CheckHypothesis
SMESH_Hypothesis::Hypothesis_Status& aStatus) SMESH_Hypothesis::Hypothesis_Status& aStatus)
{ {
_hypType = NONE; _hypType = NONE;
_quadraticMesh = false;
const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape); const bool ignoreAuxiliaryHyps = false;
if (hyps.size() == 0) const list <const SMESHDS_Hypothesis * > & hyps =
GetUsedHypothesis(aMesh, aShape, ignoreAuxiliaryHyps);
// find non-auxiliary hypothesis
const SMESHDS_Hypothesis *theHyp = 0;
list <const SMESHDS_Hypothesis * >::const_iterator h = hyps.begin();
for ( ; h != hyps.end(); ++h ) {
if ( static_cast<const SMESH_Hypothesis*>(*h)->IsAuxiliary() ) {
if ( strcmp( "QuadraticMesh", (*h)->GetName() ) == 0 )
_quadraticMesh = true;
}
else {
if ( !theHyp )
theHyp = *h; // use only the first non-auxiliary hypothesis
}
}
if ( !theHyp )
{ {
aStatus = SMESH_Hypothesis::HYP_MISSING; aStatus = SMESH_Hypothesis::HYP_MISSING;
return false; // can't work without a hypothesis return false; // can't work without a hypothesis
} }
// use only the first hypothesis
const SMESHDS_Hypothesis *theHyp = hyps.front();
string hypName = theHyp->GetName(); string hypName = theHyp->GetName();
if (hypName == "LocalLength") if (hypName == "LocalLength")
@ -508,10 +525,6 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
aMesh.GetSubMesh(aShape); aMesh.GetSubMesh(aShape);
// quardatic mesh required?
SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "QuadraticMesh" ));
bool QuadMode = aMesh.GetHypothesis( aShape, filter, true );
const TopoDS_Edge & EE = TopoDS::Edge(aShape); const TopoDS_Edge & EE = TopoDS::Edge(aShape);
TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
int shapeID = meshDS->ShapeToIndex( E ); int shapeID = meshDS->ShapeToIndex( E );
@ -558,10 +571,10 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
const SMDS_MeshNode * idPrev = idFirst; const SMDS_MeshNode * idPrev = idFirst;
double parPrev = f; double parPrev = f;
double parLast = l; double parLast = l;
if(reversed) { // if(reversed) {
parPrev = l; // parPrev = l;
parLast = f; // parLast = f;
} // }
for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) { for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) {
double param = *itU; double param = *itU;
@ -571,7 +584,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnEdge(node, shapeID, param); meshDS->SetNodeOnEdge(node, shapeID, param);
if(QuadMode) { if(_quadraticMesh) {
// create medium node // create medium node
double prm = ( parPrev + param )/2; double prm = ( parPrev + param )/2;
gp_Pnt PM = Curve->Value(prm); gp_Pnt PM = Curve->Value(prm);
@ -588,7 +601,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
idPrev = node; idPrev = node;
parPrev = param; parPrev = param;
} }
if(QuadMode) { if(_quadraticMesh) {
double prm = ( parPrev + parLast )/2; double prm = ( parPrev + parLast )/2;
gp_Pnt PM = Curve->Value(prm); gp_Pnt PM = Curve->Value(prm);
SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z()); SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
@ -603,7 +616,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
} }
else { else {
// Edge is a degenerated Edge : We put n = 5 points on the edge. // Edge is a degenerated Edge : We put n = 5 points on the edge.
int NbPoints = 5; const int NbPoints = 5;
BRep_Tool::Range(E, f, l); BRep_Tool::Range(E, f, l);
double du = (l - f) / (NbPoints - 1); double du = (l - f) / (NbPoints - 1);
//MESSAGE("************* Degenerated edge! *****************"); //MESSAGE("************* Degenerated edge! *****************");
@ -616,7 +629,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
for (int i = 2; i < NbPoints; i++) { for (int i = 2; i < NbPoints; i++) {
double param = f + (i - 1) * du; double param = f + (i - 1) * du;
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
if(QuadMode) { if(_quadraticMesh) {
// create medium node // create medium node
double prm = param - du/2.; double prm = param - du/2.;
gp_Pnt PM = Curve->Value(prm); gp_Pnt PM = Curve->Value(prm);
@ -632,7 +645,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
meshDS->SetNodeOnEdge(node, shapeID, param); meshDS->SetNodeOnEdge(node, shapeID, param);
idPrev = node; idPrev = node;
} }
if(QuadMode) { if(_quadraticMesh) {
// create medium node // create medium node
double prm = l - du/2.; double prm = l - du/2.;
gp_Pnt PM = Curve->Value(prm); gp_Pnt PM = Curve->Value(prm);
@ -655,40 +668,47 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
*/ */
//============================================================================= //=============================================================================
const list <const SMESHDS_Hypothesis *> & StdMeshers_Regular_1D::GetUsedHypothesis( const list <const SMESHDS_Hypothesis *> &
SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) StdMeshers_Regular_1D::GetUsedHypothesis(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool ignoreAuxiliary)
{ {
_usedHypList.clear(); _usedHypList.clear();
_usedHypList = GetAppliedHypothesis(aMesh, aShape); // copy
int nbHyp = _usedHypList.size();
_mainEdge.Nullify(); _mainEdge.Nullify();
SMESH_HypoFilter auxiliaryFilter, compatibleFilter;
auxiliaryFilter.Init( SMESH_HypoFilter::IsAuxiliary() );
const bool ignoreAux = true;
InitCompatibleHypoFilter( compatibleFilter, ignoreAux );
// get non-auxiliary assigned to aShape
int nbHyp = aMesh.GetHypotheses( aShape, compatibleFilter, _usedHypList, false );
if (nbHyp == 0) if (nbHyp == 0)
{ {
// Check, if propagated from some other edge // Check, if propagated from some other edge
if (aShape.ShapeType() == TopAbs_EDGE && if (aShape.ShapeType() == TopAbs_EDGE &&
aMesh.IsPropagatedHypothesis(aShape, _mainEdge)) aMesh.IsPropagatedHypothesis(aShape, _mainEdge))
{ {
// Propagation of 1D hypothesis from <aMainEdge> on this edge // Propagation of 1D hypothesis from <aMainEdge> on this edge;
//_usedHypList = GetAppliedHypothesis(aMesh, _mainEdge); // copy // get non-auxiliary assigned to _mainEdge
// use a general method in order not to nullify _mainEdge nbHyp = aMesh.GetHypotheses( _mainEdge, compatibleFilter, _usedHypList, false );
_usedHypList = SMESH_Algo::GetUsedHypothesis(aMesh, _mainEdge); // copy }
}
if (nbHyp == 0) // nothing propagated nor assigned to aShape
{
SMESH_Algo::GetUsedHypothesis( aMesh, aShape, ignoreAuxiliary );
nbHyp = _usedHypList.size(); nbHyp = _usedHypList.size();
} }
} else
if (nbHyp == 0)
{ {
TopTools_ListIteratorOfListOfShape ancIt( aMesh.GetAncestors( aShape )); // get auxiliary hyps from aShape
for (; ancIt.More(); ancIt.Next()) aMesh.GetHypotheses( aShape, auxiliaryFilter, _usedHypList, true );
{
const TopoDS_Shape& ancestor = ancIt.Value();
_usedHypList = GetAppliedHypothesis(aMesh, ancestor); // copy
nbHyp = _usedHypList.size();
if (nbHyp == 1)
break;
} }
} if ( nbHyp > 1 && ignoreAuxiliary )
if (nbHyp > 1) _usedHypList.clear(); //only one compatible non-auxiliary hypothesis allowed
_usedHypList.clear(); //only one compatible hypothesis allowed
return _usedHypList; return _usedHypList;
} }

View File

@ -49,7 +49,7 @@ public:
const TopoDS_Shape& aShape); const TopoDS_Shape& aShape);
virtual const std::list <const SMESHDS_Hypothesis *> & virtual const std::list <const SMESHDS_Hypothesis *> &
GetUsedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); GetUsedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, const bool=true);
ostream & SaveTo(ostream & save); ostream & SaveTo(ostream & save);
istream & LoadFrom(istream & load); istream & LoadFrom(istream & load);