2016-07-12 6 views
0

벡터 {X :, Y :, Z :}의 배열 형태로 AutoCad API에 의해 생성 된 정점이 200 개 이상인 점을 감안할 때, 운이없는 .js.Three.js (면)의 렌더링 메쉬 3D 정점

지금은 번호 200에 대한 모든 가능한 순열을 만들고 모든 정점을 연결하는 중입니다. 200k 개 이상의면을 부여하는 방식으로 이것이 이루어지지 않는다고 생각합니다.

편집 : 내 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); 
} 

자바 스크립트 코드 :

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에서 몇 가지 예를 찾을 수 있습니다.