Stream: brlcad

Topic: python-brlcad


view this post on Zulip Sumagna Das (May 13 2020 at 05:43):

hey @Sean is there any python interface of brlcad or any python files in the project?

view this post on Zulip Sumagna Das (May 13 2020 at 05:55):

if there isnt any, should i try adding a feature in python :slight_smile: ?(i will start contributing in C++/C )

view this post on Zulip Sean (May 13 2020 at 06:56):

@Sumagna Das there is an unofficial python interface from a couple years ago that you can find by searching. there's a development version not committed yet to the repo, which you can find in our patches tracker. You could contribute by applying that to current trunk sources, make any changes necessary to get it working again.

view this post on Zulip Sumagna Das (May 13 2020 at 09:29):

@Sean Where to search for that? Can you give me a link to the patches
tracker?

view this post on Zulip Sean (May 13 2020 at 15:45):

Sumagna Das said:

@Sean Where to search for that? Can you give me a link to the patches
tracker?

@Sumagna Das how have you tried looking for it?

view this post on Zulip Sumagna Das (May 13 2020 at 15:48):

I don't know where to start looking from

view this post on Zulip Sean (May 13 2020 at 15:51):

heh, really? so you're saying you don't know how to search for things?

view this post on Zulip Sumagna Das (May 13 2020 at 15:57):

I don't mean to say that

view this post on Zulip Sumagna Das (May 13 2020 at 15:57):

I just don't know where to look for

view this post on Zulip Sean (May 13 2020 at 15:59):

so you're saying you know how to search for things but don't know where to search for things? I'm not sure I understand how that's possible. please explain.

view this post on Zulip Sumagna Das (May 13 2020 at 16:03):

Okay

view this post on Zulip Sumagna Das (May 13 2020 at 16:04):

I am going to try and search in places I can find

view this post on Zulip Sumagna Das (May 13 2020 at 16:26):

Sean said:

Sumagna Das there is an unofficial python interface from a couple years ago that you can find by searching. there's a development version not committed yet to the repo, which you can find in our patches tracker. You could contribute by applying that to current trunk sources, make any changes necessary to get it working again.

@Sean i found the patch, is that all?

view this post on Zulip Sumagna Das (May 13 2020 at 17:17):

I couldn't complete my message earlier

view this post on Zulip Sean (May 13 2020 at 17:23):

there's an unofficial python interface AND there's a patch, they are separate things. glad you found the patch as that was the part that you could review and try to get working on the latest sources

view this post on Zulip Sumagna Das (May 13 2020 at 17:24):

So they are seperate things. Thanks for the info.

view this post on Zulip Sumagna Das (May 13 2020 at 17:24):

@Sean By unofficial, you mean, that I will not find it in the source forge repo?

view this post on Zulip Sumagna Das (May 13 2020 at 19:31):

hey @Sean, is this the one you were talking about?
https://brlcad.org/wiki/User:Krajkreddy/GSOC14/proposal

view this post on Zulip Sumagna Das (May 13 2020 at 19:31):

the unofficial python interface?

view this post on Zulip Sumagna Das (May 13 2020 at 19:33):

i also found a pip package related to this

view this post on Zulip Sumagna Das (May 13 2020 at 19:33):

python-brlcad

view this post on Zulip Sean (May 13 2020 at 19:39):

Sumagna Das said:

Sean By unofficial, you mean, that I will not find it in the source forge repo?

Correct.

And the unofficial one is the pip package you found from kanzure.

view this post on Zulip Sumagna Das (May 13 2020 at 19:40):

i found the inerface you were talking about, i think

view this post on Zulip Sumagna Das (May 13 2020 at 19:41):

but i dont think i found the right patch in the patches tracker

view this post on Zulip Sean (May 13 2020 at 19:41):

why do you say that?

view this post on Zulip Sumagna Das (May 13 2020 at 19:42):

i got a patch called superell.patch

view this post on Zulip Sumagna Das (May 13 2020 at 19:43):

is that the one you were talking about?

view this post on Zulip Sean (May 13 2020 at 19:44):

where did you get that from?

view this post on Zulip Sumagna Das (May 13 2020 at 19:44):

https://sourceforge.net/p/brlcad/patches/277/

view this post on Zulip Sumagna Das (May 13 2020 at 19:44):

:shock:

view this post on Zulip Sean (May 13 2020 at 19:45):

I don't see any mention of python whatsoever

view this post on Zulip Sumagna Das (May 13 2020 at 19:45):

i searched for python and it returned this

view this post on Zulip Sean (May 13 2020 at 19:45):

ah, that's because I was mistaken -- it's right there in the description.

view this post on Zulip Sumagna Das (May 13 2020 at 19:46):

hmm

view this post on Zulip Sean (May 13 2020 at 19:48):

hold on, let me look

view this post on Zulip Sean (May 13 2020 at 19:48):

So, here's a good write-up on the python interface -- you could try and see if you can get it working by yourself: https://medium.com/@Mr_Jaypee/brl-cads-python-procedural-geometry-990e3c286a63

view this post on Zulip Sean (May 13 2020 at 19:50):

This was the most recent work: https://github.com/Killthebug/python-brlcad/

view this post on Zulip Sean (May 13 2020 at 19:50):

Log of that work is here: https://brlcad.org/wiki/User:Schindler97/GSoC18/Log

view this post on Zulip Sumagna Das (May 13 2020 at 19:50):

i would try my best to get it working if i can

view this post on Zulip Sumagna Das (May 13 2020 at 19:51):

i have to go in a few minutes

view this post on Zulip Sumagna Das (May 13 2020 at 19:52):

i have classes tomorrow so before that i will take a look in the above links

view this post on Zulip Sumagna Das (May 13 2020 at 19:52):

or else tomorrow

view this post on Zulip Sean (May 13 2020 at 19:55):

it looks like the one pending patch I was thinking of is already integrated, so nothing to do there. the other one appears to be on that github repo

view this post on Zulip Sumagna Das (May 13 2020 at 19:56):

the other one?

view this post on Zulip Sean (May 13 2020 at 19:57):

you question is incomplete

view this post on Zulip Sumagna Das (May 13 2020 at 19:57):

Sean said:

it looks like the one pending patch I was thinking of is already integrated, so nothing to do there. the other one appears to be on that github repo

what is "the other one"?

view this post on Zulip Sean (May 13 2020 at 19:58):

the other patch I was thinking of appears to be that github repo

view this post on Zulip Sean (May 13 2020 at 19:58):

it was a gsoc project two years ago

view this post on Zulip Sumagna Das (May 13 2020 at 19:58):

oh ok

view this post on Zulip Sumagna Das (May 13 2020 at 20:02):

i have a far-fetched idea

view this post on Zulip Sumagna Das (May 13 2020 at 20:02):

should i try making a GUI?

view this post on Zulip Sean (May 13 2020 at 20:03):

haha. no.

view this post on Zulip Sumagna Das (May 13 2020 at 20:03):

i am practicing pyqt(PySide2)

view this post on Zulip Sumagna Das (May 13 2020 at 20:03):

ok no problem

view this post on Zulip Sean (May 13 2020 at 20:03):

that's so much more complexity to create something useful

view this post on Zulip Sumagna Das (May 13 2020 at 20:03):

i can understand

view this post on Zulip Sean (May 13 2020 at 20:03):

let me ask you, what are you trying to accomplish?

view this post on Zulip Sean (May 13 2020 at 20:04):

what would you like to do? why did you mention python in the first place?

view this post on Zulip Sean (May 13 2020 at 20:04):

are you looking to take on a project?

view this post on Zulip Sumagna Das (May 13 2020 at 20:04):

i wanted to contribute to brlcad using python

view this post on Zulip Sumagna Das (May 13 2020 at 20:04):

nope

view this post on Zulip Sean (May 13 2020 at 20:04):

why?

view this post on Zulip Sean (May 13 2020 at 20:04):

why "using python"?

view this post on Zulip Sumagna Das (May 13 2020 at 20:05):

i am much more comfortable now in python

view this post on Zulip Sean (May 13 2020 at 20:05):

but how are you looking to contribute? towards what end?

view this post on Zulip Sumagna Das (May 13 2020 at 20:06):

i thought if there's a python interface of brl-cad, i would contribute to that

view this post on Zulip Sumagna Das (May 13 2020 at 20:06):

or else try to make one(if i could)

view this post on Zulip Sean (May 13 2020 at 20:06):

you just repeated yourself without answering the question :)

view this post on Zulip Sumagna Das (May 13 2020 at 20:06):

ok

view this post on Zulip Sean (May 13 2020 at 20:07):

how are you looking to contribute? towards what end?

view this post on Zulip Sean (May 13 2020 at 20:08):

you said you would contribute to "that" -- presumably "that" is the python interface itself? or create something using python? or model with python? or improve the ability to work with python in brl-cad? or ... ???

view this post on Zulip Sumagna Das (May 13 2020 at 20:08):

i wanted to improve the ability to work with python in brl-cad

view this post on Zulip Sean (May 13 2020 at 20:10):

so there's two ways you can do that. there's a "script" entity type inside BRL-CAD that could be improved and there's a python interface outside BRL-CAD that could be improved.

view this post on Zulip Sumagna Das (May 13 2020 at 20:10):

what is "script"?

view this post on Zulip Sean (May 13 2020 at 20:11):

the inside one requires that you have basic understanding of BRL-CAD's tools

view this post on Zulip Sumagna Das (May 13 2020 at 20:11):

ok

view this post on Zulip Sumagna Das (May 13 2020 at 20:11):

then i would start contributing to the outside one first

view this post on Zulip Sean (May 13 2020 at 20:12):

@Sumagna Das you're asking such fundamental questions that I really recommend you first complete tutorials so you at least have a basic understanding of terms

view this post on Zulip Sean (May 13 2020 at 20:13):

have you done the MGED tutorials?

view this post on Zulip Sumagna Das (May 13 2020 at 20:13):

yeah, i think so

view this post on Zulip Sean (May 13 2020 at 20:13):

then you should know what a script entity probably refers to... just like there are ell and sph and arb8 entities, there is a script entity

view this post on Zulip Sean (May 13 2020 at 20:14):

entity = object

view this post on Zulip Sumagna Das (May 13 2020 at 20:14):

i confused entity with something else

view this post on Zulip Sumagna Das (May 13 2020 at 20:14):

sorry

view this post on Zulip Sean (May 13 2020 at 20:15):

the general idea is a user can create an object that is a python script that defines how that object behaves. this interface does not yet exist, but would be a goal.

view this post on Zulip Sean (May 13 2020 at 20:16):

the script creates geometry and is called by C code on the fly

view this post on Zulip Sean (May 13 2020 at 20:16):

that's for the work inside BRL-CAD

view this post on Zulip Sean (May 13 2020 at 20:17):

for the python work outside BRL-CAD, the approach is very different. You should read the links I provided or you will not be able to help with it.

view this post on Zulip Sumagna Das (May 13 2020 at 20:17):

ok

view this post on Zulip Sean (May 13 2020 at 20:17):

I'd start with https://medium.com/@Mr_Jaypee/brl-cads-python-procedural-geometry-990e3c286a63
and get it working on your computer.

view this post on Zulip Sumagna Das (May 13 2020 at 20:17):

i am going to sleep right now as i have school

view this post on Zulip Sumagna Das (May 13 2020 at 20:18):

i will test that tomorrow

view this post on Zulip Sean (May 13 2020 at 20:18):

If you can't get it working, then you might not have enough background -- you might want to pick a much simpler goal, which I would recommend regardless just to get familiarized.

view this post on Zulip Sumagna Das (May 13 2020 at 20:19):

like?

view this post on Zulip Sumagna Das (May 13 2020 at 20:19):

what goal can you recommend to me right now to get familiarised?

view this post on Zulip Sean (May 13 2020 at 20:19):

like starting with a simple tcl script that creates some geomtry

view this post on Zulip Sumagna Das (May 13 2020 at 20:19):

it will be much helpful

view this post on Zulip Sean (May 13 2020 at 20:19):

using mged commands

view this post on Zulip Sean (May 13 2020 at 20:20):

what's a shape or object that you want to model?

view this post on Zulip Sumagna Das (May 13 2020 at 20:20):

asking me or saying to me?

view this post on Zulip Sean (May 13 2020 at 20:20):

asking

view this post on Zulip Sumagna Das (May 13 2020 at 20:21):

umm... i dont have a answer for that right now

view this post on Zulip Sean (May 13 2020 at 20:21):

for example, you could try to model this: https://brlcad.org/gci/ideas/puzzle/puzzle.jpg

view this post on Zulip Sumagna Das (May 13 2020 at 20:22):

thats nice

view this post on Zulip Sumagna Das (May 13 2020 at 20:22):

i would like to try that

view this post on Zulip Sean (May 13 2020 at 20:22):

model it yourself first, maybe redo the tutorials if you forgot all the commands

view this post on Zulip Sumagna Das (May 13 2020 at 20:22):

alongside that i can try making the python-brlcad work

view this post on Zulip Sean (May 13 2020 at 20:22):

then once you have done that, you could try turning it into a script

view this post on Zulip Sumagna Das (May 13 2020 at 20:23):

ooh

view this post on Zulip Sumagna Das (May 13 2020 at 20:23):

thats a nice idea

view this post on Zulip Sean (May 13 2020 at 20:23):

once you have it in a script, you could try turning it into a python script

view this post on Zulip Sumagna Das (May 13 2020 at 20:23):

i do things like that now

view this post on Zulip Sean (May 13 2020 at 20:23):

first script would be an mged script, also known as a tcl script

view this post on Zulip Sumagna Das (May 13 2020 at 20:23):

i saw shell scripting

view this post on Zulip Sumagna Das (May 13 2020 at 20:24):

i can somewhat convert a sh file to python(not much confident about that)

view this post on Zulip Sean (May 13 2020 at 20:24):

you can script mged itself externally with anything including a shell script

view this post on Zulip Sumagna Das (May 13 2020 at 20:24):

thats nice

view this post on Zulip Sumagna Das (May 13 2020 at 20:25):

i would do shell scripting rather than tcl

view this post on Zulip Sean (May 13 2020 at 20:25):

you could use python today, but you don't know the mged commands

view this post on Zulip Sumagna Das (May 13 2020 at 20:25):

i know shell but not tcl

view this post on Zulip Sumagna Das (May 13 2020 at 20:25):

hmm

view this post on Zulip Sean (May 13 2020 at 20:25):

you're getting far too caught up in the language if you ask me

view this post on Zulip Sumagna Das (May 13 2020 at 20:25):

yea

view this post on Zulip Sumagna Das (May 13 2020 at 20:25):

i first want to be confident about python then start learning another language

view this post on Zulip Sean (May 13 2020 at 20:26):

like I said, you are lacking on some basics first. if you don't learn them, you won't be able to do these more advanced ideas

view this post on Zulip Sean (May 13 2020 at 20:27):

you write commands to create geometry.. there are hundreds of commands in BRL-CAD

view this post on Zulip Sumagna Das (May 13 2020 at 20:27):

hmm

view this post on Zulip Sean (May 13 2020 at 20:27):

those commands can be created from any language

view this post on Zulip Sean (May 13 2020 at 20:27):

you're wanting to use python, but you don't know the commands yet

view this post on Zulip Sumagna Das (May 13 2020 at 20:27):

i gotta go after the source code of the brl cad has been downloaded

view this post on Zulip Sean (May 13 2020 at 20:28):

so I recommend learning some of the commands first by creating some geometry like that cube example

view this post on Zulip Sumagna Das (May 13 2020 at 20:28):

i would do that

view this post on Zulip Sean (May 13 2020 at 20:28):

compile brl-cad, run mged or archer, and create that "dice" model

view this post on Zulip Sean (May 13 2020 at 20:28):

keep notes on what commands you used to create the dice model

view this post on Zulip Sean (May 13 2020 at 20:28):

what steps you do

view this post on Zulip Sumagna Das (May 13 2020 at 20:29):

i will write them down on txt file

view this post on Zulip Sean (May 13 2020 at 20:29):

good luck

view this post on Zulip Sumagna Das (May 13 2020 at 20:29):

in the meanwhile should i try getting python-brlcad to work on my computer?

view this post on Zulip Sean (May 13 2020 at 20:30):

you're welcome to try, but based on your questions I honestly do not think you will be successful without lots of help

view this post on Zulip Sumagna Das (May 13 2020 at 20:30):

whom can i take help about this from?

view this post on Zulip Sean (May 13 2020 at 20:30):

you can ask here, that's not the point

view this post on Zulip Sumagna Das (May 13 2020 at 20:30):

ok

view this post on Zulip Sean (May 13 2020 at 20:31):

the point is that it is going to take you a very long time and will likely be frustrating or confusing or "hard"

view this post on Zulip Sean (May 13 2020 at 20:31):

you're going to have to read a lot, and you don't seem very inclined to read a lot...

view this post on Zulip Sumagna Das (May 13 2020 at 20:31):

why do u say that?

view this post on Zulip Sean (May 13 2020 at 20:33):

some people like to be told what to do, others are good at discovering things on their own

view this post on Zulip Sumagna Das (May 13 2020 at 20:34):

i am a middle man

view this post on Zulip Sumagna Das (May 13 2020 at 20:34):

i discover things on my own but sometimes i need to be told what to do

view this post on Zulip Sean (May 13 2020 at 20:35):

if you need it even sometimes, then you're the first type

view this post on Zulip Sumagna Das (May 13 2020 at 20:36):

that can be so

view this post on Zulip Sean (May 13 2020 at 20:36):

people good at discovery can figure out almost any problem given enough time and motivation, they discover how on their own even when they do not know

view this post on Zulip Sean (May 13 2020 at 20:36):

it's a good skill to practice

view this post on Zulip Sumagna Das (May 13 2020 at 20:37):

i am trying to do that as much as i can

view this post on Zulip Sean (May 13 2020 at 20:37):

that said, your skills are young, so you still need to have realistic goals or you'll just get frustrated

view this post on Zulip Sumagna Das (May 13 2020 at 20:37):

what do u mean by realistic goals?

view this post on Zulip Sean (May 13 2020 at 20:39):

if you told me that you wanted to model your car in 3D

view this post on Zulip Sean (May 13 2020 at 20:39):

with enough accuracy that it could be manufactured or even just 3D printed faithfully

view this post on Zulip Sean (May 13 2020 at 20:39):

that would not be a realistic goal

view this post on Zulip Sumagna Das (May 13 2020 at 20:39):

i could not think of anything other than some sleep

view this post on Zulip Sumagna Das (May 13 2020 at 20:40):

i would go to sleep after the build of brl-cad is finished

view this post on Zulip Sean (May 13 2020 at 20:40):

there's plenty of time to sleep after we die ;)

view this post on Zulip Sumagna Das (May 13 2020 at 20:40):

:lol:

view this post on Zulip Sumagna Das (May 13 2020 at 20:41):

i am trying to do as much programming and contributing this year as i can do because next year i wouldnt get much time

view this post on Zulip Sumagna Das (May 13 2020 at 20:42):

i have to study almost all of the day

view this post on Zulip Sumagna Das (May 13 2020 at 20:42):

how much time can brl-cad take to build

view this post on Zulip Sumagna Das (May 13 2020 at 20:45):

okay good night everyone

view this post on Zulip Sumagna Das (May 13 2020 at 20:45):

see you tomorrow

view this post on Zulip Daniel Rossberg (May 14 2020 at 07:05):

I thought, the point with BRL-CAD's Python interface is that the current one is Python 2.x based, which will reach its end of life soon and is deprecated therefore. I.e. the task would be to write a Python 3.x interface.

view this post on Zulip Sumagna Das (May 14 2020 at 07:20):

I will try my best at that

view this post on Zulip Daniel Rossberg (May 14 2020 at 07:34):

As you have already discussed with Sean: This is not a trivial task. I t means to program most of the time in C or C++, not Python. It means to implement the piece of code, which a programmer can use in Python, not the Python code itself.

view this post on Zulip Sumagna Das (May 14 2020 at 11:34):

i was fixing the code for the python interface

view this post on Zulip Sumagna Das (May 14 2020 at 11:34):

it cannot find nurb.h

view this post on Zulip Sumagna Das (May 14 2020 at 11:34):

in which folder is it stored

view this post on Zulip Daniel Rossberg (May 14 2020 at 11:39):

Maybe, we don't have this header anymore.

view this post on Zulip Sumagna Das (May 14 2020 at 11:39):

probably replaced or removed

view this post on Zulip Sumagna Das (May 14 2020 at 11:39):

is it replaced by opennurbs?

view this post on Zulip Daniel Rossberg (May 14 2020 at 11:40):

I would expect this.

view this post on Zulip Sumagna Das (May 14 2020 at 11:41):

i didnt understand

view this post on Zulip Daniel Rossberg (May 14 2020 at 11:45):

I think that this is a header for the predecessor of openNURBS, but I'm not sure.

view this post on Zulip Sumagna Das (May 14 2020 at 11:45):

ok

view this post on Zulip Sumagna Das (May 14 2020 at 11:48):

i was trying to fix the python interface outside brl cad

view this post on Zulip Sumagna Das (May 14 2020 at 11:49):

my computer cannot handle brl cad rendering right now so i will do the inner interface later

view this post on Zulip Daniel Rossberg (May 14 2020 at 12:13):

BTW, I don't think that this is the right way to do it. In my opinion, the whole interface has to be rewritten. There are many changes in the BRL-CAD API too.

This means, you should start with designing the Python interface. I.e., how should the Python functions look like? To answer this, you have to learn more about APIs and interfaces in general.

Sean showed you a way to do this: Find a problem which shall be solved with Python. E.g., model a puzzle. (You can model other things too, if you like.) The curse of action would be the following:

When you have done this, you learned a lot about BRL-CAD interfaces and you may have an idea of how the one to Python should look like.

view this post on Zulip Sumagna Das (May 14 2020 at 12:13):

ok

view this post on Zulip Sumagna Das (May 14 2020 at 12:16):

Daniel Rossberg said:

BTW, I don't think that this is the right way to do it. In my opinion, the whole interface has to be rewritten. There are many changes in the BRL-CAD API too.

This means, you should start with designing the Python interface. I.e., how should the Python functions look like? To answer this, you have to learn more about APIs and interfaces in general.

Sean showed you a way to do this: Find a problem which shall be solved with Python. E.g., model a puzzle. (You can model other things too, if you like.) The curse of action would be the following:

When you have done this, you learned a lot about BRL-CAD interfaces and you may have an idea of how the one to Python should look like.

view this post on Zulip Sumagna Das (May 14 2020 at 12:19):

and also i have this year's time as i will not be doing anything much next year(i will continue contributing the year after the next one)

view this post on Zulip Sumagna Das (May 14 2020 at 12:21):

@Daniel Rossberg should i use the old python-interface as a base?

view this post on Zulip Daniel Rossberg (May 14 2020 at 12:26):

This is one possibility, to "simply" port the interface from Python 2.x to 3.x. But, I'm afraid that this is not simple because of API changes. And, there were a lot of issues with the old interface too. I.e., you can try to do so, but a restart could be easier.

view this post on Zulip Sumagna Das (May 14 2020 at 12:27):

it seems so

view this post on Zulip Sumagna Das (May 14 2020 at 12:28):

i tried fixing eveything but it was very much tough and still it isnt 1% fixed

view this post on Zulip Sumagna Das (May 14 2020 at 12:38):

what is the main library in Brl-cad?

view this post on Zulip Sumagna Das (May 14 2020 at 12:38):

which nearly include all the functions for making shapes?

view this post on Zulip Sumagna Das (May 14 2020 at 12:39):

i am going to try to restart the whole thing

view this post on Zulip Daniel Rossberg (May 14 2020 at 12:39):

In my opinion, it's worth to dive deeper into the different kinds of BRL-CAD programming. It may feel as being not productive, but learning about the different interface designs is very helpful if you want to design an own one.

view this post on Zulip Sumagna Das (May 14 2020 at 12:40):

i will do that first, mainly the c++ one

view this post on Zulip Sumagna Das (May 14 2020 at 12:40):

i had an introduction in that one in 2019 gci

view this post on Zulip Daniel Rossberg (May 14 2020 at 12:40):

Most people consider librt as the main library, but libwdb is used to create the database entries.

view this post on Zulip Sumagna Das (May 14 2020 at 12:41):

ok

view this post on Zulip Daniel Rossberg (May 14 2020 at 12:43):

There are two main designs for the interfaces:

view this post on Zulip Sumagna Das (May 14 2020 at 13:10):

I am going to do something like the first one

view this post on Zulip Sumagna Das (May 14 2020 at 13:11):

Then, if it's necessary, I will make a command line interface(if that's what you tried to mean in the second way)

view this post on Zulip Daniel Rossberg (May 14 2020 at 13:14):

It's your decision. Which of the two would look more Python-like?

view this post on Zulip Sumagna Das (May 14 2020 at 13:20):

First one

view this post on Zulip Sean (May 14 2020 at 15:49):

The ctypesgen interface does utilize an object-oriented design, if I recall correctly. It low-level binds into libwdb, but then presents a database and object API, not a command API like ged.

view this post on Zulip Sean (May 14 2020 at 15:49):

here's an example https://github.com/kanzure/python-brlcad/blob/master/examples/wdb_globe.py

view this post on Zulip Sean (May 14 2020 at 15:51):

not the cleanest, the args are nearly a pass-through to the C api, but definitely a bit closer to objects than commands in style. not an example to necessarily repeat, but an interesting study

view this post on Zulip Sumagna Das (May 14 2020 at 18:28):

@Sean can i use the old python interface as a base for the newer python package?

view this post on Zulip Sumagna Das (May 15 2020 at 08:47):

what are the libraries required to access the BRL-CAD core interface?

view this post on Zulip Daniel Rossberg (May 15 2020 at 08:53):

Do you see the TARGET_LINK_LIBRARIES in rt^3/src/coreInterface/CMakeLists.txt?

view this post on Zulip Sumagna Das (May 15 2020 at 09:01):

lemme see

view this post on Zulip Sumagna Das (May 15 2020 at 13:06):

so i was trying to use ctypesgen to generate a py file from all the header files in include/brlcad/rt folder

view this post on Zulip Sumagna Das (May 15 2020 at 13:07):

(deleted)

view this post on Zulip Sumagna Das (May 15 2020 at 13:07):

(deleted)

view this post on Zulip Sumagna Das (May 16 2020 at 10:46):

hey @Sean, do u know how to use ctypesgen command to get the macro definitions?

view this post on Zulip Sumagna Das (May 16 2020 at 10:52):

i was trying out the ctypesgen command to convert raytrace.h, vmath.h and common.h to write the rtexample.c in python

view this post on Zulip Sumagna Das (May 16 2020 at 10:52):

but ctypesgen couldnt convert macro definitions

view this post on Zulip Sumagna Das (May 16 2020 at 12:28):

btw it somewhat works

view this post on Zulip Sumagna Das (May 16 2020 at 21:51):

So an update about the python interface

view this post on Zulip Sumagna Das (May 16 2020 at 21:52):

Everything is working fine except the macro definitions

view this post on Zulip Sumagna Das (May 16 2020 at 21:54):

I was trying to convert rtexample.c to rtexample.py using the ctypes wrappers but the many of the macro definitions are not available so it is hard as I am having to redefine them as functions in the python file

view this post on Zulip Sumagna Das (May 16 2020 at 21:55):

So what should I do about it?

view this post on Zulip Sumagna Das (May 16 2020 at 21:56):

I am still trying to make the macro definitions work

view this post on Zulip Sean (May 16 2020 at 21:57):

macros don't exist to the compiler, so you may not have an alternative except wrapping them in functions or using alternative functions (many already have an alternate C function)

view this post on Zulip Sean (May 16 2020 at 22:10):

that's pretty cool that you got as far as you did @Sumagna Das -- can you show a screenshot and code example where it's at?

view this post on Zulip Sean (May 16 2020 at 22:11):

most of the vmath stuff I would expect to be available in other existing python packages -- that's basic math

view this post on Zulip Sean (May 16 2020 at 22:11):

that just leaves a few to worry about which aren't critical and/or have function alternatives. Case by case..

view this post on Zulip Sumagna Das (May 17 2020 at 05:26):

I will push the code to GitHub

view this post on Zulip Sumagna Das (May 17 2020 at 05:27):

And the screenshot I will give to you later

view this post on Zulip Sumagna Das (May 17 2020 at 05:27):

By the way, I haven't organized the code

view this post on Zulip Sumagna Das (May 17 2020 at 05:27):

So it might be a bit harder to read

view this post on Zulip Sumagna Das (May 17 2020 at 05:50):

The GitHub link is https://github.com/sumagnadas/python-brlcad

view this post on Zulip Sumagna Das (May 17 2020 at 10:35):

hey @Sean i am also creating a parser which parses the macros into normal python functions(not ctypes.CFUNCTYPE)

view this post on Zulip Sumagna Das (May 17 2020 at 10:36):

i have to see whether it gets all the macros or misses some of them

view this post on Zulip Sumagna Das (May 17 2020 at 10:41):

what are the back slashes for at end of some of the lines in some macros?

view this post on Zulip Sumagna Das (May 17 2020 at 14:59):

i have to pause the work on the interface right now because of my school and some personal problems.

view this post on Zulip Sumagna Das (May 17 2020 at 15:00):

i will resume the work from next week onwards

view this post on Zulip Sumagna Das (May 18 2020 at 05:23):

rtexample-and-rtexample.py.png

view this post on Zulip Sumagna Das (May 18 2020 at 05:24):

the screenshot of the working of the python file

view this post on Zulip Sumagna Das (May 18 2020 at 05:26):

it is somewhat working because i couldnt make the macros(converted to python functions) work so some of the calculations are wrong

view this post on Zulip Sumagna Das (May 18 2020 at 05:26):

or else all of the things are printed using bu_log and VPRINT

view this post on Zulip Sumagna Das (May 18 2020 at 05:27):

rtexample.py

view this post on Zulip Sumagna Das (May 18 2020 at 05:27):

this is the file

view this post on Zulip Sumagna Das (May 18 2020 at 05:30):

vmath_macros.py

view this post on Zulip Sumagna Das (May 18 2020 at 05:30):

this file contains almost all of the macros. it was mostly made using a parsing python script i had made.

view this post on Zulip Sumagna Das (May 18 2020 at 10:58):

umm do i need all the macros or do i need the most useful?

view this post on Zulip Sumagna Das (May 18 2020 at 12:44):

so another update about the interface

view this post on Zulip Sumagna Das (May 18 2020 at 12:44):

i made the example specified in this link: https://medium.com/@Mr_Jaypee/brl-cads-python-procedural-geometry-990e3c286a63 and it was succesful

view this post on Zulip Sumagna Das (May 18 2020 at 12:47):

here's the screenshot of the shape i made using my code example.png

view this post on Zulip Sean (May 18 2020 at 19:31):

Sumagna Das said:

what are the back slashes for at end of some of the lines in some macros?

Same as it is elsewhere in C. Those are line continuations. It's how you have a macro that's effectively multiple lines of logic.

view this post on Zulip Sumagna Das (May 18 2020 at 20:37):

Okay

view this post on Zulip Sumagna Das (May 18 2020 at 20:37):

I was trying to parse them but it was hard so I left the parser

view this post on Zulip Sean (May 19 2020 at 02:11):

@Sumagna Das that rtexample.py you wrote is impressive! I think it shows a lot of the limitations of doing a direct conversion from C to Py, but it clearly works. Do you think you could create a fake rtexample that is 'ideal', what you think the python interface should look like?

view this post on Zulip Sean (May 19 2020 at 02:12):

because the direct conversion feels very low-level to me, too low-level. That if I were to design a python API from scratch, I probably would create a raytracing example differently.

view this post on Zulip Sean (May 19 2020 at 02:13):

If you could mock it out, we could look at what changes might be needed, either on the C/C++ side or as a higher layer in python.

view this post on Zulip Sean (May 19 2020 at 02:14):

Here's a good example of a more pure object approach using the MOOSE API: https://brlcad.org/wiki/CoreInterface_Hallo_World_Example

view this post on Zulip Sumagna Das (May 19 2020 at 03:11):

ok

view this post on Zulip Sumagna Das (May 19 2020 at 03:11):

i will try

view this post on Zulip Sumagna Das (May 19 2020 at 03:14):

i just wanted to show through that example that the bindings work

view this post on Zulip Sumagna Das (May 19 2020 at 03:15):

i made another example using wdb

view this post on Zulip Sumagna Das (May 19 2020 at 03:16):

please see to that and tell me how it is

view this post on Zulip Sumagna Das (May 19 2020 at 03:17):

later i would make classes very much similar to the previous interfaces

view this post on Zulip Sean (May 19 2020 at 03:17):

Sumagna Das said:

i just wanted to show through that example that the bindings work

yeah, no don't get me wrong -- that's amazing!

view this post on Zulip Sean (May 19 2020 at 03:17):

you're on python 2 yes?

view this post on Zulip Sumagna Das (May 19 2020 at 03:17):

i can underdstand what you wanted to say

view this post on Zulip Sumagna Das (May 19 2020 at 03:18):

no python3

view this post on Zulip Sumagna Das (May 19 2020 at 03:18):

python 3.8

view this post on Zulip Sean (May 19 2020 at 03:18):

using ctypesgen?

view this post on Zulip Sumagna Das (May 19 2020 at 03:18):

yea

view this post on Zulip Sean (May 19 2020 at 03:18):

huh, so someone must have finally fixed it, updated it?

view this post on Zulip Sumagna Das (May 19 2020 at 03:18):

ctypesgen?

view this post on Zulip Sumagna Das (May 19 2020 at 03:19):

do you mean someone fixed ctypesgen?

view this post on Zulip Sumagna Das (May 19 2020 at 03:37):

if you mean ctypesgen, its latest update on pip was in december 2019 and latest commit on github repo is in march 2020

view this post on Zulip Sean (May 19 2020 at 04:52):

wow, so then yeah.. really recent. it was broken for python3 for years. that's why the python work stalled. the entire approach relied on it.

view this post on Zulip Sean (May 19 2020 at 04:55):

so then since you're looking at it... do you think you could review https://github.com/kanzure/python-brlcad and its forks to merge everyone's efforts @Sumagna Das?

https://github.com/Killthebug/python-brlcad in particular has the latest but there are at least two other forks that have commits ahead of kanzure's:

view this post on Zulip Sean (May 19 2020 at 04:56):

https://github.com/kanzure/python-brlcad/network/members

view this post on Zulip Sumagna Das (May 19 2020 at 05:21):

Sean said:

so then since you're looking at it... do you think you could review https://github.com/kanzure/python-brlcad and its forks to merge everyone's efforts Sumagna Das?

https://github.com/Killthebug/python-brlcad in particular has the latest but there are at least two other forks that have commits ahead of kanzure's:

i will do that after i make the pip package for the python interface or something like that

view this post on Zulip Sumagna Das (May 19 2020 at 06:40):

Sean said:

Here's a good example of a more pure object approach using the MOOSE API: https://brlcad.org/wiki/CoreInterface_Hallo_World_Example

this is rt^3, right?

view this post on Zulip Daniel Rossberg (May 19 2020 at 07:10):

In general, yes. Headers are in include/brlcad and sources in src/coreInterface. But this is the C++ core interface. For a MOOSE version see https://github.com/drossberg/MOOSE. From the programmers point of view, they are very much the same. For the moment, it doesn't matter which one you use. With Visual Studio you can use the brlcad.dll too (https://sourceforge.net/projects/brlcad/files/BRL-CAD%20Runtime%20Libraries/7.26.0/brlcad-7.26.0_dll_devel.zip/download).

view this post on Zulip Sumagna Das (May 19 2020 at 08:46):

ok then

view this post on Zulip Sean (May 19 2020 at 15:23):

yeah, I'm considering them one in the same. MOOSE == core interface ;)

view this post on Zulip Sumagna Das (May 19 2020 at 15:24):

i was seeing KilltheBug's repo on python-brlcad

view this post on Zulip Sumagna Das (May 19 2020 at 15:25):

i saw that he used numpy for vmath

view this post on Zulip Sumagna Das (May 19 2020 at 15:25):

so should i do something similar?

view this post on Zulip Sean (May 19 2020 at 15:31):

It's not a bad way to go about it. vmath is basic math so using something already in python is probably preferable to transcoding vmath to python

view this post on Zulip Sumagna Das (May 19 2020 at 15:33):

ok

view this post on Zulip Sumagna Das (May 19 2020 at 15:37):

is there a list or something like that which can tell me what are the important vmath function from vmath.h?

view this post on Zulip Sean (May 19 2020 at 15:55):

you could grep for them all and count up their usage

view this post on Zulip Sean (May 19 2020 at 16:13):

counting them now with:

grep 'define[^d]' include/vmath.h | grep '#' | sed 's/.*define[[:space:]]\([A-Z0-9_]*\).*/\1/g' | while read symbol ; do echo -n "$symbol " ; grep -r -I -E "[^a-zA-Z0-9_]$symbol[^a-zA-Z0-9_]" include src/[^o]* 2>/dev/null | wc -l ; done | sort -n

view this post on Zulip Sumagna Das (May 19 2020 at 16:32):

Sean said:

counting them now with:

grep 'define[^d]' include/vmath.h | grep '#' | sed 's/.*define[[:space:]]\([A-Z0-9_]*\).*/\1/g' | while read symbol ; do echo -n "$symbol " ; grep -r -I -E "[^a-zA-Z0-9_]$symbol[^a-zA-Z0-9_]" include src/[^o]* 2>/dev/null | wc -l ; done | sort -n

thanks for the command

view this post on Zulip Sumagna Das (May 19 2020 at 16:35):

going to work on vmath next with numpy

view this post on Zulip Sumagna Das (May 19 2020 at 16:36):

then try to make a much more organized python file for calling the modules

view this post on Zulip Sean (May 19 2020 at 17:01):

here's the ones that are called at least 100 times:

4425 VMOVE
3131 VSET
2092 VSCALE
1646 V3ARGS
1579 VSUB2
1485 MAT4X3PNT
1294 VDOT
1229 VJOIN1
1182 VUNITIZE
1089 VADD2
1075 MAGNITUDE
1044 ZERO
770 VSETALL
731 NEAR_ZERO
678 VCROSS
651 SMALL_FASTF
546 MAT_IDN
520 INFINITY
517 MAT4X3VEC
501 VINIT_ZERO
499 VPRINT
459 ELEMENTS_PER_VECT
433 NEAR_EQUAL
430 EQUAL
409 VJOIN2
380 MAT_COPY
359 INTCLAMP
348 VREVERSE
308 MAX_FASTF
300 DEG2RAD
284 VMINMAX
276 V_MAX
262 MAGSQ
249 ELEMENTS_PER_POINT
237 V_MIN
226 M_PI
206 M_2PI
202 V2MOVE
195 SQRT_SMALL_FASTF
167 V2SET
154 RAD2DEG
130 VUNITIZE_TOL
129 VADD3
108 VNEAR_EQUAL

view this post on Zulip Sean (May 19 2020 at 17:02):

not to say that the ones called fewer times aren't important too, but it gives an idea of the utilization

view this post on Zulip Sean (May 19 2020 at 17:04):

also note that some usages are in other macros which themselves might be used hundreds/thousands of times. I didn't try to count that, but it'd be a similar counting process to identify usage in include/ and look for those indirect calls

view this post on Zulip Sumagna Das (May 19 2020 at 17:23):

I used a script to parse the macros into functions

view this post on Zulip Sumagna Das (May 19 2020 at 17:23):

Some of them worked

view this post on Zulip Sumagna Das (May 19 2020 at 17:28):

Others have to be fixed

view this post on Zulip Sean (May 19 2020 at 17:29):

@Sumagna Das but why?? that means it will be out of sync the instant anyone makes a change to vmath.h ... it does change from time to time.

view this post on Zulip Sumagna Das (May 19 2020 at 18:28):

that i have to see to

view this post on Zulip Sumagna Das (May 19 2020 at 18:28):

that is the issue i had

view this post on Zulip Sumagna Das (May 19 2020 at 18:30):

because of that i didnt use that file nor the (somewhat) parser

view this post on Zulip Sumagna Das (May 20 2020 at 05:10):

I discarded that idea

view this post on Zulip Sean (May 20 2020 at 15:15):

@Sumagna Das so what's next?

view this post on Zulip Sumagna Das (May 20 2020 at 15:16):

I don't know right now

view this post on Zulip Sumagna Das (May 20 2020 at 15:16):

There's a storm raging outside

view this post on Zulip Sumagna Das (May 20 2020 at 15:17):

It will continue until tomorrow morning I think

view this post on Zulip Sean (May 20 2020 at 15:27):

yikes, hope you don't loose power

view this post on Zulip Sumagna Das (May 20 2020 at 19:21):

Actually the power is cut off for 7 or 8 hours now

view this post on Zulip Sean (May 20 2020 at 19:24):

yikes, sorry to hear that @Sumagna Das

view this post on Zulip Sumagna Das (May 20 2020 at 19:25):

My father told me that it will be back by tomorrow morning

view this post on Zulip Sumagna Das (May 20 2020 at 19:25):

Its 1 in midnight

view this post on Zulip Sumagna Das (May 20 2020 at 19:30):

So I don't think I will be back on the interface at least for this week

view this post on Zulip Sumagna Das (May 21 2020 at 03:25):

So I will not be back on the interface for a couple of days

view this post on Zulip Sumagna Das (May 21 2020 at 03:25):

Internet is not working here

view this post on Zulip Sean (May 21 2020 at 04:42):

@Sumagna Das how are you on chat then? is there anything I can do to help?

view this post on Zulip Sumagna Das (May 21 2020 at 09:35):

Wifi is not available. I am online through cellular net which is very very
slow.

view this post on Zulip Sumagna Das (May 21 2020 at 09:37):

Wifi will be back after three days or so

view this post on Zulip Sumagna Das (May 24 2020 at 21:01):

Hey @Sean my net is coming back after a few days(it is working well right now, though it is midnight) so I think I will be back when it comes back

view this post on Zulip Sumagna Das (May 24 2020 at 21:02):

The cyclone did too much damage to internet and cellular networks

view this post on Zulip Sumagna Das (May 28 2020 at 21:29):

Sean said:

Sumagna Das that rtexample.py you wrote is impressive! I think it shows a lot of the limitations of doing a direct conversion from C to Py, but it clearly works. Do you think you could create a fake rtexample that is 'ideal', what you think the python interface should look like?

As you said, i created a fake example, wdbexample(as it was easier to make than rtexample) in python to demonstrate the use of the prototype python interface. Right now, it only includes a Database class(yes, i somewhat copied it from the previous python interface) with support to make a sphere. The use of Database class is demonstrated in wdbexample.py file.

view this post on Zulip Sumagna Das (Jun 02 2020 at 03:16):

So @Sean, what do you think about it?

view this post on Zulip Sean (Jun 02 2020 at 04:48):

@Sumagna Das Where's the wdbexample code? I saw the rtexample but not wdb one...

view this post on Zulip Sean (Jun 02 2020 at 04:49):

It's pretty amazing that you got it all working again. Seriously, the python interface stalled for years because ctypesgen hadn't been ported to python3.

view this post on Zulip Sean (Jun 02 2020 at 04:51):

So next, would be a question on where you want to take this next? I know what I'd love to see but would rather hear your interests and ideas first.

view this post on Zulip Sumagna Das (Jun 02 2020 at 05:36):

Sean said:

Sumagna Das Where's the wdbexample code? I saw the rtexample but not wdb one...

if you mean C code for the wdexample, then its not ported from c but a new file showing the working of libwdb or wdb.h in a more organized looking way.

view this post on Zulip Sean (Jun 02 2020 at 07:15):

you said you created a fake example, wdbexample -- I've not seen this example

view this post on Zulip Sumagna Das (Jun 02 2020 at 07:54):

Sean said:

you said you created a fake example, wdbexample -- I've not seen this example

an example in python (actually not present in c files) showing the prototype working of the python interface

view this post on Zulip Sumagna Das (Jun 03 2020 at 10:43):

Sean said:

So next, would be a question on where you want to take this next? I know what I'd love to see but would rather hear your interests and ideas first.

Tell me what you would like to see. i will try to implement that. i am very much confused as to what to do next

view this post on Zulip Erik (Jun 03 2020 at 10:45):

We would like to hear your ideas and vision and interest, we want to craft this experience to be beneficial to both parties , not "just a job".

view this post on Zulip Sumagna Das (Jun 03 2020 at 10:45):

:smile:

view this post on Zulip Sumagna Das (Jun 03 2020 at 10:46):

i was thinking about creating a prototype rtexample in python(which isn't a direct connversion from C to Python)

view this post on Zulip Sumagna Das (Jun 03 2020 at 10:47):

BTW, what is the "magic" variable in nearly every struct used for?

view this post on Zulip Erik (Jun 03 2020 at 10:50):

It's a number stashed at the beginning to help deduce type, common in programming language implementations

view this post on Zulip Sumagna Das (Jun 03 2020 at 10:51):

ohh

view this post on Zulip Erik (Jun 03 2020 at 10:51):

Bualloca also stashes a little magic up front to help with memory mgmt

view this post on Zulip Sumagna Das (Jun 03 2020 at 10:51):

its just a number then?

view this post on Zulip Erik (Jun 03 2020 at 10:52):

Yes, and arbitrary. They should be #defined in headers if you want to peruse

view this post on Zulip Sumagna Das (Jun 03 2020 at 10:53):

i was going to port vmath.h functions in a python file using numpy

view this post on Zulip Sumagna Das (Jun 03 2020 at 19:31):

Should I complete the Database class first or should I try implementing the raytracing interface?

view this post on Zulip Sumagna Das (Jun 04 2020 at 14:31):

hey @Sean, what is libbn for?

view this post on Zulip Sean (Jun 04 2020 at 14:35):

@Sumagna Das A brief description of all the libraries is in HACKING. bn is for numerics.

view this post on Zulip Sumagna Das (Jun 04 2020 at 14:36):

ok

view this post on Zulip Sumagna Das (Jun 04 2020 at 14:36):

Sumagna Das said:

Should I complete the Database class first or should I try implementing the raytracing interface?

what should i do first?

view this post on Zulip Sumagna Das (Jun 04 2020 at 15:06):

hey @Sean, what information is most required when a ray hits something during raytracing.

view this post on Zulip Sean (Jun 04 2020 at 19:37):

@Sumagna Das The magic numbers definitely shouldn't be translated to python. They are an artifice of C programming, they primarily are used to catch low-level memory corruption.

view this post on Zulip Sean (Jun 04 2020 at 19:37):

Sumagna Das said:

Sumagna Das said:

Should I complete the Database class first or should I try implementing the raytracing interface?

what should i do first?

I would think Database would be more desirable first. Ability to create stuff using python scripts cleanly.

view this post on Zulip Sean (Jun 04 2020 at 19:39):

Sumagna Das said:

hey Sean, what information is most required when a ray hits something during raytracing.

This very much depends on the person or application shooting the rays. It could be almost anything. Some care about the first hit point, some care about the thickness of the things hit, some care about the curvature of the surface at the entry or exit hit point, some care how many things were hit, some want to know whether two objects are in proximity or overlap, etc ...

view this post on Zulip Sumagna Das (Jun 05 2020 at 03:18):

Sean said:

Sumagna Das said:

hey Sean, what information is most required when a ray hits something during raytracing.

This very much depends on the person or application shooting the rays. It could be almost anything. Some care about the first hit point, some care about the thickness of the things hit, some care about the curvature of the surface at the entry or exit hit point, some care how many things were hit, some want to know whether two objects are in proximity or overlap, etc ...

should i see to the rtexample for the information i can send during raytracing?

view this post on Zulip Sean (Jun 05 2020 at 03:21):

@Sumagna Das that's part why I suggested Database first .. ray tracing is an order of magnitude more complicated...

view this post on Zulip Sumagna Das (Jun 05 2020 at 03:21):

okay

view this post on Zulip Sean (Jun 05 2020 at 03:21):

but if that's what's more interesting to you,rtexample is as good a place as any to start. it shows hit points, thicknesses, and normals

view this post on Zulip Sumagna Das (Jun 05 2020 at 03:23):

okay

view this post on Zulip scorp08 (Jun 05 2020 at 07:44):

@Sumagna Das which repo of ctypesgen are you using ? I had forked from https://github.com/olsonse/ctypesgen and did some changes, for py3 but I think olsonse's repo now support py3 :)

view this post on Zulip Sumagna Das (Jun 05 2020 at 11:18):

scorp08 said:

Sumagna Das which repo of ctypesgen are you using ? I had forked from https://github.com/olsonse/ctypesgen and did some changes, for py3 but I think olsonse's repo now support py3 :slight_smile:

https://github.com/davidjamesca/ctypesgen

view this post on Zulip Sumagna Das (Jun 05 2020 at 11:19):

they are even

view this post on Zulip Sumagna Das (Jun 06 2020 at 18:36):

which function in wdb can be used to open existing geometry databases?

view this post on Zulip Sumagna Das (Jun 10 2020 at 13:36):

@Sean i got this error while trying to make a combination

view this post on Zulip Sumagna Das (Jun 10 2020 at 13:36):

ERROR: bad pointer 0x1bf5bb0: s/b rt_comb_internal(x436f6d49), was Unknown_Magic(x22af6f0), file /mnt/sda2/github/brlcad/src/librt/comb/comb.c, line 284

view this post on Zulip Sumagna Das (Jun 10 2020 at 13:37):

what is happening?

view this post on Zulip Sumagna Das (Jun 10 2020 at 15:36):

Sumagna Das said:

ERROR: bad pointer 0x1bf5bb0: s/b rt_comb_internal(x436f6d49), was Unknown_Magic(x22af6f0), file /mnt/sda2/github/brlcad/src/librt/comb/comb.c, line 284

hey @Daniel Rossberg can you help me with this?

view this post on Zulip Daniel Rossberg (Jun 10 2020 at 16:23):

It looks like you made an error, but I've no idea what you made.

view this post on Zulip Sumagna Das (Jun 10 2020 at 16:25):

what can it be related to?

view this post on Zulip Sumagna Das (Jun 10 2020 at 16:26):

what is Unknown_Magic anyways?

view this post on Zulip Daniel Rossberg (Jun 10 2020 at 16:35):

It means that you put an object in a function which expects a combination which was in fact no combination.

view this post on Zulip Sumagna Das (Jun 10 2020 at 17:51):

ok

view this post on Zulip Sumagna Das (Jun 10 2020 at 17:51):

i have to check the code then

view this post on Zulip Sumagna Das (Jun 10 2020 at 19:47):

hey @LordOfBikes why is this coming

ERROR: bad pointer 0x1be4200: s/b union tree(x91191191), was Unknown_Magic(x5f687073), file /mnt/sda2/github/brlcad/src/librt/comb/comb.c, line 93

view this post on Zulip Sumagna Das (Jun 10 2020 at 20:00):

or can you tell me what should be the magic number for the union called "tree"

view this post on Zulip Armin (LordOfBikes) (Jun 11 2020 at 08:10):

Hi @Sumagna Das , sadly I cant help here. I'm a LibreCAD maintainer and do not have sound knowledge of BRL-CAD code base.

view this post on Zulip Sumagna Das (Jun 12 2020 at 05:52):

hey @Sean can you see a backtrace i got and tell me if this is a fault with my code in python(i am calling wdb_export) or this is a fault in the brlcad code?

view this post on Zulip Sumagna Das (Jun 12 2020 at 06:37):

Sumagna Das said:

hey Sean can you see a backtrace i got and tell me if this is a fault with my code in python(i am calling wdb_export) or this is a fault in the brlcad code?

hey @Daniel Rossberg can you help me with this?

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 07:13):

I can't say more as I already did without more information: You probably made an error and used a bad parameter in a function.

view this post on Zulip Sumagna Das (Jun 12 2020 at 07:13):

should i send the backtrace

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 07:14):

This would be a start point.
Where is your source code?

view this post on Zulip Sumagna Das (Jun 12 2020 at 07:15):

python source code?

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 07:19):

Whatever you have written to get it working with Python.

view this post on Zulip Sumagna Das (Jun 12 2020 at 07:26):

(deleted)

view this post on Zulip Sumagna Das (Jun 12 2020 at 07:26):

Daniel Rossberg said:

Whatever you have written to get it working with Python.

sorry for the late reply. i didnt push the changes to my repo.

view this post on Zulip Sumagna Das (Jun 12 2020 at 07:27):

i have to code at https://github.com/sumagnadas/python-brlcad

view this post on Zulip Sumagna Das (Jun 12 2020 at 07:28):

it has the bindings pregenerated and libraries set to default locations(like /usr/brlcad/dev-7.31.0/lib/)

view this post on Zulip Sumagna Das (Jun 12 2020 at 07:30):

so it might be a problem

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 07:46):

Do you have the back-trace too?

view this post on Zulip Sumagna Das (Jun 12 2020 at 07:56):

yea

view this post on Zulip Sumagna Das (Jun 12 2020 at 07:57):

got it from gdb(as per StackOverflow) as it was giving a SIGSEGV

view this post on Zulip Sumagna Das (Jun 12 2020 at 07:57):

should i send it?

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 08:02):

AS far as I can see, this should happen when you create a combination?

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:03):

yea when i am trying to use wdb_export for making a combination(i dont know if i need it)

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:03):

#0  __memcmp_sse4_1 () at ../sysdeps/x86_64/multiarch/memcmp-sse4.S:73
#1  0x00007fffe9f9f5ce in bn_mat_is_identity (m=0x736772615f) at /mnt/sda2/github/brlcad/src/libbn/mat.c:992
#2  0x00007fffea876d12 in db_tree_counter (tp=0xdc9400, tcsp=0x7fffffffc8f0) at /mnt/sda2/github/brlcad/src/librt/comb/comb.c:99
#3  0x00007fffea87788a in rt_comb_export5 (ep=0x7fffffffc9e0, ip=0x7fffffffcaa0, UNUSED_local2mm=1, dbip=0xd53640,
    resp=0x7fffeac88f00 <rt_uniresource>) at /mnt/sda2/github/brlcad/src/librt/comb/comb.c:292
#4  0x00007fffea88fd1b in rt_db_cvt_to_external5 (ext=0x7fffffffca40, name=0x7fffe6750410 "sph_with_args_region", ip=0x7fffffffcaa0, conv2mm=1,
    dbip=0xd53640, resp=0x7fffeac88f00 <rt_uniresource>, major=1) at /mnt/sda2/github/brlcad/src/librt/db5_io.c:663
#5  0x00007fffeabf013f in wdb_put_internal (wdbp=0xd74070, name=0x7fffe6750410 "sph_with_args_region", ip=0x7fffffffcaa0, local2mm=1)
    at /mnt/sda2/github/brlcad/src/librt/wdb.c:246
#6  0x00007fffeabf038d in wdb_export (wdbp=0xd74070, name=0x7fffe6750410 "sph_with_args_region", gp=0xb03a60, id=31, local2mm=1)
    at /mnt/sda2/github/brlcad/src/librt/wdb.c:293
#7  0x00007ffff7fbeff5 in ?? () from /lib/x86_64-linux-gnu/libffi.so.7
#8  0x00007ffff7fbe40a in ?? () from /lib/x86_64-linux-gnu/libffi.so.7
#9  0x00007ffff752e69c in _ctypes_callproc () from /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so
#10 0x00007ffff752ec9c in ?? () from /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so
#11 0x00000000005f2246 in _PyObject_MakeTpCall ()
#12 0x000000000056c70f in _PyEval_EvalFrameDefault ()
#13 0x00000000005654d2 in _PyEval_EvalCodeWithName ()
#14 0x00000000005f1bc5 in _PyFunction_Vectorcall ()
#15 0x0000000000508386 in ?? ()
#16 0x00000000005f0e3e in PyObject_Call ()
#17 0x0000000000568985 in _PyEval_EvalFrameDefault ()
#18 0x00000000005654d2 in _PyEval_EvalCodeWithName ()
#19 0x0000000000507e8f in ?? ()
#20 0x0000000000568404 in _PyEval_EvalFrameDefault ()
#21 0x00000000005654d2 in _PyEval_EvalCodeWithName ()
#22 0x0000000000686d53 in PyEval_EvalCode ()
#23 0x0000000000676101 in ?? ()
#24 0x000000000067617f in ?? ()
#25 0x0000000000676237 in PyRun_FileExFlags ()
#26 0x00000000006782ba in PyRun_SimpleFileExFlags ()
#27 0x00000000006af5ce in Py_RunMain ()
#28 0x00000000006af959 in Py_BytesMain ()
#29 0x00007ffff7de10b3 in __libc_start_main (main=0x4ec640 <main>, argc=2, argv=0x7fffffffdae8, init=<optimized out>, fini=<optimized out>,
    rtld_fini=<optimized out>, stack_end=0x7fffffffdad8) at ../csu/libc-start.c:308
#30 0x00000000005f69be in _start ()

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:03):

this is the backtrace

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:24):

so i was seeing mk_region1() arguments

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:24):

what should be an ideal value for rgb?

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:26):

i mean this one const unsigned char * rgb

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 08:26):

Using wdb_export() is okay, The error is probable in the new_comb structure or how it is transferred to the C functions. What says the debugger about ip->idb_ptr in rt_comb_export5()? How does it look?

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:26):

Daniel Rossberg said:

Using wdb_export() is okay, The error is probable in the new_comb structure or how it is transferred to the C functions. What says the debugger about ip->idb_ptr in rt_comb_export5()? How does it look?

how to see that?

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 08:37):

break rt_comb_export5 in gdb? Step to line 284 and do a print comb there? (I haven't tested it and I'm not very used in using gdb, but it should work somehow like this.)

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:41):

it is giving me this (struct rt_comb_internal *) 0xdb2970

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:42):

this is before stepping to line 284

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:42):

because print comb doesnt work there

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 08:45):

comb is assigned at line 283. That's why you have to go to line 284 first to step over 283 and get this assignment.

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 08:46):

However, how are the members of rt_comb_internal doing? can you attach them to the printed variable (by "->member_name")?

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:48):

print ip->idb_ptr gives me (void *) 0x0

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 08:48):

NULL is not enough ;)

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:49):

what?

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 08:50):

rt_comb_export5() got NULL as input, this is not enough to create a combination.

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:50):

ok

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:51):

sorry gotta go

view this post on Zulip Sumagna Das (Jun 12 2020 at 08:52):

my laptop has 3% charge

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 08:53):

Now, you should go up the call stack in gdb to the wdb_export() function and look what it got from Python (I think it's the frame command).

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 08:53):

Sumagna Das said:

my laptop has 3% charge

Okay, bye...

view this post on Zulip Sumagna Das (Jun 12 2020 at 11:42):

Daniel Rossberg said:

Now, you should go up the call stack in gdb to the wdb_export() function and look what it got from Python (I think it's the frame command).

went up the call stack but what should i specifically look for?

view this post on Zulip Sumagna Das (Jun 12 2020 at 11:46):

i looked at gp and got "ImoC"

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:17):

What is "ImoC"?

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:18):

dont know but i found an interesting thing

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:18):

i have struct tree_db_leaf whose tl_mat is None

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:19):

for which there is an error happening whenever bn_mat_is_identity(tp->tr_l.tl_mat))is called

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:23):

Sumagna Das said:

for which there is an error happening whenever bn_mat_is_identity(tp->tr_l.tl_mat))is called

This shouldn't be an issue because it is tested for NULL before.

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:23):

oh sorry wrong line

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:24):

this is where the error occurs return ! memcmp(m, bn_mat_identity, sizeof(mat_t));

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:28):

m is NULL so the error is coming?

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:29):

It should not call bn_mat_is_identity() if the matrix is NULL. Therefore, what do you mean with "tl_mat is None"?

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:29):

tl_mat is actually NULL

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:30):

None = NULL

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:30):

In this case, bn_mat_is_identity() wan't be called and there can't be an error.

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:30):

so what should i do?

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:34):

It looks like the structure you hand over to wdb_export() is not what you think it is. Break at wdb_export(), check that gp is not NULL, then cast it to rt_comb_internal*, and examine it.

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:36):

sorry if i am asking a stupid question but how to check if its NULL

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:36):

print gp should be something like 0x000000.

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:36):

Nope

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:37):

(struct rt_comb_internal *) 0xb03a50

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:40):

which means it is not NULL

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:40):

(void *) 0xb03a50 when print gp is used

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:41):

What gives you print ((rt_comb_internal*)gp)->magic?

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:42):

1131375945

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:42):

or more specifically 0x436f6d49

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:43):

Is this the right number for a combination?

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:43):

how can i know?

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:44):

should that be RT_COMB_MAGIC?

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:45):

BTW, if gp is 0xb03a50 in wdb_export(), then ip->idb_ptr in wdb_put_internal() should be 0xb03a50 too, right?

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:45):

lemme see

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:46):

print ip->idb_ptr gives (void *) 0xb03a50

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:46):

so yeah they are same

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:48):

But, this value should be assigned to comb in src/librt/comb/comb.c line 283, right?

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:48):

probably

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:48):

I.e., not NULL.

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:48):

umm yeah

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:50):

comb = (struct rt_comb_internal *) 0xb03a50

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:50):

(from gdb)

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:55):

print comb->magic still okay?

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:56):

yea

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:56):

same as before, 1131375945

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:57):

Then, RT_CK_COMB(comb); should be okay too?

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:57):

(the next line in the source code)

view this post on Zulip Sumagna Das (Jun 12 2020 at 12:57):

cant check that from gdb, i think

view this post on Zulip Daniel Rossberg (Jun 12 2020 at 12:58):

step over the next line (284)

view this post on Zulip Sumagna Das (Jun 12 2020 at 13:05):

sorry for not replying but something happened and gdb is giving me SIGSEGV in another area

view this post on Zulip Sumagna Das (Jun 12 2020 at 13:05):

so i will be right back after fixing it

view this post on Zulip Sumagna Das (Jun 12 2020 at 13:43):

so i fixed it

view this post on Zulip Sumagna Das (Jun 12 2020 at 13:56):

Daniel Rossberg said:

Then, RT_CK_COMB(comb); should be okay too?

it is actually alright, it think

view this post on Zulip Sumagna Das (Jun 12 2020 at 13:57):

i couldnt step over to 284

view this post on Zulip Sumagna Das (Jun 13 2020 at 09:49):

hey @Daniel Rossberg , if you come online ping me

view this post on Zulip Sumagna Das (Jun 13 2020 at 09:49):

i need your help to find out why the segfault is happening

view this post on Zulip Sumagna Das (Jun 13 2020 at 11:10):

hey @Daniel Rossberg does what should bn_mat_is_identity return

view this post on Zulip Sumagna Das (Jun 13 2020 at 11:10):

?

view this post on Zulip Sumagna Das (Jun 13 2020 at 11:28):

Sumagna Das said:

hey Daniel Rossberg does what should bn_mat_is_identity return

grammatical mistake: what should bn_mat_is_identity return?

view this post on Zulip Sumagna Das (Jun 13 2020 at 12:00):

new backtrace

view this post on Zulip Sumagna Das (Jun 13 2020 at 12:01):

#0  tcache_get (tc_idx=<optimized out>) at malloc.c:2937
#1  __GI___libc_malloc (bytes=13) at malloc.c:3051
#2  0x00007ffff7e59ad8 in _mid_memalign (address=<optimized out>, bytes=13, alignment=<optimized out>) at malloc.c:3277
#3  __posix_memalign (size=13, alignment=<optimized out>, memptr=0x7fffffffc7a0) at malloc.c:5366
#4  __posix_memalign (memptr=0x7fffffffc7a0, alignment=<optimized out>, size=13) at malloc.c:5353
#5  0x00007fffe7733d91 in alloc (type=CALLOC, cnt=1, sz=13, str=0x7fffeac0dc9b "rt_comb_export5 ext_buf")
    at /mnt/sda2/github/brlcad/src/libbu/malloc.c:137
#6  0x00007fffe7733ee5 in bu_calloc (nelem=1, elsize=13, str=0x7fffeac0dc9b "rt_comb_export5 ext_buf")
    at /mnt/sda2/github/brlcad/src/libbu/malloc.c:174
#7  0x00007fffea877a07 in rt_comb_export5 (ep=0x7fffffffc9d0, ip=0x7fffffffca90, UNUSED_local2mm=1, dbip=0xd75870,
    resp=0x7fffeac88f00 <rt_uniresource>) at /mnt/sda2/github/brlcad/src/librt/comb/comb.c:326
#8  0x00007fffea88fd1b in rt_db_cvt_to_external5 (ext=0x7fffffffca30, name=0x7fffeaf8e090 "sph_with_args_region", ip=0x7fffffffca90, conv2mm=1,
    dbip=0xd75870, resp=0x7fffeac88f00 <rt_uniresource>, major=1) at /mnt/sda2/github/brlcad/src/librt/db5_io.c:663
#9  0x00007fffeabf013f in wdb_put_internal (wdbp=0xd54aa0, name=0x7fffeaf8e090 "sph_with_args_region", ip=0x7fffffffca90, local2mm=1)
    at /mnt/sda2/github/brlcad/src/librt/wdb.c:246
#10 0x00007fffeabf038d in wdb_export (wdbp=0xd54aa0, name=0x7fffeaf8e090 "sph_with_args_region", gp=0xaa9cc0, id=31, local2mm=1)
    at /mnt/sda2/github/brlcad/src/librt/wdb.c:293
#11 0x00007ffff7fbeff5 in ?? () from /lib/x86_64-linux-gnu/libffi.so.7
#12 0x00007ffff7fbe40a in ?? () from /lib/x86_64-linux-gnu/libffi.so.7
#13 0x00007ffff752e69c in _ctypes_callproc () from /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so
#14 0x00007ffff752ec9c in ?? () from /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so
#15 0x00000000005f2246 in _PyObject_MakeTpCall ()
#16 0x000000000056c70f in _PyEval_EvalFrameDefault ()
#17 0x00000000005654d2 in _PyEval_EvalCodeWithName ()
#18 0x00000000005f1bc5 in _PyFunction_Vectorcall ()
#19 0x0000000000508386 in ?? ()
#20 0x00000000005f0e3e in PyObject_Call ()
#21 0x0000000000568985 in _PyEval_EvalFrameDefault ()
#22 0x00000000005654d2 in _PyEval_EvalCodeWithName ()
#23 0x0000000000507e8f in ?? ()
#24 0x0000000000568404 in _PyEval_EvalFrameDefault ()
#25 0x00000000005654d2 in _PyEval_EvalCodeWithName ()
#26 0x0000000000686d53 in PyEval_EvalCode ()
#27 0x0000000000676101 in ?? ()
#28 0x000000000067617f in ?? ()
#29 0x0000000000676237 in PyRun_FileExFlags ()
#30 0x00000000006782ba in PyRun_SimpleFileExFlags ()
#31 0x00000000006af5ce in Py_RunMain ()
#32 0x00000000006af959 in Py_BytesMain ()
#33 0x00007ffff7de10b3 in __libc_start_main (main=0x4ec640 <main>, argc=2, argv=0x7fffffffdad8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdac8) at ../csu/libc-start.c:308
#34 0x00000000005f69be in _start ()

view this post on Zulip Daniel Rossberg (Jun 13 2020 at 17:28):

Sumagna Das said:

hey Daniel Rossberg does what should bn_mat_is_identity return

It's declared in include/bn/mat.h.

I'll run your Python tests by myself, next week.

view this post on Zulip Sumagna Das (Jun 13 2020 at 17:52):

sure and they are not actually tests but simple demonstrations of what is possible with the interface right now

view this post on Zulip Sumagna Das (Jun 13 2020 at 17:55):

but take care to change the genwrapper file according to your brlcad installation location

view this post on Zulip Sumagna Das (Jun 13 2020 at 18:23):

my installation is default and version is dev-7.31.0

view this post on Zulip Sumagna Das (Jun 14 2020 at 07:30):

Hey @Daniel Rossberg , if you cloned the github repo for python-brlcad before today, then it might not have the recent changes which fix the memcmp problem and has the recent problem i am struggling to fx

view this post on Zulip Sean (Jun 15 2020 at 15:15):

@Sumagna Das how does one reproduce the error you're seeing? The backtrace is still indicating that the call to wdb_export() is wrong. As this is happening on the FFI side of things for ctypesgen, it may be a sign there's something wrong in the binding setup. That said, the crash deep inside malloc typically indicates general corruption too. It might help to run inside valgrind to catch the memory fault earlier.

view this post on Zulip Sumagna Das (Jun 16 2020 at 03:31):

the malloc error is most recent one which i couldnt fix

view this post on Zulip Sumagna Das (Jun 17 2020 at 20:58):

Umm I don't know much about the use of valgrind so a little help will be good for me

view this post on Zulip Sumagna Das (Jun 18 2020 at 03:49):

so i tried using valgrind but cant understand much of it

view this post on Zulip Sumagna Das (Jun 18 2020 at 03:50):

if you guys can get anything out of it please notify me

view this post on Zulip Sumagna Das (Jun 18 2020 at 03:50):

valgrind.log

view this post on Zulip Sumagna Das (Jun 18 2020 at 03:50):

this is the log

view this post on Zulip Sumagna Das (Jun 18 2020 at 11:18):

hey @Daniel Rossberg , what should the shaderargs argument get in this function? https://brlcad.org/docs/doxygen-r64112/db/d4a/group__wdb.xhtml#ga67ddf35d1fcfc8399d90bb8b527700bf

view this post on Zulip Daniel Rossberg (Jun 18 2020 at 17:44):

grep says, that shaderargs is usually empty (NULL or ""), but only for shadername "light" "shadows=1" is a good value.

view this post on Zulip Sumagna Das (Jun 19 2020 at 04:19):

Daniel Rossberg said:

grep says, that shaderargs is usually empty (NULL or ""), but only for shadername "light" "shadows=1" is a good value.

thanks

view this post on Zulip Sumagna Das (Jun 19 2020 at 04:20):

i might try using mk_region1 for making regions if thats what it is supposed to do

view this post on Zulip Sumagna Das (Jun 19 2020 at 04:40):

and i also want to know...

view this post on Zulip Sumagna Das (Jun 19 2020 at 04:41):

why is the function called mk_region1 and not mk_region(i know there is a full caps MK_REGION definition)

view this post on Zulip Sumagna Das (Jun 19 2020 at 04:46):

Daniel Rossberg said:

grep says, that shaderargs is usually empty (NULL or ""), but only for shadername "light" "shadows=1" is a good value.

i also forgot to ask another thing. what is the membname supposed to be?

view this post on Zulip Sumagna Das (Jun 19 2020 at 04:51):

or what should be an ideal call to this function

view this post on Zulip Daniel Rossberg (Jun 20 2020 at 17:20):

Sumagna Das said:

i also forgot to ask another thing. what is the membname supposed to be?

It's the name of the object you want to put in the region. E.g., the name of an arb8.

The "1" means that you create a region with only one member. There is a mk_comb1() too.

view this post on Zulip Sumagna Das (Jun 20 2020 at 19:10):

Daniel Rossberg said:

Sumagna Das said:

i also forgot to ask another thing. what is the membname supposed to be?

It's the name of the object you want to put in the region. E.g., the name of an arb8.

The "1" means that you create a region with only one member. There is a mk_comb1() too.

by the object u mean the name of the shape

view this post on Zulip Sumagna Das (Jun 20 2020 at 19:12):

i have a sph object named 'sphere' and i passed the shader "plastic {di .9 sp .4}"

view this post on Zulip Sumagna Das (Jun 20 2020 at 19:29):

so should the call to function be like mk_region1(h.db_fp, "random", "sphere", "plastic {di .9 sp .4}", ""/None, "255 0 0") where arguments are fp=h.db_fp, combname="random", membname="sphere", shadername="plastic {di .9 sp .4}", shaderargs=("" or None), rgb="255 0 0"(i dont know much about the rgb argument)

view this post on Zulip Daniel Rossberg (Jun 21 2020 at 18:48):

The rgb is not a real string but a 3 byte value with the colors. I.e. a unsigned char rgb[3] with the numbers for red, green, and blue between 0 and 255.

view this post on Zulip Sumagna Das (Jun 21 2020 at 18:49):

ohh

view this post on Zulip Sumagna Das (Jun 21 2020 at 18:50):

can that be a reason for it returning a zero?

view this post on Zulip Sumagna Das (Jun 21 2020 at 18:50):

i was passing a string and not an array of unsigned char

view this post on Zulip Sumagna Das (Jun 25 2020 at 15:24):

@Daniel Rossberg, so that might be the reason for the mk_region1 returning 0 when i called it with the above arguments

view this post on Zulip Sumagna Das (Jun 25 2020 at 16:38):

python-mk_region1.png

view this post on Zulip Sumagna Das (Jun 25 2020 at 16:38):

the previous lines show what the arguments i am passing

view this post on Zulip Daniel Rossberg (Jun 25 2020 at 16:44):

You can try to pass 0 (NULL), which means "no color", for now.

view this post on Zulip Sean (Jun 25 2020 at 21:40):

Sumagna Das said:

why is the function called mk_region1 and not mk_region(i know there is a full caps MK_REGION definition)

This predates me, but it's quite likely that either (A) there was an mk_region for v4 databases that got replaced when we moved to v5 format (late 90's) or (B) it was to avoid confusion with MK_REGION, particularly for 3rd party devs working in case-insensitive languages like FORTRAN (which was a thing long ago). We should rename it (heck the entire "mk_" prefix is inconsistent and clumsy), and likely will when libg comes to life.

view this post on Zulip Sean (Jun 25 2020 at 21:41):

or what daniel said, makes even more sense.. I forgot all about mk_comb1! hah.

view this post on Zulip Sumagna Das (Jun 26 2020 at 05:03):

Daniel Rossberg said:

You can try to pass 0 (NULL), which means "no color", for now.

passed NULL but nothing new

view this post on Zulip Sumagna Das (Jun 26 2020 at 05:04):

still gives me 0 for some reason

view this post on Zulip Sean (Jun 26 2020 at 06:00):

@Sumagna Das To clarify, are you saying the return code from mk_region1 is a zero and you're wondering why?

view this post on Zulip Sean (Jun 26 2020 at 06:00):

I believe a zero return code indicates success...

view this post on Zulip Sean (Jun 26 2020 at 06:03):

mk_region1 returns what mk_comb returns which returns what wdb_put_internal returns which returns what wdb_export_external returns which returns zero on success, or non-zero on failure anywhere along that call stack.

view this post on Zulip Sumagna Das (Jun 26 2020 at 06:57):

oh

view this post on Zulip Sumagna Das (Jun 26 2020 at 06:57):

i went with the boolean true-false(0=false, 1=true)

view this post on Zulip Sumagna Das (Jun 26 2020 at 06:58):

btw shouldnt the color of the region show up during raytracing?

view this post on Zulip Sean (Jun 26 2020 at 07:00):

understandable. always good to check the header and/or implementation. it's not typical for C functions that have a plethora of potential error conditions to return just zero for all of them unless there's some sort of error argument or a separate error function that will tell you which occurred.

view this post on Zulip Sumagna Das (Jun 26 2020 at 07:01):

(deleted)

view this post on Zulip Sean (Jun 26 2020 at 07:01):

Sumagna Das said:

btw shouldnt the color of the region show up during raytracing?

it depends how the color was set and what you're drawing, but in general yes it should i you set one. that's pretty easy to sort out by looking at the resulting geometry.

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:43):

so coming to the next issue

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:44):

what should be passed to mk_comb() to make a region?

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:44):

i have had no luck with mk_region1()

view this post on Zulip Sean (Jun 26 2020 at 19:45):

what does your mk_region1 call look like?

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:46):

Sumagna Das said:

python-mk_region1.png

this is from the python interactive shell

view this post on Zulip Sean (Jun 26 2020 at 19:46):

yes, and? :)

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:46):

and?

view this post on Zulip Sean (Jun 26 2020 at 19:47):

do you know how the python code is transforming the wdb.mk_region1 into the actual function call?

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:48):

i thought it calls the C function directly from this

view this post on Zulip Sean (Jun 26 2020 at 19:48):

okay
do you know that j.db_fp.contents is right or should that be j.db_fp?

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:49):

i think it is

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:50):

Sean said:

okay
do you know that j.db_fp.contents is right or should that be j.db_fp?

j.db_fp actually

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:50):

it produces the same when called with j.db_fp

view this post on Zulip Sean (Jun 26 2020 at 19:51):

what does it produce?

view this post on Zulip Sean (Jun 26 2020 at 19:51):

also, huge different between those two -- need to know which was right

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:51):

i wanted to mean it returns the same

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:51):

0

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:51):

btw should i move the dev-7.31.0-disabled folder back

view this post on Zulip Sean (Jun 26 2020 at 19:52):

uhm, I'm not sure the return value has any meaning yet

view this post on Zulip Sean (Jun 26 2020 at 19:52):

you should be checking the actual result

view this post on Zulip Sean (Jun 26 2020 at 19:52):

the database needs to be closed, and then see if it made a "random" object

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:53):

Sumagna Das said:

btw should i move the dev-7.31.0-disabled folder back

view this post on Zulip Sean (Jun 26 2020 at 19:54):

doesn't matter -- you don't need to install if you're not going to be running from there. if you are going to run from there, you need to consistently run "make install" or you'll end up needing to debug weird states where what's in the install location doesn't match what's in the build tree

view this post on Zulip Sean (Jun 26 2020 at 19:54):

having both a build tree specified to compile into /usr/brlcad/dev-7.31.0 and ALSO a previous dev version installed in that same location is just asking for trouble.

view this post on Zulip Sean (Jun 26 2020 at 19:55):

if you're not going to use it, you can just delete it or leave it disabled.

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:55):

i needed the libraries from the lib folder

view this post on Zulip Sean (Jun 26 2020 at 19:55):

ah, for linking against ctypesgen?

view this post on Zulip Sean (Jun 26 2020 at 19:55):

sure

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:55):

and i dont want to change every line containing the wrong path in the raw bindings

view this post on Zulip Sean (Jun 26 2020 at 19:56):

so yeah, you can move it back -- just keep in mind that if you run into something weird with mged again, first thing to check will be making sure you "make install"'d

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:57):

region is not there

view this post on Zulip Sean (Jun 26 2020 at 19:57):

how was the database closed?

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:57):

i called the function just now and checked if the region was there

view this post on Zulip Sean (Jun 26 2020 at 19:57):

which function?

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:57):

from mged

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:57):

i checked from mged

view this post on Zulip Sumagna Das (Jun 26 2020 at 19:58):

wdb.wdb_close(self.db_fp) to close the database

view this post on Zulip Sean (Jun 26 2020 at 19:58):

there's no python binding in mged that will close the j.db_ip you were using

view this post on Zulip Sean (Jun 26 2020 at 19:59):

how is j.db_ip different from self.db_fp ?
and where did .contents come from? really need to know which is correct.

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:00):

db_ip is the db_i pointer

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:00):

db_fp is the rt_wdb pointer

view this post on Zulip Sean (Jun 26 2020 at 20:01):

I meant j.db_fp and self.db_fp

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:01):

the .contents is the main variable(not the pointer form)

view this post on Zulip Sean (Jun 26 2020 at 20:02):

are there any other mk_ calls that work? what do they look like?

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:02):

the fucntion call in the picture i referenced was when i was still seeing if it works

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:02):

mk_sph?

view this post on Zulip Sean (Jun 26 2020 at 20:02):

what's a call to it look like?

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:02):

just like they are normally called from c code

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:03):

the functions are called the same way in python as they are called in C

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:04):

the arguments are same

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:04):

it differs in the language they are called from

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:05):

>>> wdb.mk_comb()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: this function takes at least 14 arguments (0 given)

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:06):

the mk_comb requires (as it seems) 14 arguments from python

view this post on Zulip Sumagna Das (Jun 26 2020 at 20:13):

so what should a mk_comb call look like for a region in C?

view this post on Zulip Sean (Jun 26 2020 at 22:12):

mk_region1 just calls mk_comb, so if you can't get region working, you're less likely to get comb working ;)

view this post on Zulip Sean (Jun 26 2020 at 22:12):

mk_comb is fully generalized (hence the 14 arguments...)

view this post on Zulip Sean (Jun 26 2020 at 22:12):

can you show me a call to mk_sph that works?

view this post on Zulip Sumagna Das (Jun 27 2020 at 10:50):

yea wait

view this post on Zulip Sumagna Das (Jun 27 2020 at 11:08):

wdb.mk_sph(self.db_fp, name, point_t(*center), radius) where radius is 1 by default (if no arguments are provided), center is a tuple (0, 0, 0) if no arguments are provided and name is the name of the sph to be made

view this post on Zulip Sumagna Das (Jun 27 2020 at 13:01):

btw you might find this call in the Database class in the repo

view this post on Zulip Sean (Jul 01 2020 at 07:14):

okay, so then your region call should be something like wdb.mk_region1(self.db_fp, combname, membname, "", "", rgb).

I suspect the issue is passing None for NULL (my quick reading indicates that's not how ctypesgen works). There's also a question of what 'h' was as it looked like in your code that you were supposed to pass 'rgb' (or maybe wants it as a byte array).

view this post on Zulip Sumagna Das (Jul 01 2020 at 22:27):

h = rgb

view this post on Zulip Sumagna Das (Jul 01 2020 at 22:27):

rgb was a more generalized name of the variable

view this post on Zulip Sean (Jul 01 2020 at 22:30):

sure, but I mean it might need to be in a different format like bytes(rgb)

view this post on Zulip Sean (Jul 01 2020 at 22:32):

you'd have to know more intimately what ctypesgen does with a int[3], because the function is expecting a char[3] and will have no way to know how to convert.

view this post on Zulip Sumagna Das (Jul 02 2020 at 16:08):

i am passing an unsigned char, which is interpreted as c_ubyte in ctypes.

view this post on Zulip Sumagna Das (Jul 02 2020 at 16:10):

Sean said:

okay, so then your region call should be something like wdb.mk_region1(self.db_fp, combname, membname, "", "", rgb).

I suspect the issue is passing None for NULL (my quick reading indicates that's not how ctypesgen works). There's also a question of what 'h' was as it looked like in your code that you were supposed to pass 'rgb' (or maybe wants it as a byte array).

passing None might be the issue

view this post on Zulip Sumagna Das (Jul 02 2020 at 16:36):

i tried calling the way you said but it just doesnt work

view this post on Zulip Sean (Jul 02 2020 at 22:13):

Sumagna Das said:

i am passing an unsigned char, which is interpreted as c_ubyte in ctypes.

The parameter to mk_region1 doesn't take an unsigned char... it takes a pointer to one. i.e., an array of three unsigned chars.

view this post on Zulip Sean (Jul 02 2020 at 22:18):

Unless you meant c_ubyte* that could also be the issue. Can you step through it in a debugger? That will say for certain what is going on and whether the arguments are correct. Just put a breakpoint on mk_region1.

view this post on Zulip Sean (Jul 02 2020 at 22:18):

Do you know how to do that?

view this post on Zulip Sumagna Das (Jul 03 2020 at 17:52):

Sean said:

Unless you meant c_ubyte* that could also be the issue. Can you step through it in a debugger? That will say for certain what is going on and whether the arguments are correct. Just put a breakpoint on mk_region1.

i actually meant c_ubyte *. Sorry for the confusion

view this post on Zulip Sumagna Das (Jul 04 2020 at 10:13):

hey @Sean , I was thinking about switching the bindings generator to this one https://github.com/gjcarneiro/pybindgen

view this post on Zulip Sumagna Das (Jul 04 2020 at 10:13):

the ctypesgen one is having some minor problems

view this post on Zulip Sumagna Das (Jul 04 2020 at 10:13):

so should i try switching to this one?

view this post on Zulip Sean (Jul 08 2020 at 18:43):

@Sumagna Das If you feel it's worth trying, sure go for it. You're already way further with ctypesgen than I thought possible.

Did you try running in a debugger to see what was wrong with mk_region1?

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:01):

Sean said:

Sumagna Das If you feel it's worth trying, sure go for it. You're already way further with ctypesgen than I thought possible.

Did you try running in a debugger to see what was wrong with mk_region1?

i set a breakpoint but it doesnt touch that in gdb

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:03):

it shows pending but never touches that

view this post on Zulip Sean (Jul 08 2020 at 20:14):

what about mk_comb?

view this post on Zulip Sean (Jul 08 2020 at 20:14):

what did you set the breakpoint on?

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:15):

first on the rgb[0] = 153(the previous line), then on mk_region1 call

view this post on Zulip Sean (Jul 08 2020 at 20:19):

if it doesn't break on mk_region1, then you're either crashing/failing before it gets to libwdb or you're not using the debugger in a way that it'll break properly.

view this post on Zulip Sean (Jul 08 2020 at 20:19):

how did you set a breakpoint on the python line??

view this post on Zulip Sean (Jul 08 2020 at 20:19):

what debugger are you using?

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:19):

b trial.py:7 and gdb

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:22):

it not crashing or else gdb wouldnt have reported [Inferior 1 (process 19575) exited normally]

view this post on Zulip Sean (Jul 08 2020 at 20:24):

did you try a simple "b mk_region1" ?

view this post on Zulip Sean (Jul 08 2020 at 20:24):

or did you use the line number?

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:24):

line number

view this post on Zulip Sean (Jul 08 2020 at 20:25):

try using the symbol instead
should also be able to set a breakpoint on something simple to confirm it's breaking properly like mk_sph or wdb_fopen

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:26):

symbol?

view this post on Zulip Sean (Jul 08 2020 at 20:27):

"b mk_region1" tells gdb to break when it encounters the mk_region1 symbol

view this post on Zulip Sean (Jul 08 2020 at 20:27):

whenever and however it is encountered

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:28):

hmmm

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:29):

as it seems...

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:29):

gdb (or python) cannot access shaderargs and rgb

view this post on Zulip Sean (Jul 08 2020 at 20:30):

so it stopped in mk_region1?

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:30):

yea

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:31):

#0 mk_region1 (wdbp=0x7ffff7fbde79, combname=0x8 <error: Cannot access memory at address 0x8>, membname=0x7fffffffd160 "\001", shadername=0x7ffff3158c98 "x\331>\367\377\177", shaderargs=0x1 <error: Cannot access memory at address 0x1>, rgb=0xf <error: Cannot access memory at address 0xf>) at /mnt/sda2/github/brlcad/src/libwdb/reg.c:373

view this post on Zulip Sean (Jul 08 2020 at 20:32):

cool, looks like all the args are invalid, not just shaderargs and rgb. and their values are a telling indication of something else wrong.

view this post on Zulip Sean (Jul 08 2020 at 20:32):

combname is x8

view this post on Zulip Sean (Jul 08 2020 at 20:32):

that's wrong

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:32):

x8?

view this post on Zulip Sean (Jul 08 2020 at 20:32):

combname=0x8

view this post on Zulip Sean (Jul 08 2020 at 20:33):

it should be a pointer to a string. it's the number 8

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:33):

wdb.mk_region1(h.db_fp, 'random', 'comb0', "", "", rgb)

view this post on Zulip Sean (Jul 08 2020 at 20:34):

same with shaderargs being '1' and rgb being 15

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:34):

this is the call from my python script

view this post on Zulip Sean (Jul 08 2020 at 20:35):

right, it should be a pointer to "random" but instead it's the value 8

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:35):

is my call wrong?

view this post on Zulip Sean (Jul 08 2020 at 20:36):

given the other examples, that seems unlikely. either memory is simply corrupted due to something else wrong or the ctypesgen mapping isn't set up right or ... it's something we're not yet seeing.

view this post on Zulip Sean (Jul 08 2020 at 20:37):

how familiar are you with gdb? print the whole stack trace, go up and see where the vars are coming from

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:37):

yea wait

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:45):

i went up where the vars are coming from and supposedly the variables are divided into two dicts i.e., globals and locals

view this post on Zulip Sean (Jul 08 2020 at 20:46):

ima need a paste or screenshot to help understand

view this post on Zulip Sumagna Das (Jul 08 2020 at 20:55):

#0  mk_region1 (wdbp=0x7ffff7fbde79, combname=0x8 <error: Cannot access memory at address 0x8>, membname=0x7fffffffd160 "\001",
    shadername=0x7ffff3158c98 "x\331>\367\377\177", shaderargs=0x1 <error: Cannot access memory at address 0x1>,
    rgb=0xf <error: Cannot access memory at address 0xf>) at /mnt/sda2/github/brlcad/src/libwdb/reg.c:373
#1  0x00007ffff7fbeff5 in ?? () from /lib/x86_64-linux-gnu/libffi.so.7
#2  0x00007ffff7fbe40a in ?? () from /lib/x86_64-linux-gnu/libffi.so.7
#3  0x00007ffff752e69c in _call_function_pointer (argcount=6, resmem=0x7fffffffd320, restype=<optimized out>, atypes=0x7fffffffd2a0,
    avalues=0x7fffffffd2e0, pProc=0x7ffff34cfea8 <mk_region1>, flags=<optimized out>) at ./Modules/_ctypes/callproc.c:871
#4  _ctypes_callproc (pProc=<optimized out>, argtuple=<optimized out>, flags=<optimized out>, argtypes=<optimized out>, restype=<optimized out>,
    checker=<optimized out>) at ./Modules/_ctypes/callproc.c:1199
#5  0x00007ffff752ec9c in PyCFuncPtr_call (self=<optimized out>, inargs=<optimized out>, kwds=0x0) at ./Modules/_ctypes/_ctypes.c:4201
#6  0x00000000005f2246 in _PyObject_MakeTpCall (callable=<_FuncPtr(__name__='mk_region1') at remote 0x7ffff2934700>, args=<optimized out>,
    nargs=<optimized out>, keywords=<optimized out>) at ../Include/internal/pycore_pyerrors.h:13
#7  0x000000000056c70f in _PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x7ffff75837b8,
    callable=<_FuncPtr(__name__='mk_region1') at remote 0x7ffff2934700>) at ../Include/cpython/abstract.h:125
#8  _PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x7ffff75837b8,
    callable=<_FuncPtr(__name__='mk_region1') at remote 0x7ffff2934700>) at ../Include/cpython/abstract.h:115
#9  call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, tstate=0x95a220) at ../Python/ceval.c:4987
#10 _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at ../Python/ceval.c:3469
#11 0x00000000005654d2 in PyEval_EvalFrameEx (throwflag=0, f=Frame 0x7ffff7583640, for file trial.py, line 9, in <module> ())
    at ../Python/ceval.c:741
#12 _PyEval_EvalCodeWithName (_co=<optimized out>, globals=<optimized out>, locals=<optimized out>, args=<optimized out>, argcount=<optimized out>,
    kwnames=<optimized out>, kwargs=0x0, kwcount=<optimized out>, kwstep=2, defs=0x0, defcount=0, kwdefs=0x0, closure=0x0, name=0x0, qualname=0x0)
    at ../Python/ceval.c:4298
#13 0x0000000000686d53 in PyEval_EvalCodeEx (closure=0x0, kwdefs=0x0, defcount=0, defs=0x0, kwcount=0, kws=0x0, argcount=0, args=0x0,
    locals=<optimized out>, globals=<optimized out>, _co=<optimized out>) at ../Python/ceval.c:4327
#14 PyEval_EvalCode (co=<optimized out>, globals=<optimized out>, locals=<optimized out>) at ../Python/ceval.c:718
#15 0x0000000000676101 in run_eval_code_obj (co=0x7ffff753ff50,
    globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='trial.py') at remote 0x7ffff75446d0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff760d0e0>, '__file__': 'trial.py', '__cached__': None, 'Database': <_ctypes.PyCStructType at remote 0x108ed60>, 'wdb': <module at remote 0x7ffff7498860>, 'pdb': <module at remote 0x7ffff7498680>, 'h': <Database(db_ip=<LP_struct_db_i at remote 0x7fffe65f6940>, db_fp=<LP_struct_rt_wdb at remote 0x7fffe65f62c0>) at remote 0x7fffe65f6840>, 'rgb': <c_ubyte_Array_3 at remote 0x7fffe65f68c0>},
    locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='trial.py') at remote 0x7ffff75446d0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff760d0e0>, '__file__': 'trial.py', '__cached__': None, 'Database': <_ctypes.PyCStructType at remote 0x108ed60>, 'wdb': <module at remote 0x7ffff7498860>, 'pdb': <module at remote 0x7ffff7498680>, 'h': <--Type <RET> for more, q to quit, c to continue without paging--c
Database(db_ip=<LP_struct_db_i at remote 0x7fffe65f6940>, db_fp=<LP_struct_rt_wdb at remote 0x7fffe65f62c0>) at remote 0x7fffe65f6840>, 'rgb': <c_ubyte_Array_3 at remote 0x7fffe65f68c0>}) at ../Python/pythonrun.c:1125
#16 0x000000000067617f in run_mod (mod=<optimized out>, filename=<optimized out>, globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='trial.py') at remote 0x7ffff75446d0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff760d0e0>, '__file__': 'trial.py', '__cached__': None, 'Database': <_ctypes.PyCStructType at remote 0x108ed60>, 'wdb': <module at remote 0x7ffff7498860>, 'pdb': <module at remote 0x7ffff7498680>, 'h': <Database(db_ip=<LP_struct_db_i at remote 0x7fffe65f6940>, db_fp=<LP_struct_rt_wdb at remote 0x7fffe65f62c0>) at remote 0x7fffe65f6840>, 'rgb': <c_ubyte_Array_3 at remote 0x7fffe65f68c0>}, locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='trial.py') at remote 0x7ffff75446d0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff760d0e0>, '__file__': 'trial.py', '__cached__': None, 'Database': <_ctypes.PyCStructType at remote 0x108ed60>, 'wdb': <module at remote 0x7ffff7498860>, 'pdb': <module at remote 0x7ffff7498680>, 'h': <Database(db_ip=<LP_struct_db_i at remote 0x7fffe65f6940>, db_fp=<LP_struct_rt_wdb at remote 0x7fffe65f62c0>) at remote 0x7fffe65f6840>, 'rgb': <c_ubyte_Array_3 at remote 0x7fffe65f68c0>}, flags=<optimized out>, arena=<optimized out>) at ../Python/pythonrun.c:1147
#17 0x0000000000676237 in PyRun_FileExFlags (fp=0x95a9b0, filename_str=<optimized out>, start=<optimized out>, globals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='trial.py') at remote 0x7ffff75446d0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff760d0e0>, '__file__': 'trial.py', '__cached__': None, 'Database': <_ctypes.PyCStructType at remote 0x108ed60>, 'wdb': <module at remote 0x7ffff7498860>, 'pdb': <module at remote 0x7ffff7498680>, 'h': <Database(db_ip=<LP_struct_db_i at remote 0x7fffe65f6940>, db_fp=<LP_struct_rt_wdb at remote 0x7fffe65f62c0>) at remote 0x7fffe65f6840>, 'rgb': <c_ubyte_Array_3 at remote 0x7fffe65f68c0>}, locals={'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <SourceFileLoader(name='__main__', path='trial.py') at remote 0x7ffff75446d0>, '__spec__': None, '__annotations__': {}, '__builtins__': <module at remote 0x7ffff760d0e0>, '__file__': 'trial.py', '__cached__': None, 'Database': <_ctypes.PyCStructType at remote 0x108ed60>, 'wdb': <module at remote 0x7ffff7498860>, 'pdb': <module at remote 0x7ffff7498680>, 'h': <Database(db_ip=<LP_struct_db_i at remote 0x7fffe65f6940>, db_fp=<LP_struct_rt_wdb at remote 0x7fffe65f62c0>) at remote 0x7fffe65f6840>, 'rgb': <c_ubyte_Array_3 at remote 0x7fffe65f68c0>}, closeit=1, flags=0x7fffffffd938) at ../Python/pythonrun.c:1063
#18 0x00000000006782ba in PyRun_SimpleFileExFlags (fp=0x95a9b0, filename=<optimized out>, closeit=1, flags=0x7fffffffd938) at ../Python/pythonrun.c:428
#19 0x00000000006af5ce in pymain_run_file (cf=0x7fffffffd938, config=0x95ad90) at ../Modules/main.c:381
#20 pymain_run_python (exitcode=0x7fffffffd930) at ../Modules/main.c:565
#21 Py_RunMain () at ../Modules/main.c:644
#22 0x00000000006af959 in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at ../Modules/main.c:698
#23 0x00007ffff7de10b3 in __libc_start_main (main=0x4ec640 <main>, argc=2, argv=0x7fffffffdb18, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdb08) at ../csu/libc-start.c:308
#24 0x00000000005f69be in _start () at ../Objects/obmalloc.c:1233

view this post on Zulip Sean (Jul 08 2020 at 21:02):

cool, so looks like it's definitely getting called through ctypes, doing a FFI function lookup to call mk_region1

view this post on Zulip Sean (Jul 08 2020 at 21:03):

from the look of it, I would guess is that the ctypes marshalling is wrong which mean ctypesgen isn't specified correctly or it's parsing something incorrectly

view this post on Zulip Sean (Jul 08 2020 at 21:05):

you could try going up to frame #3, to _call_function_pointer, and inspect atypes and avalues ... those presumably are the arguments. confirm that the first argument is the right type. it should be a c_char_p, however that get encoded in atypes

view this post on Zulip Sumagna Das (Jul 08 2020 at 21:08):

atypes = (ffi_type **) 0x7fffffffd2a0

view this post on Zulip Sumagna Das (Jul 08 2020 at 21:08):

avalues = (void **) 0x7fffffffd2e0

view this post on Zulip Sumagna Das (Jul 08 2020 at 21:11):

there's nothing much in those two variables

view this post on Zulip Sumagna Das (Jul 10 2020 at 13:37):

The globals and locals in one of the frames are the variables I am using to call mk_region1

view this post on Zulip Sumagna Das (Jul 10 2020 at 13:37):

Probably in frame 17

view this post on Zulip Sumagna Das (Jul 12 2020 at 07:37):

Sumagna Das said:

The globals and locals in one of the frames are the variables I am using to call mk_region1

the main thing here is that i cant check from them

view this post on Zulip Sumagna Das (Jul 12 2020 at 07:38):

like this one 'rgb': <c_ubyte_Array_3 at remote 0x7fffe65f68c0>}

view this post on Zulip Sumagna Das (Jul 12 2020 at 07:38):

it says at remote 0x7fffe65f68c0

view this post on Zulip Sean (Jul 13 2020 at 05:52):

Sumagna Das said:

there's nothing much in those two variables

everything is in those two variables :grinning:

it's just typewise, they are opaque. you have to lok at atypes to get the ffi type, then one can cast the a_values pointer to the right type from void*

view this post on Zulip Sumagna Das (Jul 13 2020 at 06:10):

Sean said:

Sumagna Das said:

there's nothing much in those two variables

everything is in those two variables :grinning:

it's just typewise, they are opaque. you have to look at atypes to get the ffi type, then one can cast the a_values pointer to the right type from void*

i mean i dont know which type it is and which type to cast avalues to so that i can get what it contains

view this post on Zulip Sean (Jul 13 2020 at 19:12):

if you read atypes[0] or *atypes[0], that should give an ffi type directly or a code that implies a type indirectly.

view this post on Zulip Sean (Jul 13 2020 at 19:12):

then you cast avalues[0] or *avalues[0] to whatever that type is, probably. maybe a field of *avalues[0], depends what you see.

view this post on Zulip Sumagna Das (Jul 13 2020 at 19:14):

i have to see to that later

view this post on Zulip Sean (Jul 13 2020 at 19:16):

I wish there was a way I could attach to your debugger remotely!

view this post on Zulip Sean (Jul 13 2020 at 19:17):

@Sumagna Das do you have a .bz account? you could try setting up and running on our server and I could see what's going on there.

view this post on Zulip Sumagna Das (Jul 13 2020 at 19:27):

Sean said:

Sumagna Das do you have a .bz account? you could try setting up and running on our server and I could see what's going on there.

will do that if u want

view this post on Zulip Sumagna Das (Jul 13 2020 at 19:29):

and also where should i signup?

view this post on Zulip Sean (Jul 13 2020 at 19:31):

will follow up with private messages

view this post on Zulip Sumagna Das (Jul 13 2020 at 19:31):

ok

view this post on Zulip Sumagna Das (Jul 28 2020 at 14:26):

hey @Sean, i setted up python-brlcad on the server. i didnt have time before today....

view this post on Zulip Sumagna Das (Jul 28 2020 at 14:27):

you can see now what it says

view this post on Zulip Sumagna Das (Oct 05 2020 at 07:29):

i changed the bindings generator from ctypesgen to pybindgen.

view this post on Zulip Sumagna Das (Oct 05 2020 at 07:29):

i am going to try it out and see if it works.

view this post on Zulip Sumagna Das (Oct 05 2020 at 07:30):

the ctypesgen was not working out for me

view this post on Zulip Sumagna Das (Oct 05 2020 at 07:31):

@Sean if it works, i will tell you else it will be dead as before

view this post on Zulip Sumagna Das (Oct 05 2020 at 07:35):

one of the main problems i have encountered till now is that the lib path has to be in the LD_LIBRARY_PATH variable if on linux

view this post on Zulip Sumagna Das (Oct 05 2020 at 07:35):

dont know the same for windows

view this post on Zulip Sumagna Das (Oct 05 2020 at 20:23):

it still doesnt get all the functions :sad: :cry: :sweat:


Last updated: Oct 09 2024 at 00:44 UTC