diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..c30e5d5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Current File", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal", + "justMyCode": false, + } + ] +} \ No newline at end of file diff --git a/abstract/coordinatesystem.py b/abstract/coordinatesystem.py index 48b8593..803a677 100644 --- a/abstract/coordinatesystem.py +++ b/abstract/coordinatesystem.py @@ -66,7 +66,7 @@ def __init__(self, origin: Point, x_axis, y_axis, z_axis): ``` """ - self.id = generateID() + self.Origin = origin self.Xaxis = Vector.normalize(x_axis) self.Y_axis = Vector.normalize(y_axis) diff --git a/abstract/node.py b/abstract/node.py index d39ea0e..f07d8a0 100644 --- a/abstract/node.py +++ b/abstract/node.py @@ -57,7 +57,7 @@ def __init__(self, point=None, vector=None, number=None, distance=0.0, diameter= - `diameter` (any, optional): A diameter associated with the node, useful in structural applications. - `comments` (str, optional): Additional comments or notes about the node. """ - self.id = generateID() + self.point = point if isinstance(point, Point) else None self.vector = vector if isinstance(vector, Vector) else None self.number = number diff --git a/abstract/rect.py b/abstract/rect.py index 1eab1d1..2e8cf34 100644 --- a/abstract/rect.py +++ b/abstract/rect.py @@ -56,7 +56,7 @@ def __init__(self, *args, **kwargs): rect3 = Rect(Vector(y=8), Vector(x = 4)) # x 0, y 8, width 4, length 0 ``` """ - self.id = generateID() + #first half = for position half:int = len(args) // 2 @@ -77,7 +77,7 @@ def __init__(self, *args, **kwargs): Serializable.__init__(self) - self.id = generateID() + def change_axis_count(self,axis_count: int): self.p0.change_axis_count(axis_count) diff --git a/abstract/text.py b/abstract/text.py index 80ad52d..f7e40c5 100644 --- a/abstract/text.py +++ b/abstract/text.py @@ -74,7 +74,7 @@ def __init__(self, text: str = None, font_family: 'str' = None, cs='CoordinateSy - `points` (list): A list of points derived from the text geometry. - `path_list` (list): A list containing the path data for each character. """ - self.id = generateID() + self.text = text self.font_family = font_family or "arial" self.xyz = cs.Origin diff --git a/abstract/vector.py b/abstract/vector.py index 0a25e31..afe4698 100644 --- a/abstract/vector.py +++ b/abstract/vector.py @@ -216,154 +216,6 @@ def pitch(vector_1: 'Vector', angle: float) -> 'Vector': vector_1.y*math.sin(angle) + vector_1.z*math.cos(angle) ) - @staticmethod - def angle_between(vector_1: 'Vector', vector_2: 'Vector') -> float: - """Computes the angle in degrees between two vectors. - The angle between two vectors is the angle required to rotate one vector onto the other, measured in degrees. - - #### Parameters: - - `vector_1` (`Vector`): The first vector. - - `vector_2` (`Vector`): The second vector. - - #### Returns: - `float`: The angle in degrees between the input vectors. - - #### Example usage: - ```python - vector1 = Vector(1, 0, 0) - vector2 = Vector(0, 1, 0) - angle = Vector.angle_between(vector1, vector2) - # 90 - ``` - """ - proj_vector_1 = Vector.to_matrix(vector_1) - proj_vector_2 = Vector.to_matrix(vector_2) - dot_product = Vector.dot_product(vector_1, vector_2) - length_vector_1 = Vector.length(vector_1) - length_vector_2 = Vector.length(vector_2) - - if length_vector_1 == 0 or length_vector_2 == 0: - return 0 - - cos_angle = dot_product / (length_vector_1 * length_vector_2) - cos_angle = max(-1.0, min(cos_angle, 1.0)) - angle = math.acos(cos_angle) - return math.degrees(angle) - - @staticmethod - def angle_radian_between(vector_1: 'Vector', vector_2: 'Vector') -> float: - """Computes the angle in radians between two vectors. - The angle between two vectors is the angle required to rotate one vector onto the other, measured in radians. - - #### Parameters: - - `vector_1` (`Vector`): The first vector. - - `vector_2` (`Vector`): The second vector. - - #### Returns: - `float`: The angle in radians between the input vectors. - - #### Example usage: - ```python - vector1 = Vector(1, 0, 0) - vector2 = Vector(0, 1, 0) - angle = Vector.angle_radian_between(vector1, vector2) - # 1.5707963267948966 - ``` - """ - return math.acos((Vector.dot_product(vector_1, vector_2)/(Vector.length(vector_1)*Vector.length(vector_2)))) - - @staticmethod - def angle_between_YZ(vector_1: 'Vector', vector_2: 'Vector') -> float: - """Computes the angle in degrees between two vectors projected onto the YZ plane (X-axis rotation). - - #### Parameters: - - `vector_1` (`Vector`): The first vector. - - `vector_2` (`Vector`): The second vector. - - #### Returns: - `float`: The angle in degrees between the input vectors projected onto the YZ plane (X-axis rotation). - - #### Example usage: - ```python - vector1 = Vector(1, 1, 0) - vector2 = Vector(1, 0, 1) - angle = Vector.angle_between_YZ(vector1, vector2) - # 90 - ``` - """ - dot_product = Vector.dot_product(vector_1, vector_2) - length_vector_1 = Vector.length(Vector(0, vector_1.y, vector_1.z)) - length_vector_2 = Vector.length(Vector(0, vector_2.y, vector_2.z)) - if length_vector_1 == 0 or length_vector_2 == 0: - return 0 - - cos_angle = dot_product / (length_vector_1 * length_vector_2) - cos_angle = max(-1.0, min(cos_angle, 1.0)) - angle = math.acos(cos_angle) - return math.degrees(angle) - - @staticmethod - def angle_between_XZ(vector_1: 'Vector', vector_2: 'Vector') -> float: - """Computes the angle in degrees between two vectors projected onto the XZ plane (Y-axis rotation). - - #### Parameters: - - `vector_1` (`Vector`): The first vector. - - `vector_2` (`Vector`): The second vector. - - #### Returns: - `float`: The angle in degrees between the input vectors projected onto the XZ plane (Y-axis rotation). - - #### Example usage: - ```python - vector1 = Vector(1, 0, 1) - vector2 = Vector(0, 1, 1) - angle = Vector.angle_between_XZ(vector1, vector2) - # 90 - ``` - """ - dot_product = Vector.dot_product(vector_1, vector_2) - length_vector_1 = Vector.length(Vector(vector_1.x, 0, vector_1.z)) - length_vector_2 = Vector.length(Vector(vector_2.x, 0, vector_2.z)) - - if length_vector_1 == 0 or length_vector_2 == 0: - return 0 - - cos_angle = dot_product / (length_vector_1 * length_vector_2) - cos_angle = max(-1.0, min(cos_angle, 1.0)) - angle = math.acos(cos_angle) - return math.degrees(angle) - - @staticmethod - def angle_between_XY(vector_1: 'Vector', vector_2: 'Vector') -> float: - """Computes the angle in degrees between two vectors projected onto the XY plane (Z-axis rotation). - - #### Parameters: - - `vector_1` (`Vector`): The first vector. - - `vector_2` (`Vector`): The second vector. - - #### Returns: - `float`: The angle in degrees between the input vectors projected onto the XY plane (Z-axis rotation). - - #### Example usage: - ```python - vector1 = Vector(1, 0, 1) - vector2 = Vector(0, 1, 1) - angle = Vector.angle_between_XY(vector1, vector2) - # 45 - ``` - """ - dot_product = Vector.dot_product(vector_1, vector_2) - length_vector_1 = Vector.length(Vector(vector_1.x, vector_1.y, 0)) - length_vector_2 = Vector.length(Vector(vector_2.x, vector_2.y, 0)) - - if length_vector_1 == 0 or length_vector_2 == 0: - return 0 - - cos_angle = dot_product / (length_vector_1 * length_vector_2) - cos_angle = max(-1.0, min(cos_angle, 1.0)) - angle = math.acos(cos_angle) - return math.degrees(angle) - @staticmethod def value(vector_1: 'Vector') -> tuple: """Returns the rounded values of the vector's components. diff --git a/example/matrixtester.py b/example/matrixtester.py index 34f8cb9..3f47d8a 100644 --- a/example/matrixtester.py +++ b/example/matrixtester.py @@ -1,7 +1,6 @@ import sys from pathlib import Path -from geometry.pointlist import PointCloud sys.path.append(str(Path(__file__).resolve().parents[1])) @@ -11,6 +10,7 @@ from geometry.point import Point from abstract.vector import Vector from geometry.curve import Arc +from geometry.pointlist import PointCloud point = Point(1, 2, 3) point2 : Point = Point([4,3,2]) @@ -37,10 +37,16 @@ c = Color(23,42,43,255) print(c.hex) -l1 = Line(Point(1,2), Point(1, 5)) -l2 = Arc(Point(1,5), Point(1.8, 6.2), Point(3,7)) -l3 = Line(Point(3,7), Point(7,7)) + +#counter clockwise +l1 = Line(Point(7,7), Point(3, 7)) +l2 = Arc(Point(3,7), Point(1.8, 6.2), Point(1,5)) +l3 = Line(Point(1,5), Point(1,2)) curve = PolyCurve(l1,l2,l3) pc = PointCloud([l.start, l.end]) -transformed_pointcloud = combined2 * pc \ No newline at end of file +transformed_pointcloud = combined2 * pc + +curve.closed = True +area = curve.area +print(area) \ No newline at end of file diff --git a/geometry/coords.py b/geometry/coords.py index 20c40c7..42c9df9 100644 --- a/geometry/coords.py +++ b/geometry/coords.py @@ -33,6 +33,7 @@ import math from typing import Self +from abstract.vector import Vector from packages.helper import generateID from abstract.serializable import Serializable @@ -156,6 +157,37 @@ def angle(self) -> float: #deg = atan(other side / straight side) return math.atan2(self.x, self.y) + @staticmethod + def angle_between(vector_1: 'Coords', vector_2: 'Coords') -> float: + """Computes the angle in degrees between two coords. + The angle between two coords is the angle required to rotate one vector onto the other, measured in degrees. + + #### Parameters: + - `vector_1` (`Vector`): The first vector. + - `vector_2` (`Vector`): The second vector. + + #### Returns: + `float`: The angle in degrees between the input coords. + + #### Example usage: + ```python + vector1 = Vector(1, 0, 0) + vector2 = Vector(0, 1, 0) + angle = Vector.angle_between(vector1, vector2) + # 90 + ``` + """ + dot_product = Vector.dot_product(vector_1, vector_2) + length_vector_1 = Vector.length(vector_1) + length_vector_2 = Vector.length(vector_2) + + if length_vector_1 == 0 or length_vector_2 == 0: + return 0 + + cos_angle = dot_product / (length_vector_1 * length_vector_2) + cos_angle = max(-1.0, min(cos_angle, 1.0)) + return math.acos(cos_angle) + @staticmethod def distance_squared(point_1: 'Coords', point_2: 'Coords') -> float: """Computes the Euclidean distance between two 3D points. diff --git a/geometry/curve.py b/geometry/curve.py index c8dd28a..fc2f953 100644 --- a/geometry/curve.py +++ b/geometry/curve.py @@ -322,7 +322,7 @@ def __init__(self, *args): """ - self.id = generateID() + #self.points:list[Point] = to_array(*args) #self.approximateLength = None @@ -337,24 +337,59 @@ def __init__(self, *args): super().__init__(to_array(*args)) @property - def area(self) -> 'float': + def closed(self) -> 'bool': + return self[0].start == self[-1].end + @closed.setter + def closed(self, value : bool): + if value != self.closed: + if value: + #just fill the gap using a straight line + self.append(Line(self[-1].end, self[0].start)) + else: + del self[-1] + + @property + def area(self): """Calculates the area of the 2d PolyCurve. Returns: float: The area of the 2d poly curve. - we are assuming the PolyCurve is wound counter-clockwise. + we are assuming the PolyCurve is wound counter-clockwise and is closed. """ + if not self.closed: + raise ValueError("the polycurve needs to be closed in order to calculate its area") + area:float = 0 for line in self: - #if isinstance(line, Arc): - # - #else: + if isinstance(line, Arc): + origin = line.origin + area += (line.start.x - line.end.x) * origin.y + #now that we added the 'rectangle', let's add the sine wave + + #the arc is part of a circle. the circle can be represented as two opposite cosine waves, with the circle center being at 0, 0. + #to calculate the area, we'll be using the integral of the cosine wave, which is the sine wave. + radius = (line.origin - line.start).magnitude + + #area is negative if y < 0 + #area is measured from the -x side here, so at -radius, area == 0 and at +radius, area == circle_area + #https://www.desmos.com/calculator/ykynwhoue6 + get_area = lambda pos : math.copysign((math.sin(((pos.x - origin.x) / radius) * (math.pi / 2)) + 1) * radius, pos.y - origin.y) + start_area = get_area(line.start) + end_area = get_area(line.end) + + integral_area = start_area - end_area + if integral_area < 0: + circle_area = (radius * radius) * math.pi + integral_area += circle_area + area += integral_area + else: #check direction of line #start - end, for counterclockwiseness #when start.x < end.x, this is a bottom line. we'll substract this from the area. dx = line.start.x - line.end.x averagey = (line.start.y + line.end.y) / 2 - area = dx * averagey + area += dx * averagey + return area @property def length(self) -> 'float': @@ -402,9 +437,11 @@ def scale(self, scale_factor: 'float') -> 'PolyCurve': print("Curvetype not found") crv = PolyCurve.by_joined_curves(crvs) return crv - + + #TODO finish function + @property def centroid(self) -> 'Point': - """Calculates the centroid of the PolyCurve. + """Calculates the centroid of the PolyCurve. in 2D #### Returns: `Point`: The centroid point of the PolyCurve. @@ -414,68 +451,55 @@ def centroid(self) -> 'Point': ``` """ - if self.closed: - num_points = len(self.points) - if num_points < 3: - return "Polygon has less than 3 points!" - - A = 0.0 - for i in range(num_points): - x0, y0 = self.points[i].x, self.points[i].y - x1, y1 = self.points[( - i + 1) % num_points].x, self.points[(i + 1) % num_points].y - A += x0 * y1 - x1 * y0 - A *= 0.5 - - Cx, Cy = 0.0, 0.0 - for i in range(num_points): - x0, y0 = self.points[i].x, self.points[i].y - x1, y1 = self.points[( - i + 1) % num_points].x, self.points[(i + 1) % num_points].y - factor = (x0 * y1 - x1 * y0) - Cx += (x0 + x1) * factor - Cy += (y0 + y1) * factor - - Cx /= (6.0 * A) - Cy /= (6.0 * A) - - return Point(x=round(Cx, project.decimals), y=round(Cy, project.decimals), z=self.points[0].z) - else: - return None - - def area(self) -> 'float': # shoelace formula - """Calculates the area enclosed by the PolyCurve using the shoelace formula. - - #### Returns: - `float`: The area enclosed by the PolyCurve. - - #### Example usage: - ```python - - ``` - """ - if self.closed: - if len(self.points) < 3: - return "Polygon has less than 3 points!" - - num_points = len(self.points) - S1, S2 = 0, 0 - - for i in range(num_points): - x, y = self.points[i].x, self.points[i].y - if i == num_points - 1: - x_next, y_next = self.points[0].x, self.points[0].y - else: - x_next, y_next = self.points[i + 1].x, self.points[i + 1].y - - S1 += x * y_next - S2 += y * x_next + poly = Polygon.by_joined_curves(self) + centroid = poly.centroid + + #now check if any lines are arcs. in that case, we need to adjust the centroid a bit + + for i in range(len(self)): + current_line = self[i] + if isinstance(current_line, Arc): + #https://pickedshares.com/en/center-of-area-of-%E2%80%8B%E2%80%8Bgeometric-figures/#circlesegment + #calculate the centroid + arc_centroid = current_line.centroid + raise NotImplementedError("this code isn't done yet!") + + #now that we have the centroid, we also need to calculate the area, and multiply the centroid by the area to give it a 'weight' + - area = 0.5 * abs(S1 - S2) - return area - else: - print("Polycurve is not closed, no area!") - return None + #def area(self) -> 'float': # shoelace formula + # """Calculates the area enclosed by the PolyCurve using the shoelace formula. +# + # #### Returns: + # `float`: The area enclosed by the PolyCurve. +# + # #### Example usage: + # ```python +# + # ``` + # """ + # if self.closed: + # if len(self.points) < 3: + # return "Polygon has less than 3 points!" +# + # num_points = len(self.points) + # S1, S2 = 0, 0 +# + # for i in range(num_points): + # x, y = self.points[i].x, self.points[i].y + # if i == num_points - 1: + # x_next, y_next = self.points[0].x, self.points[0].y + # else: + # x_next, y_next = self.points[i + 1].x, self.points[i + 1].y +# + # S1 += x * y_next + # S2 += y * x_next +# + # area = 0.5 * abs(S1 - S2) + # return area + # else: + # print("Polycurve is not closed, no area!") + # return None @@ -994,7 +1018,7 @@ def transform_from_origin(polycurve: 'PolyCurve', startpoint: 'Point', direction class Polygon(PointList): """Represents a polygon composed of points.""" def __init__(self, *args) -> 'Polygon': - self.id = generateID() + super().__init__(to_array(*args)) @@ -1231,6 +1255,43 @@ def area(self) -> 'float': # shoelace formula area = 0.5 * abs(S1 - S2) return area + + @property + def centroid(self) -> 'Point': + """Calculates the centroid of the Polygon in 2D. we assume that the polygon doesn't intersect itself. + + #### Returns: + `Point`: The centroid point of the Polygon. + + #### Example usage: + ```python + + ``` + """ + if self.closed: + num_points = len(self) + if num_points < 3: + return "Polygon has less than 3 points!" + + area = self.area + + #https://stackoverflow.com/questions/5271583/center-of-gravity-of-a-polygon + + + Cx, Cy = 0.0, 0.0 + for i in range(num_points): + x0, y0 = self[i-1].x, self[i-1].y + x1, y1 = self[i].x, self[i].y + factor = (x0 * y1 - x1 * y0) + Cx += (x0 + x1) * factor + Cy += (y0 + y1) * factor + + Cx /= (6.0 * area) + Cy /= (6.0 * area) + + return Point(Cx, Cy) + else: + raise ValueError("this polycurve is not closed") def length(self) -> 'float': """Calculates the total length of the Polygon. @@ -1281,7 +1342,7 @@ def __init__(self, startPoint: 'Point', midPoint: 'Point', endPoint: 'Point') -> if not math.isclose(Point.distance_squared(startPoint, midPoint), Point.distance_squared(midPoint, endPoint), rel_tol= 1.0 / 0x100): raise ValueError('midpoint is not in the center') - self.id = generateID() + self.start = startPoint self.mid = midPoint self.end = endPoint @@ -1322,8 +1383,9 @@ def coordinatesystem_arc(self) -> 'CoordinateSystem': self.coordinatesystem = CoordinateSystem(self.origin, Vector.normalize(vx), Vector.normalize(vy), Vector.normalize(vz)) return self.coordinatesystem - - def radius_arc(self) -> 'float': + + @property + def radius(self) -> 'float': """Calculates and returns the radius of the arc. The radius is computed based on the distances between the start, mid, and end points of the arc. @@ -1347,8 +1409,9 @@ def radius_arc(self) -> 'float': else: R = (a * b * c) / (4 * A) return R - - def origin_arc(self) -> 'Point': + + @property + def origin(self) -> 'Point': """Calculates and returns the origin of the arc. The origin is calculated based on the geometric properties of the arc defined by its start, mid, and end points. @@ -1364,7 +1427,7 @@ def origin_arc(self) -> 'Point': start_to_end = self.end - self.start half_start_end = start_to_end * 0.5 b = half_start_end.magnitude - radius = Arc.radius_arc(self) + radius = Arc.radius(self) x = math.sqrt(radius * radius - b * b) #mid point as if this was a straight line mid = self.start + half_start_end @@ -1374,8 +1437,16 @@ def origin_arc(self) -> 'Point': to_center.magnitude = x center = mid + to_center return center - - def angle_radian(self) -> 'float': + def centroid(self) -> 'Point': + origin = self.origin + radius = self.radius + angle = self.angle + #the distance of the centroid of the arc to its origin + centroid_distance = (2 / 3) * ((radius * (math.sin(angle) ** 3)) / (angle - math.sin(angle) * math.cos(angle))) + centroid = origin + centroid_distance * ((self.mid - origin) / radius) + + @property + def angle(self) -> 'float': """Calculates and returns the total angle of the arc in radians. The angle is determined based on the vectors defined by the start, mid, and end points with respect to the arc's origin. @@ -1388,9 +1459,10 @@ def angle_radian(self) -> 'float': # angle will be the total angle of the arc in radians ``` """ - vector_1 = Vector.by_two_points(self.origin, self.end) - vector_2 = Vector.by_two_points(self.origin, self.start) - vector_3 = Vector.by_two_points(self.origin, self.mid) + origin = self.origin + vector_1 = self.end - origin + vector_2 = self.start - origin + vector_3 = self.mid - origin vector_4 = vector_1 + vector_2 try: v4b = Vector.new_length(vector_4, self.radius) @@ -1402,7 +1474,8 @@ def angle_radian(self) -> 'float': except: angle = 2*math.pi-Vector.angle_radian_between(vector_1, vector_2) return angle - + + @property def length(self) -> 'float': """Calculates and returns the length of the arc. The length is calculated using the geometric properties of the arc defined by its start, mid, and end points. @@ -1550,7 +1623,7 @@ def __init__(self, radius: 'float', plane: 'Plane', length: 'float') -> 'Circle' self.radius = radius self.plane = plane self.length = length - self.id = generateID() + pass # Curve def __id__(self): @@ -1587,7 +1660,7 @@ def __init__(self, firstRadius: 'float', secondRadius: 'float', plane: 'Plane') self.firstRadius = firstRadius self.secondRadius = secondRadius self.plane = plane - self.id = generateID() + pass # Curve def __id__(self): diff --git a/geometry/geometry2d.py b/geometry/geometry2d.py index 4ddb5d9..f668bf3 100644 --- a/geometry/geometry2d.py +++ b/geometry/geometry2d.py @@ -48,7 +48,7 @@ class Vector2: def __init__(self, x, y) -> None: - self.id = generateID() + self.x: float = 0.0 self.y: float = 0.0 self.x = x @@ -168,7 +168,7 @@ def __str__(self) -> str: class Point2D: def __init__(self, x: float, y: float) -> None: - self.id = generateID() + self.x = x self.y = y self.x = float(x) @@ -264,7 +264,7 @@ def __init__(self, start, end) -> None: self.vector2: Vector2 = Vector2.by_two_points(self.start, self.end) self.vector2_normalised = Vector2.normalize(self.vector2) self.length = self.length() - self.id = generateID() + def serialize(self): return { @@ -306,7 +306,7 @@ def __str__(self): # class Arc2D: # def __init__(self, pntxy1, pntxy2, pntxy3) -> None: -# self.id = generateID() +# # self.type = __class__.__name__ # self.start: Point2D = pntxy1 # self.mid: Point2D = pntxy2 @@ -436,7 +436,7 @@ def __init__(self, startPoint: 'Point2D', midPoint: 'Point2D', endPoint: 'Point2 - `midPoint` (Point2D): The mid point of the arc which defines its curvature. - `endPoint` (Point2D): The ending point of the arc. """ - self.id = generateID() + self.start = startPoint self.mid = midPoint self.end = endPoint @@ -703,7 +703,7 @@ def __str__(self) -> 'str': class PolyCurve2D: def __init__(self) -> None: - self.id = generateID() + self.curves = [] self.points2D = [] self.segmentcurves = None @@ -1131,7 +1131,7 @@ def __str__(self): class Surface2D: def __init__(self) -> None: pass # PolyCurve2D - self.id = generateID() + def __id__(self): return f"id:{self.id}" @@ -1142,7 +1142,7 @@ def __str__(self) -> str: class Profile2D: def __init__(self) -> None: - self.id = generateID() + pass def __id__(self): return f"id:{self.id}" @@ -1150,10 +1150,9 @@ def __id__(self): def __str__(self) -> str: return f"{__class__.__name__}({self})" - class ParametricProfile2D: def __init__(self) -> None: - self.id = generateID() + pass def __id__(self): return f"id:{self.id}" diff --git a/geometry/point.py b/geometry/point.py index 26c8603..213f967 100644 --- a/geometry/point.py +++ b/geometry/point.py @@ -189,7 +189,7 @@ def __init__(self, origin: Point, x_axis, y_axis, z_axis) -> 'CoordinateSystem': - `z_axis` (Vector): The initial vector representing the Z-axis before normalization. """ from abstract.vector import Vector - self.id = generateID() + self.Origin = origin self.X_axis = x_axis self.Y_axis = y_axis diff --git a/geometry/pointlist.py b/geometry/pointlist.py index c4bd4ae..22c6797 100644 --- a/geometry/pointlist.py +++ b/geometry/pointlist.py @@ -54,7 +54,7 @@ def __init__(self, points: list) -> 'PointList': Initializes the PointList's attributes and sets up the list of points based on the input provided. The ID is generated to uniquely identify the point cloud. """ super().__init__(points) - self.id = generateID() + #just execute the operator for all list members def operate_2(self, op:operator, other): diff --git a/geometry/solid.py b/geometry/solid.py index db7c964..bd0e527 100644 --- a/geometry/solid.py +++ b/geometry/solid.py @@ -75,7 +75,7 @@ def __init__(self): - `polycurve_3d_translated` (PolyCurve): A polycurve representing the translated 3D profile of the extrusion. - `bottomshape` (list): A list representing the shape of the bottom face of the extrusion. """ - self.id = generateID() + self.parameters = [] self.verts = [] self.faces = [] diff --git a/geometry/surface.py b/geometry/surface.py index 2bad158..7a1c3a0 100644 --- a/geometry/surface.py +++ b/geometry/surface.py @@ -67,7 +67,7 @@ def __init__(self) -> 'Surface': self.mesh = [] self.offset = 0 self.name = None - self.id = generateID() + self.outer_Polygon = None self.inner_Polygon = [] self.colorlst = [] @@ -215,7 +215,7 @@ def __init__(self) -> 'NurbsSurface': - `id` (str): A unique identifier for the NurbsSurface. - `type` (str): Class name, "NurbsSurface". """ - self.id = generateID() + def __id__(self) -> 'str': """Returns the unique identifier of the NurbsSurface object. @@ -258,7 +258,7 @@ def __init__(self) -> None: - `id` (str): A unique identifier for the PolySurface. - `type` (str): Class name, "PolySurface". """ - self.id = generateID() + def __id__(self) -> 'str': """Returns the unique identifier of the PolySurface object. diff --git a/geometry/systemsimple.py b/geometry/systemsimple.py index cdcb36e..3f51d11 100644 --- a/geometry/systemsimple.py +++ b/geometry/systemsimple.py @@ -59,7 +59,7 @@ def __init__(self): - `direction` (Vector): A Vector indicating the primary direction of the system. """ self.name = None - self.id = generateID() + self.polycurve = None self.direction: Vector = Vector(1, 0, 0) @@ -84,7 +84,7 @@ def __init__(self): - `system` (str): A string indicating the current system strategy (e.g., "fixed_distance_unequal_division"). """ self.name = None - self.id = generateID() + self.system_length: float = 100 self.spacing: float = 10 self.distance_first: float = 5 @@ -270,7 +270,7 @@ def __init__(self): - `symbolic_inner_grids` (list): Symbolic representations of inner grids. """ self.name = None - self.id = generateID() + self.height = 3000 self.width = 2000 self.bottom_frame_type = Rectangle("bottom_frame_type", 38, 184) @@ -479,7 +479,7 @@ class pattern_system: def __init__(self): """Initializes a new pattern_system instance.""" self.name = None - self.id = generateID() + self.pattern = None self.basepanels = [] # contains a list with basepanels of the system # contains a list sublists with Vector which represent the repetition of the system diff --git a/objects/analytical.py b/objects/analytical.py index e140e11..af6b17d 100644 --- a/objects/analytical.py +++ b/objects/analytical.py @@ -46,7 +46,7 @@ class Support: def __init__(self): self.Number = None self.Point: Point = Point(0, 0, 0) - self.id = generateID() + self.Tx: str = " " # A, P, N, S self.Ty: str = " " # A, P, N, S self.Tz: str = " " # A, P, N, S diff --git a/objects/annotation.py b/objects/annotation.py index 5c3a0d7..3e38d5c 100644 --- a/objects/annotation.py +++ b/objects/annotation.py @@ -45,7 +45,7 @@ class TickMark: # Dimension Tick Mark def __init__(self): self.name = None - self.id = generateID() + self.curves = [] @staticmethod @@ -63,7 +63,7 @@ def by_curves(name, curves): class DimensionType: def __init__(self): self.name = None - self.id = generateID() + self.font = None self.text_height = 2.5 self.tick_mark: TickMark = TMDiagonal @@ -118,7 +118,7 @@ def by_name_font_textheight_tick_mark_extension(name: str, font: str, text_heigh class Dimension: def __init__(self, start: Point, end: Point, dimension_type) -> None: - self.id = generateID() + self.start: Point = start self.text_height = 100 self.end: Point = end @@ -210,7 +210,7 @@ def write(self, project): class FrameTag: def __init__(self): # Dimensions in 1/100 scale - self.id = generateID() + self.scale = 0.1 self.cs: CoordinateSystem = CSGlobal self.offset_x = 500 @@ -289,7 +289,7 @@ def by_frame(frame): class ColumnTag: def __init__(self): # Dimensions in 1/100 scale - self.id = generateID() + self.width = 700 self.height = 500 self.factor = 3 # hellingsfacor leader diff --git a/objects/datum.py b/objects/datum.py index 706867f..f3048a6 100644 --- a/objects/datum.py +++ b/objects/datum.py @@ -48,7 +48,7 @@ class GridheadType(Serializable): def __init__(self): - self.id = generateID() + self.name = None self.curves = [] self.diameter = 150 @@ -110,7 +110,7 @@ def geom(self): class GridHead: def __init__(self): - self.id = generateID() + self.grid_name: str = "A" self.grid_head_type = GHT50 self.radius = GHT50.radius @@ -257,7 +257,7 @@ def get_grid_distances(Grids): class GridSystem: # rectangle Gridsystem def __init__(self): - self.id = generateID() + self.gridsX = None self.gridsY = None self.dimensions = [] diff --git a/objects/door.py b/objects/door.py index d9ce0b6..ea6c6c0 100644 --- a/objects/door.py +++ b/objects/door.py @@ -45,7 +45,7 @@ class Door: def __init__(self): - self.id = generateID() + self.name = None self.verts = None self.faces = None diff --git a/objects/floor.py b/objects/floor.py index 149dc95..9ddb16f 100644 --- a/objects/floor.py +++ b/objects/floor.py @@ -45,7 +45,7 @@ class Floor: def __init__(self): - self.id = generateID() + self.extrusion = None self.thickness = 0 self.name = None diff --git a/objects/frame.py b/objects/frame.py index 2499847..7517650 100644 --- a/objects/frame.py +++ b/objects/frame.py @@ -62,7 +62,7 @@ def colorlist(extrus, color): # ToDo Na update van color moet ook de colorlist geupdate worden class Frame(Serializable): def __init__(self): - self.id = generateID() + self.name = "None" self.profileName = "None" self.extrusion = None diff --git a/objects/level.py b/objects/level.py index 1a82599..a9352a0 100644 --- a/objects/level.py +++ b/objects/level.py @@ -44,7 +44,7 @@ class Level: def __init__(self): - self.id = generateID() + self.name = None self.polycurve = None self.plane = None diff --git a/objects/objectcollection.py b/objects/objectcollection.py index 71ed122..b703dca 100644 --- a/objects/objectcollection.py +++ b/objects/objectcollection.py @@ -49,7 +49,7 @@ class WurksRaster3d(Serializable): def __init__(self): - self.id = generateID() + self.bottom = None self.top = None self.name = "x" diff --git a/objects/panel.py b/objects/panel.py index d89dee6..22448a2 100644 --- a/objects/panel.py +++ b/objects/panel.py @@ -47,7 +47,7 @@ class Panel(Serializable): # Panel def __init__(self): - self.id = generateID() + self.extrusion = None self.thickness = 0 self.name = None diff --git a/objects/profile.py b/objects/profile.py index 68e61c8..987dab3 100644 --- a/objects/profile.py +++ b/objects/profile.py @@ -68,7 +68,7 @@ def __init__(self, name: str, description: str, IFC_profile_def: str, height: fl """ self.IFC_profile_def = IFC_profile_def - self.ID = generateID() + self.name = name self.description = description self.curve = [] @@ -1016,7 +1016,7 @@ def __init__(self, name, length, width, b1, l1): super().__init__(name, "Arrow-profile", "Unknown", length, width) # parameters - self.id = generateID() + self.length = length # length self.b1 = b1 self.l1 = l1 diff --git a/objects/room.py b/objects/room.py index 0bcb9f2..46eaed8 100644 --- a/objects/room.py +++ b/objects/room.py @@ -45,7 +45,7 @@ class Room: def __init__(self): - self.id = generateID() + self.name = None self.extrusion = None self.verts = None diff --git a/objects/shape3d.py b/objects/shape3d.py index 0b67af6..c7ed1f2 100644 --- a/objects/shape3d.py +++ b/objects/shape3d.py @@ -289,7 +289,7 @@ class Sphere: def __init__(self, point=Point, diameter=int, tag: None = string, comments: None = string): self.point = point self.diameter = diameter - self.id = generateID() + self.tag = None self.comments = None diff --git a/objects/view.py b/objects/view.py index b0f75a7..90f59d3 100644 --- a/objects/view.py +++ b/objects/view.py @@ -38,7 +38,7 @@ class View(Serializable): def __init__(self): self.name = None - self.id = generateID() + self.origin = Point(0, 0, 0) self.cutplane: CoordinateSystem = None self.visibility = None @@ -73,7 +73,7 @@ def deserialize(data): class Visibility(Serializable): def __init__(self): self.name = None - self.id = generateID() + self.origin = Point(0, 0, 0) self.cutplane: CoordinateSystem = None self.visibility = None diff --git a/objects/wall.py b/objects/wall.py index 9194ddc..3fe86e3 100644 --- a/objects/wall.py +++ b/objects/wall.py @@ -45,7 +45,7 @@ class Wall: def __init__(self): - self.id = generateID() + self.name = None self.verts = None self.faces = None