Stream: new members

Topic: typein.c


view this post on Zulip Debkamal Mullick (Mar 02 2021 at 06:39):

Hi,

Is the " TODO : Add support for line, curve, beizer, " on line no.630 of src/libged/typein/typein.c a requirement as of now?
Any reference or tips to attempt it?

view this post on Zulip Sean (Mar 02 2021 at 06:41):

Hi @Debkamal Mullick depends what you mean by requirement. It is desired functionality, yes. The best tip would be to study that file to understand what it's doing, how it defines inputs for different object types, and then understand that specific object type (which I assume is the sketch primitive), and then implement it

view this post on Zulip Sean (Mar 02 2021 at 06:42):

This might help: https://brlcad.org/wiki/Sketch

view this post on Zulip Debkamal Mullick (Mar 02 2021 at 06:44):

okay. I am studying the typein.c file

view this post on Zulip Debkamal Mullick (Mar 02 2021 at 15:01):

Thank you for the previous explanation. I had a query about what the declarations ending with "_t" (eg, fastf_t, vect_t, size_t ) are. These declarations are in several parts of the codebase.

view this post on Zulip Sean (Mar 02 2021 at 15:07):

@Debkamal Mullick nearly all types are in the top-level include/ directory or a subdirectory in there. If you search in those folders with typedef, you can find them easily. for example, fastf_t and vect_t are both in include/vmath.h

view this post on Zulip Sean (Mar 02 2021 at 15:07):

fastf_t is basically a double (usually), and vect_t is a double[4] (usually)

view this post on Zulip Debkamal Mullick (Mar 02 2021 at 15:13):

ok thanks

view this post on Zulip Sean (Mar 03 2021 at 05:44):

any progress @Debkamal Mullick ?

view this post on Zulip Debkamal Mullick (Mar 03 2021 at 05:54):

I have understood the structure but I cannot understand the values assigned to the variable "nvals" for different primitives

view this post on Zulip Debkamal Mullick (Mar 03 2021 at 06:18):

From what I understood, I will need to add

1) static const char *p_sketch[ ] ={

/* list of instructions for inserting sketch primitive*/

}

2) static int sketch_in(struct ged *gedp, const char **cmd_argvs, struct rt_db_internal *intern){

/* code for taking the input parameters for the sketch primitive*/

}

And finally in the " int ged_in_core(struct ged *gedp, int argc, const char *argv[ ]){...} ", I need to add the if else condition for sketch primitive

view this post on Zulip Debkamal Mullick (Mar 03 2021 at 08:25):


Do the "nvals" control the mged input prompt messages?

view this post on Zulip Sean (Mar 04 2021 at 07:32):

@Debkamal Mullick They're different for every primitive, but it might help to start with one of the simplest ones like "sph" which makes a sphere.

view this post on Zulip Sean (Mar 04 2021 at 07:33):

but yes, the sort of control the input prompt. It tells it how many "instructions" as you put it there are, if memory serves correctly.

view this post on Zulip Sean (Mar 04 2021 at 07:35):

Your understanding in general looks about correct though. Make sure you actually run the "in" command in mged to see how it works. That will explain a lot. Just type "in whatever" to get started, then "in whatever sph" and you'll see how it starts asking the p_sph prompts.

view this post on Zulip Debkamal Mullick (Mar 04 2021 at 08:12):

Ok. With reference to the Sketch wiki page, will the sketch prompt be a 2 line prompt asking for
1) V, A, B
2) The entire code containing VL, SL, line, carc
3) Sketch created

Or will it be a complex one with prompts for VL, SL with a loop?

view this post on Zulip Debkamal Mullick (Mar 04 2021 at 08:20):

Thank you. I will try and understand the code for sphere primitive

view this post on Zulip Sean (Mar 04 2021 at 16:34):

@Debkamal Mullick it can be whatever you want it to be. It doesn't exist yet, so there's a design component here. The only limitation is that the end result needs to be deterministic. What I mean by that is say you have some data being provided that can be any length, like the VL vertex lists. You'll either need to have them be specified with a count, eg.:

in {name} {type} {entity} {count} {data}

like this:

in foo sketch VL 5 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3

where we say we're going to read 5 vertices.

OR

you let them be specified with labels one at a time and you aggregate internally, eg.:

in {name} {type} {entity} {data}

like this:

in foo sketch VL 1 2 3 VL 1 2 3 VL 1 2 3 VL 1 2 3 VL 1 2 3

view this post on Zulip Sean (Mar 04 2021 at 16:36):

The first is obviously more brief but potentially error-prone and requires calculating a value that may not exist (the count) but is derivable. The second is more verbose, but is more trivial & easy for users to adapt from existing data so that approach would probably be my preference.

view this post on Zulip Debkamal Mullick (Mar 04 2021 at 17:07):

Actually, it would be best if I knew what mged prompts should be there, that would be conforming to BRL-CAD standard formats. Basically the contents of p_sketch[ ].

For the code, can I refer to the line number 683 of :

https://sourceforge.net/p/brlcad/code/HEAD/tree/brlcad/trunk/src/libged/make/make.c

view this post on Zulip Sean (Mar 04 2021 at 17:13):

There is no standard format. It's different for every entity type.

view this post on Zulip Sean (Mar 04 2021 at 17:14):

Figuring out how to prompt it is essentially the task, or at least a useful task. If you want, write up your thoughts on the wiki page and we can iterate on the design...

view this post on Zulip Debkamal Mullick (Mar 04 2021 at 17:20):

Oh. Ok

view this post on Zulip Debkamal Mullick (Mar 04 2021 at 17:48):

Will beziers be also included in sketch other than line & carc?

view this post on Zulip Sean (Mar 05 2021 at 02:12):

Of course, they're a valid segment type.

view this post on Zulip Sean (Mar 05 2021 at 02:14):

you can submit this piecemeal though, you know just get the position (V), dimensional vectors (A and B), and vertices (VL) working first, then submit that as a patch. Then work on line segments, submit that as an update to the patch, etc.

view this post on Zulip Sean (Mar 05 2021 at 02:14):

will show how you iterate on feedback, make sure you don't make unnecessary work for yourself if there's a problem

view this post on Zulip Debkamal Mullick (Mar 05 2021 at 05:46):

Thank you for the explanation. Its a lot clearer now.

view this post on Zulip Debkamal Mullick (Mar 07 2021 at 08:58):

(deleted)

view this post on Zulip Debkamal Mullick (Mar 07 2021 at 10:23):

I added the code for sketch primitive and compiled. Compile was ok but mged crashes after taking in the 7th argument,ie, the number of vertices. The error is :

Segmentation fault (core dumped)

view this post on Zulip Sean (Mar 08 2021 at 15:47):

That means you have a mistake somewhere in there... you can try debugging it with print statements or (better) use a debugger like gdb or lldb (if you're on linux/mac) or you can debug using Visual Studio if you're on Windows.

view this post on Zulip Debkamal Mullick (Mar 09 2021 at 05:01):

ok


Last updated: Jan 10 2025 at 00:48 UTC