Skip to content
Snippets Groups Projects
Commit ec333e3a authored by Chang Liu's avatar Chang Liu
Browse files

geo info extraction done

parent 04406606
No related merge requests found
Showing with 38 additions and 28 deletions
......@@ -18,13 +18,15 @@ from rocolib.library import getComponent
# =============================================================================
# c = getComponent("Paperbot_Tail", length=85, width=65, height=30)
# c = getComponent("Paperbot_Tail", length=85, width=65)
# c.makeOutput("output/Paperbot_Tail", tree=True, display=False)
# =============================================================================
d = getComponent("Paperbot_Wheel_Left", length=85, width=65, height=30)
d.makeOutput("output/Paperbot_Wheel_Left", tree=True, display=False)
# =============================================================================
# d = getComponent("Paperbot_Wheel_Left", length=85, width=65, height=30)
# d.makeOutput("output/Paperbot_Wheel_Left", tree=True, display=False)
# =============================================================================
# =============================================================================
......@@ -39,8 +41,6 @@ d.makeOutput("output/Paperbot_Wheel_Left", tree=True, display=False)
# =============================================================================
# =============================================================================
# e = getComponent("Paperbot_BodyAndTail", length=85, width=65, height=30)
# e.makeOutput("output/Paperbot_Body_And_Tail", tree=True, display=False)
# =============================================================================
e = getComponent("Paperbot_BodyAndTail", length=85, width=65, height=30)
e.makeOutput("output/Paperbot_Body_And_Tail", tree=True, display=False)
......@@ -233,9 +233,13 @@ class GraphComposable(Composable, BaseGraph):
handle("Coordinate", "3D", self.toTXT_Coord, "model_Coord.txt", **kwargs)
handle("Facet_Normal", "3D", self.toTXT_Facet_Normal, "model_Facet_Normal.txt", **kwargs)
# =============================================================================
# handle("Facet_Normal", "3D", self.toTXT_Facet_Normal, "model_Facet_Normal.txt", **kwargs)
# =============================================================================
handle("Coordinate_Index", "3D", self.toTXT_CoordIndex, "model_CoordIndex.txt", **kwargs)
# =============================================================================
# handle("Coordinate_Index", "3D", self.toTXT_CoordIndex, "model_CoordIndex.txt", **kwargs)
# =============================================================================
return rets
......
No preview for this file type
......@@ -27,9 +27,7 @@ def STLWrite(faces, fp, **kwargs):
scale = .001 # roco units : mm ; STL units m
from .stlwriter import ASCII_STL_Writer as STL_Writer
# =============================================================================
# from .stlwriter import Binary_STL_Writer as STL_Writer
# =============================================================================
import triangle
shells = []
......@@ -152,8 +150,12 @@ def TXTWrite_Coord(faces, fp, **kwargs):
facets.extend([np.dot(np.transpose(r), x) * scale for x in inflate(t, thickness=thickness, edges=True)])
else:
for t in [np.array(list(B['vertices'][x]) + [0,1] ) for x in range(0, len(B['vertices']))]:
facets.append(np.dot(np.transpose(r), t) * scale)
facets.append(np.transpose(np.dot(r, t)) * scale)
# =============================================================================
# print(facets)
# =============================================================================
triangles.extend(facets)
faces = triangles
......@@ -193,11 +195,7 @@ def TXTWrite_Facet_Normal(faces, fp, **kwargs):
facets.extend([np.dot(r, x) * scale for x in inflate(t, thickness=thickness, edges=True)])
else:
for t in [np.array(list(B['vertices'][x]) + [0,1] ) for x in range(0, len(B['vertices']))]:
facets.append(np.dot(np.transpose(r), t) * scale)
# =============================================================================
# for t in [np.transpose(np.array([list(B['vertices'][x]) + [0,1] for x in (face[0], face[1], face[2])])) for face in B['triangles']]:
# facets.append(np.dot(r, t) * scale)
# =============================================================================
facets.append(np.transpose(np.dot(r, t)) * scale)
triangles.extend(facets)
......@@ -215,16 +213,23 @@ def TXTWrite_CoordIndex(faces, fp, **kwargs):
import numpy as np
facets_index = np.empty([1, 3])
B_add = 0
for i, f in enumerate(faces):
r = f[0] # transformation matrix
A = f[1] # getTriangleDict
B = triangle.triangulate(A, opts='p')
facets_index = np.concatenate((facets_index, B['triangles']), 0)
B_triangle = B['triangles'] + B_add
B_add = np.amax(B_triangle) + 1
facets_index = np.concatenate((facets_index, B_triangle), 0)
facets_index = np.delete(facets_index, 0, 0)
writer = TXT_Writer_CoordIndex(fp)
writer.add_indexes(facets_index)
# CJL <<<<<--------------------------------------------------------------------------------------------------------------------
......
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -11,12 +11,12 @@ Created on Thu May 13 08:08:00 2021
import struct
# =============================================================================
# Coord_FACET = """{face[0][0]:.4f} {face[0][1]:.4f} {face[0][2]:.4f}, {face[1][0]:.4f} {face[1][1]:.4f} {face[1][2]:.4f}, {face[2][0]:.4f} {face[2][1]:.4f} {face[2][2]:.4f}, """
# =============================================================================
Coord_FACET = """{face[0]:.4f} {face[1]:.4f} {face[2]:.4f}, """
# =============================================================================
# Coord_FACET = """{face[0]:.4f} {face[1]:.4f} {face[2]:.4f}
# """
# =============================================================================
......
......@@ -11,12 +11,13 @@ import struct
import numpy as np
Coord_FACET_Index = """{face_pt_num[0]}, {face_pt_num[1]}, {face_pt_num[2]}, -1, """
# =============================================================================
# Coord_FACET_Index = """{face_pt_num[0]}, {face_pt_num[1]}, {face_pt_num[2]}, -1, """
# Coord_FACET_Index = """{face_pt_num[0]} {face_pt_num[1]} {face_pt_num[2]}
# """
# =============================================================================
Coord_FACET_Index = """{face_pt_num[0]}, {face_pt_num[1]}, {face_pt_num[2]}, -1, """
# CJL <<<<<--------------------------------------------------------------------------------------------------------------------
class CoordIndex_TXT_Writer:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment