From 512c67cad7a40e580163f030d26ff86ef095e49a Mon Sep 17 00:00:00 2001 From: Amaury Johnan <amjohnen@gmail.com> Date: Mon, 25 Apr 2016 14:14:27 +0000 Subject: [PATCH] fix low accuracy in computation of point parameter on edges. Why would you skip computation with relax=1 since it gives the 'exact' parameter value for straight GEdges? --- Geo/GEdge.cpp | 9 +++++---- Geo/GEdge.h | 2 +- Geo/GEntity.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp index 6cb9df2a45..5db8f3c3f7 100644 --- a/Geo/GEdge.cpp +++ b/Geo/GEdge.cpp @@ -477,7 +477,7 @@ bool GEdge::XYZToU(const double X, const double Y, const double Z, double uMin = uu.low(); double uMax = uu.high(); - SVector3 Q(X, Y, Z), P; + const SVector3 Q(X, Y, Z); double init[NumInitGuess]; @@ -490,6 +490,7 @@ bool GEdge::XYZToU(const double X, const double Y, const double Z, //err2 = 1.0; iter = 1; + SVector3 P = position(u); SVector3 dPQ = P - Q; err = dPQ.norm(); @@ -512,12 +513,12 @@ bool GEdge::XYZToU(const double X, const double Y, const double Z, if(relax > 1.e-2) { // Msg::Info("point %g %g %g on edge %d : Relaxation factor = %g", - // Q.x(), Q.y(), Q.z(), 0.75 * relax); - return XYZToU(Q.x(), Q.y(), Q.z(), u, 0.75 * relax); + // X, Y, Z, 0.75 * relax); + return XYZToU(X, Y, Z, u, 0.75 * relax); } // Msg::Error("Could not converge reparametrisation of point (%e,%e,%e) on edge %d", - // Q.x(), Q.y(), Q.z(), tag()); + // X, Y, Z, tag()); return false; } diff --git a/Geo/GEdge.h b/Geo/GEdge.h index 9c96c4c66a..e0db7f1cb0 100644 --- a/Geo/GEdge.h +++ b/Geo/GEdge.h @@ -184,7 +184,7 @@ class GEdge : public GEntity{ // compute the parameter U from a point XYZ virtual bool XYZToU(const double X, const double Y, const double Z, - double &U, const double relax=0.5) const; + double &U, const double relax=1) const; // compound void setCompound(GEdgeCompound *gec) { compound = gec; } diff --git a/Geo/GEntity.h b/Geo/GEntity.h index 2c30675979..9698d36544 100644 --- a/Geo/GEntity.h +++ b/Geo/GEntity.h @@ -332,7 +332,7 @@ class GEntity { void setAllElementsVisible(bool val){ _allElementsVisible = val ? 1 : 0; } // get the number of mesh vertices in the entity - unsigned int getNumMeshVertices() { return (int)mesh_vertices.size(); } + unsigned int getNumMeshVertices() { return mesh_vertices.size(); } // get the mesh vertex at the given index MVertex *getMeshVertex(unsigned int index) { return mesh_vertices[index]; } -- GitLab