Transcript pps

Irit Solid Modeler
Computer Graphics
1
Introduction
Irit is a set of tools to model geometrical
objects.
 It can generate:

 Polylines,
polygons, bezier and bspline curves
 Polygonal, bezier and bspline surfaces
 Volumes of hyper surfaces
Computer Graphics
2
Computer Graphics
3
Irit Parser

Object Structure:
IPobj
Pnext
IPObjectStruct
Pnext
Pnext
IPobj
IPobj
IPobj ...
...
U
IPPoly
IPVertex
IPPoly
...
...
IPPolygonStruct
...
IPPoly
IPVertex
Computer Graphics
IPVertexStruct... ...
IPVertex ...
NULL
4
IPObjectStruct
(Defined in iritprsr.h)
typedef struct IPObjectStruct {
struct IPObjectStruct *Pnext;
/* To next in chain. */
struct IPAttributeStruct *Attrs;
char Name[OBJ_NAME_LEN]; /* Name of object. */
IPObjStructType ObjType /* Object Type: Numeric, Geometric, etc. */
ByteType Count;
/* Count Number of references to this object. */
unsigned int Tags;
/* Some attributes. */
union {
IPPolygonStruct *Pl;
/* Polygon/line list. */
CagdCrvStruct *Crvs;
/* Free form curve(s). */
CagdSrfStruct *Srfs;
/* Free form surface(s). */
TrimSrfStruct *TrimSrfs;
/* Free form trimmed surface(s). */
TrivTVStruct *Trivars;
/* Free form trivariate(s). */
Computer Graphics
5
IPObjectStruct - Cont.
RealType R;
/* Numeric real data.
PointType Pt;
/* Numeric real point data.
VectorType Vec;
/* Numeric real vector data.
PlaneType Plane;
/* Numeric real plane data.
CagdCtlPtStruct CtlPt;
/* Control point data.
MatrixType *Mat;
/* Numeric 4 by 4 transformation matrix.
struct {
struct IPObjectStruct **PObjList;
/* List of objects.
int ListMaxLen;
/* Maximum number of elements in list.
} Lst;
char *Str;
/* General string for text object.
VoidPtr *VPtr;
} U;
} IPObjectStruct;
Computer Graphics
*/
*/
*/
*/
*/
*/
*/
*/
*/
6
IPPolygonStruct
(Defined in iritprsr.h)
typedef struct IPPolygonStruct {
struct IPPolygonStruct *Pnext;
struct IPAttributeStruct *Attrs;
VoidPtr PAux;
int IAux, IAux2;
PlaneType Plane;
BBoxType BBox;
IPVertexStruct *PVertex;
ByteType Count, Tags;
} IPPolygonStruct;
/* To next in chain. */
/* Holds Plane as Ax + By + Cz + D. */
/* BBox of polygons. */
/* To vertices list. */
/* Some attributes. */
Computer Graphics
7
Important facts

Every polygon has a field named plane
(coefficients a,b,c,d). You can use the vector
(a b c) as the unit normal vector of the
polygon.
 Be
careful: for many models the normals seem to be
inverted ...
 Normals point into the object, in general.

You can’t rely on having the normal for every
polygon. you can verify this by using the macro:
 IP_HAS_PLANE_POLY(Poly)

If TRUE then the normal is provided. Otherwise,
you should compute
the Graphics
normal using cross
Computer
8
IPVertexStruct
(Defined in iritprsr.h)
typedef struct IPVertexStruct {
struct IPVertexStruct *Pnext;
struct IPAttributeStruct *Attrs;
struct IPPolygonStruct *PAdj;
PointType Coord;
NormalType Normal;
ByteType Count, Tags;
} IPVertexStruct;


/* To next in chain. */
/* To adjacent polygon. */
/* Holds X, Y, Z coordinates. */
/* Hold Vertex normal into the solid. */
/* Some attributes. */
To verify the existence of the normal, you can use:
 IP_HAS_NORMAL_VRTX(Vrtx)
You can also use IritPrsrSetPolyListCirc(int) to choose
whether vertex list in polygons will be circular. Default is
non circular.
Computer Graphics
9
Irit Data Files

A Polygonal object in Irit is described as
follows:
[OBJECT [Attr] Object_name
[POLYGON [Attr] nb_of_edges
[ [Optional Normal] Points_coordinates]
[ [Optional Normal] Points_coordinates]
[ [Optional Normal] Points_coordinates]
]
]
Computer Graphics
10
Irit Data Files - Cont.

Example:
[OBJECT [COLOR 4] SQUARE
[POLYGON [PLANE 0 0 1 0] 4
[2 2 0]
[ 2 -2 0 ]
[-2 -2 0 ]
[-2 2 0 ]
]
]
Computer Graphics
11
Bezier/Bspline Surfaces

An object in Irit can also be described as a Bezier
or Bspline surface:
[OBJECT [Options] ObjectName
[SURFACE BEZIER order_u order_v tp]
[CtrPoint]
[CtrPoint]
...
[CtrPoint]
]
]
Computer Graphics
12
Example
[Object NONAME
[SURFACE BEZIER 3 3 E3
[0
0
0]
[0.05 0.2 0.1]
[0.1 0.05 0.2]
[0.1 -0.2 0]
[0.15 0.05 0.1]
[0.2 -0.1 0.2]
[0.2 0 0]
[0.25 0.2 0.1]
[0.3 0.05 0.2]
]
]
Computer Graphics
13
Output
Computer Graphics
14
Irit Data Files - Cont.

Each file may have it’s own orientation. In
order to do this, one uses a matrix:
[OBJECT VIEW_MAT
[MATRIX
matrix_4X4
]
]
Computer Graphics
15
Irit Data Files - Cont.

Example:
[OBJECT VIEW_MAT
[MATRIX
2000
0200
0020
0001
]
]
Computer Graphics
16
Irit Data Files - Cont.

After loading a data file, the parser updates the
following global variables:
 extern
MatrixType
IritPrsrViewMat,
IritPrsrPrspMat;
IritPrsrWasViewMat,
IritPrsrWasPrspMat;
 extern
int
Computer Graphics
17
Irit Data Parser
IPObjectStruct *IritPrsrGetDataFiles


(char **DataFileNames,
int NumOfDataFiles,
int Messages,
int MoreMessages);
Reads data from a set of files specified by file names.
Messages and MoreMessages control the level of printouts
to stderr.
Freeform geometry read in is handed out to a call back
function named IritPrsrProcessFreeForm before it is
returned from this routine.
Computer Graphics
18
Irit Data Parser - Cont.


This is done so applications that do not want to deal with
freeform shapes will be able to provide a call back that
processes the freeform shapes into other geometry such as
polygons.
Parameter:

DataFileNames: Array of strings (file names) to process.

NumOfDataFiles: Number of elements in DataFileNames.
Messages: Do we want error messages?
MoreMessages: Do we want informative messages?



Returned value:

IPObjectStruct *: Objects read from all files.
Computer Graphics
19
Irit Data Parser - Cont.
typedef struct IritPrsrFreeFormStruct {
IPObjectStruct *CrvObjs;
IPObjectStruct *SrfObjs;
IPObjectStruct *TrimSrfObjs;
IPObjectStruct *TrivarObjs;
IPObjectStruct *TriSrfObjs;
IPObjectStruct *ModelObjs;
IPObjectStruct *MultiVarObjs;
} IritPrsrFreeFormStruct;
IPObjectStruct
*IritPrsrProcessFreeForm(IritPrsrFreeFormStruct *FreeForms);
Computer Graphics
20
Irit Data Parser - Cont.
IPPolygonStruct *IritSurface2Polygons(CagdSrfStruct *Srf,
int FourPerFlat,
RealType FineNess,
int ComputeUV,
int ComputeNrml,
int Optimal);
 Routine to approximate a single surface by polygons
 parameters:


Srf: To approximate using polygons.
FourPerFlat: If TRUE, four triangle per flat surface patch are
created, otherwise only two.
Computer Graphics
21
Irit Data Parser - Cont.





FineNess: Fineness control on polygonal approximation. The
larger this number is the finer the approximation becomes. 10 is a
good compromise when Optimal is FALSE.
ComputeUV: Do we want UV parameter values with the vertices
of the triangles?
ComputeNrml: Do we want normals to vertices!?
Optimal: If non zero then parametric space of Srf is sampled,
optimally, otherwise uniformely.
Returned value:

IPPolygonStruct *: Resulting polygons that approximates Srf.
Computer Graphics
22
Using Irit at home


First you should get the Irit source files from the web. You
can find it in:
 The home page of the course (2 downloadable files)
 The NT systems
If you wish to recompile Irit:





Start a shell window (dos window)
Execute a file called vcvars32.bat (located in the bin directory of
the developer studio installation).
Update makeflag.wnt (located in the root directory of irit’s
sources). You should update “SRC_DIR = ….” to what you have.
Execute ‘nmake -f makefile.wnt’
You can also obtain Irit (compiled) from the Faculty CD.
Computer Graphics
23
Creating a project

For the home exercises, you will be provided a makefile. If
you wish to compile from the Visual’s interface, then
update the project according to the makefile.
Computer Graphics
24