/*------------------------------------\
|  Liberally adpated From:
|  volInt.c
|
|  This code computes volume integrals needed for
|  determining mass properties of polyhedral bodies.
|
|  Brian Mirtich, "Fast and Accurate Computation of
|  Polyhedral Mass Properties," journal of graphics
|  tools, volume 1, number 2, 1996.
|
|  This source code is public domain, and may be used
|  in any way, shape or form, free of charge.
|
|  Copyright 1995 by Brian Mirtich
|
|  mirtich@cs.berkeley.edu
|  http://www.cs.berkeley.edu/~mirtich
|
+--------------------------------------
| Rewritten by Adam Freidin to take advantage of his
| vector library, and optimized a bit more
|     Jan 2002
|
| Redesigned to be usefull
|    -Adam Freidin, Jan 2002.
| 
| Don't ask me about the algorithm math, I just used Brian's code
|  and cleaned up the API.
|
\--------------------------------------*/

/*--------------------------------------\
| Disclaimer:
|   This code is certified by me to work, and work well,
|   Since I have no credentials as yet,
|    (perhaps other than this code here)
|   my certification means nothing whatsoever.
|
| Simply stated: USE AT YOUR OWN RISK
|
| You have permision to use this library free
|  free programs free of charge. 
| However for anything commercial, I get 
|  a copy of the product.
\---------------------------------------*/

#ifndef VOLUME_H_
#define VOLUME_H_

#ifndef VOLUME_TYPES_DEFINED
typedef void *volumeDataD_ptr;
typedef void *volumeDataF_ptr;
#endif 

/* Call this to start the integration */
volumeDataF_ptr volumeStartf(float  density);
volumeDataD_ptr volumeStartd(double density);

/* Once per face, p is the face plane {A, B, C, D} | Ax + By + Cz + D == 0 */
void volumeStartFaced(volumeDataD_ptr vd, double p[4]);
void volumeStartFacef(volumeDataF_ptr vd, float  p[4]);

/* Once per edge, counter clockwise around the face, counterclockwise ordering of verticies */
void volumeEdged(volumeDataD_ptr vd, const double a[3], const double b[3]);
void volumeEdgef(volumeDataF_ptr vd, const float  a[3], const float  b[3]);

/* Once per face after all edges have been specified */
void volumeEndFaced(volumeDataD_ptr vd);
void volumeEndFacef(volumeDataF_ptr vd);

/* Final Call, returns mass properties, deallocates volumeData_ptr */
/* cm is the center of mass, */
/* J is the inertial tensor about the center of mass */
void volumeEndd(volumeDataD_ptr vd, double *mass, double cm[3], double J[9]);
void volumeEndf(volumeDataF_ptr vd, float  *mass, float  cm[3], float  J[9]);

#endif