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?
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
This might help: https://brlcad.org/wiki/Sketch
okay. I am studying the typein.c file
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.
@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
fastf_t is basically a double (usually), and vect_t is a double[4] (usually)
ok thanks
any progress @Debkamal Mullick ?
I have understood the structure but I cannot understand the values assigned to the variable "nvals" for different primitives
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
Do the "nvals" control the mged input prompt messages?
@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.
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.
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.
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?
Thank you. I will try and understand the code for sphere primitive
@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
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.
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
There is no standard format. It's different for every entity type.
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...
Oh. Ok
Will beziers be also included in sketch other than line & carc?
Of course, they're a valid segment type.
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.
will show how you iterate on feedback, make sure you don't make unnecessary work for yourself if there's a problem
Thank you for the explanation. Its a lot clearer now.
(deleted)
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)
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.
ok
Last updated: Jan 10 2025 at 00:48 UTC