-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 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
#ifdef _DEBUG_
#define DBGOUT(msg) //cout << msg << endl;
#define SHOWYXZ(msg, xyz) \
- // { gp_Pnt p (xyz); \
- // cout << msg << " ("<< p.X() << "; " <<p.Y() << "; " <<p.Z() << ") " <<endl; }
+ //{ gp_Pnt p (xyz); cout << msg << " ("<< p.X() << "; " <<p.Y() << "; " <<p.Z() << ") " <<endl; }
#else
#define DBGOUT(msg)
#define SHOWYXZ(msg, xyz)
// gravity center of a layer
gp_XYZ O(0,0,0);
int vertexCol = -1;
- for ( int i = 0; i < columns.size(); ++i )
+ for ( size_t i = 0; i < columns.size(); ++i )
{
O += gpXYZ( (*columns[ i ])[ z ]);
if ( vertexCol < 0 &&
// Z axis
gp_Vec Z(0,0,0);
int iPrev = columns.size()-1;
- for ( int i = 0; i < columns.size(); ++i )
+ for ( size_t i = 0; i < columns.size(); ++i )
{
gp_Vec v1( O, gpXYZ( (*columns[ iPrev ])[ z ]));
gp_Vec v2( O, gpXYZ( (*columns[ i ] )[ z ]));
{
O = gpXYZ( (*columns[ vertexCol ])[ z ]);
}
- if ( xColumn < 0 || xColumn >= columns.size() )
+ if ( xColumn < 0 || xColumn >= (int) columns.size() )
{
// select a column for X dir
double maxDist = 0;
- for ( int i = 0; i < columns.size(); ++i )
+ for ( size_t i = 0; i < columns.size(); ++i )
{
double dist = ( O - gpXYZ((*columns[ i ])[ z ])).SquareModulus();
if ( dist > maxDist )
if ( nbQuads > 0 )
toRemove = helper->IsStructured( faceSm );
else
- toRemove = quadAlgo->CheckNbEdges( *helper->GetMesh(),
- faceSm->GetSubShape() );
+ toRemove = ( quadAlgo->CheckNbEdges( *helper->GetMesh(),
+ faceSm->GetSubShape() ) != NULL );
nbRemoved += toRemove;
if ( toRemove )
smIt = notQuadSubMesh.erase( smIt );
std::advance( edgeIt, nbEdges-1 );
TopoDS_Edge prevE = *edgeIt;
// bool isPrevStraight = SMESH_Algo::IsStraight( prevE );
- int iPrev = nbEdges - 1;
+ // int iPrev = nbEdges - 1;
- int iUnite = -1; // the first of united EDGEs
+ // int iUnite = -1; // the first of united EDGEs
// analyse angles between EDGEs
int nbCorners = 0;
void pointsToPython(const std::vector<gp_XYZ>& p)
{
#ifdef _DEBUG_
- for ( int i = SMESH_Block::ID_V000; i < p.size(); ++i )
+ for ( size_t i = SMESH_Block::ID_V000; i < p.size(); ++i )
{
cout << "mesh.AddNode( " << p[i].X() << ", "<< p[i].Y() << ", "<< p[i].Z() << ") # " << i <<" " ;
SMESH_Block::DumpShapeID( i, cout ) << endl;
return error( err );
}
}
- return true;
+ return error( COMPERR_OK );
}
//================================================================================
list< TopoDS_Edge >::iterator edge = thePrism.myBottomEdges.begin();
std::list< int >::iterator nbE = thePrism.myNbEdgesInWires.begin();
+ std::list< int > nbQuadsPerWire;
int iE = 0;
double f,l;
while ( edge != thePrism.myBottomEdges.end() )
{
iE = 0;
++nbE;
+ int nbQuadPrev = nbQuadsPerWire.empty() ? 0 : nbQuadsPerWire.back();
+ nbQuadsPerWire.push_back( thePrism.myWallQuads.size() - nbQuadPrev );
}
}
// that is not so evident in case of several WIREs in the bottom FACE
thePrism.myRightQuadIndex.clear();
for ( size_t i = 0; i < thePrism.myWallQuads.size(); ++i )
- thePrism.myRightQuadIndex.push_back( i+1 );
- list< int >::iterator nbEinW = thePrism.myNbEdgesInWires.begin();
- for ( int iLeft = 0; nbEinW != thePrism.myNbEdgesInWires.end(); ++nbEinW )
{
- thePrism.myRightQuadIndex[ iLeft + *nbEinW - 1 ] = iLeft; // 1st EDGE index of a current WIRE
- iLeft += *nbEinW;
+ thePrism.myRightQuadIndex.push_back( i+1 ); // OK for all but the last EDGE of a WIRE
+ }
+ list< int >::iterator nbQinW = nbQuadsPerWire.begin();
+ for ( int iLeft = 0; nbQinW != nbQuadsPerWire.end(); ++nbQinW )
+ {
+ thePrism.myRightQuadIndex[ iLeft + *nbQinW - 1 ] = iLeft; // for the last EDGE of a WIRE
+ iLeft += *nbQinW;
}
while ( totalNbFaces - faceMap.Extent() > 2 )
{
// now only top and bottom FACEs are not in the faceMap
faceMap.Add( thePrism.myBottom );
- for ( TopExp_Explorer f( thePrism.myShape3D, TopAbs_FACE );f.More(); f.Next() )
+ for ( TopExp_Explorer f( thePrism.myShape3D, TopAbs_FACE ); f.More(); f.Next() )
if ( !faceMap.Contains( f.Current() )) {
thePrism.myTop = TopoDS::Face( f.Current() );
break;
n2nMapPtr = & TProjction2dAlgo::instance( this )->GetNodesMap();
}
- if ( !n2nMapPtr || n2nMapPtr->size() < botSMDS->NbNodes() )
+ if ( !n2nMapPtr || (int) n2nMapPtr->size() < botSMDS->NbNodes() )
{
// associate top and bottom faces
NSProjUtils::TShapeShapeMap shape2ShapeMap;
int _nbCheckedEdges; // nb of EDGEs whose location is defined
PrismSide *_leftSide;
PrismSide *_rightSide;
+ void SetExcluded() { _leftSide = _rightSide = NULL; }
+ bool IsExcluded() const { return !_leftSide; }
const TopoDS_Edge& Edge( int i ) const
{
return (*_edges)[ i ]._edge;
for ( iE = 0; iE < *nbE; ++e, ++iE )
if ( SMESH_Algo::isDegenerated( *e ))
{
- ee.erase( e );
+ e = --ee.erase( e );
--(*nbE);
--iE;
}
/*!
* \brief Return another faces sharing an edge
*/
- const TopoDS_Shape & getAnotherFace( const TopoDS_Face& face,
- const TopoDS_Edge& edge,
- TopTools_IndexedDataMapOfShapeListOfShape& facesOfEdge)
+ const TopoDS_Face & getAnotherFace( const TopoDS_Face& face,
+ const TopoDS_Edge& edge,
+ TopTools_IndexedDataMapOfShapeListOfShape& facesOfEdge)
{
TopTools_ListIteratorOfListOfShape faceIt( facesOfEdge.FindFromKey( edge ));
for ( ; faceIt.More(); faceIt.Next() )
if ( !face.IsSame( faceIt.Value() ))
- return faceIt.Value();
+ return TopoDS::Face( faceIt.Value() );
return face;
}
+
+ //--------------------------------------------------------------------------------
+ /*!
+ * \brief Return number of faces sharing given edges
+ */
+ int nbAdjacentFaces( const std::vector< EdgeWithNeighbors >& edges,
+ const TopTools_IndexedDataMapOfShapeListOfShape& facesOfEdge )
+ {
+ TopTools_MapOfShape adjFaces;
+
+ for ( size_t i = 0; i < edges.size(); ++i )
+ {
+ TopTools_ListIteratorOfListOfShape faceIt( facesOfEdge.FindFromKey( edges[i]._edge ));
+ for ( ; faceIt.More(); faceIt.Next() )
+ adjFaces.Add( faceIt.Value() );
+ }
+ return adjFaces.Extent();
+ }
}
//================================================================================
typedef vector< EdgeWithNeighbors > TEdgeWithNeighborsVec;
vector< TEdgeWithNeighborsVec > faceEdgesVec( allFaces.Extent() + 1 );
- TopTools_IndexedMapOfShape* facesOfSide = new TopTools_IndexedMapOfShape[ faceEdgesVec.size() ];
+ const size_t nbEdgesMax = facesOfEdge.Extent() * 2; // there can be seam EDGES
+ TopTools_IndexedMapOfShape* facesOfSide = new TopTools_IndexedMapOfShape[ nbEdgesMax ];
SMESHUtils::ArrayDeleter<TopTools_IndexedMapOfShape> delFacesOfSide( facesOfSide );
// try to use each face as a bottom one
bool prismDetected = false;
+ vector< PrismSide > sides;
for ( int iF = 1; iF < allFaces.Extent() && !prismDetected; ++iF )
{
const TopoDS_Face& botF = TopoDS::Face( allFaces( iF ));
continue; // all faces are adjacent to botF - no top FACE
// init data of side FACEs
- vector< PrismSide > sides( botEdges.size() );
- for ( int iS = 0; iS < botEdges.size(); ++iS )
+ sides.clear();
+ sides.resize( botEdges.size() );
+ for ( size_t iS = 0; iS < botEdges.size(); ++iS )
{
- sides[ iS ]._topEdge = botEdges[ iS ]._edge;
- sides[ iS ]._face = botF;
+ sides[ iS ]._topEdge = botEdges[ iS ]._edge;
+ sides[ iS ]._face = botF;
sides[ iS ]._leftSide = & sides[ botEdges[ iS ]._iR ];
sides[ iS ]._rightSide = & sides[ botEdges[ iS ]._iL ];
sides[ iS ]._faces = & facesOfSide[ iS ];
if ( side._isCheckedEdge[ iE ] ) continue;
const TopoDS_Edge& vertE = side.Edge( iE );
const TopoDS_Shape& neighborF = getAnotherFace( side._face, vertE, facesOfEdge );
- bool isEdgeShared = adjSide->IsSideFace( neighborF );
- if ( isEdgeShared )
+ bool isEdgeShared = adjSide->IsSideFace( neighborF );
+ if ( isEdgeShared ) // vertE is shared with adjSide
{
isAdvanced = true;
side._isCheckedEdge[ iE ] = true;
const TopoDS_Shape& topFace = sides[0]._faces->FindKey( nbFaces );
size_t iS;
for ( iS = 1; iS < sides.size(); ++iS )
- if ( !sides[ iS ]._faces->Contains( topFace ))
+ if ( ! sides[ iS ]._faces->Contains( topFace ))
break;
prismDetected = ( iS == sides.size() );
}
if ( nbUnitePerEdge[ iE ] < 0 )
continue;
// look for already united faces
- for ( int i = iE; i < iE + nbExraFaces; ++i )
+ for ( size_t i = iE; i < iE + nbExraFaces; ++i )
{
if ( nbUnitePerEdge[ i ] > 0 ) // a side including nbUnitePerEdge[i]+1 edge
nbExraFaces += nbUnitePerEdge[ i ];
else if ( nbExraFaces > 1 ) // unite
{
double u0 = 0, sumLen = 0;
- for ( int i = iE; i < iE + nbExraFaces; ++i )
+ for ( size_t i = iE; i < iE + nbExraFaces; ++i )
sumLen += edgeLength[ i ];
vector< TSideFace* > components( nbExraFaces );
}
}
-// #define SHOWYXZ(msg, xyz) { \
-// gp_Pnt p (xyz); \
-// cout << msg << " ("<< p.X() << "; " <<p.Y() << "; " <<p.Z() << ") " <<endl; \
-// }
+// #define SHOWYXZ(msg, xyz) { gp_Pnt p(xyz); cout << msg << " ("<< p.X() << "; " <<p.Y() << "; " <<p.Z() << ") " <<endl; }
+
// double _u[]={ 0.1, 0.1, 0.9, 0.9 };
// double _v[]={ 0.1, 0.9, 0.1, 0.9 };
// for ( int z = 0; z < 2; ++z )
double tol2;
{
Bnd_B3d bndBox;
- for ( int i = 0; i < columns.size(); ++i )
+ for ( size_t i = 0; i < columns.size(); ++i )
bndBox.Add( gpXYZ( columns[i]->front() ));
tol2 = bndBox.SquareExtent() * 1e-5;
}
//t.SetScaleFactor( distZ/dist0 ); - it does not work properly, wrong base point
// check a transformation
- for ( int i = 0; i < columns.size(); ++i )
+ for ( size_t i = 0; i < columns.size(); ++i )
{
gp_Pnt p0 = gpXYZ( (*columns[i])[0] );
gp_Pnt pz = gpXYZ( (*columns[i])[z] );
myComponents ( other.myComponents.size() ),
myHelper ( *other.myHelper.GetMesh() )
{
- for (int i = 0 ; i < myComponents.size(); ++i )
+ for ( size_t i = 0 ; i < myComponents.size(); ++i )
myComponents[ i ] = new TSideFace( *other.myComponents[ i ]);
}
StdMeshers_PrismAsBlock::TSideFace::~TSideFace()
{
- for (int i = 0 ; i < myComponents.size(); ++i )
+ for ( size_t i = 0 ; i < myComponents.size(); ++i )
if ( myComponents[ i ] )
delete myComponents[ i ];
}
if ( myComponents.empty() )
return const_cast<TSideFace*>( this );
- int i;
+ size_t i;
for ( i = 0; i < myComponents.size(); ++i )
if ( U < myParams[ i ].second )
break;
void StdMeshers_PrismAsBlock::TVerticalEdgeAdaptor::dumpNodes(int nbNodes) const
{
#ifdef _DEBUG_
- for ( int i = 0; i < nbNodes && i < myNodeColumn->size(); ++i )
+ for ( int i = 0; i < nbNodes && i < (int)myNodeColumn->size(); ++i )
cout << (*myNodeColumn)[i]->GetID() << " ";
- if ( nbNodes < myNodeColumn->size() )
+ if ( nbNodes < (int) myNodeColumn->size() )
cout << myNodeColumn->back()->GetID();
#endif
}