INTERFACE Tridimensional; (* This interface contain procedures that Write/Read one tridimensional state (.st33) and compute some 3D geometric operations. Also we include some procedures defined by R. L. W. S. and slightly modified in her tools "Animacao Dinamica de Corpos Elasticos". See the copyright and authorship futher down. Last modification : 19-02-2000 *) IMPORT LR3, Triangulation, LR3x3, Rd, Wr; FROM Triangulation IMPORT Topology; (* types for use with the R.L.W.L. procedures *) TYPE Tetrahedron = RECORD p0, p1, p2, p3: CARDINAL; A: LR3x3.T; density, alpha, beta: LONGREAL; END; Vertex = LR3.T; Vectors3D = REF ARRAY OF LR3.T; TYPE Coord3D = ARRAY OF LR3.T; PROCEDURE Barycenter3D( READONLY top: Topology; READONLY c3: Coord3D; ): LR3.T; (* Returns the barycenter of all existing vertices. *) PROCEDURE Displace3D( READONLY top: Topology; d: LR3.T; VAR c3: Coord3D; ); (* Displaces all existing vertices by "d". *) PROCEDURE Scale3D( READONLY top: Topology; s: LONGREAL; VAR c3: Coord3D; ); (* Scales the coordinates of all existing vertices by "s". *) PROCEDURE MeanVertexDistance3D( READONLY top: Topology; READONLY c3: Coord3D; ): LONGREAL; (* The average distance of existing vertices from the origin, in the root-mean-square sense; that is, "sqrt(sum(norm(c3[v])^2, v IN VExist)) /|VExist|)". *) PROCEDURE NormalizeVertexDistance3D( READONLY top: Topology; VAR c3: Coord3D; ); (* Shifts and scales all existing vertices so that they have barycenter (0,0,0) and unit mean square distance from the origin. *) PROCEDURE WriteState3D( name: TEXT; READONLY top: Topology; READONLY c: Coord3D; comments: TEXT := " "; ); (* Writes the coordinates geometrics to file disk in a format that can be read back. The file will have the given "name" with ".st3" appended. *) PROCEDURE ReadState3D(name: TEXT): REF Coord3D; (* Reads a disk file created by "WriteState3D". The file must have the given "name" with ".st3" appended. *) (* procedures associated to the R.L.W.L.'s tools *) PROCEDURE ReadHeader(rd: Rd.T; type, param: TEXT := NIL): CARDINAL RAISES {Rd.EndOfFile}; (* Similar procedure to "FileFmt.ReadHeader". *) PROCEDURE ReadFooter(rd: Rd.T; type: TEXT); (* Similar procedure to "FileFmt.ReadFooter". *) PROCEDURE ReadVectors(rd: Rd.T; n: CARDINAL; pos: Vectors3D); (* Allow to read one array of LR3.T. *) PROCEDURE WriteStates( wr: Wr.T; time: LONGREAL; READONLY vertex: ARRAY OF Vertex; (* Vertex coordinates *) prec: CARDINAL := 4; comments: TEXT := " "; ); (* Writes the 3D states (".sts") *) PROCEDURE WriteTetrahedra( name: TEXT; READONLY top: Topology; READONLY cell: ARRAY OF Tetrahedron; comments: TEXT := " "; ); (* Write the tetrahedra format (".te") *) PROCEDURE ReadTetrahedron(rd: Rd.T; VAR t: Tetrahedron); (* Read a disk file created by "WriteTetrahedra". *) PROCEDURE WriteHeader(wr: Wr.T; type, param: TEXT := NIL; n: CARDINAL := 0); (* Similar procedure to "FileFmt.WriteHeader". *) END Tridimensional. (**************************************************************************) (* *) (* Copyright (C) 2000 Universidade Estadual de Campinas (UNICAMP) *) (* *) (* Authors: *) (* L. P. Lozada & J. Stolfi - UNICAMP *) (* *) (* This file can be freely used, distributed, and modified, provided that *) (* this copyright and authorship notice is included in every copy or *) (* derived version. *) (* *) (* DISCLAIMER: This software is offered ``as is'', without any guarantee *) (* as to fitness for any particular purpose. Neither the copyright *) (* holder nor the authors or their employers can be held responsible *) (* for any damages that may result from its use. *) (* *) (**************************************************************************)