-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 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
#include "StdMeshers_Cartesian_3D.hxx"
#include "SMDS_MeshNode.hxx"
+#include "SMESHDS_Mesh.hxx"
#include "SMESH_Block.hxx"
#include "SMESH_Comment.hxx"
#include "SMESH_Mesh.hxx"
#include <utilities.h>
#include <Utils_ExceptHandlers.hxx>
-#include <Basics_OCCTVersion.hxx>
#include <GEOMUtils.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
//#define _MY_DEBUG_
#endif
-#if OCC_VERSION_LARGE <= 0x06050300
-// workaround is required only for OCCT6.5.3 and older (see OCC22809)
-#define ELLIPSOLID_WORKAROUND
-#endif
-
-#ifdef ELLIPSOLID_WORKAROUND
-#include <BRepIntCurveSurface_Inter.hxx>
-#include <BRepTopAdaptor_TopolTool.hxx>
-#include <BRepAdaptor_HSurface.hxx>
-#endif
-
//=============================================================================
/*!
* Constructor
*/
//=============================================================================
-StdMeshers_Cartesian_3D::StdMeshers_Cartesian_3D(int hypId, int studyId, SMESH_Gen * gen)
- :SMESH_3D_Algo(hypId, studyId, gen)
+StdMeshers_Cartesian_3D::StdMeshers_Cartesian_3D(int hypId, SMESH_Gen * gen)
+ :SMESH_3D_Algo(hypId, gen)
{
_name = "Cartesian_3D";
_shapeType = (1 << TopAbs_SOLID); // 1 bit /shape type
void ComputeUVW(const gp_XYZ& p, double uvw[3]);
void ComputeNodes(SMESH_MesherHelper& helper);
};
-#ifdef ELLIPSOLID_WORKAROUND
- // --------------------------------------------------------------------------
- /*!
- * \brief struct temporary replacing IntCurvesFace_Intersector until
- * OCCT bug 0022809 is fixed
- * http://tracker.dev.opencascade.org/view.php?id=22809
- */
- struct TMP_IntCurvesFace_Intersector
- {
- BRepAdaptor_Surface _surf;
- double _tol;
- BRepIntCurveSurface_Inter _intcs;
- vector<IntCurveSurface_IntersectionPoint> _points;
- BRepTopAdaptor_TopolTool _clsf;
-
- TMP_IntCurvesFace_Intersector(const TopoDS_Face& face, const double tol)
- :_surf( face ), _tol( tol ), _clsf( new BRepAdaptor_HSurface(_surf) ) {}
- Bnd_Box Bounding() const { Bnd_Box b; BRepBndLib::Add (_surf.Face(), b); return b; }
- void Perform( const gp_Lin& line, const double w0, const double w1 )
- {
- _points.clear();
- for ( _intcs.Init( _surf.Face(), line, _tol ); _intcs.More(); _intcs.Next() )
- if ( w0 <= _intcs.W() && _intcs.W() <= w1 )
- _points.push_back( _intcs.Point() );
- }
- bool IsDone() const { return true; }
- int NbPnt() const { return _points.size(); }
- IntCurveSurface_TransitionOnCurve Transition( const int i ) const { return _points[ i-1 ].Transition(); }
- double WParameter( const int i ) const { return _points[ i-1 ].W(); }
- TopAbs_State ClassifyUVPoint(const gp_Pnt2d& p) { return _clsf.Classify( p, _tol ); }
- };
-#define __IntCurvesFace_Intersector TMP_IntCurvesFace_Intersector
-#else
-#define __IntCurvesFace_Intersector IntCurvesFace_Intersector
-#endif
// --------------------------------------------------------------------------
/*!
* \brief Intersector of TopoDS_Face with all GridLine's
TGeomID _faceID;
Grid* _grid;
Bnd_Box _bndBox;
- __IntCurvesFace_Intersector* _surfaceInt;
+ IntCurvesFace_Intersector* _surfaceInt;
vector< std::pair< GridLine*, F_IntersectPoint > > _intersections;
FaceGridIntersector(): _grid(0), _surfaceInt(0) {}
GetCurveFaceIntersector();
return _bndBox;
}
- __IntCurvesFace_Intersector* GetCurveFaceIntersector()
+ IntCurvesFace_Intersector* GetCurveFaceIntersector()
{
if ( !_surfaceInt )
{
- _surfaceInt = new __IntCurvesFace_Intersector( _face, Precision::PConfusion() );
+ _surfaceInt = new IntCurvesFace_Intersector( _face, Precision::PConfusion() );
_bndBox = _surfaceInt->Bounding();
if ( _bndBox.IsVoid() )
BRepBndLib::Add (_face, _bndBox);
gp_Cone _cone;
gp_Sphere _sphere;
gp_Torus _torus;
- __IntCurvesFace_Intersector* _surfaceInt;
+ IntCurvesFace_Intersector* _surfaceInt;
vector< F_IntersectPoint > _intPoints;
int& di, double tol )
{
//val += values[0]; // input \a val is measured from 0.
- if ( i > values.size()-2 )
+ if ( i > (int) values.size()-2 )
i = values.size()-2;
else
- while ( i+2 < values.size() && val > values[ i+1 ])
+ while ( i+2 < (int) values.size() && val > values[ i+1 ])
++i;
while ( i > 0 && val < values[ i ])
--i;
if ( i > 0 && val - values[ i ] < tol )
di = -1;
- else if ( i+2 < values.size() && values[ i+1 ] - val < tol )
+ else if ( i+2 < (int) values.size() && values[ i+1 ] - val < tol )
di = 1;
else
di = 0;
}
if ( surf->IsKind( STANDARD_TYPE(Geom_BSplineSurface )) ||
surf->IsKind( STANDARD_TYPE(Geom_BezierSurface )))
- if ( !noSafeTShapes.insert((const Standard_Transient*) _face.TShape() ).second )
+ if ( !noSafeTShapes.insert( _face.TShape().get() ).second )
isSafe = false;
double f, l;
edgeIsSafe = false;
}
}
- if ( !edgeIsSafe && !noSafeTShapes.insert((const Standard_Transient*) e.TShape() ).second )
+ if ( !edgeIsSafe && !noSafeTShapes.insert( e.TShape().get() ).second )
isSafe = false;
}
return isSafe;
if ( quad._eIntNodes[ iP ]->IsUsedInFace( polygon ))
quad._eIntNodes[ iP ]->_usedInFace = 0;
#endif
- int nbUsedEdgeNodes = 0;
+ size_t nbUsedEdgeNodes = 0;
_Face* prevPolyg = 0; // polygon previously created from this quad
while ( nbSplits > 0 )
else
{
_OrientedLink foundSplit;
- for ( int i = iS; i < splits.size() && !foundSplit; ++i )
+ for ( size_t i = iS; i < splits.size() && !foundSplit; ++i )
if (( foundSplit = splits[ i ]) &&
( n2->IsLinked( foundSplit.FirstNode()->_intPoint )))
{
while ( nbFreeLinks > 0 )
{
if ( iPolygon == _polygons.size() )
+ {
_polygons.resize( _polygons.size() + 1 );
+ _polygons[ iPolygon ]._polyLinks.reserve( 20 );
+ _polygons[ iPolygon ]._links.reserve( 20 );
+ }
_Face& polygon = _polygons[ iPolygon ];
- polygon._polyLinks.reserve( 20 );
- polygon._links.reserve( 20 );
_OrientedLink* curLink = 0;
_Node* curNode;
{
sortVertexNodes( chainNodes, curNode, curFace );
}
- for ( int i = 0; i < chainNodes.size(); ++i )
+ for ( size_t i = 0; i < chainNodes.size(); ++i )
{
polygon.AddPolyLink( chainNodes[ i ], curNode );
curNode = chainNodes[ i ];
_polygons[ iPolygon ]._polyLinks.clear();
break;
}
- if ( freeLinks.back() == &polygon._links.back() )
- {
- freeLinks.pop_back();
- --nbFreeLinks;
- }
_polygons.pop_back();
usedFaceIDs.erase( curFace );
continue;
i = int(lineInd.I()) + dInd[iL][0];
j = int(lineInd.J()) + dInd[iL][1];
k = int(lineInd.K()) + dInd[iL][2];
- if ( i < 0 || i >= nbCells[0] ||
- j < 0 || j >= nbCells[1] ||
- k < 0 || k >= nbCells[2] ) continue;
+ if ( i < 0 || i >= (int) nbCells[0] ||
+ j < 0 || j >= (int) nbCells[1] ||
+ k < 0 || k >= (int) nbCells[2] ) continue;
const size_t hexIndex = _grid->CellIndex( i,j,k );
Hexahedron *& hex = allHexa[ hexIndex ];
planes._zProjs [0] = 0;
const double zFactor = _grid->_axes[ iDirZ ] * planes._zNorm;
const vector< double > & u = _grid->_coords[ iDirZ ];
- for ( int i = 1; i < planes._zProjs.size(); ++i )
+ for ( size_t i = 1; i < planes._zProjs.size(); ++i )
{
planes._zProjs [i] = zFactor * ( u[i] - u[0] );
}
ip._faceIDs = e2fIt->second;
ip._shapeID = edgeID;
- // discretize the EGDE
+ // discretize the EDGE
GCPnts_UniformDeflection discret( curve, deflection, true );
if ( !discret.IsDone() || discret.NbPoints() < 2 )
continue;
{
enum { X = 1, Y = 2, Z = 4 }; // == 001, 010, 100
int nbFacets = 0;
- int vertex = 0, egdeMask = 0;
+ int vertex = 0, edgeMask = 0;
if ( Abs( _grid->_coords[0][ _i ] - ip->_uvw[0] ) < _grid->_tol ) {
facets[ nbFacets++ ] = SMESH_Block::ID_F0yz;
- egdeMask |= X;
+ edgeMask |= X;
}
else if ( Abs( _grid->_coords[0][ _i+1 ] - ip->_uvw[0] ) < _grid->_tol ) {
facets[ nbFacets++ ] = SMESH_Block::ID_F1yz;
vertex |= X;
- egdeMask |= X;
+ edgeMask |= X;
}
if ( Abs( _grid->_coords[1][ _j ] - ip->_uvw[1] ) < _grid->_tol ) {
facets[ nbFacets++ ] = SMESH_Block::ID_Fx0z;
- egdeMask |= Y;
+ edgeMask |= Y;
}
else if ( Abs( _grid->_coords[1][ _j+1 ] - ip->_uvw[1] ) < _grid->_tol ) {
facets[ nbFacets++ ] = SMESH_Block::ID_Fx1z;
vertex |= Y;
- egdeMask |= Y;
+ edgeMask |= Y;
}
if ( Abs( _grid->_coords[2][ _k ] - ip->_uvw[2] ) < _grid->_tol ) {
facets[ nbFacets++ ] = SMESH_Block::ID_Fxy0;
- egdeMask |= Z;
+ edgeMask |= Z;
}
else if ( Abs( _grid->_coords[2][ _k+1 ] - ip->_uvw[2] ) < _grid->_tol ) {
facets[ nbFacets++ ] = SMESH_Block::ID_Fxy1;
vertex |= Z;
- egdeMask |= Z;
+ edgeMask |= Z;
}
switch ( nbFacets )
{ SMESH_Block::ID_Ex00, 0, SMESH_Block::ID_Ex10, 0,
SMESH_Block::ID_Ex01, 0, SMESH_Block::ID_Ex11 }
};
- switch ( egdeMask ) {
+ switch ( edgeMask ) {
case X | Y: sub = edge[ 0 ][ vertex ]; break;
case X | Z: sub = edge[ 1 ][ vertex ]; break;
default: sub = edge[ 2 ][ vertex ];
chn.back()->IsLinked( quad._eIntNodes[ iP ]->_intPoint ))
{
chn.push_back( quad._eIntNodes[ iP ]);
- found = quad._eIntNodes[ iP ]->_usedInFace = &quad;
+ found = ( quad._eIntNodes[ iP ]->_usedInFace = &quad );
break;
}
} while ( found && ! chn.back()->IsLinked( n2->_intPoint ) );
( !avoidFace || quad._eIntNodes[ iP ]->IsOnFace( avoidFace )))
{
chn.push_back( quad._eIntNodes[ iP ]);
- found = quad._eIntNodes[ iP ]->_usedInFace = &quad;
+ found = ( quad._eIntNodes[ iP ]->_usedInFace = &quad );
break;
}
} while ( found );
{
bool isOut = false;
- const bool moreIntPoints = ( iP+1 < link._fIntPoints.size() );
+ const bool moreIntPoints = ( iP+1 < (int) link._fIntPoints.size() );
// get 2 _Node's
_Node* n1 = link._fIntNodes[ iP ];
proj.Perform( testPnt );
if ( proj.IsDone() && proj.NbPoints() > 0 )
{
- Quantity_Parameter u,v;
+ Standard_Real u,v;
proj.LowerDistanceParameters( u,v );
if ( proj.LowerDistance() <= 0.1 * _grid->_tol )
list< int > nbEdges;
int nbW = SMESH_Block::GetOrderedEdges (face, edges, nbEdges);
if ( nbW > 1 ) {
- // select a WIRE
+ // select a WIRE - remove EDGEs of irrelevant WIREs from edges
list< TopoDS_Edge >::iterator e = edges.begin(), eEnd = e;
list< int >::iterator nE = nbEdges.begin();
- for ( ; nbW ; ++nE, --nbW )
+ for ( ; nbW > 0; ++nE, --nbW )
{
std::advance( eEnd, *nE );
for ( ; e != eEnd; ++e )
( std::find( &nShapeIds[0], nShapeIdsEnd, id ) != nShapeIdsEnd ))
{
edges.erase( eEnd, edges.end() ); // remove rest wires
- e = eEnd;
+ e = eEnd = edges.end();
+ --e;
nbW = 0;
break;
}
}
if ( nbW > 0 )
- edges.erase( edges.begin(), eEnd ); // remove a current wire
+ edges.erase( edges.begin(), eEnd ); // remove a current irrelevant wire
}
}
// rotate edges to have the first one at least partially out of the hexa
else if ( eMidOut != edges.end() )
edges.splice( edges.end(), edges, edges.begin(), eMidOut );
- // sort nodes accoring to the order of edges
+ // sort nodes according to the order of edges
_Node* orderNodes [20];
- TGeomID orderShapeIDs[20];
- int nbN = 0;
- TGeomID id, *pID;
+ //TGeomID orderShapeIDs[20];
+ size_t nbN = 0;
+ TGeomID id, *pID = 0;
for ( e = edges.begin(); e != edges.end(); ++e )
{
if (( id = _grid->_shapes.FindIndex( SMESH_MesherHelper::IthVertex( 0, *e ))) &&
(( pID = std::find( &nShapeIds[0], nShapeIdsEnd, id )) != nShapeIdsEnd ))
{
- orderShapeIDs[ nbN ] = id;
+ //orderShapeIDs[ nbN ] = id;
orderNodes [ nbN++ ] = nodes[ pID - &nShapeIds[0] ];
*pID = -1;
}
if (( id = _grid->_shapes.FindIndex( *e )) &&
(( pID = std::find( &nShapeIds[0], nShapeIdsEnd, id )) != nShapeIdsEnd ))
{
- orderShapeIDs[ nbN ] = id;
+ //orderShapeIDs[ nbN ] = id;
orderNodes [ nbN++ ] = nodes[ pID - &nShapeIds[0] ];
*pID = -1;
}
if ( !_vIntNodes.empty() )
return false;
- const int ijk[3] = { _i, _j, _k };
+ const size_t ijk[3] = { _i, _j, _k };
F_IntersectPoint curIntPnt;
// consider a cell to be in a hole if all links in any direction
const F_IntersectPoint* firstIntPnt = 0;
if ( link._nodes[0]->Node() ) // 1st node is a hexa corner
{
- curIntPnt._paramOnLine = coords[ ijk[ iDir ]] - coords[0];
+ curIntPnt._paramOnLine = coords[ ijk[ iDir ]] - coords[0] + _grid->_tol;
const GridLine& line = _grid->_lines[ iDir ][ lineIndex[ iL ]];
multiset< F_IntersectPoint >::const_iterator ip =
line._intPoints.upper_bound( curIntPnt );
}
//================================================================================
/*!
- * \brief Classify a point by grid paremeters
+ * \brief Classify a point by grid parameters
*/
bool Hexahedron::isOutParam(const double uvw[3]) const
{
map< TGeomID, vector< TGeomID > > edge2faceIDsMap;
TopExp_Explorer eExp;
Bnd_Box shapeBox;
- for ( int i = 0; i < faceVec.size(); ++i )
+ for ( size_t i = 0; i < faceVec.size(); ++i )
{
facesItersectors[i]._face = TopoDS::Face ( faceVec[i] );
facesItersectors[i]._faceID = grid._shapes.Add( faceVec[i] );
facesItersectors[i].Intersect();
#endif
- // put interesection points onto the GridLine's; this is done after intersection
+ // put intersection points onto the GridLine's; this is done after intersection
// to avoid contention of facesItersectors for writing into the same GridLine
// in case of parallel work of facesItersectors
for ( size_t i = 0; i < facesItersectors.size(); ++i )
for ( ; solidExp.More() && volIt->more(); solidExp.Next() )
{
const SMDS_MeshElement* vol = volIt->next();
- sm1->RemoveElement( vol, /*isElemDeleted=*/false );
+ sm1->RemoveElement( vol );
meshDS->SetMeshElementOnShape( vol, solidExp.Current() );
}
}