-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "StdMeshers_QuadrangleParams.hxx"
#include "StdMeshers_ViscousLayers2D.hxx"
+#include <BRepBndLib.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <BRep_Tool.hxx>
+#include <Bnd_Box.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Geom_Surface.hxx>
#include <NCollection_DefineArray2.hxx>
const TopoDS_Face& F = TopoDS::Face(aShape);
aMesh.GetSubMesh( F );
+ // do not initialize my fields before this as StdMeshers_ViscousLayers2D
+ // can call Compute() recursively
+ SMESH_ProxyMesh::Ptr proxyMesh = StdMeshers_ViscousLayers2D::Compute( aMesh, F );
+ if ( !proxyMesh )
+ return false;
+
+ myProxyMesh = proxyMesh;
+
SMESH_MesherHelper helper (aMesh);
myHelper = &helper;
- myProxyMesh = StdMeshers_ViscousLayers2D::Compute( aMesh, F );
- if ( !myProxyMesh )
- return false;
-
_quadraticMesh = myHelper->IsQuadraticSubMesh(aShape);
myNeedSmooth = false;
int nbright = (int) uv_e1.size();
int nbleft = (int) uv_e3.size();
- if (quad->nbNodeOut(0) && nbvertic == 2)
+ if (quad->nbNodeOut(0) && nbvertic == 2) // this should not occure
{
// Down edge is out
//
}
// right or left boundary quadrangles
- if (quad->nbNodeOut( QUAD_RIGHT_SIDE ) && nbhoriz == 2)
+ if (quad->nbNodeOut( QUAD_RIGHT_SIDE ) && nbhoriz == 2) // this should not occure
{
int g = 0; // last processed node in the grid
int stop = nbright - 1;
// MESSAGE("left edge is out");
int g = nbvertic - 1; // last processed node in the grid
int stop = 0;
- i = nbleft - 1;
- if (quad->side[3].from != stop ) stop++;
- if (quad->side[3].to != i ) i--;
+ i = quad->side[ QUAD_LEFT_SIDE ].to-1; // nbleft - 1;
for (; i > stop; i--) {
const SMDS_MeshNode *a, *b, *c, *d;
a = uv_e3[i].node;
return true;
}
+//================================================================================
+/*!
+ * \brief Return true if applied compute mesh on this shape
+ */
+//================================================================================
+
+bool StdMeshers_Quadrangle_2D::IsApplicable( const TopoDS_Shape & aShape, bool toCheckAll )
+{
+ int nbFoundFaces = 0;
+ for (TopExp_Explorer exp( aShape, TopAbs_FACE ); exp.More(); exp.Next(), ++nbFoundFaces ){
+ TopoDS_Face aFace = TopoDS::Face(exp.Current());
+ if ( aFace.Orientation() >= TopAbs_INTERNAL ) aFace.Orientation( TopAbs_FORWARD );
+
+ list< TopoDS_Edge > aWire;
+ list< int > nbEdgesInWire;
+ int nbWire = SMESH_Block::GetOrderedEdges (aFace, aWire, nbEdgesInWire);
+
+ int nbNoDegenEdges = 0;
+ list<TopoDS_Edge>::iterator edge = aWire.begin();
+ for ( ; edge != aWire.end(); ++edge ){
+ if ( !SMESH_Algo::isDegenerated( *edge ))
+ ++nbNoDegenEdges;
+ }
+ if( toCheckAll && (nbWire != 1 || nbNoDegenEdges <= 3 ) ) return false;
+ if( !toCheckAll && nbWire == 1 && nbNoDegenEdges > 3 ) return true;
+ }
+ if( toCheckAll && nbFoundFaces != 0) return true;
+ return false;
+};
//================================================================================
/*!
// Get nodes to smooth
+ // TODO: do not smooth fixed nodes
+
typedef map< const SMDS_MeshNode*, TSmoothNode, TIDCompare > TNo2SmooNoMap;
TNo2SmooNoMap smooNoMap;
TopoDS_Shape triaVertex = helper.GetMeshDS()->IndexToShape( myTriaVertexID );
if ( !triaVertex.IsNull() &&
triaVertex.ShapeType() == TopAbs_VERTEX &&
- helper.IsSubShape( triaVertex, theFace ))
+ helper.IsSubShape( triaVertex, theFace ) &&
+ ( vertexByAngle.size() != 4 || vertexByAngle.begin()->first < 5 * M_PI/180. ))
nbCorners = 3;
else
triaVertex.Nullify();
surf->Bounds( u1,u2,v1,v2 );
GeomAPI_ProjectPointOnSurf project;
project.Init(surf, u1,u2, v1,v2, tol );
+ Bnd_Box bbox;
+ BRepBndLib::Add( face, bbox );
+ double farTol = 0.01 * sqrt( bbox.SquareExtent() );
for ( size_t iP = 0; iP < points.size(); ++iP )
{
<< points[ iP ].X() << ", "<< points[ iP ].Y() << ", "<< points[ iP ].Z() << " )");
continue;
}
- if ( project.LowerDistance() > tol*1000 )
+ if ( project.LowerDistance() > farTol )
{
if ( isStrictCheck && iP < nbPoints )
return error