Skip to content

Commit b2c4e1c

Browse files
Removed prefs.
1 parent 85e0ee9 commit b2c4e1c

File tree

5 files changed

+9
-170
lines changed

5 files changed

+9
-170
lines changed

__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@
3838

3939
import bpy
4040
from collections import OrderedDict
41-
from .preferences import AntonInstaller, AntonPreferences
4241
from .panel import Anton_PT_Panel
4342
from .properties import AntonPropertyGroup, ForcePropertyGroup
4443
from .initializer import Anton_OT_ForceUpdater, Anton_OT_Initializer
4544
from .definer import Anton_OT_DirectionUpdater, Anton_OT_Definer
4645
from .processor import Anton_OT_Processor
4746
from .visualizer import Anton_OT_Visualizer
4847

49-
classes = [AntonPreferences, AntonInstaller, Anton_PT_Panel, Anton_OT_Processor,
50-
AntonPropertyGroup, ForcePropertyGroup, Anton_OT_ForceUpdater, Anton_OT_Visualizer,
48+
classes = [Anton_PT_Panel, Anton_OT_Processor, AntonPropertyGroup,
49+
ForcePropertyGroup, Anton_OT_ForceUpdater, Anton_OT_Visualizer,
5150
Anton_OT_Initializer, Anton_OT_DirectionUpdater, Anton_OT_Definer]
5251

5352
def register():

initializer.py

Lines changed: 7 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ class Anton_OT_Initializer(bpy.types.Operator):
7575
bl_description = 'Initializes design space'
7676

7777
def execute(self, context):
78-
"""Design space can be defined either via ``SHAPE`` or ``HULL`` mode. In case of ``SHAPE``, existing geometry
79-
is used for design space definition whereas ``HULL`` mode defines a design space with the existing objects as obstacles and
80-
a scaled convexhull as design space boundary.
78+
"""Design space is defined with existing geometry.
8179
8280
:ivar objects: List of all the obstacle objects
8381
:vartype objects: ``list``
@@ -93,109 +91,18 @@ def execute(self, context):
9391
bpy.context.space_data.shading.type = 'MATERIAL'
9492

9593
if not scene.anton.defined:
96-
if scene.anton.mode == 'HULL':
94+
scene.anton.filename = active_object.name
9795

98-
from scipy.spatial import ConvexHull
99-
objects = list()
100-
points = list()
96+
bpy.ops.export_mesh.stl(filepath=os.path.join(scene.anton.workspace_path, scene.anton.filename + '.stl'), ascii=True)
97+
active_object.select_set(True)
98+
bpy.ops.object.delete()
10199

102-
bound_scale = 1.25
103-
104-
for _obj in bpy.data.objects:
105-
dim = np.array([_obj.dimensions[0], _obj.dimensions[1], _obj.dimensions[2]])
106-
if np.linalg.norm(dim) > 0:
107-
if _obj.name_full != active_object.name_full:
108-
objects.append(_obj)
109-
110-
theta = _obj.rotation_euler[0]
111-
alpha = _obj.rotation_euler[1]
112-
beta = _obj.rotation_euler[2]
113-
114-
rot_x = np.array([[1, 0, 0], [0, np.cos(theta), -1*np.sin(theta)], [0, np.sin(theta), np.cos(theta)]])
115-
rot_y = np.array([[np.cos(alpha), 0, np.sin(alpha)], [0, 1, 0], [-1*np.sin(alpha), 0, np.cos(alpha)]])
116-
rot_z = np.array([[np.cos(beta), -1*np.sin(beta), 0], [np.sin(beta), np.cos(beta), 0], [0, 0, 1]])
117-
118-
_rotational_matrix = np.matmul(np.matmul(rot_x, rot_y), rot_z)
119-
120-
for _vert in _obj.bound_box:
121-
_scaled_bound = bound_scale * np.array([_obj.scale[0] * _vert[0], _obj.scale[1] * _vert[1], _obj.scale[2] * _vert[2]])
122-
temp = _scaled_bound + np.array([_obj.location[0], _obj.location[1], _obj.location[2]])
123-
_rotated_bound = np.matmul(_rotational_matrix, temp.T).T
124-
points.append(_rotated_bound)
125-
126-
hull = ConvexHull(points)
127-
points = np.array(points)
128-
129-
with open(os.path.join(scene.anton.workspace_path, 'hull.stl'), 'w') as f:
130-
f.write('GENERATED BY ANTON\n')
131-
for _face in hull.simplices:
132-
_a = points[_face][1] - points[_face][0]
133-
_b = points[_face][2] - points[_face][0]
134-
_cross_product = np.cross(_a, _b)
135-
_normal = 1.0/np.linalg.norm(_cross_product) * _cross_product
136-
137-
f.write('facet normal {} {} {}\n'.format(
138-
_normal[0],
139-
_normal[1],
140-
_normal[2]))
141-
f.write('outer loop\n')
142-
for i in range(3):
143-
f.write('vertex {} {} {}\n'.format(
144-
points[_face][i][0],
145-
points[_face][i][1],
146-
points[_face][i][2]))
147-
148-
f.write('endloop\n')
149-
f.write('endfacet\n')
150-
151-
f.write('endsolid\n')
152-
153-
active_object.select_set(True)
154-
155-
for _obj in objects:
156-
bpy.ops.object.modifier_add(type='BOOLEAN')
157-
bpy.context.object.modifiers["Boolean"].operation = 'UNION'
158-
bpy.context.object.modifiers["Boolean"].object = _obj
159-
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
160-
161-
bpy.ops.object.select_all(action='DESELECT')
162-
_obj.select_set(True)
163-
bpy.ops.object.delete()
164-
165-
active_object.select_set(True)
166-
167-
scene.anton.filename = active_object.name
168-
169-
bpy.ops.import_mesh.stl(filepath=os.path.join(scene.anton.workspace_path, 'hull.stl'))
170-
bpy.ops.object.modifier_add(type='BOOLEAN')
171-
bpy.context.object.modifiers["Boolean"].operation = 'DIFFERENCE'
172-
bpy.context.object.modifiers["Boolean"].object = active_object
173-
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Boolean")
174-
175-
bpy.ops.object.select_all(action='DESELECT')
176-
active_object.select_set(True)
177-
bpy.ops.object.delete()
178-
179-
bpy.ops.export_mesh.stl(filepath=os.path.join(scene.anton.workspace_path, scene.anton.filename + '.stl'), ascii=True)
180-
active_object = bpy.context.active_object
181-
active_object.select_set(True)
182-
bpy.ops.object.delete()
183-
184-
bpy.ops.import_mesh.stl(filepath=os.path.join(scene.anton.workspace_path, scene.anton.filename + '.stl'))
185-
186-
else:
187-
scene.anton.filename = active_object.name
188-
189-
bpy.ops.export_mesh.stl(filepath=os.path.join(scene.anton.workspace_path, scene.anton.filename + '.stl'), ascii=True)
190-
active_object.select_set(True)
191-
bpy.ops.object.delete()
192-
193-
bpy.ops.import_mesh.stl(filepath=os.path.join(scene.anton.workspace_path, scene.anton.filename + '.stl'))
100+
bpy.ops.import_mesh.stl(filepath=os.path.join(scene.anton.workspace_path, scene.anton.filename + '.stl'))
194101

195102
active_object = bpy.context.active_object
196103

197104
scene.anton.initialized = True
198-
self.report({'INFO'}, 'Mode: {}'.format(scene.anton.mode))
105+
self.report({'INFO'}, 'Initialized design space.')
199106
return {'FINISHED'}
200107
else:
201108
self.report({'ERROR'}, 'Design space has already been initialized. In order to re-initialize, kindly restart the process.')

panel.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ def draw(self, context):
1515
rowsub = layout.row(align=True)
1616
rowsub.prop(scene.anton, 'workspace_path')
1717

18-
row = layout.row(align=True)
19-
row.prop(scene.anton, "mode", icon='NONE', expand=True,
20-
slider=True, toggle=False, icon_only=False, event=False,
21-
full_event=False, emboss=True)
22-
2318
col = layout.column()
2419
col.operator('anton.initialize', text='Initialize')
2520

preferences.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

properties.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ class AntonPropertyGroup(bpy.types.PropertyGroup):
3232
:vartype filename: ``str``
3333
:ivar workspace_path: Path to workspace folder (``/tmp/``)
3434
:vartype workspace_path: ``str``
35-
:ivar mode: Design space defintion mode (``SHAPE``)
36-
:vartype mode: ``enum``
3735
:ivar number_of_forces: Number of forces acting on the object (``1``)
3836
:vartype number_of_forces: ``int``
3937
@@ -95,14 +93,6 @@ class AntonPropertyGroup(bpy.types.PropertyGroup):
9593
default='/tmp/',
9694
subtype='DIR_PATH')
9795

98-
mode : EnumProperty(
99-
name='mode',
100-
items=[
101-
('SHAPE', 'Shape', 'Use existing geometry'),
102-
('HULL', 'Hull', 'Form a convexhull')],
103-
default='SHAPE'
104-
)
105-
10696
number_of_forces : IntProperty(
10797
name="Forces",
10898
default=1,

0 commit comments

Comments
 (0)