Stream: brlcad

Topic: NURBS editing


view this post on Zulip Neeraj Sharma (Mar 16 2023 at 04:13):

I am doing research on project NURBS Editing Support in BRL-CAD

view this post on Zulip Sean (Mar 16 2023 at 04:13):

okay, so for that you don't really need to install anything, you just need to compile. the tools exist in the build tree and can be run from there on the command line

view this post on Zulip Sean (Mar 16 2023 at 04:15):

the primary GUIs of the main repo are called MGED and Archer in src/mged and src/archer respectively. there's also other experimental GUI work in src/qged and in another separate repository called arbalest

view this post on Zulip Sean (Mar 16 2023 at 04:15):

nurbs logic is in src/libbrep and src/other/ext/openNURBS, and all editing commands are in src/libged

view this post on Zulip Neeraj Sharma (Mar 16 2023 at 04:15):

yes I go through it

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

so for that project, you have to understand the code well enough to figure out a propopsal

view this post on Zulip Neeraj Sharma (Mar 16 2023 at 04:16):

ok first I will go through the code

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

but the general idea expected would probably be to first create basic editing commands (CLI) in src/libged which becomes command-line commands in mged and archer

view this post on Zulip Sean (Mar 16 2023 at 04:17):

then if you got that working, the next step would be to figure out what GUI to integrate that with, whether mged or archer or qged or arbalest

view this post on Zulip Neeraj Sharma (Mar 16 2023 at 05:42):

sir , figure out a whole code , that is hard for me

view this post on Zulip Himanshu (Mar 16 2023 at 05:55):

Sean said:

nurbs logic is in src/libbrep and src/other/ext/openNURBS, and all editing commands are in src/libged

Are you looking here for code, right? @Neeraj Sharma

view this post on Zulip Neeraj Sharma (Mar 16 2023 at 05:57):

Himanshu Sekhar Nayak said:

Sean said:

nurbs logic is in src/libbrep and src/other/ext/openNURBS, and all editing commands are in src/libged

Are you looking here for code, right? Neeraj Sharma

yes sir

view this post on Zulip Neeraj Sharma (Mar 16 2023 at 09:12):

Neeraj Sharma said:

Himanshu Sekhar Nayak said:

Sean said:

nurbs logic is in src/libbrep and src/other/ext/openNURBS, and all editing commands are in src/libged

Are you looking here for code, right? Neeraj Sharma

yes sir

so any other option for familiar with the NUBRS base code

view this post on Zulip Sean (Mar 16 2023 at 18:26):

There's not a better option than reading the code as that is the latest status of the implementation, but there are certainly books and websites that explain what NURBS are and how to work with them. There IS a NURBS development guide in BRL-CAD, but that's not particularly relevant for editing -- still you can see it in doc/docbook/devguides/bool_eval_development.xml

view this post on Zulip Neeraj Sharma (Mar 17 2023 at 08:55):

Sean said:

There's not a better option than reading the code as that is the latest status of the implementation, but there are certainly books and websites that explain what NURBS are and how to work with them. There IS a NURBS development guide in BRL-CAD, but that's not particularly relevant for editing -- still you can see it in doc/docbook/devguides/bool_eval_development.xml

can you exactly share location ,where the base code of implementing of NURBS

view this post on Zulip GregoryLi (Mar 18 2023 at 03:45):

Neeraj Sharma said:

Sean said:

There's not a better option than reading the code as that is the latest status of the implementation, but there are certainly books and websites that explain what NURBS are and how to work with them. There IS a NURBS development guide in BRL-CAD, but that's not particularly relevant for editing -- still you can see it in doc/docbook/devguides/bool_eval_development.xml

can you exactly share location ,where the base code of implementing of NURBS

  1. learn curves: bezier curve -> B-Spline curve -> rational B-Spline curve
  2. learn surface: bezier surface -> B-Spline surface -> rational B-Spline surface
    I think as long as you are familar with "tensor product" "control points" "knot vector" "homogeneous coordinates", you get the basics of NURBS. One week is enough to achieve it and shorter if you have a foundation. :smile:

view this post on Zulip Sean (Mar 18 2023 at 03:59):

Neeraj Sharma said:

can you exactly share location ,where the base code of implementing of NURBS

The location information was already provided earlier the first time you asked where -- it's a lot of code spanning multiple directories and those directories were itemized. Honestly if that wasn't enough information, then you may be attempting to propose a topic far too complex for your abilities. NURBS is an advanced topic. I would suggest focusing on a different project proposal that is a bit easier to navigate.

view this post on Zulip Notification Bot (Mar 18 2023 at 04:00):

17 messages were moved here from #general > Compiling BRL-CAD by Sean.

view this post on Zulip Sean (Mar 18 2023 at 04:01):

I also moved this topic thread since you had hijacked the thread about compiling BRL-CAD with unrelated discussion about NURBS. Both remain accessible.

view this post on Zulip Neeraj Sharma (Mar 18 2023 at 04:15):

Sean said:

Neeraj Sharma said:

can you exactly share location ,where the base code of implementing of NURBS

The location information was already provided earlier the first time you asked where -- it's a lot of code spanning multiple directories and those directories were itemized. Honestly if that wasn't enough information, then you may be attempting to propose a topic far too complex for your abilities. NURBS is an advanced topic. I would suggest focusing on a different project proposal that is a bit easier to navigate.

BRLCAD issue section contain the project list or there another list of projects
can you tell me easier project or all project list those are mentioned in GSOC'23

view this post on Zulip Sean (Mar 18 2023 at 04:20):

All the project ideas have a difficulty rating.

view this post on Zulip Sean (Mar 18 2023 at 04:20):

They're all listed at https://github.com/opencax/GSoC/issues?q=is%3Aopen+sort%3Aupdated-desc+label%3A%22GSoC+2023%22+label%3A%22Project%3A+BRL-CAD%22

view this post on Zulip Sean (Mar 18 2023 at 04:21):

We're an umbrella org, so each project has a separate list: https://opencax.github.io

view this post on Zulip GregoryLi (Mar 20 2023 at 10:14):

I'm wondering how do we use NURBS editing operations? I have not find how to create a NURBS curve or surface directly in mged or archer. I see we can get the NURBS form of some primitives. Do we need additional cmd to create and modify NURBS directly?
I noticed some CAD software have a unique tool for creating NURBS.
image.png

view this post on Zulip GregoryLi (Mar 20 2023 at 10:24):

I don't understand what "wrapping the openNURBS library by a scripting language" means here NURBS Editing Support in BRL-CAD. Are commands of mged command form suffice? Or do we need to wrap it for other purposes?

view this post on Zulip Daniel Rossberg (Mar 20 2023 at 18:17):

GregoryLi said:

I have not find how to create a NURBS curve or surface directly in mged or archer.

That's the point: There is no such functionality. The only way to create (openNURBS) NURBS, is by importing Rhino files as BLOBs.

view this post on Zulip Daniel Rossberg (Mar 20 2023 at 18:28):

GregoryLi said:

I don't understand what "wrapping the openNURBS library by a scripting language" means here NURBS Editing Support in BRL-CAD. Are commands of mged command form suffice? Or do we need to wrap it for other purposes?

The mged commands trigger functions in libged, which call functions in other libraries. So, the "other purposes" could do something similar than the function in libged. I.e., it would be sufficient to implement it up to the libged TCL hooks.

BTW, the main primitive creation command is in, implemented in src/libged/typein/typein.c.

view this post on Zulip GregoryLi (Mar 21 2023 at 01:25):

Daniel Rossberg said:

GregoryLi said:

I have not find how to create a NURBS curve or surface directly in mged or archer.

That's the point: There is no such functionality. The only way to create (openNURBS) NURBS, is by importing Rhino files as BLOBs.

OK, I think create NURBS curve & surface using mged command is be a good target to start with.

view this post on Zulip Sean (Mar 21 2023 at 05:48):

@GregoryLi Nearly all of BRL-CAD's non-NURBS implicit solids (e.g., ell, torus, arb8, tgc, etc) have function implementations that express them in NURBS form (like in your screenshot they show torus and some other starter shapes in addition to curve and surface creation). It's the rt__brep() callback which you can see in all the src/librt/primitives//*.cpp subdir files. As mentioned, conversion is one current way to get NURBS brep entities, but also a way is the mged "brep" command. That converts an existing solid into a brep solid.

view this post on Zulip Sean (Mar 21 2023 at 05:52):

That said, you're on the right track thinking about how to create them first. That's why I mentioned src/proc-db/brep_simple.cpp and friends where you can see examples how they're created in code, one curve, edge, trim, and surface at a time.

view this post on Zulip GregoryLi (Mar 23 2023 at 02:26):

I created one cylindrical side in proc-db.
image.png

view this post on Zulip GregoryLi (Mar 23 2023 at 02:32):

I noticed we have bspline_brep.cpp in librt/primitives/bspline, but it seems we have no corresponding option of in command. Maybe we should call the function through in command to create NURBS?

view this post on Zulip Sean (Mar 23 2023 at 07:08):

@GregoryLi Note that there are two boundary representation implementations in librt. One is the 'bspline' entity and the other is the 'brep' entity. What you're looking at there is the older bspline which implements boundaries by defining bspline patches. It works, but it's a slow 1980's approach and yes it also lacks an 'in' interface. The 'brep' entity (see src/librt/primitives/brep and src/other/ext/openNURBS) is the modern approach.

view this post on Zulip Sean (Mar 23 2023 at 07:09):

There's very likely code and algorithms in 'bspline' that should/could be migrated to 'brep', particularly for boolean evaluation, but the datastructures are different so any utilization will require some work.

view this post on Zulip GregoryLi (Mar 23 2023 at 11:53):

Yeah, I'm trying to generate the 'brep' form NURBS surface. I think the difference is that 'brep' form need to create vertex, curve, edge, trim compared to 'bspline' form. Am I right?

view this post on Zulip GregoryLi (Mar 23 2023 at 11:59):

Besides, I find one possible problem... If a 'brep' object have a edge which is a loop in Cartesian space but not a loop topologically, the 'brep' is not valid(b->IsValid()=false). And the code belongs to openNURBS. Just like the cylindrical side.
image.png

view this post on Zulip Sean (Mar 23 2023 at 15:34):

GregoryLi said:

Yeah, I'm trying to generate the 'brep' form NURBS surface. I think the difference is that 'brep' form need to create vertex, curve, edge, trim compared to 'bspline' form. Am I right?

Well the API is different because 'brep' uses the openNURBS API. They both create parametric surfaces that are stitched together with vertices, curves, and edges. 'bspline' doesn't to trimming curves whereas 'brep' does use trimming curves is probably the biggest practical difference in construction.

view this post on Zulip Sean (Mar 23 2023 at 15:36):

somewhere in the code is a function that converts a bspline to a brep. I think that might even be what I did to fix ray tracing for bspline. The only reason the bspline code is still there is for reading/writing old .g files with them and as a reference if there are functions in there that might be useful for migrating to 'brep'

view this post on Zulip Sean (Mar 23 2023 at 15:40):

GregoryLi said:

Besides, I find one possible problem... If a 'brep' object have a edge which is a loop in Cartesian space but not a loop topologically, the 'brep' is not valid(b->IsValid()=false). And the code belongs to openNURBS. Just like the cylindrical side.
image.png

Yes the topological structure of brep can be valid/invalid and really unrelated to the geometric structure. It's our job to make sure they match and form a valid definition.

Your cylinder is a valid surface but is not a valid brep because it doesn't enclose a volume.

view this post on Zulip GregoryLi (Mar 24 2023 at 01:13):

Thanks! Very detailed and interesting distinction.

view this post on Zulip GregoryLi (Mar 25 2023 at 04:36):

@Sean I'm wondering if we wrap nurbs in brep format, what format should users edit them in?

For example, One user want to 'attach' two spline curves. So he/she should have two curve in brep format like curve1.brep and curve2.brep, then run mged command like attach curve1.brep curve2.brep [other parameters]. BRL-CAD core will check if curve1.brep and curve2.brep each owns a single curve. If not, the operation is illegal. Otherwise BRL-CAD core will perform attach operation. Am I right?

view this post on Zulip Sean (Mar 25 2023 at 04:53):

@GregoryLi you might have some misunderstanding. You're not "wrapping" nurbs in brep format. nurbs are defined using a boundary representation format so for all intents and purposes nurbs==brep. I also don't think it would make any sense to put curves into separate breps if the point is to join them. What you'd probably do is create a brep, add a curve to it, add another curve to it, join them.

view this post on Zulip Sean (Mar 25 2023 at 04:53):

Did you read the the src/proc-db/brep_simple.cpp ?

view this post on Zulip Sean (Mar 25 2023 at 04:54):

Run that and look at the model it produces in mged. Now imagine wanting to edit it in mged to move a vertex. What would that command look like. That's a first step.

view this post on Zulip Sean (Mar 25 2023 at 04:58):

Once you can move a vertex, then try moving an edge. After you can move a vertex and an edge, now what about moving a face. Figure out what that looks like from an editing perspective. Once you can move those pieces around, what about deleting a vertex, or deleting an edge, or even deleting a face? What about adding a vertex in the middle of an edge? What about the middle of a face? And so on... that's the general idea for building up a command that will let you do all of that in a user-friendly way.

view this post on Zulip Sean (Mar 25 2023 at 05:00):

Once you can do all that, how about generating that same brep_simple object on the command line.. figure out what that looks like.

view this post on Zulip Sean (Mar 25 2023 at 05:01):

At that point, you'll need to figure out how to deal with trimming curves, control points, and knot values too.

view this post on Zulip GregoryLi (Mar 25 2023 at 05:17):

Sean said:

Run that and look at the model it produces in mged. Now imagine wanting to edit it in mged to move a vertex. What would that command look like. That's a first step.

Yeah, I can imagine that. So what we want to do is editing nurbs that belongs to brep, not separate nurbs?

view this post on Zulip Sean (Mar 25 2023 at 14:01):

there are no separate nurbs... brep==nurbs

view this post on Zulip Sean (Mar 25 2023 at 14:03):

they're one in the same. so if we have a brep, we want to edit the "brep nurbs" structures it contains. we need the ability to add those structures to an empty or existing brep too (so we can manually create things like brep_simple does, but as a user).

view this post on Zulip GregoryLi (Mar 27 2023 at 11:20):

As far as my understanding from openNURBS, one brep contains curves, surfaces(geometry) and vertexes, edges, trims, loops, faces(topology) info, where curves and surfaces may be NURBS. So maybe a more precise description would be there is no separate NURBS, they shall be geometries of brep?

view this post on Zulip GregoryLi (Mar 27 2023 at 11:28):

I want to understand how to use NURBS editing operations from user perspective.
For operation like "move a vertex":

  1. users may select the vertex to be moved though command brep *.brep plot V * or other operation
  2. run command(to be developed) like MoveVertex [brep name] [vertexid] [position to be moved]

view this post on Zulip GregoryLi (Mar 27 2023 at 11:34):

For operation like "create and attach two spline curve":

  1. users may create one empty brep object
  2. run command(to be developed) like AddCurve [brep_name] [curve info] twice to add two spline curve into the brep object.
  3. run command(to be developed) like AttachSpline [brep name] [curveid_1] [curveid_2] to attach the two spline

view this post on Zulip GregoryLi (Mar 27 2023 at 11:49):

@Sean @Daniel Rossberg I looked though the structure of brep and how to create a brep object. And I'm trying to figure out how users use the NURBS editing. I checked blender and some other softwares and libs. I think our operating logic is different from theirs. They are editing one separate NURBS curve/surface directly. Am I right? :grinning_face_with_smiling_eyes:

view this post on Zulip Daniel Rossberg (Mar 27 2023 at 17:48):

I think, you are on the right way. The details depend on how the data is stored in openNURBS. Do the curves and/or points have an ID? Or just an index in an array? Etc..

What I had in mind, was a command like in myNurbs.s brep <parameters>. <parameters> being something like "[curve 1 info] u [curve 2 info] ...". I.e., the real task would be to draft a concept for [curve info] and implement it.

view this post on Zulip Daniel Rossberg (Mar 27 2023 at 17:52):

The task of editing NURBS is not important at this level/stage. E.g., at the lower level, a vertex doesn't need to be movable. It would be good too, if the curve, the vertex belongs to, could be replaced by another curve (with the vertex moved).

view this post on Zulip Daniel Rossberg (Mar 27 2023 at 17:53):

Then, it would be a task of the GUI, to take the original curve, move a vertex there, and replace the original curve with the changed one.

view this post on Zulip GregoryLi (Mar 28 2023 at 01:55):

Yeah, I think I get the point! I'm writing my proposal.

view this post on Zulip Ajay Pal (Mar 28 2023 at 05:07):

..

view this post on Zulip Sean (Mar 28 2023 at 06:05):

@GregoryLi you're on the right track thinking about what a CLI might look like. Editing can happen in a variety of ways as noted. Could be a write/overwrite/delete interface like daniel mentioned where you just replace entities with different entities the have the edit. Could propose a set of relevant subcommands to an existing command (e.g., "brep translate mybrep.edge[54] 100 0 0". Could be something hooked into the existing 'adjust' command. There are tradeoff considerations with all of them. You'd probably want to budget some time to study options during the bonding phase to finalize exactly what approach will be taken, but you should understand what those options are and explain them in your proposal so you can demonstrate you've thought about this some.

view this post on Zulip GregoryLi (Mar 29 2023 at 02:52):

@Sean @Daniel Rossberg What's the difference between 'attach' and 'connect' two NURBS curve? I can imagine two cases:

  1. generate one spline curve after operation. Just like ConcatNC in Ayam
  2. get two spline curve share some control vertexes. This is strange..

view this post on Zulip GregoryLi (Mar 29 2023 at 03:10):

The points/curves/surface only have an index in an array of brep, without a name. So it is not easy to perform nurbs editing operations for users. They should find the index by drawing and NURBS operation will change the index.

view this post on Zulip GregoryLi (Mar 29 2023 at 03:10):

And I'm thinking about if it's proper to do NURBS operation in brep. For example, we have a cube 'brep' in brep format, and we just perform 'trim' operation on one edge curve or 'connect' two edge curve. This will make the 'brep' object irregular(mass up topology and relationship between topology and geometry entities of the cube). Shall we check if the operation is legal to keep some property of the brep valid?

view this post on Zulip GregoryLi (Mar 29 2023 at 07:34):

I'm a bit confused about the definition and implementation of some operations.

view this post on Zulip GregoryLi (Mar 29 2023 at 07:35):

  1. the first one is 'attach' and 'connect' for NURBS curve.

view this post on Zulip GregoryLi (Mar 29 2023 at 07:43):

  1. projection for curve to surface operation
    Is it accessable for users? As its usage tells, maybe it shall be a function in libbrep core for viewing.
    How to achieve it? My understanding is that this function will get projection(planar spline curve format) of the selected spline curve onto a plane. We can sample points on the curve, perform raytracing to get the projection points on the plane, then fit 2D curve on the plane.

view this post on Zulip GregoryLi (Mar 29 2023 at 07:50):

  1. Rebuild/Simplify(remove unnecessary control points) function in surface operations
    I don't know what it refers to. Does it mean decrease order/coarsen of the surface within a tolerance value or discard the trimmed part?

view this post on Zulip GregoryLi (Mar 29 2023 at 07:56):

  1. Trim (evaluate to untrimmed) in surface operations
    Does it mean split surface into two spline surface or trim like Ayam trim? For the latter, I think it's not easy to implement.

view this post on Zulip Daniel Rossberg (Mar 29 2023 at 18:24):

I had hoped that you would tell me that :wink:
I didn't looked at the openNURBS/brep internals yet.

view this post on Zulip GregoryLi (Mar 30 2023 at 06:11):

I thought we have a detailed description and goal about operations in NURBS Editing Support.:sweat_smile:
It's okay if not! I think the operations may not be limited to the wiki, we need NURBS editing operations just like any other lib such as Ayam and Blender. I have describled these NURBS editing operations in detail and hope to extend the operations as one part of my proposal. My proposal will be relatively long, so I will send out the first half of it as soon as possible to discuss with you.

view this post on Zulip Sean (Mar 30 2023 at 07:23):

GregoryLi said:

I'm a bit confused about the definition and implementation of some operations.

you can certainly propose changing what was written up on the wiki. I think it's mostly taking a very low-level approach of operations that could be performed on specified curves and surfaces, but it's certainly not the only approach possible.

view this post on Zulip Sean (Mar 30 2023 at 07:25):

I don't personally see operations #2 or #3 being important and #4 is a "nice to have" but not strictly necessary for editing either.

view this post on Zulip Sean (Mar 30 2023 at 07:26):

They won't/don't need to be limited to what's on the wiki. I think that was just envisioned as a potential starting point approach.

view this post on Zulip Sean (Mar 30 2023 at 07:32):

Myself, I would approach it the way I mentioned a few days ago. Assume you have the brep_simple object. Now make it so you can move any of the vertices, edges, or surfaces (maintaining connectivity/topology) of that cube. Once that's all working, and that'd likely take a month, then focus on creating that brep_simple cube on the command-line (however you can achieve that easily). That'd be basic construction and another month. With those two achieved, just about any edit operation should be possible and it stays focused on the end-user's perspective, not the data structure.

Basically keep it simple. Do the simplest things first like moving existing things around, and tackle the harder problems when nothing simpler remains.

view this post on Zulip GregoryLi (Mar 30 2023 at 09:06):

OK, I will start with simple operations like create, move vertices as you said. Think of the wiki as a borader suggestion.

view this post on Zulip GregoryLi (Mar 30 2023 at 09:09):

I give a detailed description about operations on wiki. I will update the wiki if my description meets our expectations about NURBS editing. detailed description

view this post on Zulip Daniel Rossberg (Mar 30 2023 at 09:45):

The most important point from the task description is for me:

The key-feature would be to have ged command(s) that lets you build NURBS objects from scratch. This could be done by having a declarative ASCII description of these entities and/or wrapping the openNURBS library by a scripting language.

It comes from the need to convert NURBS-like entities from another program. The project, this was part of, ended however some years ago. Nevertheless, I would like to have it, in case I need it again.

view this post on Zulip Daniel Rossberg (Mar 30 2023 at 09:49):

This can be read as "The key-feature would be to have a ged command that lets you build NURBS objects from scratch. This could be done by having a declarative ASCII description of these entities." too

view this post on Zulip GregoryLi (Mar 30 2023 at 11:27):

I can imagine two approaches, I think these are what we want to do.

  1. Create a primitive and turn it into brep format. Then modify geometry(vertices,curves,surfaces) and topology(trim,edge..) Just like make changes based on the blueprint.
  2. Make an empty brep, then add geometry and topology infomation into it.

view this post on Zulip GregoryLi (Mar 30 2023 at 11:30):

For #1, we have implemented the first half of it.

view this post on Zulip GregoryLi (Mar 30 2023 at 11:36):

So in general we need to create and modify geometry and topology of a brep using command line or interface. I hope I'm right.

view this post on Zulip Sean (Mar 31 2023 at 04:57):

Yes, I think what you've described is basically edit existing brep vs create brep from scratch. Both have strong use cases, and both are non-capabilities at the moment. Their need is far greater than higher level operations like lofting, fillets/bevels, reparameterization, etc.

view this post on Zulip GregoryLi (Apr 01 2023 at 02:29):

Hi, I have made a draft of my proposal. Please review my proposal :smile: @Sean @Daniel Rossberg
https://drive.google.com/file/d/1NUOx-cnQrl5c9-W_k8_a8bqZ7xmJxEpW/view?usp=sharing

view this post on Zulip GregoryLi (Apr 02 2023 at 01:23):

I think "brep editing" is a better name than "NURBS editing". Brep involves geometry and topology. NURBS is a part of geometry. What do you think?

view this post on Zulip Sean (Apr 02 2023 at 05:41):

while we call the entity "brep" and currently only store nurbs in them, boundary representation is a broad term and can refer to polygonal meshes, NURBS, sketches (but not extrudes), and a few others.

view this post on Zulip GregoryLi (Apr 02 2023 at 07:31):

Yeah, 'brep' is too broad for the project.

view this post on Zulip GregoryLi (Apr 02 2023 at 07:35):

I think some plot functions are needed to help users to select control vertex etc. Just like blender draw a control vertex mesh of NURBS surface.
image.png

view this post on Zulip GregoryLi (Apr 02 2023 at 13:40):

I updated my proposal with few changes. https://drive.google.com/file/d/1o5IfQQSHajEZSZsXUkGBWlmw7JZtjbJO/view?usp=sharing

view this post on Zulip GregoryLi (Apr 06 2023 at 07:48):

image.png image.png
I can move curves through cmd now. :grinning:

view this post on Zulip GregoryLi (Apr 06 2023 at 07:58):

I wrote this function by imitating _brep_cmd_flip. When we modify a brep object, we copy a new one ande delete the old object. I feel it's strange to do it this way. Won't this reduce efficiency?

view this post on Zulip Sean (Apr 24 2023 at 07:06):

@GregoryLi depends on the nature and size of the edit. a very large brep with lots of data will be inefficient, but whether that matters or is even noticeable by users remains to be seen. by doing the edit on a separate copy, that at least avoids a slew of validation code that'd be needed otherwise if/when an edit fails or cannot be applied.

view this post on Zulip Sean (Apr 24 2023 at 07:07):

worth noting that approach is also consistent with bot editing, which are typically as big or bigger than nurbs, with minimal impact.

view this post on Zulip Amanjot Singh (May 09 2023 at 16:41):

@GregoryLi Congratulations on getting selected in GSoC 2023. Looking forward to work with you :tada:

view this post on Zulip GregoryLi (May 10 2023 at 00:01):

Amanjot Singh said:

GregoryLi Congratulations on getting selected in GSoC 2023. Looking forward to work with you :tada:

thanks! I'm very excited to be selected :smile: I will check up the checklist :)

view this post on Zulip GregoryLi (May 10 2023 at 00:06):

I'm trying to create an empty brep using command line, but I can't access ON_brep in make.c. I can only access _on_brep_placeholder in include/brep/defines.h, a placeholder when compiling with a C compiler.

view this post on Zulip GregoryLi (May 10 2023 at 00:10):

Now I add a brep_create command. I can create an empty brep using "brep_create <brep_name>". But I think a subcommad of make like "make <brep_name> brep" is more suitable. Can you tell me what shall I do?

view this post on Zulip Daniel Rossberg (May 10 2023 at 07:46):

Did you had a look at libwdb? There is a brep.cpp with a mk_brep function. The low level database object creation functions should go to libwdb.

view this post on Zulip Daniel Rossberg (May 10 2023 at 08:03):

Regarding the methodology used in make.c: Maybe, you can use the NMGs in libnmg as a kind of template. E.g., there is a function nmg_mm(), which creates a new empty NMG. Can you do something similar in libbrep?

view this post on Zulip Sean (May 10 2023 at 21:39):

GregoryLi said:

I'm trying to create an empty brep using command line, but I can't access ON_brep in make.c. I can only access _on_brep_placeholder in include/brep/defines.h, a placeholder when compiling with a C compiler.

ON_brep is a C++ class, so any code that accesses, creates, inspects, or otherwise uses one needs to be from within a C++ source file. For C files, it resolves to a pointer placeholder that you can't do anything with.

view this post on Zulip Sean (May 10 2023 at 21:40):

Basically, add a new c++ file, and access code through C functions if you need to bridge to an existing C file like make.c

view this post on Zulip GregoryLi (May 12 2023 at 01:02):

I'm using mk_brep in my 'brep_create` command. I hope to call 'brep_create' command in 'make.c' using 'ged_exec()'. 'brep_create' command run but error occurs. I have checked and verified that all the parameters in 'brep_create' are correct.
Log info:

rt_db_cvt_to_external5(A_b):  ft_export5 failure
rt_db_put_internal5(A_b):  export failure

view this post on Zulip GregoryLi (May 12 2023 at 01:04):

Sean said:

Basically, add a new c++ file, and access code through C functions if you need to bridge to an existing C file like make.c

I'll try to make a bridge to call mk_brep function. Thanks!

view this post on Zulip GregoryLi (May 18 2023 at 10:11):

I tried two methods to call mk_brep, but both had problems.

view this post on Zulip GregoryLi (May 18 2023 at 10:19):

  1. I made a command to create an empty brep object: brep_create [brep_name] and it works well. Then I add a subcommand in make like make [brep_name] brep to call brep_create command using ged_exec().
    When I run make [brep_name] brep, I get this error message: Error: Database write failure. But if I add or delete any other object, the brep object occurs, which means it's created but didn't display.
    I am certain that the parameters passed in through direct calling and through invoking make [brep_name] brep are the same.

view this post on Zulip GregoryLi (May 18 2023 at 10:21):

  1. The second method is to call mk_brep() directly in make. The problem that appeared is exactly the same.

view this post on Zulip GregoryLi (May 18 2023 at 10:23):

@Sean @Daniel Rossberg @Amanjot Singh Where do you think the problem lies? Could it be due to the addition of locks or something similar in the make command?

view this post on Zulip Daniel Rossberg (May 18 2023 at 14:26):

Can you show us your code? Do you have a github account?

view this post on Zulip GregoryLi (May 19 2023 at 00:57):

Yes, it's quite simple. https://github.com/GregoryLi0/brlcad/commit/97dfd3b85f1dc68a23627fdcc4ae22c67b0db7ab

view this post on Zulip GregoryLi (May 19 2023 at 01:04):

For comparison, brep_craete command is here. https://github.com/BRL-CAD/brlcad/commit/4ac8818438ac0f3fbb2f830a22d89fc71ebfc093

view this post on Zulip Sean (May 19 2023 at 20:16):

@GregoryLi What's getting written to disk is &internal, which you don't set/initialize

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

It's also strange to me that you'd call wdb_dbopen().. I see that hyp is also calling that, but I think that's "a mistake" of sorts -- someone was being lazy and I think creating a memory issue (they don't call close).

view this post on Zulip Sean (May 19 2023 at 20:23):

You'll want to initialize the &internal like the other primitives. The only complication you have is that you need the pointer to the brep. I don't think you want to call mk_brep(). Probably better to make a function that returns a void* to the brep -- can make mk_brep() call that as well as in ged_make_core().

view this post on Zulip GregoryLi (May 23 2023 at 07:39):

Sean said:

You'll want to initialize the &internal like the other primitives. The only complication you have is that you need the pointer to the brep. I don't think you want to call mk_brep(). Probably better to make a function that returns a void* to the brep -- can make mk_brep() call that as well as in ged_make_core().

It works! Thanks :smiley:

view this post on Zulip GregoryLi (May 26 2023 at 05:09):

Now, I am able to create an empty BREP object and generate new curves within it. However, it should be noted that only a limited number of parameters can be configured now.

view this post on Zulip GregoryLi (May 26 2023 at 05:09):

2023-05-26_12-51.png

view this post on Zulip GregoryLi (May 26 2023 at 05:14):

I think users can input simple information such as the dimensions and degree of the curve using "brep [name] create_curve [curve_info]", while the specific information on controlling point positions could be set by other commands. You think it's a good idea?

view this post on Zulip GregoryLi (May 26 2023 at 05:18):

Well, I have researched some alternative libraries... NURBS-Python, blender-python requires lots of codes to create a curve.

view this post on Zulip GregoryLi (May 26 2023 at 05:21):

The Python script for creating nurbs curves in Blender is more concise.
image.png

view this post on Zulip GregoryLi (May 26 2023 at 05:24):

Btw, is there a plugin in VScode that can automatically format our code? The auto-formatting tool in VScode tends to mass up the existing code.

view this post on Zulip GregoryLi (Jun 04 2023 at 05:11):

@Daniel Rossberg Hi, I updated codes about make [name] brep. I created function brep_create_empty_brep() in libbrep to create rt_brep_internal.

view this post on Zulip GregoryLi (Jun 04 2023 at 05:11):

image.png

view this post on Zulip GregoryLi (Jun 04 2023 at 05:13):

It seems to be running well.

view this post on Zulip Daniel Rossberg (Jun 04 2023 at 14:48):

Nice :smile:

view this post on Zulip Daniel Rossberg (Jun 04 2023 at 15:09):

Some comments regarding your code:

view this post on Zulip Daniel Rossberg (Jun 04 2023 at 17:19):

I'm getting a compilation warning/error:

/home/rossberg/Devel/BRL-CAD/brlcad.GregoryLi0/src/libged/make/make.c:75:27: error: unused variable ‘brep_ip’ [-Werror=unused-variable]
   75 |  struct rt_brep_internal *brep_ip;
      |                           ^~~~~~~
cc1: all warnings being treated as errors

view this post on Zulip GregoryLi (Jun 05 2023 at 01:06):

Thanks! I will shorten the names of these functions and fix the error.

view this post on Zulip GregoryLi (Jun 05 2023 at 01:09):

And now I think brep_create() in libbrep should create an ON_Brep instead of rt_brep_internal like other primitives in make.c.

view this post on Zulip GregoryLi (Jun 05 2023 at 10:39):

Does rt means ray tracing? I tracked boolean subcommand of brep, the function call stack is libged/_brep_cmd_boolean() librt/rt_brep_boolean()libbrep/ON_Boolean(). I'm not sure why we shall go through librt..

view this post on Zulip GregoryLi (Jun 05 2023 at 10:41):

@Daniel Rossberg I think the brep editing operations shall be implemented in libbrep, and we can access them directly in libged?

view this post on Zulip Daniel Rossberg (Jun 05 2023 at 17:57):

GregoryLi said:

Does rt means ray tracing? I tracked boolean subcommand of brep, the function call stack is libged/_brep_cmd_boolean() librt/rt_brep_boolean()libbrep/ON_Boolean(). I'm not sure why we shall go through librt..

rt stands for "ray-trace", and it is the prefix of librt's symbols. The point is that both the librt ray-tracing as well as the libged brep bool sub-command need the functionality in rt_brep_boolean(). See the comment for the include of this function in src/libged/brep/brep.c: librt may not be the final place/rt_brep_boolean not the final name of this function.

However, editing the breps (NURBS) is not directly connected with ray-tracing, and the low level code should go to libbrep, where it can be accessed from libged.

view this post on Zulip GregoryLi (Jun 07 2023 at 06:14):

Yeah, thanks. Now the development is going well, slightly ahead of schedule.

view this post on Zulip GregoryLi (Jun 24 2023 at 04:16):

@Daniel Rossberg Hi, I have just submitted the PR for Milestone 1 as schedule. (https://github.com/BRL-CAD/brlcad/pull/80). Let me know if you have any feedback, suggestions, or questions :)

view this post on Zulip GregoryLi (Jun 24 2023 at 04:18):

Actually, some of the tasks for Milestone 2 have already been completed. I'm planning to conduct further research and define the required function functionalities.

view this post on Zulip Daniel Rossberg (Jun 24 2023 at 16:35):

Do you have some examples and/or advice about how to test the new features?

view this post on Zulip GregoryLi (Jun 25 2023 at 00:37):

I will write a shell script to test them, as well as change my code styles.

view this post on Zulip GregoryLi (Jun 25 2023 at 02:52):

brep_curve_edit.sh
brep_surface_edit.sh
I made two shell scripts to perfrom curves & surfaces operations. You can also execute these commands step by step and monitor the changes in data using the "brep .. info" command. @Daniel Rossberg

view this post on Zulip Daniel Rossberg (Jun 25 2023 at 17:05):

@GregoryLi, please, consider my comment on https://github.com/BRL-CAD/brlcad/pull/80 too.

view this post on Zulip Daniel Rossberg (Jun 25 2023 at 17:49):

I see :smile:
Screenshot.png

view this post on Zulip GregoryLi (Jun 26 2023 at 00:49):

Yes, I'm checking and modifying my codes.

view this post on Zulip Daniel Rossberg (Jun 27 2023 at 06:52):

Thanks, I saw your modifications. I may need however some days to review them...

view this post on Zulip GregoryLi (Jun 27 2023 at 07:43):

That's alright :) I'm now implementing local cubic curve interpolation, to support functions like InterpCrv in Rhino.

view this post on Zulip Sean (Jul 09 2023 at 23:19):

@GregoryLi can you show me an example for making a brep cone?

view this post on Zulip GregoryLi (Jul 10 2023 at 00:25):

(deleted)

view this post on Zulip GregoryLi (Jul 10 2023 at 00:26):

Sean said:

GregoryLi can you show me an example for making a brep cone?

I'm currently unable to create a brep cone using the mged command. While NURBS curve/surface editing operations are now supported, topology operations are not yet supported. I can make it by cpp code.

view this post on Zulip GregoryLi (Jul 10 2023 at 00:34):

The topology modification function belongs to milestone3(July 25 - August 21) in the schedule. But the current progress is about one week ahead of schedule,I plan to handle topology operations after writing the NURBS editing operation documentation.

view this post on Zulip GregoryLi (Jul 10 2023 at 00:44):

And I am also considering and looking at other software about brep operations. I think it is inappropriate to wrap all NURBS operations into mged command lines for users. Maybe the topology operations shall be implicitly included in. For example:
If we want to make a cylinder by a circle and a line. We can run 'extrude' cmd. Topology operations are implicitly included in.

view this post on Zulip GregoryLi (Jul 25 2023 at 01:53):

Hi, I was one week away to join a meeting :) The current project schedule and timeline are aligned. I'm going to submit PR of Milestone 2 this weekend. PR 2 includes advanced NURBS geometry operations: curve/surface interpolation, create surface by tensor product and rotating a curve.

view this post on Zulip GregoryLi (Jul 30 2023 at 11:26):

There are still some issues with the last feature Surface interpolation. I want to achieve higher continuity with fewer control points following The NURBS Book. This is quite different with the already realized local curve interpolation. I do apologize for being confused by the complexity of the math formula. :face_with_spiral_eyes:
I should need another two or three days to implement it and prepare PR2.

view this post on Zulip Daniel Rossberg (Jul 30 2023 at 17:26):

This can happen that problems turn out to be harder than expected. And, NURBS have some heavy math. Therefore, thanks for letting us know. I'm optimistic that you will overcome the difficulties. A few day more doesn't matter there.

view this post on Zulip GregoryLi (Aug 01 2023 at 08:00):

Hi, I just submit PR of milestone 2 :). https://github.com/BRL-CAD/brlcad/pull/92
There are some potential threats to the ''remove'' operation now as my comment in github PR.

view this post on Zulip GregoryLi (Aug 01 2023 at 08:00):

brep_curve_edit.sh
brep_surface_edit.sh
Here are two shell script to test new features of milestone 2.

view this post on Zulip GregoryLi (Aug 07 2023 at 16:08):

Hi Daniel, I'm working on the issues you pointed out. But I didn't have the environment to compile the code until the day after tomorrow. Sorry about that :(

view this post on Zulip Sean (Aug 10 2023 at 23:04):

GregoryLi said:

The topology modification function belongs to milestone3(July 25 - August 21) in the schedule. But the current progress is about one week ahead of schedule,I plan to handle topology operations after writing the NURBS editing operation documentation.

How's the topology operations coming along? :)

view this post on Zulip GregoryLi (Aug 11 2023 at 13:15):

@Sean I've been working with Daniel on the PR2 merge recently. It's about a week or two behind schedule.

view this post on Zulip GregoryLi (Aug 11 2023 at 13:17):

Regarding the topology operations, I was able to and plan to simply wrap topology operations into command line operations, although these commands will look very weird and require a lot of parameters.

view this post on Zulip GregoryLi (Aug 11 2023 at 13:17):

I had previously planned to make the topology operations implicit in the higher order operations. For example, having a line rotate around an axis while encapsulating the top and bottom sides and establishing topological relationships. But these operations are not very popular. So I am wrapping the basic topological operations in the command line.

view this post on Zulip Sean (Aug 18 2023 at 07:40):

Yeah, I don't think you should focus on anything higher order, without something low-level in place first. I mean a really basic goal should be creating a sphere from one surface and/or creating a tetra, box, or sphere from multiple surfaces.

view this post on Zulip Sean (Aug 18 2023 at 08:19):

Doesn't matter if it's verbose or not. I think the subcommand structure you have is probably halfway there already. For example, could be something like this:

brep mycube create
brep mycube create_surface -name bottom -u 1 -v 1 -control_points "0,0,0 1,0,0 0,1,0 1,1,0" -weights "1 1 1 1" -knots_u "0 1" -knots_v "0 1"
brep mycube create_surface -name top -u 1 -v 1 -control_points "0,0,1 1,0,1 0,1,1 1,1,1" -weights "1 1 1 1" -knots_u "0 1" -knots_v "0 1"
brep mycube create_surface -name left -u 1 -v 1 -control_points "0,0,0 0,0,1 0,1,0 0,1,1" -weights "1 1 1 1" -knots_u "0 1" -knots_v "0 1"
brep mycube create_surface -name right -u 1 -v 1 -control_points "1,0,0 1,0,1 1,1,0 1,1,1" -weights "1 1 1 1" -knots_u "0 1" -knots_v "0 1"
brep mycube create_surface -name front -u 1 -v 1 -control_points "0,0,0 1,0,0 0,0,1 1,0,1" -weights "1 1 1 1" -knots_u "0 1" -knots_v "0 1"
brep mycube create_surface -name back -u 1 -v 1 -control_points "0,1,0 1,1,0 0,1,1 1,1,1" -weights "1 1 1 1" -knots_u "0 1" -knots_v "0 1"

# some command that figures out topology automatically
brep mycube sew_surfaces -surfaces "bottom,top,left,right,front,back"

Or a diff entirely manual approach with indices:

brep mycube add_point 0 0 0    # Point 0
brep mycube add_point 1 0 0    # Point 1
brep mycube add_point 0 1 0    # Point 2
brep mycube add_point 1 1 0    # Point 3
brep mycube add_point 0 0 1    # Point 4
brep mycube add_point 1 0 1    # Point 5
brep mycube add_point 0 1 1    # Point 6
brep mycube add_point 1 1 1    # Point 7
brep mycube create_edge 0 1   # Edge 0
brep mycube create_edge 2 3   # Edge 1
brep mycube create_edge 4 5   # Edge 2
brep mycube create_edge 6 7   # Edge 3
...
brep mycube create_surface -u 1 -v 1 -points "0,1,2,3"  # Surface 0
brep mycube create_surface -u 1 -v 1 -points "4,5,6,7"  # Surface 1
brep mycube create_surface -u 1 -v 1 -points "0,4,2,6"  # Surface 2
brep mycube create_surface -u 1 -v 1 -points "1,5,3,7"  # Surface 3
brep mycube create_surface -u 1 -v 1 -points "0,4,1,5"  # Surface 4
brep mycube create_surface -u 1 -v 1 -points "2,6,3,7"  # Surface 5

brep mycube create_face -surface 0 -edges "0,1,2,3" # Face 0
brep mycube create_face -surface 1 -edges "0,1,2,3" # Face 1
brep mycube create_face -surface 2 -edges "0,1,2,3" # Face 2
brep mycube create_face -surface 3 -edges "0,1,2,3" # Face 3
brep mycube create_face -surface 4 -edges "0,1,2,3" # Face 4
brep mycube create_face -surface 5 -edges "0,1,2,3" # Face 5

brep mycube assemble -faces "0,1,2,3,4,5"

view this post on Zulip GregoryLi (Aug 18 2023 at 15:25):

Yeah, I can create a geometry face and indicates its topology info using mged commands just now. Although the topology commands seems not easy to use. For example, you have to type in edge ids and if they shall be flipped or not.

view this post on Zulip GregoryLi (Aug 18 2023 at 15:29):

I plan to implement geometrical and topological representation for the polyhedron within a week. And I need to rearrange the geometry and topology editing operations.

view this post on Zulip GregoryLi (Aug 23 2023 at 14:52):

image.png
image.png
Hi, I'm able to create valid brep object though mged commands with shell scripts, and I rearranged brep editing operations into geometry and topology two parts.

view this post on Zulip GregoryLi (Aug 23 2023 at 14:52):

image.png
image.png

view this post on Zulip GregoryLi (Aug 23 2023 at 14:56):

I'm preparing for my final submission and list possible problems and areas that need to be developed. I expect to be able to continue to contribute to this module :)

view this post on Zulip GregoryLi (Aug 24 2023 at 13:55):

Hi, I just committed my PR of milestone 3. (https://github.com/BRL-CAD/brlcad/pull/97)

view this post on Zulip GregoryLi (Aug 24 2023 at 13:56):

seven_eighths_cube.sh
triangular_prism.sh
These are the shell scripts that reproduce the above test cases.

view this post on Zulip Daniel Rossberg (Aug 24 2023 at 15:08):

:+1: I'll have a look at it :smile:

view this post on Zulip Daniel Rossberg (Aug 26 2023 at 16:10):

After creating faces with brep brep_t topo f_create I'm getting

face 0 is not valid, skippingface 1 is not valid, skippingface 2 is not valid, skippingface 3 is not valid, skippingface 4 is not valid, skipping

with brep brep_t plot F. Is this expected?

view this post on Zulip GregoryLi (Aug 29 2023 at 00:31):

A face is invalid if it does not have a valid loop. So this is expected.

view this post on Zulip Sean (Aug 30 2023 at 03:41):

@GregoryLi so why are the loops not valid? the count of them appears to be correct. are they not going in the right directions?

view this post on Zulip GregoryLi (Aug 30 2023 at 03:50):

Did you get the logs running the shell scripts?

view this post on Zulip GregoryLi (Aug 30 2023 at 03:51):

A loop is valid if the edges of the loop are connected to form a circle.

view this post on Zulip GregoryLi (Aug 30 2023 at 03:58):

That means, if we want to get a valid face, we need to:

  1. Create a geometry surface
  2. Create several geometry vertices on the surface
  3. Create several geometry 3D curves on the surface to connect the vertices
  4. Create several geometry 2D curves on the parameter space of the surface. The parameter curves correspond to geometric curves in 3D space.
  5. Create the topology face of the surface
  6. Create a topology loop on the face
  7. Create and add topology trims to the loop, using geometry curves and parameter curves
    If every step is correct, the face is valid.

view this post on Zulip GregoryLi (Aug 30 2023 at 04:00):

After creating faces with brep brep_t topo f_create I'm getting

face 0 is not valid, skippingface 1 is not valid, skippingface 2 is not valid, skippingface 3 is not valid, skippingface 4 is not valid, skipping

with brep brep_t plot F. Is this expected?

I think that this operation is only up to step 5, it hasn't created a VALID loop on the face yet

view this post on Zulip Daniel Rossberg (Sep 01 2023 at 17:33):

Hi @GregoryLi, please add links to your pull requests to https://brlcad.org/wiki/User:GregoryLi/GSoC2023/DevLog. Otherwise, I cannot confirm that the link points to your work.

view this post on Zulip GregoryLi (Sep 02 2023 at 02:43):

Thanks! I have attached PR links to the DevLog, and wrote a final report here. I will continue to refine the future expectations of brep operations.

view this post on Zulip GregoryLi (Sep 05 2023 at 00:05):

Hi @Daniel Rossberg @Sean, thank you very much for your guidance! I have received the Final Evaluation. I will keep contributing to BRL-CAD :grinning:

view this post on Zulip GregoryLi (Sep 05 2023 at 00:12):

My next step is NURBS editing using surface-surface intersection. For brep entities with NURBS surfaces, manually inputting all the geometric and topologic objects is quite hard. Getting those objects through surface-surface-intersection will help a lot.

view this post on Zulip Daniel Rossberg (Sep 05 2023 at 09:29):

The ability to create and modify NURBS makes BRL-CAD much more powerful. Therefore, thank you Gregory :smiley:

view this post on Zulip GregoryLi (Oct 03 2023 at 08:30):

Hi, I created lots of test shell scripts for NURBS editing. I think they can be used over time. Do you think they should be uploaded? What directory do you think they should be uploaded to? @Daniel Rossberg @Sean

view this post on Zulip GregoryLi (Oct 03 2023 at 08:32):

By the way, I'm adding the Surface-Surface intersection function to the NURBS editing module.

view this post on Zulip Daniel Rossberg (Oct 04 2023 at 17:07):

GregoryLi said:

Hi, I created lots of test shell scripts for NURBS editing. I think they can be used over time. Do you think they should be uploaded? What directory do you think they should be uploaded to? Daniel Rossberg Sean

They should definitely be saved somewhere. What came into my mind is src/libbrep/tests/tcl. If the scripts are a good how-to for NURBS editing, https://brlcad.org/wiki/NURBS would be possible too.

view this post on Zulip GregoryLi (Oct 09 2023 at 08:49):

I found “brep .. intersect .. SS” crashes. the dplot object is nullptr while running. If you want to reproduce the problem, you can simply run:

make b brep
brep b geo c3_create
brep b geo c3_in 0 3 3  0 1 0  1 0 0  2 1 0
brep b geo c3_in 0 3 3  1 1 -1  1 1.5 0  1 1 1
brep b geo s_tensor 0 1
brep b geo s_tensor 2 1
brep b intersect b 0 1 SS

view this post on Zulip GregoryLi (Oct 09 2023 at 08:51):

I solved it here: https://github.com/GregoryLi0/brlcad/commit/6705abd669be63adfddbeb61f9d32980b7f929de
image.png


Last updated: Oct 09 2024 at 00:44 UTC