2016-07-12 16 views
0

AutoCad APIによってベクトル{X:、Y:、Z:}の配列形式で生成された200個以上の頂点がある場合、 .jsは運がない。Three.js(面)のメッシュ3D頂点のレンダリング

今のところ私は200番のすべての可能な順列を作り、すべての頂点を一緒に接続しています - これは200k以上の面を与えるようにこれが行われているとは思いません。

EDIT:マイAutoCADのコードは、すべての頂点を得ているし、それはそれは頂点IDS(vertex1とvertex2)を接続して取得しようとします。 GetHashCode()は動作しません。問題は、148335760や682610240のような巨大なID番号を返すということではありません。問題は、これらのIDが一意ではなく、定義されていて、他の頂点に接続されていないということです。

AutoCADのコード:

//data structures for serialisation 
public class EdgeMe 
{ 
    public int vertex1; 
    public int vertex2; 
} 
public class VertexMe 
{ 
    public int id; 
    public Point3d Point; 
    public List<EdgeMe> Edges = new List<EdgeMe>(); 
} 

public class DataMe{ 
    public Extents3d extents; 
    public string layer; 
    public List<VertexMe> points = new List<VertexMe>(); 
} 


//... 


// Get each Solid3d in modelspace and add its extents 
// to the list 
foreach (var id in ms) 
{ 
    var obj = tr.GetObject(id, OpenMode.ForRead); 
    var sol = obj as Solid3d; 

    DataMe dataMe = new DataMe(); 
    if (sol != null) 
    { 
     dataMe.extents = sol.GeometricExtents; 
     dataMe.layer = sol.Layer; 
     using (var brep = new Autodesk.AutoCAD.BoundaryRepresentation.Brep(sol)) 
     { 
      foreach (var vertex in brep.Vertices) 
      { 
       VertexMe vertexMe = new VertexMe(); 
       vertexMe.Point = vertex.Point; 
       vertexMe.id = vertex.Brep.GetHashCode(); 
       foreach(var edge in vertex.Edges) 
       { 
        EdgeMe edgeMe = new EdgeMe(); 
        edgeMe.vertex1 = edge.Vertex1.Brep.GetHashCode(); 
        edgeMe.vertex2 = edge.Vertex2.Brep.GetHashCode(); 
        vertexMe.Edges.Add(edgeMe); 
       } 

       dataMe.points.Add(vertexMe); 
      } 
     } 
    } 
    sols.Add(dataMe); 
} 

Javascriptコード:

var faces = function(vertices) { 
    var results = []; 

    var vertex = [0, 1, 2]; 
    results.push(vertex.slice()); 

    while(true) { 
     vertex[2]++; 
     if(vertex[2] > vertices) { 

      vertex[1]++; 
      if(vertex[1] >= vertices) { 
       vertex[0]++; 
       vertex[1] = vertex[0] + 1; 

       if(vertex[0] > vertices - 2) 
        return results; 
      } 

      vertex[2] = vertex[1] + 1; 
     } 

     results.push(vertex.slice()); 
    } 

}; 

var generate = function(...) { 
    // Process each box, adding it to the scene 
    for (var sol in sols) { 
     var s = sols[sol]; 
     var vertices = []; 

     for(var vertix in s.points) {// deserialize 
      vertix = s.points[vertix]; 

      vertices.push(new THREE.Vector3(vertix.X, vertix.Y, vertix.Z)); 
     } 

     var holes = []; 
     var triangles, mesh; 
     var geometry = new THREE.Geometry(); 
     geometry.vertices = vertices; 
     var xfaces = faces(vertices.length); 

     for(var i = 0; i < xfaces.length; i++) { 
      geometry.faces.push(new THREE.Face3(xfaces[i][0], xfaces[i][1], xfaces[i][2])); 
     } 
     geometry.computeFaceNormals(); 
     geometry.computeVertexNormals(); 

     mesh = new THREE.Mesh(geometry, customimg); 

     mesh.rotation.set(Math.PI/2, 0, 0); 

     root.add(mesh); 
    } 
} 

よろしく、

ヨアン

+0

@gaitatあなたは正しいです。それを答えにするためにそれをポストにしてください。 – ioanb7

+0

AutoCADコードを表示すると、おそらく私はあなたを助けることができるでしょう –

+0

こんにちは@DmitriyZapevalov、それを今見てみましょう。 – ioanb7

答えて

0

あなたのやりたいことはできません。接続情報を推測しようとしています。それは仕事を推測するべきではありません。アプリケーションは接続情報をあなたに返す必要があります。

0

代わりに私はあなたがあなたのファイルから閲覧を抽出するためにForge Model Derivative APIを使用することをお勧めします。ファイルを変換したら、Viewer(Three.jsに基づいていますが、エンジニアリングファイル用に最適化されています)を使用してファイルを表示できます。 this Githubにいくつかの例があります。

関連する問題