mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 05:50:32 +05:00
some thread-safe STLGeometry projection functions
This commit is contained in:
parent
17dfd45609
commit
8659e5a3ee
@ -124,33 +124,29 @@ bool STLGeometry :: CalcPointGeomInfo(int /*surfind*/, PointGeomInfo& gi, const
|
|||||||
|
|
||||||
bool STLGeometry :: ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const
|
bool STLGeometry :: ProjectPointGI (int surfind, Point<3> & p, PointGeomInfo & gi) const
|
||||||
{
|
{
|
||||||
SelectChartOfTriangle(gi.trignum);
|
static std::mutex mutex_project_whole_surface;
|
||||||
gi.trignum = Project (p);
|
int meshchart = GetChartNr(gi.trignum);
|
||||||
if (!gi.trignum)
|
const STLChart& chart = GetChart(meshchart);
|
||||||
|
int trignum = chart.ProjectNormal(p);
|
||||||
|
if(trignum==0)
|
||||||
{
|
{
|
||||||
|
// non-thread-safe implementation
|
||||||
|
std::lock_guard<std::mutex> guard(mutex_project_whole_surface);
|
||||||
PrintMessage(7,"project failed");
|
PrintMessage(7,"project failed");
|
||||||
|
SelectChartOfTriangle (gi.trignum); // needed because ProjectOnWholeSurface uses meshchartnv (the normal vector of selected chart)
|
||||||
gi.trignum = ProjectOnWholeSurface(p);
|
trignum = ProjectOnWholeSurface(p);
|
||||||
if (!gi.trignum)
|
if(trignum==0)
|
||||||
{
|
{
|
||||||
PrintMessage(7, "project on whole surface failed");
|
PrintMessage(7, "project on whole surface failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STLGeometry :: ProjectPoint (INDEX surfind, Point<3> & p) const
|
void STLGeometry :: ProjectPoint (INDEX surfind, Point<3> & p) const
|
||||||
{
|
{
|
||||||
if (!Project (p))
|
throw Exception("ProjectPoint without PointGeomInfo not implemented");
|
||||||
{
|
|
||||||
PrintMessage(7,"project failed");
|
|
||||||
|
|
||||||
if (!ProjectOnWholeSurface(p))
|
|
||||||
{
|
|
||||||
PrintMessage(7, "project on whole surface failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void STLGeometry ::
|
void STLGeometry ::
|
||||||
@ -173,11 +169,13 @@ PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
|
|||||||
|
|
||||||
Point<3> np1 = newp;
|
Point<3> np1 = newp;
|
||||||
Point<3> np2 = newp;
|
Point<3> np2 = newp;
|
||||||
SelectChartOfTriangle (gi1.trignum);
|
auto ngi1 = gi1;
|
||||||
int tn1 = Project (np1);
|
auto ngi2 = gi2;
|
||||||
|
// SelectChartOfTriangle (gi1.trignum);
|
||||||
|
int tn1 = ProjectPointGI (surfi, np1, ngi1);
|
||||||
|
|
||||||
SelectChartOfTriangle (gi2.trignum);
|
// SelectChartOfTriangle (gi2.trignum);
|
||||||
int tn2 = Project (np2);
|
int tn2 = ProjectPointGI (surfi, np2, ngi2);
|
||||||
|
|
||||||
newgi.trignum = tn1; //urspruengliche version
|
newgi.trignum = tn1; //urspruengliche version
|
||||||
newp = np1; //urspruengliche version
|
newp = np1; //urspruengliche version
|
||||||
|
Loading…
Reference in New Issue
Block a user