def test_set_target_step(self):
     r = self.client.set_target(self.couch_design_step_file)
     self.assertIsNotNone(r, msg="set_target response is not None")
     self.assertEqual(r.status_code, 200, msg="set_target status code")
     response_json = r.json()
     common_test.check_graph_format(self, response_json["data"])
     common_test.check_bounding_box(self, response_json["data"])
     r = self.client.clear()
Exemple #2
0
 def test_graph_per_extrude_labels(self):
     # Reconstruct first
     r = self.client.reconstruct(self.couch_design_json_file)
     r = self.client.graph(format="PerExtrude", sequence=False, labels=True)
     self.assertIsNotNone(r, msg="graph response is not None")
     self.assertEqual(r.status_code, 200, msg="graph status code")
     response_json = r.json()
     common_test.check_graph_format(self,
                                    response_json["data"],
                                    mode="PerExtrude",
                                    labels=True)
     common_test.check_bounding_box(self, response_json["data"])
     r = self.client.clear()
Exemple #3
0
    def test_set_target_add_extrude(self):
        # Set target box
        r = self.client.set_target(self.box_design_smt_file)
        self.assertIsNotNone(r, msg="set_target response is not None")
        self.assertEqual(r.status_code, 200, msg="set_target status code")
        response_json = r.json()
        common_test.check_graph_format(self, response_json["data"])
        common_test.check_bounding_box(self, response_json["data"])

        # Sketch
        r = self.client.add_sketch("XY")
        response_json = r.json()
        sketch_name = response_json["data"]["sketch_name"]
        self.assertIsInstance(sketch_name, str, msg="sketch_name is string")
        pts = [{
            "x": -1,
            "y": 0
        }, {
            "x": 1,
            "y": 0
        }, {
            "x": 1,
            "y": 1
        }, {
            "x": -1,
            "y": 1
        }, {
            "x": -1,
            "y": 0
        }]
        for index in range(4):
            r = self.client.add_line(sketch_name, pts[index], pts[index + 1])
            self.assertEqual(r.status_code, 200, msg="add_line status code")

        response_json = r.json()
        response_data = response_json["data"]
        # Pull out the first profile id
        profile_id = next(iter(response_data["profiles"]))

        # Extrude
        r = self.client.add_extrude(sketch_name, profile_id, 1.0,
                                    "NewBodyFeatureOperation")
        self.assertEqual(r.status_code, 200, msg="add_extrude status code")
        response_json = r.json()
        response_data = response_json["data"]
        common_test.check_extrude_data(self, response_data, has_iou=True)
        self.assertAlmostEqual(response_data["iou"],
                               0.5,
                               places=2,
                               msg="iou ~= 0.5")
        r = self.client.clear()
    def test_set_extrude_reset_extrude(self):
        r = self.client.set_target(self.box_design_smt_file)
        self.assertIsNotNone(r, msg="set_target response is not None")
        self.assertEqual(r.status_code, 200, msg="set_target status code")
        response_json = r.json()
        response_data = response_json["data"]
        graph = response_data["graph"]
        common_test.check_graph_format(self, response_data)

        # Make an extrude
        nodes = graph["nodes"]
        start_face = nodes[0]["id"]
        end_face = nodes[2]["id"]
        r = self.client.add_extrude_by_target_face(start_face, end_face,
                                                   "NewBodyFeatureOperation")
        response_json = r.json()
        response_data = response_json["data"]
        common_test.check_extrude_data(self, response_data, has_iou=True)

        # Revert to target
        r = self.client.revert_to_target()
        self.assertIsNotNone(r, msg="revert_to_target response is not None")
        self.assertEqual(r.status_code,
                         200,
                         msg="revert_to_target status code")
        response_json = r.json()
        response_data = response_json["data"]
        common_test.check_graph_format(self, response_data)
        revert_graph = response_data["graph"]
        self.assertDictEqual(graph,
                             revert_graph,
                             msg="target graph identical if reverted")

        start_face = nodes[0]["id"]
        end_face = nodes[2]["id"]
        r = self.client.add_extrude_by_target_face(start_face, end_face,
                                                   "NewBodyFeatureOperation")
        self.assertIsNotNone(
            r, msg="add_extrude_by_target_face response is not None")
        self.assertEqual(r.status_code,
                         200,
                         msg="add_extrude_by_target_face status code")
        response_json = r.json()
        response_data = response_json["data"]
        common_test.check_extrude_data(self, response_data, has_iou=True)
        self.assertAlmostEqual(response_data["iou"],
                               1,
                               places=4,
                               msg="iou ~= 1")
 def test_set_target_box(self):
     r = self.client.set_target(self.box_design_smt_file)
     self.assertIsNotNone(r, msg="set_target response is not None")
     self.assertEqual(r.status_code, 200, msg="set_target status code")
     response_json = r.json()
     common_test.check_graph_format(self, response_json["data"])
     common_test.check_bounding_box(self, response_json["data"])
     # Check the bounding box result is correct
     bbox = response_json["data"]["bounding_box"]
     maxp = bbox["max_point"]
     minp = bbox["min_point"]
     x = math.fabs(maxp["x"] - minp["x"])
     y = math.fabs(maxp["y"] - minp["y"])
     z = math.fabs(maxp["z"] - minp["z"])
     self.assertAlmostEqual(x, 1, places=2, msg="bbox x ~= 1")
     self.assertAlmostEqual(y, 1, places=2, msg="bbox y ~= 1")
     self.assertAlmostEqual(z, 1, places=2, msg="bbox z ~= 1")
     r = self.client.clear()
Exemple #6
0
    def test_graph_sequence_per_face_labels(self):
        # Reconstruct first
        r = self.client.reconstruct(self.couch_design_json_file)
        # Make the folder
        if not self.test_output_dir.exists():
            self.test_output_dir.mkdir()
        # Save out the graphs
        r = self.client.graph(self.couch_design_json_file,
                              self.test_output_dir,
                              format="PerFace",
                              sequence=True,
                              labels=True)
        self.assertIsNotNone(r, msg="graph response is not None")
        self.assertEqual(r.status_code, 200, msg="graph status code")
        graph_file = self.test_output_dir / f"{self.couch_design_json_file.stem}_0000.json"
        self.assertTrue(graph_file.exists(), msg="graph file exists")
        self.assertGreater(graph_file.stat().st_size,
                           0,
                           msg="graph file size greater than 0")
        common_test.check_graph_format(self,
                                       graph_file,
                                       mode="PerFace",
                                       labels=True)

        graph_file = self.test_output_dir / f"{self.couch_design_json_file.stem}_0001.json"
        self.assertTrue(graph_file.exists(), msg="graph file exists")
        self.assertGreater(graph_file.stat().st_size,
                           0,
                           msg="graph file size greater than 0")
        common_test.check_graph_format(self,
                                       graph_file,
                                       mode="PerFace",
                                       labels=True)

        seq_file = self.test_output_dir / f"{self.couch_design_json_file.stem}_sequence.json"
        self.assertTrue(seq_file.exists(), msg="sequence file exists")
        self.assertGreater(seq_file.stat().st_size,
                           0,
                           msg="sequence file size greater than 0")
        # Clear
        r = self.client.clear()
        if self.clean_output:
            shutil.rmtree(self.test_output_dir)
    def test_add_extrudes_by_target_face_revert(self):
        r = self.client.set_target(self.couch_design_smt_file)
        self.assertIsNotNone(r, msg="set_target response is not None")
        self.assertEqual(r.status_code, 200, msg="set_target status code")
        response_json = r.json()
        response_data = response_json["data"]
        common_test.check_graph_format(self, response_data)

        # Multiple Extrudes
        graph = response_data["graph"]
        nodes = graph["nodes"]
        actions = [{
            "start_face": nodes[0]["id"],
            "end_face": nodes[9]["id"],
            "operation": "NewBodyFeatureOperation"
        }, {
            "start_face": nodes[1]["id"],
            "end_face": nodes[3]["id"],
            "operation": "CutFeatureOperation"
        }]
        r = self.client.add_extrudes_by_target_face(actions)
        response_json = r.json()
        response_data = response_json["data"]
        common_test.check_extrude_data(self, response_data, has_iou=True)
        prev_iou = response_data["iou"]

        # Reconstruct again but revert this time
        r = self.client.add_extrudes_by_target_face(actions, revert=True)
        self.assertIsNotNone(
            r, msg="add_extrudes_by_target_face response is not None")
        self.assertEqual(r.status_code,
                         200,
                         msg="add_extrudes_by_target_face status code")
        response_json = r.json()
        response_data = response_json["data"]
        common_test.check_extrude_data(self, response_data, has_iou=True)
        self.assertEqual(response_data["iou"], prev_iou, msg="iou == prev_iou")