//purpose :
//=======================================================================
-bool StdMeshers_Helper::IsQuadraticSubMesh(const TopoDS_Shape& aSh,
- const bool QuadMode)
+bool StdMeshers_Helper::IsQuadraticSubMesh(const TopoDS_Shape& aSh)
{
SMESHDS_Mesh* meshDS = GetMesh()->GetMeshDS();
myShapeID = meshDS->ShapeToIndex(aSh);
- myCreateQuadratic = false;
- if(QuadMode) {
- // we can create quadratic elements only if each elements
- // created on given shape is quadratic
- // also we have to fill myNLinkNodeMap
- myCreateQuadratic = true;
- if(aSh.ShapeType()!=TopAbs_FACE) {
- for (TopExp_Explorer exp(aSh, TopAbs_FACE); exp.More() && myCreateQuadratic; exp.Next()) {
- const TopoDS_Face& F = TopoDS::Face(exp.Current());
- SMDS_ElemIteratorPtr itf = GetMesh()->GetSubMesh(F)->GetSubMeshDS()->GetElements();
- while(itf->more()) {
- const SMDS_MeshElement* f = itf->next();
- if( f->GetType()==SMDSAbs_Face && !f->IsQuadratic() ) {
- 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();
+ // we can create quadratic elements only if all elements
+ // created on given shape are quadratic
+ // also we have to fill myNLinkNodeMap
+ myCreateQuadratic = true;
+ TopAbs_ShapeEnum subType( aSh.ShapeType()==TopAbs_FACE ? TopAbs_EDGE : TopAbs_FACE );
+ SMDSAbs_ElementType elemType( subType==TopAbs_FACE ? SMDSAbs_Face : SMDSAbs_Edge );
+
+ TopExp_Explorer exp( aSh, subType );
+ for (; exp.More() && myCreateQuadratic; exp.Next()) {
+ if ( SMESHDS_SubMesh * subMesh = meshDS->MeshElements( exp.Current() )) {
+ if ( SMDS_ElemIteratorPtr it = subMesh->GetElements() ) {
while(it->more()) {
const SMDS_MeshElement* e = it->next();
- if( e->GetType()==SMDSAbs_Edge && !e->IsQuadratic() ) {
+ if ( e->GetType() != elemType || !e->IsQuadratic() ) {
myCreateQuadratic = false;
break;
}
- // fill NLinkNodeMap
- SMDS_ElemIteratorPtr nodeIt = e->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;
+ else {
+ // fill NLinkNodeMap
+ switch ( e->NbNodes() ) {
+ case 3:
+ AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(2)); break;
+ case 6:
+ AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(3));
+ AddNLinkNode(e->GetNode(1),e->GetNode(2),e->GetNode(4));
+ 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;
+ }
+ }
}
}
}
//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()) {
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;
}
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n12)
{
- NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 ));
- ItNLinkNode itLN = myNLinkNodeMap.find( link );
- if ( itLN == myNLinkNodeMap.end() ) {
- // add new record to map
- myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n12));
- }
+ NLink link( n1, n2 );
+ if ( n1 > n2 ) link = NLink( n2, n1 );
+ // add new record to map
+ myNLinkNodeMap.insert( make_pair(link,n12));
}
typedef map<NLink, const SMDS_MeshNode*> NLinkNodeMap;
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
{
/**
* 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
* (default value is false). Also fill myNLinkNodeMap
* 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
//=============================================================================
StdMeshers_Hexa_3D::StdMeshers_Hexa_3D(int hypId, int studyId,
- SMESH_Gen * gen):SMESH_3D_Algo(hypId, studyId, gen)
+ SMESH_Gen * gen):SMESH_3D_Algo(hypId, studyId, gen)
{
- MESSAGE("StdMeshers_Hexa_3D::StdMeshers_Hexa_3D");
- _name = "Hexa_3D";
-// _shapeType = TopAbs_SOLID;
- _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
-// MESSAGE("_shapeType octal " << oct << _shapeType);
- for (int i = 0; i < 6; i++)
- _quads[i] = 0;
+ MESSAGE("StdMeshers_Hexa_3D::StdMeshers_Hexa_3D");
+ _name = "Hexa_3D";
+ _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type
+ for (int i = 0; i < 6; i++)
+ _quads[i] = 0;
+ myTool = 0;
}
//=============================================================================
StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D()
{
- MESSAGE("StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D");
- for (int i = 0; i < 6; i++)
- StdMeshers_Quadrangle_2D::QuadDelete(_quads[i]);
+ 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++)
+ StdMeshers_Quadrangle_2D::QuadDelete(_quads[i]);
+ if ( myTool )
+ delete myTool;
+ myTool = 0;
+ return res;
+}
+
+
//=============================================================================
/*!
*
{
Unexpect aCatch(SalomeException);
MESSAGE("StdMeshers_Hexa_3D::Compute");
- //bool isOk = false;
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
- //SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
- //const SMESHDS_SubMesh *& subMeshDS = theSubMesh->GetSubMeshDS();
// 0. - shape and face mesh verification
// 0.1 - shape must be a solid (or a shell) with 6 faces
//MESSAGE("---");
- bool QuadMode = true;
-
- myTool = new StdMeshers_Helper(aMesh);
- myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
-
vector < SMESH_subMesh * >meshFaces;
for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
SMESH_subMesh *aSubMesh = aMesh.GetSubMeshContaining(exp.Current());
}
if (meshFaces.size() != 6) {
SCRUTE(meshFaces.size());
-// ASSERT(0);
return false;
}
// 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges)
//MESSAGE("---");
+ myTool = new StdMeshers_Helper(aMesh);
+ _quadraticMesh = myTool->IsQuadraticSubMesh(aShape);
+
for (int i = 0; i < 6; i++) {
TopoDS_Shape aFace = meshFaces[i]->GetSubShape();
SMESH_Algo *algo = _gen->GetAlgo(aMesh, aFace);
SMDS_ElemIteratorPtr eIt = sm->GetElements();
while ( isAllQuad && eIt->more() ) {
const SMDS_MeshElement* elem = eIt->next();
- isAllQuad = ( elem->NbNodes()==4 ||(myCreateQuadratic && elem->NbNodes()==8) );
+ isAllQuad = ( elem->NbNodes()==4 ||(_quadraticMesh && elem->NbNodes()==8) );
}
}
}
if ( ! isAllQuad ) {
//modified by NIZNHY-PKV Wed Nov 17 15:31:37 2004 f
- bool 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;
+ bool bIsOk = ComputePentahedralMesh(aMesh, aShape);
+ return ClearAndReturn( bIsOk );
}
StdMeshers_Quadrangle_2D *quadAlgo =
dynamic_cast < StdMeshers_Quadrangle_2D * >(algo);
ASSERT(quadAlgo);
try {
- _quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aFace, myCreateQuadratic);
- // 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
+ _quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aFace, _quadraticMesh);
}
catch(SALOME_Exception & S_ex) {
- // *** delete _quads
- // *** throw exception
- // ASSERT(0);
- return false;
+ return ClearAndReturn( false );
}
// 0.2.1 - number of points on the opposite edges must be the same
_quads[i]->nbPts[1] != _quads[i]->nbPts[3]) {
MESSAGE("different number of points on the opposite edges of face " << i);
// ASSERT(0);
- return false;
+ return ClearAndReturn( false );
}
}
}
if ( np ) delete [] np;
//MESSAGE("End of StdMeshers_Hexa_3D::Compute()");
- return true;
+ return ClearAndReturn( true );
}
//=============================================================================
Point3DStruct *np,
const SMESHDS_Mesh* meshDS);
+ bool ClearAndReturn(const bool res);
+
CubeStruct _cube;
FaceQuadStruct* _quads[6];
int _indX0;
//=============================================================================
StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D(int hypId, int studyId,
- SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen)
+ SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen)
{
- MESSAGE("StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D");
- _name = "MEFISTO_2D";
-// _shapeType = TopAbs_FACE;
- _shapeType = (1 << TopAbs_FACE);
- _compatibleHypothesis.push_back("MaxElementArea");
- _compatibleHypothesis.push_back("LengthFromEdges");
-
- _edgeLength = 0;
- _maxElementArea = 0;
- _hypMaxElementArea = NULL;
- _hypLengthFromEdges = NULL;
+ MESSAGE("StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D");
+ _name = "MEFISTO_2D";
+ _shapeType = (1 << TopAbs_FACE);
+ _compatibleHypothesis.push_back("MaxElementArea");
+ _compatibleHypothesis.push_back("LengthFromEdges");
+
+ _edgeLength = 0;
+ _maxElementArea = 0;
+ _hypMaxElementArea = NULL;
+ _hypLengthFromEdges = NULL;
+ myTool = 0;
}
//=============================================================================
StdMeshers_MEFISTO_2D::~StdMeshers_MEFISTO_2D()
{
- MESSAGE("StdMeshers_MEFISTO_2D::~StdMeshers_MEFISTO_2D");
+ MESSAGE("StdMeshers_MEFISTO_2D::~StdMeshers_MEFISTO_2D");
}
//=============================================================================
int iw = 1;
int nbpnt = 0;
- bool QuadMode = true;
-
myTool = new StdMeshers_Helper(aMesh);
- myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
+ _quadraticMesh = myTool->IsQuadraticSubMesh(aShape);
myOuterWire = BRepTools::OuterWire(F);
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;
+ }
nudslf[iw++] = nbpnt;
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) {
map<int, const SMDS_MeshNode*> mefistoToDS; // correspondence mefisto index--> points IDNodes
if ( !LoadPoints(aMesh, F, myOuterWire, uvslf, m,
- mefistoToDS, scalex, scaley, VWMap) )
+ mefistoToDS, scalex, scaley, VWMap) ) {
+ delete myTool; myTool = 0;
return false;
+ }
- for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
- {
- const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
- if (!myOuterWire.IsSame(W))
- {
- if (! LoadPoints(aMesh, F, W, uvslf, m,
- mefistoToDS, scalex, scaley, VWMap ))
- return false;
- }
- }
+ for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
+ {
+ const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
+ if (!myOuterWire.IsSame(W))
+ {
+ if (! LoadPoints(aMesh, F, W, uvslf, m,
+ mefistoToDS, scalex, scaley, VWMap )) {
+ delete myTool; myTool = 0;
+ return false;
+ }
+ }
+ }
- uvst = NULL;
- nust = NULL;
- aptrte(nutysu, aretmx,
- nblf, nudslf, uvslf, nbpti, uvpti, nbst, uvst, nbt, nust, ierr);
-
- if (ierr == 0)
- {
- MESSAGE("... End Triangulation Generated Triangle Number " << nbt);
- MESSAGE(" Node Number " << nbst);
- StoreResult(aMesh, nbst, uvst, nbt, nust, F,
- faceIsForward, mefistoToDS, scalex, scaley);
- isOk = true;
- }
- else
- {
- MESSAGE("Error in Triangulation");
- isOk = false;
- }
- if (nudslf != NULL)
- delete[]nudslf;
- if (uvslf != NULL)
- delete[]uvslf;
- if (uvst != NULL)
- delete[]uvst;
- if (nust != NULL)
- delete[]nust;
- return isOk;
+ uvst = NULL;
+ nust = NULL;
+ aptrte(nutysu, aretmx,
+ nblf, nudslf, uvslf, nbpti, uvpti, nbst, uvst, nbt, nust, ierr);
+
+ if (ierr == 0)
+ {
+ MESSAGE("... End Triangulation Generated Triangle Number " << nbt);
+ MESSAGE(" Node Number " << nbst);
+ StoreResult(aMesh, nbst, uvst, nbt, nust, F,
+ faceIsForward, mefistoToDS, scalex, scaley);
+ isOk = true;
+ }
+ else
+ {
+ MESSAGE("Error in Triangulation");
+ isOk = false;
+ }
+ if (nudslf != NULL)
+ delete[]nudslf;
+ if (uvslf != NULL)
+ delete[]uvslf;
+ if (uvst != NULL)
+ delete[]uvst;
+ if (nust != NULL)
+ delete[]nust;
+ delete myTool; myTool = 0;
+
+ return isOk;
}
//=======================================================================
else {
while ( nIt->more() ) {
const SMDS_MeshNode* node = nIt->next();
- if(CreateQuadratic) {
- // 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;
- }
+ // check if node is medium
+ if ( CreateQuadratic && StdMeshers_Helper::IsMedium( node, SMDSAbs_Edge ))
+ continue;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double u = epos->GetUParameter();
}
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();
+ if ( _quadraticMesh )
+ nbPoints /= 2;
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
//bool isForward = (E.Orientation() == TopAbs_FORWARD);
map<double, const SMDS_MeshNode*> params;
- if(!myCreateQuadratic) {
- while(ite->more()) {
- const SMDS_MeshNode * node = ite->next();
- const SMDS_EdgePosition* epos =
- 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;
- const SMDS_EdgePosition* epos =
- static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
- double param = epos->GetUParameter();
- params[param] = node;
- }
+ while(ite->more()) {
+ const SMDS_MeshNode * node = ite->next();
+ if ( _quadraticMesh && StdMeshers_Helper::IsMedium( node, SMDSAbs_Edge ))
+ continue;
+ const SMDS_EdgePosition* epos =
+ static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
+ double param = epos->GetUParameter();
+ params[param] = node;
}
if ( nbPoints != params.size()) {
// add IDNodes in mefistoToDS map
if (E.Orientation() == TopAbs_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 );
uvslf[m].x = p.X();
uvslf[m].y = p.Y();
mefistoToDS[m + 1] = idFirst;
- //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
- //MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+// MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map<double, const SMDS_MeshNode*>::iterator itp = params.begin();
for (int i = 1; i <= nbPoints; i++) { // nbPoints internal
uvslf[m].x = p.X();
uvslf[m].y = p.Y();
mefistoToDS[m + 1] = (*itp).second;
- //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
- //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
itp++;
}
}
else {
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 );
uvslf[m].x = p.X();
uvslf[m].y = p.Y();
mefistoToDS[m + 1] = idLast;
- //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
- //MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+// MESSAGE("__ l "<<l<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map<double, const SMDS_MeshNode*>::reverse_iterator itp = params.rbegin();
for (int i = nbPoints; i >= 1; i--)
uvslf[m].x = p.X();
uvslf[m].y = p.Y();
mefistoToDS[m + 1] = (*itp).second;
- //MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
- //MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
+// MESSAGE(" "<<m<<" "<<mefistoToDS[m+1]);
+// MESSAGE("__ "<<i<<" "<<param<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
itp++;
}
}
+ /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ /// !!!!!!! HERE IS A BUG with fixOverlappedLinkUV !!!!!!!!!!!
+ // !!!!!!! Correct version is in the CVS head !!!!!!!!!!
+ /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// prevent failure on overlapped adjacent links
- if ( iEdge > 0 )
- fixOverlappedLinkUV (uvslf[ mFirst - 1],
- uvslf[ mFirst ],
- uvslf[ mFirst + 1 ]);
+// if ( iEdge > 0 )
+// fixOverlappedLinkUV (uvslf[ mFirst - 1],
+// uvslf[ mFirst ],
+// uvslf[ mFirst + 1 ]);
} // for wexp
- fixOverlappedLinkUV (uvslf[ m - 1],
- uvslf[ mInit ],
- uvslf[ mInit + 1 ]);
+// fixOverlappedLinkUV (uvslf[ m - 1],
+// uvslf[ mInit ],
+// uvslf[ mInit + 1 ]);
return true;
}
//MESSAGE("StdMeshers_MEFISTO_2D::ComputeEdgeElementLength");
// **** 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);
- TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
+ //TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
double meanElementLength = 100;
double wireLength = 0;
int wireElementsNumber = 0;
- for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
- {
- const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
- for (TopExp_Explorer expe(W, TopAbs_EDGE); expe.More(); expe.Next())
+ for (TopExp_Explorer expe(aShape, TopAbs_EDGE); expe.More(); expe.Next())
{
const TopoDS_Edge & E = TopoDS::Edge(expe.Current());
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
wireLength += length;
wireElementsNumber += nb;
}
- }
if (wireElementsNumber)
meanElementLength = wireLength / wireElementsNumber;
//SCRUTE(meanElementLength);
myTol3D=0.1;
myWallNodesMaps.resize( SMESH_Block::NbFaces() );
myShapeXYZ.resize( SMESH_Block::NbSubShapes() );
+ myTool = 0;
}
+//=======================================================================
+//function : ~StdMeshers_Penta_3D
+//purpose :
+//=======================================================================
+
+StdMeshers_Penta_3D::~StdMeshers_Penta_3D()
+{
+ if ( myTool )
+ delete myTool;
+}
//=======================================================================
//function : Compute
return bOK;
}
- bool QuadMode = true;
-
myTool = new StdMeshers_Helper(aMesh);
- myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
+ myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape);
//
MakeBlock();
if (myErrorStatus){
+ delete myTool; myTool = 0;
return bOK;
}
//
ClearMeshOnFxy1();
if (myErrorStatus) {
+ delete myTool; myTool = 0;
return bOK;
}
//
MakeNodes();
if (myErrorStatus){
+ delete myTool; myTool = 0;
return bOK;
}
//
//
MakeMeshOnFxy1();
if (myErrorStatus) {
+ delete myTool; myTool = 0;
return bOK;
}
//
MakeVolumeMesh();
//
+ delete myTool; myTool = 0;
return !bOK;
}
public: // methods
StdMeshers_Penta_3D();
- //~StdMeshers_Penta_3D();
+ ~StdMeshers_Penta_3D();
bool Compute(SMESH_Mesh& , const TopoDS_Shape& );
: SMESH_Hypothesis(hypId, studyId, gen)
{
_name = GetName();
- _param_algo_dim = -2;
+ _param_algo_dim = -1; // 1D auxiliary
}
//=============================================================================
_name = "Quadrangle_2D";
_shapeType = (1 << TopAbs_FACE);
_compatibleHypothesis.push_back("QuadranglePreference");
+ myTool = 0;
}
//=============================================================================
StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D()
{
MESSAGE("StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D");
+ if ( myTool )
+ delete myTool;
}
//=============================================================================
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
aMesh.GetSubMesh(aShape);
- bool QuadMode = true;
-
- myTool = new StdMeshers_Helper(aMesh);
- myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
+ if ( !myTool )
+ myTool = new StdMeshers_Helper(aMesh);
+ _quadraticMesh = myTool->IsQuadraticSubMesh(aShape);
//FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
FaceQuadStruct* quad = CheckNbEdges(aMesh, aShape);
- if (!quad)
+ if (!quad) {
+ delete myTool; myTool = 0;
return false;
+ }
if(myQuadranglePreference) {
int n1 = quad->nbPts[0];
ntmp = ntmp*2;
if( nfull==ntmp && ( (n1!=n3) || (n2!=n4) ) ) {
// 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
SetNormalizedGrid(aMesh, aShape, quad);
- if (!quad)
+ if (!quad) {
+ delete myTool; myTool = 0;
return false;
+ }
// --- compute 3D values on points, store points & quadrangles
}
QuadDelete(quad);
+ delete myTool; myTool = 0;
+
bool isOk = true;
return isOk;
}
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbEdges < 4) {
quad->edge[nbEdges] = E;
- if(!myCreateQuadratic) {
+ if(!_quadraticMesh) {
quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
}
else {
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
{
Unexpect aCatch(SalomeException);
- myCreateQuadratic = CreateQuadratic;
+ _quadraticMesh = CreateQuadratic;
FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
// --- edge internal IDNodes (relies on good order storage, not checked)
-// if(myCreateQuadratic) {
+// if(_quadraticMesh) {
// fill myNLinkNodeMap
// SMDS_ElemIteratorPtr iter = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetElements();
// while(iter->more()) {
SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
- if(!myCreateQuadratic) {
+ if(!_quadraticMesh) {
while(ite->more()) {
const SMDS_MeshNode* node = ite->next();
const SMDS_EdgePosition* epos =
// --- edge internal IDNodes (relies on good order storage, not checked)
-// if(myCreateQuadratic) {
+// if(_quadraticMesh) {
// fill myNLinkNodeMap
// SMDS_ElemIteratorPtr iter = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetElements();
// while(iter->more()) {
SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
- if(!myCreateQuadratic) {
+ if(!_quadraticMesh) {
while(ite->more()) {
const SMDS_MeshNode* node = ite->next();
const SMDS_EdgePosition* epos =
const TopoDS_Shape& aShape)
throw (SALOME_Exception);
- FaceQuadStruct* CheckAnd2Dcompute(SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape)
- throw (SALOME_Exception);
-
FaceQuadStruct* CheckAnd2Dcompute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
const bool CreateQuadratic)
:SMESH_Hypothesis(hypId, studyId, gen)
{
_name = "QuadraticMesh";
- // only one hypo of the same dim can be assigned to the shape so
- // we use -3 in order to distingush from any usual 1D hypothsis and
- // from "NotConformAllowed" (-1) and "Propagation" (-2)
- _param_algo_dim = -3;
+ _param_algo_dim = -1; // it means auxiliary, dim = 1
}
//=============================================================================
_compatibleHypothesis.push_back("Deflection1D");
_compatibleHypothesis.push_back("Arithmetic1D");
_compatibleHypothesis.push_back("AutomaticLength");
+
+ _compatibleHypothesis.push_back("QuadraticMesh"); // auxiliary !!!
}
//=============================================================================
//=============================================================================
bool StdMeshers_Regular_1D::CheckHypothesis
- (SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape,
+ (SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
SMESH_Hypothesis::Hypothesis_Status& aStatus)
{
_hypType = NONE;
+ _quadraticMesh = false;
+
+ const bool ignoreAuxiliaryHyps = false;
+ 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
+ }
+ }
- const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
- if (hyps.size() == 0)
+ if ( !theHyp )
{
aStatus = SMESH_Hypothesis::HYP_MISSING;
return false; // can't work without a hypothesis
}
- // use only the first hypothesis
- const SMESHDS_Hypothesis *theHyp = hyps.front();
-
string hypName = theHyp->GetName();
if (hypName == "LocalLength")
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
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);
TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
int shapeID = meshDS->ShapeToIndex( E );
const SMDS_MeshNode * idPrev = idFirst;
double parPrev = f;
double parLast = l;
- if(reversed) {
- parPrev = l;
- parLast = f;
- }
+// if(reversed) {
+// parPrev = l;
+// parLast = f;
+// }
for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) {
double param = *itU;
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnEdge(node, shapeID, param);
- if(QuadMode) {
+ if(_quadraticMesh) {
// create medium node
double prm = ( parPrev + param )/2;
gp_Pnt PM = Curve->Value(prm);
idPrev = node;
parPrev = param;
}
- if(QuadMode) {
+ if(_quadraticMesh) {
double prm = ( parPrev + parLast )/2;
gp_Pnt PM = Curve->Value(prm);
SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
}
else {
// 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);
double du = (l - f) / (NbPoints - 1);
//MESSAGE("************* Degenerated edge! *****************");
for (int i = 2; i < NbPoints; i++) {
double param = f + (i - 1) * du;
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
- if(QuadMode) {
+ if(_quadraticMesh) {
// create medium node
double prm = param - du/2.;
gp_Pnt PM = Curve->Value(prm);
meshDS->SetNodeOnEdge(node, shapeID, param);
idPrev = node;
}
- if(QuadMode) {
+ if(_quadraticMesh) {
// create medium node
double prm = l - du/2.;
gp_Pnt PM = Curve->Value(prm);
*/
//=============================================================================
-const list <const SMESHDS_Hypothesis *> & StdMeshers_Regular_1D::GetUsedHypothesis(
- SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
+const list <const SMESHDS_Hypothesis *> &
+StdMeshers_Regular_1D::GetUsedHypothesis(SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape,
+ const bool ignoreAuxiliary)
{
_usedHypList.clear();
- _usedHypList = GetAppliedHypothesis(aMesh, aShape); // copy
- int nbHyp = _usedHypList.size();
_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)
{
// Check, if propagated from some other edge
if (aShape.ShapeType() == TopAbs_EDGE &&
aMesh.IsPropagatedHypothesis(aShape, _mainEdge))
{
- // Propagation of 1D hypothesis from <aMainEdge> on this edge
- //_usedHypList = GetAppliedHypothesis(aMesh, _mainEdge); // copy
- // use a general method in order not to nullify _mainEdge
- _usedHypList = SMESH_Algo::GetUsedHypothesis(aMesh, _mainEdge); // copy
- nbHyp = _usedHypList.size();
+ // Propagation of 1D hypothesis from <aMainEdge> on this edge;
+ // get non-auxiliary assigned to _mainEdge
+ nbHyp = aMesh.GetHypotheses( _mainEdge, compatibleFilter, _usedHypList, false );
}
}
- if (nbHyp == 0)
+
+ if (nbHyp == 0) // nothing propagated nor assigned to aShape
{
- TopTools_ListIteratorOfListOfShape ancIt( aMesh.GetAncestors( aShape ));
- for (; ancIt.More(); ancIt.Next())
- {
- const TopoDS_Shape& ancestor = ancIt.Value();
- _usedHypList = GetAppliedHypothesis(aMesh, ancestor); // copy
- nbHyp = _usedHypList.size();
- if (nbHyp == 1)
- break;
- }
+ SMESH_Algo::GetUsedHypothesis( aMesh, aShape, ignoreAuxiliary );
+ nbHyp = _usedHypList.size();
}
- if (nbHyp > 1)
- _usedHypList.clear(); //only one compatible hypothesis allowed
+ else
+ {
+ // get auxiliary hyps from aShape
+ aMesh.GetHypotheses( aShape, auxiliaryFilter, _usedHypList, true );
+ }
+ if ( nbHyp > 1 && ignoreAuxiliary )
+ _usedHypList.clear(); //only one compatible non-auxiliary hypothesis allowed
+
return _usedHypList;
}
const TopoDS_Shape& aShape);
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);
istream & LoadFrom(istream & load);