Accessing the C++ source associated with the rgl function shade3d

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing the C++ source associated with the rgl function shade3d

R help mailing list-2
How can I access the C++ source associated with the rgl function shade3d. More specifically, I'm interested in the part of the code used by arrow3d to draw arrow heads.

I'm not familiar with how GitHub is organized and I've put in a lot of effort doing searches there and on the web in general. The result has been a few fragments of rgl C++ code but not what I'm looking for.


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the C++ source associated with the rgl function shade3d

Duncan Murdoch-2
On 29/07/2020 5:35 p.m., Byron Dom via R-help wrote:
> How can I access the C++ source associated with the rgl function shade3d. More specifically, I'm interested in the part of the code used by arrow3d to draw arrow heads.
>
> I'm not familiar with how GitHub is organized and I've put in a lot of effort doing searches there and on the web in general. The result has been a few fragments of rgl C++ code but not what I'm looking for.

shade3d() is purely written in R:  so just type "shade3d" and you'll see
that it's a generic function.  Most commonly it is used on objects of
type "mesh3d", so type "rgl:::shade3d.mesh3d" and you can see the full
source.  It makes calls to other R functions; C++ doesn't come in until
it has chosen to draw triangles or quadrilaterals.  I think you probably
don't care about how those are drawn, but let me know if you are.

The arrow3d function is also a pure R function, but not a generic.  You
can see the source by typing "arrow3d".

Duncan Murdoch

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the C++ source associated with the rgl function shade3d

Jeff Newmiller
In reply to this post by R help mailing list-2
To begin with, don't assume it is in C++... R supports multiple compiled languages, and rgl appears to have both C++ and C in it.

I googled "r rgl github" and found an online copy of the src (source) files right away. The official way is to find the CRAN package page and download the tar.gz file and extract the files. Either way, you get the whole package source code this way.

I am afraid I don't have time to dig into the source to identify which file you need. Keeping in mind that the rgl package is an interface to lower level code, beware that you may need to leave the R code to find what you are looking for... in which case you would be dealing with a different code base and community of coders.

On July 29, 2020 2:35:33 PM PDT, Byron Dom via R-help <[hidden email]> wrote:

>How can I access the C++ source associated with the rgl function
>shade3d. More specifically, I'm interested in the part of the code used
>by arrow3d to draw arrow heads.
>
>I'm not familiar with how GitHub is organized and I've put in a lot of
>effort doing searches there and on the web in general. The result has
>been a few fragments of rgl C++ code but not what I'm looking for.
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the C++ source associated with the rgl function shade3d

Rasmus Liland-3
Dear Byron,

On 2020-07-29 18:04 -0400, Duncan Murdoch wrote:
> The arrow3d function is also a pure R
> function, but not a generic.  You can
> see the source by typing "arrow3d".

... but if I type rgl::shade3d, I get

        > rgl::shade3d
        function (x, ...)
        UseMethod("shade3d")
        <bytecode: 0x562692966fb8>
        <environment: namespace:rgl>
        > dput(rgl::shade3d)
        function (x, ...)
        UseMethod("shade3d")

I've observed this is possible in the
past, but now I can't remember how ...

On 2020-07-29 15:34 -0700, Jeff Newmiller wrote:
> On July 29, 2020 2:35:33 PM PDT, Byron Dom wrote:
> > I'm not familiar with how GitHub is
> > organized
>
> The official way is to find the CRAN
> package page and download the tar.gz
> file and extract the files. Either
> way, you get the whole package source
> code this way.

I have a hunch this is the file you're
looking for
https://github.com/cran/rgl/blob/master/R/ashape3d.R 

Remember, dealing with code on github is
just a small uptick from how Linux was
developed before, by shipping around
diffs and tarballs on a mailing list
much similar to this one, Thorvalds
merging them into the kernel in the
authoritarian way.

You can do it!  *cheers*

Best,
Rasmus

[1] http://gameoftrees.org/

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the C++ source associated with the rgl function shade3d

Duncan Murdoch-2
On 29/07/2020 7:27 p.m., Rasmus Liland wrote:

> Dear Byron,
>
> On 2020-07-29 18:04 -0400, Duncan Murdoch wrote:
>> The arrow3d function is also a pure R
>> function, but not a generic.  You can
>> see the source by typing "arrow3d".
>
> ... but if I type rgl::shade3d, I get
>
> > rgl::shade3d
> function (x, ...)
> UseMethod("shade3d")
> <bytecode: 0x562692966fb8>
> <environment: namespace:rgl>

That includes the full source code to shade3d.  Like most generic
functions, it's a one-liner.

In the part of my post that you deleted, I told the OP where to look next.

> > dput(rgl::shade3d)
> function (x, ...)
> UseMethod("shade3d")
>
> I've observed this is possible in the
> past, but now I can't remember how ...
>
> On 2020-07-29 15:34 -0700, Jeff Newmiller wrote:
>> On July 29, 2020 2:35:33 PM PDT, Byron Dom wrote:
>>> I'm not familiar with how GitHub is
>>> organized
>>
>> The official way is to find the CRAN
>> package page and download the tar.gz
>> file and extract the files. Either
>> way, you get the whole package source
>> code this way.
>
> I have a hunch this is the file you're
> looking for
> https://github.com/cran/rgl/blob/master/R/ashape3d.R

No, that's not it.  That file works with mesh3d objects, but it has
nothing to do with arrows.

Duncan Murdoch

>
> Remember, dealing with code on github is
> just a small uptick from how Linux was
> developed before, by shipping around
> diffs and tarballs on a mailing list
> much similar to this one, Thorvalds
> merging them into the kernel in the
> authoritarian way.
>
> You can do it!  *cheers*
>
> Best,
> Rasmus
>
> [1] http://gameoftrees.org/
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the C++ source associated with the rgl function shade3d

Rasmus Liland-3
On 2020-07-30 05:23 -0400, Duncan Murdoch wrote:

> On 29/07/2020 7:27 p.m., Rasmus Liland wrote:
> > On 2020-07-29 18:04 -0400, Duncan Murdoch wrote:
> > > The arrow3d function is also a pure R
> > > function, but not a generic.  You can
> > > see the source by typing "arrow3d".
> >
> > ... but if I type rgl::shade3d, I get
> >
> > > rgl::shade3d
> > function (x, ...)
> > UseMethod("shade3d")
> > <bytecode: 0x562692966fb8>
> > <environment: namespace:rgl>
>
> That includes the full source code to
> shade3d.  Like most generic functions,
> it's a one-liner.
>
> In the part of my post that you
> deleted, I told the OP where to look
> next.

This part:

> > > type "rgl:::shade3d.mesh3d" and you
> > > can see the full source.

Three colons.  I didn't see it at first;
Hmm ... I might have dyslexia or
something ...

So, Byron, this is the code that R
reinterprets from the source,

        Rscript -e 'rgl:::arrow3d' | less
        Rscript -e 'rgl:::shade3d.mesh3d' | less

so you cannot necessarily grab a line
from there and expect it to look exactly
the same in the source files.

        rasmus@beefylinuxbox ~ % grep -R 'paste(allowedMeshColor,' src/rgl
        src/rgl/R/mesh3d.R:    stop("'meshColor' must be one of: ", paste(allowedMeshColor, collapse = ", "))
        rasmus@beefylinuxbox ~ % grep -R 'pi - pi/nbarbs,' src/rgl
        1 rasmus@beefylinuxbox ~ % grep -R 'pi/nbarbs,' src/rgl
        src/rgl/R/arrow3d.R: phi <- seq(pi/nbarbs, 2*pi-pi/nbarbs, len = nbarbs)
        rasmus@beefylinuxbox ~ %

> > https://github.com/cran/rgl/blob/master/R/ashape3d.R
>
> No, that's not it.  That file works
> with mesh3d objects, but it has
> nothing to do with arrows.

... I'm sorry, now I believe
rgl::shade3d.mesh3d and rgl::arrow3d
lives in
https://github.com/cran/rgl/blob/master/R/mesh3d.R 
and
https://github.com/cran/rgl/blob/master/R/arrow3d.R 
respectively.

Byron, there's a bunch of .cpp and .h
files in
https://github.com/cran/rgl/blob/master/src
you can look at to find the triangle or
quadrilateral code you're interested in,
I'm not quite sure what to look for
there.

Best,
Rasmus

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the C++ source associated with the rgl function shade3d

Duncan Murdoch-2
In reply to this post by Jeff Newmiller
On 29/07/2020 6:34 p.m., Jeff Newmiller wrote:
> To begin with, don't assume it is in C++... R supports multiple compiled languages, and rgl appears to have both C++ and C in it.

Also a few thousand lines of Javascript, but in this case, the
interesting code is all in R.

>
> I googled "r rgl github" and found an online copy of the src (source) files right away. The official way is to find the CRAN package page and download the tar.gz file and extract the files. Either way, you get the whole package source code this way.

If you're using RStudio, a really convenient way to view the source for
a package whose source is on Github (maybe the majority of packages
these days?) is to create a new project from it.  Then you can use the
built-in search functions to jump to the source of any function.

For rgl, you can get a copy of the Github mirror of the source by
specifying the "Repository URL" as "https://github.com/rforge/rgl", and
the "Project directory name" as "pkg/rgl".  (The source is hosted in
Subversion on R-forge.r-project.org, but Subversion is less familiar to
most people these days and R-forge is pretty old-fashioned, so I'd go
with Github instead.  There are some irritating things about Github.)

Once you've got it in RStudio, you can type "shade3d" in the "Go to
file/function" box, and it will offer the generic as well as the two
methods shade3d.mesh3d and shade3d.shapelist3d.

This kind of search is probably also possible in other front ends (ESS
etc.), and some purists probably know how to set it all up in command
line BSD Unix, but I don't.

Duncan Murdoch

> I am afraid I don't have time to dig into the source to identify which file you need. Keeping in mind that the rgl package is an interface to lower level code, beware that you may need to leave the R code to find what you are looking for... in which case you would be dealing with a different code base and community of coders.
>
> On July 29, 2020 2:35:33 PM PDT, Byron Dom via R-help <[hidden email]> wrote:
>> How can I access the C++ source associated with the rgl function
>> shade3d. More specifically, I'm interested in the part of the code used
>> by arrow3d to draw arrow heads.
>>
>> I'm not familiar with how GitHub is organized and I've put in a lot of
>> effort doing searches there and on the web in general. The result has
>> been a few fragments of rgl C++ code but not what I'm looking for.
>>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing the C++ source associated with the rgl function shade3d

Eric Berger
Duncan writes:
>> " ... If you're using RStudio, a really convenient way to view the source ..."

This is fantastic! Thank you for this Duncan.

On Thu, Jul 30, 2020 at 3:45 PM Duncan Murdoch <[hidden email]> wrote:

>
> On 29/07/2020 6:34 p.m., Jeff Newmiller wrote:
> > To begin with, don't assume it is in C++... R supports multiple compiled languages, and rgl appears to have both C++ and C in it.
>
> Also a few thousand lines of Javascript, but in this case, the
> interesting code is all in R.
>
> >
> > I googled "r rgl github" and found an online copy of the src (source) files right away. The official way is to find the CRAN package page and download the tar.gz file and extract the files. Either way, you get the whole package source code this way.
>
> If you're using RStudio, a really convenient way to view the source for
> a package whose source is on Github (maybe the majority of packages
> these days?) is to create a new project from it.  Then you can use the
> built-in search functions to jump to the source of any function.
>
> For rgl, you can get a copy of the Github mirror of the source by
> specifying the "Repository URL" as "https://github.com/rforge/rgl", and
> the "Project directory name" as "pkg/rgl".  (The source is hosted in
> Subversion on R-forge.r-project.org, but Subversion is less familiar to
> most people these days and R-forge is pretty old-fashioned, so I'd go
> with Github instead.  There are some irritating things about Github.)
>
> Once you've got it in RStudio, you can type "shade3d" in the "Go to
> file/function" box, and it will offer the generic as well as the two
> methods shade3d.mesh3d and shade3d.shapelist3d.
>
> This kind of search is probably also possible in other front ends (ESS
> etc.), and some purists probably know how to set it all up in command
> line BSD Unix, but I don't.
>
> Duncan Murdoch
>
> > I am afraid I don't have time to dig into the source to identify which file you need. Keeping in mind that the rgl package is an interface to lower level code, beware that you may need to leave the R code to find what you are looking for... in which case you would be dealing with a different code base and community of coders.
> >
> > On July 29, 2020 2:35:33 PM PDT, Byron Dom via R-help <[hidden email]> wrote:
> >> How can I access the C++ source associated with the rgl function
> >> shade3d. More specifically, I'm interested in the part of the code used
> >> by arrow3d to draw arrow heads.
> >>
> >> I'm not familiar with how GitHub is organized and I've put in a lot of
> >> effort doing searches there and on the web in general. The result has
> >> been a few fragments of rgl C++ code but not what I'm looking for.
> >>
> >>
> >>      [[alternative HTML version deleted]]
> >>
> >> ______________________________________________
> >> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.