#include <utilities.h>
+#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepMesh_Delaun.hxx>
#include <BRep_Tool.hxx>
#include <Bnd_B2d.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomLib_IsPlanarSurface.hxx>
+#include <Precision.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
using namespace std;
#define RETURN_BAD_RESULT(msg) { MESSAGE(")-: Error: " << msg); return false; }
+#ifdef _DEBUG_
+// enable printing algo + projection shapes while meshing
+//#define PRINT_WHO_COMPUTE_WHAT
+#endif
namespace TAssocTool = StdMeshers_ProjectionUtils;
//typedef StdMeshers_ProjectionUtils TAssocTool;
if (( err && !err->IsOK() ) ||
( srcWires.empty() ))
return err;
-
+#ifdef PRINT_WHO_COMPUTE_WHAT
+ cout << "Projection_2D" << " F "
+ << tgtMesh->GetMeshDS()->ShapeToIndex( tgtFace ) << " <- "
+ << srcMesh->GetMeshDS()->ShapeToIndex( srcFace ) << endl;
+#endif
SMESH_MesherHelper srcHelper( *srcMesh );
srcHelper.SetSubShape( srcFace );
for ( int iE = 0; iE < srcWire->NbEdges(); ++iE )
{
+#ifdef PRINT_WHO_COMPUTE_WHAT
+ if ( tgtMesh->GetSubMesh( tgtWire->Edge(iE) )->IsEmpty() )
+ cout << "Projection_2D" << " E "
+ << tgtWire->EdgeID(iE) << " <- " << srcWire->EdgeID(iE) << endl;
+#endif
if ( srcMesh->GetSubMesh( srcWire->Edge(iE) )->IsEmpty() ||
tgtMesh->GetSubMesh( tgtWire->Edge(iE) )->IsEmpty() )
{
SMESH_MesherHelper srcHelper( *srcMesh );
srcHelper.SetSubShape( srcFace );
+ SMESH_MesherHelper edgeHelper( *tgtMesh );
+ edgeHelper.ToFixNodeParameters( true );
const SMDS_MeshNode* nullNode = 0;
TAssocTool::TNodeNodeMap::iterator srcN_tgtN;
}
case SMDS_TOP_EDGE:
{
- const TopoDS_Shape & srcE = srcMeshDS->IndexToShape( srcNode->getshapeId() );
- const TopoDS_Shape & tgtE = shape2ShapeMap( srcE, /*isSrc=*/true );
- double srcU = srcHelper.GetNodeU( TopoDS::Edge( srcE ), srcNode );
- tgtMeshDS->SetNodeOnEdge( n, TopoDS::Edge( tgtE ), srcU );
+ const TopoDS_Edge& srcE = TopoDS::Edge( srcMeshDS->IndexToShape( srcNode->getshapeId()));
+ const TopoDS_Edge& tgtE = TopoDS::Edge( shape2ShapeMap( srcE, /*isSrc=*/true ));
+ double srcU = srcHelper.GetNodeU( srcE, srcNode );
+ tgtMeshDS->SetNodeOnEdge( n, tgtE, srcU );
+ if ( !tgtFace.IsPartner( srcFace ))
+ {
+ edgeHelper.SetSubShape( tgtE );
+ double tol = BRep_Tool::Tolerance( tgtE );
+ bool isOk = edgeHelper.CheckNodeU( tgtE, n, srcU, 2 * tol, /*force=*/true );
+ if ( !isOk ) // projection of n to tgtE failed (23395)
+ {
+ double sF, sL, tF, tL;
+ BRep_Tool::Range( srcE, sF, sL );
+ BRep_Tool::Range( tgtE, tF, tL );
+ double srcR = ( srcU - sF ) / ( sL - sF );
+ double tgtU = tF + srcR * ( tL - tF );
+ tgtMeshDS->SetNodeOnEdge( n, tgtE, tgtU );
+ gp_Pnt newP = BRepAdaptor_Curve( tgtE ).Value( tgtU );
+ double dist = newP.Distance( tgtP );
+ if ( tol < dist && dist < 1000*tol )
+ tgtMeshDS->MoveNode( n, newP.X(), newP.Y(), newP.Z() );
+ }
+ }
break;
}
case SMDS_TOP_VERTEX:
if ( !tgtFace.IsPartner( srcFace ) )
{
- SMESH_MesherHelper edgeHelper( *tgtMesh );
- edgeHelper.ToFixNodeParameters( true );
helper.ToFixNodeParameters( true );
int nbOkPos = 0;
- bool toCheck = true;
const double tol2d = 1e-12;
srcN_tgtN = src2tgtNodes.begin();
for ( ; srcN_tgtN != src2tgtNodes.end(); ++srcN_tgtN )
}
case SMDS_TOP_EDGE:
{
- const TopoDS_Edge & tgtE = TopoDS::Edge( tgtMeshDS->IndexToShape( n->getshapeId() ));
- edgeHelper.SetSubShape( tgtE );
- edgeHelper.GetNodeU( tgtE, n, 0, &toCheck );
+ // const TopoDS_Edge & tgtE = TopoDS::Edge( tgtMeshDS->IndexToShape( n->getshapeId() ));
+ // edgeHelper.SetSubShape( tgtE );
+ // edgeHelper.GetNodeU( tgtE, n, 0, &toCheck );
break;
}
default:;