Difference between revisions of "User:Phoenix/GSoc2013/Proposal"

From BRL-CAD
(Calculating surface-surface intersection curves)
(Split the surfaces and generate new trimmed sub-surfaces using intersection curves)
Line 38: Line 38:
  
 
== Split the surfaces and generate new trimmed sub-surfaces using intersection curves ==
 
== Split the surfaces and generate new trimmed sub-surfaces using intersection curves ==
 +
The code in the function split_trimmed_face in src/librt/primitives/brep/brep.cpp currently works on this, but it's just a scratched draft worked out last summer. (I think there should be an independent file containing the NURBS evaluating code)
 +
 +
The paper [2] gives us a good direction on how to do this. We get intersection curves in 2D uv spaces in the first part, and a NURBS surface in a 2D uv space is much simpler than in the 3D space. Trimming curves are also 2D curves.

Revision as of 10:33, 16 April 2013

Project title

NURBS Intersection & Evaluation

Brief summary

Last summer I tried to do something on NURBS surface-surface intersection for BRL-CAD, but due to the limitation of time I cannot completely finish this project. I have implemented a routine to compute the intersection curves of two NURBS surfaces, and in general cases it works well, but some improvement are still needed. And the remaining part was done in a rush, with lots of features still missing. So in this summer, I would like to continue to work on this project, finishing the remaining parts, and finally offer a routine to convert CSG combination objects to evaluated NURBS objects. The work includes but is not limited to: (1) improve the current SSI routine to deal with special cases; (2) split the surfaces with the intersection curves we get in (1); (3) combine the new trimmed faces to get a new evaluated model. If there's still some time remaining, I will tried some other interesting topics, like NURBS editing in mged/archer, or anything that have great priority in BRL-CAD.

Detailed description

Introduction

NURBS surface-surface intersection is still a high-priority project in BRL-CAD. NURBS is a dominant geometric representation format in CADs, so we need to have enough support for it in BRL-CAD. Currently most objects in BRL-CAD are modeled in CSG, when converted to NURBS representations, the primitives are first converted to NURBS primitives, which BRL-CAD supports, but the next step is missing - evaluate the boolean operations on NURBS primitives, and then get a evaluated NURBS combination as the original CSG combination object. Currently BRL-CAD only gives ``CSG tree + unevaluated NURBS primitives", so we need NURBS intersections and evaluations.

Below is my detailed proposal for this summer's project. In the first part, I'd like to mention the current status of this part left out last summer. Then I list my plan on how to implement the remaining parts, dividing into three parts. In addition, something I want to do if I have additional time will be listed. At last, I'd like to show you the schedule and what I have already done this year about this project.

The current status of NURBS intersections & evaluations

Last year I spent about a month on NURBS intersections after I almost finished the Implicit to NURBS conversion project. I implemented a surface-surface intersection routine, using the sub-division method referred in a paper [1]. Now it can give us the intersection curves of two NURBS surfaces in both 3D spaces and 2D uv spaces. If the two inputs are in good condition, the result is quite reasonable (For detailed information, please see my last year's development log, there will be some convincing figures). But when the two surfaces have some coincides, the routine may have problems, because it first calculates the intersection of surfaces' bounding boxes, and then use polylines to approximate the curves, however, in this case, we should get a surface, not some curves. And for some strange shaped surfaces, the accuracy of the output may be not ideal. (max_dis can be inputted manually to get a better result, but it's a burden for users)

And I also tried to calculate boolean operations on NURBS. I just focus on the union of two spheres, which is a well-conditioning problem, and tried to get a evaluated model which can pass the IsValid check offered by openNURBS, but failed. So this part only have many lines of code written, but doesn't have enough functionality, and lots of work ahead should be done.

Calculating surface-surface intersection curves

The function calculating NURBS surface-surface intersection curves is in /src/libbrep/opennurbs_ext.cpp:

int surface_surface_intersection(const ON_Surface* surfA, const ON_Surface* surfB, ON_SimpleArray<ON_NurbsCurve*> &intersect3d, ON_SimpleArray<ON_NurbsCurve*> &intersect_uv2d, ON_SimpleArray<ON_NurbsCurve*> &intersect_st2d, double max_dis, double)

Some improvements are still needed:

1) If we detect there are many intersection points that seems to form a surface, not just curves, that it seems that these may exist an intersection 'surface'. But finding out this is quite confusing, because that may be some cases where two surfaces have many intersection curves that are very close to each other, but they don't have anywhere coincide.

2) There should be some detection related to the two surfaces when merging polylines (the 3rd step of SSI), not just using the max_dis parameter. In some cases, there may be two segments that should be in one intersection curve have bigger distance than two segments that exists in two nearby intersection curves, but we tend to merge the latter two segments instead of the former, without that detection.

3) We should test more cases and find more problems in the intersection routine, and fix them to get better performance. For example, two surfaces have many parts that intersects, resulting in many strange-shaped intersection curves.

4) Some code re-factoring is needed, and comments should be added to make the code more readable.

Split the surfaces and generate new trimmed sub-surfaces using intersection curves

The code in the function split_trimmed_face in src/librt/primitives/brep/brep.cpp currently works on this, but it's just a scratched draft worked out last summer. (I think there should be an independent file containing the NURBS evaluating code)

The paper [2] gives us a good direction on how to do this. We get intersection curves in 2D uv spaces in the first part, and a NURBS surface in a 2D uv space is much simpler than in the 3D space. Trimming curves are also 2D curves.