@@ -44,7 +44,7 @@ void convertInterpolationPoints(apf::Mesh2* m, apf::MeshEntity* e,
44
44
apf::destroyElement (elem);
45
45
}
46
46
47
- void snapToInterpolate (apf::Mesh2* m, apf::MeshEntity* e)
47
+ void snapToInterpolate (apf::Mesh2* m, apf::MeshEntity* e, bool isNew )
48
48
{
49
49
PCU_ALWAYS_ASSERT (m->canSnap ());
50
50
int type = m->getType (e);
@@ -56,9 +56,18 @@ void snapToInterpolate(apf::Mesh2* m, apf::MeshEntity* e)
56
56
m->setPoint (e,0 ,pt);
57
57
return ;
58
58
}
59
+ // e is an edge or a face
60
+ // either way, get a length-scale by computing
61
+ // the distance b/w first two downward verts
62
+ apf::MeshEntity* down[12 ];
63
+ m->getDownward (e, 0 , down);
64
+ apf::Vector3 p0, p1;
65
+ m->getPoint (down[0 ], 0 , p0);
66
+ m->getPoint (down[1 ], 0 , p1);
67
+ double lengthScale = (p1 - p0).getLength ();
59
68
apf::FieldShape * fs = m->getShape ();
60
69
int non = fs->countNodesOn (type);
61
- apf::Vector3 p, xi, pt (0 ,0 ,0 );
70
+ apf::Vector3 p, xi, pt0, pt (0 ,0 ,0 );
62
71
for (int i = 0 ; i < non; ++i){
63
72
apf::ModelEntity* g = m->toModel (e);
64
73
fs->getNodeXi (type,i,xi);
@@ -67,7 +76,13 @@ void snapToInterpolate(apf::Mesh2* m, apf::MeshEntity* e)
67
76
else
68
77
transferParametricOnTriSplit (m,e,xi,p);
69
78
m->snapToModel (g,p,pt);
70
- m->setPoint (e,i,pt);
79
+ if (isNew || !m->canGetClosestPoint ()) {
80
+ m->setPoint (e,i,pt);
81
+ continue ;
82
+ }
83
+ m->getPoint (e,i,pt0);
84
+ if (!m->isOnModel (g, pt0, lengthScale))
85
+ m->setPoint (e,i,pt);
71
86
}
72
87
}
73
88
0 commit comments