{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "# 02. Geometry and Construction\n\nBuild a rectangle and a small solid, then translate a second solid and combine them.\n\n**Goal:** Complete one small workflow. Run the cells from top to bottom in a fresh kernel.\n\n**Extra dependencies:** None beyond the base environment.\n\nAll examples use metres unless stated otherwise.\n",
   "id": "tutorial-02-00"
  },
  {
   "cell_type": "code",
   "metadata": {},
   "source": "import os\nos.environ[\"TOPOLOGICPY_CORE_BACKEND\"] = \"pythonocc\"\n\nimport topologicpy\nfrom topologicpy.Core import Core\n\nassert topologicpy.__version__ == \"0.9.86\", \"Use TopologicPy 0.9.86 for these tutorials.\"\nassert type(Core.Backend()).__name__ == \"PythonOCCBackend\", \"Restart with the pythonocc backend.\"\nprint(\"TopologicPy\", topologicpy.__version__, \"—\", type(Core.Backend()).__name__)\n",
   "outputs": [],
   "execution_count": null,
   "id": "tutorial-02-01"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## From surfaces to solids\n\nA face is a surface; a cell encloses a volume. The default prism placement is centred on its origin.\n",
   "id": "tutorial-02-02"
  },
  {
   "cell_type": "code",
   "metadata": {},
   "source": "from topologicpy.Face import Face\nfrom topologicpy.Cell import Cell\nfrom topologicpy.Topology import Topology\n\nfloor = Face.Rectangle(width=4, length=3)\nroom = Cell.Prism(width=4, length=3, height=2)\nprint(\"Floor area:\", Face.Area(floor))\nprint(\"Room volume:\", Cell.Volume(room))\nassert Face.Area(floor) == 12\nassert Cell.Volume(room) == 24\n",
   "outputs": [],
   "execution_count": null,
   "id": "tutorial-02-03"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Translate and combine\n\nThese two boxes overlap by one metre along X. A union removes the internal overlap. More advanced construction can assemble touching cells into a cell complex.\n",
   "id": "tutorial-02-04"
  },
  {
   "cell_type": "code",
   "metadata": {},
   "source": "extension = Topology.Translate(room, x=3)\ncombined = Topology.Union(room, extension)\nprint(\"Result type:\", Topology.TypeAsString(combined))\nprint(\"Combined volume:\", Cell.Volume(combined))\nassert Cell.Volume(combined) == 42\n",
   "outputs": [],
   "execution_count": null,
   "id": "tutorial-02-05"
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": "## Try it yourself\n\nChange the translation to 2 metres. What volume do you expect?\n",
   "id": "tutorial-02-06"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (TopologicPy tutorials)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
