Skip to content

Commit b705ed1

Browse files
committed
Added option to distance map to use the old method.
1 parent 24f81ff commit b705ed1

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

FEBioStudio/PostDataPanel.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class CDistanceMapProps : public CPropertyList
256256
addProperty("Signed distance", CProperty::Bool);
257257
addProperty("Flip Primary", CProperty::Bool);
258258
addProperty("Flip Secondary", CProperty::Bool);
259+
addProperty("Method", CProperty::Enum)->setEnumValues(QStringList() << "new" << "old");
259260
addProperty("", CProperty::Action, "Apply");
260261
}
261262

@@ -276,6 +277,7 @@ class CDistanceMapProps : public CPropertyList
276277
case 2: return m_map->m_bsigned; break;
277278
case 3: return m_map->m_flipPrimary; break;
278279
case 4: return m_map->m_flipSecondary; break;
280+
case 5: return m_map->m_nopt;
279281
}
280282
return QVariant();
281283
}
@@ -297,7 +299,8 @@ class CDistanceMapProps : public CPropertyList
297299
case 2: m_map->m_bsigned = v.toBool(); break;
298300
case 3: m_map->m_flipPrimary = v.toBool(); break;
299301
case 4: m_map->m_flipSecondary = v.toBool(); break;
300-
case 5:
302+
case 5: m_map->m_nopt = v.toInt(); break;
303+
case 6:
301304
{
302305
CDlgStartThread dlg(nullptr, new DistanceMapThread(m_map));
303306
dlg.exec();

PostLib/FEDistanceMap.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Post::FEDistanceMap::FEDistanceMap(Post::FEPostModel* fem, int flags) : Post::Mo
4040
m_bsigned = false;
4141
m_flipPrimary = false;
4242
m_flipSecondary = false;
43+
m_nopt = 0;
4344
}
4445

4546
//-----------------------------------------------------------------------------
@@ -51,6 +52,7 @@ Post::ModelDataField* Post::FEDistanceMap::Clone() const
5152
pd->m_surf2 = m_surf2;
5253
pd->m_tol = m_tol;
5354
pd->m_bsigned = m_bsigned;
55+
pd->m_nopt = m_nopt;
5456
return pd;
5557
}
5658

@@ -195,8 +197,16 @@ void Post::FEDistanceMap::ApplyState(int n)
195197
a[i] = (P.q - r).Length();
196198
if (m_bsigned)
197199
{
198-
double s = (P.q - r)*P.n;
199-
if (s > 0) a[i] = -a[i];
200+
if (m_nopt == 0) // new approach
201+
{
202+
double s = (P.q - r) * P.n;
203+
if (s > 0) a[i] = -a[i];
204+
}
205+
else // old approach
206+
{
207+
double s = (P.q - r) * m_surf1.m_norm[i];
208+
if (s < 0) a[i] = -a[i];
209+
}
200210
}
201211
}
202212
vector<int> nf1(m_surf1.Faces());
@@ -215,8 +225,16 @@ void Post::FEDistanceMap::ApplyState(int n)
215225
b[i] = (P.q - r).Length();
216226
if (m_bsigned)
217227
{
218-
double s = (P.q - r)*P.n;
219-
if (s > 0) b[i] = -b[i];
228+
if (m_nopt == 0) // new approach
229+
{
230+
double s = (P.q - r) * P.n;
231+
if (s > 0) b[i] = -b[i];
232+
}
233+
else
234+
{
235+
double s = (P.q - r) * m_surf2.m_norm[i];
236+
if (s < 0) b[i] = -b[i];
237+
}
220238
}
221239
}
222240
vector<int> nf2(m_surf2.Faces());

PostLib/FEDistanceMap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ class FEDistanceMap : public ModelDataField
8686

8787
void SetSigned(bool sign) { m_bsigned = sign; }
8888

89+
void SetMethod(int nopt) { m_nopt = nopt; }
90+
8991
void FlipPrimary(bool b) { m_flipPrimary = b; }
9092
void FlipSecondary(bool b) { m_flipSecondary = b; }
9193

@@ -108,5 +110,6 @@ class FEDistanceMap : public ModelDataField
108110
bool m_bsigned; //!< signed or non-signed distance
109111
bool m_flipPrimary;
110112
bool m_flipSecondary;
113+
int m_nopt;
111114
};
112115
}

PyLib/PyFBSPost.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ void init_FBSPost(py::module& m)
198198
.def("SetSigned", &FEDistanceMap::SetSigned)
199199
.def("FlipPrimary", &FEDistanceMap::FlipPrimary)
200200
.def("FlipSecondary", &FEDistanceMap::FlipSecondary)
201+
.def("SetMethod", &FEDistanceMap::SetMethod)
201202
.def("Apply", &FEDistanceMap::Apply)
202203
;
203204
}

0 commit comments

Comments
 (0)