MCPcopy Index your code
hub / github.com/OpenMeshLab/MeshXL / write_bbox

Function write_bbox

utils/ply_helper.py:116–176  ·  view source on GitHub ↗

bbox: (cx, cy, cz, lx, ly, lz, r), center and length in three axis, the last is the rotation output_file: string

(corners, color, output_file)

Source from the content-addressed store, hash-verified

114 return verts, indices
115
116def write_bbox(corners, color, output_file):
117 """
118 bbox: (cx, cy, cz, lx, ly, lz, r), center and length in three axis, the last is the rotation
119 output_file: string
120 """
121
122 def get_bbox_edges(bbox_min, bbox_max):
123 def get_bbox_verts(bbox_min, bbox_max):
124 verts = [
125 np.array([bbox_min[0], bbox_min[1], bbox_min[2]]),
126 np.array([bbox_max[0], bbox_min[1], bbox_min[2]]),
127 np.array([bbox_max[0], bbox_max[1], bbox_min[2]]),
128 np.array([bbox_min[0], bbox_max[1], bbox_min[2]]),
129
130 np.array([bbox_min[0], bbox_min[1], bbox_max[2]]),
131 np.array([bbox_max[0], bbox_min[1], bbox_max[2]]),
132 np.array([bbox_max[0], bbox_max[1], bbox_max[2]]),
133 np.array([bbox_min[0], bbox_max[1], bbox_max[2]])
134 ]
135 return verts
136
137 box_verts = get_bbox_verts(bbox_min, bbox_max)
138 edges = [
139 (box_verts[0], box_verts[1]),
140 (box_verts[1], box_verts[2]),
141 (box_verts[2], box_verts[3]),
142 (box_verts[3], box_verts[0]),
143
144 (box_verts[4], box_verts[5]),
145 (box_verts[5], box_verts[6]),
146 (box_verts[6], box_verts[7]),
147 (box_verts[7], box_verts[4]),
148
149 (box_verts[0], box_verts[4]),
150 (box_verts[1], box_verts[5]),
151 (box_verts[2], box_verts[6]),
152 (box_verts[3], box_verts[7])
153 ]
154 return edges
155
156 radius = 0.03
157 offset = [0,0,0]
158 verts = []
159 indices = []
160 colors = []
161
162 box_min = np.min(corners, axis=0)
163 box_max = np.max(corners, axis=0)
164 edges = get_bbox_edges(box_min, box_max)
165 for k in range(len(edges)):
166 cyl_verts, cyl_ind = create_cylinder_mesh(radius, edges[k][0], edges[k][1])
167 cur_num_verts = len(verts)
168 cyl_color = [[c / 255 for c in color] for _ in cyl_verts]
169 cyl_verts = [x + offset for x in cyl_verts]
170 cyl_ind = [x + cur_num_verts for x in cyl_ind]
171 verts.extend(cyl_verts)
172 indices.extend(cyl_ind)
173 colors.extend(cyl_color)

Callers

nothing calls this directly

Calls 4

get_bbox_edgesFunction · 0.85
create_cylinder_meshFunction · 0.85
write_plyFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected