\documentclass[12pt]{beamer}
\input{BEAMERoptions.tex}

\usepackage[english]{babel}
\usepackage{graphics}
\usepackage{times}
\usepackage{graphicx}
\usepackage{epsfig}
\usepackage{subfigure}
\usepackage{textpos}
\usepackage{color}
\usepackage{listings}
\usepackage{fancyvrb}
\usepackage{tikz}
   \usetikzlibrary{shapes, arrows, shadows, calc}
   

\newcommand{\Frametitle}[1]{\frametitle{\includegraphics[width=0.25in]{esp_logo.png}
      \hspace{0.05in} #1}}
\newcommand{\FrameTitle}[1]{\frametitle{\includegraphics[width=0.3in]{caps_logo.png}
      \hspace{0.05in} #1}}

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered]

\title[Programming {\tt ESP} Plugins -- Overview]{
  \includegraphics[width=1.0in]{esp_logo.png}\\
  A Programmer's Training for \\
  {\tt ESP} UDPs, UDFs and {\tt CAPS}' AIMs\\
  The Engineering Sketch Pad -- Rev 1.28
%  An Overview
  }
\author[Haimes \& Dannenhoffer]{
Bob Haimes \\[-0.03in]
  {\footnotesize \textcolor{blue}{bob@geocentrictech.com}~~or~~\textcolor{blue}{haimes@mit.edu}}\\[-0.02in]
  {\scriptsize and}\\[-.02in]
John F. Dannenhoffer, III \\
 {\footnotesize \textcolor{blue}{john@geocentrictech.com} \\
   Geocentric Technologies LLC}
}
 \date[July 2025]{}

\begin{document}

\begin{frame}
\vspace{-0.1in}
  \titlepage
\end{frame}

\begin{frame}
  \Frametitle{Prerequisites for this Training}
  
  \begin{itemize}
  \item You are a {\bf C/C++} programmer
  \item You are here with a laptop containing:
  \begin{itemize}
  \item {\bf C} \& {\bf C++} (and optionally FORTRAN) compilers
  \item {\tt ESP} Rev 1.28 (or a recent 1.28 Beta)
  \item OpenCASCADE 7.8.1 (from {\tt HTTP://acdl.mit.edu/ESP} or a PreBuilt distribution)
  \item A functioning Python at 3.12.10 or higher\\
  If from {\tt HTTP://acdl.mit.edu/ESP} -- Run the install script and 
         make this the default Python in the shell/command-prompt used 
         for {\tt ESP} development
  \end{itemize}
  \item {\tt ESP} successfully built (and run) from source
  \vspace{0.075in}
  \item A desire to write an {\tt ESP} UDF/UFD and/or an AIM (and
    hopefully in idea for one that you would like to work on!)
  \end{itemize}
  
  \center
  \bf If any item above is not true -- you do not belong here!
  
  \end{frame}
  
\begin{frame}
  \Frametitle{{\tt ESP/CAPS} Plugin Training Team}
  
 \center
{\large Bob Haimes} \\
  {\footnotesize \textcolor{blue}{bob@geocentrictech.com}~~or~~\textcolor{blue}{haimes@mit.edu}}
  
 \vspace{0.3in}
{\large John F. Dannenhoffer, III} \\
  {\footnotesize \textcolor{blue}{john@geocentrictech.com}~~or~~\textcolor{blue}{jfdannen@syr.edu}}
  
 \vspace{0.3in}
{\large Nitin Bhagat} \\
  {\footnotesize \textcolor{blue}{nbhagat1@udayton.edu}}

\end{frame}
  
   \begin{frame}
  \FrameTitle{{\tt ESP}'s Software Guiding Principles}
  
  \vspace{-0.05in}
\begin{block}{Ideally a software system should:}
\begin{itemize}
\item Work for user, not the user working for the system
\item Be based on a mental model that is {\it easy} for the user to grasp 
\item Never lose anything they have done (backward compatibility) 
\item Solve the user's {\bf real} problem, not their stated request
\item Be responsive to the changing needs of the users
\item Never surprise the user
\item Not be reverse-engineered
\item Be tested thoroughly
\end{itemize}
\end{block}

 \vspace{-0.05in}
\begin{block}{This means that:}
\begin{itemize}
\item The programmer {\it takes a hit} so that the user's life is easier
\end{itemize}
\end{block}

  \vspace{-0.05in}
\center {\bf We do not always succeed!}

\end{frame}

\begin{frame}
  \Frametitle{{\tt ESP} In Isolation}

\vspace{-0.025in}
\begin{block}{{\tt ESP} {\bf is:}}
    \begin{itemize}
    \item a parametric geometry creation and manipulation system designed
      to {\bf fully support} the analysis and design of aerospace vehicles ({\bf aCAD+})
    \item a stand-alone system for the development of geometric models
    \item an API can be embedded into other software systems to
      support their geometric and process needs (e.g., {\tt CAPS})
     \item extensible so that users can add their own geometric {\it features}
    \end{itemize}
   \end{block}

\vspace{-0.025in}
 \begin{block}{{\tt ESP} {\bf is not:}}
    \begin{itemize}
    \item a full-featured mechanical computer-aided design ({\bf mCAD}) system
    \item a system to be used for creating ``drawings''
    \end{itemize}
  \end{block}
\end{frame}

\begin{frame}
  \Frametitle{{\tt CAPS} which includes {\tt ESP}}

\vspace{-0.025in}
\begin{block}{{\tt CAPS} {\bf is:}}
    \begin{itemize}
    \item a software system that allows for building complex workflows
    \item a system that supports multidisciplinary and multi-fidelity analyses with direct access to geometry and its attribution
    \item a system that simplifies inter-analysis communication
    \item an API that provides access to sensitivities (supports gradient-based optimization) 
    \item software designed for aircraft design settings
     \item extensible so that additional analyses can be supported
    \end{itemize}
   \end{block}

\vspace{-0.025in}
 \begin{block}{{\tt CAPS} {\bf is not:}}
    \begin{itemize}
    \item an MDO Framework (but can support them)
    \end{itemize}
  \end{block}
\end{frame}


\begin{frame}
  \Frametitle{Extensible Software}
  
  Programmers can add functionality to {\tt ESP} in the following ways:
  
  \begin{itemize}
  \item User-Defined Primitives (UDPs)
  \begin{itemize}
  \item Create and returns an {\tt EGADS} Body (usually a {\it Solid}) to be placed on the {\tt CSM} stack
  \end{itemize}
  \item User-Defined Functions (UDFs)
  \begin{itemize}
  \item Has access to other Bodies on the {\tt CSM} stack
  \item Usually creates a new {\tt EGADS} Body through some form of manipulation and add back to the stack
  \end{itemize}
  \item Analysis Interface Modules (AIMs)
  \begin{itemize}
  \item Interface between the {\tt CAPS} infrastructure and any Analysis \& Meshing codes
  \item Provides the ability to generate Analysis/Meshing inputs, perform execution and then access
  the results
  \item AIM {\it Mesh Writers} are also handled in a similar manner
  \end{itemize}
  \end{itemize}
  
  \vspace{-0.075in}
  \center {\bf All are dynamically loaded at run-time}
  
  \end{frame}

\begin{frame}
  \Frametitle{{\tt ESP} with {\tt CAPS}}

  % procedure that is part of CAPS
  \tikzstyle{iproc} = [rectangle,
                       draw,
                       fill=blue!15,
                       thick,
                       inner sep=0pt,
                       minimum width=15mm,
                       minimum height=15mm,
                       align=center]
 \tikzstyle{oproc} = [rectangle,
                       draw,
                       fill=blue!40,
                       thick,
                       inner sep=0pt,
                       minimum width=15mm,
                       minimum height=10mm,
                       align=center]
  % procedure that is external to CAPS
  \tikzstyle{eproc} = [rectangle,
                       draw,
                       fill=orange!20,
                       thick,
                       inner sep=0pt,
                       minimum width=15mm,
                       minimum height=15mm,
                       align=center]
  % file or database
  \tikzstyle{disc}  = [cylinder,
                       shape border rotate=90,
                       aspect=0.25,
                       draw,
                       fill=green!20,
                       thick,
                       inner sep=0pt,
                       minimum width=15mm,
                       minimum height=15mm,
                       align=center]
  % link between procedures and discs
  \tikzstyle{link}  = [<->,
                       very thick]

  \begin{center}
    \begin{tikzpicture}[font=\scriptsize\sf]
      % picture elements
      \node[oproc,  minimum height=12mm] (ESP)  at (0.43,6.80) {~~~~~ESP~~~~~ \\ UI};
      \node[iproc,  minimum height=12mm] (pyCaps)  at (0.43,5.15) {~~~~pyCAPS~~~~};
      \node[eproc, minimum height=40mm] (framework) at (0.43,2.05) {User \\ \\ -------- \\ \\ MDO \\ ~~Framework~~
                                                                                                               \vspace{0.04in} \\ \tiny \em MSTC Engr \\ \tiny OpenMDAO \\ \tiny \em ~ModelCenter~ \\ \tiny \em ~ModeFRONTIER~ };
      \node[eproc, double copy shadow]  (tools)     at (2.75,0.85) {Analysis \\ tools};
      \node[iproc, minimum height=45mm] (executive) at (2.75,4.35) {Computa- \\ tional \\ Aircraft \\ Prototype \\ Syntheses \\ (CAPS) \\ API};
      \node[disc]                       (probDB)    at (4.75,3.3) {Problem \\ Database};
%   \node[iproc]                      (analysis)  at (4.75,4.35) {Analysis \\ Subsystem};
      \node[oproc, minimum height=28mm]  (geometry)  at (4.75,6.1) {Geometry \\ Subsystem \\ --- \\ OpenCSM \vspace{0.01in} \\ EGADS};
      \node[oproc,]                     (lite) at (10.0,2.0)  {EGADSlite};
      \node[disc,  double copy shadow]  (analIO)    at (6.75,1.25) {Analysis \\ I/O Files};
      \node[iproc, double copy shadow]  (AIM)       at (6.75,4.35) {\textcolor{espred}{Analysis} \\ \textcolor{espred}{Interface} \\ \textcolor{espred}{Module} \\ \textcolor{espred}{(AIM)}};
      \node[iproc, double copy shadow]  (meshW) at (8.85,4.35) {\textcolor{espred}{Mesh} \\ \textcolor{espred}{Writers}};
      \node[disc]                       (geomDB)    at (6.75,6.65) {Geometry \\ Database};

      % links (arrows)
      \draw[link,dotted] (ESP)  to (pyCaps);
      \draw[link,dotted] (1.20,6.95)  to (4.0,6.95);
      \draw[link,dotted] (1.30,0.85)  to (tools);
%   \draw[link,dotted] (framework)  to (tools);
      \draw[link,dotted] (1.30,3.375)  to (2.0,3.375);
%   \draw[link,dotted] (framework)  to (executive);
      \draw[link]         (1.28,5.05) to (2.0, 5.05);
      \draw[link,dotted]        (pyCaps)      to (framework);
      \draw[link]        (3.5,1.2)      to (analIO);
      \draw[link]        (executive)  to (probDB);
%   \draw[link]        (3.50,4.375)  to (analysis);
%   \draw[link]        (executive)  to (analysis);
      \draw[link]        (executive)  to (geometry);
%   \draw[link]        (probDB)     to (analysis);
%   \draw[link]        (analysis)   to (geometry);
%   \draw[link]        (analysis)   to (AIM);
      \draw[link]        (executive) to (AIM);
      \draw[link]        (geometry) to (AIM);
      \draw[link]        (analIO)      to (AIM);
      \draw[link]        (meshW)    to (AIM);
      \draw[<-,very thick]  (AIM) to (6.0,2.4);
      \draw[<-,very thick]  (3.5,1.45) to (6.0,2.4);
      \draw[link]        (geometry)   to (geomDB);
      \draw[<-,very thick, dotted] (5.5,5.75) to (10.0, 5.75);
      \draw[->,very thick, dotted] (10.0, 5.75) to (lite);
      \draw[<-,very thick, dotted] (lite) to (10.0, 0.35);
      \draw[->,very thick, dotted] (10.0, 0.35) to (3.5,0.35);
    \end{tikzpicture}
  \end{center}

  \end{frame}
  
  \begin{frame}
  \Frametitle{{\tt ESP}'s Geometry Subsystem Architecture}

  % procedure that is part of CAPS
  \tikzstyle{iproc} = [rectangle,
                       draw,
                       fill=blue!20,
                       thick,
                       inner sep=0pt,
                       minimum width=15mm,
                       minimum height=15mm,
                       align=center]
    \tikzstyle{oproc} = [rectangle,
                       draw,
                       fill=blue!35,
                       thick,
                       inner sep=0pt,
                       minimum width=15mm,
                       minimum height=15mm,
                       align=center]
  % procedure that is external to CAPS
  \tikzstyle{eproc} = [rectangle,
                       draw,
                       fill=orange!20,
                       thick,
                       inner sep=0pt,
                       minimum width=15mm,
                       minimum height=15mm,
                       align=center]
  % file or database
  \tikzstyle{disc}  = [cylinder,
                       shape border rotate=90,
                       aspect=0.25,
                       draw,
                       fill=green!20,
                       thick,
                       inner sep=0pt,
                       minimum width=15mm,
                       minimum height=15mm,
                       align=center]
  % link between procedures and discs
  \tikzstyle{link}  = [<->,
                       very thick]
  \tikzstyle{onedir}  = [->,
                       very thick]

  \begin{center}
    \begin{tikzpicture}[font=\scriptsize\sf]
      % picture elements
      \node[oproc, minimum height=30mm] (ESP) at (-2.5,2.75) { ~Engineering~ \\ Sketch Pad \\ (ESP) \\ UI};
      \node[oproc, minimum height=30mm] (scsm) at (-0.25,2.75) {serveESP};
      \node[oproc]                     (ocsm)   at (1.75,4.0) {OpenCSM};
      \node[oproc]                     (egads)  at (1.75,1.5) {EGADS};
      \node[eproc]                     (occ)      at (4.5,1.5) { ~OpenCASCADE~ };
      \node[oproc, double copy shadow,  minimum height=23mm]  (UDP)  at (4.0,4.0) {\textcolor{espred}{User} \\ \textcolor{espred}{Defined} \\ ~\textcolor{espred}{Primitives \&} ~ \\ \textcolor{espred}{Functions} \\ \textcolor{espred}{(UDPs \&} \\\textcolor{espred}{UDFs)} };
      \node[disc,  minimum height=21mm]   (compDB)    at (3.25,6.6) { ~Configuration~ \\ Database \\ *.csm};
      \node[disc,  minimum height=21mm]   (classDB)     at (1.0,6.6) {User \\ Defined \\ ~Components ~ \\ (UDCs) };

      % links (arrows)
      \draw[link,dotted] (ESP)  to (scsm);
      \draw[link]        (egads)        to (0.5,1.5);
      \draw[link]        (ocsm)         to (0.5,4.0);
      \draw[link]        (ocsm)         to (UDP);
      \draw[link]        (ocsm)         to (egads);
      \draw[link]        (UDP)          to (egads);
      \draw[link]        (egads)        to (occ);
      \draw[onedir]   (compDB)    to (classDB);
      \draw[link]        (compDB)   to (ocsm);
      \draw[link]        (classDB)    to (ocsm);
    \end{tikzpicture}
  \end{center}
\end{frame}


\begin{frame}
  \Frametitle{{\tt ESP} Development Environment}
  
 \begin{block}{Build from source}
 Use the same shell with the same environment as was used for building
 the rest of the system
\end{block}

 \begin{block}{Build from within a PreBuilt distribution}
 Make sure you:
   \begin{itemize}
   \item Have a C/C++ compiler and {\it (N)Make} available in your shell/command-prompt
   \item Set the environment by running:
     \begin{itemize}
     \item MAC/Linux: Double-click on the ESP 1.28 desktop icon\\
     Use the opened window for your development
     \item Windows: Startup a command-prompt that supports Visual Studio\\
     $>$ {\tt cd \%ESP\_ROOT\%}~~~~~~~~(the location of EngSketchPad)\\
     $>$ {\tt ESPenv.bat}
     \end{itemize}
   \end{itemize}
\end{block}

\end{frame}

\begin{frame}
  \Frametitle{How Plugins work}
  
 \begin{block}{Built like a shared library}
\begin{itemize}
\item Windows -- a dynamically loaded library (.DLL)
\item LINUX -- shared object (.so)
\item MAC -- a {\it bundle} -- we use the extension .so
\end{itemize}
\end{block}

 \begin{block}{Loaded at run-time}
   \begin{itemize}
   \item Opened with {\tt LoadLibrary}  / {\tt dlopen}
   \item Function pointers  by name via {\tt GetProcAddress} / {\tt dlsym}
   \item Can have multiple {\it instances}, each may require its own {\it state data}
   \item Called by function pointer and {\it instance} via a dispatch table (i.e., name is only used to retrieve the pointer)
   \item Shared object/DLL not closed so that {\it valgrind} can report symbols
   \end{itemize}
\end{block}

\end{frame}


\begin{frame}
  \Frametitle{Muddy Cards}

\center
  {\bf Of prime importance} -- this is the first training of its kind.\\ We need feedback to improve future versions!\\[0.2in]
  \begin{block}{}
  \begin{itemize}
  \item Opportunity to provide anonymous (or named) immediate feedback for anything ``not clear'' (e.g. muddy)
  \item Ask questions about presentation material, previous exercises, point
      out errors, make suggestions, \ldots
  \item Questions will be answered at next session
  \item E-mail questions (post-training) to any member of the team
  \end{itemize}
  \end{block}
\end{frame}

\begin{frame}
\Frametitle{Plugin Training Sessions}

  \begin{center}
%  \def\arraystretch{0.90}
  \begin{tabular}{r l}
 01 & Plugin Overview~~~~(this session)\\

 02 & {\tt EGADS} -- Programmatic use of Geometry in the Plugins \\

 03  & {\tt OpenCSM} UDP Basics \\

  04  &  {\tt OpenCSM} Full-featured UDP \\

  05  & {\tt OpenCSM} Full-featured UDF  \\

  06  &  {\tt CAPS}' AIM Overview \\

  07  & AIM Software  Structure \\

  08 & AIM Utility Functions \& Tessellations \\

 09 &  AIM Analysis Input, Execution and Output\\
 
 10 &  AIM Sensitivities   \\
 
 11 & AIMs and Units \\
 
 12  & AIM Bounds \& the AIM Discretization Structure  \\
 
 13 & AIM Mesh Writing \\
 
  -- & AIM Documentation, Distribution \& Testing Discussion
 
% --  & Open time for your plugin development~~~~(optional)\\

   \end{tabular}
  \end{center}
  
  \end{frame}
  
  

\end{document}
