Merging master

This commit is contained in:
Umberto Zerbinati 2024-01-15 22:50:49 +00:00
commit d2bba6cb3c
3 changed files with 19 additions and 3 deletions

View File

@ -57,6 +57,17 @@ namespace ngcore
}; };
template <typename T, typename = void>
class has_shallow_archive : public std::false_type {};
template <typename T>
class has_shallow_archive<T, std::void_t<decltype(T::shallow_archive)>>
: public std::is_same<decltype(T::shallow_archive), std::true_type> {};
#ifdef NETGEN_PYTHON #ifdef NETGEN_PYTHON
pybind11::object CastAnyToPy(const std::any& a); pybind11::object CastAnyToPy(const std::any& a);
#endif // NETGEN_PYTHON #endif // NETGEN_PYTHON
@ -501,7 +512,7 @@ namespace ngcore
template <typename T> template <typename T>
Archive& operator & (std::shared_ptr<T>& ptr) Archive& operator & (std::shared_ptr<T>& ptr)
{ {
if constexpr(has_shared_from_this2<T>::value) if constexpr(has_shallow_archive<T>::value)
if (shallow_to_python) if (shallow_to_python)
{ {
Shallow (ptr); Shallow (ptr);

View File

@ -678,7 +678,7 @@ namespace netgen
// prepare new points // prepare new points
fac1 = max(0.001,min(0.33,fac1)); // fac1 = max(0.001,min(0.33,fac1));
PrintMessage(3, " in HP-REFINEMENT with fac1 ", fac1); PrintMessage(3, " in HP-REFINEMENT with fac1 ", fac1);
*testout << " in HP-REFINEMENT with fac1 " << fac1 << endl; *testout << " in HP-REFINEMENT with fac1 " << fac1 << endl;

View File

@ -61,7 +61,12 @@ namespace netgen
void OCCEdge::ProjectPoint(Point<3>& p, EdgePointGeomInfo* gi) const void OCCEdge::ProjectPoint(Point<3>& p, EdgePointGeomInfo* gi) const
{ {
auto pnt = ng2occ(p); auto pnt = ng2occ(p);
GeomAPI_ProjectPointOnCurve proj(pnt, curve, s0, s1); // extend the projection parameter range, else projection might fail
// for an endpoint
// see discussion here: https://forum.ngsolve.org/t/how-to-apply-occidentification-correctly/2555
// I do not see a better way using occ tolerances?
double eps = 1e-7 * (s1-s0);
GeomAPI_ProjectPointOnCurve proj(pnt, curve, s0-eps, s1+eps);
pnt = proj.NearestPoint(); pnt = proj.NearestPoint();
if(gi) if(gi)
gi->dist = (proj.LowerDistanceParameter() - s0)/(s1-s0); gi->dist = (proj.LowerDistanceParameter() - s0)/(s1-s0);