def _find_common_vertex_angle(self, cva_cond: RelationshipBased, indexer: Indexer): r = cva_cond.relationship vertex = r.vertex ends = r.ends size = len(ends) for i in range(size): for j in range(i + 1, size): for k in range(j + 1, size): angle_ij = indexer.index_angle_by_points( ends[i], vertex, ends[j]) angle_jk = indexer.index_angle_by_points( ends[j], vertex, ends[k]) angle_ik = indexer.index_angle_by_points( ends[i], vertex, ends[k]) cond_ik = indexer.index_value_condition(angle_ik, 'angle') if cond_ik.attr_value is None: continue eq_cond = index_equivalent_value(indexer, angle_ij, 'angle', angle_jk, 'angle') if eq_cond is None: continue cond_ij = indexer.index_value_condition(angle_ij, 'angle') cond_jk = indexer.index_value_condition(angle_jk, 'angle') unkown_cond = [ c for c in [cond_ij, cond_jk] if c.attr_value is None ] if not unkown_cond: continue return [[eq_cond, cond_ik], unkown_cond] return None
def _find_common_vertex_angle(self, cva_cond: RelationshipBased, indexer: Indexer): r = cva_cond.relationship vertex = r.vertex ends = r.ends size = len(ends) for i in range(size): for j in range(i + 1, size): for k in range(j + 1, size): angle_ij = indexer.index_angle_by_points( ends[i], vertex, ends[j]) angle_jk = indexer.index_angle_by_points( ends[j], vertex, ends[k]) angle_ik = indexer.index_angle_by_points( ends[i], vertex, ends[k]) cond_ij = indexer.index_value_condition(angle_ij, 'angle') cond_jk = indexer.index_value_condition(angle_jk, 'angle') cond_ik = indexer.index_value_condition(angle_ik, 'angle') if sum([ cond_ij.attr_value is None, cond_jk.attr_value is None, cond_ik.attr_value is None ]) == 1: return [[cva_cond, cond_ij, cond_jk], (cond_ik)] return None
def index(self, indexer: Indexer): ret = [] nas_conds = indexer.index_by_type(NAngleSector) for cond in nas_conds: r = cond.relationship # Existence of ratio condition is guaranteed. ratio_cond = indexer.index_value_condition(r, 'ratio') ratio = ratio_cond.attr_value p_near, p_split, p_far = r.three_ends vertex = r.vertex angle_near = indexer.index_angle_by_points(p_near, vertex, p_split) angle_far = indexer.index_angle_by_points(p_far, vertex, p_split) angle_full = indexer.index_angle_by_points(p_near, vertex, p_far) near_cond = indexer.index_value_condition(angle_near, 'angle') far_cond = indexer.index_value_condition(angle_far, 'angle') full_cond = indexer.index_value_condition(angle_full, 'angle') if full_cond.attr_value is None: if near_cond.attr_value is not None: ret.append([[near_cond, ratio_cond, 1 / ratio], full_cond]) elif far_cond.attr_value is not None: ret.append([[far_cond, ratio_cond, 1 / (1 - ratio)], full_cond]) if near_cond.attr_value is None: if full_cond.attr_value is not None: ret.append([[full_cond, ratio_cond, ratio], near_cond]) elif far_cond.attr_value is not None: ret.append([[far_cond, ratio_cond, ratio / (1 - ratio)], near_cond]) if far_cond.attr_value is None: if full_cond.attr_value is not None: ret.append([[full_cond, ratio_cond, 1 - ratio], far_cond]) elif near_cond.attr_value is not None: ret.append([[near_cond, ratio_cond, (1 - ratio) / ratio], far_cond]) return ret
def index(self, indexer: Indexer): ret = [] conds = indexer.index_by_type(Perpendicular) for cond in conds: r = cond.relationship line1 = r.line1 line2 = r.line2 if r.foot_point is None: r.foot_point = indexer.index_line_intersection(line1, line2) foot_point = r.foot_point for p1 in [line1.end1, line1.end2]: for p2 in [line2.end1, line2.end2]: if p1 == foot_point or p2 == foot_point: continue angle = indexer.index_angle_by_points(p1, foot_point, p2) angle_cond = indexer.index_value_condition(angle, 'angle') if angle_cond.attr_value is None: ret.append([[cond], AttributeValue(angle, **{'angle': None})]) return ret