-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathMeshDecoder.cs
More file actions
31 lines (27 loc) · 805 Bytes
/
MeshDecoder.cs
File metadata and controls
31 lines (27 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Rhino.Geometry;
using ARDB = Autodesk.Revit.DB;
namespace RhinoInside.Revit.Convert.Geometry
{
static class MeshDecoder
{
internal static Mesh ToRhino(ARDB.Mesh mesh)
{
return Raw.RawDecoder.ToRhino(mesh);
}
internal static Mesh FromRawMesh(Mesh mesh, double scaleFactor)
{
if (scaleFactor != 1.0 && !mesh.Scale(scaleFactor))
return default;
if (!mesh.IsValidWithLog(out var log))
{
if (log.Contains("has degenerate double precision vertex locations"))
{
var fixedFaceCount = 0;
mesh.Faces.RemoveZeroAreaFaces(ref fixedFaceCount);
}
}
mesh.Vertices.Align(2.0 * GeometryTolerance.Model.VertexTolerance); // MeshEncoder.ShortEdgeTolerance in model units
return mesh;
}
}
}