Skip to content

Commit

Permalink
Added final structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
senthurayyappan committed Aug 28, 2020
1 parent 79854e4 commit 7b54bfc
Show file tree
Hide file tree
Showing 30 changed files with 662 additions and 1,173 deletions.
78 changes: 71 additions & 7 deletions definer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,20 @@ def draw_arrow(gp_frame, p: tuple, norm: tuple, d: tuple, size: int, reverse: bo
return gp_stroke

class Anton_OT_DirectionUpdater(bpy.types.Operator):
"""Visualizes direction vector of applied force with grease pencil
"""
bl_idname = "anton.directionupdate"
bl_label = ""

force_id : bpy.props.StringProperty()
direction_reverse = OrderedDict()

def execute(self, context):
"""Instantiates an arrow at the centroid of a face on which force is applied. The instantiated arrow is
a grease pencil object whose color corresponds to the applied force.
:return: ``FINISHED`` if successful, ``CANCELLED`` otherwise
"""
scene = context.scene
active_object = bpy.data.objects[scene.anton.filename]
direction = np.array([0.0, 0.0, 0.0])
Expand Down Expand Up @@ -170,11 +177,33 @@ def execute(self, context):
return{'CANCELLED'}

class Anton_OT_Definer(bpy.types.Operator):
"""An operator class that creates a tetrahedral finite element mesh of the model with **gmsh_api**,
interprets the forces acting on the model and stores the required variables as a numpy binary file (.npy).
"""
bl_idname = 'anton.define'
bl_label = 'Anton_Definer'
bl_description = 'Defines the problem.'

def execute(self, context):
"""Iterates through all the faces of the model and creates sets of face indices.
:ivar nodes:
:vartype nodes: numpy.array
:ivar elements:
:vartype elements: numpy.array
:ivar fixed_nodes:
:vartype fixed_nodes: numpy.array
:ivar no_design_nodes:
:vartype no_design_nodes: numpy.array
:ivar forced_nodes:
:vartype forced_nodes: numpy.array
:ivar directions:
:vartype directions: OrderedDict
:ivar distributed_force:
:vartype distributed_force: OrderedDict
:return: ``FINISHED`` if successful, ``CANCELLED`` otherwise
"""
scene = context.scene
active_object = bpy.data.objects[scene.anton.filename]

Expand All @@ -187,7 +216,7 @@ def execute(self, context):
bpy.ops.object.mode_set(mode='OBJECT')
for face in active_object.data.polygons:
if 'FIXED' in active_object.data.materials[face.material_index].name_full:
# ADDING 1 COZ OF GMSH INDEX
# Adding 1 because of gmsh_api convention
fixed_faces.add(face.index + 1)

elif 'NODESIGNSPACE' in active_object.data.materials[face.material_index].name_full:
Expand Down Expand Up @@ -235,7 +264,6 @@ def execute(self, context):
geo_points = OrderedDict()
geo_edges = OrderedDict()

# GET POINTS FROM DATA
i = 1
for _surface in data:
for _vertex in _surface:
Expand All @@ -244,11 +272,9 @@ def execute(self, context):
geo_points[i] = _vertex
i += 1

# GET TRIANGLES FROM DATA
for i, _data in enumerate(data):
triangles[i+1] = [points[_data[0]], points[_data[1]], points[_data[2]]]

# GET EDGES FROM TRIANGLES
i = 1
for _triangle in triangles.values():
for _edge in self.get_edge_indices(_triangle):
Expand All @@ -257,7 +283,6 @@ def execute(self, context):
geo_edges[i] = _edge
i += 1

# GET CURVE_LOOP FROM TRIANGLES
for _triangle_id in triangles.keys():
curve_loop[_triangle_id] = []
for connection in self.get_curve_loop(triangles[_triangle_id]):
Expand Down Expand Up @@ -349,6 +374,45 @@ def create_geo(self,
curve_loop,
clmax):

"""Creates a tetrahedral finite element mesh of the model
:param path:
:type path: str
:param filename:
:type filename: str
:param fixed_faces:
:type fixed_faces: set
:param no_design_faces:
:type no_design_faces: set
:param forced_faces:
:type forced_faces: OrderedDict
:param forced_magnitudes:
:type forced_magnitudes: OrderedDict
:param forced_directions:
:type forced_directions: OrderedDict
:param forced_direction_signs:
:type forced_direction_signs: OrderedDict
:param points:
:type points: OrderedDict
:param edges:
:type edges: OrderedDict
:param curve_loop:
:type curve_loop: OrderedDict
:param geo_points:
:type geo_points: OrderedDict
:param geo_edges:
:type geo_edges: OrderedDict
:param clmax:
:type clmax: float
:return: nodes, elements, fixed_nodes, no_design_nodes, forced_nodes, directions, distributed_force
"""

geo = gmsh.model.geo
lc = clmax

Expand Down Expand Up @@ -466,7 +530,7 @@ def get_raw_data(path):
data.append([])
else:
if 'vertex' in line:
# IGNORING NORMALS FOR NOW
# Ignoring normals
data[-1].append(tuple(map(float, line[:-1].split(' ')[1:])))

line = f.readline()
Expand All @@ -480,7 +544,7 @@ def compute_direction(points):
return vec/vec_mag

@staticmethod
def compute_area(points):
def compute_area(points):
v1 = points[1] - points[0]
v2 = points[2] - points[0]
v3 = np.cross(v1, v2)
Expand Down
Binary file removed docs/_build/doctrees/anton.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file not shown.
Binary file added docs/_build/doctrees/scripts.doctree
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/_build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ anton is a generative design framework built on Blender, the open-source 3D crea

introduction
installation
interface
anton
quickstart
scripts
release
license

Expand Down
2 changes: 0 additions & 2 deletions docs/_build/html/_sources/interface.rst.txt

This file was deleted.

2 changes: 2 additions & 0 deletions docs/_build/html/_sources/quickstart.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Quickstart
==========
33 changes: 8 additions & 25 deletions docs/anton.rst → docs/_build/html/_sources/scripts.rst.txt
Original file line number Diff line number Diff line change
@@ -1,59 +1,42 @@
Scripts
=======

Definer
--------------------
Properties
-----------------------

.. automodule:: definer
.. automodule:: properties
:members:
:undoc-members:
:show-inheritance:


Initializer
------------------------

.. automodule:: initializer
:members:
:undoc-members:
:show-inheritance:

Panel
------------------

.. automodule:: panel
:members:
:undoc-members:
:show-inheritance:

Preferences
------------------------
Definer
--------------------

.. automodule:: preferences
.. automodule:: definer
:members:
:undoc-members:
:show-inheritance:


Processor
----------------------

.. automodule:: processor
:members:
:undoc-members:
:show-inheritance:

Properties
-----------------------

.. automodule:: properties
:members:
:undoc-members:
:show-inheritance:

Visualizer
-----------------------

.. automodule:: visualizer
:members:
:undoc-members:
:show-inheritance:

Loading

0 comments on commit 7b54bfc

Please sign in to comment.