コード例 #1
0
  public static void generateInstanceStreamWithGlobalMatrix(
      IProductManagerLocal productService,
      List<PartLink> currentPath,
      Matrix4d matrix,
      VirtualInstanceCollection virtualInstanceCollection,
      List<Integer> instanceIds,
      JsonGenerator jg) {
    try {

      PartLink partLink = currentPath.get(currentPath.size() - 1);
      PSFilter filter = virtualInstanceCollection.getFilter();
      List<PartIteration> filteredPartIterations = filter.filter(partLink.getComponent());

      if (!filteredPartIterations.isEmpty()) {

        PartIteration partI = filteredPartIterations.iterator().next();

        // Filter ACL on part
        if (!productService.canAccess(partI.getPartRevision().getKey())) {
          return;
        }

        for (CADInstance instance : partLink.getCadInstances()) {

          List<Integer> copyInstanceIds = new ArrayList<>(instanceIds);
          copyInstanceIds.add(instance.getId());

          Vector3d instanceTranslation =
              new Vector3d(instance.getTx(), instance.getTy(), instance.getTz());
          Vector3d instanceRotation =
              new Vector3d(instance.getRx(), instance.getRy(), instance.getRz());
          Matrix4d combinedMatrix =
              combineTransformation(matrix, instanceTranslation, instanceRotation);

          if (!partI.isAssembly() && !partI.getGeometries().isEmpty()) {
            writeLeaf(currentPath, copyInstanceIds, partI, combinedMatrix, jg);
          } else {
            for (PartLink subLink : partI.getComponents()) {
              List<PartLink> subPath = new ArrayList<>(currentPath);
              subPath.add(subLink);
              generateInstanceStreamWithGlobalMatrix(
                  productService,
                  subPath,
                  combinedMatrix,
                  virtualInstanceCollection,
                  copyInstanceIds,
                  jg);
            }
          }
        }
      }

    } catch (UserNotFoundException
        | UserNotActiveException
        | WorkspaceNotFoundException
        | PartRevisionNotFoundException e) {
      e.printStackTrace();
    }
  }