Skip to content

Commit 19c827b

Browse files
Made necessary codacy changes.
1 parent 9889c7a commit 19c827b

7 files changed

+18
-29
lines changed

definer.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import bpy
33
import numpy as np
44
import os
5-
import subprocess
65

76
def get_grease_pencil(gpencil_obj_name='GPencil') -> bpy.types.GreasePencil:
87
if gpencil_obj_name not in bpy.context.scene.objects:

initializer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def execute(self, context):
2727
2828
\\
2929
"""
30-
scene = context.scene
30+
scene = context.scene
3131
bpy.ops.anton.initialize()
3232
active_object = bpy.context.active_object
3333

@@ -76,7 +76,7 @@ class Anton_OT_Initializer(bpy.types.Operator):
7676
bl_description = 'Initializes design space'
7777

7878
def execute(self, context):
79-
"""Design space is defined with existing geometry.
79+
"""Design space is defined with existing geometry.
8080
8181
:ivar objects: List of all the obstacle objects
8282
:vartype objects: ``list``
@@ -100,7 +100,7 @@ def execute(self, context):
100100

101101
bpy.ops.object.modifier_add(type='TRIANGULATE')
102102
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Triangulate")
103-
bpy.ops.export_scene.obj(filepath=os.path.join(scene.anton.workspace_path, scene.anton.filename, scene.anton.filename + '.obj'),
103+
bpy.ops.export_scene.obj(filepath=os.path.join(scene.anton.workspace_path, scene.anton.filename, scene.anton.filename + '.obj'),
104104
check_existing=True,
105105
axis_forward='Y',
106106
axis_up='Z',

optimizer.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import shutil
66
from taichi.dynamics import Simulation
77

8-
import taichi.core as tc_core
98
import taichi as tc
109
import argparse
1110
from taichi.misc.util import get_unique_task_id
@@ -45,15 +44,15 @@ def __init__(self, **kwargs):
4544

4645
if args.c is not None:
4746
suffix += '_continue'
48-
47+
4948
self.task_id = get_unique_task_id()
5049
self.suffix = suffix + kwargs.get('suffix', '')
5150

5251
self.filename = kwargs.get('filename', 'anton')
5352

5453
self.working_directory = os.path.join(kwargs.get('working_directory', tc.get_output_directory()), self.filename, 'output', self.task_id + '_' + self.suffix)
5554
kwargs['working_directory'] = self.working_directory
56-
55+
5756
self.snapshot_directory = os.path.join(self.working_directory, 'snapshots')
5857
self.fem_directory = os.path.join(self.working_directory, 'fem')
5958
self.fem_obj_directory = os.path.join(self.working_directory, 'fem_obj')
@@ -62,16 +61,13 @@ def __init__(self, **kwargs):
6261
os.makedirs(self.fem_directory, exist_ok=True)
6362
os.makedirs(self.fem_obj_directory, exist_ok=True)
6463
self.max_iterations = kwargs.get('max_iterations', 20)
65-
64+
6665
self.log_fn = os.path.join(self.working_directory, 'log.txt')
6766
tc.start_memory_monitoring(os.path.join(self.working_directory, 'memory_usage.txt'), interval=0.1)
6867
tc.duplicate_stdout_to_file(self.log_fn)
6968
tc.redirect_print_to_log()
7069
tc.trace("log_fn = {}", self.log_fn)
7170

72-
with open(script_fn) as f:
73-
script_content = f.read()
74-
7571
shutil.copy(sys.argv[0], self.working_directory + "/")
7672
print(args)
7773
super().__init__(name='spgrid_topo_opt', **kwargs)
@@ -192,7 +188,7 @@ def get_block_counts(self):
192188
if __name__ == "__main__":
193189

194190
version = 1
195-
191+
196192
workspace_path = sys.argv[1]
197193
filename = sys.argv[2]
198194
max_iter = int(sys.argv[3])
@@ -276,7 +272,7 @@ def get_block_counts(self):
276272
nu=poisson,
277273
max_iterations=max_iter,
278274
wireframe_grid_size=wgridsize,
279-
wireframe_thickness=wthickness,
275+
wireframe_thickness=wthickness,
280276
grid_update_start=5 if narrow_band else 1000000,
281277
fix_cells_near_force=is_forced,
282278
fix_cells_at_dirichlet=is_fixed,

panel.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import bpy
2-
from bpy.props import BoolProperty
32

43
class Anton_PT_Panel(bpy.types.Panel):
54
bl_idname = 'ANTON_PT_panel'
@@ -45,7 +44,6 @@ def draw(self, context):
4544
full_event=False, emboss=True)
4645

4746
if scene.anton.mode == 'WIREFRAME':
48-
row = layout.row(align=True)
4947
row.prop(scene.anton, "wireframe_thickness")
5048
row.prop(scene.anton, "wireframe_gridsize")
5149

@@ -87,7 +85,7 @@ def draw(self, context):
8785
rowsub.prop(scene.anton, "smoothing_iters")
8886
rowsub = layout.row(align=True)
8987
rowsub.prop(scene.anton, "minimum_density")
90-
rowsub.prop(scene.anton, "minimum_stiffness")
88+
rowsub.prop(scene.anton, "minimum_stiffness")
9189
rowsub = layout.row(align=True)
9290
rowsub.alignment = 'CENTER'
9391
rowsub.prop(scene.anton, "exclude_fixed_cells")

processor.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import bpy
22
import os
33
import subprocess
4-
import numpy as np
54

65
class Anton_OT_Processor(bpy.types.Operator):
76
bl_idname = 'anton.process'

properties.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class AntonPropertyGroup(bpy.types.PropertyGroup):
209209
default=0.0,
210210
min=0.0,
211211
max=1.0,
212-
description="Minimum allowable density")
212+
description="Minimum allowable density")
213213

214214
minimum_stiffness : FloatProperty(
215215
name="",
@@ -265,7 +265,7 @@ class AntonPropertyGroup(bpy.types.PropertyGroup):
265265
default=0.5,
266266
min=0.0,
267267
max=1.0,
268-
description="Objective threshold")
268+
description="Objective threshold")
269269

270270
step_limit : FloatProperty(
271271
name="",

visualizer.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def execute(self, context):
3131
density_file = os.path.join(scene.anton.workspace_path, scene.anton.filename, '{:05d}.densities.txt'.format(scene.anton.viz_iteration - 1))
3232
stl_file = os.path.join(scene.anton.workspace_path, scene.anton.filename, '{}_{:05d}.stl'.format(scene.anton.filename, scene.anton.viz_iteration))
3333

34-
os.system("ti run convert_fem_solve {} {}".format(viz_file, density_file))
34+
os.system("ti run convert_fem_solve {} {}".format(viz_file, density_file))
3535

3636
if os.path.isfile(density_file):
3737
self.marchthecubes(inp_path=density_file, output_path=stl_file, resolution=scene.anton.res, density_thresh=scene.anton.density_out)
@@ -64,7 +64,7 @@ def marchthecubes(inp_path, output_path, resolution=100, density_thresh=0.1):
6464
with open(inp_path, 'r') as f:
6565
base_coord = np.array([0, 0, 0], dtype=np.int)
6666
line = f.readline()
67-
67+
6868
while(line):
6969
section_match = section_pattern.search(line)
7070
coord_match = coord_pattern.search(line)
@@ -76,28 +76,25 @@ def marchthecubes(inp_path, output_path, resolution=100, density_thresh=0.1):
7676
if float(coord_match.group('DENSITY')) >= density_thresh:
7777
verts.append(_coord)
7878
densities.append(float(coord_match.group('DENSITY')))
79-
79+
8080
line = f.readline()
8181

8282
pts = np.array(verts, dtype=np.int)
8383
lower_bound = np.floor(np.min(pts, axis=0)) - 2
8484
upper_bound = np.ceil(np.max(pts, axis=0)) + 2
8585

86-
grid, _, _ = np.mgrid[lower_bound[0]:upper_bound[0]:1,
87-
lower_bound[1]:upper_bound[1]:1,
86+
grid, _, _ = np.mgrid[lower_bound[0]:upper_bound[0]:1,
87+
lower_bound[1]:upper_bound[1]:1,
8888
lower_bound[2]:upper_bound[2]:1]
8989

9090
data_indices = np.array(np.ceil((pts - lower_bound)/1), dtype=np.int)
9191
data = 0.0 * grid
9292
# mask??
9393

94-
for i, _index in enumerate(data_indices):
94+
for _index in enumerate(data_indices):
9595
try:
9696
data[_index[0]][_index[1]][_index[2]] = 1
97-
except:
98-
print(_index)
99-
print(np.shape(data))
100-
97+
10198
vertices, faces, normals, _ = measure.marching_cubes(data)
10299
vertices = vertices + lower_bound + 0.5
103100
vertices = 10 * vertices/resolution - 5

0 commit comments

Comments
 (0)