#include "SMESH_Pattern.hxx"
#include "SMESH_subMesh.hxx"
#include "SMESH_subMeshEventListener.hxx"
+#include "SMESH_Comment.hxx"
#include "SMDS_EdgePosition.hxx"
#include "utilities.h"
!TAssocTool::IsSubShape( edge, srcMesh ) ||
!TAssocTool::IsSubShape( edge, _sourceHypo->GetSourceFace() ))
{
+ theStatus = HYP_BAD_PARAMETER;
SCRUTE((edge.IsNull()));
SCRUTE((TAssocTool::IsSubShape( edge, srcMesh )));
SCRUTE((TAssocTool::IsSubShape( edge, _sourceHypo->GetSourceFace() )));
- theStatus = HYP_BAD_PARAMETER;
}
else
{
!TAssocTool::IsSubShape( edge, tgtMesh ) ||
!TAssocTool::IsSubShape( edge, theShape ))
{
+ theStatus = HYP_BAD_PARAMETER;
SCRUTE((edge.IsNull()));
SCRUTE((TAssocTool::IsSubShape( edge, tgtMesh )));
SCRUTE((TAssocTool::IsSubShape( edge, theShape )));
- theStatus = HYP_BAD_PARAMETER;
}
}
}
// check a source face
- if ( !TAssocTool::IsSubShape( _sourceHypo->GetSourceFace(), srcMesh )) {
- MESSAGE("Bad source face");
+ if ( !TAssocTool::IsSubShape( _sourceHypo->GetSourceFace(), srcMesh ) ||
+ ( srcMesh == tgtMesh && theShape == _sourceHypo->GetSourceFace() ))
+ {
theStatus = HYP_BAD_PARAMETER;
+ SCRUTE((TAssocTool::IsSubShape( _sourceHypo->GetSourceFace(), srcMesh )));
+ SCRUTE((srcMesh == tgtMesh));
+ SCRUTE(( theShape == _sourceHypo->GetSourceFace() ));
}
}
else
// do not break but iterate over DependsOn()
}
default:
- const map< int, SMESH_subMesh * >& subSM = sm->DependsOn();
- map< int, SMESH_subMesh * >::const_iterator i_sm = subSM.begin();
- for ( ; i_sm != subSM.end(); ++i_sm )
- Clean( i_sm->second );
+ SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(false,false);
+ while ( smIt->more() )
+ Clean( smIt->next() );
}
}
};
TAssocTool::InitVertexAssociation( _sourceHypo, shape2ShapeMap );
if ( !TAssocTool::FindSubShapeAssociation( tgtFace, tgtMesh, srcFace, srcMesh,
shape2ShapeMap) )
- RETURN_BAD_RESULT("FindSubShapeAssociation failed");
+ return error(COMPERR_BAD_SHAPE,"Topology of source and target faces seems different" );
// ----------------------------------------------
// Assure that mesh on a source Face is computed
if ( tgtMesh == srcMesh ) {
if ( !TAssocTool::MakeComputed( srcSubMesh ))
- RETURN_BAD_RESULT("Impossible to compute the source mesh");
+ return error(COMPERR_BAD_INPUT_MESH,"Source mesh not computed");
}
else {
if ( !srcSubMesh->IsMeshComputed() )
- RETURN_BAD_RESULT("Source mesh is not computed");
+ return error(COMPERR_BAD_INPUT_MESH,"Source mesh not computed");
}
// --------------------
SMESH_Pattern mapper;
mapper.Load( srcMesh, srcFace );
if ( mapper.GetErrorCode() != SMESH_Pattern::ERR_OK )
- RETURN_BAD_RESULT("SMESH_Pattern::Load() failed");
+ return error(COMPERR_BAD_INPUT_MESH,"Can't load mesh pattern from the source face");
// Find the first target vertex corresponding to first vertex of the <mapper>
// and <theReverse> flag needed to call mapper.Apply()
{
TopoDS_Edge srcE1 = srcEdges.front(), tgtE1 = tgtEdges.front();
reverse = ( ! srcE1.IsSame( shape2ShapeMap( tgtE1 )));
- if ( BRep_Tool::IsClosed( tgtE1, tgtFace )) {
- reverse = ( srcE1.Orientation() == tgtE1.Orientation() );
- if ( _sourceHypo->GetSourceFace().Orientation() != theShape.Orientation() )
- reverse = !reverse;
- }
}
else if ( nbEdgesInWires.front() == 1 )
{
mapper.Apply( tgtFace, tgtV1, reverse );
if ( mapper.GetErrorCode() != SMESH_Pattern::ERR_OK )
- RETURN_BAD_RESULT("SMESH_Pattern::Apply() failed");
+ return error("Can't apply source mesh pattern to the face");
// Create the mesh
const bool toCreatePolygons = false, toCreatePolyedrs = false;
mapper.MakeMesh( tgtMesh, toCreatePolygons, toCreatePolyedrs );
if ( mapper.GetErrorCode() != SMESH_Pattern::ERR_OK )
- RETURN_BAD_RESULT("SMESH_Pattern::MakeMesh() failed");
+ return error("Can't make mesh by source mesh pattern");
// it will remove mesh built by pattern mapper on edges and vertices
// in failure case
- MeshCleaner cleaner( tgtSubMesh );
+ // MeshCleaner cleaner( tgtSubMesh );
// -------------------------------------------------------------------------
// mapper doesn't take care of nodes already existing on edges and vertices,
// Make groups of nodes to merge
// loop on edge and vertex submeshes of a target face
- const map< int, SMESH_subMesh * >& subSM = tgtSubMesh->DependsOn();
- map< int, SMESH_subMesh * >::const_iterator i_subSM = subSM.begin();
- for ( ; i_subSM != subSM.end(); ++i_subSM )
+ SMESH_subMeshIteratorPtr smIt = tgtSubMesh->getDependsOnIterator(false,false);
+ while ( smIt->more() )
{
- SMESH_subMesh* sm = i_subSM->second;
+ SMESH_subMesh* sm = smIt->next();
SMESHDS_SubMesh* smDS = sm->GetSubMeshDS();
// Sort new and old nodes of a submesh separately
bool isSeam = helper.IsSeamShape( sm->GetId() );
- enum { NEW_NODES, OLD_NODES };
+ enum { NEW_NODES = 0, OLD_NODES };
map< double, const SMDS_MeshNode* > u2nodesMaps[2], u2nodesOnSeam;
map< double, const SMDS_MeshNode* >::iterator u_oldNode, u_newNode, u_newOnSeam, newEnd;
set< const SMDS_MeshNode* > seamNodes;
}
// sort nodes on edges by its position
- map< double, const SMDS_MeshNode* > & pos2nodes = u2nodesMaps[ isOld ];
+ map< double, const SMDS_MeshNode* > & pos2nodes = u2nodesMaps[isOld ? OLD_NODES : NEW_NODES];
switch ( node->GetPosition()->GetTypeOfPosition() )
{
case SMDS_TOP_VERTEX: {
node->GetPosition()->GetTypeOfPosition());
}
}
- if ( u2nodesMaps[ OLD_NODES ].size() != u2nodesMaps[ NEW_NODES ].size() )
- RETURN_BAD_RESULT("Different nb of old and new nodes " <<
+ if ( u2nodesMaps[ NEW_NODES ].size() != u2nodesMaps[ OLD_NODES ].size() )
+ {
+ if ( u2nodesMaps[ NEW_NODES ].size() == 0 &&
+ sm->GetSubShape().ShapeType() == TopAbs_EDGE &&
+ BRep_Tool::Degenerated( TopoDS::Edge( sm->GetSubShape() )))
+ // NPAL15894 (tt88bis.py) - project mesh built by NETGEN_1d_2D that
+ // does not make segments/nodes on degenerated edges
+ continue;
+ RETURN_BAD_RESULT("Different nb of old and new nodes on shape #"<< sm->GetId() <<" "<<
u2nodesMaps[ OLD_NODES ].size() << " != " <<
u2nodesMaps[ NEW_NODES ].size());
- if ( isSeam && u2nodesMaps[ OLD_NODES ].size() != u2nodesOnSeam.size() )
+ }
+ if ( isSeam && u2nodesMaps[ OLD_NODES ].size() != u2nodesOnSeam.size() ) {
RETURN_BAD_RESULT("Different nb of old and seam nodes " <<
u2nodesMaps[ OLD_NODES ].size() << " != " << u2nodesOnSeam.size());
-
+ }
// Make groups of nodes to merge
u_oldNode = u2nodesMaps[ OLD_NODES ].begin();
u_newNode = u2nodesMaps[ NEW_NODES ].begin();
}
}
- cleaner.Release(); // do not remove mesh
+ //cleaner.Release(); // do not remove mesh
return true;
}
void StdMeshers_Projection_2D::SetEventListener(SMESH_subMesh* subMesh)
{
- if ( _sourceHypo && ! _sourceHypo->GetSourceFace().IsNull() )
- {
- SMESH_Mesh* srcMesh = _sourceHypo->GetSourceMesh();
- if ( !srcMesh )
- srcMesh = subMesh->GetFather();
-
- SMESH_subMesh* srcFaceSM =
- srcMesh->GetSubMesh( _sourceHypo->GetSourceFace() );
-
- subMesh->SetEventListener( new SMESH_subMeshEventListener(),
- SMESH_subMeshEventListenerData::MakeData( subMesh ),
- srcFaceSM );
- }
+ TAssocTool::SetEventListener( subMesh,
+ _sourceHypo->GetSourceFace(),
+ _sourceHypo->GetSourceMesh() );
}