Giter Club home page Giter Club logo

geometry3sharp's People

Contributors

gregmeess avatar matthewnewberg avatar rms80 avatar sandord avatar wieslawsoltes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geometry3sharp's Issues

Optionally write the material to a string instead of a file

Currently, the OBJWriter supports writing the material only to a file path. Some of us might need the material in memory however so it would be nice if we could write it to a string or something.

I'm currently hacking around this by writing to a temporary file and subsequently reading it into a string. This is of course very inefficient.

Any chance of some examples for MarchingCubes?

I am working with large latitude,longitude,elevation point clouds and am trying to generate an encompassing mesh. Totally new area so struggling to get started.

I expect I will need to re project into Cartesian coordinates x,y,z for it to work where do I go from there?

ObjWriter should always use InvariantCulture

The ObjWriter.Write(...) uses the thread's default culture (and that affects the numbers format ) but i guess that the obj file format should be culture angnostic/invariant.

Raise/Throw error on triangles added more than once?

// [RMS] What to do here? We definitely do not want to add a duplicate triangle!!
//   But is silently ignoring the right thing to do?

I'm still figuring my way through the library. But I'd appreciate the library showing my when I did a wrong. So that something doesn't bite me in the ass later .

Provide a .Net 4.0 dll through Nuget

Hi there,

I would very much like to use your library in a rather old code base. Would it be possible for you to provide a build for .Net 4.0?

I have downloaded the source and built it myself for .Net 4.0, but for maintainability reasons, it would be lovely to have a 4.0 build through Nuget.

To build it, I had to change line 475 of BufferUtil.cs from

DeflateStream zip = new DeflateStream(ms, (bFast) ? CompressionLevel.Fastest : CompressionLevel.Optimal, true);

to

DeflateStream zip = new DeflateStream(ms, CompressionMode.Compress, true);

I do realize that .Net 4.0 is ancient, so I understand if you would not like to support it, but I figured it was worth asking. Thanks!

Tube generator capping problem

I think there's a bug in the tube generator capping because it caps in the following incorrect way:

image

Also, the incorrect (red) vertex color is typical, although it doesn't happen on the far end side.

var profile = ... a semicircle

var path = Polygon2d
    .MakeCircle(innerRadius, steps)
    .Vertices.Select(n => new Vector3d(n.x, 0, n.y))
    .Take((int)(steps * 0.88f))
    .ToArray();

var tubeGenerator = new TubeGenerator
{
    Polygon = profile,
    Vertices = pathVertices,
    Capped = true
};

MeshIsoCurves.compute_full crashes with ArgumentOutOfRangeException

Hi!
I have stl which crashes slicer. Issue in with
MeshIsoCurves class, this line:
`
int graph_eid = Graph.AppendEdge(e0, e1, (int)TriangleCase.OnEdge);

if (WantGraphEdgeInfo)
add_on_edge(graph_eid, tid, triEdges[z0], new Index2i(e0, e1));
`

when AppendEdge returns -1, that is DuplicateEdgeID, then next method crashes. Upgrading condition to
if (WantGraphEdgeInfo && graph_eid >= 0)
solves this issue but I'm not 100% positive if this is the right way hence no PR, only issue.

Planar Reducer?

Can't seem to find it...
Basically reduce according to the difference in angle. (If more than, then remove)

How to add this project into Unity3D

I want to apply this project to make Mesh of 3D hands model in Unity, for VR .After I try to do it,it seems that those codes are not the whole project for Unity ,so I would like to know how to do with it.
one graduate from Shanghai University ,China

Converting geometry3Sharp mesh to other mesh

Hi,

I tried your library and it works:) It is supernice.

I tried to convert your mesh to other type of mesh.
Basically what I am trying to do is to pass all vertices and mesh faces from one mesh type to another.

But I noticed that DMesh3 has vertices with strange indexing. For instance if there are 100 vertices their index id can be something like 2000, 0, 281 and etc, the mesh library I am working with vertex id would go from 0,1,2 to 100 sequentially. Therefore I always have to remap indices.

Is there a better way to do below conversion?

//Remeshed cylinder
g3.DMesh3 g3m = make_good_cylinder();


//Converting DMesh3 to Other mesh
Mesh mesh = new Mesh();

//Add all vertices
var vertices = g3m.Vertices();
foreach(g3.Vector3d vec in vertices)
  mesh.Vertices.Add(vec.x, vec.y, vec.z);

//Add faces
int[] vID = g3m.VertexIndices().ToArray();
var faces = g3m.Triangles();
foreach(g3.Index3i f in faces)
  mesh.Faces.AddFace(Array.IndexOf(vID, f.a), Array.IndexOf(vID, f.b), Array.IndexOf(vID, f.c));

Order of operations for MeshSignedDistanceGrid / MarchingCubes

After some trial and error I figured out that for e.g. subtracting a sphere from a bunny one way is to

  1. reverse the sphere with ReverseOrientation
  2. use a MeshEditor to append the bunny and the sphere
  3. run both through a MeshSignedDistanceGrid
  4. run MarchingCubes on that sdf.

That means that whenever I want to move a piece inside of a more complex operation (say, I want to move the sphere around that gets subtracted), I'll have to regenerate the mesh and the SDFs for everything. Is there a way to combine different SDFs together to speed things up? What I'd want to do is this order:

  1. have a ton of operator meshes (reversed or not reversed)
  2. generate SDFs for all of them
  3. combine SDFs into one SDF
  4. run MarchingCubes on that combined SDF

And whenever something changes:

  1. recalculate only the SDF of the changed mesh - if it's only a translation, it shouldn't even be necessary to compute the SDF again, it can just be moved around (change of origin)
  2. combine SDFs again
  3. run MarchingCubes.

Am I just missing something? If not, consider this a feature request :)

StandardMeshWriter writes using current thread culture

StandardMeshWriter writes using current thread culture, which results in data such as

v 461,939769107802 0 -191,341709296824

since I'm located in The Netherlands and my PC's culture uses a comma as a decimal separator.

Obviously, this should be:

v 461.939769107802 0 -191.341709296824

Therefore, I think the writer should use the invariant culture at all times.

DijkstraGraphDistance problem

Did anyone use DijkstraGraphDistance class?
I want to find all nodes' dijkstra distance from a single seed. But only a small part of nodes has the distance.

MeshLocalParam Problem

Thank you for sharing the excellent library.I have a question about the class MeshLocalParam.When I use the function ComputeToMaxDistance,I don't know what the arguments seedFrame and seedNbrs mean.I chose a random triangle as a seed,for example, tid=1000,but the result is messy after using the material Checkerboard.Do I need to chose a suitable seed for different mesh?

Creating geometry3sharp from array of floats and array of triangles indices

Hi,

What is the simplest method to create geometry3Sharp mesh from array of floats that represent vertex coordinates and array of face id?

I tried this one below but this produces error:

//mesh variables is other type of mesh so I try convert one mesh to geometry3Sharp mesh

float[][] v = new float[mesh.Vertices.Count][];
for(int i = 0; i < mesh.Vertices.Count; i++)
  v[i] = new []{mesh.Vertices[i].X,mesh.Vertices[i].Y,mesh.Vertices[i].Z};

int[][] t = new int[mesh.Faces.Count][];
for(int i = 0; i < mesh.Faces.Count; i++)
  t[i] = new int[]{mesh.Faces[i].A,mesh.Faces[i].B,mesh.Faces[i].C};

 DMesh3 Dmesh = geometry3Sharp.mesh.DMesh3Builder.Build(v, t,null,null);

Merging mesh vertices and keeping data when Reducing

In a lack of a real documentation, I think it's easier if I ask here;

  1. is there a way to merge vertices in meshes with multiple disconnected parts? In most applications, that functionality is called "Weld".
  2. is there a way to reproject vertex data (UVs, Normals) after a Reducer pass? Since only the vertices get properly moved around, it would be great to keep as much of the original data as possible.

Edit: found some hints of "BuildMesh_TolerantWeld" and "BuildMesh_IdenticalWeld" in STLReader.cs. From a quick glance, that would have the same issue of not keeping UVs / Normals.

Remesher Example

Hi,

I would to ask if it is possible to get a remesher example?

I am totally new to this library. And would like to create a simple mesh geometry and remesh as a test.

Would you be kind to show how to do this?

uv get null

StandardMeshReader read obj file,uv is null ! why?

MeshPlaneCut bug?

Hi, thanks for sharing this lib.

I am trying to procedurally create some bevels on a cube with the MeshPlaneCut class:

// Unity code below:
var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

    var mesh = cube.GetComponent<MeshFilter>().sharedMesh;

    var dMesh = mesh.ToDMesh3();

    MonoBehaviour.DestroyImmediate(cube);

    double dist = 0.45;

    var cutDirs = new List<Vector3d> {
        new Vector3d(dist, dist, 0),
        new Vector3d(dist, -dist, 0),
        new Vector3d(-dist, dist, 0),
        new Vector3d(-dist, -dist, 0),
        new Vector3d(0, dist, dist),
        new Vector3d(0, dist, -dist),
        new Vector3d(0, -dist, dist),
        new Vector3d(0, -dist, -dist),
        new Vector3d(dist, 0, dist),
        new Vector3d(dist, 0, -dist),
        new Vector3d(-dist, 0, dist),
        new Vector3d(-dist, 0, -dist),
    };

    foreach (var cutDir in cutDirs) {
        var cut = new MeshPlaneCut(dMesh, cutDir, cutDir.Normalized);
        cut.Cut();
        cut.FillHoles();
    }

    mesh = dMesh.ToUnityMesh();

    var go = new GameObject("result");

    var mf = go.AddComponent<MeshFilter>();
    mf.sharedMesh = mesh;

    var renderer = go.AddComponent<MeshRenderer>();
    var material = new Material(Shader.Find("Standard"));
    material.color = Color.red;
    renderer.material = material;

The problem is that the holes are not filled and there the plane cutter reports that there are only CutSpans and no CutLoops.
Is this a bug or intended behaviour?

Thanks!

Oh, right here is the code for ToUnityMesh() and ToDMesh3():

public static DMesh3 ToDMesh3(this Mesh mesh) {
DMesh3 result = new DMesh3(bWantNormals: true, bWantUVs: true);

    var verts = mesh.vertices;
    var tris = mesh.triangles;
    var normals = mesh.normals;

    for (int i = 0; i < verts.Length; i++) {
        result.AppendVertex((Vector3d) verts[i]);
        result.SetVertexNormal(i, normals[i]);
    }

    for (int i = 0; i < tris.Length; i += 3) {
        result.AppendTriangle(tris[i], tris[i+1], tris[i+2]);
    }


    return result;
}

public static Mesh ToUnityMesh(this DMesh3 dm) {
    var result = new Mesh();

    List<Vector3> vertices = new List<Vector3>();
    List<int> triangles = new List<int>();
    List<Vector3> normals = new List<Vector3>();
    List<Vector2> uvs = new List<Vector2>();


    int[] mapV = new int[dm.MaxVertexID];

    int nAccumCountV = 0;
    // write vertices for this mesh
    foreach (int vertId in dm.VertexIndices()) {
        mapV[vertId] = nAccumCountV++;
        Vector3d vert = dm.GetVertex(vertId);
        vertices.Add((Vector3) vert);
        uvs.Add(dm.GetVertexUV(vertId));
        normals.Add(dm.GetVertexNormal(vertId));
    }

    foreach (var triIndex in dm.TriangleIndices()) {
        var tri = dm.GetTriangle(triIndex);
        triangles.Add(mapV[tri.a]);
        triangles.Add(mapV[tri.b]);
        triangles.Add(mapV[tri.c]);
    }

    result.vertices = vertices.ToArray();
    result.normals = normals.ToArray();
    result.triangles = triangles.ToArray();
    result.uv = uvs.ToArray();


    return result;
}

Is Surface Simplification Using Quadric Error Metrics not actually what it is?

I read original article and explored code in Reducer.cs, and found that while collecting initial "fundamental error quadric" you are multiply it by area of triangle

vertQuadrics[vid].Add(triAreas[tid], ref triQuadrics[tid]);

Why do you doing this? In paragraph 5 of original article error metric is calculated as

summ_p(K_p)

without any respect to the area of defining triangle, can you please explain this? Does this change the optimal point for contraction?

UV unwrapping of custom mesh

Hi!
I am using Unity and I would like to dynamic unwrap a mesh during the game. The problem is that UnityEditor namespace (that contains the only unwrap function) cannot be used in standalone version (.exe).
So I am searching an alternative way to do so.
Since this library works with mesh geometry I searched a function to UV unwrap custom mesh in an automatic way but I didn't found any. I was wondering if this feature is implemented or there is some future plan to do it.
Thanks anyway for the great work.

Way to Create a Bitmap3 from a Voxelized Mesh?

I was trying to follow the example you provided for Signed Distance Fields to create a BitMap3 of voxels corresponding to a mesh, but I'm not certain which method I could use. Can you suggest how I might do that? Would I be able to use a MeshSignedDistanceGrid?

Obtain a mesh from a texture

Hi,

First I explain my problem.
I have a .png binary image.
iminputblender

I would like to create a mesh out of it where x and y is defined by the image and the depth is costant. What I have achieved is creating a mesh where every pixel is a little cube of constant depth.
This lead to a very huge ammount of cube, so I tried to use the reducer to diminish the number of triangles/vertex. Unfortunately the result is not what I expected since some cube are removed leaving some blank space betweeen the cube.

So my question is: there is a better approach to this problem?
I found some extrude function that could help me but I don't know how to pass the .png point to it.
Do you have some suggestion?

Thanks for your time
Andrea

DMesh3 Extract Boundary Edges - In Unity3d

I am trying to integrate g3Sharp into Unity3d. I want to extract Boundary Edges of a Unity mesh. for now i am using Unity's cube primitive. I used the following method:

IEnumerable edges = startMesh.Edges ();
IEnumerator edgeEnum = edges.GetEnumerator ();
List boundaryEdgesList = new List();

List UniqueBoundaryEdgesList = new List ();

for (int i = 0; i < startMesh.EdgeCount; i++) {

// Debug.Log ("BEdge");
edgeEnum.MoveNext ();
if (startMesh.IsBoundaryEdge (i)) {

boundaryEdgesList.Add (startMesh.GetEdge (i));
// Debug.Log ("BEdge : " + i);
cnt++;
Debug.Log (edgeEnum.Current);
}
}
cnt = 0;

foreach (Index4i edg in boundaryEdgesList)
{

if (cnt == 0) {

UniqueBoundaryEdgesList.Add(edg);

}
else
{
bool matchd = false;
foreach(Index4i edgy in UniqueBoundaryEdgesList)
{
if (edgy.c == edg.c)
matchd = true;

}
if(!matchd)
UniqueBoundaryEdgesList.Add(edg);
}
cnt++;
}

//Debug.Log (edg);

line.positionCount = UniqueBoundaryEdgesList.Count;

cnt = 0;
foreach (Index4i edg1 in UniqueBoundaryEdgesList)
{

line.SetPosition (cnt, (Vector3)startMesh.GetVertex (edg1.a));
cnt++;
line.SetPosition (cnt, (Vector3)startMesh.GetVertex (edg1.b));
cnt++;
Debug.Log (edg1);
}

What i am trying is get the edge count first, then check for boundary edges, its a shared mesh, so repeated edges are coming, so i checked for the repeated edges and get the 12 edges only. But the result is with "Inner" edges also. I draw Lines using LineRenderer above the edges of the mesh. could you please give me a solution for this or correct me my mistake in this code.

Normalized Vector3d is not normalized

Hi, first of all wanted to say thanks for the library, it is very broad and useful. Really enjoying using it. I did notice one minor issue while using Unity that I thought I'd mention. After I normalized a Vector3d it still returned false when calling IsNormalized.

This is not a priority for me as I changed the check of IsNormalized to compare against MathUtil.ZeroTolerancef rather than MathUtil.ZeroTolerance and it is working fine for me although I haven't checked thoroughly if this fixes all cases.

Here are one set of values that reproduced the case,

Vector3d with x, y, z values,
-.90034962
.37379742
-.22281371

gives (x * x + y * y + z * z) of
.9999998987967649

and Math.Abs( (x * x + y * y + z * z) - 1) of
0.0000001012032351

which is greater than 1e-08.

Cheers,
Brian :)

Create one of several mesh

temp_write.zip
Hi, thanks for the library.
Everything works fine but on some complex objects I have to break objects into flat mesh making up complex geometry to further translate them into the format of your library, but after such manipulations the simplification does not work whether it is possible to make one of several meshes in
1 or perhaps there are nuances for flat mesh .

flatten.zip

How to calculate intersecting length

Is it possible to calculate length of intersecting line(ray) segment with a mesh volume.
(In picture, total traversing length [green in color] )
Thanks

torussegmentintersectionsml2

Cutting, stretching and boolean operation with 3d meshes

I am new in your library, but it very interesting me for my current unity3d project, so now I am trying evaluated ability to use geometry3Sharp. How can I implement cutting, stretching and boolean operation with 3d meshes using geometry3Sharp? For example, I want to subtract one shape from another, is this possible? Maybe do you have examples or you can advise me class or method name which helps me. Thanks.

Custom (simple) reducer?

I'm working on a plane mesh. 128-cell square rectangle, with cell also squares. I build the mesh procedurally, using DMesh3. Upon built, I want to reduce the triangle count, by merging adjacent cells with same height (Y axis). Looking at thr reducer, it doesn't seem operable on such simple case. Just want to confirm am I correct?

MeshDecomposition

DMesh3[] componentMeshes = MeshConnectedComponents.Separate(builder.Meshes[i]);

System error {{System.OutOfMemoryException}}

Some hints on implementing stamp tool similar to meshmixer

Hi Ryan,

I would like to create a tool, in the future, for fixing meshes produced from aerial image reconstruction, e.g. Autodesk 123D, Pix4d or Bentley ContextCapture.
A major issue is to create simple windows on the facades and I have found the stamp tool in meshmixer to be very helpful: Create a rectangle stamp on the window area -> offset a little outward for the windowsill -> extrude the windowsill.

The first thing is the stamp operation, I still have no idea on how to do it. It seems the edge of the stamp is spilt into several segments and of course the intersections between stamp and mesh edges are also considered.

Would you give me some hints on this? And again thanks for this awesome library.

Han

Vector2.Cross method

Hi
Is there a typo in the Vector2d and Vector2f Cross method?
They return (y * v2.y - y * v2.x). I would expect them to return (x * v2.y - y * v2.x)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.