ASP refactoring, sequence generation via clusterization
This commit is contained in:
parent
d2ab856d64
commit
fd59ab9e26
45 changed files with 1579 additions and 1267 deletions
48
geometric_feasibility_predicate/models/env_model.py
Normal file
48
geometric_feasibility_predicate/models/env_model.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
from dataclasses import dataclass
|
||||
from typing import List, Dict, Any, TypeVar, Callable, Type, cast
|
||||
from extensions.list import CoreList
|
||||
|
||||
from models.var import from_str, from_float
|
||||
|
||||
|
||||
@dataclass
|
||||
class EnvModel:
|
||||
cadFilePath: str
|
||||
outPath: str
|
||||
solidBodyPadding: float
|
||||
firstDetail: str
|
||||
sequencesFixed: list[list[str]]
|
||||
|
||||
@staticmethod
|
||||
def from_dict(obj: Any) -> "EnvModel":
|
||||
assert isinstance(obj, dict)
|
||||
cadFilePath = from_str(obj.get("cadFilePath"))
|
||||
outPath = from_str(obj.get("outPath"))
|
||||
solidBodyPadding = from_float(obj.get("solidBodyPadding"))
|
||||
firstDetail = from_str(obj.get("firstDetail"))
|
||||
sequencesFixed = []
|
||||
sequencesFixedParse = CoreList(obj.get("sequencesFixed"))
|
||||
for el in sequencesFixedParse:
|
||||
sequencesFixed.append(el)
|
||||
|
||||
restrictionsOnFasteners = CoreList(obj.get("restrictionsOnFasteners"))
|
||||
|
||||
for el in restrictionsOnFasteners:
|
||||
for part in el["parts"]:
|
||||
sequencesFixed.append([part, el["fastener"]])
|
||||
return EnvModel(
|
||||
cadFilePath,
|
||||
outPath,
|
||||
solidBodyPadding,
|
||||
firstDetail,
|
||||
sequencesFixed,
|
||||
)
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
result: dict = {}
|
||||
result["cadFilePath"] = from_str(self.cadFilePath)
|
||||
result["outPath"] = from_str(self.outPath)
|
||||
result["solidBodyPadding"] = from_float(self.solidBodyPadding)
|
||||
result["firstDetail"] = from_str(self.firstDetail)
|
||||
result["sequencesFixed"] = self.sequencesFixed
|
||||
return result
|
Loading…
Add table
Add a link
Reference in a new issue