Skip to content

Commit

Permalink
comparison fix, minor additions
Browse files Browse the repository at this point in the history
  • Loading branch information
rms80 committed Mar 26, 2018
1 parent 47500e5 commit ca363f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion distance/DistRay3Segment3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public double Get() {

public double GetSquared()
{
if (DistanceSquared > 0)
if (DistanceSquared >= 0)
return DistanceSquared;

Vector3d diff = ray.Origin - segment.Center;
Expand Down
8 changes: 7 additions & 1 deletion mesh/DMesh3_edge_operators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ public struct EdgeSplitInfo {
public int eNewBN; // new edge [vNew,vB] (original was AB)
public int eNewCN; // new edge [vNew,vC] (C is "first" other vtx in ring)
public int eNewDN; // new edge [vNew,vD] (D is "second" other, which doesn't exist on bdry)
public int eNewT2;
public int eNewT3;
}
public MeshResult SplitEdge(int vA, int vB, out EdgeSplitInfo split)
{
Expand Down Expand Up @@ -339,6 +341,8 @@ public MeshResult SplitEdge(int eab, out EdgeSplitInfo split)
split.eNewBN = efb;
split.eNewCN = efc;
split.eNewDN = InvalidID;
split.eNewT2 = t2;
split.eNewT3 = InvalidID;

updateTimeStamp(true);
return MeshResult.Ok;
Expand Down Expand Up @@ -403,8 +407,10 @@ public MeshResult SplitEdge(int eab, out EdgeSplitInfo split)
split.eNewBN = efb;
split.eNewCN = efc;
split.eNewDN = edf;
split.eNewT2 = t2;
split.eNewT3 = t3;

updateTimeStamp(true);
updateTimeStamp(true);
return MeshResult.Ok;
}

Expand Down
14 changes: 12 additions & 2 deletions queries/MeshQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static bool RayHitPointFrame(DMesh3 mesh, ISpatial spatial, Ray3d ray, ou
return false;
Vector3d surfPt = ray.PointAt(isect.RayParameter);
if (mesh.HasVertexNormals)
hitPosFrame = SurfaceFrame(mesh, tid, surfPt);
hitPosFrame = SurfaceFrame(mesh, tid, surfPt); // TODO isect has bary-coords already!!
else
hitPosFrame = new Frame3f(surfPt, mesh.GetTriNormal(tid));
return true;
Expand All @@ -151,7 +151,17 @@ public static Frame3f SurfaceFrame(DMesh3 mesh, int tID, Vector3d point)
}



/// <summary>
/// Get barycentric coords of point in triangle
/// </summary>
public static Vector3d BaryCoords(DMesh3 mesh, int tID, Vector3d point)
{
if (!mesh.IsTriangle(tID))
throw new Exception("MeshQueries.SurfaceFrame: triangle " + tID + " does not exist!");
Triangle3d tri = new Triangle3d();
mesh.GetTriVertices(tID, ref tri.V0, ref tri.V1, ref tri.V2);
return tri.BarycentricCoords(point);
}


/// <summary>
Expand Down

0 comments on commit ca363f3

Please sign in to comment.