adding comments
This commit is contained in:
parent
9eaf12a4fa
commit
12482ff40f
7 changed files with 102 additions and 75 deletions
|
@ -245,7 +245,7 @@ class GetPartPrimitiveCoordinatesUseCase(object):
|
|||
|
||||
|
||||
class InitPartsParseUseCase():
|
||||
|
||||
# Инициализация парсинга
|
||||
def call(self):
|
||||
product_details = []
|
||||
for part in FreeCadRepository().getAllSolids():
|
||||
|
@ -257,13 +257,14 @@ class InitPartsParseUseCase():
|
|||
|
||||
|
||||
class RenderPrimitiveUseCase(object):
|
||||
|
||||
# Рендеринг премитивов
|
||||
def call(self, meshModels: list[MeshGeometryCoordinateModel], detailSquares) -> None:
|
||||
for mesh in meshModels:
|
||||
mesh.initializePrimitivesByCoordinate(detailSquares)
|
||||
|
||||
|
||||
class ClearWorkSpaceDocumentUseCase(object):
|
||||
# Очистка рабочего простарнства
|
||||
def call(self, detailSquares):
|
||||
for key in detailSquares:
|
||||
for renderPrimitive in detailSquares[key]:
|
||||
|
@ -309,7 +310,9 @@ class ClearWorkSpaceDocumentUseCase(object):
|
|||
|
||||
|
||||
class CadAdjacencyMatrix:
|
||||
# Матрица основанная на соприкосновении примитива с обьектами
|
||||
def primitiveMatrix(self):
|
||||
# Получение матрицы
|
||||
matrix = RenderPrimitivesScenario(
|
||||
InitPartsParseUseCase(),
|
||||
GetPartPrimitiveCoordinatesUseCase(),
|
||||
|
@ -317,27 +320,27 @@ class CadAdjacencyMatrix:
|
|||
GetCollisionAtPrimitiveUseCase(),
|
||||
ClearWorkSpaceDocumentUseCase(),
|
||||
).call()
|
||||
|
||||
return AdjacencyMatrix(
|
||||
all_parts=GetAllPartsLabelsUseCase().call(),
|
||||
first_detail=GetFirstDetailUseCase().call(),
|
||||
matrix=matrix,
|
||||
)
|
||||
|
||||
def matrixBySurfaces(self,):
|
||||
adjaxed = {}
|
||||
# Матрица основанная на соприкосновении обьектов
|
||||
def matrixBySurfaces(self):
|
||||
matrix = {}
|
||||
for part in FreeCadRepository().getAllSolids():
|
||||
adjaxed[part.Label] = []
|
||||
matrix[part.Label] = []
|
||||
for nextPart in FreeCadRepository().getAllSolids():
|
||||
if part.Label != nextPart.Label:
|
||||
# Вычисление соприконсоновения площади деталей
|
||||
collisionResult: int = int(
|
||||
part.Shape.distToShape(nextPart.Shape)[0])
|
||||
if (collisionResult == 0):
|
||||
adjaxed[part.Label].append(nextPart.Label)
|
||||
matrix[part.Label].append(nextPart.Label)
|
||||
|
||||
return AdjacencyMatrix(all_parts=GetAllPartsLabelsUseCase(
|
||||
).call(), first_detail=GetFirstDetailUseCase().call(),
|
||||
matrix=adjaxed
|
||||
matrix=matrix
|
||||
)
|
||||
|
||||
|
||||
|
@ -349,9 +352,10 @@ def main():
|
|||
return TypeError('CadFile not found env.json')
|
||||
App.open(u'' + cadFile)
|
||||
|
||||
|
||||
# Получение матрицы
|
||||
matrixOut = CadAdjacencyMatrix().primitiveMatrix().to_dict()
|
||||
import json
|
||||
# Запись результата
|
||||
FS.writeFile(json.dumps(matrixOut, ensure_ascii=False, indent=4), outPath,'out.json')
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue