{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.2/review/model-review.schema.json",
  "$comment": "OpenEik 0.2: folded by tools/fold-schemas.mjs from the proposal review, which 0.2 makes a rule (decision D5). Written by hand from the text, not generated.",
  "title": "Model review",
  "description": "A review round on one version of the model, in 3D: project/reviews/<review>.json (Part XVIII, 2. The version by its root tree hash; items on its elements, each seen from a viewpoint; the reviewers, states and decisions of the drawing profile, as a drawing's review has them (Part XIV, 13). A host keeps a round while it is open; at the close the authoring tool saves it into the building.",
  "type": "object",
  "properties": {
    "format": {
      "const": "openeik-model-review/0.1"
    },
    "id": {
      "description": "Unique without coordination across hosts and forks, such as a ULID; never a host's sequence number; the file's name.",
      "$ref": "../drawings/defs.schema.json#/$defs/id"
    },
    "model": {
      "description": "The version reviewed: its id as Part VI, 8.2 names a version (null for a folder under no version control), its root tree hash, and its line of work.",
      "type": "object",
      "properties": {
        "version": {
          "$ref": "../drawings/defs.schema.json#/$defs/version"
        },
        "root": {
          "description": "The version's root tree hash (Part VI, 2, rule 4): what the round reviews.",
          "$ref": "../drawings/defs.schema.json#/$defs/hash"
        },
        "ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        }
      },
      "required": [
        "version",
        "root"
      ],
      "x-eik-closed": true
    },
    "issue": {
      "description": "The issue that released the version, by its id and its record's hash (XVIII.2.5, rule 10).",
      "type": "object",
      "properties": {
        "id": {
          "$ref": "../drawings/defs.schema.json#/$defs/id"
        },
        "hash": {
          "$ref": "../drawings/defs.schema.json#/$defs/hash"
        }
      },
      "required": [
        "id",
        "hash"
      ],
      "x-eik-closed": true
    },
    "compared": {
      "description": "The version the round compared it with.",
      "type": "object",
      "properties": {
        "version": {
          "$ref": "../drawings/defs.schema.json#/$defs/version"
        },
        "root": {
          "$ref": "../drawings/defs.schema.json#/$defs/hash"
        }
      },
      "required": [
        "version",
        "root"
      ],
      "x-eik-closed": true
    },
    "profile": {
      "$ref": "../drawings/review.schema.json#/properties/profile"
    },
    "opened": {
      "$ref": "../drawings/review.schema.json#/$defs/act"
    },
    "due": {
      "$ref": "../drawings/defs.schema.json#/$defs/date"
    },
    "closed": {
      "description": "Absent while open. A closed review is frozen (XVIII.2.5, rule 5).",
      "$ref": "../drawings/review.schema.json#/$defs/act"
    },
    "reviewers": {
      "type": "array",
      "maxItems": 1000,
      "items": {
        "$ref": "../drawings/review.schema.json#/$defs/reviewer"
      }
    },
    "items": {
      "type": "array",
      "maxItems": 100000,
      "items": {
        "$ref": "#/$defs/item"
      }
    }
  },
  "required": [
    "format",
    "id",
    "model",
    "profile",
    "opened",
    "reviewers",
    "items"
  ],
  "x-eik-closed": true,
  "$defs": {
    "item": {
      "description": "An item of a model review (XVIII.2.2): Part XIV, 13.2's members that do not depend on paper, with anchors on elements, a viewpoint and a shape in 3D.",
      "type": "object",
      "properties": {
        "id": {
          "$ref": "../drawings/review.schema.json#/$defs/item/properties/id"
        },
        "kind": {
          "$ref": "../drawings/review.schema.json#/$defs/item/properties/kind"
        },
        "author": {
          "$ref": "../drawings/review.schema.json#/$defs/author"
        },
        "at": {
          "description": "When it was made.",
          "$ref": "../drawings/defs.schema.json#/$defs/time"
        },
        "text": {
          "$ref": "../drawings/review.schema.json#/$defs/item/properties/text"
        },
        "replies": {
          "$ref": "../drawings/review.schema.json#/$defs/item/properties/replies"
        },
        "state": {
          "description": "A code of the profile's reviewStates.",
          "$ref": "../drawings/defs.schema.json#/$defs/code"
        },
        "history": {
          "$ref": "../drawings/review.schema.json#/$defs/item/properties/history"
        },
        "anchors": {
          "type": "array",
          "maxItems": 20,
          "items": {
            "description": "An anchor, tried in order: an element of the reviewed version, the hash of its record there, and a point on it.",
            "type": "object",
            "properties": {
              "element": {
                "description": "An element of the model at the reviewed version, by its id.",
                "type": "string",
                "minLength": 1,
                "x-eik-ref": "element"
              },
              "hash": {
                "description": "The hash of the element's record at the reviewed version (Part III, 6).",
                "$ref": "../drawings/defs.schema.json#/$defs/hash"
              },
              "point": {
                "description": "A point on it, in mm of the model.",
                "$ref": "../drawings/defs.schema.json#/$defs/point3"
              }
            },
            "required": [
              "element"
            ],
            "x-eik-closed": true
          }
        },
        "viewpoint": {
          "description": "Where an item is seen from (XVIII.2.3): a camera, and a section where there is one.",
          "type": "object",
          "properties": {
            "camera": {
              "description": "The camera, in mm of the model, Z up (XVIII.2.3). A perspective camera gives its vertical field of view, an orthographic one the height of what it shows (XVIII.2.5, rule 7). A direction and an up that are zero or parallel are refused in code.",
              "type": "object",
              "properties": {
                "projection": {
                  "type": "string",
                  "enum": [
                    "perspective",
                    "orthographic"
                  ]
                },
                "position": {
                  "$ref": "../drawings/defs.schema.json#/$defs/point3"
                },
                "direction": {
                  "description": "Where it looks: a direction only, which a reader uses as a unit vector.",
                  "$ref": "../drawings/defs.schema.json#/$defs/point3"
                },
                "up": {
                  "description": "Which way is up in the picture: not zero, nor parallel to direction.",
                  "$ref": "../drawings/defs.schema.json#/$defs/point3"
                },
                "fieldOfView": {
                  "description": "A perspective camera's vertical field of view, in degrees.",
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "exclusiveMaximum": 180
                },
                "height": {
                  "description": "An orthographic camera's height of view, in mm of the model.",
                  "type": "number",
                  "exclusiveMinimum": 0
                },
                "aspect": {
                  "description": "The picture's width over its height, as the reviewer saw it.",
                  "type": "number",
                  "exclusiveMinimum": 0
                }
              },
              "required": [
                "projection",
                "position",
                "direction",
                "up"
              ],
              "allOf": [
                {
                  "if": {
                    "properties": {
                      "projection": {
                        "const": "perspective"
                      }
                    },
                    "required": [
                      "projection"
                    ]
                  },
                  "then": {
                    "required": [
                      "fieldOfView"
                    ],
                    "not": {
                      "required": [
                        "height"
                      ]
                    }
                  }
                },
                {
                  "if": {
                    "properties": {
                      "projection": {
                        "const": "orthographic"
                      }
                    },
                    "required": [
                      "projection"
                    ]
                  },
                  "then": {
                    "required": [
                      "height"
                    ],
                    "not": {
                      "required": [
                        "fieldOfView"
                      ]
                    }
                  }
                }
              ],
              "x-eik-closed": true
            },
            "section": {
              "description": "What the viewpoint cuts away: 1 to 6 planes, or a box.",
              "type": "object",
              "properties": {
                "planes": {
                  "type": "array",
                  "minItems": 1,
                  "maxItems": 6,
                  "items": {
                    "description": "A plane that hides what lies on the side its normal points to.",
                    "type": "object",
                    "properties": {
                      "point": {
                        "$ref": "../drawings/defs.schema.json#/$defs/point3"
                      },
                      "normal": {
                        "description": "Not zero: it points to the side the plane hides, as a BCF clipping plane's direction does.",
                        "$ref": "../drawings/defs.schema.json#/$defs/point3"
                      }
                    },
                    "required": [
                      "point",
                      "normal"
                    ],
                    "x-eik-closed": true
                  }
                },
                "box": {
                  "description": "A box whose sides run along the model's axes: what lies outside it is cut away. Its min is below its max on each axis (XVIII.2.5, rule 8), which a validator checks in code.",
                  "type": "object",
                  "properties": {
                    "min": {
                      "$ref": "../drawings/defs.schema.json#/$defs/point3"
                    },
                    "max": {
                      "$ref": "../drawings/defs.schema.json#/$defs/point3"
                    }
                  },
                  "required": [
                    "min",
                    "max"
                  ],
                  "x-eik-closed": true
                }
              },
              "oneOf": [
                {
                  "required": [
                    "planes"
                  ]
                },
                {
                  "required": [
                    "box"
                  ]
                }
              ],
              "x-eik-closed": true
            }
          },
          "required": [
            "camera"
          ],
          "x-eik-closed": true
        },
        "shape": {
          "description": "In mm of the model: a cloud's, an arrow's, a highlight's or a measure's geometry, or the frame of a text's or a comment's words; a measure's value is derived, the length along its points. form as Part XIV, 13.2 says, checked in code (XVIII.2.5, rule 9).",
          "type": "object",
          "properties": {
            "points": {
              "type": "array",
              "minItems": 1,
              "maxItems": 10000,
              "items": {
                "$ref": "../drawings/defs.schema.json#/$defs/point3"
              }
            },
            "closed": {
              "type": "boolean"
            },
            "form": {
              "$ref": "../drawings/defs.schema.json#/$defs/shapeForm"
            }
          },
          "required": [
            "points"
          ],
          "x-eik-closed": true
        },
        "carriedFrom": {
          "description": "The item of an earlier round it carries forward: a model review's or a drawing review's.",
          "$ref": "../drawings/review.schema.json#/$defs/item/properties/carriedFrom"
        },
        "bcf": {
          "$ref": "../drawings/review.schema.json#/$defs/item/properties/bcf"
        },
        "attachments": {
          "$ref": "../drawings/review.schema.json#/$defs/item/properties/attachments"
        }
      },
      "required": [
        "id",
        "kind",
        "author",
        "at",
        "state",
        "anchors",
        "viewpoint"
      ],
      "x-eik-closed": true
    }
  }
}
