MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How do I tranfer graphics file via Mathlink



 
> Dear;
> 
> 	I want to write my own mathlink program to transfer graphics from 
> Mathematica3.0 to produce something. What is Argument type in template 
> file that i must write for transfer this.
> 	foe example :
> 		I want to transfer graph Sin[x] to my mathlink program, I  want 
to use
> my own program getgraph[Plot[Sin[x],{x,0,2}]
> 
> How do I write template file "getgraph.tm" and what type of graphics
> file  that Mathematica send to Mathlink(How do I received graphics file
> from  Mathematica) or it had other way to do this job(please not answer
> that  manual save graphics file because my job that want to do
> something to  that graphics file before and return to Mathematica to
> plot it)
> 
> Best Regards
> R.Inorn
> 

Hi,

the templates allow only simple data types like Integer, Real, .. in all
other cases You must transfer the data manual. The template entry is

:Begin:
:Function: c_function_to_getgraph
:Pattern: getgraph[gr_Graphics]
:Arguments: {gr}
:ArgumentTypes: {Manual}
:ReturnType: Manual
:End:

You C-function must transfer the data with MLGetFunction(), 
MLGetInteger(),... and is responsible for all type/error checking. The
most complicated task is still storing the the verry general data
structure of Mathematica's expressions in Your C-programm.

Sending the graphics data to Mathematica You must use the MLPut*()
functions.

It is not clear what You want to do but in the most cases You can manage
the manipulation of Graphics data by Mathematica's programming
language. 

In every case it is wise to make a Mathematica function that transform
the data in a structure that can be better implemented in C. At least I
recomment the splitting of the pure graphics primitives Line[],
Point[],... and the options of the Graphics-object. Keep in mind that
with out preprocessing the object

Line[{{0,0},{1/2,0.75}}]

has 3 data types (Integer,Rational,Real) in it's coordinates and that
N[0] evaluates to 0 (Integer) and not to 0.0 (Real).

Hope that helps
  Jens






  • Prev by Date: 1998 Mathematica Visiting Scholar Grant Applications
  • Next by Date: Re: List Manipulation (2)
  • Prev by thread: How do I tranfer graphics file via Mathlink
  • Next by thread: 3D problem