}
}
SMESHGUI_SelectionOp::startOperation();
- // iterate through dimensions and get available algoritms, set them to the dialog
+ // iterate through dimensions and get available algorithms, set them to the dialog
_PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
{
if (aDim == -1)
return;
- // find highest available dimension, all algos of this dimension are available for choice
- int aTopDim = -1;
- for (int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++)
- if (isAccessibleDim( i ))
- aTopDim = i;
- if (aTopDim == -1)
- return;
-
const bool isSubmesh = ( myToCreate ? !myIsMesh : myDlg->isObjectShown( SMESHGUI_MeshDlg::Mesh ));
HypothesisData* algoData = hypData( aDim, Algo, theIndex );
QStringList anAvailable;
- // check that tab enabled of one less dimension
- if ( aDim > SMESH::DIM_0D )
- {
- if ( myIsOnGeometry ) {
- QString anCompareType = currentMeshTypeName(myDlg->currentMeshType());
- bool is2dtype = ( anCompareType == "QUAD" ) || ( anCompareType == "TRIA" );
- int dim = is2dtype ? SMESH::DIM_2D : SMESH::DIM_3D;
- dim = ( myMaxShapeDim < dim ) ? myMaxShapeDim : dim;
- for (int i = dim; i >= SMESH::DIM_0D; i--) {
- if ( i != aDim ) {
- if ( algoData && algoData->InputTypes.isEmpty() ) {
- myDlg->disableTab( i );
- setCurrentHyp(i, Algo, -1);
- }
- else {
- myDlg->enableTab( i );
- }
+ // enable / disable tabs
+ if ( myIsOnGeometry ) {
+ for (int i = SMESH::DIM_3D; i >= SMESH::DIM_0D; i--) {
+ if ( i > aDim ) {
+ if ( i > myMaxShapeDim ) myDlg->disableTab( i );
+ else myDlg->enableTab( i );
+ }
+ else if ( i == aDim ) {
+ continue;
+ }
+ else {//( i < aDim )
+ if ( algoData && algoData->InputTypes.isEmpty() ) {
+ myDlg->disableTab( i );
+ for ( int type = Algo, nbTypes = nbDlgHypTypes(i); type < nbTypes; type++ )
+ setCurrentHyp(i, type, -1);
+ }
+ else {
+ myDlg->enableTab( i );
}
}
}
nextAlgo = 0;
}
- // set new available algoritms
+ // set new available algorithms
availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], prevAlgo, nextAlgo, anCurrentCompareType);
HypothesisData* soleCompatible = 0;
if ( anAvailable.count() == 1 )
algoIndex = myAvailableHypData[dim][Algo].indexOf( curAlgo );
if ( !isSubmesh && algoIndex < 0 && soleCompatible && !forward && dim != SMESH::DIM_0D) {
// select the sole compatible algo
- algoIndex = myAvailableHypData[dim][Algo].indexOf( soleCompatible );
+ algoIndex = 0;
}
- setCurrentHyp( dim, Algo, algoIndex);
+ setCurrentHyp( dim, Algo, algoIndex );
// remember current algo
prevAlgo = algoByDim[ dim ] = hypData( dim, Algo, algoIndex );
- }
+
+ } // loop on dims
+
if ( myMaxShapeDim == SMESH::DIM_3D && forward && algoDim == SMESH::DIM_1D )
{
algoDim = SMESH::DIM_3D;
a3DAlgo = prevAlgo;
continue;
}
- }
+ } // loops backward and forward
+
- // set hypotheses corresponding to the found algoritms
+ // set hypotheses corresponding to the found algorithms
_PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
return anAlgoVar;
QString aHypName = dataList[ aHypIndex ]->TypeName;
- // get existing algoritms
+ // get existing algorithms
_PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
QStringList tmp;
existingHyps( theDim, Algo, pObj, tmp, myExistingHyps[ theDim ][ Algo ]);
// Assign new algorithms and hypotheses
for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
{
- if ( !isAccessibleDim( dim )) continue;
+ //if ( !isAccessibleDim( dim )) continue;
// find or create algorithm
SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
// 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 )
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;
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;
/*!
* \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 );
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
}