-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 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
+// 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.
+// 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.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// SMESH SMESH : implementaion of SMESH idl descriptions
+
// File : StdMeshers_Prism_3D.cxx
// Module : SMESH
// Created : Fri Oct 20 11:37:07 2006
return gp_Ax2( O, Z, X);
}
+
+ //================================================================================
+ /*!
+ * \brief Removes submeshes meshed with regular grid from given list
+ * \retval int - nb of removed submeshes
+ */
+ //================================================================================
+
+ int removeQuasiQuads(list< SMESH_subMesh* >& notQuadSubMesh)
+ {
+ int oldNbSM = notQuadSubMesh.size();
+ SMESHDS_Mesh* mesh = notQuadSubMesh.front()->GetFather()->GetMeshDS();
+ list< SMESH_subMesh* >::iterator smIt = notQuadSubMesh.begin();
+#define __NEXT_SM { ++smIt; continue; }
+ while ( smIt != notQuadSubMesh.end() )
+ {
+ SMESH_subMesh* faceSm = *smIt;
+ SMESHDS_SubMesh* faceSmDS = faceSm->GetSubMeshDS();
+ int nbQuads = faceSmDS->NbElements();
+ if ( nbQuads == 0 ) __NEXT_SM;
+
+ // get oredered edges
+ list< TopoDS_Edge > orderedEdges;
+ list< int > nbEdgesInWires;
+ TopoDS_Vertex V000;
+ int nbWires = SMESH_Block::GetOrderedEdges( TopoDS::Face( faceSm->GetSubShape() ),
+ V000, orderedEdges, nbEdgesInWires );
+ if ( nbWires != 1 || nbEdgesInWires.front() <= 4 )
+ __NEXT_SM;
+
+ // get nb of segements on edges
+ list<int> nbSegOnEdge;
+ list< TopoDS_Edge >::iterator edge = orderedEdges.begin();
+ for ( ; edge != orderedEdges.end(); ++edge )
+ {
+ if ( SMESHDS_SubMesh* edgeSmDS = mesh->MeshElements( *edge ))
+ nbSegOnEdge.push_back( edgeSmDS->NbElements() );
+ else
+ nbSegOnEdge.push_back(0);
+ }
+
+ // unite nbSegOnEdge of continues edges
+ int nbEdges = nbEdgesInWires.front();
+ list<int>::iterator nbSegIt = nbSegOnEdge.begin();
+ for ( edge = orderedEdges.begin(); edge != orderedEdges.end(); )
+ {
+ const TopoDS_Edge& e1 = *edge++;
+ const TopoDS_Edge& e2 = ( edge == orderedEdges.end() ? orderedEdges.front() : *edge );
+ if ( SMESH_Algo::IsContinuous( e1, e2 ))
+ {
+ // common vertex of continues edges must be shared by two 2D mesh elems of geom face
+ TopoDS_Vertex vCommon = TopExp::LastVertex( e1, true );
+ const SMDS_MeshNode* vNode = SMESH_Algo::VertexNode( vCommon, mesh );
+ int nbF = 0;
+ if ( vNode )
+ {
+ SMDS_ElemIteratorPtr fIt = vNode->GetInverseElementIterator(SMDSAbs_Face);
+ while ( fIt->more() )
+ nbF += faceSmDS->Contains( fIt->next() );
+ }
+ list<int>::iterator nbSegIt1 = nbSegIt++;
+ if ( !vNode || nbF == 2 ) // !vNode - two edges can be meshed as one
+ {
+ // unite
+ if ( nbSegIt == nbSegOnEdge.end() ) nbSegIt = nbSegOnEdge.begin();
+ *nbSegIt += *nbSegIt1;
+ nbSegOnEdge.erase( nbSegIt1 );
+ --nbEdges;
+ }
+ }
+ else
+ {
+ ++nbSegIt;
+ }
+ }
+ vector<int> nbSegVec( nbSegOnEdge.begin(), nbSegOnEdge.end());
+ if ( nbSegVec.size() == 4 &&
+ nbSegVec[0] == nbSegVec[2] &&
+ nbSegVec[1] == nbSegVec[3] &&
+ nbSegVec[0] * nbSegVec[1] == nbQuads
+ )
+ smIt = notQuadSubMesh.erase( smIt );
+ else
+ __NEXT_SM;
+ }
+
+ return oldNbSM - notQuadSubMesh.size();
+ }
}
//=======================================================================
myHelper->IsQuadraticSubMesh( theShape );
- // Analyse mesh and geomerty to find block subshapes and submeshes
+ // Analyse mesh and geomerty to find block sub-shapes and submeshes
if ( !myBlock.Init( myHelper, theShape ))
return error( myBlock.GetError());
// Projections on the top and bottom faces are taken from nodes existing
// on these faces; find correspondence between bottom and top nodes
myBotToColumnMap.clear();
- if ( !assocOrProjBottom2Top() ) // it also fill myBotToColumnMap
+ if ( !assocOrProjBottom2Top() ) // it also fills myBotToColumnMap
return false;
if ( !myBlock.ComputeParameters( topCoords, topParams, ID_TOP_FACE, topParams ))
return error(TCom("Can't compute normalized parameters ")
<< "for node " << column.back()->GetID()
- << " on the face #"<< column.back()->GetPosition()->GetShapeId() );
+ << " on the face #"<< column.back()->getshapeId() );
}
// vertical loop
AddPrisms( columns, myHelper );
} // loop on bottom mesh faces
+
+ // clear data
+ myBotToColumnMap.clear();
+ myBlock.Clear();
return true;
}
void StdMeshers_Prism_3D::AddPrisms( vector<const TNodeColumn*> & columns,
SMESH_MesherHelper* helper)
{
- SMESHDS_Mesh * meshDS = helper->GetMeshDS();
- int shapeID = helper->GetSubShapeID();
-
int nbNodes = columns.size();
int nbZ = columns[0]->size();
if ( nbZ < 2 ) return;
int z = 1;
switch ( nbNodes ) {
case 3: {
- const SMDS_MeshNode* botNodes[3] = { (*columns[0])[z-1],
- (*columns[1])[z-1],
- (*columns[2])[z-1] };
- const SMDS_MeshNode* topNodes[3] = { (*columns[0])[z],
- (*columns[1])[z],
- (*columns[2])[z] };
- SMDS_VolumeOfNodes tmpVol ( botNodes[0], botNodes[1], botNodes[2],
- topNodes[0], topNodes[1], topNodes[2]);
- vTool.Set( &tmpVol );
+ SMDS_VolumeOfNodes tmpPenta ( (*columns[0])[z-1], // bottom
+ (*columns[1])[z-1],
+ (*columns[2])[z-1],
+ (*columns[0])[z], // top
+ (*columns[1])[z],
+ (*columns[2])[z] );
+ vTool.Set( &tmpPenta );
isForward = vTool.IsForward();
break;
}
case 4: {
- const SMDS_MeshNode* botNodes[4] = { (*columns[0])[z-1], (*columns[1])[z-1],
- (*columns[2])[z-1], (*columns[3])[z-1] };
- const SMDS_MeshNode* topNodes[4] = { (*columns[0])[z], (*columns[1])[z],
- (*columns[2])[z], (*columns[3])[z] };
- SMDS_VolumeOfNodes tmpVol ( botNodes[0], botNodes[1], botNodes[2], botNodes[3],
- topNodes[0], topNodes[1], topNodes[2], topNodes[3]);
- vTool.Set( &tmpVol );
+ SMDS_VolumeOfNodes tmpHex( (*columns[0])[z-1], (*columns[1])[z-1], // bottom
+ (*columns[2])[z-1], (*columns[3])[z-1],
+ (*columns[0])[z], (*columns[1])[z], // top
+ (*columns[2])[z], (*columns[3])[z] );
+ vTool.Set( &tmpHex );
isForward = vTool.IsForward();
break;
}
+ default:
+ const int di = (nbNodes+1) / 3;
+ SMDS_VolumeOfNodes tmpVol ( (*columns[0] )[z-1],
+ (*columns[di] )[z-1],
+ (*columns[2*di])[z-1],
+ (*columns[0] )[z],
+ (*columns[di] )[z],
+ (*columns[2*di])[z] );
+ vTool.Set( &tmpVol );
+ isForward = vTool.IsForward();
}
// vertical loop on columns
- for ( z = 1; z < nbZ; ++z )
- {
- SMDS_MeshElement* vol = 0;
- switch ( nbNodes ) {
- case 3: {
- const SMDS_MeshNode* botNodes[3] = { (*columns[0])[z-1],
- (*columns[1])[z-1],
- (*columns[2])[z-1] };
- const SMDS_MeshNode* topNodes[3] = { (*columns[0])[z],
- (*columns[1])[z],
- (*columns[2])[z] };
- if ( isForward )
- vol = helper->AddVolume( botNodes[0], botNodes[1], botNodes[2],
- topNodes[0], topNodes[1], topNodes[2]);
- else
- vol = helper->AddVolume( topNodes[0], topNodes[1], topNodes[2],
- botNodes[0], botNodes[1], botNodes[2]);
- break;
- }
- case 4: {
- const SMDS_MeshNode* botNodes[4] = { (*columns[0])[z-1], (*columns[1])[z-1],
- (*columns[2])[z-1], (*columns[3])[z-1] };
- const SMDS_MeshNode* topNodes[4] = { (*columns[0])[z], (*columns[1])[z],
- (*columns[2])[z], (*columns[3])[z] };
- if ( isForward )
- vol = helper->AddVolume( botNodes[0], botNodes[1], botNodes[2], botNodes[3],
- topNodes[0], topNodes[1], topNodes[2], topNodes[3]);
- else
- vol = helper->AddVolume( topNodes[0], topNodes[1], topNodes[2], topNodes[3],
- botNodes[0], botNodes[1], botNodes[2], botNodes[3]);
- break;
- }
- default:
- // polyhedron
- vector<const SMDS_MeshNode*> nodes( 2*nbNodes + 4*nbNodes);
- vector<int> quantities( 2 + nbNodes, 4 );
- quantities[0] = quantities[1] = nbNodes;
- columns.resize( nbNodes + 1 );
- columns[ nbNodes ] = columns[ 0 ];
+ helper->SetElementsOnShape( true );
+
+ switch ( nbNodes ) {
+
+ case 3: { // ---------- pentahedra
+ const int i1 = isForward ? 1 : 2;
+ const int i2 = isForward ? 2 : 1;
+ for ( z = 1; z < nbZ; ++z )
+ helper->AddVolume( (*columns[0 ])[z-1], // bottom
+ (*columns[i1])[z-1],
+ (*columns[i2])[z-1],
+ (*columns[0 ])[z], // top
+ (*columns[i1])[z],
+ (*columns[i2])[z] );
+ break;
+ }
+ case 4: { // ---------- hexahedra
+ const int i1 = isForward ? 1 : 3;
+ const int i3 = isForward ? 3 : 1;
+ for ( z = 1; z < nbZ; ++z )
+ helper->AddVolume( (*columns[0])[z-1], (*columns[i1])[z-1], // bottom
+ (*columns[2])[z-1], (*columns[i3])[z-1],
+ (*columns[0])[z], (*columns[i1])[z], // top
+ (*columns[2])[z], (*columns[i3])[z] );
+ break;
+ }
+ case 6: { // ---------- octahedra
+ const int iBase1 = isForward ? -1 : 0;
+ const int iBase2 = isForward ? 0 :-1;
+ for ( z = 1; z < nbZ; ++z )
+ helper->AddVolume( (*columns[0])[z+iBase1], (*columns[1])[z+iBase1], // bottom or top
+ (*columns[2])[z+iBase1], (*columns[3])[z+iBase1],
+ (*columns[4])[z+iBase1], (*columns[5])[z+iBase1],
+ (*columns[0])[z+iBase2], (*columns[1])[z+iBase2], // top or bottom
+ (*columns[2])[z+iBase2], (*columns[3])[z+iBase2],
+ (*columns[4])[z+iBase2], (*columns[5])[z+iBase2] );
+ break;
+ }
+ default: // ---------- polyhedra
+ vector<int> quantities( 2 + nbNodes, 4 );
+ quantities[0] = quantities[1] = nbNodes;
+ columns.resize( nbNodes + 1 );
+ columns[ nbNodes ] = columns[ 0 ];
+ const int i1 = isForward ? 1 : 3;
+ const int i3 = isForward ? 3 : 1;
+ const int iBase1 = isForward ? -1 : 0;
+ const int iBase2 = isForward ? 0 :-1;
+ vector<const SMDS_MeshNode*> nodes( 2*nbNodes + 4*nbNodes);
+ for ( z = 1; z < nbZ; ++z )
+ {
for ( int i = 0; i < nbNodes; ++i ) {
- nodes[ i ] = (*columns[ i ])[z-1]; // bottom
- nodes[ i+nbNodes ] = (*columns[ i ])[z ]; // top
+ nodes[ i ] = (*columns[ i ])[z+iBase1]; // bottom or top
+ nodes[ 2*nbNodes-i-1 ] = (*columns[ i ])[z+iBase2]; // top or bottom
// side
- int di = 2*nbNodes + 4*i - 1;
- nodes[ di ] = (*columns[i ])[z-1];
- nodes[ di+1 ] = (*columns[i+1])[z-1];
- nodes[ di+2 ] = (*columns[i+1])[z ];
- nodes[ di+3 ] = (*columns[i ])[z ];
+ int di = 2*nbNodes + 4*i;
+ nodes[ di+0 ] = (*columns[i ])[z ];
+ nodes[ di+i1] = (*columns[i+1])[z ];
+ nodes[ di+2 ] = (*columns[i+1])[z-1];
+ nodes[ di+i3] = (*columns[i ])[z-1];
}
- vol = meshDS->AddPolyhedralVolume( nodes, quantities );
+ helper->AddPolyhedralVolume( nodes, quantities );
}
- if ( vol && shapeID > 0 )
- meshDS->SetMeshElementOnShape( vol, shapeID );
- }
+
+ } // switch ( nbNodes )
}
//================================================================================
botSMDS->NbElements() != topSMDS->NbElements() ||
botSMDS->NbNodes() != topSMDS->NbNodes())
{
+ MESSAGE("nb elem bot " << botSMDS->NbElements() << " top " << topSMDS->NbElements());
+ MESSAGE("nb node bot " << botSMDS->NbNodes() << " top " << topSMDS->NbNodes());
if ( myBlock.HasNotQuadElemOnTop() )
return error(TCom("Mesh on faces #") << botSM->GetId()
<<" and #"<< topSM->GetId() << " seems different" );
const SMDS_MeshNode* topNode = bN_tN->second;
if ( botNode->GetPosition()->GetTypeOfPosition() != SMDS_TOP_FACE )
continue; // wall columns are contained in myBlock
- // compute bottom node params
- TNode bN( botNode );
-// if ( zSize > 2 ) {
-// gp_XYZ paramHint(-1,-1,-1);
-// if ( prevTNode.IsNeighbor( bN ))
-// paramHint = prevTNode.GetParams();
-// if ( !myBlock.ComputeParameters( bN.GetCoords(), bN.ChangeParams(),
-// ID_BOT_FACE, paramHint ))
-// return error(TCom("Can't compute normalized parameters for node ")
-// << botNode->GetID() << " on the face #"<< botSM->GetId() );
-// prevTNode = bN;
-// }
// create node column
+ TNode bN( botNode );
TNode2ColumnMap::iterator bN_col =
myBotToColumnMap.insert( make_pair ( bN, TNodeColumn() )).first;
TNodeColumn & column = bN_col->second;
//================================================================================
/*!
- * \brief Set projection coordinates of a node to a face and it's subshapes
+ * \brief Set projection coordinates of a node to a face and it's sub-shapes
* \param faceID - the face given by in-block ID
* \param params - node normalized parameters
* \retval bool - is a success
StdMeshers_PrismAsBlock::~StdMeshers_PrismAsBlock()
{
+ Clear();
+}
+void StdMeshers_PrismAsBlock::Clear()
+{
+ myHelper = 0;
+ myShapeIDMap.Clear();
+ myError.reset();
+
if ( mySide ) {
delete mySide; mySide = 0;
}
+ myParam2ColumnMaps.clear();
+ myShapeIndex2ColumnMap.clear();
}
//================================================================================
}
// ----------------------------------------------------------------------
- // Analyse faces mesh and topology: choose the bottom submesh.
+ // Analyse mesh and topology of faces: choose the bottom submesh.
// If there are not quadrangle geom faces, they are top and bottom ones.
// Not quadrangle geom faces must be only on top and bottom.
// ----------------------------------------------------------------------
bool hasNotQuad = ( nbNotQuad || nbNotQuadMeshed );
// detect bad cases
- if ( nbNotQuad > 0 && nbNotQuad != 2 )
- return error(COMPERR_BAD_SHAPE,
- TCom("More than 2 not quadrilateral faces: ")
- <<nbNotQuad);
if ( nbNotQuadMeshed > 2 )
+ {
return error(COMPERR_BAD_INPUT_MESH,
TCom("More than 2 faces with not quadrangle elements: ")
<<nbNotQuadMeshed);
+ }
+ int nbQuasiQuads = 0;
+ if ( nbNotQuad > 0 && nbNotQuad != 2 )
+ {
+ // Issue 0020843 - one of side faces is quasi-quadrilateral.
+ // Remove from notQuadGeomSubMesh faces meshed with regular grid
+ nbQuasiQuads = removeQuasiQuads( notQuadGeomSubMesh );
+ nbNotQuad -= nbQuasiQuads;
+ if ( nbNotQuad > 0 && nbNotQuad != 2 )
+ return error(COMPERR_BAD_SHAPE,
+ TCom("More than 2 not quadrilateral faces: ")
+ <<nbNotQuad);
+ }
// get found submeshes
if ( hasNotQuad )
}
myNotQuadOnTop = ( nbNotQuadMeshed > 1 );
+ MESSAGE("myNotQuadOnTop " << myNotQuadOnTop << " nbNotQuadMeshed " << nbNotQuadMeshed);
// ----------------------------------------------------------
// Get ordered bottom edges
list< TopoDS_Edge > orderedEdges;
- list< int > nbVertexInWires;
+ list< int > nbEInW;
SMESH_Block::GetOrderedEdges( TopoDS::Face( botSM->GetSubShape().Reversed() ),
- V000, orderedEdges, nbVertexInWires );
-// if ( nbVertexInWires.size() != 1 )
+ V000, orderedEdges, nbEInW );
+// if ( nbEInW.size() != 1 )
// RETURN_BAD_RESULT("Wrong prism geometry");
// Get Wall faces corresponding to the ordered bottom edges
list< TopoDS_Face > wallFaces;
- if ( !GetWallFaces( Mesh(), shape3D, botSM->GetSubShape(), orderedEdges, wallFaces))
+ if ( !GetWallFaces( Mesh(), shape3D, botSM->GetSubShape(), orderedEdges, nbEInW, wallFaces))
return error(COMPERR_BAD_SHAPE, "Can't find side faces");
+ // check that the found top and bottom faces are opposite
+ {
+ for (TopExp_Explorer edge(botSM->GetSubShape(), TopAbs_EDGE); edge.More(); edge.Next())
+ if ( helper->IsSubShape( edge.Current(), topSM->GetSubShape() ))
+ return error(notQuadGeomSubMesh.empty() ? COMPERR_BAD_INPUT_MESH : COMPERR_BAD_SHAPE,
+ "Non-quadrilateral faces are not opposite");
+ }
+
+ // Protect from a distorted block (test 3D_mesh_HEXA3D/B7 on 32bit platform)
+ // check that all wall faces have an edge common with the top face
+ {
+ list< TopoDS_Face >::iterator faceIt = wallFaces.begin();
+ for ( ; faceIt != wallFaces.end(); ++faceIt )
+ {
+ bool hasCommon = false;
+ for (TopExp_Explorer edge(*faceIt, TopAbs_EDGE); !hasCommon && edge.More(); edge.Next())
+ if ( helper->IsSubShape( edge.Current(), topSM->GetSubShape() ))
+ hasCommon = true;
+ if ( !hasCommon )
+ return error(COMPERR_BAD_SHAPE);
+ }
+ }
+
// Find columns of wall nodes and calculate edges' lengths
// --------------------------------------------------------
myParam2ColumnMaps.clear();
myParam2ColumnMaps.resize( orderedEdges.size() ); // total nb edges
- int iE, nbEdges = nbVertexInWires.front(); // nb outer edges
+ int iE, nbEdges = nbEInW.front(); // nb outer edges
vector< double > edgeLength( nbEdges );
map< double, int > len2edgeMap;
// columns for vertices
// 1
const SMDS_MeshNode* n0 = faceColumns.begin()->second.front();
- id = n0->GetPosition()->GetShapeId();
+ id = n0->getshapeId();
myShapeIndex2ColumnMap[ id ] = make_pair( & faceColumns, isForward );
// 2
const SMDS_MeshNode* n1 = faceColumns.rbegin()->second.front();
- id = n1->GetPosition()->GetShapeId();
+ id = n1->getshapeId();
myShapeIndex2ColumnMap[ id ] = make_pair( & faceColumns, isForward );
// SHOWYXZ("\np1 F "<<iE, gpXYZ(faceColumns.begin()->second.front() ));
// SHOWYXZ("p2 F "<<iE, gpXYZ(faceColumns.rbegin()->second.front() ));
int nbSplit = i_nb->second;
vector< double > params;
splitParams( nbSplit, &myParam2ColumnMaps[ iE ], params );
- bool isForward = ( edgeIt->Orientation() == TopAbs_FORWARD );
+ const bool isForward =
+ StdMeshers_PrismAsBlock::IsForwardEdge( myHelper->GetMeshDS(),
+ myParam2ColumnMaps[iE],
+ *edgeIt, SMESH_Block::ID_Fx0z );
for ( int i = 0; i < nbSplit; ++i ) {
- double f = ( isForward ? params[ i ] : params[ nbSplit - i-1 ]);
+ double f = ( isForward ? params[ i ] : params[ nbSplit - i-1 ]);
double l = ( isForward ? params[ i+1 ] : params[ nbSplit - i ]);
TSideFace* comp = new TSideFace( myHelper, wallFaceIds[ iSide ],
*faceIt, *edgeIt,
// columns for vertices
const SMDS_MeshNode* n0 = cols->begin()->second.front();
- id = n0->GetPosition()->GetShapeId();
+ id = n0->getshapeId();
myShapeIndex2ColumnMap[ id ] = make_pair( cols, isForward );
const SMDS_MeshNode* n1 = cols->rbegin()->second.front();
- id = n1->GetPosition()->GetShapeId();
+ id = n1->getshapeId();
myShapeIndex2ColumnMap[ id ] = make_pair( cols, !isForward );
}
}
const TNodeColumn* StdMeshers_PrismAsBlock::GetNodeColumn(const SMDS_MeshNode* node) const
{
- int sID = node->GetPosition()->GetShapeId();
+ int sID = node->getshapeId();
map<int, pair< TParam2ColumnMap*, bool > >::const_iterator col_frw =
myShapeIndex2ColumnMap.find( sID );
list< TopoDS_Edge >::iterator edgeIt = orderedEdges.begin();
for ( int iE = 0; iE < nbEdgesInWires.front(); ++iE, ++edgeIt )
{
- const TParam2ColumnMap& u2colMap =
+ if ( BRep_Tool::Degenerated( *edgeIt )) continue;
+ const TParam2ColumnMap* u2colMap =
GetParam2ColumnMap( myHelper->GetMeshDS()->ShapeToIndex( *edgeIt ), isReverse );
+ if ( !u2colMap ) return false;
isReverse = ( edgeIt->Orientation() == TopAbs_REVERSED );
- double f = u2colMap.begin()->first, l = u2colMap.rbegin()->first;
+ double f = u2colMap->begin()->first, l = u2colMap->rbegin()->first;
if ( isReverse ) swap ( f, l );
const int nbCol = 5;
for ( int i = 0; i < nbCol; ++i )
{
double u = f + i/double(nbCol) * ( l - f );
- const TNodeColumn* col = & getColumn( & u2colMap, u )->second;
+ const TNodeColumn* col = & getColumn( u2colMap, u )->second;
if ( columns.empty() || col != columns.back() )
columns.push_back( col );
}
Bnd_B3d bndBox;
for ( int i = 0; i < columns.size(); ++i )
bndBox.Add( gpXYZ( columns[i]->front() ));
- tol2 = bndBox.SquareExtent() * 4 * 1e-4;
+ tol2 = bndBox.SquareExtent() * 1e-5;
}
// Compute transformations
* \param columnsMap - node columns map of side face
* \param bottomEdge - the bootom edge
* \param sideFaceID - side face in-block ID
- * \retval bool - true if orientation coinside with in-block froward orientation
+ * \retval bool - true if orientation coinside with in-block forward orientation
*/
//================================================================================
const int sideFaceID)
{
bool isForward = false;
- if ( TAssocTool::IsClosedEdge( bottomEdge ))
+ if ( SMESH_MesherHelper::IsClosedEdge( bottomEdge ))
{
isForward = ( bottomEdge.Orientation() == TopAbs_FORWARD );
}
*/
//================================================================================
-bool StdMeshers_PrismAsBlock::GetWallFaces( SMESH_Mesh* mesh,
- const TopoDS_Shape & mainShape,
- const TopoDS_Shape & bottomFace,
- const std::list< TopoDS_Edge >& bottomEdges,
- std::list< TopoDS_Face >& wallFaces)
+bool StdMeshers_PrismAsBlock::GetWallFaces( SMESH_Mesh* mesh,
+ const TopoDS_Shape & mainShape,
+ const TopoDS_Shape & bottomFace,
+ std::list< TopoDS_Edge >& bottomEdges,
+ std::list< int > & nbEInW,
+ std::list< TopoDS_Face >& wallFaces)
{
wallFaces.clear();
TopTools_IndexedMapOfShape faceMap;
TopExp::MapShapes( mainShape, TopAbs_FACE, faceMap );
- list< TopoDS_Edge >::const_iterator edge = bottomEdges.begin();
- for ( ; edge != bottomEdges.end(); ++edge )
+ list< TopoDS_Edge >::iterator edge = bottomEdges.begin();
+ std::list< int >::iterator nbE = nbEInW.begin();
+ int iE = 0;
+ while ( edge != bottomEdges.end() )
{
- TopTools_ListIteratorOfListOfShape ancestIt = mesh->GetAncestors( *edge );
- for ( ; ancestIt.More(); ancestIt.Next() )
+ ++iE;
+ if ( BRep_Tool::Degenerated( *edge ))
{
- const TopoDS_Shape& ancestor = ancestIt.Value();
- if ( ancestor.ShapeType() == TopAbs_FACE && // face
- !bottomFace.IsSame( ancestor ) && // not bottom
- faceMap.FindIndex( ancestor )) // belongs to the prism
+ edge = bottomEdges.erase( edge );
+ --iE;
+ --(*nbE);
+ }
+ else
+ {
+ PShapeIteratorPtr fIt = myHelper->GetAncestors( *edge, *mesh, TopAbs_FACE );
+ while ( fIt->more() )
{
- wallFaces.push_back( TopoDS::Face( ancestor ));
- break;
+ const TopoDS_Shape* face = fIt->next();
+ if ( !bottomFace.IsSame( *face ) && // not bottom
+ faceMap.FindIndex( *face )) // belongs to the prism
+ {
+ wallFaces.push_back( TopoDS::Face( *face ));
+ break;
+ }
}
+ ++edge;
+ }
+ if ( iE == *nbE )
+ {
+ iE = 0;
+ ++nbE;
}
}
return ( wallFaces.size() == bottomEdges.size() );
// find edge by 2 vertices
TopoDS_Shape V1 = edge;
TopoDS_Shape V2 = myHelper->GetSubShapeByNode( node, meshDS );
- if ( V2.ShapeType() == TopAbs_VERTEX && !V2.IsSame( V1 ))
+ if ( !V2.IsNull() && V2.ShapeType() == TopAbs_VERTEX && !V2.IsSame( V1 ))
{
- TopTools_ListIteratorOfListOfShape ancestIt =
- myHelper->GetMesh()->GetAncestors( V1 );
- for ( ; ancestIt.More(); ancestIt.Next() )
- {
- const TopoDS_Shape & ancestor = ancestIt.Value();
- if ( ancestor.ShapeType() == TopAbs_EDGE )
- for ( TopExp_Explorer e( ancestor, TopAbs_VERTEX ); e.More(); e.Next() )
- if ( V2.IsSame( e.Current() ))
- return TopoDS::Edge( ancestor );
- }
+ TopoDS_Shape ancestor = myHelper->GetCommonAncestor( V1, V2, *myHelper->GetMesh(), TopAbs_EDGE);
+ if ( !ancestor.IsNull() )
+ return TopoDS::Edge( ancestor );
}
return TopoDS_Edge();
}
//================================================================================
/*!
- * \brief Fill block subshapes
+ * \brief Fill block sub-shapes
* \param shapeMap - map to fill in
- * \retval int - nb inserted subshapes
+ * \retval int - nb inserted sub-shapes
*/
//================================================================================