Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
update: use regions for fracture coords
Browse files Browse the repository at this point in the history
  • Loading branch information
uysalibov committed Mar 14, 2024
1 parent bceb49d commit cb6f66a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 7 deletions.
10 changes: 8 additions & 2 deletions marble-sculp/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self, radius: int = 1, segment: int = 32, two_ways: bool = True):
self.two_ways = two_ways
self.pos = [0.0, 0.0, 0.0]
self.constant = 0
self.color = None

self.faces = []
self.vertices = [self.pos]
Expand Down Expand Up @@ -96,7 +97,12 @@ def rotate(self, dip: int, dip_direction: int):
self.vertices[1], self.vertices[2], self.vertices[3]
)

def intersections(self, edges: List[List[int]], vertices: List[List[int]]):
def intersections(
self,
edges: List[List[int]],
vertices: List[List[int]],
color: List[float] = None,
):
lines = [[vertices[i[0]], vertices[i[1]]] for i in edges]
intersection_list = []
for line in lines:
Expand Down Expand Up @@ -147,4 +153,4 @@ def intersections(self, edges: List[List[int]], vertices: List[List[int]]):
return None
# self._reset_rotation()

return Discontinuity(sort_points(intersection_list), self.normal)
return Discontinuity(sort_points(intersection_list), self.normal, color=color)
48 changes: 43 additions & 5 deletions marble-sculp/disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@

class Discontinuity:
def __init__(
self, vertices: List[List[int]], normal: List[int] = None, two_ways: bool = True
self,
vertices: List[List[int]],
normal: List[int] = None,
two_ways: bool = True,
color: List[float] = None,
):
self.vertices = vertices
self.faces = [[]]
self.normal = normal
self.pos = [0.0, 0.0, 0.0]
self.color = color
self.min_region = []
self.max_region = []

for ind, value in enumerate(self.vertices):
self.faces[0].append(ind)
Expand All @@ -30,6 +37,18 @@ def __init__(

self.faces = self.faces + temp_faces

def calculate_regions(self):
min_x = min(self.vertices, key=lambda x: x[0])[0]
min_y = min(self.vertices, key=lambda x: x[1])[1]
min_z = min(self.vertices, key=lambda x: x[2])[2]

max_x = max(self.vertices, key=lambda x: x[0])[0]
max_y = max(self.vertices, key=lambda x: x[1])[1]
max_z = max(self.vertices, key=lambda x: x[2])[2]

self.max_region = [max_x, max_y, max_z]
self.min_region = [min_x, min_y, min_z]

def baecher(
self,
dip: int,
Expand All @@ -46,6 +65,8 @@ def baecher(
if fisher_constant > 0 and fisher_constant < 2:
raise ValueError("fisher_constant value mustn't be between 0 and 2")

self.calculate_regions()

dip *= math.pi / 180
dip_direction *= math.pi / 180

Expand Down Expand Up @@ -108,14 +129,31 @@ def baecher(

width = 1
height = 1
depth = 1
rand_coord_x = width + np.random.uniform() * (width - 0)
rand_coord_y = height + np.random.uniform() * (height - 0)
rand_coord_z = depth + np.random.uniform() * (depth - 0)
rand_coord_x = self.min_region[0] - np.random.uniform() * (
self.max_region[0] - self.min_region[0]
)
rand_coord_y = self.min_region[1] - np.random.uniform() * (
self.max_region[1] - self.min_region[1]
)
rand_coord_z = self.min_region[2] - np.random.uniform() * (
self.max_region[2] - self.min_region[2]
)

if distribution_size == "log":
return {
"pos": [rand_coord_x, rand_coord_y, rand_coord_z],
"unit_vector": pole_all_rotated,
"value": lognormal_distribution,
}
elif distribution_size == "exp":
return {
"pos": [rand_coord_x, rand_coord_y, rand_coord_z],
"unit_vector": pole_all_rotated,
"value": exponential_distribution,
}
elif distribution_size == "det":
return {
"pos": [rand_coord_x, rand_coord_y, rand_coord_z],
"unit_vector": pole_all_rotated,
"value": mean_fracture_size,
}
1 change: 1 addition & 0 deletions marble-sculp/marble.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def __init__(self, size: List[int] = [1, 1, 1], pos: List[int] = [0, 0, 0]):
self.type = "marble"
self.size = size
self.pos = pos
self.color = None
self.volume = size[0] * size[1] * size[2]
self.vertices = [
[0, 0, 0], # A 0
Expand Down
22 changes: 22 additions & 0 deletions marble-sculp/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
from enum import Enum
from typing import List
from typing_extensions import TypedDict
from pydantic import BaseModel


class FractureTypes(str, Enum):
exp = "exp"
log = "log"
det = "det"


class Discontinous(TypedDict):
dip: int
dipDirection: int
Expand All @@ -11,6 +18,21 @@ class Discontinous(TypedDict):
positionZ: float


class FractureModel(BaseModel):
filename: str
positionX: float
positionY: float
positionZ: float
sizeX: float
sizeY: float
sizeZ: float
fisherConstant: int
distributionSize: FractureTypes
meanFractureSize: int
sigmaFractureSize: int
data: List[Discontinous]


class DiscModel(BaseModel):
filename: str
positionX: float
Expand Down

0 comments on commit cb6f66a

Please sign in to comment.