#include "SMESH_subMesh.hxx"
#include "SMESH_MesherHelper.hxx"
#include "SMESH_Block.hxx"
+#include "SMESH_Comment.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
using namespace std;
typedef gp_XY gp_UV;
+typedef SMESH_Comment TComm;
//=============================================================================
/*!
aStatus = SMESH_Hypothesis::HYP_OK;
// there is only one compatible Hypothesis so far
- const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape);
+ const list <const SMESHDS_Hypothesis * >&hyps = GetUsedHypothesis(aMesh, aShape, false);
myQuadranglePreference = hyps.size() > 0;
return isOk;
//=============================================================================
bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape) throw (SALOME_Exception)
+ const TopoDS_Shape& aShape)// throw (SALOME_Exception)
{
- Unexpect aCatch(SalomeException);
+ // PAL14921. Enable catching std::bad_alloc and Standard_OutOfMemory outside
+ //Unexpect aCatchSalomeException);
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
aMesh.GetSubMesh(aShape);
- myTool = new SMESH_MesherHelper(aMesh);
- std::auto_ptr<SMESH_MesherHelper> helperDeleter( myTool );// to delete helper at exit from Compute()
+ SMESH_MesherHelper helper(aMesh);
+ myTool = &helper;
_quadraticMesh = myTool->IsQuadraticSubMesh(aShape);
FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape)
- throw(SALOME_Exception)
+ //throw(SALOME_Exception)
{
- Unexpect aCatch(SalomeException);
-
const TopoDS_Face & F = TopoDS::Face(aShape);
+ const bool ignoreMediumNodes = _quadraticMesh;
// verify 1 wire only, with 4 edges
TopoDS_Vertex V;
list< int > nbEdgesInWire;
int nbWire = SMESH_Block::GetOrderedEdges (F, V, edges, nbEdgesInWire);
if (nbWire != 1) {
- INFOS("only 1 wire by face (quadrangles)");
+ error(COMPERR_BAD_SHAPE, TComm("Wrong number of wires: ") << nbWire);
return 0;
}
FaceQuadStruct* quad = new FaceQuadStruct;
quad->uv_grid = 0;
- for ( int i = 0; i < NB_SIDES; ++i )
- quad->side[i] = 0;
+ quad->side.reserve(nbEdgesInWire.front());
int nbSides = 0;
list< TopoDS_Edge >::iterator edgeIt = edges.begin();
if ( nbEdgesInWire.front() == 4 ) { // exactly 4 edges
for ( ; edgeIt != edges.end(); ++edgeIt, nbSides++ )
- quad->side[nbSides] = new StdMeshers_FaceSide(F,*edgeIt,&aMesh,nbSides<TOP_SIDE);
+ quad->side.push_back( new StdMeshers_FaceSide(F, *edgeIt, &aMesh,
+ nbSides<TOP_SIDE, ignoreMediumNodes));
}
- else if ( nbEdgesInWire.front() > 4 ) { // more than 4 edges - try to unite
+ else if ( nbEdgesInWire.front() > 4 ) { // more than 4 edges - try to unite some
list< TopoDS_Edge > sideEdges;
- while ( edgeIt != edges.end()) {
+ while ( !edges.empty()) {
sideEdges.clear();
- sideEdges.push_back( *edgeIt++ );
+ sideEdges.splice( sideEdges.end(), edges, edges.begin()); // edges.front() -> sideEdges.end()
bool sameSide = true;
- while ( edgeIt != edges.end() && sameSide ) {
- GeomAbs_Shape cont = SMESH_Algo::Continuity( sideEdges.back(), *edgeIt );
- sameSide = ( cont >= GeomAbs_C1 );
+ while ( !edges.empty() && sameSide ) {
+ sameSide = SMESH_Algo::IsContinuous( sideEdges.back(), edges.front() );
if ( sameSide )
- sideEdges.push_back( *edgeIt++ );
+ sideEdges.splice( sideEdges.end(), edges, edges.begin());
+ }
+ if ( nbSides == 0 ) { // go backward from the first edge
+ sameSide = true;
+ while ( !edges.empty() && sameSide ) {
+ sameSide = SMESH_Algo::IsContinuous( sideEdges.front(), edges.back() );
+ if ( sameSide )
+ sideEdges.splice( sideEdges.begin(), edges, --edges.end());
+ }
}
- quad->side[nbSides] = new StdMeshers_FaceSide(F,sideEdges,&aMesh,nbSides<TOP_SIDE);
+ quad->side.push_back( new StdMeshers_FaceSide(F, sideEdges, &aMesh,
+ nbSides<TOP_SIDE, ignoreMediumNodes));
++nbSides;
}
}
if (nbSides != 4) {
- INFOS("face must have 4 edges / quadrangle");
+#ifdef _DEBUG_
+ cout << endl << "StdMeshers_Quadrangle_2D. Edge IDs of " << nbSides << " sides:";
+ for ( int i = 0; i < nbSides; ++i ) {
+ cout << " ( ";
+ for ( int e = 0; e < quad->side[i]->NbEdges(); ++e )
+ cout << myTool->GetMeshDS()->ShapeToIndex( quad->side[i]->Edge( e )) << " ";
+ cout << ")";
+ }
+ cout << endl;
+#endif
+ if ( !nbSides )
+ nbSides = nbEdgesInWire.front();
+ error(COMPERR_BAD_SHAPE, TComm("Face must have 4 sides but not ") << nbSides);
delete quad;
quad = 0;
}
FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
- const bool CreateQuadratic) throw(SALOME_Exception)
+ const bool CreateQuadratic) //throw(SALOME_Exception)
{
- Unexpect aCatch(SalomeException);
-
_quadraticMesh = CreateQuadratic;
FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
faceQuadStruct::~faceQuadStruct()
{
- for (int i = 0; i < 4; i++) {
+ for (int i = 0; i < side.size(); i++) {
if (side[i]) delete side[i];
- //if (uv_edges[i]) delete [] uv_edges[i];
}
if (uv_grid) delete [] uv_grid;
}
namespace {
inline const vector<UVPtStruct>& GetUVPtStructIn(FaceQuadStruct* quad, int i, int nbSeg)
{
- bool isXConst = ( i == BOTTOM_SIDE || i == TOP_SIDE );
+ bool isXConst = ( i == BOTTOM_SIDE || i == TOP_SIDE );
double constValue = ( i == BOTTOM_SIDE || i == LEFT_SIDE ) ? 0 : 1;
return
quad->isEdgeOut[i] ?
bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape,
- FaceQuadStruct* & quad) throw (SALOME_Exception)
+ FaceQuadStruct* & quad) //throw (SALOME_Exception)
{
- Unexpect aCatch(SalomeException);
// Algorithme décrit dans "Génération automatique de maillages"
// P.L. GEORGE, MASSON, § 6.4.1 p. 84-85
// traitement dans le domaine paramétrique 2d u,v
const vector<UVPtStruct>& uv_e2 = GetUVPtStructIn( quad, 2, nbhoriz - 1 );
const vector<UVPtStruct>& uv_e3 = GetUVPtStructIn( quad, 3, nbvertic - 1 );
- if ( uv_e0.empty() || uv_e1.empty() || uv_e2.empty() || uv_e3.empty() ) {
- MESSAGE("Nodes from edges not loaded");
- return false;
- }
+ if ( uv_e0.empty() || uv_e1.empty() || uv_e2.empty() || uv_e3.empty() )
+ return error( "Can't find nodes on sides");
// nodes Id on "in" edges
if (! quad->isEdgeOut[0]) {
uv -= (1 - x) * (1 - y) * a0 + x * (1 - y) * a1 + x * y * a2 + (1 - x) * y * a3;
- //cout<<"x0="<<x0<<" x1="<<x1<<" y0="<<y0<<" y1="<<y1<<endl;
- //cout<<"x="<<x<<" y="<<y<<endl;
- //cout<<"param_b="<<param_b<<" param_t="<<param_t<<" param_r="<<param_r<<" param_l="<<param_l<<endl;
- //cout<<"u="<<u<<" v="<<v<<endl;
-
return uv;
}
-//=======================================================================
-//function : ComputeQuadPref
-//purpose :
//=======================================================================
/*!
- * Special function for creation only quandrangle faces
+ * Create only quandrangle faces
*/
-bool StdMeshers_Quadrangle_2D::ComputeQuadPref
- (SMESH_Mesh & aMesh,
- const TopoDS_Shape& aShape,
- FaceQuadStruct* quad) throw (SALOME_Exception)
-{
- Unexpect aCatch(SalomeException);
+//=======================================================================
+bool StdMeshers_Quadrangle_2D::ComputeQuadPref (SMESH_Mesh & aMesh,
+ const TopoDS_Shape& aShape,
+ FaceQuadStruct* quad)
+{
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
const TopoDS_Face& F = TopoDS::Face(aShape);
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
- const TopoDS_Wire& W = BRepTools::OuterWire(F);
- bool WisF = false;
- if(W.Orientation()==TopAbs_FORWARD)
- WisF = true;
+// const TopoDS_Wire& W = BRepTools::OuterWire(F);
+ bool WisF = true;
+// if(W.Orientation()==TopAbs_FORWARD)
+// WisF = true;
//if(WisF) cout<<"W is FORWARD"<<endl;
//else cout<<"W is REVERSED"<<endl;
- bool FisF = (F.Orientation()==TopAbs_FORWARD);
- if(!FisF) WisF = !WisF;
+// bool FisF = (F.Orientation()==TopAbs_FORWARD);
+// if(!FisF) WisF = !WisF;
+// WisF = FisF;
int i,j,geomFaceID = meshDS->ShapeToIndex( F );
int nb = quad->side[0]->NbPoints();