240 likes | 244 Views
Irit Solid Modeler. 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. Irit Parser. IPObjectStruct. Object Structure:. Pnext. Pnext. Pnext.
E N D
Irit Solid Modeler Computer Graphics
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
Irit Parser IPObjectStruct • Object Structure: Pnext Pnext Pnext ... IPobj IPobj IPobj IPobj ... ... ... U IPPolygonStruct ... IPPoly IPPoly IPPoly ... IPVertexStruct ... ... IPVertex IPVertex IPVertex NULL Computer Graphics
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
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
IPPolygonStruct (Defined in iritprsr.h) typedef struct IPPolygonStruct { struct IPPolygonStruct *Pnext; /* To next in chain. */ struct IPAttributeStruct *Attrs; VoidPtr PAux; int IAux, IAux2; PlaneType Plane; /* Holds Plane as Ax + By + Cz + D. */ BBoxType BBox; /* BBox of polygons. */ IPVertexStruct *PVertex; /* To vertices list. */ ByteType Count, Tags; /* Some attributes. */ } IPPolygonStruct; Computer Graphics
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 normal using cross product. Computer Graphics
IPVertexStruct (Defined in iritprsr.h) typedef struct IPVertexStruct { struct IPVertexStruct *Pnext; /* To next in chain. */ struct IPAttributeStruct *Attrs; struct IPPolygonStruct *PAdj; /* To adjacent polygon. */ PointType Coord; /* Holds X, Y, Z coordinates. */ NormalType Normal; /* Hold Vertex normal into the solid. */ ByteType Count, Tags; /* Some attributes. */ } IPVertexStruct; • 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
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
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
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
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
Output Computer Graphics
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
Irit Data Files - Cont. • Example: • [OBJECT VIEW_MAT • [MATRIX • 2 0 0 0 • 0 2 0 0 • 0 0 2 0 • 0 0 0 1 • ] • ] Computer Graphics
Irit Data Files - Cont. • After loading a data file, the parser updates the following global variables: • extern MatrixType IritPrsrViewMat, IritPrsrPrspMat; • extern int IritPrsrWasViewMat, IritPrsrWasPrspMat; Computer Graphics
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
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
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
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
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
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
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